Skip to Content
author's profile photo Former Member
Former Member

date conversion

Hi Abapers,

I need a FM which can convert date: YYYYMMDD to MM/DD/YYYY.

I have used the FM '/SAPDII/SPP05_CONVERT_DATE' to achieve this. but the problem is it doesnt handle exceptions. so it may lead to dump in some scenarios. kindly suggest me some Fm which can handle exceptions too.

Regards,

Radhika.

Add a comment
10|10000 characters needed characters exceeded

Assigned Tags

Related questions

5 Answers

  • author's profile photo Former Member
    Former Member
    Posted on Nov 22, 2007 at 08:12 AM

    Do like this

    Data: Var1 type sy-datum,

    var2(10) type c.

    var1 = sy-datum.

    Concatanate var14(2)'/' var16(2) '/' var1+0(4) into var2.

    write var2.

    function module to convert date format from yyyymmdd to mmddyyyy format

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Nov 22, 2007 at 08:15 AM

    Hi Prem,

    Do like this

    YYYYMMDD to MM/DD/YYYY

    Data: date1 type sy-datum,
             date2(10) type c.
    
    Date1 = sy-datum. " This will be in YYYYMMDD format
    
    Concatenate date1+4(2) date1+6(2) + date1+0(4) into date2 seperated by '/'.
    
    write date2.

    <b>Reward Points if this helps,</b>

    Satish

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Nov 22, 2007 at 08:16 AM

    hi

    may this will help u..

    data: gd_date(10). "field to store output date

    • Converts SAP date from 20020901 to 01.09.2002

    write sy-datum to gd_date dd/mm/yyyy.

    • Converts SAP date from 20020901 to 01.09.02

    write sy-datum to gd_date dd/mm/yy.

    Prarthan

    Add a comment
    10|10000 characters needed characters exceeded

  • Posted on Nov 22, 2007 at 08:27 AM

    Hi,

    Try this FM

    CALL FUNCTION 'CONVERT_DATE_TO_EXTERNAL'

    EXPORTING

    date_internal = lv_date

    IMPORTING

    date_external = lv_date1

    EXCEPTIONS

    date_internal_is_invalid = 1

    OTHERS = 2.

    IF sy-subrc <> 0.

    MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno

    WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.

    ENDIF.

    Regards,

    Prashant

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Nov 23, 2007 at 01:27 PM

    to convert yyyymmdd to dd.mm.yyyy

    data : wa1 type sy-datum,

    wa2(10).

    concatenate wa1+6(2)'.'

    wa1+4(2)'.'

    wa1(4) into wa2.

    Add a comment
    10|10000 characters needed characters exceeded

Before answering

You should only submit an answer when you are proposing a solution to the poster's problem. If you want the poster to clarify the question or provide more information, please leave a comment instead, requesting additional details. When answering, please include specifics, such as step-by-step instructions, context for the solution, and links to useful resources. Also, please make sure that you answer complies with our Rules of Engagement.
You must be Logged in to submit an answer.

Up to 10 attachments (including images) can be used with a maximum of 1.0 MB each and 10.5 MB total.