2007 Jun 15 2:33 AM
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
2007 Jun 15 2:49 AM
Yes code is correct,i do not see any mistake (where condition is good)
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
2007 Jun 15 2:49 AM
Yes code is correct,i do not see any mistake (where condition is good)
2007 Jun 15 2:53 AM
It is giving syntax error saying "AND LF_FIELDVALUE2 not expected".
2007 Jun 15 2:56 AM
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
2007 Jun 15 3:00 AM
Hi Atish,
That is my problem I do not have FIELDVALUE1 fieldvalue2 ... instead just one field called "FIELDVALUE"
Thank You,
SB.
2007 Jun 15 3:02 AM
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
2007 Jun 15 3:02 AM
| User | Count |
|---|---|
| 6 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 |