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

Date mask in ALV grid

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

Add a comment
10|10000 characters needed characters exceeded

Assigned Tags

Related questions

4 Answers

  • author's profile photo Former Member
    Former Member
    Posted on Oct 08, 2008 at 11:21 AM

    Hello,

    Take a look on this: .

    Regards.

    Add a comment
    10|10000 characters needed characters exceeded

  • Posted on Oct 08, 2008 at 11:45 AM

    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

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Oct 08, 2008 at 11:54 AM

    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.

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Oct 08, 2008 at 11:55 AM

    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

    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.