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

using inner join

Former Member
0 Likes
1,169

How to use inner join instead of select stat. so that I get all the required fields form both my tables link (lgnum ivnum lgtyp and uname) and linp (lgnum ivnum ivpos lgpla and idatu).

Thanks.

14 REPLIES 14
Read only

Former Member
0 Likes
1,140

Hi,

Check this example..

DATA: BEGIN OF ITAB OCCURS 0,

LGNUM TYPE LINK-LGNUM,

IVNUM TYPE LINK-IVNUM,

IVPOS TYPE LINP-IVPOS,

END OF ITAB.

SELECT ALGNUM AIVNUM B~IVPOS

INTO TABLE ITAB

FROM LINK AS A INNER JOIN LINP AS B

ON ALGNUM = BLGNUM

AND AIVNUM = BIVNUM

WHERE A~LGNUM = '11221'.

THanks,

Naren

Read only

Former Member
0 Likes
1,140

Use below code:

select linklgnum linkivnum linklgtyp linkuname linpivpos linplgpla linpidatu FROM link inner join linp on linklgnum = linp~lgnum

and linkivnum = linkivnum

into TABLE it_tab1 where lgnum = pa_lgnum AND ivnum IN s_ivnum.

Thanks

Read only

0 Likes
1,140

This code gives me error

Read only

0 Likes
1,140

Shaheen,

In the given code I am assuming you have used below lines in your code from your previous threads:

PARAMETERS: pa_lgnum LIKE LINK-LGNUM.

SELECT-OPTIONS: s_ivnum FOR LINK-IVNUM.

If this used and still you are getting any error, please tell me the error description.

Thanks.

Read only

0 Likes
1,140

yes it's used. this is the error colunm name has two meanings

Read only

0 Likes
1,140

select linklgnum linkivnum linklgtyp linkuname linpivpos linplgpla linpidatu FROM link inner join linp on linklgnum = linp~lgnum

and linkivnum = linkivnum

into TABLE it_tab1

********Changes in where condition

where link~lgnum = pa_lgnum AND

link~ivnum IN s_ivnum.

Read only

0 Likes
1,140

Shaheen,

Please check if the internal table have below fields:

DATA: begin of it_tab1 occurs 0,

lgnum like link-lgnum,

ivnum like link-ivnum ,

lgtyp like link-lgtyp,

uname like link-uname ,

ivpos like linp-ivpos ,

lgpla like linp-lgpla ,

idatu like linp-idatu ,

end of it_tab1.

Please confirm.

Thanks

Read only

0 Likes
1,140

yes exactly

Read only

Former Member
0 Likes
1,140

Hi

Both ur tables are header and item.

it is better to use JOIN instead of for all entries

performance will be very good in this case

Regards

Shiva

Read only

Former Member
0 Likes
1,140

Hi,

Did you check my code..It is not giving any error..

DATA: BEGIN OF ITAB OCCURS 0,

LGNUM TYPE LINK-LGNUM,

IVNUM TYPE LINK-IVNUM,

IVPOS TYPE LINP-IVPOS,

END OF ITAB.

SELECT ALGNUM AIVNUM B~IVPOS

INTO TABLE ITAB

FROM LINK AS A INNER JOIN LINP AS B

ON ALGNUM = BLGNUM

AND AIVNUM = BIVNUM

WHERE A~LGNUM = '11221'.

Thanks,

Naren

Read only

Former Member
0 Likes
1,140

hi

good

check this code and use accordingly

SELECT c~matnr "Material no.

  • c~werks "Plant

  • c~lvorm "Flag Mat.-Del. at Plant level

  • c~bwtty "Valuation category

  • c~kzkri "Indicator: Gritical part

  • c~dispr "Material: MRP profile

    • ADD Mike Krepcik TD 3363 02/01/05 D10K913640

  • c~dismm "MRP type

    • END TD 3363 02/01/05 D10K913640

  • c~plifz "Planned delivery time in days

  • c~perkz "Period indicator

  • c~minbe "Reorder point

  • c~mabst "Maximum stock level

  • c~umlmc "Stock in Tran. (plant to plant)

  • a~mtart "Material type

  • a~meins "Base unit of measure

  • k~spras "Language key

  • k~maktx "Material description

  • w~bwkey "Valuation area

  • w~bwtar "Valuation type

  • w~lbkum "Total value stock

  • w~salk3 "Value of total valuated stock

  • w~verpr "Moving ave. price/periodic unit

  • w~peinh "Price unit ADD D10K913194

  • FROM marc AS c LEFT OUTER JOIN mara AS a

  • ON cmatnr = amatnr

  • LEFT OUTER JOIN makt AS k

  • ON cmatnr = kmatnr

  • LEFT OUTER JOIN mbew AS w

  • ON cmatnr = wmatnr AND

  • cwerks = wbwkey

  • INTO TABLE i_splus

  • WHERE c~matnr IN s_matnr "Material no.

  • AND c~werks IN s_werks. "Plant

thanks

mrutyun^

Read only

Former Member
0 Likes
1,140

Hi shaheen

create a <b>database view of these 2 tables.</b>

and write a select statement on this view.

it meets your requirement and also improves performance.

Regards,

MB

Read only

Former Member
0 Likes
1,140

Hi,

Please post your select statement and your internal table declaration..So that it will be easier for us identify the error..

Thanks,

Naren

Read only

Former Member
0 Likes
1,140

hi

plz chk this code

tables : link,linp.

DATA: begin of it_tab1 occurs 0,

lgnum like link-lgnum,

ivnum like link-ivnum ,

lgtyp like link-lgtyp,

uname like link-uname ,

ivpos like linp-ivpos ,

lgpla like linp-lgpla ,

idatu like linp-idatu ,

end of it_tab1.

*select linklgnum linkivnum linklgtyp linkuname linpivpos linplgpla linpidatu FROM link inner join linp on linklgnum = linp~lgnum

*and linkivnum = linkivnum

*into TABLE it_tab1 where lgnum = pa_lgnum AND ivnum IN s_ivnum.

select algnum aivnum algtyp auname bivpos blgpla b~idatu into table it_tab1

FROM link as a inner join linp as b

on algnum = blgnum and aivnum = bivnum.

regards.