Registration

Dear SAP Community Member,
In order to fully benefit from what the SAP Community has to offer, please register at:
http://scn.sap.com
Thank you,
The SAP Community team.
Skip to end of metadata
Go to start of metadata

Character Variable with Customer Exit

There is a lot of information with examples about customer exit which had been explained by many of our experts in SDN. In this Wiki, I would like to discuss the Characteristic variable with Customer Exit concept by considering few simple scenarios.

Initially in the Query Designer we will drag and drop our required objects into rows and columns.

stage:

1.PNG

Then for the 0calday info object we will create a variable by taking the processing type as “Customer Exit”.

stage:

2.PNG

In the details tab give the variable is as “Mandatory” and uncheck the “value is ready for input”.

stage:

3.PNG

Save the query.

stage:
4.PNG
On the BW side go to T-code CMOD.

Give the project name for example CE, click on create.stage:

 11.PNG
Give the short text and click on the Enhancement Assignment button on top.

stage:

6.PNG
Give the enhancement RSR00001 and then click on Components button on top.

stage:
7.PNG
Then double click on EXIT_SAPLRRS0_001

stage:
9.PNG
Then double click on INCLUDE ZXRSRU01.

stage:
8.PNG
We will enter the ABAP editor screen.

Here SAP has provided a default program for character variable with customer exit.

DATA: L_S_RANGE TYPE RSR_S_RANGESID,
INTERN_RANGE TYPE rrs0_s_var_range.

DATA: BEGIN OF ITAB OCCURS 1.
           INCLUDE STRUCTURE SVAL.
DATA: END OF ITAB.

DATA: BPARTNER(10) type C,
           cust_group(7) type c.
      
DATA:YEAR(4) TYPE n,
           MONTH(2) TYPE n,
           DAY(2) TYPE n,
           BEGYEAR(4) TYPE n,
           BEGMONTH(2) TYPE n,
           BEGMON(4) TYPE n,
           BEGDAT LIKE SY-DATUM,
           ENDDATE LIKE SY-DATUM.
DATA: BEGDAT2(8) TYPE n,
           BEGDAT3(8) TYPE n.

-----------------------------------------------------------------------------------

DYNAMIC CURRENT DATE
.....................

CASE I_VNAM.

WHEN 'Z_ZED'.
CLEAR L_S_RANGE.
L_S_RANGE-SIGN = 'I'.
L_S_RANGE-OPT = 'EQ'.
L_S_RANGE-LOW = SY-DATUM.
APPEND L_S_RANGE TO E_T_RANGE.

ENDCASE.

-----------------------------------------------------------------------------------

CURRENT DATE NEXT DAY
.................................................................................................
CASE I_VNAM.

WHEN 'Z_ZED'.
DATA : NEXT_DATE LIKE SY-DATUM.
CLEAR L_S_RANGE.
L_S_RANGE-SIGN = 'I'.
L_S_RANGE-OPT = 'EQ'.
L_S_RANGE-LOW = SY-DATUM.

NEXT_DATE = SY-DATUM + 1.
L_S_RANGE-SIGN = 'I'.
L_S_RANGE-OPT = 'EQ'.
L_S_RANGE-LOW = NEXT_DATE.
APPEND L_S_RANGE TO E_T_RANGE.

ENDCASE.

-------------------------------------------------------------------------------------

CURRENT YEAR
...................................................................................................
WHEN 'Z_ZED'.
CLEAR L_S_RANGE.
L_S_RANGE-SIGN = 'I'.
L_S_RANGE-OPT = 'EQ'.
L_S_RANGE-LOW = SY-DATUM+0(4).
APPEND L_S_RANGE TO E_T_RANGE.

ENDCASE.

--------------------------------------------------------------------------------------
CURRENT YEAR/MONTH
.......................................................
WHEN 'Z_ZED'.
CLEAR L_S_RANGE.
L_S_RANGE-SIGN = 'I'.
L_S_RANGE-OPT = 'EQ'.
L_S_RANGE-LOW = SY-DATUM+0(2).
APPEND L_S_RANGE TO E_T_RANGE.

ENDCASE.

--------------------------------------------------------------------------------------
1ST JAN TO CURRENT DATE RECORDS
.......................................................

CASE I_VNAM.

WHEN 'Z_ZED'.

DATA: V_YEAR(4) TYPE C,
           V_DATE TYPE DATS.
    
          CLEAR L_S_RANGE.
          V_YEAR = SY-DATUM+0(4).
          CONCATENATE V_YEAR '0101' INTO V_DATE.
           L_S_RANGE-SIGN = 'I'.
           L_S_RANGE-OPT = 'BT'.
           L_S_RANGE-LOW = v_DATE.
           L_S_RANGE-HIGH = SY-DATUM.

   
      APPEND L_S_RANGE TO E_T_RANGE.
      ENDCASE.

----------------------------------------------------------------------------------------
1ST DAY OF CURRENT MONTH TO CURRENT DATE
.................................................................
CASE I_VNAM.

WHEN 'Z_ZED'.

DATA: CMONTH(6) TYPE C,
           SDATE TYPE DATS.

      CLEAR L_S_RANGE.
      CMONTH = SY-DATUM+0(6).
      CONCATENATE CMONTH '01' INTO SDATE.
      L_S_RANGE-SIGN = 'I'.
      L_S_RANGE-OPT = 'BT'.
      L_S_RANGE-LOW = SDATE.
      L_S_RANGE-HIGH = SY-DATUM.

      APPEND L_S_RANGE TO E_T_RANGE.
      ENDCASE.

................................................................................................................................

Based on the requirement we write  our customer exit code and activate it and go back to the previous screen and activate then again go back and activate and finally activate the project.

Once this job in CMOD is complete, go back to the query designer and execute our query.

  • No labels