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

Internal Table

Former Member
0 Likes
747

Hello,

what I am trying to do is copy the contents of Internal Table A to Internal Table B,

which do have corresponding components, but , I want to select the a date field from table A , not to be between a start and end date in table B.

Is there a quick way of doing this , without a loop within a loop?

Thanks

8 REPLIES 8
Read only

amit_khare
Active Contributor
0 Likes
725

loop at itab2 into wa2.

Read table itab1 into wa1 <condition.

if sy-subrc = 0.

<statement>

endif.

endloop.

Regards,

Amit

Reward all helpful replies.

Read only

Former Member
0 Likes
725

Hi,

You can 1st copy the entire contents from table A to table B and use the DELETE Internal table command to delete the records given in the date range.

regards,

Mahesh

Read only

Former Member
0 Likes
725

loop at b.

read table a with key date >= b-startdate

date <= b-enddate.

move corresponding a to b.

append b.

endloop.

reward points if useful.

Read only

Former Member
0 Likes
725

loop at itabA.

read table itabB with key ... = itaba-... BINARY SEARCH.

if sy-subrc eq 0.

<b>if itaba-start LT itabB-start and

itaba-end GT itabb-end.</b>

....

endif.

endif.

endloop.

Read only

Former Member
0 Likes
725

no need of second table you can do the same in first table.

you can use this

SORT ITAB BY DATE.

DELETE ITAB WHERE DATE LT S_DATE-LOW and DATE GT S_DATE-HIGH.

reward if useful.

Amit Singla

Read only

Former Member
0 Likes
725

you can use this way if u need second table as well.

ITAB1[] = ITAB[].

SORT ITAB1 BY DATE.

DELETE ITAB1 WHERE DATE LT S_DATE-LOW and DATE GT S_DATE-HIGH.

reward if useful.

Amit Singla

Read only

varma_narayana
Active Contributor
0 Likes
725

Hi..

It is must to use the LOOP in this case.

Eg: Assume F1 Is the Common field (Key) in both internal tables

SORT TAB2 BY F1.

LOOP AT TAB1 .

READ TABLE TAB2 WITH KEY F1 = TAB1-F1 BINARY SEARCH.

IF SY-SUBRC = 0.

IF TAB1-DATE NOT BETWEEN TAB2-STARTDATE AND TAB2-ENDDATE.

MOVE-CORRESPONDING TAB1 TO TAB3.

APPEND TAB3.

ENDIF.

ENDIF.

ENDLOOP.

<b>reward if Helpful.</b>

Read only

hymavathi_oruganti
Active Contributor
0 Likes
725

loop at tableb.

read tableA where date > tableb-start_date and tableb-end_date.

if sy-subrc <> 0.

<b>read tableA.

if sy-subrc = 0.

delete tableA.

endif.</b>

<b>TABLEA-DATE is what u needed now</b>

endif.

endloop.

Message was edited by:

Hymavathi Oruganti