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

modify itab

Former Member
0 Likes
1,134

I have itab1 and itab2

Itab1 has fields f1 f2 f3 and f4.

Itab2 has fields f1 f2.

Itab1 is filled and itab2 is filled but itab1 doesnt have data for f2.

How Can i populate the content of whole f2 column from itab2 in itab1 ?

thanks

Golu

1 ACCEPTED SOLUTION
Read only

GauthamV
Active Contributor
0 Likes
1,110

loop at itab2 where f1 = itab1-f1.

itab1-f2 = itab2-f2.
modify itab1 transporting f2.
clear itab1.
clear itab2.

endloop.
10 REPLIES 10
Read only

GauthamV
Active Contributor
0 Likes
1,111

loop at itab2 where f1 = itab1-f1.

itab1-f2 = itab2-f2.
modify itab1 transporting f2.
clear itab1.
clear itab2.

endloop.
Read only

Former Member
0 Likes
1,110

i tried that, i was wondering if there is a smart solution...

btw f1 is a unique key field

Read only

former_member404244
Active Contributor
0 Likes
1,110

Hi,

Loop at itab1.

lv_index = sy-tabix.

read table itab2 index lv_index.

if there is any common key then..

read table itab2 with key <field> = itab1-field.

if sy-subrc eq 0.

move : itab2-f1 to ltab1-f1.

endif.

modify itab1.

endloop.

Regards,

Nagaraj

Read only

Former Member
0 Likes
1,110

Hi,

If f1 is key field for both itab1 and itab2 then look following code,

loop at itab1 into wa_itab1.

read table itab2 into wa_itab2 with key f1 = wa_itab1-f1.

if sy-subrc = 0.

move wa_itab2-f2 to wa_itab1-f2.

endif.

modify itab1 from wa_itab1.

clear: wa_itab1, wa_itab2.

endloop.

Thanks!

Brunda

Read only

Former Member
0 Likes
1,110

Hi,

Try this

loop at itab2 into wa_itab2.

wa_itab1-f2 = wa_itab2-f2.

modify itab1 from wa_itab1 transporting f2 where f1 = wa_itab2-f1 .

endloop.

Thanks & Regards,

Anagha Deshmukh

Read only

Former Member
0 Likes
1,110

use field symbols for this:

field-symbols: <f1> type wa_itab1(work area of itab1).

loop at itab1 assigning <f1>.

read table itab2 assigning <f2>

with key f1 = <f1>-f1

f2 = <f1>-f2.

if sy-subrc EQ 0.

<f2>-f2 = <f1>-f2.

like wise trasfer all required fileds.

endif.

endloop.

Read only

Former Member
0 Likes
1,110

Hi,

If f1 is key field for both itab1 and itab2 then look following code,

loop at itab1 into wa_itab1.

read table itab2 into wa_itab2 with key f1 = wa_itab1-f1.

if sy-subrc EQ 0.

move wa_itab2-f2 to wa_itab1-f2.

endif.

modify itab1 from wa_itab1.

clear: wa_itab1, wa_itab2.

endloop.

Regards,

Sekhar babu

Read only

faisalatsap
Active Contributor
0 Likes
1,110

Please Use more meaningful Subject

Read only

Former Member
0 Likes
1,110

hi,

Hope this will help u, I have tried and its working.

TYPES: BEGIN OF T_ITAB1,

FLD1(3) TYPE C,

FLD2(3) TYPE C,

FLD3(3) TYPE C,

FLD4(3) TYPE C,

END OF T_ITAB1.

TYPES: BEGIN OF T_ITAB2,

FLD1(3) TYPE C,

FLD2(3) TYPE C,

END OF T_ITAB2.

DATA: ITAB1 TYPE STANDARD TABLE OF T_ITAB1,

ITAB1_LINE LIKE LINE OF ITAB1,

ITAB2 TYPE STANDARD TABLE OF T_ITAB2,

ITAB2_LINE LIKE LINE OF ITAB2.

ITAB1_LINE-FLD1 = 'AA'.

ITAB1_LINE-FLD2 = ''.

ITAB1_LINE-FLD3 = '11'.

ITAB1_LINE-FLD4 = 'ZZ'.

APPEND ITAB1_LINE TO ITAB1.

CLEAR ITAB1_LINE.

ITAB1_LINE-FLD1 = 'BB'.

ITAB1_LINE-FLD2 = ''.

ITAB1_LINE-FLD3 = '22'.

ITAB1_LINE-FLD4 = 'YY'.

APPEND ITAB1_LINE TO ITAB1.

CLEAR ITAB1_LINE.

ITAB1_LINE-FLD1 = 'CC'.

ITAB1_LINE-FLD2 = ''.

ITAB1_LINE-FLD3 = '33'.

ITAB1_LINE-FLD4 = 'XX'.

APPEND ITAB1_LINE TO ITAB1.

CLEAR ITAB1_LINE.

ITAB2_LINE-FLD1 = 'AA'.

ITAB2_LINE-FLD2 = '99'.

APPEND ITAB2_LINE TO ITAB2.

CLEAR ITAB2_LINE.

ITAB2_LINE-FLD1 = 'BB'.

ITAB2_LINE-FLD2 = '88'.

APPEND ITAB2_LINE TO ITAB2.

CLEAR ITAB2_LINE.

LOOP AT ITAB1 INTO ITAB1_LINE.

LOOP AT ITAB2 INTO ITAB2_LINE.

IF ITAB1_LINE-FLD1 = ITAB2_LINE-FLD1.

ITAB1_LINE-FLD2 = ITAB2_LINE-FLD2.

MODIFY ITAB1 FROM ITAB1_LINE TRANSPORTING FLD2

WHERE FLD1 = ITAB1_LINE-FLD1.

ENDIF.

ENDLOOP.

ENDLOOP.

Thanks and Regards

Suraj S Nair

Read only

Former Member
0 Likes
1,110

Hi,

See below code:



data : l_tabix type sy-tabix.

loop at itab1.

l_tabix = sy-tabix.

read table itab2 with key f1 = itab1-f1.

if sy-subrc = 0.

itab1-f2 = itab2-f2.

modify itab1 index  l_tabix.

else.

continue.

endif.

endloop.


Edited by: santosh sarda on Mar 19, 2009 6:44 PM