Skip to Content
0
May 18, 2015 at 04:04 PM

TOP of Page not displaying when using CALL METHOD G_GRID->set_table_for_first_display

683 Views

Hi Team,

I am not getting the TOP of Page when using CALL METHOD G_GRID->set_table_for_first_display.

I created Custom control , its displaying TOP of PAGE and output( but output is getting in 2 windows 1, top of page and 2nd output data and not in FULL screen. ).

If i delete Custom control , now OUTPUT is in FULL Screen and top of page is missing. Please let me know where I am doing wrong. Your inputs are appreciated.

Here is my code:

data i_fieldcat TYPE STANDARD TABLE OF lvc_s_fcat."Field catalog

FIELD-SYMBOLS: <fs_fcat> TYPE lvc_s_fcat.

DATA: w_style TYPE lvc_s_styl, "cell editing and

w_cellcolor TYPE lvc_s_scol, "For cell color

w_layout TYPE lvc_s_layo,"Layout structure

w_variant TYPE disvariant.

DATA: G_GRID TYPE REF TO CL_GUI_ALV_GRID.

* Filling the fieldcatalog table

CALL FUNCTION 'LVC_FIELDCATALOG_MERGE'

EXPORTING

i_structure_name = 'struc_name'

CHANGING

ct_fieldcat = i_fieldcat

EXCEPTIONS

inconsistent_interface = 1

program_error = 2

OTHERS = 3.

w_variant-report = sy-repid.

* Setting layout

w_layout-stylefname = 'CELLSTYLES' ."cell-push button and edit

w_layout-ctab_fname = 'CELLCOLOR'."For cell coloring

* For coloring closed Notifications.

LOOP AT GT_FINAL INTO GS_FINAL.

IF GS_FINAL-COMM EQ 'CLOSE'.

CLEAR w_cellcolor.

w_cellcolor-fname = 'COMM'.

w_cellcolor-color-col = SY-TABIX.

w_cellcolor-color-int = '1'.

w_cellcolor-color-inv = '1'.

APPEND w_cellcolor TO GS_FINAL-cellcolor.

MODIFY GT_FINAL FROM GS_FINAL INDEX SY-TABIX TRANSPORTING cellcolor.

ENDIF.

ENDLOOP.

LOOP AT i_fieldcat ASSIGNING <fs_fcat>.

CASE <fs_fcat>-fieldname.

* Making a column as Editable

WHEN 'BNAME'.

<fs_fcat>-edit = 'X'.

<fs_fcat>-REPTEXT = 'QSB Techn'.

<fs_fcat>-SCRTEXT_L = 'QSB Techn'.

<fs_fcat>-SCRTEXT_M = 'QSB Techn'.

<fs_fcat>-SCRTEXT_S = 'QSB Techn'.

WHEN 'COMM'.

<fs_fcat>-edit = 'X'.

<fs_fcat>-REPTEXT = 'Comment'.

<fs_fcat>-SCRTEXT_L = 'Comment'.

<fs_fcat>-SCRTEXT_M = 'Comment'.

<fs_fcat>-SCRTEXT_S = 'Comment'.

* Changing field Description for output

WHEN 'QMNUM'.

<fs_fcat>-SCRTEXT_L = 'Quality Note'.

<fs_fcat>-SCRTEXT_M = 'Quality Note'.

<fs_fcat>-SCRTEXT_S = 'Quality Note'.

WHEN 'STATUS'.

<fs_fcat>-REPTEXT = 'Open/Close'.

<fs_fcat>-SCRTEXT_L = 'Open/Close'.

<fs_fcat>-SCRTEXT_M = 'Open/Close'.

<fs_fcat>-SCRTEXT_S = 'Open/Close'.

WHEN 'CRT_NAME'.

<fs_fcat>-DD_OUTLEN = 20.

<fs_fcat>-SCRTEXT_L = 'Created By'.

<fs_fcat>-SCRTEXT_M = 'Created By'.

<fs_fcat>-SCRTEXT_S = 'Created By'.

WHEN 'CHG_NAME'.

<fs_fcat>-DD_OUTLEN = 20.

<fs_fcat>-SCRTEXT_L = 'Changed By'.

<fs_fcat>-SCRTEXT_M = 'Changed By'.

<fs_fcat>-SCRTEXT_S = 'Changed By'.

WHEN 'QMTXT'.

<fs_fcat>-DD_OUTLEN = 20.

<fs_fcat>-SCRTEXT_L = 'QM Note Description'.

<fs_fcat>-SCRTEXT_M = 'QM Note Description'.

<fs_fcat>-SCRTEXT_S = 'QM Note Description'.

WHEN 'TNAME'.

<fs_fcat>-REPTEXT = 'QSB Techn Name'.

<fs_fcat>-SCRTEXT_L = 'QSB Techn Name'.

<fs_fcat>-SCRTEXT_M = 'QSB Techn Name'.

<fs_fcat>-SCRTEXT_S = 'QSB Techn Name'.

WHEN 'BIIND'.

<fs_fcat>-REPTEXT = 'BI.Ind'.

<fs_fcat>-SCRTEXT_L = 'BI.Ind'.

<fs_fcat>-SCRTEXT_M = 'BI.Ind'.

<fs_fcat>-SCRTEXT_S = 'BI.Ind'.

ENDCASE.

ENDLOOP.

CREATE OBJECT G_CUSTOM_CONTAINER

EXPORTING CONTAINER_NAME = G_CONTAINER.

*Create TOP-Document

CREATE OBJECT O_DYNDOC_ID

EXPORTING STYLE = 'ALV_GRID'.

*Create Splitter for custom_container

CREATE OBJECT O_SPLITTER

EXPORTING PARENT = G_CUSTOM_CONTAINER

ROWS = 2

COLUMNS = 1.

CALL METHOD O_SPLITTER->GET_CONTAINER

EXPORTING

ROW = 1

COLUMN = 1

RECEIVING

CONTAINER = O_PARENT_TOP.

CALL METHOD O_SPLITTER->GET_CONTAINER

EXPORTING

ROW = 2

COLUMN = 1

RECEIVING

CONTAINER = O_PARENT_GRID.

*Set height for g_parent_html

CALL METHOD O_SPLITTER->SET_ROW_HEIGHT

EXPORTING

ID = 1

HEIGHT = 30.

CREATE OBJECT G_GRID

EXPORTING I_PARENT = cl_gui_container=>default_screen."O_PARENT_GRID.

*Set height for g_parent_html

CREATE OBJECT G_HANDLER.

SET HANDLER G_HANDLER->TOP_OF_PAGE FOR G_GRID.

*Calling the Method for ALV output

CALL METHOD G_GRID->set_table_for_first_display

EXPORTING

is_variant = w_variant

i_save = 'A'

is_layout = w_layout

CHANGING

it_outtab = gt_final

it_fieldcatalog = i_fieldcat

EXCEPTIONS

invalid_parameter_combination = 1

program_error = 2

too_many_lines = 3

OTHERS = 4.

CALL METHOD O_DYNDOC_ID->INITIALIZE_DOCUMENT

EXPORTING

BACKGROUND_COLOR = CL_DD_AREA=>COL_TEXTAREA.

*Processing events

CALL METHOD G_GRID->LIST_PROCESSING_EVENTS

EXPORTING

I_EVENT_NAME = 'TOP_OF_PAGE'

I_DYNDOC_ID = O_DYNDOC_ID.

CLASS LCL_EVENT_HANDLER DEFINITION .

PUBLIC SECTION .

METHODS:

*Event Handler for Top of page

TOP_OF_PAGE FOR EVENT TOP_OF_PAGE

OF CL_GUI_ALV_GRID

IMPORTING E_DYNDOC_ID.

ENDCLASS. "lcl_event_handler DEFINITION

CLASS LCL_EVENT_HANDLER IMPLEMENTATION.

METHOD TOP_OF_PAGE.

*Top-of-page event

PERFORM EVENT_TOP_OF_PAGE USING O_DYNDOC_ID.

ENDMETHOD. "top_of_page

FORM EVENT_TOP_OF_PAGE USING DG_DYNDOC_ID TYPE REF TO CL_DD_DOCUMENT.

DATA : DL_TEXT(255) TYPE C. "Text

CALL METHOD DG_DYNDOC_ID->ADD_TEXT

EXPORTING

TEXT = 'Flight Details'

SAP_STYLE = CL_DD_AREA=>HEADING

SAP_FONTSIZE = CL_DD_AREA=>LARGE

SAP_COLOR = CL_DD_AREA=>LIST_HEADING_INT.

CALL METHOD DG_DYNDOC_ID->ADD_GAP

EXPORTING

WIDTH = 200.

CALL METHOD O_DYNDOC_ID->ADD_PICTURE

EXPORTING

PICTURE_ID = 'ENJOYSAP_LOGO'.

*Add new-line

CALL METHOD DG_DYNDOC_ID->NEW_LINE.

CALL METHOD DG_DYNDOC_ID->NEW_LINE.

CLEAR : DL_TEXT.

*program ID

DL_TEXT = 'Program Name :'.

CALL METHOD DG_DYNDOC_ID->ADD_GAP.

CALL METHOD O_DYNDOC_ID->ADD_TEXT

EXPORTING

TEXT = DL_TEXT

SAP_EMPHASIS = CL_DD_AREA=>HEADING

SAP_COLOR = CL_DD_AREA=>LIST_HEADING_INT.

CLEAR DL_TEXT.

DL_TEXT = SY-REPID.

CALL METHOD O_DYNDOC_ID->ADD_TEXT

EXPORTING

TEXT = DL_TEXT

SAP_EMPHASIS = CL_DD_AREA=>HEADING

SAP_COLOR = CL_DD_AREA=>LIST_NEGATIVE_INV.

*Add new-line

CALL METHOD DG_DYNDOC_ID->NEW_LINE.

CLEAR : DL_TEXT.

CLEAR : DL_TEXT.

*program ID

DL_TEXT = 'User Name :'.

CALL METHOD DG_DYNDOC_ID->ADD_GAP.

CALL METHOD O_DYNDOC_ID->ADD_TEXT

EXPORTING

TEXT = DL_TEXT

SAP_EMPHASIS = CL_DD_AREA=>HEADING

SAP_COLOR = CL_DD_AREA=>LIST_HEADING_INT.

CLEAR DL_TEXT.

DL_TEXT = SY-UNAME.

CALL METHOD O_DYNDOC_ID->ADD_TEXT

EXPORTING

TEXT = DL_TEXT

SAP_EMPHASIS = CL_DD_AREA=>HEADING

SAP_COLOR = CL_DD_AREA=>LIST_NEGATIVE_INV.

*Add new-line

CALL METHOD DG_DYNDOC_ID->NEW_LINE.

CLEAR : DL_TEXT.

*Run Date

DL_TEXT = 'Run Date :'.

CALL METHOD DG_DYNDOC_ID->ADD_GAP.

CALL METHOD O_DYNDOC_ID->ADD_TEXT

EXPORTING

TEXT = DL_TEXT

SAP_EMPHASIS = CL_DD_AREA=>HEADING

SAP_COLOR = CL_DD_AREA=>LIST_HEADING_INT.

CLEAR DL_TEXT.

*Move date

WRITE SY-DATUM TO DL_TEXT.

CALL METHOD O_DYNDOC_ID->ADD_TEXT

EXPORTING

TEXT = DL_TEXT

SAP_EMPHASIS = CL_DD_AREA=>HEADING

SAP_COLOR = CL_DD_AREA=>LIST_NEGATIVE_INV.

*Add new-line

CALL METHOD DG_DYNDOC_ID->NEW_LINE.

CLEAR : DL_TEXT.

*Time

DL_TEXT = 'Time :'.

CALL METHOD DG_DYNDOC_ID->ADD_GAP.

CALL METHOD O_DYNDOC_ID->ADD_TEXT

EXPORTING

TEXT = DL_TEXT

SAP_EMPHASIS = CL_DD_AREA=>HEADING

SAP_COLOR = CL_DD_AREA=>LIST_HEADING_INT.

CLEAR DL_TEXT.

*Move time

WRITE SY-UZEIT TO DL_TEXT.

CALL METHOD O_DYNDOC_ID->ADD_TEXT

EXPORTING

TEXT = DL_TEXT

SAP_EMPHASIS = CL_DD_AREA=>HEADING

SAP_COLOR = CL_DD_AREA=>LIST_NEGATIVE_INV.

*Add new-line

CALL METHOD DG_DYNDOC_ID->NEW_LINE.

PERFORM DISPLAY.

ENDFORM. " EVENT_TOP_OF_PAGE

FORM DISPLAY.

*Creating html control

IF O_HTML_CNTRL IS INITIAL.

CREATE OBJECT O_HTML_CNTRL

EXPORTING

PARENT = O_PARENT_TOP.

ENDIF.

CALL METHOD O_DYNDOC_ID->MERGE_DOCUMENT.

O_DYNDOC_ID->HTML_CONTROL = O_HTML_CNTRL.

*Display document

CALL METHOD O_DYNDOC_ID->DISPLAY_DOCUMENT

EXPORTING

REUSE_CONTROL = 'X'

PARENT = O_PARENT_TOP

EXCEPTIONS

HTML_DISPLAY_ERROR = 1.

IF SY-SUBRC NE 0.

MESSAGE I999(00) WITH 'Error in displaying top-of-page'(036).

ENDIF.

ENDFORM. " display