‎2014 Mar 25 2:13 PM
Hi,
I have a zreport for which one variant TEST123 is already created.
I will have to modify some of the field values of this variant programatically inside the report.
I have the code to modify the contents of this variant and the code is working fine.
I want this section of code for modifying the variant to get trigerred after user clicks on the variant icon of the selection screen.
When I put the code under At Selection screen output Event, the code for modifying the variant triggers before the selection screen gets displayed. I dont want that.
At runtime i checked that the function code when I click on the variant icon on the selection screen is GET.
Since its a selection screen I can not put the code under PBO of the selection screen either.
So my question is, in the report under which event i should put the code for modifying the variant so that it gets trigerred only when user clicks on the variant icon on selection screen.
I tried to put a sy-ucomm check under AT USER-COMMAND event in the report but its not working at that point of the report.
I executed the report-->On the Sel screen I put /h ---> clicked on the variant icon---> It goes to PBO of selection screen and sy-ucomm is 'GET' at this point but when the flow comes to AT USER_COMMAND of the zreport the SY-UCOM value clears out.
How do I capture the function code value of the variant icon in the report?
‎2014 Apr 03 2:44 PM
In AT SELECTION-SCREEN OUTPUT block, check if user has selected a new variant comparing current value of sy-slset and previous variant saved in a global variable.
If value was changed (user selected a new variant or saved current selection to a new variant) then change variant values programmatically (RS_VARIANT_VALUES_TECH_DATA + RS_CHANGE_CREATED_VARIANT and DB_COMMIT) then call RS_SUPPORT_SELECTIONS to use new values. Now save the current variant name to the variable used to detect any change.
NB: Would be easier is to change current parameters and use RS_VARIANT_SAVE_FROM_SELSCREEN to save it (if actually required)
Regards,
Raymond
‎2014 Mar 25 2:29 PM
Hi,
You can try with the particular event when you can see GET as sy-ucomm in debugging.
‎2014 Apr 04 1:09 PM
GET is found during debugging at PBO of selection screen.Since its a selection screen i can not add my code tehre.
‎2014 Mar 25 2:48 PM
the first question is - what exactly and why do you want to do something like this? You want to change the existing variant once the user is trying to pick one?
‎2014 Apr 03 1:23 PM
Yes thats the requirement. I want to change a particular field in the variant while user picks it.
‎2014 Apr 03 2:18 PM
Rakhi you can use AT selection screen output event for the same. Now in order to prevent the code from being triggered during the first time you can set a flag in Load-of-Prorgram event set FLAG as 'X'.
Then in AT SELECTION SCREEN OUTPUT check if flag ne X then do your work else clear the flag so that now your logic shall work
‎2014 Apr 03 4:28 PM
well you still did not answer the WHY question. Why would you do this?
‎2014 Apr 04 12:25 PM
‎2014 Mar 25 5:58 PM
Hello Rakhi,
Try with AT SELECTION SCREEN event.
After the selection screen is displayed and any action is done then this event is triggered.
Refer to the below link for the hierarchy of the events triggered.
https://help.sap.com/saphelp_nw04/helpdata/en/56/1eb6c705ad11d2952f0000e8353423/content.htm
Regards,
TP
‎2014 Apr 03 2:44 PM
In AT SELECTION-SCREEN OUTPUT block, check if user has selected a new variant comparing current value of sy-slset and previous variant saved in a global variable.
If value was changed (user selected a new variant or saved current selection to a new variant) then change variant values programmatically (RS_VARIANT_VALUES_TECH_DATA + RS_CHANGE_CREATED_VARIANT and DB_COMMIT) then call RS_SUPPORT_SELECTIONS to use new values. Now save the current variant name to the variable used to detect any change.
NB: Would be easier is to change current parameters and use RS_VARIANT_SAVE_FROM_SELSCREEN to save it (if actually required)
Regards,
Raymond
‎2014 Apr 04 12:59 PM
Thanks so much the check with sy-slset in At Selection screen output event solved my problem.
‎2014 Apr 04 1:07 PM
Solution:
LOAD-OF-PROGRAM.
w_load = c_x.
AT SELECTION-SCREEN OUTPUT.
IF w_load IS INITIAL.
CHECK sy-slset = w_variant.
*change the variant ESSBASE_EXTCT
PERFORM change_variant USING w_repid w_variant.
ELSE.
CLEAR w_load.
ENDIF.