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

Changing Column Names in ALV Object Model

Hi All,

In a report development using ALV Object Model, I am required to over write the text given in the data elements for all the fields and display customized text, for the ALV column texts. This is proving to be rather tricky and doesn't work.

I read that to do this, we need to delete the DDIC bindings for the columns, which could be done through CL_SALV_WD_COLUMN_HEADER->SET_PROP_DDIC_BINDING_FIELD. To understand it's usage I researched some more and found the thread: changing-alv-column-name

What I understood from this thread is that the above mentioned class is for use in Web Dynpros. My query is, can't this be used in the context outside of Web Dynpro? If yes, please guide me on how to instantiate classes CL_SALV_WD_COLUMN and CL_SALV_WD_COLUMN_HEADER. If no, please suggest an alternative.

Thanks and Regards,

Vidya.

Add a comment
10|10000 characters needed characters exceeded

Assigned Tags

Related questions

9 Answers

  • author's profile photo Former Member
    Former Member
    Posted on Dec 12, 2008 at 06:38 PM

    Hi Vidya

    You can create the Field Catlog like this in your object oriented ALV also.

    lv_fldcat-row_pos = '1'.

    lv_fldcat-col_pos = '1'.

    lv_fldcat-fieldname = 'VBELN'.

    lv_fldcat-tabname = 'IT_OUTPUT'.

    lv_fldcat-outputlen = 10.

    lv_fldcat-scrtext_m = 'Order'.

    lv_fldcat-icon = 'X'.

    Neha

    Add a comment
    10|10000 characters needed characters exceeded

  • Posted on Dec 12, 2008 at 06:45 PM

    You may try with SET_DDIC_REFERENCE or APPLY_DDIC_STRUCTURE methods of CL_SALV_COLUMN class Change DDIC reference for an individual column/for several columns ([Change of DDIC Reference for a Column|http://help.sap.com/saphelp_sm32/helpdata/en/2c/762c41089b6e24e10000000a155106/frameset.htm])

    If you only want to change the texts (header, selection) try with SET_LONG_TEXT, SET_MEDIUM_TEXT and SET_SHORT_TEXT methods of CL_SALV_COLUMN. ([Column Header|http://help.sap.com/saphelp_sm32/helpdata/en/e3/e3eb40c4f8712ae10000000a155106/frameset.htm])

    Read the documentation in the above given links and try some search at sdn on keywords like

    - [GET_COLUMN ALV|https://www.sdn.sap.com/irj/scn/advancedsearch?cat=sdn_all&query=get_column+alv&adv=false&sortby=cm_rnd_rankvalue]

    - [SET_DDIC_REFERENCE|https://www.sdn.sap.com/irj/scn/advancedsearch?cat=sdn_all&query=set_ddic_reference&adv=false&sortby=cm_rnd_rankvalue]

    - [SET_LONG_TEXT|https://www.sdn.sap.com/irj/scn/advancedsearch?cat=sdn_all&query=set_long_text&adv=false&sortby=cm_rnd_rankvalue]

    Regards

    Add a comment
    10|10000 characters needed characters exceeded

  • Posted on Dec 12, 2008 at 06:47 PM

    Try to do this way

    data: gr_columns    type ref to cl_salv_columns_table.
    ...
    ...
    ...
    gr_column ?= gr_columns->get_column( text-112 ).   " text-112 = SIGNED
    gr_column->set_long_text( 'Signed by Approver' ).   " Here Signed by Approver is the custom heading for the column
    

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Dec 12, 2008 at 06:57 PM

    Hi,

    You can use the GET_COLUMNS and SET_COLUMNS method.

    With GET_COLUMNS you get a reference to the individual column objects of the ALV output and make all the technical settings for a column. Once you a reference to each column, you case use the SET_COLUMNS method of each column reference.

    [GET_COLUMNS|http://help.sap.com/saphelp_nw04/helpdata/en/5e/88d440e14f8431e10000000a1550b0/frameset.htm]

    [SET_COLUMNS|http://help.sap.com/saphelp_nw04/helpdata/en/e3/e3eb40c4f8712ae10000000a155106/content.htm]

    regards,

    Advait

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Dec 12, 2008 at 07:45 PM

    I thank all of you for trying to help me out. But I'd like to mention here that SET_LONG_TEXT, SET_MEDIUM_TEXT and SET_SHORT_TEXT are not overwriting the labels of the data elements. There is a lot of shuffling around and manipulation that needs to be done, with respect to the output length and the length of the customized column text. Hence, it would probably suit me best if I am somehow able to delink the DDIC reference from the column. Do let me know your thoughts.

    Thanks and Regards,

    Vidya.

    Add a comment
    10|10000 characters needed characters exceeded

  • Posted on Dec 12, 2008 at 10:15 PM

    Hi Vidya,

    I am not sure? But I would re-build my internal table dynamically and use that instead of the structure being used.

    Thanks,

    Gokul

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Feb 26, 2009 at 04:18 AM

    HI

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on May 28, 2009 at 11:01 AM

    Use the DDICTXT field of the fielcat structure.

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Jul 11, 2016 at 10:46 AM

    First of all if you had used "LVC_FIELDCATALOG_MERGE" and "REUSE_ALV_GRID_DISPLAY_LVC" Function modules then the columns name will come form DDIC.

    But to overwrite this you can use this code for every single column where you want the different name than DDIC. try this out:-

    wa_fldcat-seltext = 'Location'.

    wa_fldcat-reptext = 'Location'.

    wa_fldcat-scrtext_s = wa_fldcat-scrtext_m = wa_fldcat-scrtext_l = 'Location'.

    MODIFY it_fldcat FROM wa_fldcat TRANSPORTING seltext reptext scrtext_l scrtext_s scrtext_m WHERE fieldname = 'BTEXT'.


    1. You need to know which name you want as column name like I had used Location instead of "Personnel Subarea Text",

    2. and its table field name from which it was earlier picking the name....like I had "BTEXT"

    3. define it_fldcat type lvc_t_fcat. and wa_fldcat type lvc_s_fcat.

    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.