‎2006 Dec 21 6:24 AM
i have a selection-criteria for a variable. I want to copy all the values corresponding to that selection-criteria into an internal table. suppose
select-options: s_lifnr like.....
data: begin of itab occurs 0,
lifnr ....
end of itab.
in selection screen i have entered range of values for s_lifnr. i want to copy all the values corresponding to that selection-criteria into itab. How can i do this...please help me.
‎2006 Dec 21 6:28 AM
select-options field is creating strcuture like ranges. so, you can loop at s_lifnr and copy all required fields/values to your internal table.
‎2006 Dec 21 6:28 AM
select-options field is creating strcuture like ranges. so, you can loop at s_lifnr and copy all required fields/values to your internal table.
‎2006 Dec 21 6:29 AM
Hi ,
Select option is an internal table. So s_lifnr in your program would map to an internal table .
So you can copy the range of values in ITAB as under:
LOOP AT S_LIFNR[].
IF S_LIFNR-HIGH is initial.
itab-lifnr = s_lifnr-low.
else.
select lifnr from lfa1
into table itab
where lifnr >= S_lifnr-low
ANd lifnr <= S_lifnr-high.
append itab.
ENDLOOP.
Regards,
Chetan.
PS:Reward points if this helps.
‎2006 Dec 21 6:30 AM
Hi,
Try this code.
loop at s_lifnr .
itab-lifnr = s_lifnr-low .
append itab .
clear itab.
endloop.
Regards,
Raghav
‎2006 Dec 21 6:30 AM
Hi Subhakar
The way you are expecting can cause problem as in selection-screen, you can exclude, negotiate the value or ranges...
You can expect the correct result only with:
select-options: s_lifnr for lfa1-lifnr.
data: begin of itab occurs 0,
lifnr type lifnr,
end of itab.
select lifnr into table itab from lfa1 where lifnr in s_lifnr.The above code works as LIFNR has a master table. If you are looking for a non master table, i guess it will lead to complications...
Kind Regards
Eswar
‎2006 Dec 21 6:31 AM
Hi,
Select options itself is a internal table with four fields low,high,sign,option.
If you loop at s_lifnr,you can get the values.
loop at s_lifnr.
write : / s_lifnr-low, s_lifnr-high, s_lifnr-sign, s_lifnr-option.
endloop.
‎2006 Dec 21 6:31 AM
write query like this -
Select * from dbtab into corresponding fields of table Itab where
lifnr in s_lifnr " ur select option name..
example code -
tables pa0001.
select-options : s_pernr for pa0001-pernr.
select * from pa0001 into corresponding fields of table itab where pernr in s_pernr.
Message was edited by:
Amit Tyagi
‎2006 Dec 21 6:34 AM
Hi,
Please see below code.
loop at s_lifnr into wa_lifnr.
if s_lifnr-high is initial.
itab-lifnr = wa_lifnr-low.
append itab.
else.
do.
if wa_lifnr-low > wa_lifnr-high.
exit.
endif.
itab-lifnr = wa_lifnr-low.
append itab.
wa_lifnr-low = wa_lifnr-low + 1.
enddo.
endif.
endloop.Regards
Bhupal Reddy
Message was edited by:
Bhupal Reddy Vendidandi
‎2006 Dec 21 6:37 AM
just check this ..
tables : vbak.
select-options : so_vbeln for vbak-vbeln.
data : begin of itab occurs 0,
vbeln like vbak-vbeln,
end of itab.
start-of-selection.
select vbeln into table itab from vbak
where vbeln
between so_vbeln-low and so_vbeln-high. "like this
loop at itab.
write:/ itab-vbeln.
endloop.Im using between to fill the itab to split the range .
hope this helps ,
regards,
vijay.
‎2006 Dec 21 6:42 AM
Hi,
As mention by Eswar it is better to use the select-options in a select statement to avoid complications..
You use LOOP AT S_LIFNR..and move it to an internal table if you have the following in your code..
1) if no-intervals is given For select-options
2) if you have restricted the user to give only "equal to" option using the FM SELECT_OPTIONS_RESTRICT
Thanks,
Naren
‎2006 Dec 21 7:03 AM
Thanks for the backup Naren, but Subhakar seems to be having different ideas..:)
Kind Regards
Eswar
‎2006 Dec 21 6:52 AM
forgot to add for parameter when select -option high is initial.
tables : vbak.
select-options : so_vbeln for vbak-vbeln.
data : begin of itab occurs 0,
vbeln like vbak-vbeln,
end of itab.
start-of-selection.
if so_vbeln-high ne ' '.
select vbeln into table itab from vbak
where vbeln
between so_vbeln-low and so_vbeln-high. "takes care of select-options
else.
select vbeln into table itab from vbak "takes care of parameter
where vbeln = so_vbeln-low .
endif.
loop at itab.
write:/ itab-vbeln.
endloop.check if this works for u ,
Assumption is if at all u give a parameter then check for the valid entry in the corresponding table .. cause we proceed with the range but the hits will be limited .
use at selection screen to filter out any wrong entries .
u can enhance the code.
see if this is working for one entry in the select-option for a parameter like and then check for the range.
regards,
vijay.
‎2006 Dec 21 7:15 AM
:):)
Hi Naren and Eswar i'm Vijay
.. glad that the problem is fixed ..