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

INNER JOIN

Former Member
0 Likes
1,261

Hi!! I'm tryhig to do a query on three database views and read it on an internal table, the sintax is ok (at least there's no error messsage when I verify it)but it's not working propperly because when I run the debugging mode the program doesn't execute the select.

My internal table is declared like this:

TYPES:BEGIN OF st_output,

tplnr LIKE viaufkst-tplnr,

pltxt LIKE iflo-pltxt,

acpos LIKE pmco-acpos,

objnr LIKE viaufkst-objnr,

END OF st_output.

DATA gt_output TYPE STANDARD TABLE OF st_output WITH HEADER LINE.

The database views are viaufkst, iflo and pmco and they are declared with the TABLES statement.

The query's sintax is:

SELECT VTPLNR VOBJNR IPLTXT PACPOS

FROM ( ( VIAUFKST AS V

INNER JOIN IFLO AS I ON VTPLNR = ITPLNR

)

INNER JOIN PMCO AS P ON VOBJNR = POBJNR )

INTO TABLE gt_output

WHERE V~TPLNR = '0001-GRUP-0001'.

I do know that the where condition is true, so:

Anybody can tell me why is it not working?

10 REPLIES 10
Read only

anversha_s
Active Contributor
0 Likes
1,075

hi juna,

this will work for u.

chk the new code.

data:BEGIN OF gt_output occurs 0,

tplnr LIKE viaufkst-tplnr,

pltxt LIKE iflo-pltxt,

acpos LIKE pmco-acpos,

objnr LIKE viaufkst-objnr,

END OF gt_output.

SELECT VTPLNR VOBJNR IPLTXT PACPOS

INTO TABLE gt_output

FROM VIAUFKST AS V

INNER JOIN IFLO AS I

ON VTPLNR = ITPLNR

INNER JOIN PMCO AS P

ON VOBJNR = POBJNR

WHERE V~TPLNR = '0001-GRUP-0001'.

rgds

anver

if hlped mark points

Read only

Former Member
0 Likes
1,075

Hi,

Try this,

<b>SELECT VTPLNR VOBJNR IPLTXT PACPOS

INTO TABLE gt_output

FROM ( VIAUFKST AS V

INNER JOIN IFLO AS I ON VTPLNR = ITPLNR )

INNER JOIN PMCO AS P ON VOBJNR = POBJNR</b>

WHERE V~TPLNR = '0001-GRUP-0001'.

If you are not sure abt the where condition check with only the bold part and check if it is fetching any value in the debugger.

Reward if it helps.

Regards,

Senthil

Message was edited by: senthil kumar

Message was edited by: senthil kumar

Read only

Former Member
0 Likes
1,075

just check this ..may be because of missmatch ..in

<b>TPLNR = '0001-GRUP-0001'.</b>

TYPES:BEGIN OF st_output,
tplnr LIKE viaufkst-tplnr,
pltxt LIKE iflo-pltxt,
acpos LIKE pmco-acpos,
objnr LIKE viaufkst-objnr,
END OF st_output.

DATA gt_output TYPE STANDARD TABLE OF st_output WITH HEADER LINE.
The database views are viaufkst, iflo and pmco and they are declared with the TABLES statement.
The query's sintax is:
SELECT V~TPLNR V~OBJNR I~PLTXT P~ACPOS

FROM ( ( VIAUFKST AS V
INNER JOIN IFLO AS I ON V~TPLNR = I~TPLNR
)
INNER JOIN PMCO AS P ON V~OBJNR = P~OBJNR )
INTO TABLE gt_output

Read only

Former Member
0 Likes
1,075

There is no need for the brackets but I think it must be executing the statement but since there is no data to be fetched you no able to view the result...

To check that please check on the SY-SUBRC after the select statement.

Regards

Anurag

Read only

Former Member
0 Likes
1,075

Hi Juan

I guess Table VIAUFKST is not having records for field TPLNR Value '0001-GRUP-0001'. Please check.

Regards

Srikanth M

Read only

0 Likes
1,075

Ok guys!! We are appraching the solution, I think the problem is on the where clause. I've disabled the where clause an I've made a loop at the table gt_output, to write its content on the screen. Everything is ok and the program shows on the screen all the rows of gt_output, the problem now is that in this list there're 25 rows with the value 0001-GRUP-0001 on the field tplnr. What the hell is going on????

This is thenew sintax:

SELECT VTPLNR VOBJNR IPLTXT PACPOS

INTO TABLE gt_output

FROM VIAUFKST AS V

INNER JOIN IFLO AS

I ON VTPLNR = ITPLNR

INNER JOIN PMCO AS P

ON VOBJNR = POBJNR.

  • WHERE I~TPLNR = '0001-GRUP-0001'.

LOOP AT gt_output into wa_output.

write:/ wa_output-tplnr,WA_OUTPUT-OBJNR,wa_output-acpos,wa_output-pltxt.

ENDLOOP.

Read only

0 Likes
1,075

the reason is ..

TPLNR is char type and ur value ('0001-GRUP-0001'.

)stsrted by 000 so ir Surplus the zeros and it take it like -GRUP-0001' and it not fount it in table.

Read only

Former Member
0 Likes
1,075

hi juan ollero ,

The problem with ur select query is that u have not used the 'into corresponding fields of' statement. The following Select query will work.

SELECT VTPLNR VOBJNR IPLTXT PACPOS

INTO CORRESPONDING FIELDS OF TABLE gt_output

FROM VIAUFKST AS V INNER JOIN IFLO AS I ON VTPLNR = ITPLNR INNER JOIN PMCO AS P ON VOBJNR = POBJNR

WHERE V~TPLNR = '0001-GRUP-0001'.

Read only

Former Member
0 Likes
1,075

Hi Juan,

The entire code is correct may be check out the where condition.

Thanks

Vikranth Khimavath

Read only

Former Member
0 Likes
1,075

Hi,

SELECT VTPLNR VOBJNR IPLTXT PACPOS

FROM ( ( VIAUFKST AS V

INNER JOIN IFLO AS I ON VTPLNR = ITPLNR

)

INNER JOIN PMCO AS P ON VOBJNR = POBJNR )

INTO TABLE gt_output

<b>WHERE V~TPLNR like '%0001%'.</b>Regards

amole