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 issue

Former Member
0 Likes
889

hi All,

I am having three itabs. itab1 and itab2 have common field prctr. And prctr can be same for many records in both itab1 and itab2. i want to check that if records for a particular prctr are not in itab1 but are in itab2 then those records be moved to itab3. can anyone give me some suggestion?

thanks and regards,

Reena

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
864

HI,

Loop at itab2.

read table itab1 with key prctr = itab2-prctr.

if sy-subrc NE 0.

move-correspondings itab2 to itab3.

endif.

endloop.

Regs

Manas

7 REPLIES 7
Read only

Former Member
0 Likes
865

HI,

Loop at itab2.

read table itab1 with key prctr = itab2-prctr.

if sy-subrc NE 0.

move-correspondings itab2 to itab3.

endif.

endloop.

Regs

Manas

Read only

ferry_lianto
Active Contributor
0 Likes
864

Hi,

Please try this.


LOOP AT ITAB2.
  READ TABLE ITAB1 WITH KEY PRCTR = ITAB2-PRCTR
                   BINARY SEARCH.
  
  IF SY-SUBRC <> 0.
    MOVE-CORRESPONDING ITAB2 TO ITAB3.
    APPEND ITAB3.
  ENDIF.

ENDLOOP.

Regards,

Ferry Lianto

Read only

Former Member
0 Likes
864

Hi Reena,

SORT ITAB1 BY PRCTR.

SORT ITAB2 BY PRCTR.

LOOP AT ITAB1.

READ TABLE ITAB2 WITH KEY PRCTR = ITAB1-PRCTR BINARY SEARCH.

IF SY-SUBRC <> 0.

MOVE-CORRESPONDING ITAB1 TO ITAB3.

APPEND ITAB3.

CLEAR ITAB3.

ENDIF.

CLEAR ITAB1.

ENDLOOP.

Thanks,

Vinay

Read only

Former Member
0 Likes
864

loop at itab1.

read table itab2 with key

prctr = itab1-prctr.

if sy-subrc ne 0.

move itab2 to itab3.

enif.

endloop.

Warren.

Read only

Former Member
0 Likes
864

Hi Reena,

If you want to append itab3 based on internal table is ITAB2.

Use this:

LOOP AT ITAB2.

READ TABLE ITAB1 WITH KEY PRCTR = ITAB2-PRCTR.

IF SY-SUBRC <> 0.

MOVE CORRESPONDING ITAB2 TO ITAB3.

APPEND ITAB3.

CLEAR ITAB2.

ENDIF.

ENDLOOP.

else If you want to append itab3 based on internal table is ITAB1

Use this:

LOOP AT ITAB1.

READ TABLE ITAB2 WITH KEY PRCTR = ITAB1-PRCTR.

IF SY-SUBRC <> 0.

MOVE CORRESPONDING ITAB1 TO ITAB3.

APPEND ITAB3.

CLEAR ITAB1.

ENDIF.

ENDLOOP.

Regards,

Vinod.

Read only

ferry_lianto
Active Contributor
0 Likes
864

Hi Reena,

How could it work without APPEND ITAB3?

Your ITAB3 will be empty.

Let me know ...

Regards,

Ferry Lianto

Read only

0 Likes
864

i have used append statement. thanks for ur answer. Actually everyone suggested the same answer so i figured out more or less a mixed solution.