‎2007 Aug 06 1:59 PM
For a particular matnr and werks, I need to check if the batch management has been switched on. If it is on then execute code, else skip the code. I am looking for the most efficient way of doing this.
Currently what I have is
DATA flag TYPE xchar
SELECT xchpf
FROM marc
INTO flag
WHERE matnr = collector-matnr
AND werks = collector-werks
AND xchpf = 'X'.
ENDSELECT.
IF sy-subrc = 0.
PERFORM get_classification_data.
ENDIF.
I dont like this code, perhaps something with READ would be better. Any ideas!!
Message was edited by:
Megan Flores
‎2007 Aug 06 2:02 PM
Hi,
If you just want to check the existense of record use the following.
SELECT single xchpf
FROM marc
INTO flag
WHERE matnr = collector-matnr
AND werks = collector-werks
AND xchpf = 'X'.
IF sy-subrc = 0.
PERFORM get_classification_data.
ENDIF.
<b>Reward if helpful.</b>
‎2007 Aug 06 2:02 PM
Hi,
do like this.
DATA xchpf TYPE xchar
SELECT<b> single </b>xchpf
FROM marc
INTO flag
WHERE matnr = collector-matnr
AND werks = collector-werks
AND xchpf = 'X'.
IF sy-subrc = 0.
PERFORM get_classification_data.
ENDIF.
rgds,
bharat.
‎2007 Aug 06 2:02 PM
Instead of using <b>SELECT... ENDSELECT</b>, you can replace the code as below...
DATA xchpf TYPE xchar
SELECT xchpf
FROM marc
INTO <b>ITAB</b>
WHERE matnr = collector-matnr
AND werks = collector-werks
AND xchpf = 'X'.
IF sy-subrc = 0.
LOOP AT ITAB.
PERFORM get_classification_data USING <b>itab-flag</b>.
ENDLOOP.
ENDIF.
Regards,
Pavan
‎2007 Aug 06 2:02 PM
Hi,
If you just want to check the existense of record use the following.
SELECT single xchpf
FROM marc
INTO flag
WHERE matnr = collector-matnr
AND werks = collector-werks
AND xchpf = 'X'.
IF sy-subrc = 0.
PERFORM get_classification_data.
ENDIF.
<b>Reward if helpful.</b>
‎2007 Aug 06 2:17 PM
SELECT single xchpf
FROM marc
INTO marc-xchpf
WHERE matnr = collector-matnr
AND werks = collector-werks
AND xchpf = 'X'.
if sy-subrc = 0. ...
Can I write something like that. What does it mean to do SELECT FROM INTO marc-xchpf. Is it the same as using a variable?
‎2007 Aug 06 2:29 PM
Hi,
Using this statement you can select just one field and place it on marc-xchpf or in a variable like marc-xchpf.
You can use this with:
Tables MARC.Or just define a variable:
DATA v_xchpf TYPE marc-xchpf.
SELECT single xchpf
FROM marc
INTO marc-xchpf "or v_xchpf
WHERE matnr = collector-matnr
AND werks = collector-werks
AND xchpf = 'X'. "In this case marc-xchpf always be "X"
if sy-subrc = 0. ...Regards.
Marcelo Ramos
‎2007 Aug 06 2:13 PM
hi,
using read statement u can read records only from internal table and not from database tables.
if u wanna use read then u have to select all records into internal table and try like this
loop at itab.
read table itab with key field xchpf = 'X'.
................
............
endloop.
if useful reward some points.
with regards,
Suresh Aluri