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: 

User defined column name not coming to output screen using OOPS Alv.

Former Member
0 Kudos

Hi all experts,

I deloped one sales report. Its working fine.  But i added one user defined field 'status' in my final table declaration.

once i checked with break point that column heading is coming correctly but once i use cl_salv_table to display report

the column heading is not coming but the value of this field coming correctly.

I have go through thread but i am not able rectify my issues. so can you guys as well as all experts please help me out over here.

I am sharing screen shot please once go through that. Some declaration i might have to do but i am not understand which i need to do for the same.

Thanks in advance to all.

Thanks & Regards,

kaushik.

Report declaration

DATA : R_ALV TYPE REF TO CL_SALV_TABLE.
DATA : R_FUNCTIONS TYPE REF TO CL_SALV_FUNCTIONS_LIST.
DATA : R_COLUMNS TYPE REF TO CL_SALV_COLUMNS_TABLE.


FORM DISPLAY .
IF P_OP = 'X' AND P_CL = ' '.
try.
call method CL_SALV_TABLE=>FACTORY
*  exporting
*   LIST_DISPLAY   = IF_SALV_C_BOOL_SAP=>FALSE
*    R_CONTAINER    = R_ALV
*    CONTAINER_NAME =
   importing
     R_SALV_TABLE   =  R_ALV
   changing
     T_TABLE        = T_FINAL
     .
R_FUNCTIONS = R_ALV->GET_FUNCTIONS( ).
R_FUNCTIONS->SET_ALL( IF_SALV_C_BOOL_SAP=>TRUE ).

R_COLUMNS = R_ALV->GET_COLUMNS( ).
R_COLUMNS->SET_OPTIMIZE( IF_SALV_C_BOOL_SAP=>TRUE ).



R_ALV->DISPLAY( ).

  catch CX_SALV_MSG .
    MESSAGE 'ERROR WHILE DISPLAYING THE REPORT .'  TYPE 'I' DISPLAY LIKE 'E'.
    LEAVE LIST-PROCESSING.
endtry.

please see the column heading after net value...

1 ACCEPTED SOLUTION

former_member194965
Active Participant
0 Kudos

Hi Kaushik,

After calling of GET_COLUMNS method, Call GET_COLUMN method in  CL_SALV_COLUMNS_TABLE class, Here declare your field and pass to GR_COLMN( CL_SALV_COLUMN_TABLE). And call SET_SHORT_TEXT,  SET_MEDIUM_TEXT,  SET_LONG_TEXT methods in CL_SALV_COLUMN_TABLE class.

Add this code:

  TRY.

   GR_COLMN ?= GR_COLMS->GET_COLUMN( COLUMNNAME = 'YOUR FIELD' ).

   GR_COLMN->SET_SHORT_TEXT( VALUE = 'Status' ).

   GR_COLMN->SET_MEDIUM_TEXT( VALUE = 'Status' ).

   GR_COLMN->SET_LONG_TEXT( VALUE = 'Status').

   CATCH CX_SALV_NOT_FOUND .

   ENDTRY.

Regards,

E.Ananthachari.

4 REPLIES 4

raymond_giuseppi
Active Contributor
0 Kudos

How did you declare the field in the interna table definition, how did you provide the column headings?

0 Kudos

Ok.

Thanks Raymond.

this is the way i declared int. table.

TYPES : BEGIN OF TY_FINAL,
           VKORG   TYPE VBAK-VKORG,
           VTEXT_S TYPE  TVKOT-VTEXT,
           VTWEG TYPE VBAK-VTWEG,
           VTEXT_D TYPE TVTWT-VTEXT,
           KUNNR  TYPE  VBAK-KUNNR,
           NAME1 TYPE    KNA1-NAME1,
           VBELN TYPE   VBAK-VBELN,
           ERDAT  TYPE  VBAK-ERDAT,
           NETWR   TYPE  VBAK-NETWR,
           STATUS(6) TYPE C,
         END OF TY_FINAL.


after this declaration i fetch the data accordingly and call the factory method. value is coming correctly

as per my test case.



but i didn't provide any heading its taking by default from ddic. if i want to provide in oops alv

how would be declaration part can you please help me out little.



Thanks & Regards,

kaushik.

former_member194965
Active Participant
0 Kudos

Hi Kaushik,

After calling of GET_COLUMNS method, Call GET_COLUMN method in  CL_SALV_COLUMNS_TABLE class, Here declare your field and pass to GR_COLMN( CL_SALV_COLUMN_TABLE). And call SET_SHORT_TEXT,  SET_MEDIUM_TEXT,  SET_LONG_TEXT methods in CL_SALV_COLUMN_TABLE class.

Add this code:

  TRY.

   GR_COLMN ?= GR_COLMS->GET_COLUMN( COLUMNNAME = 'YOUR FIELD' ).

   GR_COLMN->SET_SHORT_TEXT( VALUE = 'Status' ).

   GR_COLMN->SET_MEDIUM_TEXT( VALUE = 'Status' ).

   GR_COLMN->SET_LONG_TEXT( VALUE = 'Status').

   CATCH CX_SALV_NOT_FOUND .

   ENDTRY.

Regards,

E.Ananthachari.

0 Kudos

OK.

Thank you so much to all.

I resolved my Issue Mr. Ananthachari. The output is coming absolutely correct.  Thank you so much for your support.

Thank & Reagrds,

kaushik.