2009 Jun 03 9:58 AM
How to move data from select options into an internal table.
For example
At selection screen my filed is s_subtype.
user gives a range of subtypes.
I want to move these into aN INTERNAL TABLE.
How is this possible
Please provide pointers.
TIA
2009 Jun 03 10:01 AM
Hi,
The value provided in the select options will be stored as an internal table.
You can use the same name which provided for the Select options.
so, s_subtype will hold all the records.
Thanks,
Mohanraj.N
2009 Jun 03 10:01 AM
loop at s_subtype.
move s_subtype-low to it-val.
append it.
endloop.
2009 Jun 03 10:01 AM
2009 Jun 03 10:03 AM
Define a internal table t_dum.
pass values like
t_dum-low = s_subtype-low.
t_dum-high = s_subtype-high.
append t_dum.
2009 Jun 03 10:03 AM
Hi,
The select option itself act as internal table. It has following fields: Sign,Option,High value and low value.
Just loop the select option variable and read the data and transfer data to internal table.
LOOP AT s_option.
if s_option-option EQ 'EQ'
itab-value = s_option-low.
append itab.
else.
itab-value = s_option-low.
append itab.
itab-value = s_option-high.
append itab.
endif.
ENDLOOP.
In this way it can be done.
Regards,
Brajvir
2009 Jun 03 10:06 AM
Hi,
Check this example.
You can not directly get the all values from select-options. In select-options, you will get low and high values only. if you want to get between these high and low values you have to write select query and get that values into the internal table.
Example:
TABLES:mara.
DATA:BEGIN OF it_matnr OCCURS 0,
matnr LIKE mara-matnr,
END OF it_matnr.
SELECT-OPTIONS:s_matnr FOR mara-matnr.
START-OF-SELECTION.
SELECT matnr FROM mara INTO TABLE it_matnr WHERE matnr IN s_matnr.
LOOP AT it_matnr.
WRITE: it_matnr-matnr.
ENDLOOP.
2009 Jun 03 10:13 AM
Hi,
You can directly pass the value into internal table. For eg.
Suppose you have a selection field sub-low and your internal table is itab.
itab-low = sub-low .
now you can modify the itab or append.
Like
Modify itab transporting low.
or
append itab.
Hope this will solve your problem.
2009 Jun 03 10:16 AM
If I have understood your question right,
try to query the database using the 'IN' parameter.
for eg
SELECT VKORG FROM VBAK INTO TABLE T_VBELN WHERE VBELN IN S_ORG.
Or, if you want to move your select options range of values into your internal table then declare an internal table like
data: begin of itab,
low type string,
high type string,
end of itab.
select-options: s_org for vabk-vbeln.
itab-low = s_org-low.
itab-high = s_org-high.
append itab.
The select options has for fields - sign, option, high, low.
Edited by: Nitwick on Jun 3, 2009 2:49 PM
2009 Jun 03 10:30 AM
Hi,
Use event At Selection screen output.
and append this ranges and use in your internal table.
Regards,
Vijay
2009 Jun 03 10:45 AM
Hi,
do it like below:
TABLES :mara.
SELECT-OPTIONS : s_matnr FOR mara-matnr.
DATA : BEGIN OF itab OCCURS 0,
matnr TYPE matnr,
END OF itab.
DATA : gv_matnr_high TYPE matnr.
LOOP AT s_matnr.
itab-matnr = s_matnr-low.
APPEND itab.
IF NOT s_matnr-high IS INITIAL.
gv_matnr_high = s_matnr-low.
DO.
IF s_matnr-high GT s_matnr-low.
gv_matnr_high = gv_matnr_high + 1.
CONDENSE gv_matnr_high NO-GAPS.
itab-matnr = gv_matnr_high.
APPEND itab.
ENDIF.
IF gv_matnr_high = s_matnr-high.
EXIT.
ENDIF.
ENDDO.
ENDIF.
ENDLOOP.
Hope it helps!!
Rgds,
Pavan