2011 Jan 25 2:52 PM
Hi Experts,
I have a scenario, to display all possible values based on the select-options field. Is there any Function Module available for that?
Here is a Scenario:
I have one select-options field in the selection screen and data type for the field either character/number.
When user executing a report by passing some conditions in the above select-options, it needs to display all possible results based on the select-options conditions.
Values may be like....
Include Single/ Include Multiple/ Exclude Single/ Exclude Multiple/Include Ranges/ Exclude Ranges/ Less than/ Greater than/Not Equal to/u2026
Assume.., user passing Low value as 1 and High value as 30 and excluded 15 to 20.
Report should display all possible numbers like... 1,2,3,4,5,6,7,8,9,10,11,12,13,14,21,22,23,24,25,26,27,28,29,30.
Is there any function module available in SAP to get all possible values based on the select-option? Or Is there any easy way to find those values.
The example above I have given is simple. But in my original scenario, they are passing 12 digit number.
Please help me.
Thanks in advance.
Raghu
Hi Experts,
I have a scenario, to display all possible values based on the select-options field. Is there any Function Module available for that?
Here is a Scenario:
I have one select-options field in the selection screen and data type for the field either character/number.
When user executing a report by passing some conditions in the above select-options, it needs to display all possible results based on the select-options conditions.
Values may be like....
Include Single/ Include Multiple/ Exclude Single/ Exclude Multiple/Include Ranges/ Exclude Ranges/ Less than/ Greater than/Not Equal to/u2026
Assume.., user passing Low value as 1 and High value as 30 and excluded 15 to 20.
Report should display all possible numbers like... 1,2,3,4,5,6,7,8,9,10,11,12,13,14,21,22,23,24,25,26,27,28,29,30.
Is there any function module available in SAP to get all possible values based on the select-option? Or Is there any easy way to find those values.
The example above I have given is simple. But in my original scenario, they are passing 12 digit number.
Please help me.
Thanks in advance.
Raghu
2011 Jan 25 3:26 PM
Hi r badveli,
the possible values must be defined: If they come from one database table, you can select the values from that databse table using the select-options table in the where clause.
If there are further restrictions, as i.e. ignoring objects with deletion flag or checking for authorities, this is to be handled.
There are various methods for display, as i.e. function modules popup*, custom search help, own (s)alv popup screen etc.
I think, just a little search will bring you closer to the result. You should start the development of a prototype right now.
Regards,
Clemens
2011 Jan 25 3:47 PM
It's a database field.
I need to findout available numbers.
suppose if I pass select-option low as 1 and High as 10 and excluded 5 and 6.
For all possible iterations, I need to do some validation.If no record exists in database, should be displayed as AVAILABLE other wise "ALREADY EXISTS".
For the number 1 ==> Assume record exist in database. display as ALREADY EXISTS
For the number 2 ==> Assume record not exist in database. display as AVAILABILITY
For the number 3 ==> Assume record exist in database. display as ALREADY EXISTS
For the number 4 ==> Assume record exist in database. display as ALREADY EXISTS
For the number 7 ==> Assume record not exist in database. display as AVAILABILITY
For the number 8 ==> Assume record not exist in database. display as AVAILABILITY
For the number 9 ==> Assume record exist in database. display as ALREADY EXISTS
For the number 10 ==> Assume record not exist in database. display as AVAILABILITY
Hope you understood my situation.
2011 Jan 25 4:00 PM
I am assuming you are going to restrict some select options like greater than or less than (because then you are looking at a nightmare list of all possible values).. And what happens if user enter a single value WITH NE operator? You are looking at very controlled SELECT OPTION to even run this report...
I would probably try to convince my user that I will list all entries that are available in database and leave it to them to figure out values that "ARE AVAILABLE" or not found in database... Unless they can convince me otherwise
2011 Jan 25 4:25 PM
I need to show the word "AVAILABLE" and available number also. They will use available number in some other transaction for their reference.
Edited by: r badveli on Jan 25, 2011 5:25 PM
2011 Jan 25 4:45 PM
Hi r,
(out of pure boredom...)
DATA:
lv_num TYPE <num>,
lt_num TYPE TABLE OF <num>.
FIELD-SYMBOLS:
<num> TYPE num.
SELECT num
INTO TABLE lt_num
FROM <your table>
WHERE num IN s_num.
SORT lt_num.
READ TABLE lt_num INTO lv_num index 1.
LOOP AT lt_num ASSIGNING <num>.
WHILE <num> NE lv_num.
WRITE: / lv_num, 'AVAILABILITY'.
ADD 1 TO lv_num.
ENDWHILE.
WRITE: / lv_num, 'ALREADY EXISTS'.
ENDLOOP.
But this code can work only if the select-options table has exactly one line with SIGN = 'I' and OPTION = 'EQ' or OPTION = 'BT'
Anything else may cause trouble.
Question remains: What kind of business scenario is this?
Regards,
Clemens
2011 Jan 25 4:48 PM
Is your other transaction a standard transaction and table that they are selecting from, is it a custom table or standard table?
is there a scope to implement a number range object, so that users do not have to worry about selecting a number that is not in use and a system automatically picks the right number...
Please make sure that there are no other options for the user and this is the only way (to get all possible values from select option), before doing lot of analysis or development...
2011 Jan 25 5:15 PM
concur with Clemens... If you can restrict the Select Options to one entry with Range or Equal to, you could potentially use his code with a slight variation;
lv_num = s_num-low.
LOOP AT lt_num ASSIGNING <num>.
WHILE <num> LT lv_num.
WRITE: / lv_num, 'AVAILABILITY'.
ADD 1 TO lv_num.
ENDWHILE.
WRITE: / lv_num, 'ALREADY EXISTS'.
ADD 1 TO lv_num.
ENDLOOP.
if lv_num LE s_num-high.
WHILE <lv_num> LE s_num-high.
WRITE: / lv_num, 'AVAILABILITY'.
ADD 1 TO lv_num.
ENDWHILE.
endif.
2011 Jan 25 10:26 PM
A mug's game
What if one of the SELECT-OPTIONS is include/greater than/25.
This question comes up in various forms occasionally. The best answer is :Why bother" and if you don't have a database table to validate against, there is no good solution.
I was going to move this to the test and playground forum but decided against it because the discussion around it at least is interesting.
Rob
Edited by: Rob Burbank on Jan 25, 2011 5:27 PM
2011 Mar 02 6:33 PM
2011 Mar 02 6:42 PM
Hi r badveli,
thank you indeed for sharing this innovative solution.
Regards,
Clemens