sapdev logo background
sapdev logo sapdev logo
Comments

Convert month value of a date to text




The following ABAP code gets the month value of a particular date (YYYYMMDD) and converts it to its text value. I know its a very crude way of doing it but it does the job and having the ABAP code below provides a quick and easy way to copy and paste it into your SAP program.

DATA: gd_datetext TYPE string.
  CASE sy-datum+4(2).
    WHEN '01'.
      gd_datetext = 'January'.
    WHEN '02'.
      gd_datetext = 'February'.
    WHEN '03'.
      gd_datetext = 'March'.
    WHEN '04'.
      gd_datetext = 'April'.
    WHEN '05'.
      gd_datetext = 'May'.
    WHEN '06'.
      gd_datetext = 'June'.
    WHEN '07'.
      gd_datetext = 'July'.
    WHEN '08'.
      gd_datetext = 'August'.
    WHEN '09'.
      gd_datetext = 'September'.
    WHEN '10'.
      gd_datetext = 'October'.
    WHEN '11'.
      gd_datetext = 'November'.
    WHEN '12'.
      gd_datetext = 'December'.
  ENDCASE.

  concatenate sy-datum(2) gd_datetext sy-datum+2(2) into gd_datetext
                                                   separated by space.




comments powered by Disqus