[BW] user exit type of variable
I_S_RKB1D-COMPID --> report id
*&---------------------------------------------------------------------*
*& Include ZXRSRU01
*&---------------------------------------------------------------------*
DATA : L_S_RANGE TYPE RSR_S_RANGESID,
LOC_VAR_RANGE TYPE RRS0_S_VAR_RANGE,
WA_E_T_RANGE TYPE RRRANGESID,
L_DATE LIKE SY-DATUM,
L_WEEK LIKE SCAL-WEEK,
L_YRMON(06),
v_month(2) type n,
v_year(4) type n.
IF I_STEP = 3.
LOOP AT I_T_VAR_RANGE INTO LOC_VAR_RANGE WHERE VNAM = 'ZVFRDAT'."'VAR_FROM'. "'0CWEEK'.
LSVAR_FR = LOC_VAR_RANGE-LOW.
EXIT.
ENDLOOP.
LOOP AT I_T_VAR_RANGE INTO LOC_VAR_RANGE WHERE VNAM = 'VAR_TO'.
LSVAR_TO = LOC_VAR_RANGE-LOW.
EXIT.
ENDLOOP.
ENDIF.
** Calculate Last Calendar Month
*break charlie.
CASE I_STEP.
WHEN '2'.
IF I_S_RKB1D-COMPID = 'REP0011_1' OR
I_S_RKB1D-COMPID = 'REP0011_2'.
READ TABLE I_T_VAR_RANGE INTO LOC_VAR_RANGE WITH KEY VNAM = 'ZVDAYI'
IOBJNM = '0CALDAY'.
IF SY-SUBRC = 0.
W_TODATE = LOC_VAR_RANGE-HIGH.
ENDIF.
ENDIF.
CASE I_VNAM.
WHEN 'ZVDAY2M'.
* Current Month
READ TABLE I_T_VAR_RANGE INTO LOC_VAR_RANGE WITH KEY VNAM = 'ZVDATE'
IOBJNM = '0CALDAY'.
IF SY-SUBRC = 0.
L_DATE = LOC_VAR_RANGE-LOW.
WA_E_T_RANGE-SIGN = 'I'.
WA_E_T_RANGE-OPT = 'EQ'.
WA_E_T_RANGE-LOW = L_DATE(06).
APPEND WA_E_T_RANGE TO E_T_RANGE.
ENDIF.
WHEN 'ZVDAY2M1'.
* Previous Week's month
READ TABLE I_T_VAR_RANGE INTO LOC_VAR_RANGE WITH KEY VNAM = 'ZVDATE'
IOBJNM = '0CALDAY'.
IF SY-SUBRC = 0.
L_DATE = LOC_VAR_RANGE-LOW.
L_DATE = L_DATE - 7.
WA_E_T_RANGE-SIGN = 'I'.
WA_E_T_RANGE-OPT = 'EQ'.
WA_E_T_RANGE-LOW = L_DATE(06).
APPEND WA_E_T_RANGE TO E_T_RANGE.
ENDIF.
WHEN 'ZVLSTMON1'. " Text Variable: From Value
* Previous Month
READ TABLE I_T_VAR_RANGE INTO LOC_VAR_RANGE WITH KEY VNAM = 'ZVDAYI'
IOBJNM = '0CALDAY'.
IF SY-SUBRC = 0.
L_DATE = LOC_VAR_RANGE-HIGH.
L_DATE+6(02) = '01'.
L_DATE = L_DATE - 1.
WA_E_T_RANGE-SIGN = 'I'.
WA_E_T_RANGE-OPT = 'EQ'.
WA_E_T_RANGE-LOW = L_DATE(06).
APPEND WA_E_T_RANGE TO E_T_RANGE.
ENDIF.
WHEN 'ZVLSTMON2'. " Text Variable: To Value
* Previous Month - 1
READ TABLE I_T_VAR_RANGE INTO LOC_VAR_RANGE WITH KEY VNAM = 'ZVDAYI'
IOBJNM = '0CALDAY'.
IF SY-SUBRC = 0.
L_DATE = LOC_VAR_RANGE-HIGH.
L_DATE+6(02) = '01'.
L_DATE = L_DATE - 1.
L_DATE+6(02) = '01'.
L_DATE = L_DATE - 1.
WA_E_T_RANGE-SIGN = 'I'.
WA_E_T_RANGE-OPT = 'EQ'.
WA_E_T_RANGE-LOW = L_DATE(06).
APPEND WA_E_T_RANGE TO E_T_RANGE.
ENDIF.
WHEN 'ZVDAY2W1'. " Last week's WEEK NO.
BREAK CHARLIE.
READ TABLE I_T_VAR_RANGE INTO LOC_VAR_RANGE WITH KEY VNAM = 'ZVDATE'
IOBJNM = '0CALDAY'.
IF SY-SUBRC = 0.
L_DATE = LOC_VAR_RANGE-LOW.
L_DATE = L_DATE - 7.
CALL FUNCTION 'DATE_GET_WEEK'
EXPORTING
DATE = L_DATE
IMPORTING
WEEK = L_WEEK
EXCEPTIONS
DATE_INVALID = 1
OTHERS = 2.
WA_E_T_RANGE-SIGN = 'I'.
WA_E_T_RANGE-OPT = 'EQ'.
WA_E_T_RANGE-LOW = L_WEEK.
APPEND WA_E_T_RANGE TO E_T_RANGE.
ENDIF.
WHEN 'ZVDAY2W'. " Date to WEEK NO.
READ TABLE I_T_VAR_RANGE INTO LOC_VAR_RANGE WITH KEY VNAM = 'ZVDATE'
IOBJNM = '0CALDAY'.
IF SY-SUBRC = 0.
L_DATE = LOC_VAR_RANGE-LOW.
CALL FUNCTION 'DATE_GET_WEEK'
EXPORTING
DATE = L_DATE
IMPORTING
WEEK = L_WEEK
EXCEPTIONS
DATE_INVALID = 1
OTHERS = 2.
WA_E_T_RANGE-SIGN = 'I'.
WA_E_T_RANGE-OPT = 'EQ'.
WA_E_T_RANGE-LOW = L_WEEK.
APPEND WA_E_T_RANGE TO E_T_RANGE.
ENDIF.
WHEN 'ZTVMON1'. " Text Variable: From Value
* Next Month
READ TABLE I_T_VAR_RANGE INTO LOC_VAR_RANGE WITH KEY VNAM = 'ZPCALMON'
IOBJNM = '0CALMONTH'.
IF SY-SUBRC = 0.
L_YRMON = LOC_VAR_RANGE-LOW.
v_month = L_YRMON+4(02).
v_year = L_YRMON(04).
IF v_month = '12'.
v_month = '01'.
v_year = v_year + 1.
ELSE.
V_MONTH = V_MONTH + 1.
ENDIF.
WA_E_T_RANGE-SIGN = 'I'.
WA_E_T_RANGE-OPT = 'EQ'.
WA_E_T_RANGE-LOW(04) = V_YEAR.
WA_E_T_RANGE-LOW+4(02) = V_MONTH.
APPEND WA_E_T_RANGE TO E_T_RANGE.
ENDIF.
WHEN 'ZVNXTYR1'. " Text Variable: From Value
* Get a list of company code from selected projects
WHEN 'ZVCPYT'.
LOOP AT I_T_VAR_RANGE INTO LOC_VAR_RANGE WHERE VNAM = 'ZVTPJK'
AND IOBJNM = 'ZPRJ_KEY'.
BREAK CHARLIE.
SELECT SINGLE COMP_CODE
INTO WA_E_T_RANGE-LOW
FROM /BIC/PZPRJ_KEY
WHERE /BIC/ZPRJ_KEY = LOC_VAR_RANGE-LOW
AND COMP_CODE <> ''
AND CO_AREA <> ''.
IF SY-SUBRC = 0.
WA_E_T_RANGE-SIGN = 'I'.
WA_E_T_RANGE-OPT = 'EQ'.
APPEND WA_E_T_RANGE TO E_T_RANGE.
ENDIF.
ENDLOOP.
ENDCASE.
ENDCASE.
<< Home