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 logic2

Former Member
0 Likes
371

Dear Friends,

I have an internal table A like below show, i am looping the interal table

A and inside i am reading the internal table B to assign the field value STLKN

based on PLNKN and modifying the internal table A. So for all (PLNKN) 5 values

(STLKN) 1 is assiged. this is ok

now my requirement is for the second 5 (PLNKN)value in internal table B , the value 5(STLKN) should assign by appending new records.

when you see the internal table B contains two 5 PLNKN and

two 7 value in PLNKN and contains different STLKN values.

when i loop internal table A and modify only the first value is assigned.

now remaining value to be appended for the second value 5 PLNKN

if not understandable below i given example.

WARPL ABNUM PLNKN STLKN Internal table A

211--


1
4
--


0

211--


9
4
--


0

211--


3
4
--


0

211--


5
4
--


0

211--


7
4
--


0

211--


4
5
--


1

211--


2
5
--


1

211--


8
5
--


1

211--


10
5
--


1

211--


6
5
--


1

211--


4
6
--


6

211--


8
6
--


6

211--


8
7
--


7

-


example-here need to append----


211--


4
5
--


5 like this

211--


2
5
--


5

211--


8
5
--


5

211--


10
5
--


5

211--


6
5
--


5

-


211--


8
7
--


1

PLLNR----


PLNKN -


STLKN Internal table B

106900--


4--


0

106900--


5--


1

106900--


5--


5

106900--


6--


6

106900--


7--


7

106900--


7--


1

can anyone give the code for this. keep in mind the internal table B contains

more than 2 or 3 values repeated in PLNKN.

Thnaks in advance

karthik

2 REPLIES 2
Read only

Former Member
0 Likes
341

Hi Karthik,

In the second case when you are modifying internal table A use the where clause as

MODIFY itab a some fields tranporting ur fields where stkln = Internal Table B-stkln and plnkn = Internal Table B-PLNKN.

If i have understood ur requiremen correctly .

Please reward if useful.

Read only

Former Member
0 Likes
341

Hi Karthik,

Try this code below.

i_a_temp[] = i_tab_a.

Loop at i_a_temp into wa_a_temp.

read table i_tab_b into wa_tab_b with key plnkn = wa_a_temp-plnkn.

if sy-subrc eq 0.

i_b_temp[] = i_tab_b[].

delete i_b_temp where plnkn ne wa_a_temp-plnkn.

describe table i_b_temp line v_lines.

do v_lines times.

read i_b_temp into wa_b_temp with key plnkn = wa_a_temp-plnkn

stlkn = wa_a_temp-stlkn.

if sy-subrc NE 0.

wa_a_temp-stlkn = wa_b_temp-stlkn.

append wa_a_temp to i_tab_a.

endif.

enddo.

endif.

endloop.

Kindly give rewards if helpful!

mariposa