Skip to Content
author's profile photo
Former Member

BEX variable using customer exit

I have created one custom variable ZVAR for infoobject 0calmonth for YTD calculation, the YTD should calculate from April to the current month, depending on the user inputs. If, say, october'05 is given as input (single input, no range), then it should calculate from April'05 to October'05. If march is given as input, then the YTD should be from April previous year to March this year etc. Is there any sample code for this? This is a bit urgent.

Add comment
10|10000 characters needed characters exceeded

  • Follow
  • Get RSS Feed

1 Answer

  • author's profile photo
    Former Member
    Oct 05, 2005 at 05:17 AM

    your question is not very clear, but i can think of below logic,

    data: TYEAR LIKE T009B-BDATJ,

    TYEAR1 LIKE T009B-BDATJ,

    TMONTH TYPE RSCALMONTH.

    TMONTH1 TYPE RSCALMONTH.

    TMONTH = ZVAR+4(2).

    TYEAR = ZVAR(4).

    if TMONTH = '01' OR TMONTH = '02' OR TMONTH = '03'

    TMONTH1 = '04'.

    TYEAR1 = TYEAR - 1.

    else

    TMONTH1 = '04'.

    TYEAR1 = TYEAR.

    endif.

    i am not sure how you want to proceed from here.

    reward if helps.

    Add comment
    10|10000 characters needed characters exceeded

    • Former Member

      Hi,

      Define VAR1 as the variable on 0calday with customer exit as processing type,and with representing single value.

      Define VAR2 as the variable on 0calday with user entry as processing type,and with representing single value.

      Restict the key figure with above 2 varaible , like "

      Key figure1

      0calday <= VAR2

      and

      0calday >= VAR1

      And use the following code in user exit:

      DATA: L_S_RANGE TYPE RSR_S_RANGESID.

      DATA: LOC_VAR_RANGE LIKE RRRANGEEXIT.

      data: datein like sy-datum.

      DATA: L_DATE LIKE SY-DATUM.

      DATA: L_YEAR TYPE I.

      DATA: L_MONTH TYPE I.

      CASE I_VNAM.

      WHEN 'ZVAR2'.

      IF I_STEP = 2. "after the popup

      LOOP AT I_T_VAR_RANGE INTO LOC_VAR_RANGE

      WHERE VNAM = 'ZVAR1'.

      CLEAR L_S_RANGE.

      L_DATE = LOC_VAR_RANGE-LOW.

      MOVE '01' TO L_DATE+6(2).

      MOVE L_DATE(4) TO L_YEAR.

      MOVE L_DATE+4(2) TO L_MONTH.

      IF L_MONTH LT 4.

      L_YEAR = L_YEAR - 1.

      ENDIF.

      L_MONTH = 04.

      MOVE L_YEAR TO L_DATE(4).

      MOVE L_MONTH TO L_DATE+4(2).

      MOVE: L_DATE TO L_S_RANGE-LOW(8) .

      L_S_RANGE-SIGN = 'I'.

      L_S_RANGE-OPT = 'EQ'.

      APPEND L_S_RANGE TO E_T_RANGE.

      EXIT.

      ENDLOOP.

      ENDIF.

      ENDCASE.

      With rgds,

      Anil Kumar Sharma .P

      Close the thread, if you get the solution. closing threads helps this forum to run successfully.