15
Oct
Date formatting for Display in ABAP Program
Posted by Admin, under ABAP, Formatting, Function Modules, Sample Code, TutorialFunction 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.

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:

Post a Comment