10-08-2008 12:14 PM
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
10-08-2008 12:21 PM
10-08-2008 12:45 PM
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
10-08-2008 12:54 PM
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.
10-08-2008 12:55 PM
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