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 for ALV Grid

Former Member
0 Kudos

Hello,

who can tell me how can i create title for my alv grid??? Thanks.

1 ACCEPTED SOLUTION

mnicolai_77
Active Participant
0 Kudos

hi,

if you want to create a title for your ALV_GRID you have ti set value into a field of the layout structrure

for example

data: ls_layo type lvc_s_layo

ls_layo-grid_title = 'Title of my grid'.

then you pass the value of layout structure to the function.

Hope that is useful.

Bye

Marco

7 REPLIES 7

Former Member
0 Kudos

Hi,

set titlebar 'title'.

Plzz reward points if it helps.

Former Member
0 Kudos

Hi jane,

If u r using classes then in the screen pbo u can do set titlebar 'title'.

Check this example.

THIS IS TO DISPLAY THE HEADER WITH LOGO.

TABLES VBAK.

TYPE-POOLS SLIS.

Data Declaration

TYPES: BEGIN OF T_VBAK,

VBELN TYPE VBAK-VBELN,

ERDAT TYPE VBAK-ERDAT,

ERNAM TYPE VBAK-ERNAM,

AUDAT TYPE VBAK-AUDAT,

VBTYP TYPE VBAK-VBTYP,

NETWR TYPE VBAK-NETWR,

VKORG TYPE VBAK-VKORG,

VKGRP TYPE VBAK-VKGRP,

LINE_COLOR(4) TYPE C,

END OF T_VBAK.

DATA: IT_VBAK TYPE STANDARD TABLE OF T_VBAK INITIAL SIZE 0,

WA_VBAK TYPE T_VBAK.

ALV Data Declaration

DATA: FLDCAT TYPE SLIS_T_FIELDCAT_ALV WITH HEADER LINE,

GD_LAYOUT TYPE SLIS_LAYOUT_ALV,

GD_REPID TYPE SY-REPID.

START-OF-SELECTION.

PERFORM DATA_RETRIEVAL.

PERFORM BLD_FLDCAT.

PERFORM BLD_LAYOUT.

PERFORM DISPLAY_ALV_REPORT.

Build Field Catalog for ALV Report

FORM BLD_FLDCAT.

FLDCAT-FIELDNAME = 'VBELN'.

FLDCAT-SELTEXT_M = 'Sales Document'.

FLDCAT-COL_POS = 0.

*FLDCAT-EMPHASIZE = 'C411'.

FLDCAT-OUTPUTLEN = 20.

FLDCAT-KEY = 'X'.

APPEND FLDCAT TO FLDCAT.

CLEAR FLDCAT.

FLDCAT-FIELDNAME = 'ERDAT'.

FLDCAT-SELTEXT_L = 'Record Date created'.

FLDCAT-COL_POS = 1.

FLDCAT-KEY = 'X'.

APPEND FLDCAT TO FLDCAT.

CLEAR FLDCAT.

FLDCAT-FIELDNAME = 'ERNAM'.

FLDCAT-SELTEXT_L = 'Cteated Object Person Name'.

APPEND FLDCAT TO FLDCAT.

CLEAR FLDCAT.

FLDCAT-FIELDNAME = 'AUDAT'.

FLDCAT-SELTEXT_M = 'Document Date'.

FLDCAT-COL_POS = 3.

FLDCAT-EMPHASIZE = 'C110'.

APPEND FLDCAT TO FLDCAT.

CLEAR FLDCAT.

FLDCAT-FIELDNAME = 'VBTYP'.

FLDCAT-SELTEXT_L = 'SD Document category'.

FLDCAT-COL_POS = 4.

APPEND FLDCAT TO FLDCAT.

CLEAR FLDCAT.

FLDCAT-FIELDNAME = 'NETWR'.

FLDCAT-SELTEXT_L = 'Net Value of the SO in Document Currency'.

FLDCAT-COL_POS = 5.

FLDCAT-OUTPUTLEN = 60.

FLDCAT-DO_SUM = 'X'.

FLDCAT-DATATYPE = 'CURR'.

APPEND FLDCAT TO FLDCAT.

CLEAR FLDCAT.

FLDCAT-FIELDNAME = 'VKORG'.

FLDCAT-SELTEXT_L = 'Sales Organization'.

FLDCAT-COL_POS = 6.

APPEND FLDCAT TO FLDCAT.

CLEAR FLDCAT.

FLDCAT-FIELDNAME = 'VKGRP'.

FLDCAT-SELTEXT_M = 'Sales Group'.

FLDCAT-COL_POS = 7.

FLDCAT-EMPHASIZE = 'C801'.

APPEND FLDCAT TO FLDCAT.

CLEAR FLDCAT.

ENDFORM.

Build Layout for ALV Grid Report

FORM BLD_LAYOUT.

GD_LAYOUT-NO_INPUT = 'X'.

GD_LAYOUT-COLWIDTH_OPTIMIZE = 'X'.

GD_LAYOUT-INFO_FIELDNAME = 'LINE_COLOR'.

GD_LAYOUT-WINDOW_TITLEBAR = 'GRID DISPLAY'.

GD_LAYOUT-CONFIRMATION_PROMPT = 'X'.

ENDFORM.

Display report using ALV grid

FORM DISPLAY_ALV_REPORT.

GD_REPID = SY-REPID.

CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'

EXPORTING

I_CALLBACK_PROGRAM = GD_REPID

IS_LAYOUT = GD_LAYOUT

I_CALLBACK_TOP_OF_PAGE = 'TOP_OF_PAGE'

I_GRID_TITLE = 'SALES DOCUMENT HEADER'

IT_FIELDCAT = FLDCAT[]

I_SAVE = 'X'

TABLES

T_OUTTAB = IT_VBAK

EXCEPTIONS

PROGRAM_ERROR = 1

OTHERS = 2.

IF SY-SUBRC 0.

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

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

ENDIF.

ENDFORM.

Retrieve data from VBAK table and populate itab IT_VBAK

FORM DATA_RETRIEVAL.

DATA LD_COLOR(1) TYPE C.

SELECT VBELN ERDAT ERNAM AUDAT VBTYP NETWR VKORG

UP TO 20 ROWS

FROM VBAK

INTO TABLE IT_VBAK.

LOOP AT IT_VBAK INTO WA_VBAK.

LD_COLOR = LD_COLOR + 1.

IF LD_COLOR = 8.

LD_COLOR = 1.

ENDIF.

CONCATENATE 'C' LD_COLOR '10' INTO WA_VBAK-LINE_COLOR.

MODIFY IT_VBAK FROM WA_VBAK.

ENDLOOP.

ENDFORM.

FORM TOP_OF_PAGE.

DATA: T_HEADER TYPE SLIS_T_LISTHEADER,

W_HEADER TYPE SLIS_LISTHEADER.

W_HEADER-TYP = 'H'.

W_HEADER-INFO = 'WELCOME HEADER LIST'.

APPEND W_HEADER TO T_HEADER.

W_HEADER-TYP = 'S'.

W_HEADER-KEY = 'REPORT:'.

W_HEADER-INFO = SY-REPID.

APPEND W_HEADER TO T_HEADER.

W_HEADER-TYP = 'S'.

W_HEADER-KEY = 'DATE:'.

CONCATENATE SY-DATUM6(2) ' / ' SY-DATUM4(2) ' / ' SY-DATUM(4) INTO W_HEADER-INFO.

APPEND W_HEADER TO T_HEADER.

CALL FUNCTION 'REUSE_ALV_COMMENTARY_WRITE'

EXPORTING

IT_LIST_COMMENTARY = T_HEADER

I_LOGO = ‘TRIPODSM.GIF’.

ENDFORM.

Former Member
0 Kudos

Hi,

see Kausik sample code there

in top of page u can give your title

Former Member
0 Kudos

HI,

in the layout PASSING TO FM.

GD_LAYOUT-WINDOW_TITLEBAR = 'YOUR TITEL'.

REWARD POINTS IF HELP FULL.

REGARDS,

SREE.....

Former Member
0 Kudos

Hi Jane,

Below is an example to create title for ALV grid

REPORT ZTEST_DIL4 .

TABLES ZMSTKSUM.

DATA : OK_CODE LIKE SY-UCOMM,

TAB_DISPLAY TYPE TABLE OF ZMSTKSUM,

C_CONTAINER TYPE SCRFNAME VALUE 'DILEEP_TEST1',

ALV_GRID TYPE REF TO CL_GUI_ALV_GRID,

C_CUSTOM_CONTAINER TYPE REF TO CL_GUI_CUSTOM_CONTAINER.

SELECTION-SCREEN BEGIN OF BLOCK B1 WITH FRAME TITLE TEXT-001.

SELECT-OPTIONS : S_WERKS FOR ZMSTKSUM-WERKS.

SELECTION-SCREEN END OF BLOCK B1.

SELECT * FROM ZMSTKSUM INTO TABLE TAB_DISPLAY WHERE WERKS IN S_WERKS.

CALL SCREEN 100.

*&----


*& Module STATUS_0100 OUTPUT

*&----


  • text

*----


MODULE STATUS_0100 OUTPUT.

SET PF-STATUS 'MAIN'.

  • SET TITLEBAR 'xxx'.

IF C_CUSTOM_CONTAINER IS INITIAL.

CREATE OBJECT C_CUSTOM_CONTAINER EXPORTING CONTAINER_NAME = C_CONTAINER

.

CREATE OBJECT ALV_GRID EXPORTING I_PARENT = C_CUSTOM_CONTAINER.

CALL METHOD ALV_GRID->SET_TABLE_FOR_FIRST_DISPLAY

EXPORTING

  • I_BUFFER_ACTIVE =

  • I_BYPASSING_BUFFER =

I_STRUCTURE_NAME = 'ZMSTKSUM'

  • IS_VARIANT =

  • I_SAVE =

  • I_DEFAULT = 'X'

  • IS_LAYOUT =

  • IS_PRINT =

  • IT_SPECIAL_GROUPS =

  • IT_TOOLBAR_EXCLUDING =

CHANGING

IT_OUTTAB = TAB_DISPLAY

  • IT_FIELDCATALOG =

  • IT_SORT =

  • IT_FILTER =

  • EXCEPTIONS

  • INVALID_PARAMETER_COMBINATION = 1

  • PROGRAM_ERROR = 2

  • others = 3

.

IF SY-SUBRC <> 0.

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

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

ENDIF.

ENDIF.

ENDMODULE. " STATUS_0100 OUTPUT

*&----


*& Module USER_COMMAND_0100 INPUT

*&----


  • text

*----


MODULE USER_COMMAND_0100 INPUT.

CASE OK_CODE.

WHEN 'EXIT'.

LEAVE PROGRAM.

ENDCASE.

ENDMODULE. " USER_COMMAND_0100 INPUT

Regards,

Chandru

Former Member
0 Kudos

Do the following

1) Decomment the code MODULE STATUS_0100. and then double click on it.

PROCESS BEFORE OUTPUT.

  • MODULE STATUS_0100.

2) It will take you to se38 and you will see the following set of statements

MODULE STATUS_0100 OUTPUT.

  • SET PF-STATUS 'xxxxxxxx'.

  • SET TITLEBAR 'xxx'.

ENDMODULE. " STATUS_0100 OUTPUT

3) decomment * SET TITLEBAR 'xxx'.

and give the title name instead of xxx.

mnicolai_77
Active Participant
0 Kudos

hi,

if you want to create a title for your ALV_GRID you have ti set value into a field of the layout structrure

for example

data: ls_layo type lvc_s_layo

ls_layo-grid_title = 'Title of my grid'.

then you pass the value of layout structure to the function.

Hope that is useful.

Bye

Marco