Date formatting for Display in ABAP Program

Function module FORMAT_DATE_4_OUTPUT comes in handy in case we need simple formatting on date. Formatting which involves change in position day, month and year, changing the separator we can achieve with this function module. Following sample code shows how we can manipulate date directly to different formats.

Date Formats

 

 

Sample code:

 

Program ZDATEFORMAT.
DATA : v_date TYPE syst-datum ,
      lv_foramt TYPE char10  .

START-OF-SELECTION .
PERFORM format_date USING 'DD.MM.YYYY' .
PERFORM format_date USING 'DD/MM/YYYY' .
PERFORM format_date USING 'DD/MM/YY' .
PERFORM format_date USING 'YY-MM-DD' .
PERFORM format_date USING 'MM*DD*YYYY' .
PERFORM format_date USING 'YY,MM,DD' .

*&---------------------------------------------------------------------*
*&      Form format_date
*&---------------------------------------------------------------------*
FORM format_date USING iv_format TYPE rn1datum-format.
  DATA : lv_date TYPE rn1datum-datex .
  CALL FUNCTION 'FORMAT_DATE_4_OUTPUT'
  EXPORTING
    datin  = sy-datum
    format = iv_format
  IMPORTING
    datex  = lv_date.
  WRITE : / sy-datum , ' Format : ' , iv_format , lv_date .
ENDFORM.                    "format_date

You might also be interested in these posts:

  1. ABAP Program to display SAP Data in 3-Dimension
  2. Formatting SAPScript / SMARTFORMS in SAP
  3. ABAP Program to Display SE78 pictures on Screen
  4. ABAP Program to add Colors in ALV Grid
  5. ABAP Program for Table Maintenance in SAP

No Responses to “Date formatting for Display in ABAP Program”

Post a Comment