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: 

INNER JOIN WITH SELECT OPTIONS

Former Member
0 Kudos
1,796

hello,

i have used a select query with inner join with conditions from select options,but its filling one field of the internal table wrongly,

i will post you my select query

SELECT b~aennr
            a~aenst                                         
            b~datuv                                        
            a~andat                                         
            a~annam
            a~lvorm
        INTO TABLE it_aenr
             FROM aenr AS a INNER JOIN aedt AS b
       ON  a~datuv = b~datuv
       WHERE a~aenst in pm_aenst
       AND a~annam IN pm_annam AND
           b~datuv IN pm_datuv AND
           a~ccart IN pm_ccart AND
           a~aenbe IN pm_aenbe AND
           a~lvorm like lvorm1 .

all the variables starting with pm_   and lvorm1 are select-options variables.

annam field is wrongly obtained in table it_aenr.

please help me.

Regards,

4 REPLIES 4

Former Member
0 Kudos
349

Hi

How have you defined the internal table it_aenr, the fields has to be in the same sequance (and type) of the fields set in the query:

DATA: BEGIN OT IT_AENR OCCURS 0,

               AENNR .....

               AENST .....

               DATUV .....

               ...........................

           END OF IT AENR.

MaX

0 Kudos
349

hello,

the fields are defined in same sequence,but the field annam is wrongly geting entered into the table,

i mean to say that the value of the  field annam in the first row of the table is repeating in the other rows.

regards,

0 Kudos
349

Hi

Perhaps it's not ok the condition of the join:

SELECT b~aennr

            a~aenst                                         

            b~datuv                                        

            a~andat                                         

            a~annam

            a~lvorm

        INTO TABLE it_aenr

             FROM aenr AS a INNER JOIN aedt AS b

*       ON  a~datuv = b~datuv

        ON  a~AENNR = b~AENNR

    WHERE a~aenst in pm_aenst

       AND a~annam IN pm_annam AND

           b~datuv IN pm_datuv AND

           a~ccart IN pm_ccart AND

           a~aenbe IN pm_aenbe AND

           a~lvorm like lvorm1 .


But I suppose the data of table AENR should be repeated for every record of AEDT

Max

former_member288351
Participant
0 Kudos
349

Dear,

I think ur field donot have same sequence as in select query so

Please use INTO CORRESPONDING FIELDS OF TABLE  in place of

INTO TABLE.

regards