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: 

Changing Column Names in ALV Object Model

Former Member
0 Kudos

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:

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.

9 REPLIES 9

Former Member
0 Kudos

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

raymond_giuseppi
Active Contributor
0 Kudos

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

former_member194669
Active Contributor
0 Kudos

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

Former Member
0 Kudos

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

Former Member
0 Kudos

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.

Bhaskar_K
Explorer
0 Kudos

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

Former Member
0 Kudos

HI

Former Member
0 Kudos

Use the DDICTXT field of the fielcat structure.

Former Member

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.