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

Need help with program for Inner join

Former Member
0 Likes
905

Hello Experts,

I need to create a list from table sbook containing booking number (sbook-bookid), customer number (sbook-customid), customer name (scustom-name) , customer class (sbook-class) and ticket price (sflight-price). I am new to ABAP and am very confused I tried reading up some examples and came up with the attached program

Attached is my program for inner join

Kindly Help

Thanks Su

6 REPLIES 6
Read only

Former Member
0 Likes
868

Hi,

     First Provide your Join then into table, Also check for the valid values in IT_FLIGHT-CONNID

SELECT SBOOK~BOOKID SBOOK~CUSTOMID SBOOK~CLASS

  SCUSTOM~ID SCUSTOM~NAME  FROM SBOOK

  INNER JOIN SCUSTOM ON SCUSTOM~ID = SBOOK~ID

     into TABLE itbook

     where CONNID = IT_FLIGHT-CONNID.

Regards

Read only

0 Likes
868

Hi Somendra,

Thanks for responding how do I join the ticket price field (sflight-price) from sflight to the above select statement?

Read only

0 Likes
868

Hi Su K

          You May use key fields , Foreign keys for joining , Here

SELECT SBOOK~BOOKID SBOOK~CUSTOMID SBOOK~CLASS

  SCUSTOM~ID SCUSTOM~NAME  FROM SFILGHT

   INNER JOIN SBOOK ON   SBOOK~CARRID EQ SFILGHT~CARRID

                                          SBOOK~CONNID EQ SFILGHT~CONNID

                                          SBOOK~FLDATE EQ SFILGHT~FLDATE

  INNER JOIN SCUSTOM ON SCUSTOM~ID = SBOOK~ID

Read only

Former Member
0 Likes
868

Hi,

To join two tables you need common field in both table.

select <db1~f1>

          <db1~f2>

          <db2~g1>

          <db2~g2>

          from db1 innerjoin db2 on <db1~f1> = <db2~f1>

          into table <it_tab> where f1 = <selection_screen_field>.

regards.

laxman

Read only

venuarun
Active Participant
0 Likes
868

Hi,

Please refer this link

ABAP Keyword Documentation

With Regards

Arun VS


Read only

Former Member
0 Likes
868

Hi,

The correct syntax is:

SELECT SBOOK~BOOKID SBOOK~CUSTOMID SBOOK~CLASS

  SCUSTOM~NAME sbook~loccuram SCUSTOM~ID FROM SBOOK

  INNER JOIN SCUSTOM ON SCUSTOM~ID eq SBOOK~customID  into table itbook where sbook~CONNID = IT_FLIGHT-CONNID.

plz try this query.