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

Join statment is not working

Former Member
0 Likes
717

Hello Experts,

I am trying to write a below code where i will be using JOIN statment to select data from 2 table faglflexas and cepct.These two tables have only one field in common(prctr).I would also be getting the value of prctr from the user on selection screen.

But the code syntax is not allowing me to prctr in both the places.

SELECT faglflexapoper faglflexaryear faglflexaprctr cepctktext " FROM faglflexa

INTO CORRESPONDING FIELDS OF TABLE gi_prctr

FROM cepct JOIN faglflexa ON cepctprctr = faglflexaprctr

WHERE poper IN s_period

AND ryear EQ p_fyear.

AND prctr in s_prctr.

I am getting error in last line of AND prctr in s_prctr. asking that I prctr is defined in two places in the select query.

please help.

points will be rewarded definately.

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
681

Hi,

The code written by you is giving a syntax error as PRCTR field is present in both the tables and you are using a join but in the where clause you are not specifying the field with respect to a table.

try the below syntax:

SELECT faglflexapoper faglflexaryear faglflexaprctr cepctktext " FROM faglflexa

INTO CORRESPONDING FIELDS OF TABLE gi_prctr

FROM cepct JOIN faglflexa ON cepctprctr = faglflexaprctr

WHERE poper IN s_period

AND ryear EQ p_fyear.

AND cepct~prctr in s_prctr.

Thanks.

4 REPLIES 4
Read only

Former Member
0 Likes
682

Hi,

The code written by you is giving a syntax error as PRCTR field is present in both the tables and you are using a join but in the where clause you are not specifying the field with respect to a table.

try the below syntax:

SELECT faglflexapoper faglflexaryear faglflexaprctr cepctktext " FROM faglflexa

INTO CORRESPONDING FIELDS OF TABLE gi_prctr

FROM cepct JOIN faglflexa ON cepctprctr = faglflexaprctr

WHERE poper IN s_period

AND ryear EQ p_fyear.

AND cepct~prctr in s_prctr.

Thanks.

Read only

0 Likes
681

Thanks Sananth,

It solved the problem.

Read only

former_member194669
Active Contributor
0 Likes
681

Try this way


SELECT faglflexa~poper faglflexa~ryear faglflexa~prctr cepct~ktext " FROM faglflexa
INTO CORRESPONDING FIELDS OF TABLE gi_prctr
FROM cepct INNER JOIN faglflexa ON cepct~prctr = faglflexa~prctr
WHERE faglflexa~poper IN s_period
AND faglflexa~ryear EQ p_fyear.
AND faglflexa~prctr in s_prctr.

Read only

Former Member
0 Likes
681

Hi,

there is small mistake in your query, just try this one.

SELECT faglflexapoper faglflexaryear faglflexaprctr cepctktext " FROM faglflexa

INTO CORRESPONDING FIELDS OF TABLE gi_prctr

FROM cepct JOIN faglflexa ON cepctprctr = faglflexaprctr

WHERE poper IN s_period

AND ryear EQ p_fyear.

AND faglflexa~prctr in s_prctr.