|
Defining A Default Variant |
|
|
|
|
Written by Dany Charbonneau
|
|
Monday, 21 May 2007 |
There are 2 different ways to define a default variant. Method 1 - By assigning a variant directly on the transaction code. This is the easiest way but if the program was called from another program or directly from SE38, the default variant will be ignored. Method 2 - By assigning a variant in the code, here is a short example of this:
Code: * The code must be in the INITIALIZATION section INITIALIZATION. * We must check if a default variant was already entered by the user in a batch job or in the transaction code * we do not want to overwrite it ! the current variant is store in the sy-slset field IF sy-slset IS INITIAL. CALL FUNCTION 'RS_SUPPORT_SELECTIONS' EXPORTING report = sy-cprog "actual program name variant = 'SAPDEFAULT' "default variant name EXCEPTIONS variant_not_existent = 0 variant_obsolete = 0 OTHERS = 0. ENDIF. * After the initialization we start the real code of our program in the section START-OF-SELECTION START-OF-SELECTION. Here is how to create a the variant "SAPDEFAULT" always using as a default date today minus 30 days: Goto -> variant -> save as variant Here is the standard variant save screen. Enter a name and a description and press "execute". Very few know how to handle the weird looking bottom part of this screen:  - Check the variables for which you want to maintain default values
- Choose selection variables button and see the next one
 The first part is a legend of the column headers (T D B Z). Because we want to create a date, we double click on the traffic lights of the column "D" for Dynamic date calculation. when the traffic light turn green, you can press on the down arrow in the "T" column. This will bring a popup with all possibilities you can imagine for defaulting a date. From a usability point of view, this is not really good screens but nevertheless, this tool is very powerful.
Related Items:
|