Quickinfo in ALV

Hi Everyone,
I have a small query Iam sure someone must have done it.
Is it possible to attach quickinfo in ALV list.
In my assignment I have to show the material description for a material number as quickinfo.
Please let me know which parameter we need to set in the fieldcatalog to get it.
Thanks and Regards
Varun

Hello Varun / Subramanian,
Thanks for your interest in this. Here's the code:
Prelude: The program has one screen(0100), which has a custom control area (named CC)
as it's only element. The Flow Logic has only one PBO Module (called PBO). The program
displays an ALV Grid with two columns, one for the Material and the other to contain
an icon. This icon will have a tooltip text, which is the material text for the material
in the first column of that row.
data : container type ref to cl_gui_custom_container,
       alv_grid  type ref to cl_gui_alv_grid.
data: fcat type lvc_t_fcat,
      fs_fcat type lvc_s_fcat,
      begin of itab occurs 0,
        matnr     type matnr,
        text(44)  type c,
      end of itab.
start-of-selection.
  call screen 100.
module pbo output.
  create object container
         exporting container_name = 'CC'.
  create object alv_grid
         exporting i_parent = container.
  fs_fcat-fieldname = 'MATNR'.
  fs_fcat-ref_table = 'MARA'.
  append fs_fcat to fcat.
  fs_fcat-fieldname = 'TEXT'.
  fs_fcat-outputlen = 4.
  fs_fcat-coltext = 'Text'.
  fs_fcat-INTTYPE = 'C'.
  fs_fcat-SELTEXT = 'Description'.
  fs_fcat-icon = 'X'.
  append fs_fcat to fcat.
  select distinct matnr
         maktx
    from makt
    up to 10 rows
    into (itab-matnr , itab-text)
   where spras = 'EN'.
* @0P@ is the icon code that I have chosen here.
* obviously, you can choose something else.
    concatenate '@0PQ'
                itab-text
           into itab-text.
    append itab.
  endselect.
  call method alv_grid->set_table_for_first_display
     changing
       IT_FIELDCATALOG  = fcat
       IT_OUTTAB        = itab[].
endmodule.
Please note that, for the sake of simplicity, I have not writeen any PAI module. So you cannot come back to the program from the screen. You can have one button on the screen which says "Back" or something like that...
Regards,
Anand Mandalika.
P.S. Go to <a href="http://help.sap.com/saphelp_erp2004/helpdata/en/ff/4649baf17411d2b486006094192fe3/content.htm">this link</a>in the SAP documentation where the icon with tooltip is mentioned.

Similar Messages

  • Quickinfo on a Cell in ALV-OO

    Hi,
    is it possible to create a Quickinfo to several cells on a OO-ALV? i thought its possible, but i cant find any information. So i dispute it dont works.
    Thanks & Best Regards
    Andreas

    Hello Andreas
    As far as I am aware you can have tooltips for icons only.
    The crucial line of coding in the sample report is:
    concatenate value '\Q' text '@' into value. " Example: @00\QICON_DUMMY@
    Regards
      Uwe

  • First try with ALV Grid and Abap Objects

    Hi,
    this is my first try to write a simple report which just reads a textfile and display it in an ALV Grid. As a basis, I used some examples from SDN, but it did not work as expected
    I would like just to use a docking container. I do not need a separate area for the ALV Grid. The report gives no syntax errors, but it just display the report title, nothing else. SAP R/3 Release is 4.7. Below is the source code of the report. Any idea what is missing?
    *& Report  Z_PLAN_TEXT_UPLOAD                                          *
    REPORT z_plan_text_upload.
    INCLUDE <icon>.
    * Data Declaration
    DATA:
      gf_dynnr TYPE sy-dynnr,
      gf_repid TYPE sy-repid.
    DATA:
      go_docking_container TYPE REF TO cl_gui_docking_container,
      go_alv_grid TYPE REF TO cl_gui_alv_grid.
    DATA:
      gt_fieldcat TYPE lvc_t_fcat,
      gs_fieldcat LIKE LINE OF gt_fieldcat.
    TYPES:
      BEGIN OF gy_text_input,
        firma(20)           TYPE c,
        kostenstelle(20)    TYPE c,
        datenart1(10)       TYPE c,
        planjahr(10)        TYPE c,
    *    planperiode         TYPE co_perio,
        planperiode(5)      TYPE c,
        datenart2(10)       TYPE c,
        planungposition(10) TYPE c,
    *    kostenart           TYPE koart,
        kostenart(10)       TYPE c,
    *    planbetrag          TYPE bapicurr_d,
        planbetrag(20)      TYPE c,
      END OF gy_text_input.
    DATA:
      gt_text_input TYPE TABLE OF gy_text_input,
      gs_text_input LIKE LINE OF gt_text_input.
    * Local Class Definition
    * Local Class Implementation
    * Selection-Screen
    SELECTION-SCREEN BEGIN OF BLOCK b1
      WITH FRAME TITLE text-001.
    SKIP.
    PARAMETERS:
      gp_file TYPE localfile,
      gp_head TYPE checkbox DEFAULT 'X'.
    SKIP.
    PARAMETERS:
      gp_gjahr LIKE coep-gjahr,
      gp_versn LIKE coep-versn.
    SELECTION-SCREEN END OF BLOCK b1.
    * Initialization
    INITIALIZATION.
      DATA:
        lf_sapworkdir TYPE string.
      CALL METHOD cl_gui_frontend_services=>get_sapgui_workdir
        CHANGING
          sapworkdir            = lf_sapworkdir
        EXCEPTIONS
          get_sapworkdir_failed = 1
          cntl_error            = 2
          error_no_gui          = 3
          not_supported_by_gui  = 4
          OTHERS                = 5.
      IF sy-subrc <> 0 OR lf_sapworkdir = ''.
        CALL METHOD cl_gui_frontend_services=>directory_get_current
          CHANGING
            current_directory            = lf_sapworkdir
          EXCEPTIONS
            directory_get_current_failed = 1
            cntl_error                   = 2
            error_no_gui                 = 3
            not_supported_by_gui         = 4
            OTHERS                       = 5.
        CALL METHOD cl_gui_cfw=>flush.
      ENDIF."sy-subrc <> 0 OR sapworkdir = ''
      gp_file = lf_sapworkdir.
      gf_dynnr = sy-dynnr.
      gf_repid = sy-repid.
    * At Selection-Screen
    AT SELECTION-SCREEN ON VALUE-REQUEST FOR gp_file.
      DATA:
        lt_filetable TYPE filetable,
        ls_filetable LIKE LINE OF lt_filetable,
        lt_rc TYPE i.
      CALL METHOD cl_gui_frontend_services=>file_open_dialog
    *  EXPORTING
    *    WINDOW_TITLE            =
    *    DEFAULT_EXTENSION       =
    *    DEFAULT_FILENAME        =
    *    FILE_FILTER             =
    *    INITIAL_DIRECTORY       =
    *    MULTISELECTION          =
    *    WITH_ENCODING           =
        CHANGING
          file_table              = lt_filetable
          rc                      = lt_rc
    *    USER_ACTION             =
    *    FILE_ENCODING           =
        EXCEPTIONS
          file_open_dialog_failed = 1
          cntl_error              = 2
          error_no_gui            = 3
          not_supported_by_gui    = 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.
      READ TABLE lt_filetable INDEX 1
        INTO
          ls_filetable.
      gp_file = ls_filetable-filename.
      CALL METHOD cl_gui_cfw=>flush.
    * Start-Of-Selection
    START-OF-SELECTION.
      DATA:
        lf_filename LIKE filename-fileintern.
      lf_filename = gp_file.
      CALL FUNCTION 'FILE_READ_AND_CONVERT_SAP_DATA'
        EXPORTING
          i_filename                 = lf_filename
          i_servertyp                = 'PRS '
          i_fileformat               = 'TXT'
    *     I_FIELD_SEPERATOR          =
          i_line_header              = gp_head
    *   IMPORTING
    *     E_BIN_FILELENGTH           =
       TABLES
         i_tab_receiver             = gt_text_input
       EXCEPTIONS
         file_not_found             = 1
         close_failed               = 2
         authorization_failed       = 3
         open_failed                = 4
         conversion_failed          = 5
         OTHERS                     = 6.
      IF sy-subrc <> 0.
    * MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
    *         WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
      ENDIF.
    *------ Build the Field Catalog ---------------------------------------*
      PERFORM build_fieldcatalog
        CHANGING gt_fieldcat.
    *------ Create the docking container ----------------------------------*
      IF go_docking_container IS INITIAL.
        CREATE OBJECT go_docking_container
          EXPORTING
    *      PARENT                      =
            repid                       = gf_repid
            dynnr                       = gf_dynnr
    *     SIDE                        = go_docking_container->DOCK_AT_bottom
    *      EXTENSION                   = 200
    *      STYLE                       =
    *      LIFETIME                    = lifetime_default
    *      CAPTION                     =
    *      METRIC                      = 0
    *      RATIO                       =
    *      NO_AUTODEF_PROGID_DYNNR     =
    *      NAME                        =
          EXCEPTIONS
            cntl_error                  = 1
            cntl_system_error           = 2
            create_error                = 3
            lifetime_error              = 4
            lifetime_dynpro_dynpro_link = 5
            OTHERS                      = 6.
        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."go_docking_container IS INITIAL
    *------ Create the ALV Grid -------------------------------------------*
      IF go_alv_grid IS INITIAL.
        CREATE OBJECT go_alv_grid
          EXPORTING
    *      I_SHELLSTYLE      = 0
    *      I_LIFETIME        =
            i_parent          = go_docking_container
    *      I_APPL_EVENTS     = space
    *      I_PARENTDBG       =
    *      I_APPLOGPARENT    =
    *      I_GRAPHICSPARENT  =
    *      I_NAME            =
          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.
      ENDIF."go_alv_grid is initial
    *------ Call ALV Grid -------------------------------------------------*
      CALL METHOD go_alv_grid->set_table_for_first_display
    *     EXPORTING
    *      I_BUFFER_ACTIVE               =
    *      I_BYPASSING_BUFFER            =
    *      I_CONSISTENCY_CHECK           =
    *      I_STRUCTURE_NAME              =
    *      IS_VARIANT                    =
    *      I_SAVE                        =
    *      I_DEFAULT                     = 'X'
    *      IS_LAYOUT                     =
    *      IS_PRINT                      =
    *      IT_SPECIAL_GROUPS             =
    *      IT_TOOLBAR_EXCLUDING          =
    *      IT_HYPERLINK                  =
    *      IT_ALV_GRAPHICS               =
    *      IT_EXCEPT_QINFO               =
        CHANGING
          it_outtab                     = gt_text_input
          it_fieldcatalog               = gt_fieldcat
    *      IT_SORT                       =
    *      IT_FILTER                     =
        EXCEPTIONS
          invalid_parameter_combination = 1
          program_error                 = 2
          too_many_lines                = 3
          OTHERS                        = 4.
      IF sy-subrc <> 0.
    *   MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
    *              WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
      ENDIF.
    *&      Form  build_fieldcatalog
    *       text
    *      <--P_GT_FIELDCAT  text
    FORM build_fieldcatalog
      CHANGING
        pt_fieldcat TYPE lvc_t_fcat.
      DATA ls_fcat TYPE lvc_s_fcat.
      ls_fcat-fieldname = 'FIRMA' .
      ls_fcat-inttype = 'C' .
      ls_fcat-outputlen = '20' .
      ls_fcat-coltext = 'Firma' .
      ls_fcat-seltext = 'Firma' .
      APPEND ls_fcat TO pt_fieldcat .
      ls_fcat-fieldname = 'KOSTENSTELLE' .
      ls_fcat-inttype = 'C' .
      ls_fcat-outputlen = '20' .
      ls_fcat-coltext = 'Kostenstelle' .
      ls_fcat-seltext = 'Kostenstelle' .
      APPEND ls_fcat TO pt_fieldcat .
      ls_fcat-fieldname = 'DATENART1' .
      ls_fcat-inttype = 'C' .
      ls_fcat-outputlen = '10' .
      ls_fcat-coltext = 'Datenart1' .
      ls_fcat-seltext = 'Datenart1' .
      APPEND ls_fcat TO pt_fieldcat .
      ls_fcat-fieldname = 'PLANJAHR' .
      ls_fcat-inttype = 'C' .
      ls_fcat-outputlen = '10' .
      ls_fcat-coltext = 'Planjahr' .
      ls_fcat-seltext = 'Planjahr' .
      APPEND ls_fcat TO pt_fieldcat .
      APPEND ls_fcat TO pt_fieldcat .
      ls_fcat-fieldname = 'PLANPERIODE' .
      ls_fcat-inttype = 'C' .
      ls_fcat-outputlen = '5' .
      ls_fcat-coltext = 'Planperiode' .
      ls_fcat-seltext = 'Planperiode' .
      APPEND ls_fcat TO pt_fieldcat .
      ls_fcat-fieldname = 'DATENART2' .
      ls_fcat-inttype = 'C' .
      ls_fcat-outputlen = '10' .
      ls_fcat-coltext = 'Datenart2' .
      ls_fcat-seltext = 'Datenart2' .
      APPEND ls_fcat TO pt_fieldcat .
      ls_fcat-fieldname = 'PLANUNGSPOSITION' .
      ls_fcat-inttype = 'C' .
      ls_fcat-outputlen = '10' .
      ls_fcat-coltext = 'Planungsposition' .
      ls_fcat-seltext = 'Planungsposition' .
      APPEND ls_fcat TO pt_fieldcat .
      APPEND ls_fcat TO pt_fieldcat .
      ls_fcat-fieldname = 'KOSTENART' .
      ls_fcat-inttype = 'C' .
      ls_fcat-outputlen = '10' .
      ls_fcat-coltext = 'Kostenart' .
      ls_fcat-seltext = 'Kostenart' .
      APPEND ls_fcat TO pt_fieldcat .
      ls_fcat-fieldname = 'PLANBETRAG' .
      ls_fcat-inttype = 'C' .
      ls_fcat-outputlen = '20' .
      ls_fcat-coltext = 'Planbetrag' .
      ls_fcat-seltext = 'Planbetrag' .
      APPEND ls_fcat TO pt_fieldcat .
    ENDFORM.                    "build_fieldcatalog

    I have added some more functionality to my report. The good thing is, the report works as it should.
    BUT, I'm not really sure, whether this is a good (correct) design. The report works the following way:
    1. Read planning data form text file into internal table
    2. Display the internal table
    3. Convert the data and display the converted result
    4. Post the converted data to the system
    5. Display log with messages
    The main thing is, I would like to know, do i really need two dynros, to display the two different internal tables or is it possible just to use one ALV-Grid? I was not able to find another solution. Any comment or help to the report is appreciated.
    *& Report  Z_PLAN_TEXT_UPLOAD_TEST                                     *
    REPORT z_plan_text_upload_test.
    INCLUDE <icon>.
    * Data Declaration
    DATA:
      gf_okcode TYPE ui_func,
      gf_balloghndl TYPE balloghndl.
    DATA:
      go_docking_container TYPE REF TO cl_gui_docking_container,
      go_alv_grid_0100 TYPE REF TO cl_gui_alv_grid,
      go_alv_grid_0200 TYPE REF TO cl_gui_alv_grid.
    DATA:
      gt_fieldcat TYPE lvc_t_fcat,
      gs_fieldcat LIKE LINE OF gt_fieldcat.
    TYPES:
      BEGIN OF gy_text_input,
        firma(20)            TYPE c,
        kostenstelle(20)     TYPE c,
        datenart1(10)        TYPE c,
        planjahr(10)         TYPE c,
    *    planperiode         TYPE co_perio,
        planperiode(5)       TYPE c,
        datenart2(10)        TYPE c,
        planungsposition(10) TYPE c,
    *    kostenart           TYPE koart,
        kostenart(10)        TYPE c,
    *    planbetrag          TYPE bapicurr_d,
        planbetrag(20)       TYPE c,
      END OF gy_text_input.
    DATA:
      gt_text_input TYPE TABLE OF gy_text_input,
      gs_text_input LIKE LINE OF gt_text_input.
    * Bapi Strukturen
    DATA:
      gs_headerinfo TYPE bapiplnhdr,
      gt_indexstructure TYPE TABLE OF bapiacpstru,
      gs_indexstructure LIKE LINE OF gt_indexstructure,
      gt_coobject TYPE TABLE OF bapipcpobj,
      gs_coobject LIKE LINE OF gt_coobject,
      gt_pervalue TYPE TABLE OF bapipcpval,
      gs_pervalue LIKE LINE OF gt_pervalue,
      gt_return TYPE TABLE OF bapiret2,
      gs_return LIKE LINE OF gt_return,
      gt_control TYPE TABLE OF bapipcpctrl,
      gt_totvalue TYPE TABLE OF bapipcptot.
    TYPES:
      BEGIN OF gy_bapi_input,
        version      TYPE versn,
    *    perio       TYPE co_perio,
        fisc_year    TYPE gjahr,
        coobject(10) TYPE c,
        cost_elem    TYPE kstar,
        wkgbtr01     TYPE wkgxxx,
        wkgbtr02     TYPE wkgxxx,
        wkgbtr03     TYPE wkgxxx,
        wkgbtr04     TYPE wkgxxx,
        wkgbtr05     TYPE wkgxxx,
        wkgbtr06     TYPE wkgxxx,
        wkgbtr07     TYPE wkgxxx,
        wkgbtr08     TYPE wkgxxx,
        wkgbtr09     TYPE wkgxxx,
        wkgbtr10     TYPE wkgxxx,
        wkgbtr11     TYPE wkgxxx,
        wkgbtr12     TYPE wkgxxx,
      END OF gy_bapi_input.
    DATA:
      gt_bapi_input TYPE TABLE OF gy_bapi_input,
      gs_bapi_input LIKE LINE OF gt_bapi_input.
    * Anwendungs-Log
    DATA: gs_balsmsg TYPE bal_s_msg.
    * Selection-Screen
    SELECTION-SCREEN BEGIN OF BLOCK b1
      WITH FRAME TITLE text-001.
    PARAMETERS:
      gp_file TYPE localfile,
      gp_head TYPE checkbox DEFAULT 'X'.
    SELECTION-SCREEN SKIP.
    PARAMETERS:
      gp_kokrs  LIKE coep-kokrs,
      gp_gjahr LIKE coep-gjahr,
      gp_versn LIKE coep-versn,
      gp_test AS CHECKBOX DEFAULT 'X'.
    SELECTION-SCREEN END OF BLOCK b1.
    * Local Class Definition
    CLASS lcl_event_handler DEFINITION.
      PUBLIC SECTION.
        METHODS:
        handle_toolbar_0100 FOR EVENT toolbar OF cl_gui_alv_grid
          IMPORTING
            e_object
            e_interactive,
        handle_user_command_0100 FOR EVENT user_command OF cl_gui_alv_grid
          IMPORTING
            e_ucomm,
        handle_toolbar_0200 FOR EVENT toolbar OF cl_gui_alv_grid
          IMPORTING
            e_object
            e_interactive,
        handle_user_command_0200 FOR EVENT user_command OF cl_gui_alv_grid
          IMPORTING
            e_ucomm.
      PRIVATE SECTION.
    ENDCLASS.                    "lcl_event_handler DEFINITION
    * Local Class Implementation
    CLASS lcl_event_handler IMPLEMENTATION.
      METHOD handle_toolbar_0100.
        PERFORM handle_toolbar_0100
          USING
            e_object.
    *        e_interactive.
      ENDMETHOD.                    "handle_toolbar_0100
      METHOD handle_user_command_0100.
        PERFORM handle_user_command_0100
          USING
            e_ucomm.
      ENDMETHOD.                    "handle_user_command_0100
      METHOD handle_toolbar_0200.
        PERFORM handle_toolbar_0200
          USING
            e_object.
    *        e_interactive.
      ENDMETHOD.                    "handle_toolbar_0100
      METHOD handle_user_command_0200.
        PERFORM handle_user_command_0200
          USING
            e_ucomm.
      ENDMETHOD.                    "handle_user_command_0100
    ENDCLASS.                    "lcl_event_handler IMPLEMENTATION
    * Initialization
    INITIALIZATION.
      DATA:
        lf_sapworkdir TYPE string.
      CALL METHOD cl_gui_frontend_services=>get_sapgui_workdir
        CHANGING
          sapworkdir            = lf_sapworkdir
        EXCEPTIONS
          get_sapworkdir_failed = 1
          cntl_error            = 2
          error_no_gui          = 3
          not_supported_by_gui  = 4
          OTHERS                = 5.
      IF sy-subrc <> 0 OR lf_sapworkdir = ''.
        CALL METHOD cl_gui_frontend_services=>directory_get_current
          CHANGING
            current_directory            = lf_sapworkdir
          EXCEPTIONS
            directory_get_current_failed = 1
            cntl_error                   = 2
            error_no_gui                 = 3
            not_supported_by_gui         = 4
            OTHERS                       = 5.
        CALL METHOD cl_gui_cfw=>flush.
      ENDIF."sy-subrc <> 0 OR sapworkdir = ''
      gp_file = lf_sapworkdir.
    * At Selection-Screen
    AT SELECTION-SCREEN ON VALUE-REQUEST FOR gp_file.
      DATA:
        lt_filetable TYPE filetable,
        ls_filetable LIKE LINE OF lt_filetable,
        lt_rc TYPE i.
      CALL METHOD cl_gui_frontend_services=>file_open_dialog
    *  EXPORTING
    *    WINDOW_TITLE            =
    *    DEFAULT_EXTENSION       =
    *    DEFAULT_FILENAME        =
    *    FILE_FILTER             =
    *    INITIAL_DIRECTORY       =
    *    MULTISELECTION          =
    *    WITH_ENCODING           =
        CHANGING
          file_table              = lt_filetable
          rc                      = lt_rc
    *    USER_ACTION             =
    *    FILE_ENCODING           =
        EXCEPTIONS
          file_open_dialog_failed = 1
          cntl_error              = 2
          error_no_gui            = 3
          not_supported_by_gui    = 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.
      READ TABLE lt_filetable INDEX 1
        INTO
          ls_filetable.
      gp_file = ls_filetable-filename.
      CALL METHOD cl_gui_cfw=>flush.
    * Start-Of-Selection
    START-OF-SELECTION.
      DATA:
        lf_filename LIKE filename-fileintern.
      PERFORM create_log.
      gs_return-type = 'I'.
      IF gp_test = 'X'.
        gs_return-message = text-010.
      ELSE.
        gs_return-message = text-020.
      ENDIF.
      PERFORM add_log_message_free_text
        USING
           gs_return-type
           gs_return-message.
      lf_filename = gp_file.
      CALL FUNCTION 'FILE_READ_AND_CONVERT_SAP_DATA'
        EXPORTING
          i_filename                 = lf_filename
          i_servertyp                = 'PRS '
          i_fileformat               = 'TXT'
    *     I_FIELD_SEPERATOR          =
          i_line_header              = gp_head
    *   IMPORTING
    *     E_BIN_FILELENGTH           =
       TABLES
         i_tab_receiver             = gt_text_input
       EXCEPTIONS
         file_not_found             = 1
         close_failed               = 2
         authorization_failed       = 3
         open_failed                = 4
         conversion_failed          = 5
         OTHERS                     = 6.
      IF sy-subrc <> 0.
        gs_balsmsg-msgty = sy-msgty.
        gs_balsmsg-msgid = sy-msgid.
        gs_balsmsg-msgno = sy-msgno.
        gs_balsmsg-msgv1 = sy-msgv1.
        gs_balsmsg-msgv2 = sy-msgv2.
        gs_balsmsg-msgv3 = sy-msgv3.
        gs_balsmsg-msgv4 = sy-msgv4.
        PERFORM add_log_message
          USING
            gs_balsmsg.
      ENDIF.
      CALL SCREEN '0100'.
    *&      Module  status_0100  OUTPUT
    *       text
    MODULE status_0100 OUTPUT.
      SET PF-STATUS 'STATUS_0100'.
    *------ Create the docking container ----------------------------------*
      IF go_docking_container IS INITIAL.
        CREATE OBJECT go_docking_container
          EXPORTING
            parent                      = cl_gui_container=>screen0
    *        repid                       = gf_repid
    *        dynnr                       = gf_dynnr
    *     SIDE                        = go_docking_container->DOCK_AT_bottom
    *       EXTENSION                   = 200
    *      STYLE                       =
    *      LIFETIME                    = lifetime_default
    *      CAPTION                     =
    *      METRIC                      = 0
            ratio                       = 95
    *      NO_AUTODEF_PROGID_DYNNR     =
    *      NAME                        =
          EXCEPTIONS
            cntl_error                  = 1
            cntl_system_error           = 2
            create_error                = 3
            lifetime_error              = 4
            lifetime_dynpro_dynpro_link = 5
            OTHERS                      = 6.
        IF sy-subrc <> 0.
    *   MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
    *              WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
        ENDIF.
    *------ Expand  docking container to full screen    -------------------*
        CALL METHOD go_docking_container->set_extension
          EXPORTING
            extension  = 99999  "full-screen size !!!
          EXCEPTIONS
            cntl_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.
      ENDIF."go_docking_container IS INITIAL
    *------ Link docking container to screen ------------------------------*
      CALL METHOD go_docking_container->link
        EXPORTING
          repid                       = sy-repid
          dynnr                       = '0100'
    *      CONTAINER                   =
        EXCEPTIONS
          cntl_error                  = 1
          cntl_system_error           = 2
          lifetime_dynpro_dynpro_link = 3
          OTHERS                      = 4
      IF sy-subrc <> 0.
    *   MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
    *              WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
      ENDIF.
    *------ Build the Field Catalog ---------------------------------------*
      PERFORM build_fieldcatalog_input
        CHANGING gt_fieldcat.
    *------ Create the ALV Grid -------------------------------------------*
      IF go_alv_grid_0100 IS INITIAL.
        CREATE OBJECT go_alv_grid_0100
          EXPORTING
    *      I_SHELLSTYLE      = 0
    *      I_LIFETIME        =
            i_parent          = go_docking_container
    *      I_APPL_EVENTS     = space
    *      I_PARENTDBG       =
    *      I_APPLOGPARENT    =
    *      I_GRAPHICSPARENT  =
    *      I_NAME            =
          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.
      ENDIF."go_alv_grid_0100 is initial
    *------ Create instance for event handler -----------------------------*
      DATA: go_event_handler_0100 TYPE REF TO lcl_event_handler.
      CREATE OBJECT go_event_handler_0100.
    *------ Register event handler ----------------------------------------*
      SET HANDLER go_event_handler_0100->handle_toolbar_0100
        FOR go_alv_grid_0100.
      SET HANDLER go_event_handler_0100->handle_user_command_0100
        FOR go_alv_grid_0100.
    *------ Call ALV Grid -------------------------------------------------*
      CALL METHOD go_alv_grid_0100->set_table_for_first_display
    *     EXPORTING
    *      I_BUFFER_ACTIVE               =
    *      I_BYPASSING_BUFFER            =
    *      I_CONSISTENCY_CHECK           =
    *      I_STRUCTURE_NAME              =
    *      IS_VARIANT                    =
    *      I_SAVE                        =
    *      I_DEFAULT                     = 'X'
    *      IS_LAYOUT                     =
    *      IS_PRINT                      =
    *      IT_SPECIAL_GROUPS             =
    *      IT_TOOLBAR_EXCLUDING          =
    *      IT_HYPERLINK                  =
    *      IT_ALV_GRAPHICS               =
    *      IT_EXCEPT_QINFO               =
        CHANGING
          it_outtab                     = gt_text_input
          it_fieldcatalog               = gt_fieldcat
    *      IT_SORT                       =
    *      IT_FILTER                     =
        EXCEPTIONS
          invalid_parameter_combination = 1
          program_error                 = 2
          too_many_lines                = 3
          OTHERS                        = 4.
      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 'set_toolbar_interactive' to raise event TOOLBAR.
      CALL METHOD go_alv_grid_0100->set_toolbar_interactive.
    ENDMODULE.                 " status_0100  OUTPUT
    *&      Module  status_0200  OUTPUT
    *       text
    MODULE status_0200 OUTPUT.
      SET PF-STATUS 'STATUS_0100'.
    *------ Create the docking container ----------------------------------*
      IF go_docking_container IS INITIAL.
        CREATE OBJECT go_docking_container
          EXPORTING
            parent                      = cl_gui_container=>screen0
    *        repid                       = gf_repid
    *        dynnr                       = gf_dynnr
    *     SIDE                        = go_docking_container->DOCK_AT_bottom
    *       EXTENSION                   = 200
    *      STYLE                       =
    *      LIFETIME                    = lifetime_default
    *      CAPTION                     =
    *      METRIC                      = 0
            ratio                       = 95
    *      NO_AUTODEF_PROGID_DYNNR     =
    *      NAME                        =
          EXCEPTIONS
            cntl_error                  = 1
            cntl_system_error           = 2
            create_error                = 3
            lifetime_error              = 4
            lifetime_dynpro_dynpro_link = 5
            OTHERS                      = 6.
        IF sy-subrc <> 0.
    *   MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
    *              WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
        ENDIF.
    *------ Expand  docking container to full screen    -------------------*
        CALL METHOD go_docking_container->set_extension
          EXPORTING
            extension  = 99999
          EXCEPTIONS
            cntl_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.
      ENDIF."go_docking_container IS INITIAL
    *------ Link docking container to screen ------------------------------*
      CALL METHOD go_docking_container->link
        EXPORTING
          repid                       = sy-repid
          dynnr                       = '0200'
    *      CONTAINER                   =
        EXCEPTIONS
          cntl_error                  = 1
          cntl_system_error           = 2
          lifetime_dynpro_dynpro_link = 3
          OTHERS                      = 4
      IF sy-subrc <> 0.
    *   MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
    *              WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
      ENDIF.
    *------ Build the Field Catalog---------------------------------------*
      PERFORM build_fieldcatalog_bapi_input
        CHANGING
          gt_fieldcat.
    *------ Create the ALV Grid -------------------------------------------*
      IF go_alv_grid_0200 IS INITIAL.
        CREATE OBJECT go_alv_grid_0200
          EXPORTING
    *      I_SHELLSTYLE      = 0
    *      I_LIFETIME        =
           i_parent          = go_docking_container
    *      I_APPL_EVENTS     = space
    *      I_PARENTDBG       =
    *      I_APPLOGPARENT    =
    *      I_GRAPHICSPARENT  =
    *      I_NAME            =
          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.
      ENDIF."go_alv_grid_0200 is initial
    *------ Create instance for event handler -----------------------------*
      DATA: go_event_handler_0200 TYPE REF TO lcl_event_handler.
      CREATE OBJECT go_event_handler_0200.
    *------ Register event handler ----------------------------------------*
      SET HANDLER go_event_handler_0200->handle_toolbar_0200
        FOR go_alv_grid_0200.
      SET HANDLER go_event_handler_0200->handle_user_command_0200
        FOR go_alv_grid_0200.
    *------ Call ALV Grid -------------------------------------------------*
      CALL METHOD go_alv_grid_0200->set_table_for_first_display
    *     EXPORTING
    *      I_BUFFER_ACTIVE               =
    *      I_BYPASSING_BUFFER            =
    *      I_CONSISTENCY_CHECK           =
    *      I_STRUCTURE_NAME              =
    *      IS_VARIANT                    =
    *      I_SAVE                        =
    *      I_DEFAULT                     = 'X'
    *      IS_LAYOUT                     =
    *      IS_PRINT                      =
    *      IT_SPECIAL_GROUPS             =
    *      IT_TOOLBAR_EXCLUDING          =
    *      IT_HYPERLINK                  =
    *      IT_ALV_GRAPHICS               =
    *      IT_EXCEPT_QINFO               =
        CHANGING
          it_outtab                     = gt_bapi_input
          it_fieldcatalog               = gt_fieldcat
    *      IT_SORT                       =
    *      IT_FILTER                     =
        EXCEPTIONS
          invalid_parameter_combination = 1
          program_error                 = 2
          too_many_lines                = 3
          OTHERS                        = 4.
      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 'set_toolbar_interactive' to raise event TOOLBAR.
      CALL METHOD go_alv_grid_0200->set_toolbar_interactive.
      CALL METHOD go_alv_grid_0200->refresh_table_display
    *  EXPORTING
    *    IS_STABLE      =
    *    I_SOFT_REFRESH =
        EXCEPTIONS
          finished       = 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.
      CALL METHOD cl_gui_control=>set_focus
        EXPORTING
          control = go_alv_grid_0200.
    ENDMODULE.                 " status_0200  OUTPUT
    *&      Module  user_command_0100  INPUT
    *       text
    MODULE user_command_0100 INPUT.
      CASE gf_okcode.
        WHEN 'BACK' OR 'END' OR 'CANC'.
          PERFORM exit_program.
        WHEN OTHERS.
      ENDCASE.
      CLEAR gf_okcode.
    ENDMODULE.                 " user_command_0100  INPUT
    *&      Module  user_command_0200  INPUT
    *       text
    MODULE user_command_0200 INPUT.
      CASE gf_okcode.
        WHEN 'BACK' OR 'END' OR 'CANC'.
          PERFORM exit_program.
        WHEN OTHERS.
      ENDCASE.
      CLEAR gf_okcode.
    ENDMODULE.                 " user_command_0200  INPUT
    *&      Form  build_fieldcatalog
    *       text
    *      <--P_GT_FIELDCAT  text
    FORM build_fieldcatalog_input
      CHANGING
        pt_fieldcat TYPE lvc_t_fcat.
      DATA ls_fcat TYPE lvc_s_fcat.
      CLEAR pt_fieldcat.
      ls_fcat-fieldname = 'FIRMA' .
      ls_fcat-inttype = 'C' .
      ls_fcat-outputlen = '20' .
      ls_fcat-coltext = 'Firma' .
      ls_fcat-seltext = 'Firma' .
      APPEND ls_fcat TO pt_fieldcat .
      ls_fcat-fieldname = 'KOSTENSTELLE' .
      ls_fcat-inttype = 'C' .
      ls_fcat-outputlen = '20' .
      ls_fcat-coltext = 'CO-Objekt' .
      ls_fcat-seltext = 'CO-Objekt' .
      APPEND ls_fcat TO pt_fieldcat .
      ls_fcat-fieldname = 'DATENART1' .
      ls_fcat-inttype = 'C' .
      ls_fcat-outputlen = '10' .
      ls_fcat-coltext = 'Datenart1' .
      ls_fcat-seltext = 'Datenart1' .
      APPEND ls_fcat TO pt_fieldcat .
      ls_fcat-fieldname = 'PLANJAHR' .
      ls_fcat-inttype = 'C' .
      ls_fcat-outputlen = '10' .
      ls_fcat-coltext = 'Planjahr' .
      ls_fcat-seltext = 'Planjahr' .
      APPEND ls_fcat TO pt_fieldcat .
      ls_fcat-fieldname = 'PLANPERIODE' .
      ls_fcat-inttype = 'C' .
      ls_fcat-outputlen = '5' .
      ls_fcat-coltext = 'Planperiode' .
      ls_fcat-seltext = 'Planperiode' .
      APPEND ls_fcat TO pt_fieldcat .
      ls_fcat-fieldname = 'DATENART2' .
      ls_fcat-inttype = 'C' .
      ls_fcat-outputlen = '10' .
      ls_fcat-coltext = 'Datenart2' .
      ls_fcat-seltext = 'Datenart2' .
      APPEND ls_fcat TO pt_fieldcat .
      ls_fcat-fieldname = 'PLANUNGSPOSITION' .
      ls_fcat-inttype = 'C' .
      ls_fcat-outputlen = '10' .
      ls_fcat-coltext = 'Planungsposition' .
      ls_fcat-seltext = 'Planungsposition' .
      APPEND ls_fcat TO pt_fieldcat .
      ls_fcat-fieldname = 'KOSTENART' .
      ls_fcat-inttype = 'C' .
      ls_fcat-outputlen = '10' .
      ls_fcat-coltext = 'Kostenart' .
      ls_fcat-seltext = 'Kostenart' .
      APPEND ls_fcat TO pt_fieldcat .
      ls_fcat-fieldname = 'PLANBETRAG' .
      ls_fcat-inttype = 'C' .
      ls_fcat-outputlen = '20' .
      ls_fcat-coltext = 'Planbetrag' .
      ls_fcat-seltext = 'Planbetrag' .
      APPEND ls_fcat TO pt_fieldcat .
    ENDFORM.                    "build_fieldcatalog
    *&      Form  handle_toolbar_0100
    *       text
    *      -->P_E_OBJECT  text
    *      -->P_E_INTERACTIVE  text
    FORM handle_toolbar_0100
      USING
        po_object TYPE REF TO cl_alv_event_toolbar_set.
      DATA: ls_toolbar TYPE stb_button.
      CLEAR ls_toolbar.
      ls_toolbar-butn_type  = 0.
      ls_toolbar-function   = 'KONV'.
      ls_toolbar-quickinfo  = 'Konvertieren'.
      ls_toolbar-text       = 'Konvertieren'.
      ls_toolbar-disabled   = ' '.
      APPEND ls_toolbar TO po_object->mt_toolbar.
    ENDFORM.                    " handle_toolbar_0100
    *&      Form  handle_user_command_0100
    *       text
    *      -->P_E_UCOMM  text
    FORM handle_user_command_0100
      USING
        pf_ucomm TYPE syucomm.
      CASE pf_ucomm.
        WHEN 'KONV'.
          PERFORM convert_data.
      ENDCASE.
    ENDFORM.                    " handle_user_command_0100
    *&      Form  exit_program
    *       text
    *  -->  p1        text
    *  <--  p2        text
    FORM exit_program.
      CALL METHOD go_alv_grid_0100->free.
      IF NOT go_alv_grid_0200 IS INITIAL.
        CALL METHOD go_alv_grid_0200->free.
      ENDIF.
      CALL METHOD go_docking_container->free.
      CALL METHOD cl_gui_cfw=>flush.
      IF sy-subrc NE 0.
    * add your handling, for example
        CALL FUNCTION 'POPUP_TO_INFORM'
          EXPORTING
            titel = sy-repid
            txt2  = sy-subrc
            txt1  = 'Error in Flush'(500).
      ENDIF.
      LEAVE PROGRAM.
    ENDFORM.                    " exit_program
    *&      Form  handle_toolbar_0200
    *       text
    *      -->P_E_OBJECT  text
    *      -->P_E_INTERACTIVE  text
    FORM handle_toolbar_0200
      USING
        po_object TYPE REF TO cl_alv_event_toolbar_set.
      DATA: ls_toolbar TYPE stb_button.
      CLEAR ls_toolbar.
      ls_toolbar-butn_type  = 0.
      ls_toolbar-function   = 'POST'.
      ls_toolbar-quickinfo  = 'Buchen'.
      ls_toolbar-text       = 'Buchen'.
      ls_toolbar-disabled   = ' '.
      APPEND ls_toolbar TO po_object->mt_toolbar.
    ENDFORM.                    " handle_toolbar_0200
    *&      Form  handle_user_command_0200
    *       text
    *      -->P_E_UCOMM  text
    FORM handle_user_command_0200
      USING
        pf_ucomm TYPE syucomm.
      CASE pf_ucomm.
        WHEN 'POST'.
          PERFORM post.
      ENDCASE.
    ENDFORM.                    " handle_user_command_0200
    *&      Form  convert_data
    *       text
    *  -->  p1        text
    *  <--  p2        text
    FORM convert_data.
      DATA: lf_perio(3) TYPE n.
      LOOP AT gt_text_input INTO gs_text_input.
        TRANSLATE gs_text_input-planbetrag USING '. '.
        TRANSLATE gs_text_input-planbetrag USING ',.'.
        CONDENSE gs_text_input-planbetrag.
        gs_bapi_input-version   = gp_versn.
        gs_bapi_input-fisc_year = gp_gjahr.
        gs_bapi_input-coobject  = gs_text_input-kostenstelle.
        gs_bapi_input-cost_elem = gs_text_input-kostenart.
        lf_perio = gs_text_input-planperiode.
        CASE lf_perio.
          WHEN '001'.
            gs_bapi_input-wkgbtr01 = gs_text_input-planbetrag.
          WHEN '002'.
            gs_bapi_input-wkgbtr02 = gs_text_input-planbetrag.
          WHEN '003'.
            gs_bapi_input-wkgbtr03 = gs_text_input-planbetrag.
          WHEN '004'.
            gs_bapi_input-wkgbtr04 = gs_text_input-planbetrag.
          WHEN '005'.
            gs_bapi_input-wkgbtr05 = gs_text_input-planbetrag.
          WHEN '006'.
            gs_bapi_input-wkgbtr06 = gs_text_input-planbetrag.
          WHEN '007'.
            gs_bapi_input-wkgbtr07 = gs_text_input-planbetrag.
          WHEN '008'.
            gs_bapi_input-wkgbtr08 = gs_text_input-planbetrag.
          WHEN '009'.
            gs_bapi_input-wkgbtr09 = gs_text_input-planbetrag.
          WHEN '010'.
            gs_bapi_input-wkgbtr10 = gs_text_input-planbetrag.
          WHEN '011'.
            gs_bapi_input-wkgbtr11 = gs_text_input-planbetrag.
          WHEN '012'.
            gs_bapi_input-wkgbtr12 = gs_text_input-planbetrag.
        ENDCASE.
        COLLECT gs_bapi_input INTO gt_bapi_input.
        CLEAR gs_bapi_input.
      ENDLOOP. "at gt_text_input
      CALL SCREEN 0200.
    ENDFORM.                    " convert_data
    *&      Form  build_fieldcatalog_bapi_input
    *       text
    *      <--P_GT_FIELDCAT  text
    FORM build_fieldcatalog_bapi_input
      CHANGING
        pt_fieldcat TYPE lvc_t_fcat.
      DATA ls_fcat TYPE lvc_s_fcat.
      CLEAR pt_fieldcat.
      CLEAR ls_fcat.
      ls_fcat-fieldname = 'VERSION' .
      ls_fcat-ref_table = 'BAPIPLNHDR' .
      APPEND ls_fcat TO pt_fieldcat .
      CLEAR ls_fcat.
      ls_fcat-fieldname = 'FISC_YEAR' .
      ls_fcat-ref_table = 'BAPIPLNHDR' .
      APPEND ls_fcat TO pt_fieldcat .
      CLEAR ls_fcat.
      ls_fcat-fieldname = 'COOBJECT' .
      ls_fcat-inttype = 'C' .
      ls_fcat-outputlen = '20' .
      ls_fcat-coltext = 'CO-Objekt' .
      ls_fcat-seltext = 'CO-Objekt' .
      APPEND ls_fcat TO pt_fieldcat .
      CLEAR ls_fcat.
      ls_fcat-fieldname = 'COST_ELEM' .
      ls_fcat-ref_table = 'BAPIPCPVAL' .
      APPEND ls_fcat TO pt_fieldcat .
      CLEAR ls_fcat.
      ls_fcat-fieldname = 'WKGBTR01'.
      ls_fcat-ref_table = 'COEP' .
      ls_fcat-ref_field = 'WKGBTR'.
      APPEND ls_fcat TO pt_fieldcat .
      CLEAR ls_fcat.
      ls_fcat-fieldname = 'WKGBTR02'.
      ls_fcat-ref_table = 'COEP' .
      ls_fcat-ref_field = 'WKGBTR'.
      APPEND ls_fcat TO pt_fieldcat .
      CLEAR ls_fcat.
      ls_fcat-fieldname = 'WKGBTR03'.
      ls_fcat-ref_table = 'COEP' .
      ls_fcat-ref_field = 'WKGBTR'.
      APPEND ls_fcat TO pt_fieldcat .
      CLEAR ls_fcat.
      ls_fcat-fieldname = 'WKGBTR04'.
      ls_fcat-ref_table = 'COEP' .
      ls_fcat-ref_field = 'WKGBTR'.
      APPEND ls_fcat TO pt_fieldcat .
      CLEAR ls_fcat.
      ls_fcat-fieldname = 'WKGBTR05'.
      ls_fcat-ref_table = 'COEP' .
      ls_fcat-ref_field = 'WKGBTR'.
      APPEND ls_fcat TO pt_fieldcat .
      CLEAR ls_fcat.
      ls_fcat-fieldname = 'WKGBTR06'.
      ls_fcat-ref_table = 'COEP' .
      ls_fcat-ref_field = 'WKGBTR'.
      APPEND ls_fcat TO pt_fieldcat .
      CLEAR ls_fcat.
      ls_fcat-fieldname = 'WKGBTR07'.
      ls_fcat-ref_table = 'COEP' .
      ls_fcat-ref_field = 'WKGBTR'.
      APPEND ls_fcat TO pt_fieldcat .
      CLEAR ls_fcat.
      ls_fcat-fieldname = 'WKGBTR08'.
      ls_fcat-ref_table = 'COEP' .
      ls_fcat-ref_field = 'WKGBTR'.
      APPEND ls_fcat TO pt_fieldcat .
      CLEAR ls_fcat.
      ls_fcat-fieldname = 'WKGBTR09'.
      ls_fcat-ref_table = 'COEP' .
      ls_fcat-ref_field = 'WKGBTR'.
      APPEND ls_fcat TO pt_fieldcat .
      CLEAR ls_fcat.
      ls_fcat-fieldname = 'WKGBTR10'.
      ls_fcat-ref_table = 'COEP' .
      ls_fcat-ref_field = 'WKGBTR'.
      APPEND ls_fcat TO pt_fieldcat .
      CLEAR ls_fcat.
      ls_fcat-fieldname = 'WKGBTR11'.
      ls_fcat-ref_table = 'COEP' .
      ls_fcat-ref_field = 'WKGBTR'.
      APPEND ls_fcat TO pt_fieldcat .
      CLEAR ls_fcat.
      ls_fcat-fieldname = 'WKGBTR12'.
      ls_fcat-ref_table = 'COEP' .
      ls_fcat-ref_field = 'WKGBTR'.
      APPEND ls_fcat TO pt_fieldcat .
    ENDFORM.                    " build_fieldcatalog_bapi_input
    *&      Form  post
    *       text
    *  -->  p1        text
    *  <--  p2        text
    FORM post.
      DATA:
        lf_index(6) TYPE n,
        lf_kostl    LIKE csks-kostl,
        lf_aufnr    LIKE aufk-aufnr,
        lf_kstar    LIKE cska-kstar.
      DATA:
        lt_csks TYPE TABLE OF csks.
      break c5085345.
    * Header
      gs_headerinfo-co_area       = gp_kokrs.
      gs_headerinfo-fisc_year     = gp_gjahr.
      gs_headerinfo-period_from   = '001'.
      gs_headerinfo-period_to     = '012'.
      gs_headerinfo-version       = gp_versn.
      gs_headerinfo-plan_currtype = 'C'.
      LOOP AT gt_bapi_input INTO gs_bapi_input.
    *   Fill index structure
        CLEAR gs_indexstructure.
        lf_index = sy-tabix.
        gs_indexstructure-object_index = lf_index.
        gs_indexstructure-value_index  = lf_index.
        gs_indexstructure-attrib_index = '000000'.
        INSERT gs_indexstructure INTO TABLE gt_indexstructure.
    *   Fill coobject
        CLEAR gs_coobject.
        gs_coobject-object_index = lf_index.
        CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT'
          EXPORTING
            input  = gs_bapi_input-coobject
          IMPORTING
            output = lf_kostl.
        SELECT * FROM csks INTO TABLE lt_csks
          WHERE
            kokrs = gp_kokrs AND
            kostl = lf_kostl.
        IF sy-subrc = 0.
          gs_coobject-costcenter = lf_kostl.
        ELSE.
          CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT'
            EXPORTING
              input  = gs_bapi_input-coobject
            IMPORTING
              output = lf_aufnr.
          CALL FUNCTION 'K_ORDER_READ'
            EXPORTING
              aufnr     = lf_aufnr
            EXCEPTIONS
              not_found = 1.
          IF NOT sy-subrc = 0.
            gs_return-type = 'E'.
            gs_return-message+0(10)  = 'CO-Objekt '.
            gs_return-message+10(10) = gs_bapi_input-coobject.
            gs_return-message+20(20)  = ' existiert nicht.'.
            CONDENSE gs_return-message.
            PERFORM add_log_message_free_text
              USING
                gs_return-type
                gs_return-message.
            EXIT.
          ENDIF. "IF NOT sy-subrc = 0
          gs_coobject-orderid = lf_aufnr.
        ENDIF. "sy-subrc = 0
        INSERT gs_coobject INTO TABLE gt_coobject.
    *   Period value
        gs_pervalue-value_index = lf_index.
        CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT'
          EXPORTING
            input  = gs_bapi_input-cost_elem
          IMPORTING
            output = lf_kstar.
        gs_pervalue-cost_elem = lf_kstar.
        gs_pervalue-fix_val_per01 = gs_bapi_input-wkgbtr01.
        gs_pervalue-fix_val_per02 = gs_bapi_input-wkgbtr02.
        gs_pervalue-fix_val_per03 = gs_bapi_input-wkgbtr03.
        gs_pervalue-fix_val_per04 = gs_bapi_input-wkgbtr04.
        gs_pervalue-fix_val_per05 = gs_bapi_input-wkgbtr05.
        gs_pervalue-fix_val_per06 = gs_bapi_input-wkgbtr06.
        gs_pervalue-fix_val_per07 = gs_bapi_input-wkgbtr07.
        gs_pervalue-fix_val_per08 = gs_bapi_input-wkgbtr08.
        gs_pervalue-fix_val_per09 = gs_bapi_input-wkgbtr09.
        gs_pervalue-fix_val_per10 = gs_bapi_input-wkgbtr10.
        gs_pervalue-fix_val_per11 = gs_bapi_input-wkgbtr11.
        gs_pervalue-fix_val_per12 = gs_bapi_input-wkgbtr12.
        INSERT gs_pervalue INTO TABLE gt_pervalue.
      ENDLOOP. "at gt_bapi_input
    * Buchungsbaustein
      CALL FUNCTION 'BAPI_PRIM_COST_CHECK_AND_POST'
        EXPORTING
          header_info         = gs_headerinfo
          testrun             = gp_test
    *   DELTA               = ' '
        TABLES
          idx_structure       = gt_indexstructure
          object              = gt_coobject
          per_value           = gt_pervalue
          tot_value           = gt_totvalue
          contrl              = gt_control
          return              = gt_return.
      CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'.
    *   EXPORTING
    *     WAIT          =
    *   IMPORTING
    *     RETURN        =
      LOOP AT gt_return INTO gs_return.
        gs_balsmsg-msgty = gs_return-type.
        gs_balsmsg-msgid = gs_return-id.
        gs_balsmsg-msgno = gs_return-number.
        gs_balsmsg-msgv1 = gs_return-message_v1.
        gs_balsmsg-msgv2 = gs_return-message_v2.
        gs_balsmsg-msgv3 = gs_return-message_v3.
        gs_balsmsg-msgv4 = gs_return-message_v4.
        PERFORM add_log_message
          USING
            gs_balsmsg.
      ENDLOOP. "AT gt_return
      PERFORM show_log.
    ENDFORM.                    " post
    *&      Form  create_log
    *       text
    *  -->  p1        text
    *  <--  p2        text
    FORM create_log .
      DATA: ls_balslog TYPE bal_s_log.
    * Einige Verwaltungsdaten
      ls_balslog-extnumber = 'ZPLAN010'.
      ls_balslog-aluser    = sy-uname.
      ls_balslog-alprog    = sy-repid.
    * Create
      CALL FUNCTION 'BAL_LOG_CREATE'
        EXPORTING
          i_s_log                 = ls_balslog
    *    IMPORTING
    *      e_log_handle            = gf_balloghndl
        EXCEPTIONS
          log_header_inconsistent = 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.                    " create_log
    *&      Form  add_log_message
    *       text
    *      -->P_GS_BALSMSG  text
    FORM add_log_message
      USING
        ps_balsmsg TYPE bal_s_msg.
      break c5085345.
      CALL FUNCTION 'BAL_LOG_MSG_ADD'
        EXPORTING
    *       I_LOG_HANDLE              =
          i_s_msg                   = ps_balsmsg
    *     IMPORTING
    *       E_S_MSG_HANDLE            =
    *       E_MSG_WAS_LOGGED          =
    *       E_MSG_WAS_DISPLAYED       =
       EXCEPTIONS
         log_not_found             = 1
         msg_inconsistent          = 2
         log_is_full               = 3
         OTHERS                    = 4.
      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.                    " add_log_messa
    *&      Form  add_log_message_free_text
    *       text
    *      -->P_GS_RETURN_TYPE  text
    *      -->P_GS_RETURN_MESSAGE  text
    FORM add_log_message_free_text
      USING
        ps_type
        ps_message.
      CALL FUNCTION 'BAL_LOG_MSG_ADD_FREE_TEXT'
        EXPORTING
    *       I_LOG_HANDLE              =
          i_msgty                   = ps_type
    *       I_PROBCLASS               = '4'
          i_text                    = ps_message
    *       I_S_CONTEXT               =
    *       I_S_PARAMS                =
    *     IMPORTING
    *       E_S_MSG_HANDLE            =
    *       E_MSG_WAS_LOGGED          =
    *       E_MSG_WAS_DISPLAYED       =
       EXCEPTIONS
         log_not_found             = 1
         msg_inconsistent          = 2
         log_is_full               = 3
         OTHERS                    = 4.
      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.                    " add_log_message_free_text
    *&      Form  show_log
    *       text
    *  -->  p1        text
    *  <--  p2        text
    FORM show_log .
      DATA:
        l_s_display_profile TYPE bal_s_prof.
    * get display profile
      CALL FUNCTION 'BAL_DSP_PROFILE_NO_TREE_GET'
        IMPORTING
          e_s_display_profile = l_s_display_profile
        EXCEPTIONS
          OTHERS              = 1.
      IF sy-subrc <> 0.
        MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
                 WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
      ENDIF.
    * use grid for display if wanted
      l_s_display_profile-use_grid = 'X'.
    * set report to allow saving of variants
      l_s_display_profile-disvariant-report = sy-repid.
    * when you use also other ALV lists in your report,
    * please specify a handle to distinguish between the display
    * variants of these different lists, e.g:
      l_s_display_profile-disvariant-handle = 'LOG'.
    * call display function module
    * We do not specify any filter (like I_S_LOG_FILTER, ...,
    * I_T_MSG_HANDLE) since we want to display all logs available
      CALL FUNCTION 'BAL_DSP_LOG_DISPLAY'
        EXPORTING
          i_s_display_profile = l_s_display_profile
        EXCEPTIONS
          OTHERS              = 1.
      IF sy-subrc <> 0.
        MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
                 WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
      ENDIF.

  • Problem in ALV Tree

    Hello Friends,
    I am using ALV Tree to display a report.
    In this report for a particular input.2 nodes are cerated.
    On clicking on the 2nd node the details for the same are shown .
    However on clicking the 1st node , the system automatically logs off closing all the SAP sessions and even the SAP Logon pad.
    Suppose i am on executing the program on development server,even the sessions of test server are closed.
    Can anyone please help me in this.....
    its a bit urgent.
    i am attaching my code for reference.
    REPORT  ZPRPROUTOPERATIONS1                     .
    tables : mapl,t001w,zroutpromast.
    TYPE-POOLS: slis,kkblo.
    include <icon>.
    data : it_zrouteledtl like zrouteledtl occurs 0 with header line.
    data : it_zeledtl type zeledtl occurs 0 with header line.
    data : conv_sec(5) type c value '0.036'.
    types : begin of it_output2,
           Srno like zrouteledtl-srno,
           srno1 type p decimals 8,
           subgid like zrouteledtl-subgid,
           subopn like zrouteledtl-subopn,
           movetype type zeledtl-movetype,
           DESC type zeledtl-description,
           Add_desc like zrouteledtl-DESCRIPTION,
           Freq type p decimals 2,
           div_freq type p decimals 2,
           men type p decimals 2,
           offline(3),
           CT type p decimals 2,
           CW type p decimals 2,
           Ideal_ct type p decimals 2,
           ideal_cw type p decimals 2,
           A_trg type p decimals 2,
           b_Trg type p decimals 2,
           g_Trg type p decimals 2,
           p_Trg type p decimals 2,
           m_Trg type p decimals 2,
           t_Trg type p decimals 2,
           i_Trg type p decimals 2,
           Autocycle type p decimals 2,
           online_time type p decimals 2,
           offline_time type p decimals 2,
           online_p_time type p decimals 2,
           offline_p_time type p decimals 2,
           end of it_output2.
    *types : begin of it_output3,
          Srno like zrouteledtl-srno,
          mop_gid like zroutdetails-MOP_GID,
          MOp_opn like zroutdetails-MOP_OPN,
          sub_gid like zpromast-subgid,
          subopn like zpromast-subopn,
          DESC like zpromast-description,
          Add_desc like zroutdetails-ADD_INFO,
          Freq type p decimals 2,
          batch type p decimals 2,
          mix type p decimals 2,
          offline(3),
          CT type p decimals 2,
          CW type p decimals 2,
          Ideal_ct type p decimals 2,
          ideal_cw type p decimals 2,
          A_trg type p decimals 2,
          b_Trg type p decimals 2,
          g_Trg type p decimals 2,
          p_Trg type p decimals 2,
          m_Trg type p decimals 2,
          t_Trg type p decimals 2,
          i_Trg type p decimals 2,
          Autocycle type p decimals 2,
          online_time type p decimals 2,
          offline_time type p decimals 2,
          online_p_time type p decimals 2,
          offline_p_time type p decimals 2,
          end of it_output3.
    data : it_output type it_output2 occurs 0 with header line,
           it_output1 type it_output2 occurs 0 with header line,
           it_emptytab type standard table of it_output2 INITIAL SIZE 0.
    data : a_trg type f,b_trg type f,g_trg type f,p_trg type f,m_trg type f,t_trg type f,i_trg type f,
           autocycle type f,online_p_time type f,offline_p_time type f.
    data : ch1 type c,ch2.
    DATA: ok_code like sy-ucomm,           "OK-Code
          save_ok like sy-ucomm.
    data : ct_fieldcat type KKBLO_T_FIELDCAT.
    *ALV data declarations
    DATA: fieldcatalog  TYPE lvc_t_fcat WITH HEADER LINE.
    DATA: gd_fieldcat   TYPE lvc_t_fcat,
          gd_tab_group  TYPE slis_t_sp_group_alv,
          gd_layout     TYPE slis_layout_alv.
    *ALVtree data declarations
    CLASS cl_gui_column_tree DEFINITION LOAD.
    CLASS cl_gui_cfw DEFINITION LOAD.
    DATA: gd_tree             TYPE REF TO cl_gui_alv_tree,
          gd_hierarchy_header TYPE treev_hhdr,
          gd_report_title     TYPE slis_t_listheader,
          gd_logo             TYPE sdydo_value,
          gd_variant          TYPE disvariant.
    *Create container for alv-tree
    DATA: gd_tree_container_name(30) TYPE c,
          gd_custom_container        TYPE REF TO cl_gui_custom_container.
    *data mr_toolbar type ref to cl_gui_toolbar.  "Add to top include
    selection-screen begin of block start with frame title text-001.
    select-options: p_gid for zroutpromast-mop_gid obligatory no-extension no intervals,
                    p_opn for zroutpromast-mop_opn obligatory no-extension no intervals,
                    p_werks for t001w-werks obligatory no-extension no intervals.
    selection-screen end of block start.
    *selection-screen begin of block detail with frame title text-002.
    *parameter : radio1 radiobutton group dept default 'X',
               radio2 radiobutton group dept.
    *selection-screen end of block detail.
    include ZTEST_TOOLBAR_EVENT_RECEIVER.
    start-of-selection.
    ALVtree setup data
      PERFORM data_retrieval.
      PERFORM build_fieldcatalog.
      PERFORM build_layout.
      PERFORM build_hierarchy_header CHANGING gd_hierarchy_header.
      PERFORM build_report_title USING gd_report_title gd_logo.
      PERFORM build_variant.
    Display ALVtree report
      call screen 100.
    *&      Form  data_retrieval
          text
    -->  p1        text
    <--  p2        text
    FORM data_retrieval .
      select * from zrouteledtl into table it_zrouteledtl where mop_gid in p_gid and
                                                                  mop_opn in p_opn
                                                                  and werks in p_werks.
      if sy-subrc ne 0.
      message i001(0) with 'No Records Found'.
      leave program.
      endif.
      select * from zeledtl into table it_zeledtl for all entries in it_zrouteledtl
                                                          where subgid = it_zrouteledtl-subgid
                                                          and subopn = it_zrouteledtl-subopn
                                                          and werks = it_zrouteledtl-werks.
      loop at it_zeledtl.
        it_output1-srno = it_zeledtl-srno.
        it_output1-srno1 = it_zeledtl-srno.
        it_output1-subgid = it_zeledtl-subgid.
        it_output1-subopn = it_zeledtl-subopn.
        it_output1-movetype = it_zeledtl-movetype.
        it_output1-desc = it_zeledtl-DESCRIPTION.
        it_output1-freq = it_zeledtl-frequency.
        it_output1-div_freq = it_zeledtl-div_freq.
        it_output1-men = it_zeledtl-men.
        it_output1-offline = it_zeledtl-offline1.
        it_output1-ct = it_zeledtl-cy_time * conv_sec.
        it_output1-cw = it_zeledtl-wc_time * conv_sec.
        it_output1-ideal_ct = it_zeledtl-cy_trg_time * conv_sec.
        it_output1-ideal_cw = it_zeledtl-wc_trg_time * conv_sec.
        if it_zeledtl-men = 0.
        it_output-autocycle = it_zeledtl-cy_time * conv_sec.
        endif.
        if it_zeledtl-men ne 0 and it_zeledtl-offline1 eq 'NO'
              and ( it_zeledtl-movetype eq 'A' or it_zeledtl-movetype eq 'C' ).
        case it_zeledtl-movetype.
              when 'A'.
                if it_zeledtl-SIM_AUTO = 'TRUE'.
                  ch2 = 0.
                else.
                  ch2 = 1.
                endif.
                it_output-online_p_time = ( it_zeledtl-autocycle * ch2 * conv_sec ) * it_zeledtl-frequency / it_zeledtl-div_freq.
              when 'C'.
                if it_zeledtl-sim5 = 'TRUE'.
                  ch1 = 0.
                else.
                  ch1 = 1.
                endif.
                it_output-online_p_time =  ( it_zeledtl-index5 * it_zeledtl-par_freq5 * ch1
    it_zeledtl-frequency * 10 ) / it_zeledtl-div_freq  .
            endcase.
          elseif it_zeledtl-men ne 0 and it_zeledtl-offline1 eq 'YES'
                  and ( it_zeledtl-movetype eq 'A' or it_zeledtl-movetype eq 'C' ).
            case it_zeledtl-movetype.
              when 'A'.
                if it_zeledtl-SIM_AUTO = 'TRUE'.
                  ch2 = 0.
                else.
                  ch2 = 1.
                endif.
                it_output1-offline_p_time = ( it_zeledtl-autocycle * ch2 * conv_sec ) * it_zeledtl-frequency / it_zeledtl-div_freq.
              when 'C'.
                if it_zeledtl-sim5 = 'TRUE'.
                  ch1 = 0.
                else.
                  ch1 = 1.
                endif.
                it_output-offline_p_time =  ( it_zeledtl-index5 * it_zeledtl-par_freq5 * ch1
    it_zeledtl-frequency * 10 ) / it_zeledtl-div_freq  .
            endcase.
          endif.
          it_output1-a_trg = it_zeledtl-TARGET_A * conv_sec.
          it_output1-b_trg = it_zeledtl-target_B * conv_sec.
          it_output1-g_trg = it_zeledtl-TARGET_G * conv_sec.
          it_output1-p_trg = it_zeledtl-TARGET_P * conv_sec.
          it_output1-M_trg = it_zeledtl-TARGET_M * conv_sec.
          it_output1-t_trg = it_zeledtl-TARGET_T * conv_sec.
          it_output1-i_trg = it_zeledtl-TARGET_I * conv_sec.
        append it_output1.
      endloop.
      sort it_output1 ascending by subgid subopn srno1.
      clear ch1.
      loop at it_zrouteledtl.
        move-corresponding it_zrouteledtl to it_output.
        select single description from zpromast into it_output-desc
                                      where subgid = it_zrouteledtl-subgid and
                                      subopn = it_zrouteledtl-subopn and
                                      werks in p_werks.
        it_output-add_desc = it_zrouteledtl-description.
        it_output-freq = it_zrouteledtl-frequency.
        it_output-div_freq = it_zrouteledtl-div_freq.
        it_output-men = it_zrouteledtl-men.
        it_output-ct = it_zrouteledtl-cy_time * conv_sec.
        it_output-cw = it_zrouteledtl-wc_time * conv_sec.
        it_output-ideal_ct = it_zrouteledtl-cy_trg_time * conv_sec.
        it_output-ideal_cw = it_zrouteledtl-wc_trg_time * conv_sec.
        if it_zrouteledtl-offline1 = '1'.
          it_output-offline = 'No'.
        else.
          it_output-offline = 'Yes'.
        endif.
        append it_output.
      endloop.
      loop at it_output.
        if it_output-offline = 'Yes'.
        ch1 = 0.
        else.
        ch1 = 1.
        endif.
        loop at it_output1 where subgid = it_output-subgid and
                                 subopn = it_output-subopn.
          a_trg = A_trg + it_output1-A_trg.
          b_Trg = b_Trg + it_output1-b_Trg.
          g_Trg = g_Trg + it_output1-g_Trg.
          p_Trg = p_Trg + it_output1-p_Trg.
          m_Trg = m_Trg + it_output1-m_Trg.
          t_Trg = t_Trg + it_output1-t_Trg.
          i_Trg = i_Trg + it_output1-i_Trg.
          autocycle = autocycle + it_output1-Autocycle.
          online_p_time = online_p_time + it_output1-online_p_time.
          offline_p_time = offline_p_time + it_output1-offline_p_time.
        endloop.
          it_output-autocycle = ( autocycle * ch1 * it_output-freq ) / it_output-div_freq / it_output-men.
          it_output-a_trg = ( a_trg * ch1 * it_output-freq ) / it_output-div_freq / it_output-men.
          it_output-b_trg = ( b_trg * ch1 * it_output-freq ) / it_output-div_freq / it_output-men.
          it_output-g_trg = ( g_trg * ch1 * it_output-freq ) / it_output-div_freq / it_output-men.
          it_output-p_trg = ( p_trg * ch1 * it_output-freq ) / it_output-div_freq / it_output-men.
          it_output-m_trg = ( m_trg * ch1 * it_output-freq ) / it_output-div_freq / it_output-men.
          it_output-t_trg = ( t_trg * ch1 * it_output-freq ) / it_output-div_freq / it_output-men.
          it_output-i_trg = ( i_trg * ch1 * it_output-freq ) / it_output-div_freq / it_output-men.
          it_output-online_time = ( it_output-ct - it_output-autocycle ) * ch1.
          it_output-offline_time = ( it_output-ct - it_output-cw ) + it_output-autocycle.
          it_output-online_p_time = ( online_p_time * ch1 * it_output-freq ) / it_output-div_freq / it_output-men.
          it_output-offline_p_time = ( offline_p_time * ch1 * it_output-freq ) / it_output-div_freq / it_output-men.
          clear : a_trg,b_trg,g_trg,p_trg,m_trg,t_trg,i_trg,online_p_time,offline_p_time,ch1,ch2,it_zeledtl,
                  autocycle,online_p_time,offline_p_time,zroutpromast.
        modify it_output.
      endloop.
    ENDFORM.                    " data_retrieval
    *&      Form  build_fieldcatalog
          text
    -->  p1        text
    <--  p2        text
    FORM build_fieldcatalog .
    Please not there are a number of differences between the structure of
    ALVtree fieldcatalogs and ALVgrid fieldcatalogs.
    For example the field seltext_m is replace by scrtext_m in ALVtree.
      DATA: COL_POS TYPE I VALUE 0.
      fieldcatalog-fieldname   = 'SRNO'.
      fieldcatalog-SCRTEXT_L   = 'Sr No.'.
      fieldcatalog-SCRTEXT_m   = 'Sr No.'.
      fieldcatalog-SCRTEXT_s   = 'Sr No.'.
      fieldcatalog-outputlen   = 15.
      fieldcatalog-col_pos     = COL_POS.
      APPEND fieldcatalog TO gd_fieldcat..
      CLEAR  fieldcatalog.
      COL_POS = COL_POS + 1.
      fieldcatalog-fieldname   = 'SUBGID'.           "Field name in itab
      fieldcatalog-SCRTEXT_L   = 'Sub Opn GID'.  "Column text
      fieldcatalog-SCRTEXT_m   = 'Sub Opn GID'.  "Column text
      fieldcatalog-SCRTEXT_s   = 'Sub Opn GID'.  "Column text
      fieldcatalog-col_pos     = COL_POS.     "Column position
      fieldcatalog-outputlen   = 15.                "Column width
      fieldcatalog-emphasize   = 'X'.               "Emphasize  (X or SPACE)
      fieldcatalog-key         = 'X'.               "Key Field? (X or SPACE)
    fieldcatalog-do_sum      = 'X'.              "Sum Column?
    fieldcatalog-no_zero     = 'X'.              "Don't display if zero
      APPEND fieldcatalog TO gd_fieldcat.
      CLEAR  fieldcatalog.
      COL_POS = COL_POS + 1.
      fieldcatalog-fieldname   = 'SUBOPN'.
      fieldcatalog-SCRTEXT_L   = 'Sub Opn'.
      fieldcatalog-SCRTEXT_m   = 'Sub Opn'.
      fieldcatalog-SCRTEXT_s   = 'Sub Opn'.
      fieldcatalog-outputlen   = 15.
      fieldcatalog-col_pos     = COL_POS.
      fieldcatalog-emphasize   = 'X'.               "Emphasize  (X or SPACE)
      fieldcatalog-key         = 'X'.               "Key Field? (X or SPACE)
      APPEND fieldcatalog TO gd_fieldcat..
      CLEAR  fieldcatalog.
      COL_POS = COL_POS + 1.
      fieldcatalog-fieldname   = 'MOVETYPE'.
      fieldcatalog-SCRTEXT_L   = 'Movetype'.
      fieldcatalog-SCRTEXT_m   = 'Movetype'.
      fieldcatalog-SCRTEXT_s   = 'Movetype'.
      fieldcatalog-outputlen   = 15.
      fieldcatalog-col_pos     = COL_POS.
      APPEND fieldcatalog TO gd_fieldcat..
      CLEAR  fieldcatalog.
      COL_POS = COL_POS + 1.
      fieldcatalog-fieldname   = 'DESC'.
      fieldcatalog-SCRTEXT_L   = 'Description'.
      fieldcatalog-SCRTEXT_m   = 'Description'.
      fieldcatalog-SCRTEXT_s   = 'Description'.
      fieldcatalog-outputlen   = 600.
      fieldcatalog-col_pos     = COL_POS.
      APPEND fieldcatalog TO gd_fieldcat..
      CLEAR  fieldcatalog.
      COL_POS = COL_POS + 1.
      fieldcatalog-fieldname   = 'ADD_DESC'.
      fieldcatalog-SCRTEXT_L   = 'Add. Description'.
      fieldcatalog-SCRTEXT_m   = 'Add. Description'.
      fieldcatalog-SCRTEXT_s   = 'Add. Description'.
      fieldcatalog-outputlen   = 100.
      fieldcatalog-col_pos     = COL_POS.
      APPEND fieldcatalog TO gd_fieldcat..
      CLEAR  fieldcatalog.
      COL_POS = COL_POS + 1.
      fieldcatalog-fieldname   = 'FREQ'.
      fieldcatalog-SCRTEXT_L   = 'Frequency'.
      fieldcatalog-SCRTEXT_m   = 'Frequency'.
      fieldcatalog-SCRTEXT_s   = 'Frequency'.
      fieldcatalog-outputlen   = 15.
      fieldcatalog-col_pos     = COL_POS.
      APPEND fieldcatalog TO gd_fieldcat..
      CLEAR  fieldcatalog.
      COL_POS = COL_POS + 1.
      fieldcatalog-fieldname   = 'DIV_FREQ'.
      fieldcatalog-SCRTEXT_L   = 'Div Freq'.
      fieldcatalog-SCRTEXT_m   = 'Div Freq'.
      fieldcatalog-SCRTEXT_s   = 'Div Freq'.
      fieldcatalog-outputlen   = 15.
      fieldcatalog-col_pos     = COL_POS.
      APPEND fieldcatalog TO gd_fieldcat..
      CLEAR  fieldcatalog.
      COL_POS = COL_POS + 1.
      fieldcatalog-fieldname   = 'MEN'.
      fieldcatalog-SCRTEXT_L   = 'Men'.
      fieldcatalog-SCRTEXT_m   = 'Men'.
      fieldcatalog-SCRTEXT_s   = 'Men'.
      fieldcatalog-outputlen   = 15.
      fieldcatalog-col_pos     = COL_POS.
      APPEND fieldcatalog TO gd_fieldcat..
      CLEAR  fieldcatalog.
    COL_POS = COL_POS + 1.
    fieldcatalog-fieldname   = 'BATCH'.
    fieldcatalog-SCRTEXT_L   = 'Batch/Div Freq'.
    fieldcatalog-SCRTEXT_m   = 'Batch/Div Freq'.
    fieldcatalog-SCRTEXT_s   = 'Batch/Div Freq'.
    fieldcatalog-outputlen   = 15.
    fieldcatalog-col_pos     = COL_POS.
    APPEND fieldcatalog TO gd_fieldcat.
    CLEAR  fieldcatalog.
      COL_POS = COL_POS + 1.
      fieldcatalog-fieldname   = 'OFFLINE'.
      fieldcatalog-SCRTEXT_L   = 'Offline'.
      fieldcatalog-SCRTEXT_m   = 'Offline'.
      fieldcatalog-SCRTEXT_s   = 'Offline'.
      fieldcatalog-outputlen   = 6.
      fieldcatalog-col_pos     = COL_POS.
      APPEND fieldcatalog TO gd_fieldcat.
      CLEAR  fieldcatalog.
      COL_POS = COL_POS + 1.
      fieldcatalog-fieldname   = 'CT'.
      fieldcatalog-SCRTEXT_L   = 'Cycle Time'.
      fieldcatalog-SCRTEXT_m   = 'Cycle Time'.
      fieldcatalog-SCRTEXT_s   = 'Cycle Time'.
      fieldcatalog-outputlen   = 15.
      fieldcatalog-col_pos     = COL_POS.
      fieldcatalog-do_sum      = 'X'.
      APPEND fieldcatalog TO gd_fieldcat.
      CLEAR  fieldcatalog.
      COL_POS = COL_POS + 1.
      fieldcatalog-fieldname   = 'CW'.
      fieldcatalog-SCRTEXT_L   = 'Work Content'.
      fieldcatalog-SCRTEXT_m   = 'Work Content'.
      fieldcatalog-SCRTEXT_s   = 'Work Content'.
      fieldcatalog-outputlen   = 15.
      fieldcatalog-col_pos     = COL_POS.
      fieldcatalog-do_sum      = 'X'.
      APPEND fieldcatalog TO gd_fieldcat.
      CLEAR  fieldcatalog.
      COL_POS = COL_POS + 1.
      fieldcatalog-fieldname   = 'IDEAL_CT'.
      fieldcatalog-SCRTEXT_L   = 'Ideal CT'.
      fieldcatalog-SCRTEXT_m   = 'Ideal CT'.
      fieldcatalog-SCRTEXT_s   = 'Ideal CT'.
      fieldcatalog-outputlen   = 15.
      fieldcatalog-col_pos     = COL_POS.
      fieldcatalog-do_sum      = 'X'.
      APPEND fieldcatalog TO gd_fieldcat.
      CLEAR  fieldcatalog.
      COL_POS = COL_POS + 1.
      fieldcatalog-fieldname   = 'IDEAL_CW'.
      fieldcatalog-SCRTEXT_L   = 'Ideal CW'.
      fieldcatalog-SCRTEXT_m   = 'Ideal CW'.
      fieldcatalog-SCRTEXT_s   = 'Ideal CW'.
      fieldcatalog-outputlen   = 15.
      fieldcatalog-col_pos     = COL_POS.
      fieldcatalog-do_sum      = 'X'.
      APPEND fieldcatalog TO gd_fieldcat.
      CLEAR  fieldcatalog.
      COL_POS = COL_POS + 1.
      fieldcatalog-fieldname   = 'A_TRG'.
      fieldcatalog-SCRTEXT_L   = 'Target A'.
      fieldcatalog-SCRTEXT_m   = 'Target A'.
      fieldcatalog-SCRTEXT_s   = 'Target A'.
      fieldcatalog-outputlen   = 15.
      fieldcatalog-col_pos     = COL_POS.
      fieldcatalog-do_sum      = 'X'.
      APPEND fieldcatalog TO gd_fieldcat.
      CLEAR  fieldcatalog.
      COL_POS = COL_POS + 1.
      fieldcatalog-fieldname   = 'B_TRG'.
      fieldcatalog-SCRTEXT_L   = 'Target B'.
      fieldcatalog-SCRTEXT_m   = 'Target B'.
      fieldcatalog-SCRTEXT_s   = 'Target B'.
      fieldcatalog-outputlen   = 15.
      fieldcatalog-col_pos     = COL_POS.
      fieldcatalog-do_sum      = 'X'.
      APPEND fieldcatalog TO gd_fieldcat.
      CLEAR  fieldcatalog.
      COL_POS = COL_POS + 1.
      fieldcatalog-fieldname   = 'G_TRG'.
      fieldcatalog-SCRTEXT_L   = 'Target G'.
      fieldcatalog-SCRTEXT_m   = 'Target G'.
      fieldcatalog-SCRTEXT_s   = 'Target G'.
      fieldcatalog-outputlen   = 15.
      fieldcatalog-col_pos     = COL_POS.
      fieldcatalog-do_sum      = 'X'.
      APPEND fieldcatalog TO gd_fieldcat.
      CLEAR  fieldcatalog.
      COL_POS = COL_POS + 1.
      fieldcatalog-fieldname   = 'P_TRG'.
      fieldcatalog-SCRTEXT_L   = 'Target P'.
      fieldcatalog-SCRTEXT_m   = 'Target P'.
      fieldcatalog-SCRTEXT_s   = 'Target P'.
      fieldcatalog-outputlen   = 15.
      fieldcatalog-col_pos     = COL_POS.
      fieldcatalog-do_sum      = 'X'.
      APPEND fieldcatalog TO gd_fieldcat.
      CLEAR  fieldcatalog.
      COL_POS = COL_POS + 1.
      fieldcatalog-fieldname   = 'M_TRG'.
      fieldcatalog-SCRTEXT_L   = 'Target M'.
      fieldcatalog-SCRTEXT_m   = 'Target M'.
      fieldcatalog-SCRTEXT_s   = 'Target M'.
      fieldcatalog-outputlen   = 15.
      fieldcatalog-col_pos     = COL_POS.
      fieldcatalog-do_sum      = 'X'.
      APPEND fieldcatalog TO gd_fieldcat.
      CLEAR  fieldcatalog.
      COL_POS = COL_POS + 1.
      fieldcatalog-fieldname   = 'T_TRG'.
      fieldcatalog-SCRTEXT_L   = 'Target T'.
      fieldcatalog-SCRTEXT_m   = 'Target T'.
      fieldcatalog-SCRTEXT_s   = 'Target T'.
      fieldcatalog-outputlen   = 15.
      fieldcatalog-col_pos     = COL_POS.
      fieldcatalog-do_sum      = 'X'.
      APPEND fieldcatalog TO gd_fieldcat.
      CLEAR  fieldcatalog.
      COL_POS = COL_POS + 1.
      fieldcatalog-fieldname   = 'I_TRG'.
      fieldcatalog-SCRTEXT_L   = 'Target I'.
      fieldcatalog-SCRTEXT_m   = 'Target I'.
      fieldcatalog-SCRTEXT_s   = 'Target I'.
      fieldcatalog-outputlen   = 15.
      fieldcatalog-col_pos     = COL_POS.
      fieldcatalog-do_sum      = 'X'.
      APPEND fieldcatalog TO gd_fieldcat.
      CLEAR  fieldcatalog.
      COL_POS = COL_POS + 1.
      fieldcatalog-fieldname   = 'AUTOCYCLE'.
      fieldcatalog-SCRTEXT_L   = 'AutoCycle'.
      fieldcatalog-SCRTEXT_m   = 'AutoCycle'.
      fieldcatalog-SCRTEXT_s   = 'AutoCycle'.
      fieldcatalog-outputlen   = 15.
      fieldcatalog-col_pos     = COL_POS.
      fieldcatalog-do_sum      = 'X'.
      APPEND fieldcatalog TO gd_fieldcat.
      CLEAR  fieldcatalog.
      COL_POS = COL_POS + 1.
      fieldcatalog-fieldname   = 'ONLINE_TIME'.
      fieldcatalog-SCRTEXT_L   = 'Online Time'.
      fieldcatalog-SCRTEXT_m   = 'Online Time'.
      fieldcatalog-SCRTEXT_s   = 'Online Time'.
      fieldcatalog-outputlen   = 15.
      fieldcatalog-col_pos     = COL_POS.
      fieldcatalog-do_sum      = 'X'.
      APPEND fieldcatalog TO gd_fieldcat.
      CLEAR  fieldcatalog.
      COL_POS = COL_POS + 1.
      fieldcatalog-fieldname   = 'OFFLINE_TIME'.
      fieldcatalog-SCRTEXT_L   = 'Offline Time'.
      fieldcatalog-SCRTEXT_m   = 'Offline Time'.
      fieldcatalog-SCRTEXT_s   = 'Offline Time'.
      fieldcatalog-outputlen   = 15.
      fieldcatalog-col_pos     = COL_POS.
      fieldcatalog-do_sum      = 'X'.
      APPEND fieldcatalog TO gd_fieldcat.
      CLEAR  fieldcatalog.
      COL_POS = COL_POS + 1.
      fieldcatalog-fieldname   = 'ONLINE_P_TIME'.
      fieldcatalog-SCRTEXT_L   = 'Online Process Time'.
      fieldcatalog-SCRTEXT_m   = 'Online Process Time'.
      fieldcatalog-SCRTEXT_s   = 'Online Process Time'.
      fieldcatalog-outputlen   = 15.
      fieldcatalog-col_pos     = COL_POS.
      fieldcatalog-do_sum      = 'X'.
      APPEND fieldcatalog TO gd_fieldcat.
      CLEAR  fieldcatalog.
      COL_POS = COL_POS + 1.
      fieldcatalog-fieldname   = 'OFFLINE_P_TIME'.
      fieldcatalog-SCRTEXT_L   = 'Offline Process Time'.
      fieldcatalog-SCRTEXT_m   = 'Offline Process Time'.
      fieldcatalog-SCRTEXT_s   = 'Offline Process Time'.
      fieldcatalog-outputlen   = 15.
      fieldcatalog-col_pos     = COL_POS.
      fieldcatalog-do_sum      = 'X'.
      APPEND fieldcatalog TO gd_fieldcat.
      CLEAR  fieldcatalog.
    ENDFORM.                    " build_fieldcatalog
    *&      Form  build_layout
          text
    -->  p1        text
    <--  p2        text
    FORM build_layout .
      gd_layout-no_input          = 'X'.
      gd_layout-colwidth_optimize = 'X'.
      gd_layout-totals_text       = 'Totals'(201).
      gd_layout-totals_only        = 'X'.
    gd_layout-f2code            = 'DISP'.  "Sets fcode for when double
                                            "click(press f2)
      gd_layout-zebra             = 'X'.
    gd_layout-group_change_edit = 'X'.
    gd_layout-header_text       = 'helllllo'.
    ENDFORM.                    " build_layout
    *&      Form  build_hierarchy_header
          text
         <--P_GD_HIERARCHY_HEADER  text
    FORM build_hierarchy_header CHANGING
                                        p_hierarchy_header TYPE treev_hhdr.
      p_hierarchy_header-heading = 'Drill Down For Detail'(022).
      p_hierarchy_header-tooltip = 'This is the Hierarchy Header !'(014).
      p_hierarchy_header-width = 30.
      p_hierarchy_header-width_pix = ''.
    ENDFORM.                    " build_hierarchy_header
    *&      Form  build_report_title
          text
         -->P_GD_REPORT_TITLE  text
         -->P_GD_LOGO  text
    FORM build_report_title  using
                     pt_report_title  TYPE slis_t_listheader
                     pa_logo TYPE sdydo_value.
      DATA: ls_line TYPE slis_listheader,
            ld_date(10) TYPE c,
            string1 type string,string2 type string.
    List Heading Line(TYPE H)
    concatenate 'Material: ' p_matnr-low into string1 separated by space.
      CLEAR ls_line.
      ls_line-typ  = 'H'.
      ls_line-key  = 'MOST Operation'.
      concatenate p_gid-low p_opn-low into string2 separated by space.
      ls_line-info = string2.
      APPEND ls_line TO pt_report_title.
      ls_line-typ  = 'S'.
      ls_line-key  = 'Text'.
      select single DESCRIPTION from zroutpromast into string1 where mop_gid = p_gid-low
                                                               and mop_opn = p_opn-low
                                                               and werks = p_werks-low.
      ls_line-info = string1.
      APPEND ls_line TO pt_report_title.
    ls_line-typ  = 'S'.
    ls_line-key  = 'Routing Counter:'.
    ls_line-info = counter.
    APPEND ls_line TO pt_report_title.
    Status Line(TYPE S)
      ld_date(2) = sy-datum+6(2).
      ld_date+2(1) = '/'.
      ld_date3(2) = sy-datum4(2).
      ld_date+5(1) = '/'.
      ld_date+6(4) = sy-datum(4).
      ls_line-typ  = 'S'.
      ls_line-key  = 'Date'.
      ls_line-info = ld_date.
      APPEND ls_line TO pt_report_title.
    Action Line(TYPE A)
    CLEAR ls_line.
    ls_line-typ  = 'A'.
    CONCATENATE 'Report: ' sy-repid INTO ls_line-info  SEPARATED BY space.
    APPEND ls_line TO pt_report_title.
    ENDFORM.                    " build_report_title
    *&      Form  build_variant
          text
    -->  p1        text
    <--  p2        text
    FORM build_variant .
      gd_variant-report = sy-repid.
    ENDFORM.                    " build_variant
    *&      Module  STATUS_0100  OUTPUT
          text
    MODULE STATUS_0100 OUTPUT.
      SET PF-STATUS 'STATUS1'.
      SET TITLEBAR 'ZTITLE'.
      IF gd_tree IS INITIAL.
    Create ALVtree (must be performed within screen PBO module)
        PERFORM create_alvtree_container.
        PERFORM create_object_in_container.
        PERFORM create_empty_alvtree_control.
        perform change_toolbar.
        PERFORM create_alvtree_hierarchy.
      ENDIF.
      CALL METHOD cl_gui_cfw=>flush.
    ENDMODULE.                 " STATUS_0100  OUTPUT
    *&      Module  USER_COMMAND_0100  INPUT
          text
    MODULE USER_COMMAND_0100 INPUT.
      case sy-ucomm.
        when 'EXIT' or 'BACK' or 'CANC'.
          call method gd_tree->free.
          leave program.
        when others.
          call method cl_gui_cfw=>dispatch.
      endcase.
      clear ok_code.
      call method cl_gui_cfw=>flush.
    ENDMODULE.                 " USER_COMMAND_0100  INPUT
    *&      Form  create_alvtree_container
          text
    -->  p1        text
    <--  p2        text
    FORM create_alvtree_container .
      gd_tree_container_name = 'SCREEN_CONTAINER'.
      create object gd_custom_container
          exporting
                container_name = gd_tree_container_name
          exceptions
                cntl_error                  = 1
                cntl_system_error           = 2
                create_error                = 3
                lifetime_error              = 4
                lifetime_dynpro_dynpro_link = 5.
      if sy-subrc <> 0.
        message x208(00) with 'ERROR'.
      endif.
    ENDFORM.                    " create_alvtree_container
    *&      Form  create_object_in_container
          text
    -->  p1        text
    <--  p2        text
    FORM create_object_in_container .
      create object gd_tree
          exporting
              parent              = gd_custom_container
              node_selection_mode = cl_gui_column_tree=>node_sel_mode_single
              item_selection      = 'X'
              no_html_header      = ''
              no_toolbar          = ''
          exceptions
              cntl_error                   = 1
              cntl_system_error            = 2
              create_error                 = 3
              lifetime_error               = 4
              illegal_node_selection_mode  = 5
              failed                       = 6
              illegal_column_name          = 7.
      if sy-subrc <> 0.
        message x208(00) with 'ERROR'.
      endif.
    ENDFORM.                    " create_object_in_container
    *&      Form  create_empty_alvtree_control
          text
    -->  p1        text
    <--  p2        text
    FORM create_empty_alvtree_control .
      CLEAR: it_emptytab.
      REFRESH: it_emptytab.
      CALL METHOD gd_tree->set_table_for_first_display
         EXPORTING
                   is_hierarchy_header  = gd_hierarchy_header
                   it_list_commentary   = gd_report_title
                  i_logo               = gd_logo
                  i_background_id      = 'ALV_BACKGROUND'
                   i_save               = 'A'
                   is_variant            = gd_variant
         CHANGING
                   it_outtab            =  it_emptytab      "Must be empty
                   it_fieldcatalog      =  gd_fieldcat.
    ENDFORM.                    " create_empty_alvtree_control
    *&      Form  create_alvtree_hierarchy
          text
    -->  p1        text
    <--  p2        text
    FORM create_alvtree_hierarchy .
      data: ls_sflight type sflight,
              lt_sflight type sflight occurs 0.
      data: ld_mop_gid_key type lvc_nkey,
            ld_mop_opn_key type lvc_nkey.
      loop at it_output.
        perform add_ekko_node using      it_output
                                changing ld_mop_gid_key.
        loop at it_output1 where subgid eq it_output-subgid
                                 and subopn eq it_output-subopn.
          perform add_ekpo_line using      it_output1
                                           ld_mop_gid_key
                                  changing ld_mop_opn_key.
        endloop.
      endloop.
    calculate totals
      call method gd_tree->update_calculations.
    this method must be called to send the data to the frontend
      call method gd_tree->frontend_update.
    ENDFORM.                    " create_alvtree_hierarchy
    *&      Form  add_ekko_node
          text
         -->P_IT_OUTPUT  text
         -->P_2478   text
         <--P_LD_MOP_GID_KEY  text
    FORM add_ekko_node  USING  ps_output like it_output
                               VALUE(p_relate_key)
                        CHANGING p_node_key.
      data: ld_node_text type lvc_value,
             ls_sflight type sflight.
      data : text128(128).
    Set item-layout
      concatenate ps_output-subgid ps_output-subopn into text128 separated by space.
      data: lt_item_layout type lvc_t_layi,
            ls_item_layout type lvc_s_layi.
      ls_item_layout-t_image   = '@3P@'.
      ls_item_layout-fieldname = gd_tree->c_hierarchy_column_name.
      ls_item_layout-style     = cl_gui_column_tree=>style_default.
      ld_node_text             = text128.
      append ls_item_layout to lt_item_layout.
    Add node
      call method gd_tree->add_node
        exporting
              i_relat_node_key = p_relate_key
              i_relationship   = cl_gui_column_tree=>relat_last_child
              i_node_text      = ld_node_text
              is_outtab_line   = ps_output
              it_item_layout   = lt_item_layout
           importing
              e_new_node_key = p_node_key.
    ENDFORM.                    " add_ekko_node
    *&      Form  add_ekpo_line
          text
         -->P_IT_OUTPUT1  text
         -->P_LD_MOP_GID_KEY  text
         <--P_LD_MOP_OPN_KEY  text
    FORM add_ekpo_line  USING    Ps_OUTPUT1 like it_output1
                                 value(p_relate_key)
                        CHANGING p_node_key.
    data: ld_node_text type lvc_value,
          ls_sflight type sflight.
    data : text128(128).
    concatenate ps_output1-srno ps_output1-movetype into text128 separated by space.
    Set item-layout
      data: lt_item_layout type lvc_t_layi,
            ls_item_layout type lvc_s_layi.
      ls_item_layout-t_image   = '@3P@'.
      ls_item_layout-fieldname = gd_tree->c_hierarchy_column_name.
      ls_item_layout-style     = cl_gui_column_tree=>style_default.
      ld_node_text             = text128.
      append ls_item_layout to lt_item_layout.
    Add node
      call method gd_tree->add_node
        exporting
              i_relat_node_key = p_relate_key
              i_relationship   = cl_gui_column_tree=>relat_last_child
              i_node_text      = ld_node_text
              is_outtab_line   = ps_output1
              it_item_layout   = lt_item_layout
           importing
              e_new_node_key = p_node_key.
    ENDFORM.                    " add_ekpo_line
    *&      Form  change_toolbar
          text
    -->  p1        text
    <--  p2        text
    FORM change_toolbar .
    get toolbar control
      call method gd_tree->get_toolbar_object
              importing
                  er_toolbar = mr_toolbar.
      check not mr_toolbar is initial.
    add seperator to toolbar
      call method mr_toolbar->add_button
              exporting
                  fcode     = ''
                  icon      = ''
                  butn_type = cntb_btype_sep
                  text      = ''
                  quickinfo = 'This is a Seperator'.         "#EC NOTEXT
    add Standard Button to toolbar (for Delete Subtree)
      call method mr_toolbar->add_button
              exporting
                  fcode     = 'EXPORT'           "Function code of button
                  icon      = '@49@'             "Icon ID (see )
                  butn_type = cntb_btype_button  "Button type
                  text      = ''                 "Button text
                  quickinfo = 'Download To Excel'.  "Quick info text
    add Dropdown Button to toolbar (for Insert Line)
    call method mr_toolbar->add_button
             exporting
                 fcode     = 'INSERT_LC'         "Function code of button
                 icon      = '@17@'              "Icon ID (see )
                 butn_type = cntb_btype_dropdown "Button type
                 text      = ''                  "Button text
                 quickinfo = 'Insert Line'.      "Quick info text
    set event-handler for toolbar-control
      data: toolbar_event_receiver type ref to lcl_toolbar_event_receiver.
      create object toolbar_event_receiver.
      set handler toolbar_event_receiver->on_function_selected
                                                          for mr_toolbar.
      set handler toolbar_event_receiver->on_toolbar_dropdown
                                                          for mr_toolbar.
    ENDFORM.                    " change_toolbar
    Edited by: Darshan Shah on Jan 2, 2008 1:31 PM

    Gui patch was not available on my pc

  • Here's how to do ALV (OO) with dynamic fcat, int table and editable data

    Hi everybody
    Here's a more useful approach to ALV grid with OO using dynamic table, data NOT from DDIC, dynamic FCAT and how to get changed lines from the grid when ENTER key is pressed.
    It's really not too dificult but I think this is more useful than the ever present SFLIGHT methods from the demos.
    This also defines a subclass of cl_gui_alv_grid so you can access the protected attributes / methods of that class.
    You don't need to add the class via SE24 -- done fron this ABAP.
    When you run it click Edit for the first time.
    After editing data press ENTER and the break point should bring you into the relevant method.
    Code developed on NW2004S trial version but also works on rel 6.40 on a "Real" system.
    The code should work without any changes on any system >=6.40.
    All you need to do is to create a blank screen 100 via SE51  with a custom container on it called CCONTAINER1.
    The rest of the code can just be uploaded into your system using the SE38 upload facility.
    When running the program click on the EDIT button to enable the edit functionality of the grid.
    Change your data and when you press ENTER you should get the break-point where you can see the original table and changed rows.
    This program is actually quite general as it covers Dynamic tables, building a dynamic fcat where your table fields are NOT in the DDIC, intercepting the ENTER key via using an event, and accessing the protected attributes of the cl_gui_alv_grid by defining a subclass of this class in the abap.
    I've seen various questions relating to all these functions but none in my view ever answers the questions in a simple manner. I hope this simple program will answer all these and show how using OO ALV is actually quite easy and people shouldn't be scared of using OO.
    Have fun and award points if useful.
    Cheers
    Jimbo.
    <b>PROGRAM zdynfieldcat.
    Simple test of dynamic ITAB with user defined (not ddic) fields
    Build dynamic fcat
    use ALV grid to display and edit.
    *When edit mode set to 1 toolbar gives possibility of adding and
    *deleting rows.
    *Define subclass of cl_gui_alv_grid so we can use protected attributes
    *and methods.
    Add event handler to intercept user entering data and pressing the
    *ENTER key.
    When enter key is pressed get actual value of NEW table (all rows)
    rather than just the changed data.
    *use new RTTI functionality to retrieve internal table structure
    *details.
    Create a blank screen 100  with a custom container called CCONTAINER1.
    James Hawthorne
    include <icon>.
    define  any old internal structure  NOT in DDIC
    types: begin of s_elements,
           anyfield1(20) type c,
           anyfield2(20) type c,
           anyfield3(20) type c,
           anyfield4(20) type c,
           anyfield5(11) type n,
           end of s_elements.
    types:  lt_rows  type lvc_t_roid.
    Note new RTTI functionality allows field detail retrieval
    at runtime for dynamic tables.
    data:   wa_element type s_elements ,
            wa_data type s_elements,
            c_index type sy-index,
            c_dec2 type s_elements-anyfield5,
            wa_it_fldcat type lvc_s_fcat,
            it_fldcat type lvc_t_fcat,
            lr_rtti_struc TYPE REF TO cl_abap_structdescr,    "RTTI
            lt_comp TYPE cl_abap_structdescr=>component_table,"RTTI
            ls_comp LIKE LINE OF lt_comp,                     "RTTI
            zog  like line of lr_rtti_struc->components,      "RTTI
            struct_grid_lset type lvc_s_layo,
            l_valid  type c,
            new_table type ref to data.
    field-symbols: <dyn_table> type standard table,
                   <actual_tab> type standard table,
                   <fs1> type ANY,
                   <FS2> TYPE TABLE.
    data: grid_container1 type ref to cl_gui_custom_container.
    class lcl_grid_event_receiver definition deferred.
    data: g_event_receiver type ref to lcl_grid_event_receiver.
    data: ls_modcell type LVC_S_MODI,
          stab type ref to data,
          sdog type  s_elements.      .
    class lcl_grid_event_receiver definition.
      public section.
        methods:
        handle_data_changed
             for event data_changed of cl_gui_alv_grid
                 importing er_data_changed,
           toolbar for event toolbar of cl_gui_alv_grid
                     importing e_object
                               e_interactive,
          user_command for event user_command of cl_gui_alv_grid
                     importing e_ucomm.
    endclass.
    *implementation of Grid event-handler class
    class lcl_grid_event_receiver implementation.
    method handle_data_changed.
    code whatever required after data entry.
    various possibilites here as you can get back Cell(s) changed
    columns or the entire updated table.
    Data validation is also possible here.
    perform check_data using er_data_changed.
    endmethod.
    Method for handling all creation/modification calls to the toolbar
      method toolbar.
        data : ls_toolbar type stb_button.
    Define Custom Button in the toolbar
        clear ls_toolbar.
        move 0 to ls_toolbar-butn_type.
        move 'EDIT' to ls_toolbar-function.
        move space to ls_toolbar-disabled.
        move 'Edit' to ls_toolbar-text.
        move icon_change_text to ls_toolbar-icon.
        move 'Click2Edit' to ls_toolbar-quickinfo.
        append ls_toolbar to e_object->mt_toolbar.
        clear ls_toolbar.
        move 0 to ls_toolbar-butn_type.
        move 'UPDA' to ls_toolbar-function.
        move space to ls_toolbar-disabled.
        move 'Update' to ls_toolbar-text.
        move icon_system_save to ls_toolbar-icon.
        move 'Click2Update' to ls_toolbar-quickinfo.
        append ls_toolbar to e_object->mt_toolbar.
        clear ls_toolbar.
        move 0 to ls_toolbar-butn_type.
        move 'EXIT' to ls_toolbar-function.
        move space to ls_toolbar-disabled.
        move 'Exit' to ls_toolbar-text.
        move icon_system_end to ls_toolbar-icon.
        move 'Click2Exit' to ls_toolbar-quickinfo.
        append ls_toolbar to e_object->mt_toolbar.
      endmethod.
      method user_command.
        case e_ucomm .
          when 'EDIT'.          "From Tool bar
            perform set_input.
             perform init_grid.
          when 'UPDA'.          "From Tool bar
            perform refresh_disp.
            perform update_table.
          when 'EXIT'.          "From Tool bar
            leave program.
        endcase.
      endmethod.
    endclass.
    class zcltest definition inheriting from  cl_gui_alv_grid.
    define this as a subclass so we can access the protected attributes
    of the superclass cl_gui_alv_grid
    public section.
    methods: constructor, disp_tab.
    endclass.
    need this now to instantiate object
    as we are using subclass rather than the main cl_gui_alv_grid.
    class zcltest implementation.
    METHOD constructor.
    CALL METHOD super->constructor
            exporting i_appl_events = 'X'
               i_parent = grid_container1.
    endmethod.
    method disp_tab.
    FIELD-SYMBOLS: <outtab> TYPE STANDARD TABLE.
    break-point 1.
    mt_outtab is the data table held as a protected attribute
    in class cl_gui_alv_grid.
    ASSIGN me->mt_outtab->* TO <outtab>.  "Original data
    do whatever you want with <outtab>
    contains data BEFORE changes each time.
    Note that NEW (Changed) table has been obtained already by
    call to form check_data USING P_ER_DATA_CHANGED
             TYPE REF TO CL_ALV_CHANGED_DATA_PROTOCOL.
    Entered data is in table defined by <fs2>
    In this method you can compare original and changed data.
    Easier than messing around with individual cells.
    do what you want with data in <fs2>  validate / update / merge etc
    endmethod.
    endclass.
    data :
        ok_code like sy-ucomm,
        save_ok like sy-ucomm,
        i4 type int4,
    Container Object [grid_container]
    now created via method constructor
    in the subclass zcltest.
    Control Object [grid]
    grid1 type ref to zcltest,
    Event-Handler Object [grid_handler]
    grid_handler type ref to lcl_grid_event_receiver.
    start-of-selection.
    call screen 100.
    module status_0100 output.
    now display it as grid
    if grid_container1 is initial.
        create object grid_container1
            exporting
              container_name = 'CCONTAINER1'.
        create object grid1.
         break-point 1.
        create object grid_handler.
        set handler:
           grid_handler->user_command for grid1,
           grid_handler->toolbar for grid1,
           grid_handler->handle_data_changed for grid1.
    perform create_dynamic_fcat.
    perform create_dynamic_itab.
    perform populate_dynamic_itab.
    perform init_grid.
    perform register_enter_event.
    set off ready for input initially
    i4 = 0.
      call method grid1->set_ready_for_input
             exporting
               i_ready_for_input = i4.
    endif.
    endmodule.
    module user_command_0100 input.
    *PAI not needed in OO ALV anymore as User Commands are handled as events
    *in method user_command.
    *we can also get control if the Data entered and the ENTER is pressed by
    *raising an event.
    Control then returns to method handle_data_changed.
    endmodule.
    form create_dynamic_fcat.
    get structure of our user table for building field catalog
    Use the RTTI functionality
    lr_rtti_struc ?= cl_abap_structdescr=>describe_by_data( wa_data ).
    Build field catalog just use basic data here
    colour specific columns as well
    loop at lr_rtti_struc->components into zog.
    c_index = c_index + 1.
    clear wa_it_fldcat.
      wa_it_fldcat-fieldname = zog-name .
      wa_it_fldcat-datatype =  zog-type_kind.
      wa_it_fldcat-inttype =   zog-type_kind.
      wa_it_fldcat-intlen =    zog-length.
      wa_it_fldcat-decimals =  zog-decimals.
      wa_it_fldcat-lowercase = 'X'.
      if c_index eq 2.
      wa_it_fldcat-emphasize = 'C411'.
         endif.
        if c_index eq 3.
      wa_it_fldcat-emphasize = 'C511'.
       endif.
      append wa_it_fldcat to it_fldcat .
    endloop.
    endform.
    form create_dynamic_itab.
    Create dynamic internal table and assign to field sysmbol.
    Use dynamic field catalog just built.
    call method cl_alv_table_create=>create_dynamic_table
                 exporting
                    it_fieldcatalog = it_fldcat
                 importing
                    ep_table        = new_table.
    assign new_table->* to <dyn_table>.
    endform.
    form populate_dynamic_itab.
    load up a line of the dynamic table
    c_dec2 = c_dec2 + 11.
    wa_element-anyfield1 = 'Tabbies'.
    wa_element-anyfield2 = 'ger.shepards'.
    wa_element-anyfield3  = 'White mice'.
    wa_element-anyfield4 =  'Any old text'.
    wa_element-anyfield5 =  c_dec2.
    append  wa_element to <dyn_table>.
    endform.
    form check_data USING P_ER_DATA_CHANGED
               TYPE REF TO CL_ALV_CHANGED_DATA_PROTOCOL.
    Get altered data back
      ASSIGN   p_er_data_changed->mp_mod_rows TO <FS1>.
    stab =       p_er_data_changed->mp_mod_rows.
    ASSIGN STAB->* TO <FS2>.
    LOOP AT <FS2> INTO sdog.
    ALV grid display with altered data is now in <fs2>.
    do any extra processing you want here
    endloop.
    now display new table
    call method grid1->disp_tab.
    endform.
    form exit_program.
      call method grid_container1->free.
      call method cl_gui_cfw=>flush.
      leave program.
    endform.
    form refresh_disp.
      call method grid1->refresh_table_display.
    endform.
    form update_table.
    The dynamic table here is the changed table read from the grid
    after user has changed it
    Data can be saved to DB or whatever.
    loop at <dyn_table> into wa_element.
    do what you want with the data here
    endloop.
    switch off edit mode again for next function
    i4 = 0.
      call method grid1->set_ready_for_input
          exporting
              i_ready_for_input = i4.
    endform.
    form set_input.
    i4 = 1.
      call method grid1->set_ready_for_input
         exporting
           i_ready_for_input = i4.
    endform.
    form switch_input.
    if i4 = 1.
    i4 = 0.
    else.
    i4 = 1.
    endif.
      call method grid1->set_ready_for_input
         exporting
           i_ready_for_input = i4.
    endform.
    form init_grid.
    Enabling the grid to edit mode,
         struct_grid_lset-edit = 'X'. "To enable editing in ALV
         struct_grid_lset-grid_title  = 'Jimbos Test'.
         call method grid1->set_table_for_first_display
           exporting
             is_layout           = struct_grid_lset
           changing
             it_outtab             =  <dyn_table>
             it_fieldcatalog       =  it_fldcat.
    endform.
    form register_enter_event.
    call method grid1->register_edit_event
                   exporting
                      i_event_id = cl_gui_alv_grid=>mc_evt_enter.
    Instantiate the event or it won't work.
    create object g_event_receiver.
    set handler g_event_receiver->handle_data_changed for grid1.
    endform.</b>

    Hi there
    IE7 doesn't give me the add new page option and I get 404 error when trying to access the "How to contribute" section.
    I'll load up Firefox later (this browser usually works when IE7 doesn't always work properly).
    I'll copy the stuff to the wiki when I've got the browser sorted out.
    Cheers
    jimbp

  • Regarding making hyperlink in OOPs ALV

    Please see the following ALV Code. Its based on OOPs. There is no fieldcatalog defined in the program. In the output I want to make a hotspot on the filed VBELN & want to call T.code VA03 using SET PARAMETER ID. Please help. If I would have made it through Function Modules, It could have been easier as I can modify the fieldcatalog. Please help me urgently. Points will be rewarded.
    *& Report  ZTEST_OOPS_REPT1                                            *
    REPORT  ztest_oops_rept1                        .
    Type pool for icons - used in the toolbar
    TYPE-POOLS: icon.
    TYPE-POOLS: slis.
    TABLES: vbak.
    To allow the declaration of o_event_receiver before the
    lcl_event_receiver class is defined, decale it as deferred in the
    start of the program
    CLASS lcl_event_receiver DEFINITION DEFERRED.
    G L O B A L   I N T E R N  A L   T A B L E S
    *DATA: gi_sflight TYPE STANDARD TABLE OF sflight.
    To include a traffic light and/or color a line the structure of the
    table must include fields for the traffic light and/or the color
    TYPES: BEGIN OF st_vbak.
            INCLUDE STRUCTURE vbak.
    TYPES: END OF st_vbak.
    TYPES: tt_vbak TYPE STANDARD TABLE OF st_vbak.
    DATA: gi_vbak TYPE tt_vbak.
    *declaration for fieldcatalog
    DATA: lit_fieldcat TYPE slis_t_fieldcat_alv,
        ls_fieldcat  TYPE slis_fieldcat_alv.
    G L O B A L   D A T A
    DATA: ok_code         LIKE sy-ucomm,
        Work area for internal table
          g_wa_vbak    TYPE st_vbak,
        ALV control: Layout structure
          gs_layout       TYPE lvc_s_layo.
    Declare reference variables to the ALV grid and the container
    DATA:
      go_grid             TYPE REF TO cl_gui_alv_grid,
      go_custom_container TYPE REF TO cl_gui_custom_container,
      o_event_receiver    TYPE REF TO lcl_event_receiver.
    DATA:
    Work area for screen 200
      g_screen200 LIKE vbak.
    Data for storing information about selected rows in the grid
    DATA:
    Internal table
      gi_index_rows TYPE lvc_t_row,
    Information about 1 row
      g_selected_row LIKE lvc_s_row.
                            SELECTION-SCREEN                             *
    SELECTION-SCREEN BEGIN OF BLOCK ch1 WITH FRAME.
    SELECT-OPTIONS:  s_vbeln FOR vbak-vbeln OBLIGATORY.
    SELECTION-SCREEN END OF BLOCK ch1.
    C L A S S E S
    CLASS lcl_event_receiver DEFINITION.
      PUBLIC SECTION.
        METHODS:
         handle_toolbar FOR EVENT toolbar OF cl_gui_alv_grid
           IMPORTING
             e_object e_interactive,
         handle_user_command FOR EVENT user_command OF cl_gui_alv_grid
           IMPORTING e_ucomm.
    ENDCLASS.                    "lcl_event_receiver DEFINITION
          CLASS lcl_event_receiver IMPLEMENTATION
    CLASS lcl_event_receiver IMPLEMENTATION.
      METHOD handle_toolbar.
    Event handler method for event toolbar.
        CONSTANTS:
    Constants for button type
          c_button_normal           TYPE i VALUE 0,
          c_menu_and_default_button TYPE i VALUE 1,
          c_menu                    TYPE i VALUE 2,
          c_separator               TYPE i VALUE 3,
          c_radio_button            TYPE i VALUE 4,
          c_checkbox                TYPE i VALUE 5,
          c_menu_entry              TYPE i VALUE 6.
        DATA:
            ls_toolbar  TYPE stb_button.
      Append seperator to the normal toolbar
        CLEAR ls_toolbar.
        MOVE c_separator TO ls_toolbar-butn_type..
        APPEND ls_toolbar TO e_object->mt_toolbar.
      Append a new button that to the toolbar. Use E_OBJECT of
      event toolbar. E_OBJECT is of type CL_ALV_EVENT_TOOLBAR_SET.
      This class has one attribute MT_TOOLBAR which is of table type
      TTB_BUTTON. The structure is STB_BUTTON
        CLEAR ls_toolbar.
        MOVE 'CHANGE'        TO ls_toolbar-function.
        MOVE  icon_change    TO ls_toolbar-icon.
        MOVE 'Change flight' TO ls_toolbar-quickinfo.
        MOVE 'Change'        TO ls_toolbar-text.
        MOVE ' '             TO ls_toolbar-disabled.
        APPEND ls_toolbar    TO e_object->mt_toolbar.
      ENDMETHOD.                    "handle_toolbar
      METHOD handle_user_command.
      Handle own functions defined in the toolbar
        CASE e_ucomm.
          WHEN 'CHANGE'.
            PERFORM change_flight.
           LEAVE TO SCREEN 0.
        ENDCASE.
      ENDMETHOD.                    "handle_user_command
    ENDCLASS.                    "lcl_event_receiver IMPLEMENTATION
    S T A R T - O F - S E L E C T I O N.
    START-OF-SELECTION.
      SET SCREEN '100'.
    *&      Module  USER_COMMAND_0100  INPUT
    MODULE user_command_0100 INPUT.
      CASE ok_code.
        WHEN 'BACK'.
          LEAVE TO SCREEN 0.
      ENDCASE.
    ENDMODULE.                 " USER_COMMAND_0100  INPUT
    *&      Module  STATUS_0100  OUTPUT
    MODULE status_0100 OUTPUT.
      SET PF-STATUS 'ZTEST_ALV'.
      SET TITLEBAR 'ZTEST_ALV'.
      DATA:
      For parameter IS_VARIANT that is sued to set up options for storing
      the grid layout as a variant in method set_table_for_first_display
        l_layout TYPE disvariant,
      Utillity field
        l_lines TYPE i.
    After returning from screen 200 the line that was selected before
    going to screen 200, should be selected again. The table gi_index_rows
    was the output table from the GET_SELECTED_ROWS method in form
    CHANGE_FLIGHT
      DESCRIBE TABLE gi_index_rows LINES l_lines.
      IF l_lines > 0.
        CALL METHOD go_grid->set_selected_rows
          EXPORTING
            it_index_rows = gi_index_rows.
        CALL METHOD cl_gui_cfw=>flush.
        REFRESH gi_index_rows.
      ENDIF.
    Read data and create objects
      IF go_custom_container IS INITIAL.
      Read data from datbase table
        PERFORM get_data.
      Create objects for container and ALV grid
        CREATE OBJECT go_custom_container
          EXPORTING container_name = 'ALV_CONTAINER'.
        CREATE OBJECT go_grid
          EXPORTING
            i_parent = go_custom_container.
      Create object for event_receiver class
      and set handlers
        CREATE OBJECT o_event_receiver.
        SET HANDLER o_event_receiver->handle_user_command FOR go_grid.
        SET HANDLER o_event_receiver->handle_toolbar FOR go_grid.
      Layout (Variant) for ALV grid
        l_layout-report = sy-repid. "Layout fo report
    Setup the grid layout using a variable of structure lvc_s_layo
      Set grid title
        gs_layout-grid_title = 'SALES ORDER'.
      Selection mode - Single row without buttons
      (This is the default  mode
        gs_layout-sel_mode = 'B'.  "B for single selection.
      Grid setup for first display
        CALL METHOD go_grid->set_table_for_first_display
          EXPORTING
            i_structure_name = 'VBAK'
            is_variant       = l_layout
            i_save           = 'A'
            is_layout        = gs_layout
          CHANGING
            it_outtab        = gi_vbak.
    *-- End of grid setup -
      Raise event toolbar to show the modified toolbar
        CALL METHOD go_grid->set_toolbar_interactive.
      Set focus to the grid. This is not necessary in this
      example as there is only one control on the screen
        CALL METHOD cl_gui_control=>set_focus
          EXPORTING
            control = go_grid.
      ENDIF.
    ENDMODULE.                 " STATUS_0100  OUTPUT
    *&      Module  USER_COMMAND_0200  INPUT
          text
    MODULE user_command_0200 INPUT.
      CASE ok_code.
        WHEN 'BACK'.
          LEAVE TO SCREEN 100.
          WHEN'SAVE'.
          PERFORM save_changes.
      ENDCASE.
    ENDMODULE.                 " USER_COMMAND_0200  INPUT
    *&      Form  get_data
          text
    FORM get_data.
    Read data from table VBAK
      SELECT *
        FROM vbak
        INTO TABLE gi_vbak
        WHERE vbeln IN s_vbeln.
    ENDFORM.                    " load_data_into_grid
    *&      Form  change_flight
    Reads the contents of the selected row in the grid, ans transfers
    the data to screen 200, where it can be changed and saved.
    FORM change_flight.
      DATA:l_lines TYPE i.
      REFRESH gi_index_rows.
      CLEAR   g_selected_row.
    Read index of selected rows
      CALL METHOD go_grid->get_selected_rows
        IMPORTING
          et_index_rows = gi_index_rows.
    Check if any row are selected at all. If not
    table  gi_index_rows will be empty
      DESCRIBE TABLE gi_index_rows LINES l_lines.
      IF l_lines = 0.
        CALL FUNCTION 'POPUP_TO_DISPLAY_TEXT'
          EXPORTING
            textline1 = 'You must choose a line'.
        EXIT.
      ENDIF.
    Read indexes of selected rows. In this example only one
    row can be selected as we are using gs_layout-sel_mode = 'B',
    so it is only ncessary to read the first entry in
    table gi_index_rows
      LOOP AT gi_index_rows INTO g_selected_row.
        IF sy-tabix = 1.
          READ TABLE gi_vbak INDEX g_selected_row-index
           INTO g_wa_vbak.
        ENDIF.
      ENDLOOP.
    Transfer data from the selected row to screenm 200 and show
    screen 200
      CLEAR g_screen200.
      MOVE-CORRESPONDING g_wa_vbak TO g_screen200.
      LEAVE TO SCREEN '200'.
    ENDFORM.                    " change_flight
    *&      Form  save_changes
    Changes made in screen 200 are written to the datbase table
    zsflight, and to the grid table gi_sflight, and the grid is
    updated with method refresh_table_display to display the changes
    FORM save_changes.
    Update traffic light field
    Update database table
      MODIFY vbak FROM g_screen200.
    Refresh grid
      CALL METHOD go_grid->refresh_table_display.
      CALL METHOD cl_gui_cfw=>flush.
      LEAVE TO SCREEN '100'.
    ENDFORM.                    " save_changes
    *&      Module  STATUS_0200  OUTPUT
          text
    MODULE status_0200 OUTPUT.
      SET PF-STATUS 'ZTEST_ALV'.
      SET TITLEBAR 'ZTEST_ALV'.
    ENDMODULE.                 " STATUS_0200  OUTPUT
                     " lit_fieldcat_init

    Use FM -LVC_FIELDCATALOG_MERGE to derive the field catalog for table VBAK. It will give you the field catalog. You can modify the column VBELN  by changing HOTSPOT = 'X".
    and in your code - at the method SET_TABLE_FOR....DISPLAY , you comment out the structure name and pass the modified field catalog.
    Hope it helps.

  • Do not include some lines in Subtotals and totals in ALV

    Hello All,
    I am printing a report with all sale order details and Quantities( delveered ,conformed etc..) iam doing subtotals based on the material and Plant.
    In this if the document date is less than the SY-DATUM, we should not include the quantity into the subtotals and totals, Only the orders wiht doc date GQ to Sy-datum then display them..
    As of now I am using ALV grid display and doing the sums by 
    l_wa_fcat-do_sum = c_x. (field catalog) for the whole colom) but i want to avoid sum row from tehe calculation based on the condition.
    <b>Do we have any way to achive this, like if we want to have separate color for a purticular Cell then we add an extra field in outout table and we link this field with layout-coltab_fieldname in the same way or any other way if we have</b>.
    I will be  thankfull to if you can provide me your valuable suggesstions on this. it is very urgent. I am trying in all the ways from my side.

    Hi,
    see this code,
    Complete code for the ALV grid example
    This example shows and ALV grid with flights. After selecting a line a change button can be pushed to display a change screen. After the changes have been saved, the ALV grid screen is displayed again, and the grid is updated with the changes.
    The example shows:
    How to setup the ALV grid
    How to ste focus to the grid
    How to set the title of the grid
    How to allow a user to save and reuse a grid layout (Variant)
    How to customize the ALV grid toolbar
    Refresh the grid
    Set and get row selection and read line contents
    Make and exception field (Traffic light)
    Coloring a line
    Steps:
    Create screen 100 with the ALV grid. Remember to include an exit button
    Add a change button to the ALV grid toolbar
    Create screen 200 the Change screen
    The screens:
    The code:
       REPORT sapmz_hf_alv_grid .
    Type pool for icons - used in the toolbar
       TYPE-POOLS: icon.
       TABLES: zsflight.
    To allow the declaration of o_event_receiver before the
    lcl_event_receiver class is defined, decale it as deferred in the
    start of the program
       CLASS lcl_event_receiver DEFINITION DEFERRED.
    G L O B A L   I N T E R N  A L   T A B L E S
       *DATA: gi_sflight TYPE STANDARD TABLE OF sflight.
    To include a traffic light and/or color a line the structure of the
    table must include fields for the traffic light and/or the color
       TYPES: BEGIN OF st_sflight.
               INCLUDE STRUCTURE zsflight.
          Field for traffic light
       TYPES:  traffic_light TYPE c.
          Field for line color
       types:  line_color(4) type c.
       TYPES: END OF st_sflight.
       TYPES: tt_sflight TYPE STANDARD TABLE OF st_sflight.
       DATA: gi_sflight TYPE tt_sflight.
    G L O B A L   D A T A
       DATA: ok_code         LIKE sy-ucomm,
        Work area for internal table
             g_wa_sflight    TYPE st_sflight,
        ALV control: Layout structure
             gs_layout       TYPE lvc_s_layo.
    Declare reference variables to the ALV grid and the container
       DATA:
         go_grid             TYPE REF TO cl_gui_alv_grid,
         go_custom_container TYPE REF TO cl_gui_custom_container,
         o_event_receiver    TYPE REF TO lcl_event_receiver.
       DATA:
    Work area for screen 200
         g_screen200 LIKE zsflight.
    Data for storing information about selected rows in the grid
       DATA:
    Internal table
         gi_index_rows TYPE lvc_t_row,
    Information about 1 row
         g_selected_row LIKE lvc_s_row.
    C L A S S E S
       CLASS lcl_event_receiver DEFINITION.
         PUBLIC SECTION.
           METHODS:
            handle_toolbar FOR EVENT toolbar OF cl_gui_alv_grid
              IMPORTING
                e_object e_interactive,
            handle_user_command FOR EVENT user_command OF cl_gui_alv_grid
              IMPORTING e_ucomm.
       ENDCLASS.
          CLASS lcl_event_receiver IMPLEMENTATION
       CLASS lcl_event_receiver IMPLEMENTATION.
         METHOD handle_toolbar.
    Event handler method for event toolbar.
           CONSTANTS:
    Constants for button type
             c_button_normal           TYPE i VALUE 0,
             c_menu_and_default_button TYPE i VALUE 1,
             c_menu                    TYPE i VALUE 2,
             c_separator               TYPE i VALUE 3,
             c_radio_button            TYPE i VALUE 4,
             c_checkbox                TYPE i VALUE 5,
             c_menu_entry              TYPE i VALUE 6.
           DATA:
               ls_toolbar  TYPE stb_button.
      Append seperator to the normal toolbar
           CLEAR ls_toolbar.
           MOVE c_separator TO ls_toolbar-butn_type..
           APPEND ls_toolbar TO e_object->mt_toolbar.
      Append a new button that to the toolbar. Use E_OBJECT of
      event toolbar. E_OBJECT is of type CL_ALV_EVENT_TOOLBAR_SET.
      This class has one attribute MT_TOOLBAR which is of table type
      TTB_BUTTON. The structure is STB_BUTTON
           CLEAR ls_toolbar.
           MOVE 'CHANGE'        TO ls_toolbar-function.
           MOVE  icon_change    TO ls_toolbar-icon.
           MOVE 'Change flight' TO ls_toolbar-quickinfo.
           MOVE 'Change'        TO ls_toolbar-text.
           MOVE ' '             TO ls_toolbar-disabled.
           APPEND ls_toolbar    TO e_object->mt_toolbar.
         ENDMETHOD.
         METHOD handle_user_command.
      Handle own functions defined in the toolbar
           CASE e_ucomm.
             WHEN 'CHANGE'.
               PERFORM change_flight.
           LEAVE TO SCREEN 0.
           ENDCASE.
         ENDMETHOD.
       ENDCLASS.
    S T A R T - O F - S E L E C T I O N.
       START-OF-SELECTION.
         SET SCREEN '100'.
       *&      Module  USER_COMMAND_0100  INPUT
       MODULE user_command_0100 INPUT.
         CASE ok_code.
           WHEN 'EXIT'.
             LEAVE TO SCREEN 0.
         ENDCASE.
       ENDMODULE.                 " USER_COMMAND_0100  INPUT
       *&      Module  STATUS_0100  OUTPUT
       MODULE status_0100 OUTPUT.
         DATA:
      For parameter IS_VARIANT that is sued to set up options for storing
      the grid layout as a variant in method set_table_for_first_display
           l_layout TYPE disvariant,
      Utillity field
           l_lines TYPE i.
    After returning from screen 200 the line that was selected before
    going to screen 200, should be selected again. The table gi_index_rows
    was the output table from the GET_SELECTED_ROWS method in form
    CHANGE_FLIGHT
         DESCRIBE TABLE gi_index_rows LINES l_lines.
         IF l_lines > 0.
           CALL METHOD go_grid->set_selected_rows
               EXPORTING
                 it_index_rows = gi_index_rows.
           CALL METHOD cl_gui_cfw=>flush.
           REFRESH gi_index_rows.
         ENDIF.
    Read data and create objects
         IF go_custom_container IS INITIAL.
      Read data from datbase table
           PERFORM get_data.
      Create objects for container and ALV grid
           CREATE OBJECT go_custom_container
             EXPORTING container_name = 'ALV_CONTAINER'.
           CREATE OBJECT go_grid
             EXPORTING
               i_parent = go_custom_container.
      Create object for event_receiver class
      and set handlers
           CREATE OBJECT o_event_receiver.
           SET HANDLER o_event_receiver->handle_user_command FOR go_grid.
           SET HANDLER o_event_receiver->handle_toolbar FOR go_grid.
      Layout (Variant) for ALV grid
           l_layout-report = sy-repid. "Layout fo report
    Setup the grid layout using a variable of structure lvc_s_layo
      Set grid title
           gs_layout-grid_title = 'Flights'.
      Selection mode - Single row without buttons
      (This is the default  mode
           gs_layout-sel_mode = 'B'.
      Name of the exception field (Traffic light field) and the color
      field + set the exception and color field of the table
           gs_layout-excp_fname = 'TRAFFIC_LIGHT'.
           gs_layout-info_fname = 'LINE_COLOR'.
           LOOP AT gi_sflight INTO g_wa_sflight.
             IF g_wa_sflight-paymentsum < 100000.
          Value of traffic light field
               g_wa_sflight-traffic_light = '1'.
          Value of color field:
          C = Color, 6=Color 1=Intesified on, 0: Inverse display off
               g_wa_sflight-line_color    = 'C610'.
             ELSEIF g_wa_sflight-paymentsum => 100000 AND
                    g_wa_sflight-paymentsum < 1000000.
               g_wa_sflight-traffic_light = '2'.
             ELSE.
               g_wa_sflight-traffic_light = '3'.
             ENDIF.
             MODIFY gi_sflight FROM g_wa_sflight.
           ENDLOOP.
      Grid setup for first display
           CALL METHOD go_grid->set_table_for_first_display
             EXPORTING i_structure_name = 'SFLIGHT'
                       is_variant       = l_layout
                       i_save           = 'A'
                       is_layout        = gs_layout
             CHANGING  it_outtab        = gi_sflight.
       *-- End of grid setup -
      Raise event toolbar to show the modified toolbar
           CALL METHOD go_grid->set_toolbar_interactive.
      Set focus to the grid. This is not necessary in this
      example as there is only one control on the screen
           CALL METHOD cl_gui_control=>set_focus EXPORTING control = go_grid.
         ENDIF.
       ENDMODULE.                 " STATUS_0100  OUTPUT
       *&      Module  USER_COMMAND_0200  INPUT
       MODULE user_command_0200 INPUT.
         CASE ok_code.
           WHEN 'EXIT200'.
             LEAVE TO SCREEN 100.
             WHEN'SAVE'.
             PERFORM save_changes.
         ENDCASE.
       ENDMODULE.                 " USER_COMMAND_0200  INPUT
       *&      Form  get_data
       FORM get_data.
    Read data from table SFLIGHT
         SELECT *
           FROM zsflight
           INTO TABLE gi_sflight.
       ENDFORM.                    " load_data_into_grid
       *&      Form  change_flight
    Reads the contents of the selected row in the grid, ans transfers
    the data to screen 200, where it can be changed and saved.
       FORM change_flight.
         DATA:l_lines TYPE i.
         REFRESH gi_index_rows.
         CLEAR   g_selected_row.
    Read index of selected rows
         CALL METHOD go_grid->get_selected_rows
           IMPORTING
             et_index_rows = gi_index_rows.
    Check if any row are selected at all. If not
    table  gi_index_rows will be empty
         DESCRIBE TABLE gi_index_rows LINES l_lines.
         IF l_lines = 0.
           CALL FUNCTION 'POPUP_TO_DISPLAY_TEXT'
                EXPORTING
                     textline1 = 'You must choose a line'.
           EXIT.
         ENDIF.
    Read indexes of selected rows. In this example only one
    row can be selected as we are using gs_layout-sel_mode = 'B',
    so it is only ncessary to read the first entry in
    table gi_index_rows
         LOOP AT gi_index_rows INTO g_selected_row.
           IF sy-tabix = 1.
            READ TABLE gi_sflight INDEX g_selected_row-index INTO g_wa_sflight.
           ENDIF.
         ENDLOOP.
    Transfer data from the selected row to screenm 200 and show
    screen 200
         CLEAR g_screen200.
         MOVE-CORRESPONDING g_wa_sflight TO g_screen200.
         LEAVE TO SCREEN '200'.
       ENDFORM.                    " change_flight
       *&      Form  save_changes
    Changes made in screen 200 are written to the datbase table
    zsflight, and to the grid table gi_sflight, and the grid is
    updated with method refresh_table_display to display the changes
       FORM save_changes.
         DATA: l_traffic_light TYPE c.
    Update traffic light field
    Update database table
         MODIFY zsflight FROM g_screen200.
    Update grid table , traffic light field and color field.
    Note that it is necessary to use structure g_wa_sflight
    for the update, as the screen structure does not have a
    traffic light field
         MOVE-CORRESPONDING g_screen200 TO g_wa_sflight.
         IF g_wa_sflight-paymentsum < 100000.
           g_wa_sflight-traffic_light = '1'.
      C = Color, 6=Color 1=Intesified on, 0: Inverse display off
           g_wa_sflight-line_color    = 'C610'.
         ELSEIF g_wa_sflight-paymentsum => 100000 AND
                g_wa_sflight-paymentsum < 1000000.
           g_wa_sflight-traffic_light = '2'.
           clear g_wa_sflight-line_color.
         ELSE.
           g_wa_sflight-traffic_light = '3'.
           clear g_wa_sflight-line_color.
         ENDIF.
         MODIFY gi_sflight INDEX g_selected_row-index FROM g_wa_sflight.
    Refresh grid
         CALL METHOD go_grid->refresh_table_display.
         CALL METHOD cl_gui_cfw=>flush.
         LEAVE TO SCREEN '100'.
       ENDFORM.                    " save_changes

  • How to add button in ALV report (Class method )?

    Hello experts,
    I have developed one ALV report using classes.
    I want to add one more  button on the report like already is there named DISPLQUA
    How ca i do that here?
    Following the code of CLASS definition & implimentation
    CLASS lcl_handle_events DEFINITION.
      PUBLIC SECTION.
        METHODS:
          handle_on_user_command FOR EVENT added_function OF cl_salv_events
            IMPORTING e_salv_function.
    ENDCLASS.                    "lcl_handle_events DEFINITION
          CLASS lcl_handle_events IMPLEMENTATION
    CLASS lcl_handle_events IMPLEMENTATION.
      METHOD handle_on_user_command.
        CASE e_salv_function.
          WHEN 'DISPLQUA'.
            PERFORM show_quant_record.
         WHEN 'DISPQM03'.                                " Here i want to add button
           PERFORM display_quality_notification.
          WHEN OTHERS.
        ENDCASE.
      ENDMETHOD.                    "handle_on_user_command
    ENDCLASS.                    "lcl_handle_events IMPLEMENTATION

    HI Ronny.
    Code snippet for reference.
    CLASS LCL_EVENT_HANDLER DEFINITION .
      PUBLIC SECTION.
        METHODS :
    *--Toolbar control
          HANDLE_TOOLBAR FOR EVENT TOOLBAR
            OF CL_GUI_ALV_GRID IMPORTING E_OBJECT
                                         E_INTERACTIVE,
    ENDCLASS
    CLASS LCL_EVENT_HANDLER IMPLEMENTATION.
    *--handle toolbar
      METHOD HANDLE_TOOLBAR.
    * append a separator to normal toolbar
        CLEAR G_TOOLBAR.
        G_TOOLBAR-BUTN_TYPE = 3.
        APPEND G_TOOLBAR TO E_OBJECT->MT_TOOLBAR.
        CLEAR G_TOOLBAR.
        G_TOOLBAR-FUNCTION = 'SAVE'.
        G_TOOLBAR-ICON = ICON_SYSTEM_SAVE.
        G_TOOLBAR-BUTN_TYPE = 0.
        G_TOOLBAR-QUICKINFO = 'Save the Customer'(203).
        APPEND G_TOOLBAR TO E_OBJECT->MT_TOOLBAR.
      ENDMETHOD.                    "HANDLE_TOOLBAR
    Hope this helps.
    Gary.
    <REMOVED BY MODERATOR>
    Edited by: Alvaro Tejada Galindo on Apr 7, 2008 5:41 PM

  • Button in ALV Grid

    Hi ,
    I want to display a ALV Grid layout output and on that I want to insert a button on the application bar .When I click on it I should call a screen and dispaly that out on that screen .
    Prg :
    CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
       EXPORTING
         i_callback_program                = 'ZL_NAV'
         I_CALLBACK_PF_STATUS_SET          = 'ZL_PF_STATUS'
      I_CALLBACK_USER_COMMAND           = ' '
      I_CALLBACK_TOP_OF_PAGE            = ' '
          i_structure_name                  = 'ZLT_MARKET_VALUE'
          is_layout                         =  gs_layout
          i_save                            =  g_save
      IT_FIELDCAT                       =
      IT_EVENTS                         =
        TABLES
          t_outtab                          = i_market_value
    EXCEPTIONS
      PROGRAM_ERROR                     = 1
      OTHERS                            = 2
      IF sy-subrc <> 0.
      ENDIF.
    Iam settingthe pf status as 'ZL_PF_STATUS' and writing the sub routine for the same.
    form 'ZL_PF_STATUS'
    set pf-status = 'NAVDISP' .
    endform .
    But iam getting a dump that there are one actual parameter and zero formal parameters .
    Help in this regard
    Bye
    Santosh ..

    Hello!
    Take this code:
    Regards
    Ilhan
    TYPE-POOLS: col, icon.
    DATA:
      BEGIN OF wa_sflight.
    INCLUDE TYPE sflight.
    DATA: color(4),
        light,  "graphical indicator for booking status
        it_field_colors TYPE lvc_t_scol, "for cell highlighting
        changes_possible TYPE icon-id,
      END OF wa_sflight,
      it_sflight LIKE TABLE OF wa_sflight.
    DATA:
      ok_code LIKE sy-ucomm.
    DATA:
      alv TYPE REF TO cl_gui_alv_grid,
      cont TYPE REF TO cl_gui_custom_container.
    DATA: my_variant TYPE disvariant,
          my_print TYPE lvc_s_prnt.
    DATA:
      wa_layout TYPE lvc_s_layo,
      wa_field_color LIKE LINE OF wa_sflight-it_field_colors.
    DATA:
      it_field_cat TYPE lvc_t_fcat,
      wa_field_cat LIKE LINE OF it_field_cat.
    DATA:
      bookings_total TYPE i,
      bookings_total_c(10),
      message_text(60).
    DATA: row TYPE i.
    DATA: it_row_no TYPE lvc_t_roid,
          wa_row_no LIKE LINE OF it_row_no,
          it_lines type i.
    DATA: BEGIN OF wa_sel_flights,
            mandt TYPE sy-mandt,
            carrid TYPE sflight-carrid,
            connid TYPE sflight-connid,
            fldate TYPE sflight-fldate,
          END OF wa_sel_flights,
          it_sel_flights LIKE TABLE OF wa_sel_flights.
    SELECT-OPTIONS: so_car FOR wa_sflight-carrid,
                    so_con FOR wa_sflight-connid.
    SELECTION-SCREEN SKIP.
    PARAMETERS: pa_lv TYPE disvariant-variant.
    **********************  CLASS  **************************
    CLASS: lcl_handler DEFINITION.
      PUBLIC SECTION.
        CLASS-METHODS: on_doubleclick
                         FOR EVENT double_click OF cl_gui_alv_grid
                         IMPORTING es_row_no,
                       print_top
                         FOR EVENT print_top_of_page OF cl_gui_alv_grid,
                       print_tol
                         FOR EVENT print_top_of_list OF cl_gui_alv_grid,
                       on_toolbar
                         FOR EVENT toolbar OF cl_gui_alv_grid
                         IMPORTING e_object,
                       on_user_command
                         FOR EVENT user_command OF cl_gui_alv_grid
                         IMPORTING e_ucomm,
                         on_context_menu_request
             FOR EVENT context_menu_request OF cl_gui_alv_grid
             IMPORTING e_object.
    ENDCLASS.                    "lcl_handler DEFINITION
    CLASS: lcl_handler IMPLEMENTATION.
      METHOD on_doubleclick.
        READ TABLE it_sflight INTO wa_sflight INDEX es_row_no-row_id.
        IF sy-subrc NE 0.
          MESSAGE i075(bc408).
          EXIT.
        ENDIF.
        bookings_total = wa_sflight-seatsocc + wa_sflight-seatsocc_b +
                           wa_sflight-seatsocc_f.
        bookings_total_c = bookings_total.
        CONCATENATE 'Total number of bookings:'(m01)
                    bookings_total_c
          INTO message_text.
        MESSAGE message_text TYPE 'I'.
      ENDMETHOD.                    "on_doubleclick
      METHOD print_top.
        DATA: pos TYPE i.
        FORMAT COLOR COL_HEADING.
        WRITE: / sy-datum.
        pos = sy-linsz / 2 - 3. " length of pagno: 6 chars
        WRITE AT pos sy-pagno.
        pos = sy-linsz - 11. " length of username: 12 chars
        WRITE: AT pos sy-uname.
        ULINE.
      ENDMETHOD.                    "print_top
      METHOD print_tol.
        DATA: wa_so_car LIKE LINE OF so_car,
              wa_so_con LIKE LINE OF so_con.
        CONSTANTS: end TYPE i VALUE 20.
        FORMAT COLOR COL_HEADING.
        WRITE: / 'Select options'(000), AT end space.           "#EC *
        SKIP.
        WRITE: / 'Airlines'(001), AT end space.                 "#EC *
        ULINE AT /(end).
        FORMAT COLOR COL_NORMAL.
        LOOP AT so_car INTO wa_so_car.
          WRITE: / wa_so_car-sign,
                   wa_so_car-option,
                   wa_so_car-low,
                   wa_so_car-high.
        ENDLOOP.
        SKIP.
        FORMAT COLOR COL_HEADING.
        WRITE: / 'Connections'(002), AT end space .             "#EC *
        ULINE AT /(end).
        FORMAT COLOR COL_NORMAL.
        LOOP AT so_con INTO wa_so_con.
          WRITE: / wa_so_con-sign,
                   wa_so_con-option,
                   wa_so_con-low NO-ZERO,
                   wa_so_con-high NO-ZERO.
        ENDLOOP.
        SKIP.
      ENDMETHOD.                    "print_tol
      METHOD on_toolbar.
        DATA l_wa_button TYPE stb_button.
        l_wa_button-butn_type = 3.
        INSERT l_wa_button INTO TABLE e_object->mt_toolbar.
        CLEAR l_wa_button.
        l_wa_button-function = 'AENDERN'.
        l_wa_button-icon = ICON_MC_CONTENTINDICATOR.
        l_wa_button-quickinfo =  'FLÜGE ANZEIGEN'.           "#EC *
        l_wa_button-butn_type = 0.
        l_wa_button-text = 'ÄNDERN FLÜGE'.
        INSERT l_wa_button INTO TABLE e_object->mt_toolbar.
    * Create button "Display bookings"
        CLEAR l_wa_button.
        l_wa_button-function = 'ANZEGEN'.
        l_wa_button-icon = ICON_FLIGHT.
        l_wa_button-quickinfo =
        'FLÜGE ANZEIGEN'.           "#EC *
        l_wa_button-butn_type = 0.
        l_wa_button-text = 'ANZEIGEN FLÜGE'.
        INSERT l_wa_button INTO TABLE e_object->mt_toolbar.
      ENDMETHOD.                    "on_toolbar
    *        Ereignisbehandlung                                           *
      METHOD on_user_command.
        CASE e_ucomm.
          WHEN 'AENDERN'.
          message 'Was möchten Sie ändern ?' type 'I'.
          WHEN 'ANZEGEN '.
          message 'Was möchten Sie denn anzeigen ?' type 'I'.
       ENDCASE.
      ENDMETHOD.                    "on_user_command
      METHOD on_context_menu_request.
        DATA:
          column_info TYPE lvc_s_col.
        CALL METHOD alv->get_current_cell
          IMPORTING
            e_row     = row
            es_col_id = column_info.
        CASE column_info-fieldname.
          WHEN 'CARRID'.
            CALL METHOD e_object->add_function
              EXPORTING
                fcode = 'CARRIER_INFO'
                text  = 'Carrier info'(me1). "#EC *
          WHEN OTHERS.
        ENDCASE.
      ENDMETHOD.
    ENDCLASS.                    "lcl_handler IMPLEMENTATION
    **********************  ENDCLASS  ***********************
    *ABAP events
    START-OF-SELECTION.
      SELECT * FROM sflight
        INTO CORRESPONDING FIELDS OF TABLE it_sflight
        WHERE carrid IN so_car
        AND   connid IN so_con.
      LOOP AT it_sflight INTO wa_sflight.
        CLEAR: wa_sflight-it_field_colors.
    * set indicator for flights of current month
    * Fluege des laufenden Monats hervorheben
        IF wa_sflight-fldate(6) = sy-datum(6).
          CONCATENATE 'C' col_negative '01' INTO wa_sflight-color.
        ENDIF.
    * set icon for bookings status
    * Ikone für Buchungsstatus belegen
        IF wa_sflight-seatsocc = 0.
          wa_sflight-light = 1.
        ELSEIF wa_sflight-seatsocc < 50.
          wa_sflight-light = 2.
        ELSE.
          wa_sflight-light = 3.
        ENDIF.
    * highlight specific aircraft
    * besonderen Flugzeugtyp hervorheben
        IF wa_sflight-planetype = '747-400'.
          wa_field_color-fname = 'PLANETYPE'.
          wa_field_color-color-col = col_positive.
          wa_field_color-color-int = 1.
          wa_field_color-color-inv = 0.
          APPEND wa_field_color TO wa_sflight-it_field_colors.
        ENDIF.
    * set indicator for flights in the past
    * Ikone setzen für Flüge in der Vergangenheit
        IF wa_sflight-fldate < sy-datum.
          wa_sflight-changes_possible = icon_space.
        ELSE.
          wa_sflight-changes_possible = icon_okay.
        ENDIF.
        MODIFY it_sflight
          FROM wa_sflight
          TRANSPORTING color light it_field_colors changes_possible.
      ENDLOOP.
      CALL SCREEN 100.
    *PBO modules
    MODULE status_0100 OUTPUT.
      SET PF-STATUS 'DYN'.
      SET TITLEBAR 'T1'.
    ENDMODULE.                 " STATUS_0100  OUTPUT
    MODULE clear_ok_code OUTPUT.
      CLEAR ok_code.
    ENDMODULE.                 " clear_ok_code  OUTPUT
    MODULE create_and_transfer OUTPUT.
      CHECK cont IS INITIAL.
      CREATE OBJECT cont
        EXPORTING
          container_name              = 'MY_CONTROL_AREA'
        EXCEPTIONS
          OTHERS                      = 1.
      IF sy-subrc <> 0 AND sy-batch IS INITIAL.
        MESSAGE a010(bc408).
      ENDIF.
      CREATE OBJECT alv
        EXPORTING
          i_parent          = cont
        EXCEPTIONS
          OTHERS            = 1.
      IF sy-subrc <> 0 AND sy-batch IS INITIAL.
        MESSAGE a010(bc408).
      ENDIF.
    * register event handlers
      SET HANDLER:
        lcl_handler=>on_toolbar      FOR alv,
        lcl_handler=>on_user_command FOR alv,
        lcl_handler=>on_doubleclick  FOR alv,
        lcl_handler=>print_top       FOR alv,
        lcl_handler=>print_tol       FOR alv,
        lcl_handler=>on_context_menu_request FOR alv.
      my_variant-report = sy-cprog.
      IF NOT pa_lv IS INITIAL.
        my_variant-variant = pa_lv.
      ENDIF.
      my_print-prntlstinf = 'X'.
      my_print-grpchgedit = 'X'.
    *define layout
      wa_layout-grid_title = 'Flights'(h01).                    "#EC *
      wa_layout-no_hgridln = 'X'.
      wa_layout-no_vgridln = 'X'.
    *field that contains information on row color
      wa_layout-info_fname = 'COLOR'.
    *internal table that contains information on cell color
      wa_layout-ctab_fname = 'IT_FIELD_COLORS'.
    *field that contains information on exception (indicator)
      wa_layout-excp_fname = 'LIGHT'.
    *multiple row and column selection
      wa_layout-sel_mode = 'A'.
    *fill field catalog
      wa_field_cat-fieldname = 'SEATSOCC'.
      wa_field_cat-do_sum = 'X'.
      APPEND wa_field_cat TO it_field_cat.
      CLEAR wa_field_cat.
      wa_field_cat-fieldname = 'PAYMENTSUM'.
      wa_field_cat-no_out = 'X'.
      APPEND wa_field_cat TO it_field_cat.
      CLEAR wa_field_cat.
      wa_field_cat-fieldname = 'LIGHT'.
      wa_field_cat-coltext = 'Utilization'(h02).                "#EC *
      APPEND wa_field_cat TO it_field_cat.
      CLEAR wa_field_cat.
      wa_field_cat-fieldname = 'CHANGES_POSSIBLE'.
      wa_field_cat-col_pos = 5.
      wa_field_cat-coltext = 'Changes possible'(h03).           "#EC *
      wa_field_cat-tooltip = 'Are changes possible?'(t01).      "#EC *
      APPEND wa_field_cat TO it_field_cat.
      CALL METHOD alv->set_table_for_first_display
        EXPORTING
          i_structure_name = 'SFLIGHT'
          is_variant       = my_variant
          i_save           = 'A'
          is_layout        = wa_layout
          is_print         = my_print
        CHANGING
          it_outtab        = it_sflight
          it_fieldcatalog  = it_field_cat
        EXCEPTIONS
          OTHERS           = 1.
      IF sy-subrc <> 0.
        MESSAGE a012(bc408).
      ENDIF.
    ENDMODULE.                 " create_and_transfer OUTPUT
    *PAI modules
    MODULE user_command_0100 INPUT.
      CASE ok_code.
        WHEN 'BACK' OR 'EXIT' OR 'CANCEL'.
          PERFORM free.
          SET SCREEN 0.
      ENDCASE.
    ENDMODULE.                 " USER_COMMAND_0100  INPUT
    *Form routines
    FORM free.
      CALL METHOD: alv->free,
                   cont->free.
      FREE: alv,
            cont.
    ENDFORM.                    " free

  • Set pf status in alv oops concept

    Hi all,
    can any one pls tell me  by using which method or class  i can set the
    pf status......?  
    regards
    cnu

    Fast and Easy way
    As you are using OO ALV, remove any function not needed from the ALV via parameter IT_TOOLBAR_EXCLUDING of method set_table_for_first_display and put your own function in the menu of your dynpro PBO via SET PF-STATUS.
    Nethertheless you can use a more complew way using :
    <b>Changing Standard Functions</b>
    Purpose
    The standard functions are not designed for specific applications. As a result, special knowledge of the data displayed cannot be considered. In individual cases, you may design a standard function - such as sorting by a specific column - more effectively in a specific application.
    Process Flow
    1. Define an event handler method for event before_user_command [Page 108]. This event is triggered after the user has selected a function. This means that the ALV Grid Control passes control to the application before the function is executed. Using event parameter I_UCOMM you can restrict the function code to the function you want to modify.
    2. Implement your own algorithm for the function within the event handler method. In this context, you can call methods of the ALV Grid Control.
    3. Reset the function code to ensure that the standard function is no longer executed:
    CALL METHOD <Instance of the ALV Ccntrol>->set_user_command exporting I_UCOMM = SPACE.
    If you never need specific functions of the tool bar, you can hide them for the entire life-cycle of the control. To do this, you use parameter IT_TOOLBAR_EXCLUDING of method set_table_for_first_display  to pass a table that contains the function codes to be hidden.
    <b>Defining GUI Elements in the Toolbar</b>
    Process Flow
    1. Define an event handler method for event TOOLBAR.
    2. Declare a structure for defining a toolbar element:
    data: ls_toolbar TYPE stb_button.
    3. For a pushbutton, for example, you would fill the following fields:
    CLEAR ls_toolbar. MOVE 0 TO ls_toolbar-butn_type.
    MOVE 'BOOKINGS' TO ls_toolbar-function.
    MOVE icon_employee TO ls_toolbar-icon.
    MOVE 'Show Bookings'(111) TO ls_toolbar-quickinfo. MOVE SPACE TO ls_toolbar-disabled.
    In the butn_type field, you specify the type of the GUI element for the ALV Grid Control. For possible values, see the value range of domain TB_BTYPE.
    4. Use event parameter E_OBJECT to append the new definition to table mt_toolbar:
    APPEND ls_toolbar TO e_object->mt_toolbar.
    5. If you want to define additional elements, go back to step 3.
    6. Call method set_toolbar_interactive, if you want to rebuild the toolbar.
    Result
    In the event handler method of event USER_COMMAND, you can query the function code you specified in field function to implement the associated function.
    See also report BCALV_GRID_05 in development class SLIS.
    Look at this documentation too : <a href="http://help.sap.com/printdocu/core/Print46c/en/data/pdf/BCSRVALV/BCSRVALV.pdf">ALV Gird Control (BC-SRV-ALV)</a>
    Regards

  • Menu Button in ALV toolbar (multiple choices for a button)

    Hi abapers,
    I would like to have a button with multiple choices in the toolbar;
    at the moment I have created a menu button with just one function.
    Here is my code:
    CLASS lcl_event_receiver (Definition)
    CLASS lcl_event_receiver DEFINITION.
      PUBLIC SECTION.
        METHODS:
        handle_toolbar
            FOR EVENT toolbar OF cl_gui_alv_grid
                IMPORTING e_object e_interactive.
    ENDCLASS.                    "lcl_event_receiver DEFINITION
    CLASS lcl_event_receiver (Implementation)
    CLASS lcl_event_receiver IMPLEMENTATION.
      METHOD handle_toolbar.
        DATA: ls_toolbar  TYPE stb_button.
    *Separator
        CLEAR ls_toolbar.
        MOVE 3 TO ls_toolbar-butn_type.
        APPEND ls_toolbar TO e_object->mt_toolbar.
    *Button
        CLEAR ls_toolbar.
        MOVE 1 TO ls_toolbar-butn_type.
        MOVE 'EDIT' TO ls_toolbar-function.
        MOVE icon_change TO ls_toolbar-icon.
        MOVE ' Modifica'(l02) TO ls_toolbar-text.
        MOVE ' ' TO ls_toolbar-disabled.
        MOVE 'Modifica' TO ls_toolbar-quickinfo.
        APPEND ls_toolbar TO e_object->mt_toolbar.
      ENDMETHOD.                    "handle_toolbar
    ENDCLASS.                    "lcl_event_receiver IMPLEMENTATION

    hi,
    check this code and reward me if it helps you..
    TYPE-POOLS : slis,icon.
    *Structure declaration for tcodes
    TYPES : BEGIN OF ty_table,
            tcode TYPE tcode,
            pgmna TYPE progname,
            END OF ty_table.
    *Structure for tocde text
    TYPES : BEGIN OF ty_itext,
            tcode TYPE tcode,
            ttext TYPE ttext_stct,
            sprsl TYPE sprsl,
            END OF ty_itext.
    *Structure for output display
    TYPES : BEGIN OF ty_output,
            tcode TYPE tcode,
            pgmna TYPE progname,
            ttext TYPE ttext_stct,
           END OF ty_output.
    *internal table and work area declarations
    DATA : it_table TYPE STANDARD TABLE OF ty_table INITIAL SIZE 0,
           it_output TYPE STANDARD TABLE OF ty_output INITIAL SIZE 0,
           it_ittext TYPE STANDARD TABLE OF ty_itext INITIAL SIZE 0,
           wa_table TYPE ty_table,
           wa_output TYPE ty_output,
           wa_ittext TYPE ty_itext.
    *Class definition for ALV toolbar
    CLASS:      lcl_alv_toolbar   DEFINITION DEFERRED.
    *Declaration for toolbar buttons
    DATA : ty_toolbar TYPE stb_button.
    Data declarations for ALV
    DATA: c_ccont TYPE REF TO cl_gui_custom_container,   "Custom container object
          c_alvgd         TYPE REF TO cl_gui_alv_grid,   "ALV grid object
          it_fcat            TYPE lvc_t_fcat,            "Field catalogue
          it_layout          TYPE lvc_s_layo,            "Layout
          c_alv_toolbar    TYPE REF TO lcl_alv_toolbar,           "Alv toolbar
          c_alv_toolbarmanager TYPE REF TO cl_alv_grid_toolbar_manager.  "Toolbar manager
    *Initialization event
    INITIALIZATION.
    *Start of selection event
    START-OF-SELECTION.
    *Subroutine to get values from tstc table
      PERFORM fetch_data.
    *subroutine for alv display
      PERFORM alv_output.
          CLASS lcl_alv_toolbar DEFINITION
          ALV event handler
    CLASS lcl_alv_toolbar DEFINITION.
      PUBLIC SECTION.
    *Constructor
        METHODS: constructor
                   IMPORTING
                     io_alv_grid TYPE REF TO cl_gui_alv_grid,
    *Event for toolbar
        on_toolbar
           FOR EVENT toolbar
           OF  cl_gui_alv_grid
           IMPORTING
             e_object.
    ENDCLASS.                    "lcl_alv_toolbar DEFINITION
          CLASS lcl_alv_toolbar IMPLEMENTATION
          ALV event handler
    CLASS lcl_alv_toolbar IMPLEMENTATION.
      METHOD constructor.
      Create ALV toolbar manager instance
        CREATE OBJECT c_alv_toolbarmanager
          EXPORTING
            io_alv_grid      = io_alv_grid.
       ENDMETHOD.                    "constructor
      METHOD on_toolbar.
      Add customized toolbar buttons.
      variable for Toolbar Button
          ty_toolbar-icon      =  icon_generate.
        ty_toolbar-butn_type = 0.
        ty_toolbar-text = 'Button1'.
          APPEND ty_toolbar TO e_object->mt_toolbar.
          ty_toolbar-icon      =  icon_voice_output.
        ty_toolbar-butn_type = 0.
        ty_toolbar-text = 'Button2'.
           APPEND ty_toolbar TO e_object->mt_toolbar.
         ty_toolbar-icon      =  icon_phone.
        ty_toolbar-butn_type = 0.
        ty_toolbar-text = 'Button3'.
           APPEND ty_toolbar TO e_object->mt_toolbar.
         ty_toolbar-icon      =  icon_mail.
        ty_toolbar-butn_type = 0.
        ty_toolbar-text = 'Button4'.
           APPEND ty_toolbar TO e_object->mt_toolbar.
       ty_toolbar-icon      =  icon_voice_input.
        ty_toolbar-butn_type = 0.
        ty_toolbar-text = 'Button5'.
         APPEND ty_toolbar TO e_object->mt_toolbar.
      Call reorganize method of toolbar manager to
      display the toolbar
         CALL METHOD c_alv_toolbarmanager->reorganize
          EXPORTING
            io_alv_toolbar = e_object.
       ENDMETHOD.                    "on_toolbar
    ENDCLASS.                    "lcl_alv_toolbar IMPLEMENTATION
    *&      Form  fetch_data
          text
    -->  p1        text
    <--  p2        text
    FORM fetch_data .
    Select the tcodes upto 200 rows from TSTC
       SELECT   tcode
               pgmna
               FROM tstc
               INTO CORRESPONDING FIELDS OF TABLE it_table
               UP TO 200 ROWS
               WHERE dypno NE '0000'.
    *Select the tcode textx
       IF it_table[] IS NOT INITIAL.
         SELECT ttext
               tcode
               sprsl
               FROM tstct
               INTO CORRESPONDING FIELDS OF TABLE it_ittext
               FOR ALL ENTRIES IN it_table
               WHERE tcode = it_table-tcode
               AND sprsl = 'E'.
       ENDIF.
    Apppending the data to the internal table of ALV output
       LOOP AT it_table INTO wa_table.
        wa_output-tcode = wa_table-tcode.
        wa_output-pgmna = wa_table-pgmna.
       For texts
        READ TABLE it_ittext INTO wa_ittext WITH KEY tcode = wa_table-tcode.
        wa_output-ttext = wa_ittext-ttext.
         APPEND wa_output TO it_output.
        CLEAR wa_output.
       ENDLOOP.
       ENDFORM.                    " fetch_data
    *&      Form  alv_output
          text
    -->  p1        text
    <--  p2        text
    FORM alv_output .
    *Calling the ALV
      CALL SCREEN 0600.
      ENDFORM.                    " alv_output
    Calling the ALV screen with custom container
    On this statement double click  it takes you to the screen painter SE51.Enter the attributes
    *Create a Custom container and name it CC_CONT and OK code as OK_CODE.
    *Save check and Activate the screen painter.
    Now a normal screen with number 600 is created which holds the ALV grid. PBO of the actual screen , Here we can give a title and *customized menus
    *&      Module  STATUS_0600  OUTPUT
          text
    MODULE status_0600 OUTPUT.
    SET PF-STATUS 'xxxxxxxx'.
    SET TITLEBAR 'xxx'.
    ENDMODULE.                 " STATUS_0600  OUTPUT
    calling the PBO module ALV_GRID.
    *&      Module  ALV_GRID  OUTPUT
          text
    MODULE alv_grid OUTPUT.
    *create object for custom container
      CREATE OBJECT c_ccont
           EXPORTING
              container_name = 'CC_CONT'.
    *create object of alv grid
      CREATE OBJECT c_alvgd
          EXPORTING
              i_parent = c_ccont.
    create ALV event handler
      CREATE OBJECT c_alv_toolbar
        EXPORTING
          io_alv_grid = c_alvgd.
    Register event handler
      SET HANDLER c_alv_toolbar->on_toolbar FOR c_alvgd.
    Fieldcatalogue for ALV
       PERFORM alv_build_fieldcat.
    ALV attributes FOR LAYOUT
      PERFORM alv_report_layout.
       CHECK NOT c_alvgd IS INITIAL.
    Call ALV GRID
       CALL METHOD c_alvgd->set_table_for_first_display
        EXPORTING
          is_layout                     = it_layout
        CHANGING
          it_outtab                     = it_output
          it_fieldcatalog               = it_fcat
        EXCEPTIONS
          invalid_parameter_combination = 1
          program_error                 = 2
          too_many_lines                = 3
          OTHERS                        = 4.
      IF sy-subrc <> 0.
        MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
                   WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
      ENDIF.
    ENDMODULE.                 " ALV_GRID  OUTPUT
    *&      Form  alv_build_fieldcat
          text
         <--P_IT_FCAT  text
    FORM alv_build_fieldcat.
       DATA lv_fldcat TYPE lvc_s_fcat.
      CLEAR lv_fldcat.
      lv_fldcat-row_pos   = '1'.
      lv_fldcat-col_pos   = '1'.
      lv_fldcat-fieldname = 'TCODE'.
      lv_fldcat-tabname   = 'IT_OUTPUT'.
      lv_fldcat-outputlen = 8.
      lv_fldcat-scrtext_m = 'TCODE'.
      APPEND lv_fldcat TO it_fcat.
      CLEAR lv_fldcat.
       lv_fldcat-row_pos   = '1'.
      lv_fldcat-col_pos   = '2'.
      lv_fldcat-fieldname = 'PGMNA'.
      lv_fldcat-tabname   = 'IT_OUTPUT'.
      lv_fldcat-outputlen = 15.
      lv_fldcat-scrtext_m = 'PROGNAME'.
      APPEND lv_fldcat TO it_fcat.
      CLEAR lv_fldcat.
      lv_fldcat-row_pos   = '1'.
      lv_fldcat-col_pos   = '3'.
      lv_fldcat-fieldname = 'TTEXT'.
      lv_fldcat-tabname   = 'IT_OUTPUT'.
      lv_fldcat-outputlen = 60.
      lv_fldcat-scrtext_m = 'Description'.
      APPEND lv_fldcat TO it_fcat.
      CLEAR lv_fldcat.
    ENDFORM.                    " alv_build_fieldcat
    *&      Form  alv_report_layout
          text
         <--P_IT_LAYOUT  text
    FORM alv_report_layout.
       it_layout-cwidth_opt = 'X'.
       it_layout-zebra = 'X'.
    ENDFORM.                    " alv_report_layout
    PAI module of the screen created. In case we use an interactive ALV or
    *for additional functionalities we can create OK codes
    *and based on the user command we can do the coding.
    *&      Module  USER_COMMAND_0600  INPUT
          text
    MODULE user_command_0600 INPUT.
    ENDMODULE.                 " USER_COMMAND_0600  INPUT
    thanks,
    gupta

  • Disbable button on alv report using oops

    Hi all,
    I have a button to toll bar of alv grid using oops
    based on that when the user clicks on that some action is performed and list is displayed again
    now when the list is diaplyed i need the button that i added to be disabled so that the user cannot click it agin
    i have everything i don't know how to disable the button.
    USING THIS STATMENT  move 'X' to ls_toolbar-disabled WE CAN DISABLE BUT I DON'T WHERE TO PASS IT..
    LOCAL CLASSES: Definition
    *===============================================================
    class lcl_event_receiver: local class to
                            define and handle own functions.
    Definition:
    ~~~~~~~~~~~
    class lcl_event_receiver definition.
      public section.
        methods:
        handle_toolbar
            for event toolbar of cl_gui_alv_grid
                importing e_object e_interactive,
        handle_user_command
            for event user_command of cl_gui_alv_grid
                importing e_ucomm.
      private section.
    endclass.
    lcl_event_receiver (Definition)
    *===============================================================
    LOCAL CLASSES: Implementation
    *===============================================================
    class lcl_event_receiver (Implementation)
    class lcl_event_receiver implementation.
      method handle_toolbar.
    append a separator to normal toolbar
        clear ls_toolbar.
        move 3 to ls_toolbar-butn_type.
        append ls_toolbar to e_object->mt_toolbar.
    append an icon to show booking table
        clear ls_toolbar.
        move 'ADD' to ls_toolbar-function.
        move icon_employee to ls_toolbar-icon.
        move 'Show Bookings'(111) to ls_toolbar-quickinfo.
        move 'Add Material'(112) to ls_toolbar-text.
        move '' to ls_toolbar-disabled.
        append ls_toolbar to e_object->mt_toolbar.
      endmethod.
      method handle_user_command.
        case e_ucomm.
          when 'ADD'.
            call method g_grid->get_selected_rows
                     importing et_index_rows = lt_rows.
            call method cl_gui_cfw=>flush.
            if sy-subrc ne 0.
    add your handling, for example
             call function 'POPUP_TO_INFORM'
                  exporting
                       titel = g_repid
                       txt2  = sy-subrc
                       txt1  = 'Error in Flush'(500).
            else.
    *tHIS IS THE PART IAM HAVING PROBLEM WITH
    *class lcl_event_receiver implementation.
    method handle_toolbar.
    *clear : ls_toolbar.
    loop at e_object->mt_toolbar into ls_toolbar WHERE FUNCTION = 'ADD'.
    DELETE e_object->mt_toolbar FROM ls_toolbar.
    move ' ' to ls_toolbar-disabled.
    append ls_toolbar to e_object->mt_toolbar.
    endloop.
    *ENDMETHOD.
    *ENDCLASS.
    ***tHIS IS THE PART
      call method g_grid->refresh_table_display.
            endif.
        endcase.
      endmethod.
    Thanks in advance

    Hi
    hI ALL,
    MY QUESTION IS WHEN method handle_toolbaR WOULD BE TRIGERRED
    first time i have the button enabled and when i press the button its get disabled.This is what i need
    But iam trying to understand how this is working
    Let me know whether iam right or not
    when this piece of code would be triggered
    method handle_toolbar.
        clear ls_toolbar.
        move 3 to ls_toolbar-butn_type.
        append ls_toolbar to e_object->mt_toolbar.
        clear ls_toolbar.
        move 'ADD' to ls_toolbar-function.
        move icon_employee to ls_toolbar-icon.
        move 'Show Bookings'(111) to ls_toolbar-quickinfo.
        move 'Add Material'(112) to ls_toolbar-text.
        move ' ' to ls_toolbar-disabled.
        append ls_toolbar to e_object->mt_toolbar.
        IF FLAG = 'X'.
        LOOP AT e_object->mt_toolbar INTO ls_toolbar.
       if ls_toolbar-function = 'ADD'.
       ls_toolbar-disabled = 'X'.
       MODIFY e_object->mt_toolbar FROM ls_toolbar.
       endif.
       ENDLOOP.
        ENDIF.
    1 ) would this be triggered
    when i call this  call method g_grid->refresh_table_display.
    2)or
    call method g_grid->set_toolbar_interactive
    This is my piece of code
    class lcl_event_receiver definition.
      public section.
        methods:
        handle_toolbar
            for event toolbar of cl_gui_alv_grid
                importing e_object e_interactive,
        handle_user_command
            for event user_command of cl_gui_alv_grid
                importing e_ucomm.
      private section.
    endclass.
    class lcl_event_receiver implementation.
      method handle_toolbar.
        clear ls_toolbar.
        move 3 to ls_toolbar-butn_type.
        append ls_toolbar to e_object->mt_toolbar.
        clear ls_toolbar.
        move 'ADD' to ls_toolbar-function.
        move icon_employee to ls_toolbar-icon.
        move 'Show Bookings'(111) to ls_toolbar-quickinfo.
        move 'Add Material'(112) to ls_toolbar-text.
        move ' ' to ls_toolbar-disabled.
        append ls_toolbar to e_object->mt_toolbar.
        IF FLAG = 'X'.
        LOOP AT e_object->mt_toolbar INTO ls_toolbar.
       if ls_toolbar-function = 'ADD'.
       ls_toolbar-disabled = 'X'.
       MODIFY e_object->mt_toolbar FROM ls_toolbar.
       endif.
       ENDLOOP.
        ENDIF.
      endmethod.
      method handle_user_command.
        case e_ucomm.
          when 'ADD'.
            call method g_grid->get_selected_rows
                     importing et_index_rows = lt_rows.
            call method cl_gui_cfw=>flush.
            if sy-subrc ne 0.
            else.
        perform test.
      call method g_grid->refresh_table_display.
           endif.
        endcase.
      endmethod.                           "handle_user_command
    odule status_0100 output.
    SET PF-STATUS 'STATUS'.
      set pf-status 'MAIN100'.
      set titlebar 'HEADER_CHECK'.
    if g_custom_container is initial.
        create object g_custom_container
                 exporting container_name = g_container.
        create object g_grid
                   exporting i_parent = g_custom_container.
    call function 'LVC_FIELDCATALOG_MERGE'
    exporting
    i_structure_name = 'ZTEST'
    changing
    ct_fieldcat = fieldcat
    exceptions
    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.
    g_layout-sel_mode = 'A'.              " TO GET SELECTION BOX
    call method g_grid->set_table_for_first_display
    exporting
       I_BYPASSING_BUFFER            =
       I_BUFFER_ACTIVE               =
       I_CONSISTENCY_CHECK           =
       I_STRUCTURE_NAME              =
       IS_VARIANT                    =
       I_SAVE                        =
       I_DEFAULT                     = 'X'
         is_layout                     = g_layout
       IS_PRINT                      =
       IT_SPECIAL_GROUPS             =
        it_toolbar_excluding          = pt_exclude
       IT_HYPERLINK                  =
       IT_ALV_GRAPHICS               =
      changing
        it_outtab                     =  i_zTEST
        it_fieldcatalog               = fieldcat
       IT_SORT                       =
       IT_FILTER                     =
      exceptions
        invalid_parameter_combination = 1
        program_error                 = 2
        too_many_lines                = 3
        others                        = 4
    create object event_receiver.
        set handler event_receiver->handle_user_command for g_grid.
        set handler event_receiver->handle_toolbar for g_grid.
      call method g_grid->set_toolbar_interactive.
      endif.                               "IF grid1 IS INITIAL
      call method cl_gui_control=>set_focus exporting control = g_grid.
    endmodule.                 " STATUS_0100  OUTPUT
    Thanks
    Suchitra

  • For all users having probs with OO ALV Grid

    I wanted to put this in the WIKI but it keeps bombing out when I try and save so I've put this here -- Maybe a MOD can move it for me.
    This generic class should give you far more insite into using an EDITABLE ALV table than the standard documentation.
    If you follow the steps you should be able to code very quickly a decent useable ALV OO program which can retrieve and manipulate data very easily.  The events are (hopefully) well documented as are all the steps.
    Once you understand the basics you can add more functionality like colouring Cells, adding hyperlinks etc etc.
    I've always found that stupid SEAT / AIRLINE application SAP uses for its examples far too overblown and in reality who would ever use a SAP system for Airline reservations anyway.
    The class here describes a much simpler application which CLEARLY (I hope) explains how the whole thing works.
    Jimbo's generic class for using the OO ALV GRID Class CL_GUI_ALV_GRID
    from an application program to display and manipulate ANY table
    with minimal coding needed in the Calling application program.
    Handles the following EVENTS
    1) TOOLBAR BUTTONS
    (you can add more to the toolbar method
      if you need even more functionality).
    2) DOUBLE CLICK
    3) ENTER KEY PRESSED
    4) DATA CHANGED
    5) DATA CHANGED FINISHED
    Methods available
    PUBLIC METHODS  ( Can be called directly from the application program).
    1) display_grid  displays grid with toolbar
       Table and FCAT are built dynamically - user only needs to
       define the table structure (can be DDIC or User fields)
    2) change_title  - changes title at the top of the Grid
    3) refresh_grid   - refreshes grid after table updated etc.
    4) build_dynamic_structures - this method creates a dynamic table and a dynamic FCAT
       using the structure defined in the calling application program
    PRIVATE METHODS (Internal Methods used within the class)
    1) verwerk - returns to FORM VERWERK in calling application program
       (Via Toolbar). The application program can then do any special processing
       at this point e.g update SAP tables etc.
    2) download_to_excel (via Toolbar). This creates an EXCEL spreadsheet
       directly which can be downloaded / saved to a file if required,
    3) return_structure - internal method returns the structure
       of the table defined in the calling application program. This is needed in order
       to build the dynamic table and Field Catalog.
    4) create_dynamic_table  - creates a dynamic table from the structure defined in
       the calling application program
    5) create_dynamic_fcat  - creates the dynamic field catalog from the structure
       defined in the application program.
    6) dubbleklik entered when user double clicks a cell
    activated by EVENT DOUBLE_CLICK.
    returns to FORM DUBBELKLIK  in the
    calling application program
       COOKBOOK STEP BY STEP instructions on how to use this class
       in your application program.
       In the application program :
    1) define a blank screen 100  - SE51 with a custom container
       on it called CCONTAINER1.
       you need the following logic in the screen
       The PAI is only used if you have defined a STATUS with SE41 and you exit the
       application program via the standard SAP buttons on the
       top of the Screen (NOT the GRID toolbar).
         PROCESS BEFORE OUTPUT.
          MODULE STATUS_0100.
         PROCESS AFTER INPUT.
         MODULE USER_COMMAND_0100.
    2) (optional) define a STATUS with a titlebar - SE41
       you only need this if you want the standard EXIT and menu buttons on the
       top line of the screen
    3) If you want to have your OWN colum names on the grid
       add the following macro to the start of your program
         DEFINE col_name.
         read  table it_fldcat into  wa_it_fldcat index &1.
         wa_it_fldcat-coltext = &2.
         modify it_fldcat from wa_it_fldcat index &1.
         END-OF-DEFINITION.
    4) Define the following Field symbols
       <fs1>           TYPE  ANY,
       <fs2>           TYPE  STANDARD TABLE,
       <fs3>           TYPE ANY,
       <field_catalog> TYPE STANDARD TABLE,
       <dyn_table>    TYPE  STANDARD TABLE,
       <orig_table>   TYPE  STANDARD TABLE,
       <dyn_field>,
       <dyn_wa>.
    5) After the field-symbols add the code in this class
        as an INCLUDE
        e.g INCLUDE ZZJIMBOXX_INCL.
    6) define your Internal table as follows
        TYPES:  BEGIN OF s_elements,
                  Your structure
                your structure etc.
                END OF  s_elements.
    For example
    INCLUDE  <icon>.
    TABLES: VAPMA.
    *TYPES:  BEGIN OF s_elements,
    vbeln   TYPE vapma-vbeln,
    posnr   TYPE vapma-posnr,
    matnr   TYPE vapma-matnr,
    kunnr   TYPE vapma-kunnr,
    werks   TYPE vapma-werks,
    vkorg   TYPE vapma-vkorg,
    vkbur   TYPE vapma-vkbur,
    status  TYPE c,
    *END OF  s_elements.
    7) Define the following data  IN YOUR APPLICATION PROGRAM
       (note here only data is described
       that relates to using THIS CLASS. Data purely used internally
       in the application program is NOT shown here).
    DATA: z_object          TYPE REF TO zcl_dog,  "Instantiate our class
          grid_container1    TYPE REF TO cl_gui_custom_container,
          t_elements         TYPE TABLE OF s_elements, "refers to our ITAB
          wa_elements        TYPE s_elements,
          wa_dyn_table_line  TYPE REF TO DATA,
          it_fldcat          TYPE lvc_t_fcat,
          i_gridtitle        TYPE lvc_title,
          wa_it_fldcat       TYPE lvc_s_fcat,
          new_table          TYPE REF TO DATA,
          dy_table           TYPE REF TO data,
          dy_line            TYPE REF TO data,
          row_id             TYPE sy-index.
    8) insert the following code at the start of the application program.
    *START-OF-SELECTION.
    *CALL SCREEN 100.
    *END-OF-SELECTION.
    *MODULE status_0100 OUTPUT.
    *ASSIGN  wa_elements TO <fs1>.
    *CREATE OBJECT z_object EXPORTING z_object = z_object. "Instantiate the class
    *CALL METHOD z_object->build_dynamic_structures
           CHANGING it_fldcat = it_fldcat.
    9) if you inserted the macro in step 3) then
       define your own column names as follws
      col_name 1 'Name1'.
      col_name 2 'Name2'.
      etc. The number is the colum number you want and the name is
      the name you want to assign to the column.
    for example using the table shown above
      col_name 1 'Order Nr'.
      col_name 2 'Item'.
      col_name 3 'Material'.
      col_name 4 'Customer'.
      col_name 5 'Plant'.
      col_name 6 'Sales Org'.
      col_name 7 'Sales Office'.
      col_name 8 'Status'.
    10)  perform a routine that fills your dynamic table and
         display the GRID. If you created a status with SE41 you can set
         a title etc. Further processing is dependent on the users action
         after the GRID is displayed for example if a Cell is double clicked,
         dat is entered, a toolbar button is pressed or a SAP ICON on top of the screen is pressed.
    PERFORM populate_dynamic_itab.
    CALL METHOD z_object->display_grid
          CHANGING it_fldcat = it_fldcat.
    SET PF-STATUS '0001'.
    SET TITLEBAR '000'.
    ENDMODULE.
    11) If you added a STATUS via SE41 you can exit the program via the
    standard SAP buttons at the top of the screen
    otherwise exit via the exit button on the toolbar.
    You only need this piece of code if you defined a STATUS in the application program
    MODULE user_command_0100 INPUT.
    CASE sy-ucomm.
       WHEN 'BACK'.
         LEAVE PROGRAM.
       WHEN 'EXIT'.
         LEAVE PROGRAM.
       WHEN 'RETURN'.
         LEAVE PROGRAM.
       WHEN OTHERS.
    ENDCASE.
    12)  to populate the dynamic table you only need to code something like this
    remember the class has already created and structured the field-symbol <dyn_table>
    so you don't have to do anything other than just select the fields you want
    filled and from what data source(es).
    *FORM populate_dynamic_itab.
    *SELECT vbeln posnr matnr kunnr werks vkorg vkbur
          UP TO 200 rows
          FROM vapma
          INTO  CORRESPONDING FIELDS OF TABLE <dyn_table>.
    if you want to keep the original table before making any changes etc code
    the following
    create 2nd Dyn table to hold original data. We can use
    the same field catalog as for the original table
    as we are just creating an identical copy here.
    *CALL METHOD cl_alv_table_create=>create_dynamic_table
       EXPORTING
            it_fieldcatalog = it_fldcat
         IMPORTING
            ep_table = dy_table.
      ASSIGN dy_table->* TO <orig_table>.
    CREATE DATA dy_line LIKE LINE OF <orig_table>.
    ASSIGN dy_line->* TO <dyn_wa>.
    <orig_table> = <dyn_table>.
    ENDFORM.
    13) you need these 2 processing routines in your application program.
    FORM VERWERK.  "Entered from VERW on toolbar
    *break-point 1.
    Orig table is in dynamic table <orig_table>
    ALV GRID changed table is in <dyn_table>.
    *Loop at <orig_table>  into <dyn_wa>.
      Do what you want here
    end
    endloop.
    ENDFORM.
    *form dubbleklik using     "Entered when a cell is double clicked
           e_row   type LVC_S_ROW
           e_column type LVC_S_col
           es_row_no type lvc_s_roid.
           break-point 1.
    Get Row id into a variable for this program.
           row_id =  e_row.
            SET TITLEBAR '001'.      "If you defined a status in SE41
           i_gridtitle = 'Grid Title Changed'.
           CALL METHOD  z_object->change_title
             EXPORTING i_gridtitle = i_gridtitle.
           PERFORM refresh.
    endform.
    The REFRESH routine is optional but after a double click I assume
    you want to do some processing
    and re-display the data
    so as a sample code something like
    *FORM refresh.
    data: ord_nr  TYPE vapma-vbeln.  "Your data
    *READ TABLE  <dyn_table> index row_id into wa_elements.
       ord_nr = wa_elements-vbeln.
    You've now got the Row double clicked so pick out the data element(s)
    you wnat to process and do your processing
    *set parameter id 'AUN'  field ord_nr.
    *CALL TRANSACTION  'VA02' AND SKIP FIRST SCREEN.
    You can update the dynamic table for example
    *wa_elements-status = 'C'.
    *modify <dyn_table> from wa_elements index row_id.
    now redisplay the updated grid.
    *CALL METHOD z_object->refresh_grid.
    *ENDFORM.
    *************Class ZCL_DOG*************
    CLASS zcl_dog DEFINITION.
    PUBLIC SECTION.
    METHODS:
      constructor
         IMPORTING
                      z_object TYPE REF TO zcl_dog,
       display_grid
         CHANGING
                      it_fldcat TYPE lvc_t_fcat,
           build_dynamic_structures
         CHANGING        it_fldcat TYPE lvc_t_fcat,
        change_title
         IMPORTING
                i_gridtitle  TYPE lvc_title,
         refresh_grid.
      PRIVATE SECTION.
       METHODS:
        on_user_command FOR EVENT before_user_command OF cl_gui_alv_grid
          IMPORTING       e_ucomm
                          sender,
        on_toolbar FOR EVENT toolbar OF cl_gui_alv_grid
          IMPORTING      e_object
                         e_interactive,
         on_dubbelklik FOR EVENT double_click OF cl_gui_alv_grid
          IMPORTING e_row
                    e_column
                    es_row_no,
        handle_data_changed
                 FOR EVENT data_changed OF cl_gui_alv_grid
                 IMPORTING er_data_changed,
        handle_data_changed_finished
                 FOR EVENT data_changed_finished OF cl_gui_alv_grid
                 IMPORTING e_modified
                           et_good_cells,
        verwerk
                IMPORTING program TYPE sy-repid,
        download_to_excel,
        dubbleklik
                IMPORTING
                     e_row  type  LVC_S_ROW
                     e_column   TYPE LVC_S_COL
                     es_row_no  type lvc_s_ROID
                     program type sy-repid,
         return_structure,
         create_dynamic_fcat
          EXPORTING       it_fldcat TYPE lvc_t_fcat,
          create_dynamic_table
          IMPORTING       it_fldcat TYPE lvc_t_fcat
          EXPORTING       dy_table  TYPE REF TO DATA.
    DATA:
        lr_rtti_struc    TYPE REF TO cl_abap_structdescr,        "RTTI
        zog              LIKE LINE OF lr_rtti_struc->components, "RTTI
        wa_it_fldcat     TYPE lvc_s_fcat,
        it_fldcat        TYPE lvc_t_fcat,
        dy_table         TYPE REF TO data,
        dy_line          TYPE REF TO data,
        struct_grid_lset TYPE lvc_s_layo,
        e_row            TYPE LVC_S_ROW,
        e_column         TYPE lvc_s_col,
        es_rowid         TYPE lvc_s_roid,
        grid_container1  TYPE REF TO cl_gui_custom_container,
        grid1            TYPE REF TO cl_gui_alv_grid,
        ls_layout        TYPE kkblo_layout,
        lt_fieldcat_wa   TYPE kkblo_fieldcat,
        l_mode           TYPE raw4,
        celltab          TYPE LVC_T_STYL,
        wa_celltab       TYPE lvc_s_styl,
        lt_fieldcat      TYPE kkblo_t_fieldcat,
       l_tabname         TYPE slis_tabname.
    TYPES:
       struc            LIKE  zog.
    DATA:
        zogt           TYPE TABLE OF struc.
       ENDCLASS.
    CLASS zcl_dog IMPLEMENTATION.
    METHOD constructor.
       CREATE OBJECT grid_container1
           EXPORTING
                   container_name = 'CCONTAINER1'.
        CREATE OBJECT  grid1
            EXPORTING
                  i_parent = grid_container1.
        SET HANDLER z_object->on_user_command for grid1.
        SET HANDLER z_object->on_toolbar for grid1.
        SET HANDLER Z_OBJECT->handle_data_changed_finished FOR grid1.
        SET HANDLER Z_OBJECT->on_dubbelklik FOR grid1.
        CALL METHOD grid1->register_edit_event
            EXPORTING
                    i_event_id = cl_gui_alv_grid=>mc_evt_enter.
    ENDMETHOD.
    METHOD refresh_grid.
      CALL METHOD cl_gui_cfw=>flush.
      CALL METHOD grid1->refresh_table_display.
    ENDMETHOD.
    METHOD on_dubbelklik.
    CALL METHOD me->dubbleklik
             EXPORTING
                     e_row  = e_row
                     e_column =  e_column
                     es_row_no = es_row_no
                     program  = sy-repid.
    break-point 1.
    ENDMETHOD.
    METHOD  handle_data_changed.
    Insert user code here if required
    this method is entered if user ENTERS DATA.
    ENDMETHOD.
    METHOD handle_data_changed_finished.
    Insert user code here if required
    Method entered here after data entry has finished.
    ENDMETHOD.
    METHOD return_structure.
      lr_rtti_struc ?= cl_abap_structdescr=>DESCRIBE_BY_DATA( <fs1> ).
      zogt[]  = lr_rtti_struc->components.
      ASSIGN zogt[] TO <fs2>.
      ENDMETHOD.
    METHOD create_dynamic_fcat.
        LOOP AT <fs2>  INTO zog.
          CLEAR wa_it_fldcat.
          wa_it_fldcat-fieldname = zog-name .
          wa_it_fldcat-datatype = zog-type_kind.
          wa_it_fldcat-inttype = zog-type_kind.
          wa_it_fldcat-intlen = zog-length.
          wa_it_fldcat-decimals = zog-decimals.
          wa_it_fldcat-coltext = zog-name.
          wa_it_fldcat-lowercase = 'X'.
          APPEND wa_it_fldcat TO it_fldcat .
          ASSIGN it_fldcat[] TO <field_catalog>.
          ENDLOOP.
           ASSIGN  it_fldcat[] TO <field_catalog>.
        ENDMETHOD.
    METHOD  download_to_excel.
    break-point 5.
    CALL FUNCTION  'LVC_TRANSFER_TO_KKBLO'
        EXPORTING
          it_fieldcat_lvc   = <field_catalog>
         is_layout_lvc     = m_cl_variant->ms_layout
           is_tech_complete  = ' '
        IMPORTING
          es_layout_kkblo   = ls_layout
          et_fieldcat_kkblo = lt_fieldcat.
    LOOP AT lt_fieldcat INTO lt_fieldcat_wa.
       CLEAR lt_fieldcat_wa-tech_complete.
        IF lt_fieldcat_wa-tabname IS initial.
           lt_fieldcat_wa-tabname = '1'.
           MODIFY lt_fieldcat FROM lt_fieldcat_wa.
        ENDIF.
        l_tabname = lt_fieldcat_wa-tabname.
    ENDLOOP.
    CALL FUNCTION 'ALV_XXL_CALL'
        EXPORTING
          i_tabname           = l_tabname
          is_layout           = ls_layout
          it_fieldcat         = lt_fieldcat
          i_title             = sy-title
        TABLES
          it_outtab           = <dyn_table>
        EXCEPTIONS
          fatal_error         = 1
          no_display_possible = 2
          others              = 3.
      IF  sy-subrc <> 0.
         message id sy-msgid type 'S' number sy-msgno
                with sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
        ENDIF.
    ENDMETHOD.
    METHOD create_dynamic_table.
    CALL METHOD cl_alv_table_create=>create_dynamic_table
        EXPORTING
             it_fieldcatalog = it_fldcat
          IMPORTING
             ep_table = dy_table.
    ENDMETHOD.
    METHOD build_dynamic_structures.
    CALL METHOD me->return_structure.
    CALL METHOD me->create_dynamic_fcat
       IMPORTING
         it_fldcat = it_fldcat.
    CALL METHOD me->create_dynamic_table
        EXPORTING
          it_fldcat = it_fldcat
        IMPORTING
          dy_table        = dy_table.
         ASSIGN dy_table->* TO <dyn_table>.
    CREATE DATA dy_line LIKE LINE OF <dyn_table>.
    ASSIGN dy_line->* TO <dyn_wa>.
    ENDMETHOD.
    METHOD display_grid.
      struct_grid_lset-edit = 'X'. "To enable editing in ALV
      struct_grid_lset-grid_title = 'Bulkwijzigingen inkoopprijzen'.
      struct_grid_lset-ctab_fname = 'T_CELLCOLORS'.
      struct_grid_lset-stylefname = 'CELLTAB'.
      CALL METHOD grid1->set_ready_for_input
          EXPORTING
               i_ready_for_input = '1'.
      CALL METHOD grid1->set_table_for_first_display
          EXPORTING
               is_layout       = struct_grid_lset
        CHANGING
               it_outtab       = <dyn_table>
               it_fieldcatalog = it_fldcat.
    ENDMETHOD.
    METHOD change_title.
      CALL METHOD grid1->set_gridtitle
       EXPORTING
       i_gridtitle =  i_gridtitle.
      ENDMETHOD.
    METHOD on_user_command.
      CASE e_ucomm.
          WHEN 'EXIT'.
            LEAVE PROGRAM.
         WHEN 'EXCEL'.
         CALL METHOD me->download_to_excel.
          WHEN 'SAVE'.
          WHEN 'VERW'.
          CALL METHOD me->verwerk
               EXPORTING
                  PROGRAM = SY-REPID.
      ENDCASE.
    ENDMETHOD.                    "on_user_command
    METHOD on_toolbar.
    User can add extra functionality by adding extra
    buttons if required. Functionality can also be simplified by removing buttons.
    DATA: ls_toolbar TYPE stb_button.
         CLEAR ls_toolbar.
         MOVE 0 TO ls_toolbar-butn_type.
         MOVE 'EXIT' TO ls_toolbar-function.
         MOVE SPACE TO ls_toolbar-disabled.
         MOVE icon_system_end TO ls_toolbar-icon.
         MOVE 'Click2Exit' TO ls_toolbar-quickinfo.
         APPEND ls_toolbar TO e_object->mt_toolbar.
         CLEAR ls_toolbar.
         MOVE  0 TO ls_toolbar-butn_type.
         MOVE 'SAVE' TO ls_toolbar-function.
         MOVE SPACE TO ls_toolbar-disabled.
         MOVE  icon_system_save TO ls_toolbar-icon.
         MOVE 'Save data' TO ls_toolbar-quickinfo.
         APPEND ls_toolbar TO e_object->mt_toolbar.
         CLEAR ls_toolbar.
         MOVE  0 TO ls_toolbar-butn_type.
         MOVE 'EDIT' TO ls_toolbar-function.
         MOVE  SPACE TO ls_toolbar-disabled.
         MOVE  icon_toggle_display_change TO ls_toolbar-icon.
         MOVE 'Edit data' TO ls_toolbar-quickinfo.
         MOVE  'EDIT' TO ls_toolbar-text.
         APPEND ls_toolbar TO e_object->mt_toolbar.
         CLEAR ls_toolbar.
         MOVE  0 TO ls_toolbar-butn_type.
         MOVE 'VERW' TO ls_toolbar-function.
         MOVE  SPACE TO ls_toolbar-disabled.
         MOVE   icon_businav_process to ls_toolbar-icon.
         MOVE 'Verw.' TO ls_toolbar-quickinfo.
         MOVE  'VERW' TO ls_toolbar-text.
         APPEND ls_toolbar TO e_object->mt_toolbar.
          CLEAR ls_toolbar.
         MOVE  0 TO ls_toolbar-butn_type.
         MOVE 'EXCEL' TO ls_toolbar-function.
         MOVE  SPACE TO ls_toolbar-disabled.
         MOVE  icon_xxl TO ls_toolbar-icon.
         MOVE 'Excel' TO ls_toolbar-quickinfo.
         MOVE  'EXCEL' TO ls_toolbar-text.
         APPEND ls_toolbar TO e_object->mt_toolbar.
       ENDMETHOD.
       METHOD verwerk.
          PERFORM verwerk IN PROGRAM (program).
          LEAVE PROGRAM.
      ENDMETHOD.
      METHOD dubbleklik.
      PERFORM dubbleklik IN PROGRAM (program)
        USING
            e_row
            e_column
            es_row_no.
      ENDMETHOD.
    ENDCLASS.
    Cheers
    Jimbo

    Hi Dinu,
    Before analysing ALV, please cross check the behaviour of the calling program.
    Is the control really going to the application server when you do all the above process?
    If so, when user makes some changes are they saved in the data base / affected the internal table which you are using for ALV?
    Regards
    Surya.

  • Error while printing ALV

    Hi,
    I am having an error occuring while i am printing my alv report and it is going to short dump. But i am getting the out put.
    The error message is                       
    "GETWA_NOT_ASSIGNED"     
    Program:  "SAPLKKBL " or "LKKBLF01 "
    In the form: "CHECKBOX_OUT"           
    Can anyone help me with this.
    Thanks...
    Dump Code:
                                                                                    Source code extract                                                                               
    009740     hide g_tabname.                                                            
    009750     if lflg_icon is initial.                                                   
    009760       write at (rs_fieldcat-outputlen) <hf> no-gap quickinfo                   
    009770                                                    rs_fieldcat-seltext.        
    009780     else.                                                                      
    009790       write at (rs_fieldcat-outputlen) <hf> as icon no-gap.                    
    009800     endif.                                                                     
    009810                                                                               
    009820     g_tabname = l_tabname.                                                     
    009830                                                                               
    009840     format hotspot off.                                                        
    009850                                                                               
    009860   endform.                               " HEADER_FIELD_OUT                    
    009870   *&                                                                     *     
    009880   *&      Form  CHECKBOX_OUT                                                   
    009890   *&                                                                     *     
    009900   *       text                                                           *     
    009910   *                                                                      *     
    009920   form checkbox_out using rs_layout type kkblo_layout                          
    009930                           r_tabname type stack-i_tabname                       
    009940                           r_sum type c.                                        
    009950     data: l_mark(1) type c.                                                    
    009960                                                                               
    009970     if not rs_layout-box_tabname is initial and                                
    009980            rs_layout-box_tabname ne r_tabname.                                 
    009990       format color off.                                                        
    010000       write at (2) space no-gap.                                               
    010010       exit.                                                                    
    010020     endif.                                                                     
    010030                                                                               
    >     if not r_sum is initial or <box> = '-'.                                    
    010050       format color off.                                                        
    010060       write at (2) space no-gap.                                               
    010070     else.                                                                      
    010080       format color off.                                                        
    010090       if <box> = ' ' or <box> = 'X'.                                           
    010100         g_mark = <box>.                                                        
    010110         if rs_layout-no_input = 'X'.                                           
    010120           write g_mark as checkbox no-gap input off.                           
    010130         else.                                                                  
    010140           write g_mark as checkbox no-gap.                                     
    010150         endif.                                                                 
    010160         write at (1) space no-gap.

    Looks like a coding problem,  have you looked for a fix on OSS?
    Regards,
    Rich Heilman

  • ALV - access to protected method

    Hello,
    I have a object from class "CL_GUI_ALV_GRID" and want to change the protected attribute "EVT_DELAYED_CHANGE_SELECTION     Constant     Protected" with the method
        CALL METHOD alv_grid->SET_DELAY_CHANGE_SELECTION
          EXPORTING
            time = lv_delay.
    How can I access this protected attribute?
    Thanks in advance,
    Holger

    This will do what you want
    Trick is to define a sub class inheriting the super class where the protected attributes and methods exist in - then you can access the protected methods and attributes.
    If you do this don't forget to call  the SUPER CONSTRUCTOR (of the class you are inheriting from) in your constructor method. Code example shown below.
    Here I want the original and modified table of an alv grid but you can adapt this code to whatever you need.
    Hope it helps.
    create blank screen (100) with a custom container CCONTAINER1 and the following scren logic in it
    PROCESS BEFORE OUTPUT.
    MODULE STATUS_0100.
    PROCESS AFTER INPUT.
    MODULE USER_COMMAND_0100.
    now look at the code here. Note text in Bold
    PROGRAM zdynfieldcat.
    class zcltest definition  deferred.  "For field symbol reference.
    Simple test of dynamic ITAB with user defined (not ddic) fields
    Build dynamic fcat
    Table structure obtained via new RTTI functionality
    use ALV grid to display and edit.
    Create a blank screen 100 with a custom container called CCONTAINER1.
    James Hawthorne
    Define field symbols as these can't be defined in classes
    field-symbols: <dyn_table> type standard table,
                   <g2> type ref to zcltest,
                   <g1> type ref to cl_gui_custom_container,
                   <actual_tab> type standard table,
                   <outtab> type table,
                   <fs1> type ANY,
                   <FS2> TYPE TABLE,
                   <fs3> type table,
                   <fs4> type table,
                   <fs5> type  table.
    <b>class zcltest definition inheriting from cl_gui_alv_grid.
    define this as a subclass so we can access the protected attributes
    of the superclass cl_gui_alv_grid</b>
      public section.
        types:  g4 type ref to cl_gui_custom_container.
        types:  g3  type ref to cl_alv_changed_data_protocol.
        data:   i_parent type g4,
                lr_rtti_struc TYPE REF TO cl_abap_structdescr, "RTTI
        zog like line of lr_rtti_struc->components. "RTTI
        types: struc like zog.
        types: struc1 type table of struc.
        methods:
           constructor
               importing i_parent type g4,
           disp_tab
               importing  p_er_data_changed type g3,
           create_dynamic_fcat
               importing zogt type struc1
               exporting it_fldcat type lvc_t_fcat.
    Protected section.
       data: stab type ref to data,
            wa_it_fldcat type lvc_s_fcat,
            c_index type sy-index.
    endclass.
    <b>class zcltest implementation.
      METHOD constructor.
        CALL METHOD super->constructor
          EXPORTING
            i_appl_events = 'X'
            i_parent      = i_parent.
          endmethod
    method disp_tab.
    *mt_outtab is the data table held as a protected attribute
    in class cl_gui_alv_grid.
        assign me->mt_outtab->* TO <outtab>. "Original data
        assign p_er_data_changed->mp_mod_rows TO <FS1>.
        stab = p_er_data_changed->mp_mod_rows.
        assign p_er_data_changed->mt_inserted_rows to <fs3>.
        assign p_er_data_changed->mt_deleted_rows to <fs4>.
        assign p_er_data_changed->mt_mod_cells to <fs5>.
        assign stab->* TO <fs2>.
    do whatever you want with <outtab>
    contains data BEFORE changes each time.
    Note that NEW (Changed) table has been obtained already by
    call to form check_data USING P_ER_DATA_CHANGED
    TYPE REF TO CL_ALV_CHANGED_DATA_PROTOCOL.
    Entered data is in table defined by <fs2>
    In this method you can compare original and changed data.
    Easier than messing around with individual cells.
    do what you want with data in <fs2> validate / update / merge etc
      endmethod.</b>
      method create_dynamic_fcat.
        loop at zogt into zog.
          c_index = c_index + 1.
          clear wa_it_fldcat.
          wa_it_fldcat-fieldname = zog-name .
          wa_it_fldcat-datatype = zog-type_kind.
          wa_it_fldcat-inttype = zog-type_kind.
          wa_it_fldcat-intlen = zog-length.
          wa_it_fldcat-decimals = zog-decimals.
          wa_it_fldcat-coltext = zog-name.
          wa_it_fldcat-lowercase = 'X'.
          if c_index eq 2.
            wa_it_fldcat-emphasize = 'C411'.
          endif.
          if c_index eq 3.
            wa_it_fldcat-emphasize = 'C511'.
          endif.
          append wa_it_fldcat to it_fldcat .
        endloop.
      endmethod.                    "create_dynamic_fcat
    endclass.                    "zcltest IMPLEMENTATION
    class lcl_grid_event_receiver definition.
      public section.
    methods:
        handle_data_changed
             for event data_changed of zcltest
            for event data_changed of cl_gui_alv_grid
             importing  er_data_changed,
        toolbar
             for event toolbar of zcltest
             importing e_object
             e_interactive,
        user_command
             for event user_command of zcltest
             importing e_ucomm.
    endclass.
    class lcl_grid_event_receiver implementation.
      method handle_data_changed.
    code whatever required after data entry.
    various possibilites here as you can get back Cell(s) changed
    columns or the entire updated table.
    Data validation is also possible here.
        call method <g2>->disp_tab
          EXPORTING
            p_er_data_changed = er_data_changed.
      endmethod.                    "handle_data_changed
      method toolbar.
        data : ls_toolbar type stb_button.
        clear ls_toolbar.
        move 0 to ls_toolbar-butn_type.
        move 'EDIT' to ls_toolbar-function.
        move space to ls_toolbar-disabled.
        move 'Edit' to ls_toolbar-text.
        move icon_change_text to ls_toolbar-icon.
        move 'Click2Edit' to ls_toolbar-quickinfo.
        append ls_toolbar to e_object->mt_toolbar.
        clear ls_toolbar.
        move 0 to ls_toolbar-butn_type.
        move 'UPDA' to ls_toolbar-function.
        move space to ls_toolbar-disabled.
        move 'Update' to ls_toolbar-text.
        move icon_system_save to ls_toolbar-icon.
        move 'Click2Update' to ls_toolbar-quickinfo.
        append ls_toolbar to e_object->mt_toolbar.
        clear ls_toolbar.
        move 0 to ls_toolbar-butn_type.
        move 'EXIT' to ls_toolbar-function.
        move space to ls_toolbar-disabled.
        move 'Exit' to ls_toolbar-text.
        move icon_system_end to ls_toolbar-icon.
        move 'Click2Exit' to ls_toolbar-quickinfo.
        append ls_toolbar to e_object->mt_toolbar.
      endmethod.                    "toolbar
      method user_command.
        case e_ucomm .
          when 'EDIT'. "From Tool bar
            perform set_input.
            perform init_grid.
          when 'UPDA'. "From Tool bar
            perform refresh_disp.
            perform update_table.
          when 'EXIT'. "From Tool bar
            leave program.
        endcase.
      endmethod.                    "user_command
    endclass.                    "lcl_grid_event_receiver IMPLEMENTATION
    program data
    include <icon>.
    define any old internal structure NOT in DDIC
    types: begin of s_elements,
    anyfield1(20) type c,
    anyfield2(20) type c,
    anyfield3(20) type c,
    anyfield4(20) type c,
    anyfield5(11) type n,
    end of s_elements.
    data: wa_element type s_elements,
    wa_data type s_elements.
    Note new RTTI functionality allows field detail retrieval
    at runtime for dynamic tables.
    data:
            grid1 type ref to zcltest,
            grid_handler type ref to lcl_grid_event_receiver,
            c_dec2 type s_elements-anyfield5,
            wa_it_fldcat type lvc_s_fcat,
            it_fldcat type lvc_t_fcat,
            lr_rtti_struc TYPE REF TO cl_abap_structdescr, "RTTI
            lt_comp TYPE cl_abap_structdescr=>component_table,"RTTI
            ls_comp LIKE LINE OF lt_comp, "RTTI
            zog like line of lr_rtti_struc->components,  "RTTI
            struct_grid_lset type lvc_s_layo,
            l_valid type c,
            new_table type ref to data.
            types: struc like zog.
    data:  zogt type table of struc,
            grid_container1 type ref to cl_gui_custom_container,
            g_event_receiver type ref to lcl_grid_event_receiver,
            ok_code like sy-ucomm,
            i4 type int4.
    start-of-selection.
      call screen 100.
    module status_0100 output.
      if grid_container1 is initial.
        create object grid_container1
        exporting
        container_name = 'CCONTAINER1'.
        assign grid_container1 to <g1>.
        create object grid1
         exporting i_parent = grid_container1.
    we need reference to this instance so we can use
    Methods etc of zcltest class and alv (superclass)
    in our event receiver class.
         assign grid1 to <g2>.
        create object grid_handler.
        set handler:
        grid_handler->user_command for grid1,
        grid_handler->toolbar for grid1,
        grid_handler->handle_data_changed for grid1.
    Get the Internal table structure
        lr_rtti_struc ?= cl_abap_structdescr=>describe_by_data( wa_data ).
    Build field catalog just use basic data here
    colour specific columns as well
        zogt[] = lr_rtti_struc->components.
          call method grid1->create_dynamic_fcat
          EXPORTING
            zogt      = zogt
          IMPORTING
            it_fldcat = it_fldcat.
    Create dynamic internal table and assign to field symbol.
    Use dynamic field catalog just built.
      call method cl_alv_table_create=>create_dynamic_table
        EXPORTING
          it_fieldcatalog = it_fldcat
        IMPORTING
          ep_table        = new_table.
      assign new_table->* to <dyn_table>.
        perform populate_dynamic_itab.
        perform init_grid.
        perform register_enter_event.
    set off ready for input initially
        i4 = 0.
        call method grid1->set_ready_for_input
          EXPORTING
            i_ready_for_input = i4.
      endif.
    endmodule.                    "status_0100 OUTPUT
    module user_command_0100 input.
    *PAI not needed in OO ALV anymore as User Commands are handled as events
    *in method user_command.
    *we can also get control if the Data entered and the ENTER is pressed by
    *raising an event.
    Control then returns to method handle_data_changed.
    endmodule.                    "user_command_0100 INPUT
    form populate_dynamic_itab.
    load up a line of the dynamic table
      c_dec2 = c_dec2 + 11.
      wa_element-anyfield1 = 'Tabbies'.
      wa_element-anyfield2 = 'ger.shepards'.
      wa_element-anyfield3 = 'White mice'.
      wa_element-anyfield4 = 'Any old text'.
      wa_element-anyfield5 = c_dec2.
      append wa_element to <dyn_table>.
    endform.                    "populate_dynamic_itab
    form exit_program.
      call method grid_container1->free.
      call method cl_gui_cfw=>flush.
      leave program.
    endform.                    "exit_program
    form refresh_disp.
      call method grid1->refresh_table_display.
    endform.                    "refresh_disp
    form update_table.
    The dynamic table here is the changed table read from the grid
    after user has changed it
    Data can be saved to DB or whatever.
      loop at <dyn_table> into wa_element.
    do what you want with the data here
      endloop.
    switch off edit mode again for next function
      i4 = 0.
      call method grid1->set_ready_for_input
        EXPORTING
          i_ready_for_input = i4.
    endform.                    "update_table
    form set_input.
      i4 = 1.
      call method grid1->set_ready_for_input
        EXPORTING
          i_ready_for_input = i4.
    endform.                    "set_input
    form switch_input.
      if i4 = 1.
        i4 = 0.
      else.
        i4 = 1.
      endif.
      call method grid1->set_ready_for_input
        EXPORTING
          i_ready_for_input = i4.
    endform.                    "switch_input
    form init_grid.
    Enabling the grid to edit mode,
      struct_grid_lset-edit = 'X'. "To enable editing in ALV
      struct_grid_lset-grid_title = 'Jimbos Test'.
       call method grid1->set_table_for_first_display
        EXPORTING
          is_layout       = struct_grid_lset
        CHANGING
          it_outtab       = <dyn_table>
          it_fieldcatalog = it_fldcat.
    endform.                    "init_grid
    form register_enter_event.
      call method grid1->register_edit_event
        EXPORTING
          i_event_id = cl_gui_alv_grid=>mc_evt_enter.
    Instantiate the event or it won't work.
      create object g_event_receiver.
      set handler g_event_receiver->handle_data_changed for grid1.
    endform.                    "register_enter_event

Maybe you are looking for

  • Tree component display problem when text too long???

    hi all whenever i use a tree component to display some sort of text, i run into problems when the width of the text being display for a node is larger than the width of the tree component. Given: Tree tree1 with Node node1 and Child Node child1 When

  • What program do I need to buy in order to cut and paste from Adobe

    I recieve drawings from architects in PDF form. I want to be able to select areas of the drawings copy and paste them to a seperate PDF or word doc to forward on to my vendors for pricing.

  • Message Processing Status

    Hi All, I have a Webservice to Proxy synchronous scenario in which I have to find out whether we can monitor the processing time in XI in order to give a specific response message to the sender when the processing takes longer than 45 Secs. This mean

  • Remove missing file warning

    I have some photos I want to edit - sequence, reject, sort etc - but not develop. The full catalog is on my desktop at the studio. I'm travelling right now with my laptop and have exported a catalog with those images to work on. Of course, when I ope

  • Add link for a script from Indesign menu

    Dear, Is it possible to add a new menu on Indesign top menu near help for exemple. And it is possible to lanche a script from it ? thanks !