‎2009 Feb 12 6:02 PM
Hi all,
I'm running abap program where the input has Calender month (MM/YYYY). So i have created the varient where this calender month selection will always be the current month whenever this program executes. Say for eg. if i'm running today it is 02/2008, if im running next month it is 03/2008. How can i define this in variant's Selection Variable. The type of the calender month is char6. the Calendar month is mandatory to execute this program, this to automate the process, as not to change variant values periodically each month.
Thanks
Sreedh
‎2009 Feb 12 6:18 PM
hi,
Step 1: Go to transaction SE38 to specify the Program name and select u2018Variantu2019 radio button and u2018Displayu2019.
Then it will lead you to next screen u2018ABAP:Variants u2013Initial Screenu2019 as shown below: Specify the variant which needs to be created or changed.
Step2: Specify all those values which are static on the selection screen in this step. Then click u2018Variant Attributesu2019 to define selection variable for u2018Date Createdu2019 on the selection screen.
Step 3: In this step, provide suitable meaning for the variant. As we need to define selection variable for u2018Date createdu2019 item on selection screen, check the box under L
Step 4: In the previous step, select u2018Selection Variablesu2019 on the menu. It leads to the next screen as shown below. As we have decided to create selection variable for u2018Date createdu2019 item only, in this screen you get to see the variable as u2018Date createdu2019. Here you are provided with three options.
T: Table variable from TVARV
😧 Dynamic Date Calculation
B: User defined Variables.
From the provided options as per our requirement select u2018Du2019 option. This can be done by clicking the Traffic lights under u2018Du2019as shown below to know that the particular option is selected.
Now click the black arrow and you will be prompted with search help of different formulas for the selection variable.
Step 5: Find the suitable formula as u2018Current date u2013 xxx, current date + yyyu2019 and select it. This will lead you to the next screen to enter the values for xxx and yyy. So, provide values as 15 for xxx and 0 for yyy. Save the variant and this will conclude the creation of dynamic variant with the help of selection variable. This variant can also be used in the background jobs.
i tried pasting the link but some issue is ther..open google and type how to make dynamic variant in sap see the first result...its very useful
‎2009 Feb 12 6:18 PM
Hi,
Do the below coding in INITIALIZATION event,
PARAMETERS : p_date(7) NO-DISPLAY. " It will not display selection screen
DATA : w_date TYPE sy-datum.
INITIALIZATION.
w_date = sy-datum.
CONCATENATE w_date+4(2) '/' w_date+0(4) INTO p_date. " field is filled according to report run date
START-OF-SELECTION.so now no need to create a variant, just schedule the Report, it will execute taking the sy-datun value without displaying selection screen.
Regards
Bala Krishna
Edited by: Bala Krishna on Feb 12, 2009 11:48 PM
‎2009 Feb 12 7:02 PM
Thanks for the quick response.
The requiement is to setup 3 varients for current month(eg.02/2009), prior month(eg.01/2009) and 2nd prior month(12/2008). The same program has been scheduled 3 times by using the 3 varients, so that at any point of time it will refresh for last 3 months. The input for the calender month is of type char7 to get input as mm/yyyy, so that 'D: Dynamic date calculation' is not displying in Selection variable. Is there any workaround to resolve this. And also there is no values in TVARVC (very less entries), pl let me know to get the standard entries.
Thanks
Sreedh.
‎2009 Feb 13 7:01 AM
Hi,
Try the below code
PARAMETERS : p_date(7) NO-DISPLAY,
p_date1(7) NO-DISPLAY,
p_date2(7) NO-DISPLAY. " It will not display selection screen
DATA : w_date TYPE sy-datum,
w_year(4),
w_mon(2).
INITIALIZATION.
w_date = sy-datum.
CASE w_date+4(2).
WHEN '01'. " When January
CONCATENATE w_date+4(2) '/' w_date+0(4) INTO p_date. " Present month
w_year = w_date+0(4) - 1.
w_mon = '12'.
CONCATENATE w_mon '/' w_year INTO p_date1. " Previous Month
w_mon = '11'.
CONCATENATE w_mon '/' w_year INTO p_date2. " 2nd Prior month
WHEN '02'. " When February
CONCATENATE w_date+4(2) '/' w_date+0(4) INTO p_date.
w_mon = '01'.
w_year = w_date+0(4).
CONCATENATE w_mon '/' w_year INTO p_date1. " Previous month
w_year = w_date+0(4) - 1.
w_mon = '12'.
CONCATENATE w_mon '/' w_year INTO p_date2. " 2nd Prior month
WHEN OTHERS. " Other months
CONCATENATE w_date+4(2) '/' w_date+0(4) INTO p_date. " Current month
w_mon = w_date+4(2) - 1.
w_year = w_date+0(4).
CONCATENATE w_mon '/' w_year INTO p_date1. " Previous month
w_mon = w_date+4(2) - 2.
w_year = w_date+0(4).
CONCATENATE w_mon '/' w_year INTO p_date2. " 2nd Prior month
ENDCASE.
START-OF-SELECTION.Regards
Bala Krishna
‎2009 Feb 13 2:44 PM
Bala,
Thanks for you response.
Need to handle this in the abap varient. Every month needs to run seperately.
Thanks
Sreedh
‎2009 Feb 13 6:09 PM
Hi,
In my above example, declare w_date as a PARAMETER, and create a variant.
PARAMETERS : p_date(7) NO-DISPLAY,
p_date1(7) NO-DISPLAY,
p_date2(7) NO-DISPLAY. " It will not display selection screen
PARAMETERS : w_date TYPE sy-datum.so you will a current date in selection, with this you can create a variant,
In INITILIZATION event, it will get the remaining values according to the current date.
Regards
Bala Krishna
‎2009 Feb 13 6:21 PM