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
719

Hello Experts,

Can anybody of you pleaes help me in writing the logic.

<b>select matnr

werks

into table i_data

where matnr = i_mara-mantr

and werks IN s_werks.</b>

here i have to execute the following logic if "S_WERKS" is not "US" and "EU".

<b>loop at i_data.

..................................

..................................

endloop.</b>

Thanks a lot.

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
691

Hi

RANGES R_WERKS FOR MARC-WERKS.

R_WERKS(3) = 'EEQ'.

R_WERKS-LOW = 'US'.

APPEND R_WERKS.

R_WERKS-LOW = 'EU'.

APPEND R_WERKS.

loop at i_data where werks in R_WERKS.

..................................

..................................

endloop.

Max

7 REPLIES 7
Read only

Former Member
0 Likes
692

Hi

RANGES R_WERKS FOR MARC-WERKS.

R_WERKS(3) = 'EEQ'.

R_WERKS-LOW = 'US'.

APPEND R_WERKS.

R_WERKS-LOW = 'EU'.

APPEND R_WERKS.

loop at i_data where werks in R_WERKS.

..................................

..................................

endloop.

Max

Read only

0 Likes
691

Thnx Max.

Can you please let me knwo if I want to check that condition before the "SELECT" statement how would I do that?

Thnx.

Read only

0 Likes
691

In the Initialization event you can populate the same into <b>s_werks</b> instead in r_werks. and use this s_werks in the select statement.

regards,

vamshi tallada

Read only

0 Likes
691

Hi

Have you tried:

select matnr
werks 
into table i_data
where matnr = i_mara-mantr
and ( werks IN s_werks and
      werks <> 'US' and
      werks <> 'EU ).

Max

Read only

0 Likes
691

i'm sorry for not giving u a clear idea of what I want.

the code is like this:

<b>form get_data.</b>

now i hve to check the plants (S_WERKS) first and if they are not 'US' and 'EU' then i hve to execute this following logic.

and if they are euqual to 'EU' or 'US', there is a different approach i hve to take.

<b>select matnr

werks

into table i_data

where matnr = i_mara-matnr

and werks IN s_werks.

loop at i_data.

.......................

.......................

endloop.</b>

Read only

0 Likes
691

Hi

Sorry...

DATA: BEGIN OF T_PLANT OCCURS 2,

WERKS TYPE WERKS,

END OF T_PLANT.

T_PLANT-WERKS = 'US'.

APPEND T_PLANT.

T_PLANT-WERKS = 'EU'.

APPEND T_PLANT.

DELETE T_PLANT WHERE WERKS IN S_WERKS.

IF SY-SUBRC <> 0.

-


> It means US and EU not in S_WERKS

ELSE.

DESCRIBE TABLE T_PLANT LINES SY-TABIX.

IF SY-TABIX = 0.

-


> It means US and EU are in S_WERKS

ELSE.

-


> It means US or EU are in S_WERKS

ENDIF.

ENDIF.

Max

Read only

0 Likes
691

thanks for the help. i appreciate that.