ABAP Program: Output of Date Format

Suppose a date is given in the format 20050428 how to get the output in the format 28th Apr 2005.

FORM set_text_date.

DATA: month(9),
      year(4),
      date(2).

CASE p_frd+4(2).

WHEN '01'.
  month = 'January'.

WHEN '02'.
  month = 'February'.

WHEN '03'.
  month = 'March'.

WHEN '04'.
  month = 'April'.

WHEN '05'.
  month = 'May'.

WHEN '06'.
  month = 'June'.

WHEN '07'.
  month = 'July'.

WHEN '08'.
  month = 'August'.

WHEN '09'.
  month = 'September'.

WHEN '10'.
  month = 'October'.

WHEN '11'.
  month = 'November'.

WHEN '12'.
  month = 'December'.

WHEN OTHERS.

ENDCASE.

WRITE p_frd+0(4) TO year.

WRITE p_frd+6(2) TO date.

CONCATENATE month date ',' year INTO return_date SEPARATED BY space.

CONDENSE return_date.

ENDFORM.

ABAP Tips by : Kiran

Currently my date is getting printed in format 05262005.
I want the output as 26 May, 2005.
I have tried using Set date mask option but it is not picking up in the output.

Code:

This code yields as 12 march 2006.

DATA: ZTEMP(9). 

CLEAR: ZTEMP, ZDD, ZMMM, ZYYYY. 

CALL FUNCTION 'CONVERSION_EXIT_IDATE_OUTPUT' 
EXPORTING 
INPUT = IS_DLV_DELNOTE-HD_GEN-CREA_DATE 
IMPORTING 
OUTPUT = ZTEMP. 

ZDD = ZTEMP+3(2). 
ZMMM = ZTEMP+0(3). 
ZYYYY = ZTEMP+5(4).

ABAP Tips by : Sujana

ABAP Tips

Fast Links:
A Sample ALV Program 
ALV Reporting - Z_LIST_MATERIALS

Get help for your ABAP problems
Do you have a ABAP Question?

SAP Books
SAP Certification, Functional, Basis Administration and ABAP Programming Reference Books

More ABAP Tips

Best regards,
SAP Basis, ABAP Programming and Other IMG Stuff
http://www.erpgreat.com

All the site contents are Copyright © www.erpgreat.com and the content authors. All rights reserved.
All product names are trademarks of their respective companies.  The site www.erpgreat.com is in no way affiliated with SAP AG.
Every effort is made to ensure the content integrity.  Information used on this site is at your own risk.
 The content on this site may not be reproduced or redistributed without the express written permission of
www.erpgreat.com or the content authors.