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

Loop at internal table

Former Member
0 Likes
512

Hello Freinds,

I have an internal table which has some fields,prctr(Profit Center) is one of them.

In other internal table I have fields of prctr(Profit Center) and ktext(profit Center descrition).

how can i combine two tables so that the first internal tables will have profit center description againts each profit center.

Please suggest some code besides Join as some other constraints are present.

points will be rewarded definately.

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
481

Hi,

As per your requirement you want to have the profit center description for each profit center in the first internal table also.

first of all add a field for profit center description (say PRCTR_TXT) in the first internal table.Considering first itnernal table as ITAB1.

sort the second internal table with profit center.Considering second internal table as ITAB2.

below is the code:

loop at the ITAB1.

read table ITAB2 with key PRCTR = ITAB1-PRCTR

binary search.

if sy-subrc eq 0.

move ITAB2-PRCTR_TXT to ITAB1-PRCTR_TXT.

MODIFY ITAB1 transporting PRCTR_TXT.

endif.

endloop.

Thanks.

2 REPLIES 2
Read only

Former Member
0 Likes
482

Hi,

As per your requirement you want to have the profit center description for each profit center in the first internal table also.

first of all add a field for profit center description (say PRCTR_TXT) in the first internal table.Considering first itnernal table as ITAB1.

sort the second internal table with profit center.Considering second internal table as ITAB2.

below is the code:

loop at the ITAB1.

read table ITAB2 with key PRCTR = ITAB1-PRCTR

binary search.

if sy-subrc eq 0.

move ITAB2-PRCTR_TXT to ITAB1-PRCTR_TXT.

MODIFY ITAB1 transporting PRCTR_TXT.

endif.

endloop.

Thanks.

Read only

Former Member
0 Likes
481

consider first intertabl ltab1, second itab2 then

select the records into itab1,

then use, for all entries select profit description into itab2 based on profit center.

then read the table itab1 with key profit center

if sy-subrc eq 0.

pass the profit description. itab1-pdec = itab2-pdec. (pdec = profit desc)

after modify the itab1.