2007 Apr 12 7:28 AM
Hello Experts,
I am trying to eliminate records in my internal table based on a condition on
another internal table. I have 2 internal tables namely LT_VBAP and LT_VBFA.
What I want to do is to DELETE records from LT_VBAP where its VBELN does not match any
VBELV from LT_VBFA with VBTYP_N = 'J' and VBTYP_V = 'c' or VBTYP_N = 'T' and
VBTYP_V = 'H'. This is the actual code when I use loop:
LOOP AT lt_vbap ASSIGNING <wa_vbap>.
IF <wa_vbap>-auart EQ 'ZUCI' OR
<wa_vbap>-auart EQ 'ZURV' OR
<wa_vbap>-auart EQ 'ZUPR'.
CLEAR wa_vbfa.
READ TABLE lt_vbfa INTO wa_vbfa WITH KEY vbelv = <wa_vbap>-vbeln
vbtyp_n = 'J'
vbtyp_v = 'C'
BINARY SEARCH
TRANSPORTING vbeln.
IF sy-subrc <> 0.
READ TABLE lt_vbfa INTO wa_vbfa WITH KEY vbelv = <wa_vbap>-vbeln
vbtyp_n = 'T'
vbtyp_v = 'H'
BINARY SEARCH
TRANSPORTING vbeln.
ENDIF.
IF sy-subrc <> 0.
<wa_vbap>-del_ind = 'X'.
CONTINUE.
ELSE.
...............
ENDIF.
ELSE.
..............
ENDIF.
ENDLOOP.
DELETE lt_vbap WHERE del_ind = 'X'.
As you can see, I delete the records based on the indicator which is the field del_ind.
But what I want to do is to remove those records before looping since I process more than
a million records and it is giving us a run time limit error in production server.
Help would be appreciated and rewarded. Thank you guys and take care!
2007 Apr 12 7:59 AM
Hi u can do like this..
LOOP AT lt_vbap ASSIGNING <wa_vbap>.
w_index = sy-tabix.
READ TABLE lt_vbfa INTO wa_vbfa WITH KEY vbelv = <wa_vbap>-vbeln.
if ( wa_vbap-vbtyp_n = 'J' and wa_vbap-vbtyp_v = 'C' )
or ( wa_vbap- vbtyp_n = 'T' and wa_vbap-vbtyp_v = 'H' ).
<b>delete table lt_vbap index w_index.</b>
else.
continue.
endif.
try this...
How many recor u have in table <b>lt_vbfa</b>??
try looping that...
Hi u can do like this..
LOOP AT lt_vbap ASSIGNING <wa_vbap>.
w_index = sy-tabix.
READ TABLE lt_vbfa INTO wa_vbfa WITH KEY vbelv = <wa_vbap>-vbeln.
if ( wa_vbap-vbtyp_n = 'J' and wa_vbap-vbtyp_v = 'C' )
or ( wa_vbap- vbtyp_n = 'T' and wa_vbap-vbtyp_v = 'H' ).
<b>delete table lt_vbap index w_index.</b>
else.
continue.
endif.
try this...
How many recor u have in table <b>lt_vbfa</b>??
try looping that...
2007 Apr 12 7:59 AM
Hi u can do like this..
LOOP AT lt_vbap ASSIGNING <wa_vbap>.
w_index = sy-tabix.
READ TABLE lt_vbfa INTO wa_vbfa WITH KEY vbelv = <wa_vbap>-vbeln.
if ( wa_vbap-vbtyp_n = 'J' and wa_vbap-vbtyp_v = 'C' )
or ( wa_vbap- vbtyp_n = 'T' and wa_vbap-vbtyp_v = 'H' ).
<b>delete table lt_vbap index w_index.</b>
else.
continue.
endif.
try this...
How many recor u have in table <b>lt_vbfa</b>??
try looping that...
2007 Apr 12 8:17 AM
Hi,
What I want to do is to delete those records without using LOOP statement. Thanks
2007 Apr 12 8:17 AM
Hi Viray,
Instead of fetching the data into two tables and then processing further, why cant you try to use inner join on those two tables? or fetch data from VBAP into an internal table and then you can use for all entries in lt_vbap in the next select statement for VBFA and in where clause you can give vbelv = lt_vbap-vbeln and ( ( vbtyp_n <> 'J' and vbtyp_v <> 'C' ) or (vbtyp_n <> 'T' and vbtyp_v <> 'H' )).
This is just my opinion... Try using this... So there will be no loop and we can eliminate unnecessary records well before further processing.
Regards,
Phani.
2007 Apr 12 8:23 AM
Hi,
the peudocode is here:
LT_VBFA_tmp[] = LT_VBFA[].
Delete LT_VBFA_tmp WHERE VBTYP_N = 'J' and VBTYP_V = 'c' or VBTYP_N = 'T' and
VBTYP_V = 'H'.
store the VBELV in a range table.
DELETE LT_VBAP WHERE VBELN NOT IN (the range table)
Reward is useful,
Regards,
Tanmay
| User | Count |
|---|---|
| 3 | |
| 2 | |
| 2 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 |