Application Development and Automation Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

Modifying an Existing Variant Programatically

Former Member
0 Likes
4,535


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?

1 ACCEPTED SOLUTION
Read only

RaymondGiuseppi
Active Contributor
3,250

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

11 REPLIES 11
Read only

jayanthi_jayaraman
Active Contributor
0 Likes
3,250

Hi,

You can try with the particular event when you can see GET as sy-ucomm in debugging.

Read only

0 Likes
3,250

GET is found during debugging at PBO of selection screen.Since its a selection screen i can not add my code tehre.

Read only

Former Member
0 Likes
3,250

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?

Read only

0 Likes
3,250

Yes thats the requirement. I want to change a particular field in the variant while user picks it.

Read only

0 Likes
3,250

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


Read only

0 Likes
3,250

well you still did not answer the WHY question. Why would you do this?

Read only

0 Likes
3,250

Since business asked it.

Read only

ThangaPrakash
Active Contributor
0 Likes
3,250

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

Read only

RaymondGiuseppi
Active Contributor
3,252

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

Read only

0 Likes
3,250

Thanks so much the check with sy-slset in At Selection screen output event solved my problem.

Read only

Former Member
0 Likes
3,250


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.