Application Development 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: 

internal table

Former Member
0 Kudos

we have two internal tables . now we need to combine

values from one table on basis of keys present in second table...these keys are common in both tables....now if values

of these keys are same for all entries....so final internal table will contain values from first row only (because all values of the keys will be same so only first row gets modified)..how

to avoid this and we able to read all entries....(can this problem be solved by using counter)

5 REPLIES 5

Former Member
0 Kudos

you can use outer join for that it will work definitely as it gives u UNION not INTERSECTION of two tables.

here is syntax check for outer join

PARAMETERS p_cityfr TYPE spfli-cityfrom.

DATA: BEGIN OF wa,

carrid TYPE scarr-carrid,

carrname TYPE scarr-carrname,

connid TYPE spfli-connid,

END OF wa,

itab LIKE SORTED TABLE OF wa

WITH NON-UNIQUE KEY carrid.

SELECT scarrid scarrname p~connid

INTO CORRESPONDING FIELDS OF TABLE itab

FROM scarr AS s

LEFT OUTER JOIN spfli AS p ON scarrid = pcarrid

AND p~cityfrom = p_cityfr.

LOOP AT itab INTO wa.

IF wa-connid = '0000'.

WRITE: / wa-carrid, wa-carrname.

ENDIF.

ENDLOOP.[/code]

Regards

vivek

Edited by: Vivek Gaur on Feb 25, 2008 1:06 PM

Former Member
0 Kudos

first table

kstar wrttp cost quan

1 4 1 1

1 4 9 8

second table

kstar wrttp

1 4

1 4

resultant table

kstar wrttp cost quan origin

1 4 1 1

1 4 1 1

but we want

resultant table

kstar wrttp cost quan origin

1 4 1 1

1 4 9 8

0 Kudos

Hi


loop at <itab1> into <wa1>
  read table <itab2> into <wa2> with key
                 kstar = <wa1>-kstar
                 wrttp = <wa1>-wrttp.
  if sy-subrc = 0.
        <wa3>-kstar = <wa2>-kstar.
        <wa3>-wrttp = <wa2>-wrttp.
        <wa3>-cost = <wa1>-cost.
        <wa3>-quan = <wa1>-quan.

        append <wa3> to <itab3>
  endif.
endloop.

This will work.

Thanks

Vijay

<REMOVED BY MODERATOR>

Edited by: Alvaro Tejada Galindo on Feb 25, 2008 5:14 PM

Former Member
0 Kudos

hmmm...exactly ...

but we can notice that kstar and wrttp are the keys which

are same .....so resultant table wil have modified values

of first row only...thats the question...

Former Member
0 Kudos

loop at itab1.

read f1 f2 f3 f4 from itab1 into wa for all entries in itab2 where itab1-f1 = itab2-f1.

append wa to itab3.

endloop.