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

ABAP About modify BAPI internal table

former_member709286
Participant
0 Likes
1,204

Hi Expert team:


we have 2 internal table:

ITAB1 has same structure like bapi2017_gm_item_create

ITAB2 has more fields and some fields like in bapi2017_gm_item_create

We would like to modify ITAB1 so we can pass information to BAPI call later.

How to modify ITAB1 with information from ITAB2 pls.
Both ITAB1 and ITAB2 has same field which is PO_Number and PO_Item.

We are not sure how to loop:

Should it be like this

Loop ITAB2

Read ITAB1 with key fields ITAB2-PO_Number and ITAB2-PO_Item

Move ITAB2-field1 to ITAB1-field1

Modify ITAB1

Endloop.


pls advise and many thanks.

1 ACCEPTED SOLUTION
Read only

MateuszAdamus
Active Contributor
0 Likes
1,117

Hi,

You can do it like you wrote.

Or you can try MOVE-CORRESPONDING.

MOVE-CORRESPONDING itab2 TO itab1. 

Kind regards,

Mateusz

4 REPLIES 4
Read only

MateuszAdamus
Active Contributor
0 Likes
1,118

Hi,

You can do it like you wrote.

Or you can try MOVE-CORRESPONDING.

MOVE-CORRESPONDING itab2 TO itab1. 

Kind regards,

Mateusz

Read only

0 Likes
1,117

A few more questions:

1.Which one is better

Loop ITAB1

Read ITAB2

Endloop


or


loop ITAB2

Read iTAB1

Endloop

2. When using MoDIFY do I need to MoDIFY with sy-tabix or not?


pls help again and many thanks.

Read only

0 Likes
1,117

If you use REFERENCE TO then you do not need the MODIFY statement. That's best.

As to which LOOP sequence is better - it depends on your internal tables' definitions (with or without key, what is the condition) and the number of records. Whether these are sorted or not.

Kind regards,

Mateusz

LOOP AT itab2 REFERENCE INTO ld_itab2.
  READ TABLE itab1 REFERENCE INTO ld_itab1 WITH...
  ld_itab2->field = ld_itab1->field. 
ENDLOOP.
Read only

touzik_itc
Active Participant
0 Likes
1,117

Here lt_itab1 and lt_itab2 have the same type, but it works also for two tables, which with a different type (bapi2017_gm_item_create_t is a table of bapi2017_gm_item_create).

 DATA(lt_itab1) = VALUE bapi2017_gm_item_create_t( ( po_number = '1234567890' po_item = '12345') ).
 DATA(lt_itab2) = CORRESPONDING bapi2017_gm_item_create_t( lt_itab1 ).