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: 

Title to ALV Display

Former Member
0 Kudos

Hallo Friends,

I want to put TITLE to my ALV display. Can someone help to modify this code.

METHOD LIST_IN_ALV.

*Object Referenz

DATA LIST TYPE REF TO CL_GUI_ALV_GRID.

CREATE OBJECT LIST

EXPORTING

I_PARENT = CL_GUI_CONTAINER=>SCREEN0

EXCEPTIONS

ERROR_CNTL_CREATE = 1

ERROR_CNTL_INIT = 2

ERROR_CNTL_LINK = 3

ERROR_DP_CREATE = 4

OTHERS = 5.

IF SY-SUBRC <> 0.

  • MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO

  • WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.

ENDIF.

CALL METHOD LIST->SET_TABLE_FOR_FIRST_DISPLAY

EXPORTING

I_STRUCTURE_NAME = 'ZARASTRUC1'

CHANGING

IT_OUTTAB = AUSGABE.

CALL SELECTION-SCREEN 1000.

ENDMETHOD.

Blacky.

1 ACCEPTED SOLUTION

uwe_schieferstein
Active Contributor
0 Kudos

Hello Blacky

Forget to mention this excellent tutorial:

<a href="https://www.sdn.sap.comhttp://www.sdn.sap.comhttp://www.sdn.sap.com/irj/sdn/go/portal/prtroot/docs/library/uuid/e8a1d690-0201-0010-b7ad-d9719a415907">An Easy Reference For ALV Grid Control</a>

Regards

Uwe

5 REPLIES 5

uwe_schieferstein
Active Contributor
0 Kudos

Hello Blacky

Fill the layout gs_layout-GRID_TITLE (LVC_S_LAYO) and provide the layout at method SET_TABLE_FOR_FIRST_DISPLAY.

In order to change or retrieve the grid title use methods go_grid->SET_GRIDTITLE and go_grid->GET_FRONTEND_LAYOUT.

Regards

Uwe

uwe_schieferstein
Active Contributor
0 Kudos

Hello Blacky

Forget to mention this excellent tutorial:

<a href="https://www.sdn.sap.comhttp://www.sdn.sap.comhttp://www.sdn.sap.com/irj/sdn/go/portal/prtroot/docs/library/uuid/e8a1d690-0201-0010-b7ad-d9719a415907">An Easy Reference For ALV Grid Control</a>

Regards

Uwe

0 Kudos

Hallo Uwe,

I am still having problem with the title. Below is the implementation (DB selection) and start-of-selection part of my code. Can You Please help to modify this code to inlude title in the ALV listing.

I have used the method below, but it is not working:

CALL METHOD LIST->SET_GRIDTITLE

EXPORTING

I_GRIDTITLE = 'Selection in ALV'.

****************************************************************

CLASS TEST IMPLEMENTATION.

METHOD CONSTRUCTOR.

TYPES: BEGIN OF TAB

,CARRID TYPE SFLIGHT-CARRID

,CONNID TYPE SFLIGHT-CONNID

,END OF TAB

.

DATA: T_TAB TYPE STANDARD TABLE OF TAB. "Intern Tab

DATA WA_TTAB TYPE TAB. "Work Area

*Pre selection

SELECT SINGLE CARRID

CONNID

FROM SFLIGHT

INTO CORRESPONDING FIELDS OF WA_TTAB

WHERE CARRID = P_CARRID

AND CONNID = P_CONNID

.

IF SY-SUBRC NE 0.

EXIT.

ENDIF.

APPEND WA_TTAB TO T_TAB.

*Selection into Structure Ausgabe

SELECT CARRID

CONNID

FLDATE

CUSTOMID

SMOKER

FROM SBOOK

INTO CORRESPONDING FIELDS OF TABLE AUSGABE

FOR ALL ENTRIES IN T_TAB

WHERE CARRID = T_TAB-CARRID

AND CONNID = T_TAB-CONNID

.

ENDMETHOD. "constructor

METHOD GET_AUSGABE_DATA.

ENDMETHOD. "GET_AUSGABE_DATA

"get_ausgabe_data

METHOD WRITE_DATA.

ENDMETHOD. "write_data

METHOD LIST_IN_ALV.

DATA: LIST TYPE REF TO CL_GUI_ALV_GRID

,LIST_CONTAINER TYPE REF TO CL_GUI_CUSTOM_CONTAINER

.

CREATE OBJECT LIST

EXPORTING

I_PARENT = CL_GUI_CONTAINER=>DEFAULT_SCREEN.

IF SY-SUBRC <> 0.

EXIT.

ENDIF.

CALL METHOD LIST->SET_GRIDTITLE

EXPORTING

I_GRIDTITLE = 'Selection in ALV'.

CALL METHOD LIST->SET_TABLE_FOR_FIRST_DISPLAY

EXPORTING

I_STRUCTURE_NAME = 'ZARASTRUC1'

CHANGING

IT_OUTTAB = AUSGABE.

IF SY-SUBRC <> 0.

EXIT.

ENDIF.

CALL SELECTION-SCREEN 1000.

ENDMETHOD. "list_in_alv

ENDCLASS. "test IMPLEMENTATION

*Object Referenz

DATA: OBJ TYPE REF TO TEST.

START-OF-SELECTION.

CREATE OBJECT OBJ

EXPORTING

I_CARRID = P_CARRID

I_CONNID = P_CONNID

EXCEPTIONS

NOTHING_FOUND = 4.

IF SY-SUBRC NE 0.

EXIT.

ENDIF.

  • Listing

CALL METHOD OBJ->LIST_IN_ALV.

ENDIF.

END-OF-SELECTION.

0 Kudos

Hello Blacky

Simply change the order in which the methods are called because otherwise the method SET_TABLE_FOR_FIRST_DISPLAY will overwrite the grid title (its IMPORTING parameter IS_LAYOUT is empty and thus is_layout-grid_title = ' ' 😞

" CALL METHOD LIST->SET_GRIDTITLE
" EXPORTING
" I_GRIDTITLE = 'Selection in ALV'.

CALL METHOD LIST->SET_TABLE_FOR_FIRST_DISPLAY
EXPORTING
I_STRUCTURE_NAME = 'ZARASTRUC1'
CHANGING
IT_OUTTAB = AUSGABE.
IF SY-SUBRC <> 0.
EXIT.
ENDIF.

CALL METHOD LIST->SET_GRIDTITLE
EXPORTING
I_GRIDTITLE = 'Selection in ALV'.

CALL SELECTION-SCREEN 1000.
ENDMETHOD. "list_in_alv
ENDCLASS. "test IMPLEMENTATION
...

When you change to grid title after the first display then you have to refresh (-> call method go_grid->REFRESH_TABLE_DISPLAY).

Regards

Uwe

0 Kudos

Danke Uwe,

Problem gelöst und ich habe max point gegeben.

Blacky