tags:

views:

153

answers:

1

Hi there,

I'm new to abap and just writing my first application. Now I got a date of the type SYDATUM and wondering how to format it in a format like m/d/y. I've found some snippets on the web, but they were not really helpful. -thanks yor your help.

+5  A: 

You should be more specific - what exactly do you want to do with the date (use type D internally, it's shorter and does the same thing).

  • Do you want to WRITE it to a list screen? Use the formatting options described in the documentation and online help:

    WRITE l_my_date MM/DD/YYYY.

  • Do you want to convert it to a text variable? Very similar:

    WRITE l_my_date TO l_my_text MM/DD/YYYY.

  • To set the date format in a SAPscript form, see the SET DATE MASK command.

  • To print the formatted date in a SmartForm, use the WRITE command and a temporary variable (yes, ugly, I know...)

  • Most controls (ALV Grid for example) should take care of the format automatically.

However - be careful when hard-coding the format into your application. Usually you don't have to do this because the system automatically uses the format specified in the user master data. This ensures that every user will see the date formatted according to their locale settings.

vwegert