2007 Aug 31 8:41 AM
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.
2007 Aug 31 9:58 AM
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
2007 Aug 31 8:52 AM
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
2007 Aug 31 9:58 AM
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
2007 Aug 31 12:08 PM
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.
2007 Aug 31 12:38 PM
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
2007 Aug 31 7:45 PM
Danke Uwe,
Problem gelöst und ich habe max point gegeben.
Blacky