Technology Blogs by Members
Explore a vibrant mix of technical expertise, industry insights, and tech buzz in member blogs covering SAP products, technology, and events. Get in the mix!
cancel
Showing results for 
Search instead for 
Did you mean: 
pallab_haldar
Active Participant
3,211
Hi Today I am going to discuss about the different type of commonly used date type implementation for customer exit.  I feel from my experience that offset of a date variable not always give you the exact result expected for your requirement. In those scenarios we will go to go with the customer exit variable.

@Customer Exit variable for MTD(Till current date) :

1. Create a Customer exit Variable of type range ZVC_DT_MTD :


2.  Go to SE19 and create BADI implementation(if no implementation exists in you development landscape) or go the implemented class directly to implement the code to populate the data for the variable created.

 
   DATA:  WA1 like LINE OF C_T_RANGE,
WA2 like LINE OF I_T_VAR_RANGE,
ZINITIALDT TYPE SY-DATUM,
ZENDDT TYPE SY-DATUM,
ZCYEAR TYPE N LENGTH 4,
ZPYEAR TYPE N LENGTH 4,
ZCMONTH TYPE N LENGTH 2,
ZPMONTH TYPE N LENGTH 2,
ZCDAYS TYPE N LENGTH 2,
ZPDAYS TYPE N LENGTH 2,
ZVAR type N LENGTH 8.

CASE I_VNAM.
* For Current Month to Date varriable
WHEN 'ZVC_DT_MTD'.
I_STEP = 1.

ZINITIALDT = sy-datum.
ZINITIALDT+6(2) = '01'.
ZENDDT = sy-datum.

WA1-sign = 'I'.
WA1-opt = 'BT'.
WA1-LOW = ZINITIALDT.
WA1-HIGH = ZENDDT.
APPEND WA1 TO C_T_RANGE.
CLEAR WA1.

 

3. Activate it.

4. Add the variable to the Query, save it and Execute the query in RSRT and check the data.

 

@Customer Exit variable for YTD (Till current date) :

1. Do all the above steps and create variable ZVC_DT_YTD   and implement the below in implemented class on above point no 2.
* For Current Year to Date varriable
WHEN 'ZVC_DT_YTD'.
I_STEP = 1.

ZINITIALDT = sy-datum.
ZINITIALDT+4(2) = '01'.
ZINITIALDT+6(2) = '01'.
ZENDDT = sy-datum.

WA1-sign = 'I'.
WA1-opt = 'BT'.
WA1-LOW = ZINITIALDT.
WA1-HIGH = ZENDDT.
APPEND WA1 TO C_T_RANGE.
CLEAR WA1.

2. Activate it.

3. Add the variable to the Query, save it and Execute the query in RSRT and check the data.

@Customer Exit variable for Previous Year Current Month to the same Date PYMTD (Till current date) :

1. Do all the above steps and create variable ZVC_DT_YTD   and implement the below in implemented class on above point no 2.
* For Previous Year Current Month to Date varriable
WHEN 'ZVC_DT_PYMTD'.
I_STEP = 1.

ZINITIALDT = sy-datum.
ZCDAYS = ZINITIALDT+6(2).
ZCMONTH = ZINITIALDT+4(2).
ZCYEAR = ZINITIALDT+0(4).
ZPYEAR = ZCYEAR - 1.

CONCATENATE ZPYEAR ZCMONTH '01' INTO ZINITIALDT.
CONCATENATE ZPYEAR ZCMONTH ZCDAYS INTO ZENDDT.


WA1-sign = 'I'.
WA1-opt = 'BT'.
WA1-LOW = ZINITIALDT.
WA1-HIGH = ZENDDT.
APPEND WA1 TO C_T_RANGE.
CLEAR WA1.

2. Activate it.

3. Add the variable to the Query, save it and Execute the query in RSRT and check the data.

 

@Customer Exit variable for Previous Year to the same Date of previous year  PYYTD (Till current date) : 

1. Do all the above steps and create variable ZVC_DT_YTD   and implement the below in implemented class on above point no 2.
* For Previous Year  to Current Date PYYTD varriable
WHEN 'ZVC_DT_PYYTD'.
I_STEP = 1.

ZINITIALDT = sy-datum.
ZCDAYS = ZINITIALDT+6(2).
ZCMONTH = ZINITIALDT+4(2).
ZPMONTH = '01'.
ZCYEAR = ZINITIALDT+0(4).
ZPYEAR = ZCYEAR - 1.

CONCATENATE ZPYEAR ZPMONTH '01' INTO ZINITIALDT.
CONCATENATE ZPYEAR ZCMONTH ZCDAYS INTO ZENDDT.
ZENDDT = sy-datum.

WA1-sign = 'I'.
WA1-opt = 'BT'.
WA1-LOW = ZINITIALDT.
WA1-HIGH = ZENDDT.
APPEND WA1 TO C_T_RANGE.
CLEAR WA1.

 

2. Activate it.

3. Add the variable to the Query, save it and Execute the query in RSRT and check the data.

 

@Customer Exit variable for MTD(Till User provided date) :

1. Create a single input variable ZVI_DATE for use input:.


 

2.  Create a Customer exit Variable of type interval  ZVC_FDATE  :


2.  Go to SE19 and create BADI implementation(if no implementation exists in you development landscape) or go the implemented class directly to implement the code to populate the data for the variable created.
* For varriable Same Month data till the user input date.
* ZVI_DATE is a single input date varriable

WHEN 'ZVC_FDATE'.
I_STEP = 2.

READ TABLE I_T_VAR_RANGE INTO WA2 WITH KEY VNAM = 'ZVI_DATE'.
ZENDDT = WA2-LOW.
ZCYEAR = ZENDDT+0(4).
ZCMONTH = ZENDDT+4(2).
ZCDAYS = ZENDDT+6(2).

CONCATENATE ZCYEAR ZCMONTH '01' INTO ZVAR.

WA1-sign = 'I'.
WA1-opt = 'BT'.
WA1-LOW = ZVAR.
WA1-HIGH = ZENDDT.
APPEND WA1 TO C_T_RANGE.
CLEAR WA1.

 

3. Activate it.

4. Add the variable to the Query, save it and Execute the query in RSRT and check the data.

@Customer Exit variable for YTD(Till User provided date) :

1. Create a single input variable ZVI_DATE for use input:.


 

2.  Create a Customer exit Variable of type interval  ZVC_FDATE   :


2.  Go to SE19 and create BADI implementation(if no implementation exists in you development landscape) or go the implemented class directly to implement the code to populate the data for the variable created.

 
* ZVI_DATE is a Single input date varriable.

WHEN 'ZVC_PDATE'.
I_STEP = 2.

READ TABLE I_T_VAR_RANGE INTO WA2 WITH KEY VNAM = 'ZVI_DATE'.
ZENDDT = WA2-LOW.
ZCYEAR = ZENDDT+0(4).
ZCMONTH = '01'.
ZCDAYS = ZENDDT+6(2).

CONCATENATE ZCYEAR ZCMONTH '01' INTO ZVAR.

WA1-sign = 'I'.
WA1-opt = 'BT'.
WA1-LOW = ZVAR.
WA1-HIGH = ZENDDT.
APPEND WA1 TO C_T_RANGE.
CLEAR WA1.

3. Activate it.

4. Add the variable to the Query, save it and Execute the query in RSRT and check the data.

 

 
1 Comment
Labels in this area