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: 

Code for select

Former Member
0 Kudos

Hi ,

I need to bring fields from 2 different tables into a single itab.

Data : begin of itab occurs 0,

F1 type lfa1-regio,

F2 type ekorg,

F3 type wyt3-adrnr,

End of itab.

First I need to check in for the field of LFA1 and fill the itab and then I must check the LIFN2 of LFA1 with WYT3-LIFNR and fill the F3.

How do I write the select statements?

8 REPLIES 8

Former Member
0 Kudos

Select lfa1regio lfa1ekorg

wyt3~adrnr

FROM ( lfa1

INNER JOIN wyt3

ON wyt3lifnr = lfa1LIFN2 )

INTO TABLE itab

WHERE .....

Regards,

John.

Former Member
0 Kudos

Hi,

Use Innerjoin or Forallentry joining statement.

Regards,

Bhaskar

Former Member
0 Kudos

HI ramana,

use inner join ........

SELECT LFA1REGIO LFA1EKORG WYT3ADRNR INTO CORRESPONDING FIELDS OF TABLE ITAB FROM LFA1 INNER JOIN WYT3 ON LFA1LIFN2 = WYT3~LIFNR WHERE ( UR CONDITION IF EXISTS ).

Regards

SAB

ferry_lianto
Active Contributor
0 Kudos

Hi,

Please try this.


SELECT A~REGIO B~EKORG A~ADRNR
INTO TABLE ITAB
FROM LFA1 AS A INNER JOIN WYT3 AS B
ON A~LIFNR = B~LIFN2
WHERE A~LIFNR IN S_LIFNR.

Regards,

Ferry Lianto

0 Kudos

But Ferry ,

I need to pick somemore fields from ADRC table into field F4.What If I need to write another select stmt for the same ITAB ?

ferry_lianto
Active Contributor
0 Kudos

Hi,

What is the field from ADRC?

Regards,

Ferry Lianto

0 Kudos

The logic is that I need to check LIFN2 with the LIFNR of LFA1 again and get NAME1 & ADRNR from LFA1 and then check it with the ADRNR of ADR6

ferry_lianto
Active Contributor
0 Kudos

Hi,

Please try this.


SELECT A~REGIO B~EKORG A~ADRNR
INTO TABLE ITAB
FROM LFA1 AS A INNER JOIN WYT3 AS B
ON A~LIFNR = B~LIFN2
INNER JOIN ADRC AS C
ON A~ADRNR = C~ADDRNUMBER
WHERE A~LIFNR IN S_LIFNR.

Regards,

Ferry Lianto