‎2009 Jun 04 2:13 PM
Hey Guys,
I have a quit difficult problem. I created a report with variable select options and using the SAP standart process to select fields from a customer table for selection (like in SE16). This works fine for me. But the problem is, that I would like to create the report as usefull as possible and so I want to allow user to change the selection fields while the selection screen is displayed. For example:
SELECT-OPTION: SO1 LIKE SEL1.
INITIALISATION.
SEL1 = '/SAPAPO/MATKEY-MATID'.
This works fine! But know I want to change the data type after it was generated:
SELECT-OPTION: SO1 LIKE SEL1.
INITIALISATION.
SEL1 = '/SAPAPO/MATKEY-MATID'.
SELECTION SCREEN OUTPUT.
SEL1 = '/SAPAPO/MATKEY-MATNR'.
Here is the problem. I dont get any error message or something like that, but nothing happends. I guess it is because I already signed a data type to the select option SO1 and it does not overwrite this. Is there any chance to modify the select options while the selection screen is displayed?
Thanks
Andy
‎2009 Jun 04 2:29 PM
Hi Andreas,
Please check following code. It changes output field to PSPNR from MATNR at selection screen.
DATA : lv_char TYPE char100.
SELECT-OPTIONS : sel FOR (lv_char).
AT SELECTION-SCREEN OUTPUT.
lv_char = 'PRPS-PSPNR'.
INITIALIZATION.
lv_char = 'MARA-MATNR'.
Let me know if it helps.
Gouri.
‎2009 Jun 04 4:11 PM
Hi,
wat ever the final variable where you want to store declare it as string.
Thanks & Regards,
Sateesh.
‎2009 Jun 05 7:35 AM
Dear Gouri,
that is exactly what I described. I can change the contend of the field SEL1 but it would not change the data type of SO_1...
Dear Sateesh,
I know how to declare the field SEL_1 that is not the problem and it works but I dont want to change anything at the declaration for this field than for select option SO_1.
Thanks both for the answer.
‎2009 Jun 05 8:08 AM
Hi Andreas,
Can you explain me why you want change data of select-option itself and not the other way around? bacause if you change value in char/string variable, data type of select-option will automatically change.
Gouri.
‎2009 Jun 05 8:17 AM
Hi Gouri,
that is exactly the point. The data type of the select option will not change automatically. When I put MATNR into the string field and the select option was generated with the type "MATNR" I can change the value of the string field as many times as I want, the select option will everytime be "MATNR" no matter what is contend of the string field.
Step 1: SELECT-OPTION: SO1 LIKE (SEL_1) -> SEL_1 is "MATNR", than SO1 will be like "MATNR"
Step 2: SELECT-OPTION: SO1 LIKE (SEL_1) -> SEL_1 is "LOCNO", than SO1 will also be like "MATNR" and nothing was changed. That is what I want to change.
Best regards
Andy
‎2009 Jun 05 9:06 AM
Hi Andreas,
If I understand the requirement correctely, SO1 should change as per sel1 and this is what will happen. when you say sel1 = 'MARA-MATNR', SO1 will behave like MATNR and when you change sel1 to 'LOCNO', SO1 should behave like 'LOCNO'.
Also, I am not sure whether we can use code like :
select-option: so1 like (sel_1).
I suppose it is SELECT-OPTIONS : so1 FOR (sel1).
The code which I gave earlier was working exactely like this. You can try it once may be.
Gouri.
‎2009 Jun 05 9:12 AM
Dear Gouri,
you understand the problem. But your code does not work. It is exactly the same as my code I described in the question itself and SO1 does not change when SEL1 was changed. That is the problem. And in my code SO1 LIKE (SEL1) works. I had problems with FOR, thats why I use LIKE.
‎2009 Jun 05 9:18 AM
at first i want to add that your "requirement" is not a very common one, since people tend to work with tabs when wanting various selscreens.
Tho still you aint got no chance to change the datatype of a select option during runtime.
But what you can do is: have more select options on your selection screen, hide the ones you dont need. and if you need to change a select option from vbeln to matnr just hide the vbeln one and unhide the matnr one.
to hide/unhide screen fields go for a "Loop at screen" statement in event AT SELECTION-SCREEN OUTPUT.
‎2009 Jun 05 9:24 AM
Hi Florian,
I know that I do not choose the best way to do it, but the program has to be as independend as possible, so that I have to create the seletion options dynamicaly...
I thought about the way to do it right before you answered the post and so I'm on it to try it like that. Btw, LOOP AT SCREEN was in before I am now creating a table with the selections and a filed called "Display" where all possible selections where in and just the ones, that needs to be displayed will be visible at the selection screen.
Best regards.
Andy