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-options

Former Member
0 Likes
1,046

Hi,

I need to check the select-options values using the internal table.

ex.

loop at itab.

check itab-from not between field-high and field-low.

if sy-subrc eq 0.

write : 'OK'.

else.

write : 'not OK'.

endif.

Please I need exact code for this.

thanks,

Pavan.

11 REPLIES 11
Read only

Former Member
0 Likes
1,011

Loop at ITAB where FLD1 in S_FLD1.

ENDLOOP.

IF sy-subrc eq 0.

*Entry exists

ELSE.

*Entry does not exist

ENDIF.

-Kiran

Read only

RichHeilman
Developer Advocate
Developer Advocate
0 Likes
1,011

You can use the IN operateor.



loop at itab.
<b>if itab-from in so_field.</b>
write : 'OK'.
else.
write : 'not OK'.
endif.
endloop.

Regards,

Rich Heilman

Read only

Former Member
0 Likes
1,011

HI,

loop at itab.

if itab-field in s_field.

  • entry exist.

else.

*entry does not exist

endif.

endloop.

Regards,

Richa

Read only

Former Member
0 Likes
1,011

Hi,

do this

loop at itab where from in field.

-


logic

if it falls in the date range

endloop.

Read only

Former Member
0 Likes
1,011

Hi Pavan,

Try with this code.

SELECT-OPTINS: S_MATNR FOR MARA-MATNR.

DATA ITAB LIKE MARA OCCURS 0 WITH HEADER LINE.

LOOP AT ITAB.

IF ITAB-VALUE < S_MATNR-LOW OR ITAB-VALUE > S_MATNR-HIGH.

IF SY-SUBRC = 0.

WRITE:/ 'OK'.

ELSE.

WRITE:/ 'NOT OK'.

ENDIF.

ENDIF.

ENDLOOP.

Thanks,

Vinay

Read only

Former Member
0 Likes
1,011

Hi,

You can do this way..

Loop at ITAB .
if itab-from in field[].
write : 'OK'.
else.
write : 'not OK'.
endif.

endloop.

regards

vijay

Read only

Former Member
0 Likes
1,011

Hai Pavan

Check the following Code

tables : mara.

data : begin of itab occurs 0,

matnr like mara-matnr,

mbrsh like mara-mbrsh,

mtart like mara-mtart,

meins like mara-meins,

end of itab.

select-options : S_matnr for mara-matnr.

initialization.

clear s_matnr.

refresh : s_matnr.

s_matnr-low = '0001'.

s_matnr-high = '0010'.

s_matnr-Sign = 'I'.

s_matnr-Option = 'BT'.

append s_matnr.

start-of-selection.

select matnr

mbrsh

mtart

meins

from mara

into table itab

where matnr in s_matnr.

if sy-subrc = 0.

sort itab by matnr.

endif.

if not itab[] is initial.

loop at itab.

if itab-matnr NOT BETWEEN s_matnr-high AND s_matnr-low.

if sy-subrc = 0.

write 😕 'OK'.

else.

write 😕 'Not OK'.

endif.

endif.

endloop.

endif.

Thanks & regards

Sreenivasulu P

Message was edited by: Sreenivasulu Ponnadi

Read only

Former Member
0 Likes
1,011

HI Pavan,

Loop at itab

if itab-from in field1.

write: 'XX'.

else.

write: 'YY'.

endif.

endloop.

Regards,

Laxmi.

Read only

Former Member
0 Likes
1,011

Hi Pavan,

You can do it in this way. I am assuming you have some values in your Internal Table and this you want to cross check with the SELECT-OPTIONS.

Consider this code.


REPORT zarun_2.
TABLES : mara.
DATA : it_mara TYPE STANDARD TABLE OF mara WITH HEADER LINE.
SELECT-OPTIONS : s_mara FOR mara-matnr.

it_mara-matnr = '111111'.
it_mara-mtart = 'SAP'.
APPEND it_mara.

CLEAR it_mara.

it_mara-matnr = '222222'.
it_mara-mtart = 'SDN'.
APPEND it_mara.

LOOP AT it_mara WHERE matnr NOT  BETWEEN s_mara-high AND s_mara-low.

"Some processing


ENDLOOP.


Regards,

Arun Sambargi.

Read only

Former Member
0 Likes
1,011

Try this way...

Data: w_matnr type mara-matrnr,

w_werks type marc-werks.

**Selectio-Screen

Select-options s_matnr for w_matnr.

s_werks for w-werks.

**Extract Data

Select f1 f2 into <itab> from <database table>

where f3 in s_matnr

and f4 in s_werks.

**Conditional Loop.

loop at <itab> into <workarea> where f1 = s_matnr

and f2 = s_werks.

You can write your condition based on the Business Process.

"Do some processing"

Endlooop.

Read only

Former Member
0 Likes
1,011

Why not do this?

loop at itab where not from in field.
... do whatever
endloop.

You have to remember with select options the user has several options of entering ranges, single values, exclusions, inclusions etc. So it will not be correct to just look at LOW or HIGH or LOW and HIGH.

Unless you suppressed all other options using NO INTERVALS or NO EXTENSION or SELECTOPTIONS_RESTRICT function module, you should always use IN with a select option.