Tuesday, December 21, 2010
We create custom container object and connect the screen object to a customer container control. Create an ALV object and connect to the container control. Display data using CL_GUI_ALV_GRID=>SET_TABLE_FOR_FIRST_DISPLAY method.

REPORT ztest_notepad.
"Control definitions
DATA: 
      g_grid_control     TYPE REF TO cl_gui_alv_grid,
      g_custom_container TYPE REF TO cl_gui_custom_container.
"ALV Declarations
DATA:
      wa_fieldcat TYPE lvc_s_fcat,
      it_fieldcat TYPE lvc_t_fcat,
      wa_layout   TYPE lvc_s_layo.
"Data declarations
DATA: 
      it_t100 TYPE TABLE OF t100.
*start-of-selection
START-OF-SELECTION.
  CALL SCREEN 1001.
  
*&---------------------------------------------------------------------*
*&      Module  INITIALIZE_DATA  OUTPUT
*&---------------------------------------------------------------------*
MODULE initialize_data OUTPUT.
  IF g_custom_container IS INITIAL.
    CREATE OBJECT g_custom_container
      EXPORTING
        container_name = 'G_CCONTROL'.
    CREATE OBJECT g_grid_control
      EXPORTING
        i_parent = g_custom_container.
  ENDIF.
  IF it_t100[] IS INITIAL.
    SELECT * 
        FROM t100 
         INTO TABLE it_t100 
         UP TO 20 ROWS 
       WHERE sprsl = sy-langu.
  ENDIF.
  "Field catalog
  DEFINE fieldcat.
    wa_fieldcat-fieldname = &1.
    wa_fieldcat-tabname   = &2.
    wa_fieldcat-seltext   = &3.
    append wa_fieldcat to it_fieldcat.
    clear  wa_fieldcat.
  END-OF-DEFINITION.
  "         Field    table     Description
  fieldcat:'ARBGB'  'IT_T100'  'ARBGB',
  'MSGNR'  'IT_T100'  'MSGNR',
  'TEXT'   'IT_T100'  'TEXT'.

  wa_layout-cwidth_opt = 'X'.
  CALL METHOD g_grid_control->set_table_for_first_display
    EXPORTING
      is_layout       = wa_layout
    CHANGING
      it_outtab       = it_t100
      it_fieldcatalog = it_fieldcat.
ENDMODULE.                 " INITIALIZE_DATA  OUTPUT


PROCESS BEFORE OUTPUT.
MODULE initialize_data.

PROCESS AFTER INPUT.
*  MODULE user_command_1001.

0 comments:

Post a Comment

Your useful comments, suggestions are appreciated.Your comments are moderated.

Followers

Contact Form

Name

Email *

Message *

Web Dynpro ABAP Book

An SAP Consultant

Follow US


Want to Contribute ?

If you are interested in writing about the new stuff you learn everyday while working, please write to the.sap.consultants@gmail.com.

Click on Contribution for more details.