ABAP function articles 1 Date Functions

 

  • 1. Check the date format field

data:l_date type ekko-bedat.

l_date = '20080901'.

CALL FUNCTION 'DATE_CHECK_PLAUSIBILITY'

  EXPORTING

    DATE                            = l_date

 EXCEPTIONS

   PLAUSIBILITY_CHECK_FAILED       = 1

   OTHERS                          = 2

          .

IF SY-SUBRC <> 0.

 MESSAGE ID AND-msgid TYPE AND Sgt NUMBER AND MSGNO

         WITH HIS-MSGV1 SY MSGV2 SY MSGV3 SY MSGV4.

ENDIF.

 

 

  • 2. Query the day between two dates

  CALL FUNCTION 'FIMA_DAYS_AND_MONTHS_AND_YEARS'

    EXPORTING

      I_DATE_FROM          = '20080101'

*     I_KEY_DAY_FROM  =

      I_DATE_TO                = '20090508'

*     I_KEY_DAY_TO        =

*     I_FLG_SEPARATE   = ' '

   IMPORTING

*     E_DAYS                 =

     E_MONTHS            = T_MOTH

*     E_YEARS              =

            .

 

  • 3. Query the last day of a month

 CALL FUNCTION 'LAST_DAY_OF_MONTHS'

    EXPORTING

      DAY_IN = FSTDAY_NMTH

    IMPORTING

      LAST_DAY_OF_MONTH = LSTDAY_NMTH

    EXCEPTIONS

      DAY_IN_NO_DATE = 1

      OTHERS = 2.

Description: Enter a date, the function returns the last day of the month of the date on which the date falls.

 

** Calculated on the first day of a date

DATA:  T_DATE TYPE DATE VALUE '20100810'.

T_DATE+6(2) = 01.

Description: The position of the date of a day, is the first of the month.

 

 

  • 4. Calculate the date to another date

CALL FUNCTION 'RP_CALC_DATE_IN_INTERVAL'

   EXPORTING

      DATE            = LSTDAY

      DAYS            = 1

      MONTHS          = 0

      SIGNUM          = '+'

      YEARS           = 0

   IMPORTING

      CALC_DATE       = FSTDAY_NMTH.

Description: Enter a date, day of the input interval, month, year, operator input, the function returns the calculated date.

 

  • The current time is how to find the first day and the last day of the last month? 

CALL FUNCTION 'FIMA_DATE_CREATE' 

        EXPORTING 

             I_DATE = SY-Datum 

             I_MONTHS                = '-1' 

             I_SET_LAST_DAY_OF_MONTH = 'X' 

        IMPORTING 

             E_DATE                  = LASTDATE. 

LASTDATE is the last day of last month. 

FIRSTDAY is the first day of the month 

 

 

  • 6. Get the number of days between two dates separated by: 

 

FIMA_DAYS_AND_MONTHS_AND_YEARS 

  DATA: zdays TYPE i.

      CALL FUNCTION 'FIMA_DAYS_AND_MONTHS_AND_YEARS'
        EXPORTING
          i_date_from    = tem-gltrp
          i_date_to      = sy-datum
          i_flg_separate ' '       "
        IMPORTING
          e_days         = zdays.
      zdays = zdays + 1.
      IF zdays <= 7.
        tem-sctime '1周以内'.
      ELSEIF zdays <= 30.
        tem-sctime '1个月以内'.
      ELSEIF zdays <= 90.
        TEM -sctime  'within three months' .
      The ELSE .
        TEM -sctime  '3 months or more' .
      ENDIF

  • 7, the plant will convert the date to a calendar date

DATE_CONVERT_TO_FACTORYDATE "returned to the factory calendar dates based on date

 

    CALL FUNCTION 'DATE_CONVERT_TO_FACTORYDATE'
      EXPORTING
        factory_calendar_id          = ydm07r-fabkl
        correct_option               = plus
        date                         = rkpf-rsdat
      IMPORTING
        factorydate                  = fdayf1
      EXCEPTIONS
        date_after_range             01
        date_before_range            02
        date_invalid                 03
        factory_calendar_not_found   04
        correct_option_invalid       05
        calendar_buffer_not_loadable 06.

**MESSAGE ID M7

    CASE sy-subrc.
      WHEN 1.
        MESSAGE e523 WITH rkpf-rsdat.
      WHEN 2.
        MESSAGE e524 WITH rkpf-rsdat.
      WHEN 3.
        MESSAGE e525 WITH rkpf-rsdat.
      WHEN 4.
        MESSAGE e526 WITH ydm07r-fabkl.
      WHEN 5.
        MESSAGE e526 WITH ydm07r-fabkl.
      WHEN 6.
        MESSAGE e526 WITH ydm07r-fabkl.
    ENDCASE

 

 

 

I am receiving the annual operation and maintenance and remote SAP project, ECC, S / 4HANA, CRM, WDA. 

人天可谈,终身售后 有活请联系V信:18925782767(问问题免费,欢迎交流!)

本人常年接收SAP运维和远程项目,ECC,S/4HANA,CRM,WDA. 

人天可谈,终身售后 有活请联系V信:18925782767(问问题免费,欢迎交流!)

本人常年接收SAP运维和远程项目,ECC,S/4HANA,CRM,WDA. 

人天可谈,终身售后 有活请联系V信:18925782767(问问题免费,欢迎交流!)

 

 

你盯着我

 不关注

 不点赞

 不评论

 

难道是想暗算我 ???

卡忙on,用丘比特的箭暗算我吧!

笔芯准备  I'm ready!!
来不及解释了,快上车!!!

 

Guess you like

Origin www.cnblogs.com/rainysblog/p/11986387.html