Application Development Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 

Re: ALV grid date format MM/DD/YYYY

Former Member
0 Kudos

Hi All,

i am craeting report in ALV grid, in that report i want to dispaly date like 'MM/DD/YYYY'. present its display like YYYYMMDD.

can you give me some idea...

Thanks

zeni

5 REPLIES 5

amit_khare
Active Contributor
0 Kudos

before pasing it to ALV conver the date format.

rainer_hbenthal
Active Contributor
0 Kudos

refer to a date type in the fieldcatalog andthe date will be converted automatically according tothe user settings. dont transformthe date yourself.

Former Member

If you want to use the date type (this is the easiest way and it will be formatted according to the logon default of the master data of the current user):

1. Be sure you are using a proper date type in the output table.

2. Make sure that the following fields of the field catalog contain the following:


    LVC_S_FCAT-DATATYPE = 'DATS'. 
    LVC_S_FCAT-INTTYPE = 'D'.
    LVC_S_FCAT-INTLEN = '000008'.
    LVC_S_FCAT-DD_OUTLEN = '000010'.

However if you want to have a more generic approach that is independent on the user master data:

Assuming output_tab-external_date is of type C and has 10 digits.


data: date_int  type d value '20080808'.

case date_format.
  when 'MM/DD/YYYY'.
    write date_int to output_tab-external_date MM/DD/YYYY.

   when 'MM/DD/YY'.
     write date_int to output_tab-external_date MM/DD/YY.

   when 'DD/MM/YYYY'.
     write date_int to output_tab-external_date DD/MM/YYYY.

   when 'DD/MM/YY'.
     write date_int to output_tab-external_date DD/MM/YY.

endcase.

append output_tab. 

Then make sure that the following fields of the field catalog contain the following:


    LVC_S_FCAT-DATATYPE = 'CHAR'. 
    LVC_S_FCAT-INTTYPE = 'C'.
    LVC_S_FCAT-INTLEN = '000010'.
    LVC_S_FCAT-DD_OUTLEN = '000010'.

Former Member
0 Kudos

hi, to avoid this:

LVC_S_FCAT-DATATYPE = 'DATS'. 
    LVC_S_FCAT-INTTYPE = 'D'.
    LVC_S_FCAT-INTLEN = '000008'.
    LVC_S_FCAT-DD_OUTLEN = '000010'.

and all other things, just refer your field to a DATUM data element. Like this:


data:
....
....
date_today type datum,
....
....

The convertion of the field to DD/MM/YYYY will be automatically.

Former Member
0 Kudos

Hi,

Otherwise you can declare the date field as CHAR10, and you can write the date value in to that field as

: write dat1 into dat2 MM/DD/YYYY.

Where dat1 is of type DATS, and dat2 is of type CHAR10.

While passing into the ALV pass the dat2.

It will be solved.

Regards

Elini.P