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: 

Date mask in ALV grid

Former Member
0 Kudos

Hi all,

I have a requirement. I am displaying the output in alv grid. In that there are 3 date fields. My client want to display that date fields like YYYY/MM/DD this format. How can we do this with change fieldcat. Could you please suggest me?

Advance Thanks

4 REPLIES 4

Former Member
0 Kudos

Hello,

Take a look on this: .

Regards.

MarcinPciak
Active Contributor
0 Kudos

Hi,

You can't enter to D type field (which is of 8 char size) a string which is of 10 char size.

Instead you may swap all D (date) fields with C(10) fields, but this require an internal table exactly with same structure you display in ALV, but with change D -> C(10) fields.

Here is an example


"suppose your data are in such table
data: it_alv_org type table .... 

"define new table with same structure but different fields type only where Date type
data: begin of it_alv_mod occurs 0,
          field1 like il_alv_org-field1,
          field2 like it_alv_org-field2,
          ...
          field3(10) type c,      "field3 in it_alv_org is of D type
          field4(10) type c,      "field4 too
         ....
        end of it_alv_mod.

"now rewrite all data
loop at it_alv_org.
    move-corresponding it_alv_org to it_alv_mod. 
    "now change all D->C(10)
    perform change_date using it_alv_org-field3 changing it_alv_mod-field3.
    perform change_date using it_alv_org-field4 changing it_alv_mod-field4.
    ...
endloop.


form change_date using org_field type d 
                           changing mod_field type c.
     mod_field(4) = org_field(4).
     mod_field+4(1) = '/'.
     mod_field+5(2) = org_field+4(2).
     mod_field+7(1) = '/'.
     mod_field+8(2) = org_field+6(2).
endform.

Now you only display it_alv_mod instead of it_alv_org. Remember that field catalog should be now created according to it_alv_mod.

I hope it will help you

Regards

Marcin

Former Member
0 Kudos

Hi ,

In field catalog there is an option for Edit Mask. Field EDIT_MASK. You can use this field to specify the edit mask.

OR

You can modify the dates before filling this in the internal table.

Former Member
0 Kudos

Hi Sreekala,

Try this.

WRITE <ur field name> TO <which field you want to store> USING EDIT MASK '____/__/__'.

This should be quite simple.

Regards,

Shobana.K

Edited by: Shobana k on Oct 8, 2008 1:55 PM