Skip to Content
avatar image
Former Member

Convert date field as a key figure with customer exit variable using replacement path in bex query

Hi folks,

i have a query in that we have to bring date field(date field is last date of the closing period). this date field is there in another DSO. so, we have to apply logic based on sy-datum and check the last date of the closing period and populate in query as a key figure.

Ex: every time closing period date will change.

per example today date is 9/7/2017(sy-datum)

but august month (05) is not closed it will close this month 11/7/2017.

the date field, we have ton show 31/08/2017 in query as a key figure.

i tried below one.

i wrote cmod code for customer exit variable(logic) and when used to customer exit variable in replacement path variable(convert date field to key figure) it is showing error.

WHEN 'YVAR_DATE_CE01'. customer exit (logic)
IF i_step = '2'.
DATA : lv_day.
READ TABLE I_T_VAR_RANGE INTO LOC_VAR_RANGE WITH KEY VNAM = 'YVAR_FISC_YEAR'.
lv_year = sy-datum+0(4).
lv_mon = sy-datum+4(2).
lv_day = sy-datum+6(2).
IF LOC_VAR_RANGE-low LT lv_year.
CONCATENATE LOC_VAR_RANGE-low '03' '31' INTO lv_date.
l_s_range-low = lv_date.
l_s_range-sign = 'I'.
l_s_range-opt = 'EQ'.
APPEND l_s_range TO e_t_range.
ELSE.

DATA: WA_TABD393 TYPE /BIC/AYSD_D3900.


SELECT SINGLE * FROM /BIC/AYSD_D3900 INTO WA_TABD393 WHERE CALDAY = SY-DATUM.
lv_year = WA_TABD393-/BIC/YACT_TO+0(4).
lv_mon = WA_TABD393-/BIC/YACT_TO+4(3).
CALL FUNCTION 'LAST_DAY_IN_PERIOD_GET'
EXPORTING
I_GJAHR = lv_year
I_PERIV = 'V3'
I_POPER = lv_mon
IMPORTING
E_DATE = lv_date
IF SY-SUBRC <> 0.
ENDIF.
l_s_range-low = lv_date.
l_s_range-sign = 'I'.
l_s_range-opt = 'EQ'.
APPEND l_s_range TO e_t_range.
ENDIF.
ENDIF.

Appreciate your valuable inputs.

Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

1 Answer

  • Sep 08, 2017 at 12:24 PM

    hi,

    if I got it right you just want to fetch the closing data that is held in a DSO.

    so the way to go is:

    WHEN 'YVAR_DATE_CE01'. 
    IF i_step = '2'.
    
    DATA WA_TABD393 type /BIC/AYSD_D3900-/BIC/YACT_TO.
    
    READ TABLE I_T_VAR_RANGE INTO LOC_VAR_RANGE WITH KEY VNAM = 'YVAR_FISC_YEAR'.
    
    SELECT /BIC/YACT_TO FROM /BIC/AYSD_D3900 INTO WA_TABD393 WHERE CALDAY = SY-DATUM.
     
    IF sy-subrc = 0.
     lv_year = WA_TABD393(4).
     lv_mon = WA_TABD393+4(2).
     CALL FUNCTION 'LAST_DAY_IN_PERIOD_GET'
     	EXPORTING
     	I_GJAHR = lv_year
     	I_PERIV = 'V3'
     	I_POPER = lv_mon
     	IMPORTING
     	E_DATE = lv_date
     IF SY-SUBRC = 0.
    	l_s_range-low = lv_date.
     	l_s_range-sign = 'I'.
     	l_s_range-opt = 'EQ'.
     	APPEND l_s_range TO e_t_range.
    ENDIF. ENDIF. ENDIF.
    
    
    Add comment
    10|10000 characters needed characters exceeded

    • Former Member Koen Hesters

      Hi Koen,

      Thanks for given support, now i got the data for date field in query after used formula variable using customer exit.