Aller au contenu

Abap - Function to add/subtract value for Date / Period / Week

2 solutions :

1 - orienté BW

1
2
3
4
5
6
7
CALL FUNCTION 'RST_TOBJ_SHIFT'
    EXPORTING
        i_timnm = '0CALMONTH'
        i_timvl = sy-datum(6)
        i_shift = '-1'
    IMPORTING 
        e_timvl = wa_calmonth.
Marche avec tout type de caractéristique de type temps dans un système BW (CALWEEK etc)

2 - Orienté Abap sans Infoobjet

DATA: lv_date         TYPE sydatum,
      lv_current_week TYPE/bi0/oicalweek,
      lv_week         TYPE/bi0/oicalweek,
      lv_fiscper      TYPE/bi0/oifiscper,
      lv_number       TYPE i,
      lv_year         TYPE/bi0/oicalyear.

CALL FUNCTION'RSARCH_DATE_SHIFT'
    EXPORTING
        i_date             =sy-datum
        i_shift            =lv_number
        i_shift_unit       ='WEE'
        i_option           ='LT'
    IMPORTING
        e_date             =lv_date
    EXCEPTIONS
        illegal_shift_unit=1
        out_of_bounds      =2
        illegal_option     =3
    OTHERS             =4.