01-14-2013 11:34 AM
Hi,
Following query runs based selection screen. When we do not enter single value S_AUFNR which has to pull based on s_date wise or including S_Aufnr wise. We have an option like radio-button.. is there any option to do?
SELECT ap~dwerk
ak~aufnr
ak~plnbez
ak~gamng
ak~gltri
ak~aufld
INTO CORRESPONDING FIELDS OF TABLE gt_afko
FROM afko AS ak INNER JOIN
afpo AS ap
ON ak~aufnr EQ ap~aufnr
WHERE ap~dwerk EQ p_dwerk
AND ak~gltri IN s_gltri "Date
AND ak~aufnr EQ s_aufnr "Single value
regards
Shree
01-14-2013 11:39 AM
Hi, No you mean..Multiple selection values..I need single where we can use EQ symbol only...
01-14-2013 11:38 AM
Hi Shree,
just change the code as below
AND ak~aufnr IN s_aufnr.
It will work for single value also.
01-14-2013 11:38 AM
Hi
can you please clearly tell your problem, What exactly you want to do?
01-14-2013 11:38 AM
01-14-2013 11:39 AM
Hi, No you mean..Multiple selection values..I need single where we can use EQ symbol only...
01-14-2013 11:41 AM
the you can use
AND ak~aufnr EQ s_aufnr-low.
why don;t you use parameter instead?
and even if you enter single value in select-options, the system automatically takes oonly single value.
01-14-2013 11:48 AM
Try using this if you want select options and restrict to one box
SELECT-OPTIONS : s_aufnr FOR aufk-aufnr NO INTERVALS
01-14-2013 11:44 AM
01-14-2013 11:46 AM
Hi Shree,
If you could please close the thread and change it to answered
01-14-2013 11:45 AM
Hi,
If you ignore the parameter which has to pull value based on S_DATE or if you use the S_aufnr based single value with date wise...Thanks
01-14-2013 11:49 AM
Hi Shree,
Use IN insted of EQ in below code:
AND ak~aufnr EQ s_aufnr "Single value
AND ak~aufnr IN s_aufnr " Single Value
01-14-2013 11:53 AM
When i ignore the parameter S_AUFNR...Need result based on S_date wise then you would get multiple AUFNR values on output...When you use S_AUFNR only single value
01-14-2013 11:56 AM
Can you please clarify more?
Using the code below suffices all the requirements, whether you give single value,a range or ignore it, the below code works
AND ak~aufnr EQ s_aufnr
Why don;t you use the below code and debug to see
01-14-2013 11:58 AM
Hi Shree,
if you want that your code should work for single and multiple order then use following code.
TABLES afko.
data gt_afko TYPE STANDARD TABLE OF afko.
PARAMETERS p_dwerk TYPE dwerk.
SELECT-OPTIONS: s_gltri for afko-gltri,
s_aufnr for afko-aufnr.
IF lines( s_aufnr[] ) EQ 1 AND s_aufnr-high is INITIAL.
SELECT ap~dwerk
ak~aufnr
ak~plnbez
ak~gamng
ak~gltri
ak~aufld
INTO CORRESPONDING FIELDS OF TABLE gt_afko
FROM afko AS ak INNER JOIN
afpo AS ap
ON ak~aufnr EQ ap~aufnr
WHERE ap~dwerk EQ p_dwerk
AND ak~gltri IN s_gltri "Date
AND ak~aufnr EQ s_aufnr-low. "Single value
else.
SELECT ap~dwerk
ak~aufnr
ak~plnbez
ak~gamng
ak~gltri
ak~aufld
INTO CORRESPONDING FIELDS OF TABLE gt_afko
FROM afko AS ak INNER JOIN
afpo AS ap
ON ak~aufnr EQ ap~aufnr
WHERE ap~dwerk EQ p_dwerk
AND ak~gltri IN s_gltri "Date
AND ak~aufnr EQ s_aufnr.
endif.
01-14-2013 11:59 AM
01-14-2013 12:01 PM
Use as below.Now it will work.
TABLES afko.
data gt_afko TYPE STANDARD TABLE OF afko.
PARAMETERS p_dwerk TYPE dwerk.
SELECT-OPTIONS: s_gltri for afko-gltri,
s_aufnr for afko-aufnr.
IF lines( s_aufnr[] ) EQ 1 AND s_aufnr-high is INITIAL.
SELECT ap~dwerk
ak~aufnr
ak~plnbez
ak~gamng
ak~gltri
ak~aufld
INTO CORRESPONDING FIELDS OF TABLE gt_afko
FROM afko AS ak INNER JOIN
afpo AS ap
ON ak~aufnr EQ ap~aufnr
WHERE ap~dwerk EQ p_dwerk
AND ak~gltri IN s_gltri "Date
AND ak~aufnr EQ s_aufnr-low. "Single value
else.
SELECT ap~dwerk
ak~aufnr
ak~plnbez
ak~gamng
ak~gltri
ak~aufld
INTO CORRESPONDING FIELDS OF TABLE gt_afko
FROM afko AS ak INNER JOIN
afpo AS ap
ON ak~aufnr EQ ap~aufnr
WHERE ap~dwerk EQ p_dwerk
AND ak~gltri IN s_gltri "Date
AND ak~aufnr IN s_aufnr.
endif.
01-14-2013 12:01 PM
When we use select-options in a query and a single value is entered on the selection screen, the system automatically changes the value of S_XXXX-LOW to IEQ<value>. We don't have to do anything except using it as normal select-options
01-14-2013 12:03 PM
Every one of their aspect is right...But ketan bhajni is right...We can use no intervals, it would satisfy both condition... thank you all..
01-14-2013 12:05 PM
You could have declared it as parameter rather than select-options if you wanted single value
01-14-2013 12:08 PM
Hi aniket,
I declared parameter only but when i leave the input values then it has to satisfy s_date wise...Now i use selection-option no intervals.... you are also right.....
01-14-2013 12:14 PM
Hi Omar,
Why don't use select-option and no interval then query retrieves multiple values. In case, giving S_aufnr value which gives single value...Right...
01-14-2013 12:39 PM
Hi,
When we do not use the parameter or input the value S_Aufnr...which will retrieve based on S_date where we would get all aufnr data because the join condition you would see...
When we S_Aufnr we get single value based aufnr value...
01-14-2013 1:00 PM
Hi Shree,
Your requirement is:
If S_AUFNR is entered with a single value, then the select query should get records corresponding to that.
And if S_AUFNR is left blank, then the records must be fetched based on S_DATE?
Is it right????
If yes, then in either case the below code works
AND ak~aufnr IN S_AUFNR.
01-14-2013 1:02 PM
01-14-2013 1:05 PM
The go ahead and use the code
AND ak~aufnr IN S_AUFNR.
This will definitely work
01-15-2013 4:55 AM
01-14-2013 1:12 PM
Not sure to understand your requirement, if you only want user to input a list of order numbers, you could rely on FM SELECT_OPTIONS_RESTRICT. Then use a syntax like aufnr IN so_aufnr or even a FOR ALL ENRIES IN so_aufnr WHERE aufnr = so_aufnr-low, second syntax get lesser performance, but will not raise an error for many order numbers.
data: restrict type sscr_restrict,
opt_list type sscr_opt_list,
ass type sscr_ass.
* Default option for other criteria
clear opt_list.
move 'ALL' to opt_list-name.
move 'X' to: opt_list-options-bt,
opt_list-options-cp,
opt_list-options-eq,
opt_list-options-ge,
opt_list-options-gt,
opt_list-options-le,
opt_list-options-lt,
opt_list-options-nb,
opt_list-options-ne,
opt_list-options-np.
clear ass.
move: 'A' to ass-kind,
'*' to ass-sg_main,
'ALL' to ass-op_main.
* Option for only list of values
clear opt_list.
move 'EQU' to opt_list-name.
move 'X' to opt_list-options-eq.
append opt_list to restrict-opt_list_tab.
clear ass.
move: 'S' to ass-kind,
'SO_AUFNR' to ass-name,
'I' to ass-sg_main, " no exclude
'EQU' to ass-op_main. " only list of values
* Execute FM call
call function 'SELECT_OPTIONS_RESTRICT'
exporting
restriction = restrict
exceptions
others = 0.
Otherwise, try to make your request more clearly or read abap online documentation like col [NOT] IN seltab.
Regards,
Raymond