‎2008 Feb 21 7:45 AM
hi experts
how to improve the perfomance of the following code.
IF counta <> 0.
LOOP AT itab_zdfkkwoh.
tmp_zdfkkwoh-abbel = itab_zdfkkwoh-abbel.
tmp_zdfkkwoh-opbel = itab_zdfkkwoh-opbel.
tmp_zdfkkwoh-opupw = itab_zdfkkwoh-opupw.
tmp_zdfkkwoh-opupk = itab_zdfkkwoh-opupk.
tmp_zdfkkwoh-opupz = itab_zdfkkwoh-opupz.
tmp_zdfkkwoh-bukrs = itab_zdfkkwoh-bukrs.
tmp_zdfkkwoh-gsber = itab_zdfkkwoh-gsber.
tmp_zdfkkwoh-gpart = itab_zdfkkwoh-gpart.
tmp_zdfkkwoh-vkont = itab_zdfkkwoh-vkont.
tmp_zdfkkwoh-waers = itab_zdfkkwoh-waers.
APPEND tmp_zdfkkwoh. " INDEX lv_tabix.
CLEAR tmp_zdfkkwoh.
IF sy-subrc = 0.
countb = countb + 1.
ELSE.
countc = countc + 1.
CONCATENATE 'Contract account :' space tmp_zdfkkwoh-abbel cdelimit 'RECORD FAILED'
INTO
t_message-msg_text.
APPEND t_message.
CLEAR t_message.
ENDIF.
ENDLOOP.
ENDIF.
INSERT zdfkkwoh
FROM TABLE tmp_zdfkkwoh.
helpful points will be reward
‎2008 Feb 21 7:53 AM
‎2008 Feb 21 7:54 AM
APPEND LINES OF itab_zdfkkwoh TO tmp_zdfkkwoh. " Moving data from One ITAB to Other.
"You can ignore whole looping process with this statement if both structures are same
INSERT zdfkkwoh FROM TABLE tmp_zdfkkwoh. " Inserting actually occurs here, so inconsistencies if any will happen here
Edited by: Eswar Rao Boddeti on Feb 21, 2008 3:54 PM
‎2008 Feb 21 7:55 AM
Hi,
Since the tmp and source table are the same, you can move the entire tables inone statement:
tmp_zdfkkwoh[] = itab_zdfkkwoh[].
OR
APPEND LINES OF itab_zdfkkwoh TO tmp_zdfkkwoh.
Also, I dont quite understand the logic of your SY-SUBRC check, because it will check SY-SUBRC for APPEND statement and that's rarely going to fail !
Also, use internal tables without header lines rather than with.
Hence code would be:
REFRESH tmp_zdfkkwoh.
APPEND LINES OF itab_zdfkkwoh TO tmp_zdfkkwoh.
INSERT zdfkkwoh FROM TABLE tmp_zdfkkwoh.
IF sy-subrc EQ 0. COMMIT WORK.
ELSE. ROLLBACK WORK. ENDIF.
Cheers,
Aditya
‎2008 Feb 21 8:01 AM
hi
i dont want to pass the value to tmp_zdfkkwoh.
i need to use describe and how to handle Exception for failure records?
Thanks
‎2008 Feb 21 8:04 AM
Hi,
To check the number of records in a internal table you can simpyly check
v_line = LINES( itab_zdfkkwoh ) .
where v_line is an integer field. You dont need DESCRIBE.
If v_line is not equal to the number of expected records, then you raise an error message or store it in t_message as you are doing.
Cheers,
Aditya
‎2008 Feb 21 8:08 AM
Try as below:
IF counta 0.
LOOP AT itab_zdfkkwoh.
INSERT zdfkkwok FROM itab_zdffkwoh.
IF sy-subrc = 0.
countb = countb + 1.
ELSE.
countc = countc + 1.
CONCATENATE 'Contract account :' space tmp_zdfkkwoh-abbel cdelimit 'RECORD FAILED'
INTO t_message-msg_text.
APPEND t_message.
CLEAR t_message.
ENDIF.
ENDLOOP.
ENDIF.
‎2008 Feb 21 8:22 AM
Hi Easwar
This is working fine. but i dont want to INSERT in LOOP. B'çoz my text file having 2 millon records