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

check for value

Former Member
0 Likes
626

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

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
602

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>

6 REPLIES 6
Read only

Former Member
0 Likes
602

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.

Read only

Former Member
0 Likes
602

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

Read only

Former Member
0 Likes
603

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>

Read only

0 Likes
602
    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?

Read only

0 Likes
602

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

Read only

Former Member
0 Likes
602

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