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

Select statement

Former Member
0 Likes
622

Hi,

I have a requirement where in I have to get 2 values for the field "FIELDNAME". Under any case I have to select the data related to FIELDNAME = CO_PSPEL and the other value can be either CO_KOSTL or CO_KDAUF. SO how to write the select statement so that I can get 2 values in 2 variables lf_fieldvalue1 and lf_fieldvalue2 .

IF sy-subrc EQ 0.

SELECT FIELDVALUE INTO lf_fieldvalue1 and

lf_fieldvalue2

FROM ZCMTRANS

WHERE ITEM = CO_ITEM

AND ITEMTYPE = CO_ITEMTYPE1

AND ITEMVALUE = lf_matnr1

AND FIELDNAME = CO_PSPEL

and ( FIELDNAME = CO_KOSTL

or FIELDNAME = CO_KDAUF ).

ENDIF.

Thank You,

SB

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
593

Yes code is correct,i do not see any mistake (where condition is good)

6 REPLIES 6
Read only

Former Member
0 Likes
594

Yes code is correct,i do not see any mistake (where condition is good)

Read only

0 Likes
593

It is giving syntax error saying "AND LF_FIELDVALUE2 not expected".

Read only

0 Likes
593

Hi SB,

Change the code as below

IF sy-subrc EQ 0.

SELECT <b>FIELDVALUE1 fieldvalue2</b> INTO <b>lf_fieldvalue1

lf_fieldvalue2</b>

FROM ZCMTRANS

WHERE ITEM = CO_ITEM

AND ITEMTYPE = CO_ITEMTYPE1

AND ITEMVALUE = lf_matnr1

AND FIELDNAME = CO_PSPEL

and ( FIELDNAME = CO_KOSTL

or FIELDNAME = CO_KDAUF ).

ENDIF.

Reward points if useful.

Regards,

Atish

Message was edited by:

Atish Sarda

Read only

0 Likes
593

Hi Atish,

That is my problem I do not have FIELDVALUE1 fieldvalue2 ... instead just one field called "FIELDVALUE"

Thank You,

SB.

Read only

0 Likes
593

Hi SB,

Then you can't select the single fieldvalue in two fields at a time. Either you can write two select statement or you can first get value the field1 and move it to field2.

Reward points to all useful answers.

Regards,

Atish

Read only

0 Likes
593

Hello SB,

I verified only where condition