cancel
Showing results for 
Search instead for 
Did you mean: 

Syntax to use FM in User exit

Former Member
0 Kudos

Gurus

I am trying to use SLS_MISC_GET_LAST_DAY_OF_MONTH to get last day of the month, can you please advise me the syntax to use in user exit to call this FM ?

Thanks in advance

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Hi there,

Her you go:


DATA ln_range LIKE LINE OF e_t_range.
DATA: g_l_per(3).
DATA: g_l_year(4).
DATA: l_date TYPE sy-datum.
DATA: l_last_day_date TYPE sy-datum.

* collects the last day of a date based on period ZANYVARWITHPERIOD of type FISCPER3 and year ZANYVARWITHYEAR
  WHEN 'ZMYVAR'.

    IF i_step = 2.

      CLEAR ln_range.
      CLEAR g_l_per.
      CLEAR g_l_year.
      CLEAR l_date.
      CLEAR l_last_day_date.

      ln_range-sign  = 'I'.
      ln_range-opt   = 'EQ'.

      LOOP AT i_t_var_range INTO ln_t_var_range
        WHERE vnam = 'ZANYVARWITHPERIOD'.
        g_l_per = ln_t_var_range-low.
        EXIT.
      ENDLOOP.

      LOOP AT i_t_var_range INTO ln_t_var_range
        WHERE vnam = 'ZANYVARWITHYEAR'.
        g_l_year = ln_t_var_range-low.
        EXIT.
      ENDLOOP.

      CONCATENATE g_l_year g_l_per+1(2) '01' INTO l_date. "first day of a date

      CALL FUNCTION 'SLS_MISC_GET_LAST_DAY_OF_MONTH'
        EXPORTING
          DAY_IN            = l_date
        IMPORTING
          LAST_DAY_OF_MONTH = l_last_day_date
        EXCEPTIONS
          DAY_IN_NOT_VALID  = 1
          OTHERS            = 2.

      ln_range-low = l_last_day_date.

      APPEND ln_range TO e_t_range.

    ENDIF.

Hope this helps,

Regards,

Diogo.

Former Member
0 Kudos

Thanks Diogo

Points given

Answers (0)