Skip to Content
0

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

Sep 07, 2017 at 07:09 PM

141

avatar image
Former Member

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.

10 |10000 characters needed characters left characters exceeded
* Please Login or Register to Answer, Follow or Comment.

1 Answer

Koen Hesters Sep 08, 2017 at 12:24 PM
1

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.

Show 3 Share
10 |10000 characters needed characters left characters exceeded
Former Member

Hi Koen Hestores,

Thanks for given Valuable inputs.But how to use the above logic(customer exit)for creating a Key figure( show only date field output) in Bex query.

is it possible to use customer exit variable in formula variable with type replacement path?(for creating the key figure).

0
create a formula or a calculation keyfigure, in it you create a formula variable ( customer exit with above code)
1
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.

0