Application Development and Automation Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

pls help( logic needed)

Former Member
0 Likes
845

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

7 REPLIES 7
Read only

Former Member
0 Likes
829

anyone pls helpme

Read only

Former Member
0 Likes
829


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

Read only

Former Member
0 Likes
829

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

Read only

0 Likes
829

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

Read only

0 Likes
829

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

Read only

Former Member
0 Likes
829

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.

Read only

0 Likes
829

Hi Easwar

This is working fine. but i dont want to INSERT in LOOP. B'çoz my text file having 2 millon records