IF g_custom_container IS INITIAL

IF g_custom_container IS INITIAL.
    CREATE OBJECT g_custom_container
       EXPORTING
          CONTAINER_NAME = 'CCCONTAINER'.
    CREATE OBJECT GRID1
       EXPORTING
         I_PARENT = g_custom_container.
ENDIF.
in the above code what for this line used.<b>
IF g_custom_container IS INITIAL</b>
and after excuting what is the value assigned to  g_custom_container.

Hi,
         Since container object generally contains your CONTROL objects like ALV etc you should create this object only once. If you create it in every ntry to your PBO then a new container is getting created and you will see a fresh screen every time which is wrong since you are working on the previous screen that screen should be preserved means this container object should exist so you create once and use it every time till you exit the program.
<b>
and after excuting what is the value assigned to g_custom_container.</b>
In your screen you would have created a custom container you are passing the name of your custom container in this create object statement.
Regards,
sesh
Message was edited by:
        Seshatalpasai Madala

Similar Messages

  • Hyperlink in OO-ALV to Sap-Business- Workplace-Dokuments

    Hello specialists,
    I  have implemented hyperlinks to an oo-based ALV-List
    ( please see sample code later ). Now we have the problem that these hyperlinks only work in a local network-area.
    But we have also foreign-departments on our SAP-system, that have no access to our network.
    Now the question: is it also possible to create hyperlinks
    assigned to SAP-Business-Workplace-documents ?
    Do you have a solution for this problem ?
    Thank' s in advance !
    Best regards !
    Oliver Perthen / Germany
    *& Modulpool         ZBWS_TESTSZENARIEN_LINK                           *
    INCLUDE Z_LINK_TOP                              .                      "
    *&      Module  STATUS_0100  OUTPUT
          text
    MODULE STATUS_0100 OUTPUT.
      SET PF-STATUS 'ZTEST'.
      SET TITLEBAR 'ZX'.
    ENDMODULE.                 " STATUS_0100  OUTPUT
    *&      Module  USER_COMMAND_0100  INPUT
          text
    MODULE USER_COMMAND_0100 INPUT.
      CASE SY-UCOMM.
        WHEN 'BACK'.
          LEAVE TO SCREEN 0.
        WHEN 'CANCEL' OR 'ABORT'.
          LEAVE PROGRAM.
      ENDCASE.
    ENDMODULE.                 " USER_COMMAND_0100  INPUT
    *&      Module  create_object  OUTPUT
          text
    MODULE CREATE_OBJECT OUTPUT.
      CHECK G_CUSTOM_CONTAINER IS INITIAL.
      CREATE OBJECT G_CUSTOM_CONTAINER EXPORTING
      CONTAINER_NAME = 'CONTAINER'.
      CHECK ALV_GRID IS INITIAL.
      CREATE OBJECT ALV_GRID EXPORTING
      I_PARENT = G_CUSTOM_CONTAINER.
    ENDMODULE.                 " create_object  OUTPUT
    *&      Module  read_data  OUTPUT
          text
    MODULE READ_DATA OUTPUT.
      SELECT * FROM ZBWS_TESTSZENARI INTO TABLE ZTEST WHERE TESTER EQ
    'RW#9952'.
    ENDMODULE.                 " read_data  OUTPUT
    *&      Module  transfer_to_alv  OUTPUT
          text
    MODULE TRANSFER_TO_ALV OUTPUT.
      REPORT = SY-REPID.
      CLEAR LAYOUT.
      CLEAR FIELDCAT_D.
      REFRESH FIELDCAT_D.
      CALL FUNCTION 'LVC_FIELDCATALOG_MERGE'
           EXPORTING
                I_STRUCTURE_NAME   = 'ZBWS_TESTSZENARI'
                I_BUFFER_ACTIVE    = 'X'
                I_BYPASSING_BUFFER = 'X'
           CHANGING
                CT_FIELDCAT        = FIELDCAT_D[].
      FIELDCAT-FIELDNAME = 'HL_FNAME'.
      FIELDCAT-NO_OUT = 'X'.
      APPEND FIELDCAT TO FIELDCAT_D.
      LOOP AT FIELDCAT_D INTO FIELDCAT.
        FIELDCAT-SELTEXT = FIELDCAT-FIELDNAME.
        FIELDCAT-REPTEXT = FIELDCAT-FIELDNAME.
        CASE FIELDCAT-FIELDNAME.
          WHEN 'TESTDATEI'.
            FIELDCAT-WEB_FIELD = 'HL_FNAME'.
        ENDCASE.
        MODIFY FIELDCAT_D FROM FIELDCAT.
      ENDLOOP.
      LOOP AT ZTEST.
        ZTEST-HL_FNAME = SY-TABIX.
        LS_HYPE-HANDLE = SY-TABIX.
        LS_HYPE-HREF = ZTEST-TESTDATEI.
        APPEND LS_HYPE TO GT_HYPETAB.
        MODIFY ZTEST.
      ENDLOOP.
      LAYOUT-NO_KEYFIX = 'X'.  " Schlüssel nicht Fixieren
      LAYOUT-INFO_FNAME = 'COLOR'."Farbstufen
      LAYOUT-SEL_MODE = 'D'.   "Markierungsspalte
      LAYOUT-SGL_CLK_HD = 'X'. "Sortierung per Click
      LAYOUT-CWIDTH_OPT = 'X'.
      CALL METHOD ALV_GRID->SET_TABLE_FOR_FIRST_DISPLAY
       EXPORTING
        I_STRUCTURE_NAME = 'ZBWS_TESTSZENARI'
        IS_LAYOUT = LAYOUT
        I_SAVE = 'A'
        IT_HYPERLINK = GT_HYPETAB
       CHANGING
      IT_OUTTAB = ZTEST[]
      IT_FIELDCATALOG = FIELDCAT_D.
    ENDMODULE.                 " transfer_to_alv  OUTPUT

    Hi.
    I'll try it.
    Thanks.

  • Abour report containing classes - urgent pls

    hi to all,
                i have to study this report and analyse output coming how.  iam in debugging observed that value(total) last column in the output giving some value in debugging but in output it is giving some other value.  can any one pls help me.
    like if in debugging it is giving total-as -68.13 but in grid display it is displaying as 473.10 like.
    REPORT ZFIRD035  MESSAGE-ID zfi_e1
                     NO STANDARD PAGE HEADING
                     LINE-COUNT 58
                     LINE-SIZE 200.
    Author.......:*
    Date Created.: Aug 21, 2006
    Request #....:                                                       *
    Purpose......: This program summarizes accounting journal entries
                   by biller. The biller is recognized by the first three
                   chararcters of the reference field.
    Inputs.......:
    Outputs......:                                                       *
    Selections...:                                                       *
    Logical D/B..:                                                       *
    Includes.....:                                                       *
    Predefine a local class for event handling to allow the
    declaration of a reference variable before the class is defined.
    CLASS lcl_event_receiver DEFINITION DEFERRED.
    TABLES:
       bkpf,                               "Accounting document header
       bseg,                               "Accounting document segment
       zmapzce1.                           "CostElement to ZCE1COPA Mapping
    TYPES: BEGIN OF disp_tab ,             "Internal Table D_TAB
          usnam   LIKE bkpf-usnam,         "User Id
          blart   LIKE bkpf-blart,         "Document type
          bukrs   LIKE bkpf-bukrs,         "Company code
          bldat   LIKE bkpf-bldat,         "Date of the document
          xblnr   LIKE bkpf-xblnr,         "refernce number
          belnr   LIKE bkpf-belnr,         "Accounting document number
          buzei   LIKE bseg-buzei,         "Line Item Number
          prctr   LIKE bseg-prctr,         "Profit center
          kostl   LIKE bseg-kostl,         "Cost center
          hkont   LIKE bseg-hkont,         "Account number
          matnr   LIKE bseg-matnr,         "Product code
          aufnr   LIKE bseg-aufnr,         "Internal order
          projk   LIKE bseg-projk,         "WBS Element
          budat   LIKE bkpf-budat,         "Posting date
          bschl   LIKE bseg-bschl,         "Posting Key
          dmbtr   LIKE bseg-dmbtr,         "Amount in document currency
          sgtxt   LIKE bseg-sgtxt,         "Description
          zuonr   LIKE bseg-zuonr,         "Allocation
          shkzg   LIKE bseg-shkzg,         "Debit/Credit Indicator
    END OF disp_tab.
    DATA: gv_prdha_all   LIKE mara-prdha.
    FIELD-SYMBOLS: .
    DATA: BEGIN OF   gv_prdha,
            wwph1(5)  TYPE c,
            wwph2(5)  TYPE c,
            wwph3(8)  TYPE c.
    DATA: END  OF   gv_prdha.
    DATA  save_matnr LIKE mara-matnr.
    DATA: d_tab TYPE disp_tab OCCURS 0 WITH HEADER LINE.
    TYPES:  BEGIN OF out_tab2.                      "Internal Table out_TAB
            INCLUDE STRUCTURE zfirevje.
    TYPES:  END   OF out_tab2.
    DATA: BEGIN OF zfirevje OCCURS 50.
            INCLUDE STRUCTURE zfirevje.
    DATA: END   OF zfirevje.
    DATA: ok_code     LIKE sy-ucomm,
          gt_jesum    TYPE TABLE OF zfirevje,
          gt_jesum2   TYPE zfirevje OCCURS 100 WITH HEADER LINE,
          g_container TYPE scrfname VALUE 'ZFIRD035_0100_CONT1',
    Start of Change - DR1K901005 - JIRA#: ENT-93----
    *>>> Added:
        Field catalog table
          git_fieldcat TYPE lvc_t_fcat,  "field catalog table
    End of Change - DR1K901005 - JIRA#: ENT-93----
          grid1  TYPE REF TO cl_gui_alv_grid,
          g_custom_container TYPE REF TO cl_gui_custom_container,
          event_receiver TYPE REF TO lcl_event_receiver.
    lcl_event_receiver (Implementation)
    LOCAL CLASSES: Definition
    *===============================================================
    class lcl_event_receiver: local class to handle event DOUBLE_CLICK
                              and CLOSE.
    Definition:
    ~~~~~~~~~~~
    CLASS lcl_event_receiver DEFINITION.
      PUBLIC SECTION.
        METHODS:
        handle_double_click
            FOR EVENT double_click OF cl_gui_alv_grid
                IMPORTING e_row e_column.
      PRIVATE SECTION.
       DATA: dialogbox_status TYPE c.  "'X': does exist, SPACE: does not ex.
    ENDCLASS.
    lcl_event_receiver (Definition)
    *===============================================================
    LOCAL CLASSES: Implementation
    *===============================================================
    class c_event_receiver (Implementation)
    In this example, only event DOUBLE_CLICK is caught
    CLASS lcl_event_receiver IMPLEMENTATION.
    §3.At doubleclick(1): The event DOUBLE_CLICK provides
       parameters of the clicked row and column.
       Use row parameter to select a line of the
       corresponding internal table.
      METHOD handle_double_click.
        DATA: ls_jesum  LIKE LINE OF gt_jesum.
    read selected row from internal table gt_sflight
       read table gt_jesum index e_row-index into ls_jesum.
       call function 'REMD_SHOW_MASTER_DATA'
           exporting
                i_objnr                 = ls_jesum-recnobjnr
                  I_IMKEY                 =
                  I_INTRENO               =
                  I_CHANGE                = ' '
           exceptions
                unknown_type            = 1
                object_key_inconsistent = 2
                others                  = 3.
      ENDMETHOD.
    ENDCLASS.
    DATA: x_save,                          "for Parameter I_SAVE
          gs_layout  TYPE lvc_s_layo,
          gs_variant TYPE disvariant.      "for parameter IS_VARIANT
    DATA: BEGIN OF fieldnames OCCURS 25,
           fieldname(30)    TYPE c,        "download col names
          END OF fieldnames.
    DATA:
          program_name     LIKE sy-repid,   "Program Name for Call
          title_line_1     LIKE sy-title,   "Report Title Line 1
          title_line_2     LIKE sy-title,   "Report Title Line
          title_line_3     LIKE sy-title,   "Report Title Line
          sum_cdmbtr       LIKE bseg-dmbtr, "Sum credit amt for document
          sum_ddmbtr       LIKE bseg-dmbtr, "Sum debit amt for document
          total_cdmbtr     LIKE bseg-dmbtr, "Total credit amount
          total_ddmbtr     LIKE bseg-dmbtr, "Total debit amount
          ddmbtr           LIKE bseg-dmbtr, "Debit amount
          cdmbtr           LIKE bseg-dmbtr, "Credit amount
          dec_dmbtr(16)    TYPE p DECIMALS 2, "Amount in decimal format
          disp_prctr(5)    TYPE c,          "Work var for prctr
          gv_zuonr         LIKE bseg-zuonr, "Assignment field
          gv_shkzg         LIKE bseg-shkzg, "Dr/Cr Ind.
          gv_hkont         LIKE bseg-hkont, "Account nbr
          gv_amount        LIKE bseg-pswbt, "G/L amount
          gv_currncy       LIKE bseg-pswsl, "Currency
          gv_matnr         LIKE bseg-matnr, "Product
          BEGIN OF w_filename,
             w_directory(22) TYPE c,       "file directory name
             w_userid(7)     TYPE c,       "User Id
             w_filenm2(20)   TYPE c,       "file name continuation
          END OF w_filename.
    Selection Screen Options  ******************
    SELECTION-SCREEN BEGIN OF BLOCK rpt WITH FRAME TITLE text-003.
    SELECT-OPTIONS:  sbukrs  FOR  bkpf-bukrs OBLIGATORY,
                     sbelnr  FOR  bkpf-belnr,
                     sgjahr  FOR  bkpf-gjahr OBLIGATORY,
                     smonat  FOR  bkpf-monat OBLIGATORY,
                     sxblnr  FOR  bkpf-xblnr,
                     sprctr  FOR  bseg-prctr,
                    shkont  FOR  bseg-hkont.
                     shkont  FOR zmapzce1-saknr."G/L account number
    Start of Change - DR1K901005 - JIRA#: ENT-93----
    *>>> Removed:
    *SELECTION-SCREEN BEGIN OF LINE.
    *SELECTION-SCREEN            COMMENT 1(31) text-005.
    *PARAMETERS: p_pdtls         AS CHECKBOX DEFAULT ' '.         "flag
    *SELECTION-SCREEN END OF LINE.
    *SELECTION-SCREEN BEGIN OF LINE.
    *SELECTION-SCREEN            COMMENT 1(31) text-004.
    *PARAMETERS: p_hdtls         AS CHECKBOX DEFAULT ' '.         "flag
    *SELECTION-SCREEN END OF LINE.
    End of Change - DR1K901005 - JIRA#: ENT-93----
    SELECTION-SCREEN END OF BLOCK rpt.
    INITIALIZATION.
    init accounts
      MOVE 'I'             TO shkont-sign.
      MOVE 'EQ'            TO shkont-option.
    Start of Change - DR1K901005 - JIRA#: ENT-93----
    *>>> Removed:
    MOVE '0000200000'    TO shkont-low.
    MOVE '0000299999'    TO shkont-high.
    *>>> Added:
    MOVE '0000400100'    TO shkont-low.
    MOVE '0000400199'    TO shkont-high.
    End of Change - DR1K901005 - JIRA#: ENT-93----
    APPEND shkont.
    START-OF-SELECTION.
    set pf-status 'VDOC'.
      PERFORM get_je_data
         TABLES gt_jesum.
      IF sy-subrc  = 0.
        CALL SCREEN 100.
      ELSE.
        MESSAGE ID 'F5' TYPE 'S' NUMBER '194'.
      ENDIF.
    END-OF-SELECTION.
    *&      Form get_je_data
          loads the internal table for jesum
    FORM get_je_data TABLES gt_jesum STRUCTURE zfirevje.
      SELECT *
         FROM bkpf
         WHERE bukrs IN sbukrs
           AND belnr IN sbelnr
           AND gjahr IN sgjahr
           AND monat IN smonat
           AND xblnr IN sxblnr.
        PERFORM save_to_dtab.
        CLEAR: gv_zuonr, gv_shkzg, gv_amount,
               gv_hkont, gv_currncy, gv_matnr.
        SELECT   zuonr shkzg pswbt
                 pswsl hkont matnr
           INTO (gv_zuonr,   gv_shkzg, gv_amount,
                 gv_currncy, gv_hkont, gv_matnr)
           FROM bseg
           WHERE bukrs EQ bkpf-bukrs "IN sbukrs
           AND belnr   EQ bkpf-belnr "IN sbelnr
           AND gjahr   EQ bkpf-gjahr "IN sgjahr
           AND hkont   IN shkont
           AND prctr   IN sprctr.
          PERFORM save_to_outtab TABLES gt_jesum.
        ENDSELECT.
      ENDSELECT.
    ENDFORM.
          FORM SAVE_TO_DTAB                                            *
    FORM save_to_dtab.
      CLEAR d_tab.
      MOVE-CORRESPONDING bkpf TO d_tab.
      APPEND d_tab.
    ENDFORM.
          FORM SAVE_TO_OUTTAB                                            *
    FORM save_to_outtab TABLES gt_jesum STRUCTURE zfirevje.
      DATA:  tempamount  LIKE tdrxx-wrbtr,
             subacct(2)  TYPE c.
      CLEAR:  gt_jesum,  tempamount, subacct.
      IF d_tab-xblnr+0(1) = '@'.
        gt_jesum-zbiller   = d_tab-xblnr+1(2).
    Start of Change - DR1K901241 - JIRA#: ENT-102----
    *>>> Removed:
       gt_jesum-zcyclenbr = gv_zuonr+6(2).
    *>>> Added:
        gt_jesum-zcyclenbr = gv_zuonr+3(2).
        SELECT SINGLE zbillname
           INTO  gt_jesum-zbillname
           FROM  zbillers
           WHERE zbiller = gt_jesum-zbiller.
        IF sy-subrc <> 0.
           gt_jesum-zbillname = 'Non-biller entries'.
        ENDIF.
    End of Change - DR1K901241 - JIRA#: ENT-102----
      ELSE.
        gt_jesum-zbiller   = d_tab-xblnr+0(2).
        gt_jesum-zbillname = 'Non-biller entries'.
      ENDIF.
    *>>> Removed:  IES out now identified by biller @NX
    IF  gt_jesum-zbillname    = 'IES'.
      IF  gv_matnr         IS INITIAL.
        gt_jesum-zbillname      = 'IES-OUT'.
      ELSE.
        gt_jesum-zbillname      = 'IES-IN'.
      ENDIF.
    ENDIF.
    Start of Change - DR1K901241 - JIRA#: ENT-102----
    *>>> Removed:
    gt_jesum-zruntype  = gv_zuonr+3(2).
    *>>> Added:
      gt_jesum-zruntype  = gv_zuonr(2).
    End of Change - DR1K901241 - JIRA#: ENT-102----
      IF d_tab-xblnr+0(1) = '@'.
        CASE gt_jesum-zruntype.
          WHEN 'RB'.     gt_jesum-zruntype_desc = 'Billed'.
          WHEN 'UB'.     gt_jesum-zruntype_desc = 'Unbilled'.
          WHEN OTHERS.   gt_jesum-zruntype_desc = 'Other bller entries'.
        ENDCASE.
      ELSE.
        gt_jesum-zruntype_desc = 'Non-biller entry'.
      ENDIF.
      IF gv_shkzg    = 'H'.
        tempamount =  gv_amount * -1.
      ELSE.
        tempamount =  gv_amount.
      ENDIF.
      subacct  =   gv_hkont+8(2).
      CASE subacct.
        WHEN '00'.                "Gross Billing
          gt_jesum-vvgrb001 = tempamount.
        WHEN '80'.                "Accruals
          gt_jesum-vvbaa001 = tempamount.
        WHEN '85'.                "Reversals
          gt_jesum-vvrba001 = tempamount.
        WHEN '15'.                "Discount
          gt_jesum-vvdis001 = tempamount.
        WHEN '81'.                "Discount Accruals
          gt_jesum-vvdac001 = tempamount.
        WHEN '86'.                "Discount Reversals
          gt_jesum-vvrda001 = tempamount.
        WHEN '70'.                "Other
          gt_jesum-vvoth001 = tempamount.
        WHEN '65'.                "Sale Allowance
          gt_jesum-vvsa001  = tempamount.
        WHEN '60'.                "Reba  tes
          gt_jesum-vvrab001 = tempamount.
        WHEN '10'.                "Adjustments
          gt_jesum-vvadj001 = tempamount.
        WHEN '75'.                "Manual Bils
          gt_jesum-vvman001 = tempamount.
        WHEN '20'.                "Inbound Settlements
          gt_jesum-vvinb001  = tempamount.
      ENDCASE.
      gt_jesum-total = tempamount.
      gt_jesum-pswsl = gv_currncy.
    Start of Change - DR1K901005 - JIRA#: ENT-93----
    *>>> Removed:
    IF p_pdtls = 'X' OR p_hdtls = 'X'.
       PERFORM get_product_hierarchy
               USING     gv_matnr
               CHANGING  gt_jesum-matnr
                         gt_jesum-wwph1
                         gt_jesum-wwph2
                         gt_jesum-wwph3.
    ENDIF.
    End of Change - DR1K901005 - JIRA#: ENT-93----
      COLLECT gt_jesum.
    SORT gt_jesum BY zbiller zruntype.
    ENDFORM.
          MODULE PBO OUTPUT                                             *
    MODULE pbo OUTPUT.
      SET PF-STATUS 'MAIN100'.
      IF g_custom_container IS INITIAL.
        CREATE OBJECT g_custom_container
               EXPORTING container_name = g_container
            EXCEPTIONS
                cntl_error = 1
                cntl_system_error = 2
                create_error = 3
                lifetime_error = 4
                lifetime_dynpro_dynpro_link = 5.
        CREATE OBJECT grid1
               EXPORTING i_parent = g_custom_container.
        CALL METHOD grid1->get_frontend_layout
         IMPORTING
            es_layout   = gs_layout.
        gs_layout-cwidth_opt = 'X'.
        CALL METHOD grid1->set_3d_border
         EXPORTING
          border  =   1.
        gs_layout-grid_title  =
          'Revenue journal entry summary by biller and type'(100).
        x_save = 'A'.
        gs_variant = '/ZFIRD035'.
    Start of Change - DR1K901005 - JIRA#: ENT-93----
    *>>> Added:
        PERFORM prepare_field_catalogue.
    End of Change - DR1K901005 - JIRA#: ENT-93----
        CALL METHOD grid1->set_table_for_first_display
             EXPORTING
    Start of Change - DR1K901005 - JIRA#: ENT-93----
    *>>> Removed:
                      i_structure_name = 'ZFIREVJE'
    End of Change - DR1K901005 - JIRA#: ENT-93----
                       is_variant       = gs_variant
                       is_layout        = gs_layout
                       i_save           = x_save
             CHANGING  it_outtab        = gt_jesum
    Start of Change - DR1K901005 - JIRA#: ENT-93----
    *>>> Added:
                       it_fieldcatalog  = git_fieldcat[]
    End of Change - DR1K901005 - JIRA#: ENT-93----
    ->Create Object to receive events and link them to handler methods.
    When the ALV Control raises the event for the specified instance
    the corresponding method is automatically called.
        CREATE OBJECT event_receiver.
        SET HANDLER event_receiver->handle_double_click FOR grid1.
    *CALL METHOD grid1->refresh_table_display
         EXPORTING
            IS_STABLE    = <structure of type LVC_S_STBL >
            I_SOFT_REFRESH    = 'X'.
      ENDIF.
    ENDMODULE.
          MODULE PAI INPUT                                              *
    MODULE pai INPUT.
      to react on oi_custom_events:
      DATA: lt_t_row      TYPE  lvc_t_row,
            wa_t_row      LIKE  LINE OF lt_t_row,
            ls_jesum      LIKE  LINE OF gt_jesum.
      CALL METHOD cl_gui_cfw=>dispatch.
      CASE ok_code.
        WHEN 'EXIT'.
          PERFORM exit_program.
        WHEN 'BACK'.
         PERFORM exit_listing.
        WHEN OTHERS.
        do nothing
      ENDCASE.
      CLEAR ok_code.
    ENDMODULE.
          FORM EXIT_PROGRAM                                             *
    FORM exit_program.
      CALL METHOD g_custom_container->free.
      CALL METHOD cl_gui_cfw=>flush.
      LEAVE PROGRAM.
    ENDFORM.
    *&      Form  exit_Listing
          text
    -->  p1        text
    <--  p2        text
    FORM exit_listing.
      CALL METHOD g_custom_container->free.
      CALL METHOD cl_gui_cfw=>flush.
      LEAVE TO TRANSACTION 'ZF06'.
    ENDFORM.                               " exit_Listing
    *&      Form  get_product_hierarchy
          text
         -->P_GV_MATNR  text
         <--P_GT_WWPH1  text
         <--P_GT_WWPH2  text
         <--P_GT_WWPH3  text
    FORM get_product_hierarchy USING    p_gv_matnr
                               CHANGING p_gt_matnr
                                        p_gt_wwph1
                                        p_gt_wwph2
                                        p_gt_wwph3.
      IF p_gv_matnr  = gv_prdha_all.
          ENDIF.
        ENDSELECT.
      ELSE.
      ENDIF.
    Start of Change - DR1K901005 - JIRA#: ENT-93----
    *>>> Removed:
    IF p_pdtls = 'X'.
       p_gt_matnr = p_gv_matnr.
    ENDIF.
    IF p_hdtls = 'X'.
       p_gt_wwph1 = gv_prdha-wwph1.
       p_gt_wwph2 = gv_prdha-wwph2.
       p_gt_wwph3 = gv_prdha-wwph3.
    ENDIF.
    End of Change - DR1K901005 - JIRA#: ENT-93----
    ENDFORM.                    " get_product_hierarchy
    Start of Change - DR1K901005 - JIRA#: ENT-93----
    *>>> Added:
          FORM prepare_summary_catalogue
          Prepare catalogue for Report
    FORM prepare_field_catalogue.
      DATA: lwa_fieldcat TYPE lvc_s_fcat.
      REFRESH: git_fieldcat.
      CLEAR git_fieldcat.
      CALL FUNCTION 'LVC_FIELDCATALOG_MERGE'
        EXPORTING
        I_BUFFER_ACTIVE              =
          I_STRUCTURE_NAME             = 'ZFIREVJE'
        I_CLIENT_NEVER_DISPLAY       = 'X'
        I_BYPASSING_BUFFER           =
        CHANGING
          ct_fieldcat                  = git_fieldcat
        EXCEPTIONS
          INCONSISTENT_INTERFACE       = 1
          PROGRAM_ERROR                = 2
          OTHERS                       = 3
      IF sy-subrc <> 0.
        MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
           WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
      ENDIF.
    Do not display Material, ProH1, ProH2, and ProHLe3.
      READ TABLE git_fieldcat INTO lwa_fieldcat
           WITH KEY fieldname = 'MATNR'.
      lwa_fieldcat-no_out = 'X'.
      MODIFY git_fieldcat FROM lwa_fieldcat INDEX sy-tabix.
      READ TABLE git_fieldcat INTO lwa_fieldcat
           WITH KEY fieldname = 'WWPH1'.
      lwa_fieldcat-no_out = 'X'.
      MODIFY git_fieldcat FROM lwa_fieldcat INDEX sy-tabix.
      READ TABLE git_fieldcat INTO lwa_fieldcat
           WITH KEY fieldname = 'WWPH2'.
      lwa_fieldcat-no_out = 'X'.
      MODIFY git_fieldcat FROM lwa_fieldcat INDEX sy-tabix.
      READ TABLE git_fieldcat INTO lwa_fieldcat
           WITH KEY fieldname = 'WWPH3'.
      lwa_fieldcat-no_out = 'X'.
      MODIFY git_fieldcat FROM lwa_fieldcat INDEX sy-tabix.
    ENDFORM.                    "prepare_field_catalogue
    End of Change - DR1K901005 - JIRA#: ENT-93----

    Hi,
    I would suggest that you post this on the ABAP forum.
    From a functional point of view is there any exchange rate involved that is converting the field to the local currency?
    Steve B

  • Excel fiel from ALV report

    Hi Gurus,
        is der any way to download data from ALV report to excel sheet depending on  layout set dyanmically.
      I mean to say that if I choose a layout then data has to transfer to excel sheet according to layout fields automaticaly.

    I think this can be done by oops ALV , are u using reusealv F.M to call output in ALV ?
    Try the below kind of ALV
    IN PBO -
    >
    SET PF-STATUS 'PROJREP'.
    SET TITLEBAR text-046.
    DATA: g_container TYPE scrfname VALUE 'ALV',
          g_grid1  TYPE REF TO cl_gui_alv_grid,
          g_custom_container TYPE REF TO cl_gui_custom_container.
    IF g_custom_container IS INITIAL.
        CREATE OBJECT g_custom_container
               EXPORTING container_name = g_container.  (Name of the container )
    CREATE OBJECT g_grid1
               EXPORTING i_parent = g_custom_container.
    PERFORM create_field_catalog_ce
    CALL METHOD g_grid1->set_frontend_fieldcatalog
          EXPORTING
            it_fieldcatalog = t_fcat_ce.
    ALL METHOD g_grid1->set_table_for_first_display
          EXPORTING
            i_structure_name = 'ST_DISPLAY'
          CHANGING
            it_outtab        = t_display_io
            it_fieldcatalog  = t_fcat_ce.
    ->Create Object to receive events and link them to handler methods.
    When the ALV Control raises the event for the specified instance
    the corresponding method is automatically called.
        CREATE OBJECT g_event_receiver.
        SET HANDLER g_event_receiver->handle_double_click FOR g_grid1.
      ENDIF.
      CALL METHOD cl_gui_control=>set_focus
        EXPORTING
          control = g_grid1.
    IN PAI -->
    CALL METHOD cl_gui_cfw=>dispatch.

  • How to get the multiple  lines on the header part in ALV

    HI all,
    In my program i am using the ALV- Grid functionality through methods. I have 2 different layouts in the same screen , for this i have 2 containers and i am displaying the title through the gird title now i need to add the few more lines under the title .
    Please suggest me, how can i proceede now.
    Thanks
    Giridhar

    Hi,
    check this sample code, i did it using splitter container. check it, it is weel documented to know what are required ....
    REPORT  ZTEST_ALV_TOP    MESSAGE-ID ZZ                           .
    DATA: G_GRID TYPE REF TO CL_GUI_ALV_GRID.
    DATA: L_VALID TYPE C,
          V_FLAG,
          V_DATA_CHANGE,
          V_ROW TYPE LVC_S_ROW,
          V_COLUMN TYPE LVC_S_COL,
          V_ROW_NUM TYPE LVC_S_ROID.
    DATA: IT_ROW_NO TYPE LVC_T_ROID,
          X_ROW_NO TYPE LVC_S_ROID.
    DATA:BEGIN OF  ITAB OCCURS 0,
         VBELN LIKE LIKP-VBELN,
         POSNR LIKE LIPS-POSNR,
         CELLCOLOR TYPE LVC_T_SCOL, "required for color
         DROP(10),
         END OF ITAB.
    "The Below Definitions Must.....
    DATA:
    * Reference to document
           DG_DYNDOC_ID       TYPE REF TO CL_DD_DOCUMENT,
    * Reference to split container
           DG_SPLITTER          TYPE REF TO CL_GUI_SPLITTER_CONTAINER,
    * Reference to grid container
           DG_PARENT_GRID     TYPE REF TO CL_GUI_CONTAINER,
    * Reference to html container
           DG_HTML_CNTRL        TYPE REF TO CL_GUI_HTML_VIEWER,
    * Reference to html container
           DG_PARENT_HTML     TYPE REF TO CL_GUI_CONTAINER.
    "up to here
    *       CLASS lcl_event_handler DEFINITION
    CLASS LCL_EVENT_HANDLER DEFINITION .
      PUBLIC SECTION .
        METHODS:
    **Hot spot Handler
        HANDLE_HOTSPOT_CLICK FOR EVENT HOTSPOT_CLICK OF CL_GUI_ALV_GRID
                          IMPORTING E_ROW_ID E_COLUMN_ID ES_ROW_NO,
    **Double Click Handler
        HANDLE_DOUBLE_CLICK FOR EVENT DOUBLE_CLICK OF CL_GUI_ALV_GRID
                                         IMPORTING E_ROW E_COLUMN ES_ROW_NO,
        TOP_OF_PAGE FOR EVENT TOP_OF_PAGE              "event handler
                             OF CL_GUI_ALV_GRID
                             IMPORTING E_DYNDOC_ID.
    *        END_OF_LIST FOR EVENT end_of_list              "event handler
    *                         OF CL_GUI_ALV_GRID
    *                         IMPORTING E_DYNDOC_ID.
    ENDCLASS.                    "lcl_event_handler DEFINITION
    *       CLASS lcl_event_handler IMPLEMENTATION
    CLASS LCL_EVENT_HANDLER IMPLEMENTATION.
    *Handle Hotspot Click
      METHOD HANDLE_HOTSPOT_CLICK .
        CLEAR: V_ROW,V_COLUMN,V_ROW_NUM.
        V_ROW  = E_ROW_ID.
        V_COLUMN = E_COLUMN_ID.
        V_ROW_NUM = ES_ROW_NO.
    *    MESSAGE I000 WITH V_ROW 'clicked'.
        CLEAR IT_ROW_NO[].
        X_ROW_NO-ROW_ID = V_ROW.
        APPEND X_ROW_NO TO IT_ROW_NO .
        CALL METHOD G_GRID->SET_SELECTED_ROWS
          EXPORTING
            IT_ROW_NO = IT_ROW_NO.
      ENDMETHOD.                    "lcl_event_handler
    *Handle Double Click
      METHOD  HANDLE_DOUBLE_CLICK.
        CLEAR: V_ROW,V_COLUMN,V_ROW_NUM.
        V_ROW  = E_ROW.
        V_COLUMN = E_COLUMN.
        V_ROW_NUM = ES_ROW_NO.
        IF E_COLUMN = 'VBELN'.
          SET PARAMETER ID 'VL' FIELD ITAB-VBELN.
          CALL TRANSACTION 'VL03N' AND SKIP FIRST SCREEN.
        ENDIF.
        IF E_COLUMN = 'POSNR'.
          SET PARAMETER ID 'VL' FIELD ITAB-VBELN.
          CALL TRANSACTION 'VL03N' AND SKIP FIRST SCREEN."
        ENDIF.
      ENDMETHOD.                    "handle_double_click
    *  METHOD END_OF_LIST.                   "implementation
    ** Top-of-page event
    *    PERFORM EVENT_TOP_OF_PAGE USING DG_DYNDOC_ID.
    *  ENDMETHOD.                            "top_of_page
        METHOD TOP_OF_PAGE.                   "implementation
    * Top-of-page event
        PERFORM EVENT_TOP_OF_PAGE USING DG_DYNDOC_ID.
      ENDMETHOD.                            "top_of_page
    ENDCLASS.                    "LCL_EVENT_HANDLER IMPLEMENTATION
    *&             Global Definitions
    DATA:      G_CUSTOM_CONTAINER TYPE REF TO CL_GUI_CUSTOM_CONTAINER,"Container1
                G_HANDLER TYPE REF TO LCL_EVENT_HANDLER. "handler
    DATA: OK_CODE LIKE SY-UCOMM,
          SAVE_OK LIKE SY-UCOMM,
          G_CONTAINER1 TYPE SCRFNAME VALUE 'TEST',
          GS_LAYOUT TYPE LVC_S_LAYO.
    data: v_lines type i.
    data: v_line(3) type c.
    *- Fieldcatalog for First and second Report
    DATA: IT_FIELDCAT  TYPE  LVC_T_FCAT,
          X_FIELDCAT TYPE LVC_S_FCAT,
          LS_VARI  TYPE DISVARIANT.
    *                START-OF_SELECTION
    START-OF-SELECTION.
      SELECT VBELN
             POSNR
             FROM LIPS
             UP TO 20 ROWS
             INTO CORRESPONDING FIELDS OF TABLE ITAB.
    describe table itab lines v_lines.
    END-OF-SELECTION.
      IF NOT ITAB[] IS INITIAL.
        CALL SCREEN 100.
      ELSE.
        MESSAGE I002 WITH 'NO DATA FOR THE SELECTION'(004).
      ENDIF.
    *&      Form  CREATE_AND_INIT_ALV
    *       text
    FORM CREATE_AND_INIT_ALV .
      DATA: LT_EXCLUDE TYPE UI_FUNCTIONS.
      "attention.....from here
      "split your container here...into two parts
      "create the container
      CREATE OBJECT G_CUSTOM_CONTAINER
               EXPORTING CONTAINER_NAME = G_CONTAINER1.
      "this is for top of page
    * Create TOP-Document
      CREATE OBJECT DG_DYNDOC_ID
                       EXPORTING STYLE = 'ALV_GRID'.
    * Create Splitter for custom_container
      CREATE OBJECT DG_SPLITTER
                 EXPORTING PARENT  = G_CUSTOM_CONTAINER
                           ROWS    = 2
                           COLUMNS = 1.
    * Split the custom_container to two containers and move the reference
    * to receiving containers g_parent_html and g_parent_grid
      "i am allocating the space for grid and top of page
      CALL METHOD DG_SPLITTER->GET_CONTAINER
        EXPORTING
          ROW       = 1
          COLUMN    = 1
        RECEIVING
          CONTAINER = DG_PARENT_HTML.
      CALL METHOD DG_SPLITTER->GET_CONTAINER
        EXPORTING
          ROW       = 2
          COLUMN    = 1
        RECEIVING
          CONTAINER = DG_PARENT_GRID.
    *  CALL METHOD DG_SPLITTER->GET_CONTAINER
    *    EXPORTING
    *      ROW       = 2
    *      COLUMN    = 1
    *    RECEIVING
    *      CONTAINER = DG_PARENT_HTML.
    *  CALL METHOD DG_SPLITTER->GET_CONTAINER
    *    EXPORTING
    *      ROW       = 1
    *      COLUMN    = 1
    *    RECEIVING
    *      CONTAINER = DG_PARENT_GRID.
      "you can set the height of it
    * Set height for g_parent_html
      CALL METHOD DG_SPLITTER->SET_ROW_HEIGHT
        EXPORTING
          ID     = 1
          HEIGHT = 5.
      "from here as usual..you need to specify parent as splitter part
      "which we alloted for grid
      CREATE OBJECT G_GRID
             EXPORTING I_PARENT = DG_PARENT_GRID.
    * Set a titlebar for the grid control
      CLEAR GS_LAYOUT.
      GS_LAYOUT-GRID_TITLE = TEXT-003.
      GS_LAYOUT-ZEBRA = SPACE.
      GS_LAYOUT-CWIDTH_OPT = 'X'.
      GS_LAYOUT-NO_ROWMARK = 'X'.
      GS_LAYOUT-CTAB_FNAME = 'CELLCOLOR'.
      CALL METHOD G_GRID->REGISTER_EDIT_EVENT
        EXPORTING
          I_EVENT_ID = CL_GUI_ALV_GRID=>MC_EVT_ENTER.
      CREATE OBJECT G_HANDLER.
      SET HANDLER G_HANDLER->HANDLE_DOUBLE_CLICK FOR G_GRID.
      SET HANDLER G_HANDLER->HANDLE_HOTSPOT_CLICK FOR G_GRID.
    *  SET HANDLER G_HANDLER->END_OF_LIST FOR G_GRID.
      SET HANDLER G_HANDLER->TOP_OF_PAGE FOR G_GRID.
      DATA: LS_CELLCOLOR TYPE LVC_S_SCOL. "required for color
      DATA: L_INDEX TYPE SY-TABIX.
      "Here i am changing the color of line 1,5,10...
      "so you can change the color of font conditionally
      LOOP AT ITAB.
        L_INDEX = SY-TABIX.
        IF L_INDEX = 1 OR L_INDEX = 5 OR L_INDEX = 10.
          LS_CELLCOLOR-FNAME = 'VBELN'.
          LS_CELLCOLOR-COLOR-COL = '6'.
          LS_CELLCOLOR-COLOR-INT = '0'.
          LS_CELLCOLOR-COLOR-INV = '1'.
          APPEND LS_CELLCOLOR TO ITAB-CELLCOLOR.
          MODIFY ITAB INDEX L_INDEX TRANSPORTING CELLCOLOR.
          LS_CELLCOLOR-FNAME = 'POSNR'.
          LS_CELLCOLOR-COLOR-COL = '6'.
          LS_CELLCOLOR-COLOR-INT = '0'.
          LS_CELLCOLOR-COLOR-INV = '1'.
          APPEND LS_CELLCOLOR TO ITAB-CELLCOLOR.
          MODIFY ITAB INDEX L_INDEX TRANSPORTING CELLCOLOR.
        ENDIF.
      ENDLOOP.
    * setting focus for created grid control
      CALL METHOD CL_GUI_CONTROL=>SET_FOCUS
        EXPORTING
          CONTROL = G_GRID.
    * Build fieldcat and set editable for date and reason code
    * edit enabled. Assign a handle for the dropdown listbox.
      PERFORM BUILD_FIELDCAT.
      PERFORM  SET_DRDN_TABLE.
    * Optionally restrict generic functions to 'change only'.
    *   (The user shall not be able to add new lines).
      PERFORM EXCLUDE_TB_FUNCTIONS CHANGING LT_EXCLUDE.
    **Vaiant to save the layout
      LS_VARI-REPORT      = SY-REPID.
      LS_VARI-HANDLE      = SPACE.
      LS_VARI-LOG_GROUP   = SPACE.
      LS_VARI-USERNAME    = SPACE.
      LS_VARI-VARIANT     = SPACE.
      LS_VARI-TEXT        = SPACE.
      LS_VARI-DEPENDVARS  = SPACE.
    **Calling the Method for ALV output
      CALL METHOD G_GRID->SET_TABLE_FOR_FIRST_DISPLAY
        EXPORTING
          IT_TOOLBAR_EXCLUDING = LT_EXCLUDE
          IS_VARIANT           = LS_VARI
          IS_LAYOUT            = GS_LAYOUT
          I_SAVE               = 'A'
        CHANGING
          IT_FIELDCATALOG      = IT_FIELDCAT
          IT_OUTTAB            = ITAB[].
      "do these..{
    * Initializing document
      CALL METHOD DG_DYNDOC_ID->INITIALIZE_DOCUMENT.
    * Processing events
      CALL METHOD G_GRID->LIST_PROCESSING_EVENTS
        EXPORTING
          I_EVENT_NAME = 'TOP_OF_PAGE'
          I_DYNDOC_ID  = DG_DYNDOC_ID.
      "end }
    * Set editable cells to ready for input initially
      CALL METHOD G_GRID->SET_READY_FOR_INPUT
        EXPORTING
          I_READY_FOR_INPUT = 1.
    ENDFORM.                               "CREATE_AND_INIT_ALV
    *&      Form  EXCLUDE_TB_FUNCTIONS
    *       text
    *      -->PT_EXCLUDE text
    FORM EXCLUDE_TB_FUNCTIONS CHANGING PT_EXCLUDE TYPE UI_FUNCTIONS.
    * Only allow to change data not to create new entries (exclude
    * generic functions).
      DATA LS_EXCLUDE TYPE UI_FUNC.
      LS_EXCLUDE = CL_GUI_ALV_GRID=>MC_FC_LOC_COPY_ROW.
      APPEND LS_EXCLUDE TO PT_EXCLUDE.
      LS_EXCLUDE = CL_GUI_ALV_GRID=>MC_FC_LOC_DELETE_ROW.
      APPEND LS_EXCLUDE TO PT_EXCLUDE.
      LS_EXCLUDE = CL_GUI_ALV_GRID=>MC_FC_LOC_APPEND_ROW.
      APPEND LS_EXCLUDE TO PT_EXCLUDE.
      LS_EXCLUDE = CL_GUI_ALV_GRID=>MC_FC_LOC_INSERT_ROW.
      APPEND LS_EXCLUDE TO PT_EXCLUDE.
      LS_EXCLUDE = CL_GUI_ALV_GRID=>MC_FC_LOC_MOVE_ROW.
      APPEND LS_EXCLUDE TO PT_EXCLUDE.
      LS_EXCLUDE = CL_GUI_ALV_GRID=>MC_FC_LOC_COPY.
      APPEND LS_EXCLUDE TO PT_EXCLUDE.
      LS_EXCLUDE = CL_GUI_ALV_GRID=>MC_FC_LOC_CUT.
      APPEND LS_EXCLUDE TO PT_EXCLUDE.
      LS_EXCLUDE = CL_GUI_ALV_GRID=>MC_FC_LOC_PASTE.
      APPEND LS_EXCLUDE TO PT_EXCLUDE.
      LS_EXCLUDE = CL_GUI_ALV_GRID=>MC_FC_LOC_PASTE_NEW_ROW.
      APPEND LS_EXCLUDE TO PT_EXCLUDE.
      LS_EXCLUDE = CL_GUI_ALV_GRID=>MC_FC_LOC_UNDO.
      APPEND LS_EXCLUDE TO PT_EXCLUDE.
    ENDFORM.                               " EXCLUDE_TB_FUNCTIONS
    *&      Form  build_fieldcat
    *       Fieldcatalog
    FORM BUILD_FIELDCAT .
      DATA: L_POS TYPE I.
      L_POS = L_POS + 1.
      X_FIELDCAT-SCRTEXT_M = 'Delivery'(024).
      X_FIELDCAT-FIELDNAME = 'VBELN'.
      X_FIELDCAT-TABNAME = 'IT_FINAL'.
      X_FIELDCAT-COL_POS    = L_POS.
      X_FIELDCAT-NO_ZERO    = 'X'.
      X_FIELDCAT-OUTPUTLEN = '10'.
      X_FIELDCAT-HOTSPOT = 'X'.
      APPEND X_FIELDCAT TO IT_FIELDCAT.
      CLEAR X_FIELDCAT.
      L_POS = L_POS + 1.
      X_FIELDCAT-SCRTEXT_M = 'Item'(025).
      X_FIELDCAT-FIELDNAME = 'POSNR'.
      X_FIELDCAT-TABNAME = 'IT_FINAL'.
      X_FIELDCAT-COL_POS    = L_POS.
      X_FIELDCAT-OUTPUTLEN = '5'.
      APPEND X_FIELDCAT TO IT_FIELDCAT.
      CLEAR X_FIELDCAT.
      L_POS = L_POS + 1.
      X_FIELDCAT-SCRTEXT_M = 'Drop'(025).
      X_FIELDCAT-FIELDNAME = 'DROP'.
      X_FIELDCAT-TABNAME = 'IT_FINAL'.
      X_FIELDCAT-COL_POS    = L_POS.
      X_FIELDCAT-OUTPUTLEN = '5'.
      X_FIELDCAT-EDIT = 'X'.
      X_FIELDCAT-DRDN_HNDL = '1'.
      X_FIELDCAT-DRDN_ALIAS = 'X'.
      APPEND X_FIELDCAT TO IT_FIELDCAT.
      CLEAR X_FIELDCAT.
    ENDFORM.                    " build_fieldcat
    *&      Module  STATUS_0100  OUTPUT
    *       text
    MODULE STATUS_0100 OUTPUT.
      SET PF-STATUS 'MAIN100'.
      SET TITLEBAR 'MAIN100'.
      IF G_CUSTOM_CONTAINER IS INITIAL.
    **Initializing the grid and calling the fm to Display the O/P
        PERFORM CREATE_AND_INIT_ALV.
      ENDIF.
    ENDMODULE.                 " STATUS_0100  OUTPUT
    *&      Module  USER_COMMAND_0100  INPUT
    *       text
    MODULE USER_COMMAND_0100 INPUT.
      CASE SY-UCOMM.
        WHEN 'BACK'.
          LEAVE TO SCREEN 0.
      ENDCASE.
    ENDMODULE.                 " USER_COMMAND_0100  INPUT
    *&      Form  SET_DRDN_TABLE
    *       text
    FORM SET_DRDN_TABLE.
      DATA:LT_DRAL TYPE LVC_T_DRAL,
            LS_DRAL TYPE LVC_S_DRAL.
      LOOP AT ITAB .
    * First listbox (handle '1').
        IF SY-INDEX = 1.
          LS_DRAL-HANDLE = '1'.
          LS_DRAL-VALUE =  ' '.
          LS_DRAL-INT_VALUE =  ' '.
        ELSE.
          LS_DRAL-HANDLE = '1'.
          LS_DRAL-VALUE =  ITAB-POSNR.
          LS_DRAL-INT_VALUE =  ITAB-POSNR.
        ENDIF.
        APPEND LS_DRAL TO LT_DRAL.
      ENDLOOP.
    **Setting the Drop down table for Reason Code
      CALL METHOD G_GRID->SET_DROP_DOWN_TABLE
        EXPORTING
          IT_DROP_DOWN_ALIAS = LT_DRAL.
    ENDFORM.                               " set_drdn_table
    *&      Form  EVENT_TOP_OF_PAGE
    *       text
    *      -->DG_DYNDOC_ID  text
    FORM EVENT_TOP_OF_PAGE USING   DG_DYNDOC_ID TYPE REF TO CL_DD_DOCUMENT.
      "this is more clear.....check it
      "first add text, then pass it to comentry write fm
      DATA : DL_TEXT(255) TYPE C.  "Text
    * Populating header to top-of-page
      CALL METHOD DG_DYNDOC_ID->ADD_TEXT
        EXPORTING
          TEXT      = 'Test Report'
          SAP_STYLE = CL_DD_AREA=>HEADING.
    * Add new-line
      CALL METHOD DG_DYNDOC_ID->NEW_LINE.
      CLEAR : DL_TEXT.
    * Move program ID
      CONCATENATE 'Program Name :' SY-REPID
             INTO DL_TEXT SEPARATED BY SPACE.
    * Add Program Name to Document
      PERFORM ADD_TEXT USING DL_TEXT.
    * Add new-line
      CALL METHOD DG_DYNDOC_ID->NEW_LINE.
      CLEAR : DL_TEXT.
    * Move User ID
      CONCATENATE 'User ID :' SY-UNAME INTO DL_TEXT SEPARATED BY SPACE
    * Add User ID to Document
      PERFORM ADD_TEXT USING DL_TEXT.
    * Add new-line
      CALL METHOD DG_DYNDOC_ID->NEW_LINE.
      CLEAR : DL_TEXT.
    * Move count (no of records).
      move v_lines to v_line.
      CONCATENATE 'No of records :' v_line INTO DL_TEXT SEPARATED BY SPACE.
    * Add Client to Document
      PERFORM ADD_TEXT USING DL_TEXT.
    * Add new-line
      CALL METHOD DG_DYNDOC_ID->NEW_LINE.
      CLEAR : DL_TEXT.
    * Move date
      WRITE SY-DATUM TO DL_TEXT.
      CONCATENATE 'Date :' DL_TEXT INTO DL_TEXT SEPARATED BY SPACE.
    * Add Date to Document
      PERFORM ADD_TEXT USING DL_TEXT.
    * Add new-line
      CALL METHOD DG_DYNDOC_ID->NEW_LINE.
      CLEAR : DL_TEXT.
    * Move time
      WRITE SY-UZEIT TO DL_TEXT.
      CONCATENATE 'Time :' DL_TEXT INTO DL_TEXT SEPARATED BY SPACE.
    * Add Time to Document
      PERFORM ADD_TEXT USING DL_TEXT.
    * Add new-line
      CALL METHOD DG_DYNDOC_ID->NEW_LINE.
    * Populating data to html control
      PERFORM HTML.
    ENDFORM.                    " EVENT_TOP_OF_PAGE
    *&      Form  ADD_TEXT
    *       To add Text
    FORM ADD_TEXT USING P_TEXT TYPE SDYDO_TEXT_ELEMENT.
    * Adding text
      CALL METHOD DG_DYNDOC_ID->ADD_TEXT
        EXPORTING
          TEXT         = P_TEXT
          SAP_EMPHASIS = CL_DD_AREA=>HEADING.
    ENDFORM.                    " ADD_TEXT
    *&      Form  HTML
    *       text
    FORM HTML.
      DATA : DL_LENGTH  TYPE I,                           " Length
             DL_BACKGROUND_ID TYPE SDYDO_KEY VALUE SPACE. " Background_id
    * Creating html control
      IF DG_HTML_CNTRL IS INITIAL.
        CREATE OBJECT DG_HTML_CNTRL
             EXPORTING
                  PARENT    = DG_PARENT_HTML.
      ENDIF.
    * Reuse_alv_grid_commentary_set
      CALL FUNCTION 'REUSE_ALV_GRID_COMMENTARY_SET'
        EXPORTING
          DOCUMENT = DG_DYNDOC_ID
          BOTTOM   = SPACE
        IMPORTING
          LENGTH   = DL_LENGTH.
    * Get TOP->HTML_TABLE ready
      CALL METHOD DG_DYNDOC_ID->MERGE_DOCUMENT.
    * Set wallpaper
      CALL METHOD DG_DYNDOC_ID->SET_DOCUMENT_BACKGROUND
        EXPORTING
          PICTURE_ID = DL_BACKGROUND_ID.
    * Connect TOP document to HTML-Control
      DG_DYNDOC_ID->HTML_CONTROL = DG_HTML_CNTRL.
    * Display TOP document
      CALL METHOD DG_DYNDOC_ID->DISPLAY_DOCUMENT
        EXPORTING
          REUSE_CONTROL      = 'X'
          PARENT             = DG_PARENT_HTML
        EXCEPTIONS
          HTML_DISPLAY_ERROR = 1.
      IF SY-SUBRC NE 0.
        MESSAGE I999 WITH 'Error in displaying top-of-page'(036).
      ENDIF.
    ENDFORM.                    " HTML
    Regards
    vijay

  • Lr_selections- get_selected_rows returns zero entries Follow-Up Question...

    Hello SDN Community,
    I was able to get a list of row numbers returned from GET_SELECTED_ROWS when I added a call to GET_METADATA.
    However, GET_SELECTED_ROWS only works the first time.  When I return to the screen, the lines are still highlighted and if I click the button again, it goes thru the code but won't return the row numbers. 
    If I back up to the previous screen and come forward to the ALV grid screen, the rows are still highlighted and when i click the button, no row numbers are returned.
    I do not understand why the rows remain highlighted in the grid.  I tried the grid->refresh method, but that does not clear the highlighting.  I can't help but think that maybe if I could figure out how to get the highlighted lines to go away, that maybe GET_SELECTED_ROWS would start working again.
    Or maybe I need to do something else for GET_SELECTED_ROWS to start working again?
    Your thoughts and insights are appreciated!
    Thank you,
    Dean Atteberry.

    Hi,
    Not sure ...what you are missing...I tried this code..and it returns the correct set of rows...even if click the button to get the rows...multiple times...
    please check this sample.
    DATA: g_container TYPE scrfname VALUE 'CONTAINER1'.
    DATA: g_custom_container TYPE REF TO cl_gui_custom_container.
    TYPES: BEGIN OF type_output,
             matnr TYPE matnr,
           END OF type_output.
    DATA:lt_output   TYPE STANDARD TABLE OF type_output,
         lwa_rows    TYPE int4,
         lwa_output  TYPE type_output,
         lt_rows     TYPE salv_t_row.
    * Local declarations.
    DATA: lr_table      TYPE REF TO cl_salv_table,
          lr_selections TYPE REF TO cl_salv_selections.
    DATA: lr_columns    TYPE REF TO cl_salv_columns_table.
    DATA: lr_grid       TYPE REF TO cl_gui_alv_grid.
    START-OF-SELECTION.
    * Prepare data.
      lwa_output-matnr = 'TEST1'.APPEND lwa_output TO lt_output.
      lwa_output-matnr = 'TEST2'.APPEND lwa_output TO lt_output.
      lwa_output-matnr = 'TEST3'.APPEND lwa_output TO lt_output.
      CALL SCREEN 100.
    *       MODULE PBO OUTPUT                                             *
    MODULE pbo OUTPUT.
      SET PF-STATUS 'TEST'.
      IF g_custom_container IS INITIAL.
        CREATE OBJECT g_custom_container
          EXPORTING
            container_name = g_container.
    * Call the factory method
        TRY.
            cl_salv_table=>factory(
              EXPORTING
                r_container = g_custom_container
                container_name = 'CONTAINER1'
              IMPORTING
                r_salv_table = lr_table
              CHANGING
                t_table      = lt_output ).
          CATCH cx_salv_msg.                                "#EC NO_HANDLER
        ENDTRY.
    * Column selection
        lr_selections = lr_table->get_selections( ).
        lr_selections->set_selection_mode( if_salv_c_selection_mode=>row_column ).
        lr_columns = lr_table->get_columns( ).
        lr_columns->set_optimize( abap_true ).
    * Display
        lr_table->display( ).
      ENDIF.
    ENDMODULE.                    "pbo OUTPUT
    *       MODULE PAI INPUT                                              *
    MODULE pai INPUT.
      CASE sy-ucomm.
        WHEN 'EXIT' OR 'BACK'.
          PERFORM exit_program.
        WHEN 'GET_ROWS'.
          CALL METHOD lr_table->get_metadata.  " call this method....
    * Get the selected rows.
          lt_rows = lr_selections->get_selected_rows( ).
    * Display the selected rows.
          BREAK-POINT.          " break point.
          LOOP AT lt_rows INTO lwa_rows.
            READ TABLE lt_output INTO lwa_output INDEX lwa_rows.
            WRITE: / lwa_output-matnr.
          ENDLOOP.
      ENDCASE.
    ENDMODULE.                    "pai INPUT
    *       FORM EXIT_PROGRAM                                             *
    FORM exit_program.
      LEAVE PROGRAM.
    ENDFORM.                    "exit_program
    Thanks
    Naren

  • Why this code is not working for alv

    Dear
    Regards,
    i have implemented the same program for ALV which i have used earlier in the reports. but now it is showing no output:
    *& Report  ZTCT1_ALV2                                                  *
    REPORT  ztct1_alv2                              .
    CLASS lcl_event_receiver DEFINITION DEFERRED.
    * INCLUDING TABLES.
    TABLES: vbrk,
            vbrp,
            kna1,
            t001w,
            makt.
    * DECLARATION OF INTERNAL TABLES.
    DATA: BEGIN OF itab OCCURS 0,  "Including the fields of VBRK and VBRP
            kunag LIKE vbrk-kunag, "Customer Code
            name1 LIKE kna1-name1, "Customer Name
            vbeln LIKE vbrk-vbeln, "Invoice #
            fkdat LIKE vbrk-fkdat, "Invoice Date
            werks LIKE vbrp-werks, "Plant
            name2 LIKE t001w-name1,"Plant Description
            matnr LIKE vbrp-matnr, "Material #
            maktx LIKE makt-maktx, "Material Description
            meins LIKE vbrp-meins, "Unit of Measure
            fklmg LIKE vbrp-fklmg, "Quantity
            netwr LIKE vbrp-netwr, "Amount
          END OF itab,
          BEGIN OF itnm OCCURS 0,  "Including the fields of VBRK and KNA1
            kunag LIKE vbrk-kunag, "Customer Code
            name1 LIKE kna1-name1, "Customer Name
          END OF itnm,
          BEGIN OF itpt OCCURS 0,  "Including the fields of VBRP and T001W
            werks LIKE vbrp-werks, "Plant
            name1 LIKE t001w-name1,"Plant Description
          END OF itpt,
          BEGIN OF itmt OCCURS 0,  "Including the fields of VBRP and MAKT
            matnr LIKE vbrp-matnr, "Material #
            maktx LIKE makt-maktx, "Material description
          END OF itmt,
          BEGIN OF itsm OCCURS 0,
            kunag LIKE kna1-kunnr,
            name1 LIKE kna1-name1,
            fklmg LIKE vbrp-fklmg,
            netwr LIKE vbrp-netwr,
          END OF itsm,
          ok_code            LIKE sy-ucomm,
          save_ok            LIKE sy-ucomm,
          g_max              TYPE i VALUE 100,
          g_repid            LIKE sy-repid,
          gs_layout          TYPE lvc_s_layo,
          g_container        TYPE scrfname VALUE 'CUST_CONT',
          grid1              TYPE REF TO cl_gui_alv_grid,
          g_custom_container TYPE REF TO cl_gui_custom_container,
          grid2              TYPE REF TO cl_gui_alv_grid,
          gt_sort            TYPE lvc_t_sort,
          gt_fieldcatalog    TYPE lvc_t_fcat,
          w_tot_qty          LIKE vbrp-fklmg,
          w_tot_amt          LIKE vbrp-netwr,
    * Reference to Dialogbox Container.
          dialogbox_container TYPE REF TO cl_gui_dialogbox_container,
    * Reference to local class that handles events of GRID1 and
    * DIALOGBOX_CONTAINER
          event_receiver TYPE REF TO lcl_event_receiver.
    * SELECT-OPTIONS
    SELECTION-SCREEN SKIP 1.
    SELECTION-SCREEN BEGIN OF BLOCK input WITH FRAME TITLE text-000.
    SELECT-OPTIONS: s_werks FOR vbrp-werks, "Plant
                    s_kunag FOR vbrk-kunag, "Customer
                    s_matnr FOR vbrp-matnr, "Material Number
                    s_fkdat FOR vbrk-fkdat. "Invoice Date
    SELECTION-SCREEN END OF BLOCK input .
    SELECTION-SCREEN SKIP 1.
    * START-OF-SELECTION
    START-OF-SELECTION.
      SET SCREEN 100.
    * CLEARING INTERNAL TABLES.
      CLEAR: itab,
             itnm,
             itmt,
             itpt.
    * QUERY FOR JOINING TABLES VBRK AND VBRP
      SELECT vbrk~kunag
             vbrk~vbeln
             vbrk~fkdat
             vbrp~werks
             vbrp~matnr
             vbrp~meins
             vbrp~fklmg
             vbrp~netwr
             INTO CORRESPONDING FIELDS OF TABLE itab
             FROM vbrk
             INNER JOIN vbrp
                 ON vbrk~vbeln = vbrp~vbeln
             WHERE vbrk~kunag IN s_kunag
               AND vbrk~fkdat IN s_fkdat
               AND vbrp~matnr IN s_matnr
               AND vbrp~werks IN s_werks.
    * QUERY FOR JOINING TABLES VBRK AND KNA1
      SELECT kna1~kunnr AS kunag
             kna1~name1
             INTO TABLE itnm
             FROM kna1
             WHERE kna1~kunnr IN s_kunag.
    * QUERY FOR JOINING TABLES VBRP AND T001W
      SELECT t001w~werks
             t001w~name1
             INTO TABLE itpt
             FROM t001w
             WHERE t001w~werks IN s_werks.
    * QUERY FOR JOINING TABLES VBRP AND MAKT
      SELECT makt~matnr
             makt~maktx
             INTO TABLE itmt
             FROM makt
             WHERE makt~matnr IN s_matnr.
    * SORTING INTERNAL TABLES.
      SORT itab BY kunag.
    *    LOOP AT itab.
    *      CLEAR: itmt, itnm, itpt.
    *      READ TABLE itnm WITH KEY kunag = itab-kunag.
    *      READ TABLE itmt WITH KEY matnr = itab-matnr.
    *      READ TABLE itpt WITH KEY werks = itab-werks.
    *      itab-name1 = itnm-name1.
    *      itab-maktx = itmt-maktx.
    *      itab-name2 = itpt-name1.
    *      MODIFY itab.
    *    ENDLOOP.
    *    PERFORM fieldcatalog_init USING gt_fieldcatalog[] 'KUNAG' 'C' 'Customer Code'.
    *    PERFORM fieldcatalog_init USING gt_fieldcatalog[] 'NAME1' 'C' 'Customer Name'.
    *    PERFORM fieldcatalog_init USING gt_fieldcatalog[] 'VBELN' 'C' 'Invoice #'.
    *    PERFORM fieldcatalog_init USING gt_fieldcatalog[] 'FKDAT' 'DATS' 'Invoice Date'.
    *    PERFORM fieldcatalog_init USING gt_fieldcatalog[] 'WERKS' 'C' 'Plant'.
    *    PERFORM fieldcatalog_init USING gt_fieldcatalog[] 'NAME2' 'C' 'Plant Description'.
    *    PERFORM fieldcatalog_init USING gt_fieldcatalog[] 'MATNR' 'C' 'Material #'.
    *    PERFORM fieldcatalog_init USING gt_fieldcatalog[] 'MAKTX' 'C' 'Material Description'.
    *    PERFORM fieldcatalog_init USING gt_fieldcatalog[] 'MEINS' 'C' 'UoM'.
    *    PERFORM fieldcatalog_init USING gt_fieldcatalog[] 'FKLMG' 'QUAN' 'Quantity'.
    *    PERFORM fieldcatalog_init USING gt_fieldcatalog[] 'NETWR' 'CURR' 'Amount'.
        LOOP AT itab.
          CLEAR itsm.
          READ TABLE itnm WITH KEY kunag = itab-kunag.
          itsm-kunag = itab-kunag.
          itsm-name1 = itnm-name1.
          itsm-fklmg = itab-fklmg.
          itsm-netwr = itab-netwr.
          COLLECT itsm.
        ENDLOOP.
        PERFORM fieldcatalog_init USING gt_fieldcatalog[] 'KUNAG' 'C' 'Customer Code'.
        PERFORM fieldcatalog_init USING gt_fieldcatalog[] 'NAME1' 'C' 'Customer Name'.
        PERFORM fieldcatalog_init USING gt_fieldcatalog[] 'FKLMG' 'QUAN' 'Quantity'.
        PERFORM fieldcatalog_init USING gt_fieldcatalog[] 'NETWR' 'CURR' 'Amount'.
      PERFORM sort_build USING gt_sort[].
      PERFORM layout_init USING gs_layout.
    *   LOCAL CLASSES: Definition
    CLASS lcl_event_receiver DEFINITION.
      PUBLIC SECTION.
        METHODS:
        handle_double_click
            FOR EVENT double_click OF cl_gui_alv_grid
                IMPORTING e_row e_column,
        handle_close
            FOR EVENT close OF cl_gui_dialogbox_container
                IMPORTING sender.
      PRIVATE SECTION.
        DATA: dialogbox_status TYPE c.  "'X': does exist, SPACE: does not ex.
    ENDCLASS.                    "lcl_event_receiver DEFINITION
    *   LOCAL CLASSES: Implementation
    CLASS lcl_event_receiver IMPLEMENTATION.
    *   §3.At doubleclick(1): The event DOUBLE_CLICK provides
    *      parameters of the clicked row and column.
    *      Use row parameter to select a line of the
    *      corresponding internal table.
      METHOD handle_double_click.
        DATA: ls_sm LIKE LINE OF itsm,
              wa_itab LIKE ITAB.
    *   read selected row from internal table gt_sflight
        READ TABLE itsm INDEX e_row-index INTO ls_sm.
    *   §4.At Doubleclick(2): Select booking data
    *    READ TABLE ITAB WITH KEY KUNAG = LS_SM-KUNAG.    .
        READ TABLE ITAB INTO WA_ITAB WITH KEY KUNAG = LS_SM-KUNAG.
    *   §5.At doubleclick(3): Create dialogbox to show detail list
    *     (if not already existent)
        IF dialogbox_status IS INITIAL.
          dialogbox_status = 'X'.
          PERFORM create_detail_list.
        ELSE.
          CALL METHOD dialogbox_container->set_visible
            EXPORTING
              visible = 'X'.
          CALL METHOD grid2->refresh_table_display.
        ENDIF.
      ENDMETHOD.                    "handle_double_click
      METHOD handle_close.
    *   §6.Handle the CLOSE-button of the dialogbox
    *   set dialogbox invisible
    *   (the dialogbox is destroyed outomatically when the user
    *   switches to another dynpro).
        CALL METHOD sender->set_visible
          EXPORTING
            visible = space.
    *   In this example closing the dialogbox leads
    *   to make it invisible. It is also conceivable to destroy it
    *   and recreate it if the user doubleclicks a line again.
    *   Displaying a great amount of data has a greater impact on performance.
      ENDMETHOD.                    "handle_close
    ENDCLASS.                    "lcl_event_receiver IMPLEMENTATION
    *   lcl_event_receiver (Implementation)
    *=====================================================================
    *       FORM EXIT_PROGRAM                                             *
    FORM exit_program.
      CALL METHOD g_custom_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 = g_repid
            txt2  = sy-subrc
            txt1  = 'Error in FLush'(500).
      ENDIF.
      LEAVE TO SCREEN 0.
    ENDFORM.                    "exit_program
    *  MODULE PBO_ALV OUTPUT
    MODULE pbo_alv OUTPUT.
      SET PF-STATUS 'MAIN'.
      SET TITLEBAR 'MAIN100'.
      g_repid = sy-repid.
      IF g_custom_container IS INITIAL.
        READ TABLE itsm.
        CREATE OBJECT g_custom_container
          EXPORTING
            container_name = g_container
          EXCEPTIONS
            cntl_error = 1
            cntl_system_error = 2
            create_error = 3
            lifetime_error = 4
            lifetime_dynpro_dynpro_link = 5.
        IF sy-subrc NE 0.
          CALL FUNCTION 'POPUP_TO_INFORM'
            EXPORTING
              titel = g_repid
              txt2  = sy-subrc
              txt1  = 'The control could not be created'(510).
        ENDIF.
        CREATE OBJECT grid1
          EXPORTING
            i_parent = g_custom_container.
        gs_layout-grid_title = 'Invoice Summary'.
        CALL METHOD grid1->set_table_for_first_display
          EXPORTING
            is_layout       = gs_layout
          CHANGING
            it_outtab       = itsm[]
            it_fieldcatalog = gt_fieldcatalog
            it_sort         = gt_sort.
        CREATE OBJECT event_receiver.
        SET HANDLER event_receiver->handle_double_click FOR grid1.
      ENDIF.
      CALL METHOD cl_gui_control=>set_focus
        EXPORTING
          control = grid1.
    ENDMODULE.                    "PBO_ALV OUTPUT
    *  MODULE PAI_ALV INPUT
    MODULE pai_alv INPUT.
      CALL METHOD cl_gui_cfw=>dispatch.
      CASE sy-ucomm.
        WHEN 'BACK' OR 'EXIT' OR 'CANCEL'.
          LEAVE TO SCREEN 0.
      ENDCASE.
    ENDMODULE.                    "PAI_ALV INPUT
    *&      Form  fieldcatalog_init
    *       text
    *      -->LT_FIELDCATtext
    *      -->VALUE(FIELDtextE)
    *      -->VALUE(FIELDtextE)
    *      -->VALUE(FIELDtextT)
    FORM fieldcatalog_init USING lt_fieldcatalog TYPE lvc_t_fcat
                           value(field_name) value(field_type) value(field_text).
      DATA: ls_fieldcatalog TYPE lvc_s_fcat.
      CLEAR ls_fieldcatalog.
      ls_fieldcatalog-fieldname = field_name.
      ls_fieldcatalog-datatype  = field_type.
      ls_fieldcatalog-reptext   = field_text.
      ls_fieldcatalog-coltext  =  field_text.
      ls_fieldcatalog-seltext  =  field_text.
      ls_fieldcatalog-tooltip  =  field_text.
      APPEND ls_fieldcatalog TO lt_fieldcatalog.
    ENDFORM.                    "fieldcatalog_init
    *&      Form  sort_build
    *       text
    *      -->LT_SORT    text
    FORM sort_build USING lt_sort TYPE lvc_t_sort.
      DATA: ls_sort TYPE lvc_s_sort.
      ls_sort-fieldname = 'KUNAG'.    "Fieldname on which to sort
      ls_sort-up        = 'X'.        "Sort Ascending
      APPEND ls_sort TO lt_sort.
      ls_sort-fieldname = 'NAME1'.    "Fieldname on which to sort
      ls_sort-up        = 'X'.        "Sort Ascending
      APPEND ls_sort TO lt_sort.
    ENDFORM.                    "sort_build
    *&      Form  layout_init
    *       text
    *      -->LS_LAYOUT  text
    FORM layout_init USING ls_layout TYPE lvc_s_layo.
      ls_layout-zebra      = 'X'.
      ls_layout-grid_title = 'Customer Details'.
      ls_layout-sel_mode   = 'A'.
      ls_layout-cwidth_opt = 'X'.
    ENDFORM.                    "layout_init
    *&      Form  create_detail_list
    *         text
    *    -->  p1        text
    *    <--  p2        text
    FORM create_detail_list.
    *   create dialogbox container as dynpro-instance
    *   When the user switches to another screen, it is
    *   destroyed by lifetime mangagement of CFW
      CREATE OBJECT dialogbox_container
          EXPORTING
            top = 150
            left = 150
            lifetime = cntl_lifetime_dynpro
            caption = 'INVOICE DETAILS'(200)
            width = 800
            height = 200.
      CREATE OBJECT grid2
          EXPORTING i_parent = dialogbox_container.
    *   Register ABAP OO event 'CLOSE'. It is not necessary to register this
    *   event at the frontend (this is done during creation).
      SET HANDLER event_receiver->handle_close FOR dialogbox_container.
    *   display data
      gs_layout-grid_title = 'Invoice Details'(100).
      CALL METHOD grid2->set_table_for_first_display
        EXPORTING
          i_structure_name = 'itab'
          is_layout        = gs_layout
        CHANGING
          it_outtab        = itab[]
          it_fieldcatalog  = gt_fieldcatalog
          it_sort          = gt_sort.
      CALL METHOD cl_gui_control=>set_focus
        EXPORTING
          control = grid2.
    ENDFORM.                    " create_detail_list[code][/
    code]

    Hi,
    I also copied and pasted the same code check once again by copying this code and create screens by double clicking on 100.
    CLASS lcl_event_receiver DEFINITION DEFERRED.
    * INCLUDING TABLES.
    TABLES: vbrk,
            vbrp,
            kna1,
            t001w,
            makt.
    * DECLARATION OF INTERNAL TABLES.
    DATA: BEGIN OF itab OCCURS 0,  "Including the fields of VBRK and VBRP
            kunag LIKE vbrk-kunag, "Customer Code
            name1 LIKE kna1-name1, "Customer Name
            vbeln LIKE vbrk-vbeln, "Invoice #
            fkdat LIKE vbrk-fkdat, "Invoice Date
            werks LIKE vbrp-werks, "Plant
            name2 LIKE t001w-name1,"Plant Description
            matnr LIKE vbrp-matnr, "Material #
            maktx LIKE makt-maktx, "Material Description
            meins LIKE vbrp-meins, "Unit of Measure
            fklmg LIKE vbrp-fklmg, "Quantity
            netwr LIKE vbrp-netwr, "Amount
          END OF itab,
          BEGIN OF itnm OCCURS 0,  "Including the fields of VBRK and KNA1
            kunag LIKE vbrk-kunag, "Customer Code
            name1 LIKE kna1-name1, "Customer Name
          END OF itnm,
          BEGIN OF itpt OCCURS 0,  "Including the fields of VBRP and T001W
            werks LIKE vbrp-werks, "Plant
            name1 LIKE t001w-name1,"Plant Description
          END OF itpt,
          BEGIN OF itmt OCCURS 0,  "Including the fields of VBRP and MAKT
            matnr LIKE vbrp-matnr, "Material #
            maktx LIKE makt-maktx, "Material description
          END OF itmt,
          BEGIN OF itsm OCCURS 0,
            kunag LIKE kna1-kunnr,
            name1 LIKE kna1-name1,
            fklmg LIKE vbrp-fklmg,
            netwr LIKE vbrp-netwr,
          END OF itsm,
          ok_code            LIKE sy-ucomm,
          save_ok            LIKE sy-ucomm,
          g_max              TYPE i VALUE 100,
          g_repid            LIKE sy-repid,
          gs_layout          TYPE lvc_s_layo,
          g_container        TYPE scrfname VALUE 'CUST_CONT',
          grid1              TYPE REF TO cl_gui_alv_grid,
          g_custom_container TYPE REF TO cl_gui_custom_container,
          grid2              TYPE REF TO cl_gui_alv_grid,
          gt_sort            TYPE lvc_t_sort,
          gt_fieldcatalog    TYPE lvc_t_fcat,
          w_tot_qty          LIKE vbrp-fklmg,
          w_tot_amt          LIKE vbrp-netwr,
    * Reference to Dialogbox Container.
          dialogbox_container TYPE REF TO cl_gui_dialogbox_container,
    * Reference to local class that handles events of GRID1 and
    * DIALOGBOX_CONTAINER
          event_receiver TYPE REF TO lcl_event_receiver.
    * SELECT-OPTIONS
    SELECTION-SCREEN SKIP 1.
    SELECTION-SCREEN BEGIN OF BLOCK input WITH FRAME TITLE text-000.
    SELECT-OPTIONS: s_werks FOR vbrp-werks, "Plant
                    s_kunag FOR vbrk-kunag, "Customer
                    s_matnr FOR vbrp-matnr, "Material Number
                    s_fkdat FOR vbrk-fkdat. "Invoice Date
    SELECTION-SCREEN END OF BLOCK input .
    SELECTION-SCREEN SKIP 1.
    * START-OF-SELECTION
    START-OF-SELECTION.
    SET SCREEN 100.
    * CLEARING INTERNAL TABLES.
      CLEAR: itab,
             itnm,
             itmt,
             itpt.
    * QUERY FOR JOINING TABLES VBRK AND VBRP
      SELECT vbrk~kunag
             vbrk~vbeln
             vbrk~fkdat
             vbrp~werks
             vbrp~matnr
             vbrp~meins
             vbrp~fklmg
             vbrp~netwr
             INTO CORRESPONDING FIELDS OF TABLE itab
             FROM vbrk
             INNER JOIN vbrp
                 ON vbrk~vbeln = vbrp~vbeln
             WHERE vbrk~kunag IN s_kunag
               AND vbrk~fkdat IN s_fkdat
               AND vbrp~matnr IN s_matnr
               AND vbrp~werks IN s_werks.
    * QUERY FOR JOINING TABLES VBRK AND KNA1
      SELECT kna1~kunnr AS kunag
             kna1~name1
             INTO TABLE itnm
             FROM kna1
             WHERE kna1~kunnr IN s_kunag.
    * QUERY FOR JOINING TABLES VBRP AND T001W
      SELECT t001w~werks
             t001w~name1
             INTO TABLE itpt
             FROM t001w
             WHERE t001w~werks IN s_werks.
    * QUERY FOR JOINING TABLES VBRP AND MAKT
      SELECT makt~matnr
             makt~maktx
             INTO TABLE itmt
             FROM makt
             WHERE makt~matnr IN s_matnr.
    * SORTING INTERNAL TABLES.
      SORT itab BY kunag.
        LOOP AT itab.
          CLEAR itsm.
          READ TABLE itnm WITH KEY kunag = itab-kunag.
          itsm-kunag = itab-kunag.
          itsm-name1 = itnm-name1.
          itsm-fklmg = itab-fklmg.
          itsm-netwr = itab-netwr.
          COLLECT itsm.
        ENDLOOP.
    * END-OF-SELECTION.
    * If not itsm[] is initial.
    *    CALL SCREEN 100.
    * endif.
    *   LOCAL CLASSES: Definition
    CLASS lcl_event_receiver DEFINITION.
      PUBLIC SECTION.
        METHODS:
        handle_double_click
            FOR EVENT double_click OF cl_gui_alv_grid
                IMPORTING e_row e_column,
        handle_close
            FOR EVENT close OF cl_gui_dialogbox_container
                IMPORTING sender.
      PRIVATE SECTION.
        DATA: dialogbox_status TYPE c.  "'X': does exist, SPACE: does not ex
    ENDCLASS.                    "lcl_event_receiver DEFINITION
    *   LOCAL CLASSES: Implementation
    CLASS lcl_event_receiver IMPLEMENTATION.
    *   §3.At doubleclick(1): The event DOUBLE_CLICK provides
    *      parameters of the clicked row and column.
    *      Use row parameter to select a line of the
    *      corresponding internal table.
      METHOD handle_double_click.
        DATA: ls_sm LIKE LINE OF itsm,
              wa_itab LIKE ITAB.
    *   read selected row from internal table gt_sflight
        READ TABLE itsm INDEX e_row-index INTO ls_sm.
    *   §4.At Doubleclick(2): Select booking data
    *    READ TABLE ITAB WITH KEY KUNAG = LS_SM-KUNAG.    .
        READ TABLE ITAB INTO WA_ITAB WITH KEY KUNAG = LS_SM-KUNAG.
    *   §5.At doubleclick(3): Create dialogbox to show detail list
    *     (if not already existent)
        IF dialogbox_status IS INITIAL.
          dialogbox_status = 'X'.
          PERFORM create_detail_list.
        ELSE.
          CALL METHOD dialogbox_container->set_visible
            EXPORTING
              visible = 'X'.
          CALL METHOD grid2->refresh_table_display.
        ENDIF.
      ENDMETHOD.                    "handle_double_click
      METHOD handle_close.
    *   §6.Handle the CLOSE-button of the dialogbox
    *   set dialogbox invisible
    *   (the dialogbox is destroyed outomatically when the user
    *   switches to another dynpro).
        CALL METHOD sender->set_visible
          EXPORTING
            visible = space.
    *   In this example closing the dialogbox leads
    *   to make it invisible. It is also conceivable to destroy it
    *   and recreate it if the user doubleclicks a line again.
    *   Displaying a great amount of data has a greater impact on
    *performance.
      ENDMETHOD.                    "handle_close
    ENDCLASS.                    "lcl_event_receiver IMPLEMENTATION
    *   lcl_event_receiver (Implementation)
    *=====================================================================
    *       FORM EXIT_PROGRAM                                             *
    FORM exit_program.
      CALL METHOD g_custom_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 = g_repid
            txt2  = sy-subrc
            txt1  = 'Error in FLush'(500).
      ENDIF.
      LEAVE TO SCREEN 0.
    ENDFORM.                    "exit_program
    *&      Module  STATUS_0100  OUTPUT
    *       text
    module STATUS_0100 output.
      SET PF-STATUS 'MAIN'.
      SET TITLEBAR 'MAIN100'.
      g_repid = sy-repid.
      IF g_custom_container IS INITIAL.
        READ TABLE itsm.
        CREATE OBJECT g_custom_container
          EXPORTING
            container_name = g_container
          EXCEPTIONS
            cntl_error = 1
            cntl_system_error = 2
            create_error = 3
            lifetime_error = 4
            lifetime_dynpro_dynpro_link = 5.
        IF sy-subrc NE 0.
          CALL FUNCTION 'POPUP_TO_INFORM'
            EXPORTING
              titel = g_repid
              txt2  = sy-subrc
              txt1  = 'The control could not be created'(510).
        ENDIF.
        CREATE OBJECT grid1
          EXPORTING
            i_parent = g_custom_container.
        gs_layout-grid_title = 'Invoice Summary'.
    PERFORM fieldcatalog_init USING gt_fieldcatalog[] 'KUNAG' 'C'
    'Customer Code'.
        PERFORM fieldcatalog_init USING gt_fieldcatalog[] 'NAME1' 'C'
    'Customer Name'.
        PERFORM fieldcatalog_init USING gt_fieldcatalog[] 'FKLMG' 'QUAN'
    'Quantity'.
        PERFORM fieldcatalog_init USING gt_fieldcatalog[] 'NETWR' 'CURR'
    'Amount'.
      PERFORM sort_build USING gt_sort[].
      PERFORM layout_init USING gs_layout.
        CALL METHOD grid1->set_table_for_first_display
          EXPORTING
            is_layout       = gs_layout
          CHANGING
            it_outtab       = itsm[]
            it_fieldcatalog = gt_fieldcatalog
            it_sort         = gt_sort.
        CREATE OBJECT event_receiver.
        SET HANDLER event_receiver->handle_double_click FOR grid1.
      ENDIF.
      CALL METHOD cl_gui_control=>set_focus
        EXPORTING
          control = grid1.
    endmodule.                 " STATUS_0100  OUTPUT
    *  MODULE PAI_ALV INPUT
    MODULE USER_COMMAND_0100.
    CALL METHOD cl_gui_cfw=>dispatch.
      CASE sy-ucomm.
        WHEN 'BACK' OR 'EXIT' OR 'CANC'.
          LEAVE TO SCREEN 0.
      ENDCASE.
    ENDMODULE.                    "PAI_ALV INPUT
    *&      Form  fieldcatalog_init
    *       text
    *      -->LT_FIELDCATtext
    *      -->VALUE(FIELDtextE)
    *      -->VALUE(FIELDtextE)
    *      -->VALUE(FIELDtextT)
    FORM fieldcatalog_init USING lt_fieldcatalog TYPE lvc_t_fcat
                           value(field_name) value(field_type)
    value(field_text).
      DATA: ls_fieldcatalog TYPE lvc_s_fcat.
      CLEAR ls_fieldcatalog.
      ls_fieldcatalog-fieldname = field_name.
      ls_fieldcatalog-datatype  = field_type.
      ls_fieldcatalog-reptext   = field_text.
      ls_fieldcatalog-coltext  =  field_text.
      ls_fieldcatalog-seltext  =  field_text.
      ls_fieldcatalog-tooltip  =  field_text.
      APPEND ls_fieldcatalog TO lt_fieldcatalog.
    ENDFORM.                    "fieldcatalog_init
    *&      Form  sort_build
    *       text
    *      -->LT_SORT    text
    FORM sort_build USING lt_sort TYPE lvc_t_sort.
      DATA: ls_sort TYPE lvc_s_sort.
      ls_sort-fieldname = 'KUNAG'.    "Fieldname on which to sort
      ls_sort-up        = 'X'.        "Sort Ascending
      APPEND ls_sort TO lt_sort.
      ls_sort-fieldname = 'NAME1'.    "Fieldname on which to sort
      ls_sort-up        = 'X'.        "Sort Ascending
      APPEND ls_sort TO lt_sort.
    ENDFORM.                    "sort_build
    *&      Form  layout_init
    *       text
    *      -->LS_LAYOUT  text
    FORM layout_init USING ls_layout TYPE lvc_s_layo.
      ls_layout-zebra      = 'X'.
      ls_layout-grid_title = 'Customer Details'.
      ls_layout-sel_mode   = 'A'.
      ls_layout-cwidth_opt = 'X'.
    ENDFORM.                    "layout_init
    *&      Form  create_detail_list
    *         text
    *    -->  p1        text
    *    <--  p2        text
    FORM create_detail_list.
    *   create dialogbox container as dynpro-instance
    *   When the user switches to another screen, it is
    *   destroyed by lifetime mangagement of CFW
      CREATE OBJECT dialogbox_container
          EXPORTING
            top = 150
            left = 150
            lifetime = cntl_lifetime_dynpro
            caption = 'INVOICE DETAILS'(200)
            width = 800
            height = 200.
      CREATE OBJECT grid2
          EXPORTING i_parent = dialogbox_container.
    *   Register ABAP OO event 'CLOSE'. It is not necessary to register this
    *   event at the frontend (this is done during creation).
      SET HANDLER event_receiver->handle_close FOR dialogbox_container.
    *   display data
      gs_layout-grid_title = 'Invoice Details'(100).
      CALL METHOD grid2->set_table_for_first_display
        EXPORTING
          i_structure_name = 'itab'
          is_layout        = gs_layout
        CHANGING
          it_outtab        = itab[]
          it_fieldcatalog  = gt_fieldcatalog
          it_sort          = gt_sort.
      CALL METHOD cl_gui_control=>set_focus
        EXPORTING
          control = grid2.
    ENDFORM.                    " create_detail_list
    Nothing wrong in the code i am able to see the output with five records and the pop-up screen on double clicking a value.
    Kindly close the thread or revert back

  • 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

  • Update ZTable from editable ALV

    Hi All,
    i'm calling a Function Module from within a Badi Class ( Workorder_Update) which uses an ALV to Add Comments in a Field of the ALV for Transportation to a ZTable. Therefore the ALV is set to editable.
    The Problem is that if the User does not press 'enter' after she/he added the Comment, the value is not send back to the internal Table wich updates the ZTab. If the User presses 'enter' ONLY the Comment is transported but the remainder of the Fields are cleared.
    This is part of the Coding:
    Before Calling FM -->
      + IF wa_header_old-pronr NE wa_header-pronr.
            CLEAR wa_zthlog.
            wa_zthlog-uzeit     = sy-uzeit.
            wa_zthlog-aufnr     = wa_header-aufnr.
            wa_zthlog-objnr     = wa_header-objnr.
            wa_zthlog-vornr     = wa_operation-vornr.
            wa_zthlog-ktext     = wa_header-ktext.
            wa_zthlog-aenam     = sy-uname.
            wa_zthlog-aedat     = sy-datum.
            wa_zthlog-larnt     = wa_operation-larnt.
            wa_zthlog-pronr     = wa_header-pronr.
            wa_zthlog-arbei     = wa_operation-arbei.
            wa_zthlog-dauno     = wa_operation-dauno.
            wa_zthlog-dauno     = wa_operation-dauno.
            wa_zthlog-ltxa1     = wa_operation-ltxa1.
            wa_zthlog-arbid     = wa_operation-arbid.
            wa_zthlog-fieldname = 'PRONR'.
            wa_zthlog-matkl     = wa_operation-matkl.
            wa_zthlog-preis     = wa_operation-preis.
            wa_zthlog-waers     = wa_header-waers.
            wa_zthlog-old_value = wa_header_old-pronr.
            wa_zthlog-new_value = wa_header-pronr.
    Fill t_zthlog - Call FM
            APPEND wa_zthlog TO t_zthlog.
          ENDIF.
        ENDLOOP.
    Secure Values before change
        MOVE t_zthlog TO y_zthlog.+
    Calling FM -->
    +function z_thlog.
      t_zthlog[] = c_zthlog[].
      call screen 0100 starting at 10 3.
      c_zthlog[] = t_zthlog[].
    endfunction.+
    ALV Grid - Processing -->
    +module output_0100 output.
    Fill Fieldcatalog
      call function 'LVC_FIELDCATALOG_MERGE'
        exporting
          i_structure_name       = 'ZTHLOG'
        changing
          ct_fieldcat            = gt_fieldcat[]
        exceptions
          inconsistent_interface = 1
          program_error          = 2
          others                 = 3.
      if g_custom_container is initial.
    Prepare ALV
        create object g_custom_container
             exporting container_name = g_container.
        create object grid1
             exporting i_parent = g_custom_container.
        g_repid = sy-repid.
        gs_layout-grid_title = 'Änderungsprotokoll'.
        gs_layout-zebra      = 'X'.
        gs_layout-cwidth_opt = 'X'.
        gs_variant-report    = g_repid.
        gs_variant           = '/default'.
    gs_layout-edit = 'X'.
    Call ALV
        call method grid1->set_table_for_first_display
          exporting
            i_structure_name = 'ZTHLOG'
            is_layout        = gs_layout
            i_save           = 'A'
            is_variant       = gs_variant
          changing
            it_outtab        = t_zthlog
            it_fieldcatalog  = gt_fieldcat[].
    Ready for Input
        call method grid1->set_ready_for_input
          exporting
            i_ready_for_input = 1.
    Eventregistration
        call method grid1->register_edit_event
          exporting
            i_event_id = cl_gui_alv_grid=>mc_evt_enter.
        create object g_event_receiver.
        set handler g_event_receiver->handle_data_changed for grid1.
      else.
    Refresh, if filled
        call method grid1->refresh_table_display.
      endif.
    set Cursor
      call method cl_gui_control=>set_focus
        exporting
          control = grid1.
    endmodule.                 " output_0100  OUTPUT+
    There are alot of fields so the manual creation of the fieldcatalog should be avoided if possible.
    Any Help is appreciated!
    Best Regards
    Stefan

    Hi,
    Check this
    * Module Pai INPUT                                                     *
    * PAI module                                                           *
    module pai input.
      save_ok = ok_code.
      clear ok_code.
      call method grid1->check_changed_data
        importing
          e_valid = v_valid.
    " After this system will automatically update your changed data into
    " internal table t_zthlog
      case save_ok.
        when 'EXIT'.
          perform f_exit_program.
        when 'CANC'.
          perform f_exit_program.
        when 'BACK'.
          perform f_exit_program.
        when 'SAVE'.
          perform f_save_data.
      endcase.
    endmodule.                               " Pai INPUT
    aRs

  • ALV report editable to enter text and print with including the text?

    Hi all,
    I have to display output of a  report in ALV format and i have to make two fileds can be editable to enter texts by user  and able to print the list with that texts .
    Is it possible using standard Function modules or I have to go for OO methods? Please give the sample code ?
    Thanks,
    Vamshi
    Edited by: VAMSHI KRISHNA on Oct 31, 2008 4:25 PM

    Hi Vamshi,
    Check out the Below sample code for the editable ALV.
    *& Report  Z7CC_OOPS_ALV_EDITABLE
    report  z7cc_oops_alv_editable.
    tables sflight.
    data: begin of gt_outtab occurs 0.     "with header line
            include structure sflight.
    data: celltab type lvc_t_styl.
    data: end of gt_outtab.
    data: gt_fieldcat type lvc_t_fcat.
    data: g_carrid like sflight-carrid,
          g_connid like sflight-connid.
    data: gs_spfli type spfli.                                  "#EC NEEDED
    data: g_custom_container type ref to cl_gui_custom_container.
    data:  g_container type scrfname value 'BCALV_GRID_DEMO_0100_CONT1'.
    data: g_grid  type ref to cl_gui_alv_grid.
    data: wa_outtab like gt_outtab.
    *       CLASS lcl_event_receiver DEFINITION
    class lcl_event_receiver definition.
      public section.
        types: begin of sflight_key.
        types:   carrid type s_carr_id.
        types:   connid type s_conn_id.
        types:   fldate type s_date.
        types: end of sflight_key.
        types: sflight_keys type standard table of sflight_key,
               sflight_table type standard table of sflight.
        methods:
          handle_data_changed
             for event data_changed of cl_gui_alv_grid
                 importing er_data_changed.
        methods:
          get_inserted_rows
               exporting
                  inserted_rows type sflight_keys.
        methods:
          get_deleted_rows
              exporting
                  deleted_rows type sflight_table.
        methods:
           refresh_delta_tables.
        methods: set_table_is_initial.
        methods: set_table_is_not_initial.
        methods: table_is_initial
                    returning value(initial) type char01.
      private section.
    * §4.Define internal tables to remember inserted and deleted lines,
    *    thus the delta between input made after the last saving.
        data: inserted_rows type sflight_keys,
              deleted_rows type standard table of sflight.
    * This flag is set if any error occured in one of the
    * following methods:
        data: error_in_data type c.
    * This flag signals that no records were read for the flight
    * table initially:
        data: initial_table type c.
    ** Methods to modularize event handler method HANDLE_DATA_CHANGED:
        methods:
          check_double_entries
             importing
                pr_data_changed type ref to cl_alv_changed_data_protocol.
        methods:
          update_delta_tables
             importing
                pr_data_changed type ref to cl_alv_changed_data_protocol.
        methods:
          perform_semantic_checks
             importing
                pr_data_changed type ref to cl_alv_changed_data_protocol.
        methods:
          get_cell_values
               importing
                 row_id          type int4
                 pr_data_changed type ref to cl_alv_changed_data_protocol
               exporting
                 key             type sflight_key.
    endclass.                    "lcl_event_receiver DEFINITION
    class lcl_event_receiver implementation.
      method handle_data_changed.
    *    data: ls_good type lvc_s_modi,
    *          l_price type s_price,
    *          ls_new type lvc_s_moce.
    *    error_in_data = space.
    ** check if there exist double entries
    *    call method check_double_entries( er_data_changed ).
    ** remember new or deleted lines for saving
    *    call method update_delta_tables( er_data_changed ).
    ** check mt_good_cells semantically
    *    call method perform_semantic_checks( er_data_changed ).
    *    if error_in_data = 'X'.
    *      call method er_data_changed->display_protocol.
    *    endif.
      endmethod.                    "handle_data_changed
      method check_double_entries.
        data: lt_good_cells type lvc_t_modi,
              ls_good type lvc_s_modi,
              ls_key type sflight_key,
              ls_sflight type sflight,
              l_flightdate like gt_outtab-fldate,
              l_del_row type lvc_s_moce,
              ls_outtab like line of gt_outtab,
              l_reentered type c.
    * §5.Check if there exist already other records with equal key fields.
    * Check if the user has entered two new lines where the key fields
    * are equal.
    * Since CARRID and CONNID are read only, the check is restrained
    * to field FLDATE.
    * Algorithm: Copy all entries in MT_GOOD_CELLS to a dummy table.
    *            During the copying procedure check if there exists
    *            already a line with the same Flight date.
    *    loop at pr_data_changed->mt_good_cells into ls_good.
    *      case ls_good-fieldname.
    *        when 'FLDATE'.
    *          call method pr_data_changed->get_cell_value
    *                      exporting
    *                            i_row_id = ls_good-row_id
    *                            i_fieldname = ls_good-fieldname
    *                      importing e_value = l_flightdate.
    *          read table lt_good_cells with key
    *                            value = l_flightdate
    *                            transporting no fields.
    *          if sy-subrc = 0.
    ** There exists already a line with the same flight date!
    *            call method pr_data_changed->add_protocol_entry
    *                         exporting
    *              i_msgid = '0K' i_msgno = '000'  i_msgty = 'E'
    *              i_msgv1 = text-m01
    *              i_fieldname = ls_good-fieldname
    *              i_row_id = ls_good-row_id.
    *            error_in_data = 'X'.
    *          else.
    *            ls_good-value = l_flightdate.
    *            append ls_good to lt_good_cells.
    *          endif.
    *      endcase.
    *    endloop.
    ** Check if any new entries already exist in gt_outtab.
    ** At this point, lt_good_cells contains only lines with
    ** FIELDNAME = 'FLDATE'.
    *    loop at lt_good_cells into ls_good.
    *      l_flightdate = ls_good-value.      "flightdate, see above
    *      read table gt_outtab with key
    *                    carrid = g_carrid
    *                    connid = g_connid
    *                    fldate = l_flightdate
    *                    transporting no fields.
    *      if sy-subrc = 0.
    ** Check if this entry was deleted before, i.e. it is in the table
    ** of deleted rows. If so, the entry does not exist twice. The user
    ** has deleted a line and then reentered it.
    *        l_reentered = space.
    *        loop at pr_data_changed->mt_deleted_rows into l_del_row.
    *          read table gt_outtab into ls_outtab index l_del_row-row_id.
    *          if sy-subrc ne 0.
    *            message i000(0k) with text-e01."Fehler beim Löschen
    *          elseif
    *                    ls_outtab-carrid eq g_carrid
    *                and ls_outtab-connid eq g_connid
    *                and ls_outtab-fldate eq ls_good-value.
    *            l_reentered = 'X'.
    *          endif.
    *        endloop.
    *        if l_reentered ne 'X'.
    *          call method pr_data_changed->add_protocol_entry
    *                         exporting
    *              i_msgid = '0K' i_msgno = '000'  i_msgty = 'E'
    *              i_msgv1 = text-m01
    *              i_fieldname = ls_good-fieldname
    *              i_row_id = ls_good-row_id.
    *          error_in_data = 'X'.
    *        endif.
    *      endif.
    *    endloop.
    ** In this demo report you may prevent the selection
    ** of data by setting parameter 'p_ds'.
    ** If this is done, the next check is required:
    *    if me->table_is_initial( ) eq 'X'.
    *      call method get_cell_values
    *           exporting row_id          = 1
    *                     pr_data_changed = pr_data_changed
    *           importing key             = ls_key.
    *      select single * from sflight into ls_sflight
    *                where carrid = ls_key-carrid
    *                  and connid = ls_key-connid
    *                  and fldate = ls_key-fldate.
    *      if sy-subrc = 0.
    *        call method pr_data_changed->add_protocol_entry
    *                       exporting
    *            i_msgid = '0K' i_msgno = '000'  i_msgty = 'E'
    *            i_msgv1 = text-m01
    *            i_fieldname = 'FLDATE'
    *            i_row_id = 1.
    *        error_in_data = 'X'.
    *      endif.
    ** flag initial_table is reset in method 'update_delta_tables'
    *    endif.
      endmethod.                    "check_double_entries
      method update_delta_tables.
    *    data: l_ins_row type lvc_s_moce,
    *          l_del_row type lvc_s_moce,
    *          ls_key type sflight_key,
    *          ls_sflight type sflight,
    *          ls_outtab like line of gt_outtab.
    ** §6.Use protocol attributes MT_DELETED_ROWS and MT_INSERTED_ROWS
    **    to remember which lines where deleted or inserted. Save this
    **    information in your internal tables.
    ** deleted rows
    *    loop at pr_data_changed->mt_deleted_rows into l_del_row.
    *      read table gt_outtab into ls_outtab index l_del_row-row_id.
    *      if sy-subrc ne 0.
    *        message i000(0k) with text-e01."Fehler beim Löschen
    *      else.
    *        move-corresponding ls_outtab to ls_sflight.
    ** It should no be possible that the same line is deleted twice,
    ** so we just add the new key line to 'deleted_rows'.
    *        append ls_sflight to deleted_rows.
    ** If this line was inserted just before it is deleted:
    *        delete me->inserted_rows
    *             where carrid = ls_outtab-carrid
    *             and   connid = ls_outtab-connid
    *             and   fldate = ls_outtab-fldate.
    *      endif.
    *    endloop.
    ** inserted rows
    ** At this point ALV has not added new lines
    ** to gt_outtab, so you can not access their values
    ** by reading gt_outtab.
    ** Table MT_GOOD_CELLS holds new values that can be
    ** referenced using the ROW_ID.
    *    if me->table_is_initial( ) eq 'X'.
    ** No flights were selected initially. This is the first new line.
    *      call method get_cell_values
    *            exporting row_id          = 1
    *                      pr_data_changed = pr_data_changed
    *            importing key             = ls_key.
    *      append ls_key to inserted_rows.
    *      call method me->set_table_is_not_initial.
    *    endif.
    *    loop at pr_data_changed->mt_inserted_rows into l_ins_row.
    *      call method get_cell_values
    *              exporting row_id          = l_ins_row-row_id
    *                        pr_data_changed = pr_data_changed
    *              importing key             = ls_key.
    **      READ TABLE gt_outtab INTO ls_outtab INDEX l_ins_row-row_id.
    ** Just insert the new row regardless if the input is wrong
    *      append ls_key to inserted_rows.
    *    endloop.
      endmethod.                    "update_delta_tables
      method get_cell_values.
    * get values of key cells of row ROW_ID
    ** CARRIER
    *    call method pr_data_changed->get_cell_value
    *          exporting
    *                 i_row_id    = row_id
    *                 i_fieldname = 'CARRID'
    *               importing
    *                 e_value = key-carrid.
    *    if sy-subrc ne 0.
    *      message i000(0k) with text-e02.  "Fehler beim Einfügen
    *    endif.
    ** CONNID
    *    call method pr_data_changed->get_cell_value
    *          exporting
    *                 i_row_id    = row_id
    *                 i_fieldname = 'CONNID'
    *               importing
    *                 e_value = key-connid.
    *    if sy-subrc ne 0.
    *      message i000(0k) with text-e02.  "Fehler beim Einfügen
    *    endif.
    ** FLDATE
    *    call method pr_data_changed->get_cell_value
    *          exporting
    *                 i_row_id    = row_id
    *                 i_fieldname = 'FLDATE'
    *               importing
    *                 e_value = key-fldate.
    *    if sy-subrc ne 0.
    *      message i000(0k) with text-e02.  "Fehler beim Einfügen
    *    endif.
      endmethod.                    "get_cell_values
      method perform_semantic_checks.
    *    data: ls_good type lvc_s_modi,
    *          l_planetype type s_planetye,
    *          l_seatsmax type s_seatsmax.
    *    loop at pr_data_changed->mt_good_cells into ls_good.
    *      case ls_good-fieldname.
    *        when 'PLANETYPE'.
    *          call method pr_data_changed->get_cell_value
    *             exporting
    *               i_row_id = ls_good-row_id
    *               i_fieldname = ls_good-fieldname
    *             importing
    *               e_value = l_planetype.
    *          select single seatsmax from saplane into l_seatsmax
    *                        where planetype = l_planetype.
    *          if sy-subrc ne 0.
    *            call method pr_data_changed->add_protocol_entry
    *                            exporting
    *                 i_msgid = '0K' i_msgno = '000'  i_msgty = 'E'
    *                 i_msgv1 = text-m02
    *                 i_fieldname = ls_good-fieldname
    *                 i_row_id = ls_good-row_id.
    *            error_in_data = 'X'.
    *          else.
    *            call method pr_data_changed->modify_cell
    *              exporting i_row_id    = ls_good-row_id
    *                        i_fieldname = 'SEATSMAX'
    *                        i_value     = l_seatsmax.
    *          endif.
    *      endcase.
    *    endloop.
      endmethod.                    "perform_semantic_checks
      method get_inserted_rows.
    *    inserted_rows = me->inserted_rows.
      endmethod.                    "get_inserted_rows
      method get_deleted_rows.
    *    deleted_rows = me->deleted_rows.
      endmethod.                    "get_deleted_rows
      method refresh_delta_tables.
    *    clear me->inserted_rows[].
    *    clear me->deleted_rows[].
      endmethod.                    "refresh_delta_tables
      method set_table_is_initial.
    *    initial_table = 'X'.
      endmethod.                    "set_table_is_initial
      method set_table_is_not_initial.
    *    initial_table = space.
      endmethod.                    "set_table_is_not_initial
      method table_is_initial.
    *    if initial_table = 'X'.
    *      initial = 'X'.
    *    else.
    *      initial = space.
    *    endif.
      endmethod.                    "table_is_initial
    endclass.                    "lcl_event_receiver IMPLEMENTATION
    data: g_verifier type ref to lcl_event_receiver.
    data: g_max type i value 100.
    data: gs_layout type lvc_s_layo.
    data: ok_code like sy-ucomm,
          save_ok like sy-ucomm.
    parameters: p_ds type c as checkbox.   "delete selection
    select-options s_carrid for sflight-carrid
                                no intervals no-extension default 'LH'.
    select-options s_connid for sflight-connid
                               no intervals no-extension default '0400'.
    start-of-selection.
      g_carrid = s_carrid-low.
      g_connid = s_connid-low.
    * first check airline and connection
      select single * from spfli into gs_spfli
                         where carrid = g_carrid
                         and connid = g_connid.
      call screen 100.
    *&      Module  STATUS_0100  OUTPUT
    *       text
    module status_0100 output.
      set pf-status 'MAIN100'.
      set titlebar 'MAIN100'.
      if g_custom_container is initial.
        perform create_and_init_alv changing gt_outtab[]
                                             gt_fieldcat.
      endif.
    endmodule.                 " STATUS_0100  OUTPUT
    *&      Form  create_and_init_alv
    *       text
    *      <--P_GT_OUTTAB[]  text
    *      <--P_GT_FIELDCAT  text
    form create_and_init_alv changing pt_outtab like gt_outtab[]
                                      pt_fieldcat type lvc_t_fcat.
      data: lt_exclude type ui_functions.
      create object g_custom_container
             exporting container_name = g_container.
      create object g_grid
             exporting i_parent = g_custom_container.
    * Create Objekt to verify input values.
    * (This object is already needed in form SELECT_DATA).
      create object g_verifier.
    *  SET HANDLER g_verifier->handle_data_changed FOR g_grid.
      perform select_data changing pt_outtab[].
      perform build_fieldcat changing pt_fieldcat.
      perform exclude_tb_functions changing lt_exclude.
      gs_layout-stylefname = 'CELLTAB'.
      call method g_grid->set_table_for_first_display
        exporting
          it_toolbar_excluding = lt_exclude
          is_layout            = gs_layout
        changing
          it_fieldcatalog      = pt_fieldcat
          it_outtab            = pt_outtab[].
    * Set editable cells to ready for input initially
      call method g_grid->set_ready_for_input
        exporting
          i_ready_for_input = 1.
    endform.                    " create_and_init_alv
    *&      Form  select_data
    *       text
    *      <--P_GT_OUTTAB  text
    form select_data changing pt_outtab like gt_outtab[].
      data: lt_sflight type table of sflight,
            ls_sflight type sflight,
            ls_outtab like line of gt_outtab,
            l_index type i,
            ls_spfli type spfli,                                "#EC NEEDED
            lt_celltab type lvc_t_styl.
    * Check parameter 'p_ds'=>optionally select no data
      if p_ds is initial.
    * Select data from sflight
        select * from sflight into table lt_sflight up to g_max rows
                         where carrid = g_carrid
                           and connid = g_connid.
      endif.
      if sy-subrc ne 0 or not p_ds is initial.
    * no flights were found!
    * We provide some default values for the first line that is entered:
        ls_outtab-carrid = g_carrid.
        ls_outtab-connid = g_connid.
        case g_carrid.
          when 'LH'.
            ls_outtab-currency = 'DEM'.
          when others.
            ls_outtab-currency = 'US'.
        endcase.
        ls_outtab-seatsocc = 0.
        ls_outtab-paymentsum = 0.
    * set fields FLDATE, PRICE and PLANETYPE to editable
        perform fill_celltab using 'RW'
                             changing lt_celltab.
        insert lines of lt_celltab into table ls_outtab-celltab.
        append ls_outtab to pt_outtab.
    * Tell Verify-Objekt that the table was initial
        call method g_verifier->set_table_is_initial.
      else.
        call method g_verifier->set_table_is_not_initial.
    * move corresponding fields from lt_sflight to gt_outtab
        loop at lt_sflight into ls_sflight.
          move-corresponding ls_sflight to ls_outtab.
          append ls_outtab to pt_outtab.
        endloop.
    * §3.Set all cells of the table non-editable by using the style table.
        loop at pt_outtab into ls_outtab.
          l_index = sy-tabix.
          refresh lt_celltab.
          perform fill_celltab using 'RO'
                            changing lt_celltab.
    * Copy your celltab to the celltab of the current row of gt_outtab.
          insert lines of lt_celltab into table ls_outtab-celltab.
          modify pt_outtab from ls_outtab index l_index.
        endloop.
      endif.
    endform.                               " select_data
    *&      Form  fill_celltab
    *       text
    *      -->VALUE(P_MODE)  text
    *      -->PT_CELLTAB     text
    form fill_celltab using value(p_mode)
                      changing pt_celltab type lvc_t_styl.
      data: ls_celltab type lvc_s_styl,
            l_mode type raw4.
    * This forms sets the style of columns 'PRICE', FLDATE and PLANETYPE
    * editable
      if p_mode eq 'RW'.
        l_mode = cl_gui_alv_grid=>mc_style_enabled.
      else.                                "p_mode eq 'RO'
        l_mode = cl_gui_alv_grid=>mc_style_disabled.
      endif.
      ls_celltab-fieldname = 'FLDATE'.
      ls_celltab-style = l_mode.
      insert ls_celltab into table pt_celltab.
      ls_celltab-fieldname = 'PRICE'.
      ls_celltab-style = l_mode.
      insert ls_celltab into table pt_celltab.
      ls_celltab-fieldname = 'PLANETYPE'.
      ls_celltab-style = l_mode.
      insert ls_celltab into table pt_celltab.
    endform.                               " FILL_CELLTAB
    *&      Form  BUILD_FIELDCAT
    *       text
    *      <--P_GT_FIELDCAT  text
    form build_fieldcat changing pt_fieldcat type lvc_t_fcat.
      data ls_fcat type lvc_s_fcat.
      call function 'LVC_FIELDCATALOG_MERGE'
        exporting
          i_structure_name = 'SFLIGHT'
        changing
          ct_fieldcat      = pt_fieldcat.
      loop at pt_fieldcat into ls_fcat.
        if    ls_fcat-fieldname eq 'PRICE'
           or ls_fcat-fieldname eq 'PLANETYPE'
           or ls_fcat-fieldname eq 'FLDATE'.
    * §1.Set status of columns FLDATA, PRICE and PLANETYPE to editable.
    *    Since all cells are set to non-editable (see step 3) the cells
    *    of this columns will only be editable for new lines.
          ls_fcat-edit = 'X'.
    * Field 'checktable' is set to avoid shortdumps that are caused
    * by inconsistend data in check tables. You may comment this out
    * when the test data of the flight model is consistent in your system.
          ls_fcat-checktable = '!'.        "do not check foreign keys
          modify pt_fieldcat from ls_fcat.
        elseif ls_fcat-fieldname = 'CARRID'
           or ls_fcat-fieldname = 'CONNID'
           or ls_fcat-fieldname = 'CURRENCY'.
    * §2.Use field AUTO_VALUE of the fieldcatalog to preset values when new
    *    lines are added.
          ls_fcat-auto_value = 'X'.
          ls_fcat-checktable = '!'.   "do not check foreign key relations
          modify pt_fieldcat from ls_fcat.
        endif.
      endloop.
    endform.                    "build_fieldcat
    *&      Form  exclude_tb_functions
    *       text
    *      <--P_LT_EXCLUDE  text
    form exclude_tb_functions changing pt_exclude type ui_functions.
      data ls_exclude type ui_func.
      ls_exclude = cl_gui_alv_grid=>mc_fc_loc_insert_row.
      append ls_exclude to pt_exclude.
      ls_exclude = cl_gui_alv_grid=>mc_fc_loc_undo.
      append ls_exclude to pt_exclude.
      ls_exclude = cl_gui_alv_grid=>mc_fc_loc_copy_row.
      append ls_exclude to pt_exclude.
    endform.                               " EXCLUDE_TB_FUNCTIONS
    *&      Module  USER_COMMAND_0100  INPUT
    *       text
    module user_command_0100 input.
      save_ok = sy-ucomm.
      clear ok_code.
      case save_ok.
        when 'SAVE'.
    *      perform save_data.
        when 'BACK'.
    * §10.Unlock your database table.
    *      perform unlock_sflight.
          leave to screen 0.
        when 'EXIT'.
          perform exit_program.
        when 'ADD'.
          perform add_line_item.
        when others.
    *     do nothing
      endcase.
    endmodule.                 " USER_COMMAND_0100  INPUT
    *       FORM EXIT_PROGRAM                                             *
    form exit_program.
      leave program.
    endform.                    "exit_program
    *&      Form  ADD_LINE_ITEM
    *       text
    *  -->  p1        text
    *  <--  p2        text
    form add_line_item .
    data: lt_rows type lvc_t_row.
    data: wa_rows type lvc_t_row with header line.
    data: tabix type sy-tabix.
    *&Find the  row ( index ) number
    call method g_grid->get_selected_rows
              importing et_index_rows = lt_rows.
    call method cl_gui_cfw=>flush.
    read table lt_rows into wa_rows index 1.
    tabix = wa_rows-index .
    insert gt_outtab  index tabix.
    *REFRESH_TABLE_DISPLAY
    call method g_grid->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.
    endform.                    " ADD_LINE_ITEM
    Thanks,
    Chidanand

  • Unable to display grid using OOALV

    Hi,
    I'm not able to display the list using Object-Oriented ALV technique. On executing it shows a pop-up error message as 'Program Error'. When I see its details, it shows as 'Output table passed to the ALV is not defined globally but locally. thus the reference to the table is lost'. My code snippet is as follows:
    <Garbled code removed by moderator>
    Kindly inform me the reason for this error or inform me the resolution for it.
    I've created the Screen '200' and Custom container in it. Given the same name (i.e 'cust_cont') as ALV grid's parent. Also created the PF Status 'GRID'
    Moderator message : Post only relevant portion of source code, use code tags for better visibility of code.
    Edited by: Vinod Kumar on Jan 12, 2012 6:29 PM

    You have to define the table in the TOP include of your program, then you should be good to go.
    I have not seen your code but you have to do something like this
      IF G_CUSTOM_CONTAINER IS INITIAL.
    * creating container
        CREATE OBJECT G_CUSTOM_CONTAINER
               EXPORTING CONTAINER_NAME = G_CONTAINER.
    * creating ALV GRID...
        CREATE OBJECT GRID1
               EXPORTING I_PARENT = G_CUSTOM_CONTAINER.
    * SEt layout and fieldcat
        PERFORM layout.
        PERFORM fieldcat.
    * Show list
        CALL METHOD GRID1->SET_TABLE_FOR_FIRST_DISPLAY
             EXPORTING
               IS_LAYOUT        = ge_layout
             CHANGING
               IT_FIELDCATALOG  = gt_fieldcat
               IT_OUTTAB        = gt_materiales.
      ENDIF.
    kind regards!

  • Drop down list in ALV grid

    Dear Expert,
    I am new to OOPS ,
    I want to display drop down list for a particular field in my output, so I am using OOPS but in my below code
    I am facing problem in displaying the output as I am getting the error message
    Field catalog not found...
    Also advice me how to display drop down list in a particular field.
    Please advice
    MODULE pbo OUTPUT.
      SET PF-STATUS 'ZTEST'.
      IF g_custom_container IS INITIAL.
        DATA: lt_exclude TYPE ui_functions,
              lt_f4 TYPE lvc_t_f4 WITH HEADER LINE.
        CREATE OBJECT g_custom_container
          EXPORTING
            container_name = g_container.
        CREATE OBJECT g_grid
          EXPORTING
            i_parent = g_custom_container.
        PERFORM field_catalog TABLES it_lvc_t_fcat
           USING: 'S_FINAL' 'MATNR' ' ' 'Part Number' ' ' ' ',
                       'S_FINAL' 'MAKTX' ' ' 'Part Description' ' ' ' ',
                       'S_FINAL' 'MBLNR' ' ' 'Document No' ' ' ' ',
                       'S_FINAL' 'BLDAT' ' ' 'Document date' ' ' ' ',
                       'S_FINAL' 'LIFNR' ' ' 'Vendor Number' ' ' ' ',
                       'S_FINAL' 'STATUS' ' ' 'Acknowledgement' ' ' 'X',
                       'S_FINAL' 'REMARKS' ' ' 'Remarks' ' ' 'X'.
        CALL METHOD g_grid->set_table_for_first_display
           EXPORTING
    *    I_STRUCTURE_NAME              =
         is_layout                                =   it_lvc_s_layo
           CHANGING
             it_outtab                        =   i_final
         it_fieldcatalog                =   it_lvc_t_fcat
      ENDIF.
    ENDMODULE.                 " PBO  OUTPUT
    FORM field_catalog  TABLES t_field_catalog STRUCTURE wt_lvc_s_fcat
    USING fp_tabname TYPE any
    fp_fieldname TYPE any
    fp_key TYPE any
    fp_text TYPE any
    fp_do_sum TYPE any
    fp_edit TYPE any.
      t_field_catalog-tabname = fp_tabname.
      t_field_catalog-fieldname = fp_fieldname.
      t_field_catalog-key = fp_key.
      t_field_catalog-seltext = fp_text.
      t_field_catalog-do_sum = fp_do_sum .
      t_field_catalog-edit = fp_edit .
    ENDFORM.                    "field_catalog
    Edited by: Karthik R on Mar 15, 2010 6:11 PM

    Hi Karthik,
    Below mentioned  is a Simple code for creating dropdown lists for columns in ALV grid output
    REPORT z_alv_dropdown.
    *Type pools declarations for ALV
    TYPE-POOLS : slis.
    *data declarations for ALV container, ALV grid,  Field catalogues & layout
    DATA: g_grid  TYPE REF TO cl_gui_alv_grid,
          g_custom_container TYPE REF TO cl_gui_custom_container,
          gt_fieldcat TYPE lvc_t_fcat,
          gs_layout TYPE lvc_s_layo.
    *INTERNAL TABLE AND WA DECLARATIONS FOR t517 A table
    DATA: gt_outtab TYPE STANDARD TABLE OF t517a INITIAL SIZE 0,
          wa_outtab TYPE t517a.
    *initialisation event
    INITIALIZATION.
    *Start of selection event
    START-OF-SELECTION.
    *Call to ALV
      CALL SCREEN 600.
    *On this statement double click  it takes you to the screen painter SE51.
    *Create a Custom container and name it CCONT 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
    Here we also call the subroutine for ALV output.
          MODULE PBO OUTPUT                                             *
    MODULE pbo OUTPUT.
    set pf-status 'xxx'.
    set titlebar 'MAIN100'.
    Subroutine to display the output in alv
      PERFORM alv_output.
    ENDMODULE.                    "pbo OUTPUT
    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 PAI INPUT                                              *
    MODULE pai INPUT.
    ENDMODULE.                    "pai INPUT
    *&      Form  BUILD_FIELDCAT
    FORM build_fieldcat.
      DATA ls_fcat TYPE lvc_s_fcat.
    *Build the field catalogue
      CALL FUNCTION 'LVC_FIELDCATALOG_MERGE'
        EXPORTING
          i_structure_name = 'T517A'
        CHANGING
          ct_fieldcat      = gt_fieldcat.
    To assign dropdown in the fieldcataogue
      LOOP AT gt_fieldcat INTO ls_fcat.
        CASE ls_fcat-fieldname.
          WHEN 'SLART'.
    *drdn-hndl = '1' is the first list box
            ls_fcat-drdn_hndl = '1'.
            ls_fcat-outputlen = 15.
            MODIFY gt_fieldcat FROM ls_fcat.
    *drdn-hndl = '2' is the second list box
          WHEN 'ABART'.
            ls_fcat-drdn_hndl = '2'.
            ls_fcat-outputlen = 15.
            MODIFY gt_fieldcat FROM ls_fcat.
        ENDCASE.
      ENDLOOP.
    ENDFORM.                    "build_fieldcat
    *&      Form  ALV_OUTPUT
    FORM alv_output .
    *Create object for container
      CREATE OBJECT g_custom_container
             EXPORTING container_name = 'CCONT'.
    *create object for grid
      CREATE OBJECT g_grid
             EXPORTING i_parent = g_custom_container.
    Build fieldcat and set column
    *Assign a handle for the dropdown listbox.
      PERFORM build_fieldcat.
    *Build layout
      PERFORM build_layout.
    Define a drop down table.
      PERFORM dropdown_table.
    *fetch values from the T517A table
      SELECT * FROM t517a INTO TABLE gt_outtab.
    *Display ALV output
      CALL METHOD g_grid->set_table_for_first_display
        EXPORTING
          is_layout       = gs_layout
        CHANGING
          it_fieldcatalog = gt_fieldcat
          it_outtab       = gt_outtab.
    ENDFORM.                               "ALV_OUTPUT
    *&      Form  dropdown_table
          text
    -->  p1        text
    <--  p2        text
    FORM dropdown_table.
    *Declarations for drop down lists in ALV.
      DATA: lt_dropdown TYPE lvc_t_drop,
            ls_dropdown TYPE lvc_s_drop.
    First SLART listbox (handle '1').
      ls_dropdown-handle = '1'.
      ls_dropdown-value = '01 Pink'.
      APPEND ls_dropdown TO lt_dropdown.
      ls_dropdown-handle = '1'.
      ls_dropdown-value = '02 Yellow'.
      APPEND ls_dropdown TO lt_dropdown.
      ls_dropdown-handle = '1'.
      ls_dropdown-value = '03 Green'.
      APPEND ls_dropdown TO lt_dropdown.
      ls_dropdown-handle = '1'.
      ls_dropdown-value = '04 Black'.
      APPEND ls_dropdown TO lt_dropdown.
      ls_dropdown-handle = '1'.
      ls_dropdown-value = '05 White'.
      APPEND ls_dropdown TO lt_dropdown.
      ls_dropdown-handle = '1'.
      ls_dropdown-value = '06 Blue'.
      APPEND ls_dropdown TO lt_dropdown.
      ls_dropdown-handle = '1'.
      ls_dropdown-value = '09 Other Colors'.
      APPEND ls_dropdown TO lt_dropdown.
    *method to display the dropdown in ALV
      CALL METHOD g_grid->set_drop_down_table
        EXPORTING
          it_drop_down = lt_dropdown.
    ENDFORM.                               " dropdown_table
    *&      Form  build_layout
          text
    *layout for ALV output
    FORM build_layout .
      gs_layout-cwidth_opt = 'X'.
      gs_layout-grid_title = 'ALV DROPDOWN LISTS'.
      gs_layout-no_toolbar = 'X'.
    ENDFORM.                    " build_layout
    Hope it is helpful,
    Regards,
    Soundarya.

  • Run-time error while executing alv grid report

    Hi everyone
    I m trying to run a alv grid report it is giving a run time error while executing the statement CALL METHOD V_ALV->SET_TOOLBAR_INTERACTIVE.
    Actually i added 2 buttons in the toolbar.after that when i execute the report i m getting errors.
    <b>Error Analysis</b>
    An exception occurred that is explained in detail below.                     
    The exception, which is assigned to class 'CX_SY_REF_IS_INITIAL', was not    
    caught in                                                                   
    procedure "TOOLBAR_MENUS_INIT" "(METHOD)", nor was it propagated by a RAISING
    clause.                                                                     
    Since the caller of the procedure could not have anticipated that the        
    exception would occur, the current program is terminated.                    
    The reason for the exception is:                                             
    You attempted to use a 'NULL' object reference (points to 'nothing')         
    access a component (variable: "ME->M_CL_MENU_BUTTON_VARIANT").               
    An object reference must point to an object (an instance of a class)         
    before it can be used to access components.                                  
    Either the reference was never set or it was set to 'NULL' using the         
    CLEAR statement.

    Hi Dinesh,
    Seems you have not initialised ( Instantiated in OO ) the object and / or the parent container.
    Check if you have create object for both the parent as well as the alv object.
    So when you instatntiate the object of ALV you pass the object ( instantiated before hand ) in the parent container position.
    Also you would have to register the events to the object using method. Then only the buttons will finction.
    eg :
    IF G_CUSTOM_CONTAINER IS INITIAL.
        CREATE OBJECT CUSTOM_CONTAINER_1
               EXPORTING CONTAINER_NAME = CONTAINER_1.
        CREATE OBJECT GRID1
               EXPORTING I_PARENT = CUSTOM_CONTAINER_1.
        CALL METHOD ALV_GRID1->SET_TABLE_FOR_FIRST_DISPLAY
             EXPORTING I_STRUCTURE_NAME = 'VBAK
             CHANGING  IT_OUTTAB        = IT_VBAK.
    Reward points if useful.

  • Check box.

    Hello Frnds,
             i need  check box in my hierarchial alv list display.
    i am produing my  code.pls specify the changes.
    *& Report  ZCASE9_ORDERSLISTREPORT
    REPORT  ZCASE9_ORDERSLISTREPORT.
    TYPE-POOLS: VRM,SLIS.
    TABLES:VBAK,
           VBAP,
           VBKD,
           VBEP,
           KNA1,
           VBPA,
           MAKT,
           VBUP,
           TVBST.
    TYPES:BEGIN OF ST_VBAK,
            VBELN TYPE VBAK-VBELN,
            ERDAT TYPE VBAK-ERDAT,
            ERZET TYPE VBAK-ERZET,
            ERNAM TYPE VBAK-ERNAM,
            AUDAT TYPE VBAK-AUDAT,
            LIFSK TYPE VBAK-LIFSK,
            VDATU TYPE VBAK-VDATU,
            VSBED TYPE VBAK-VSBED,
            BSTNK TYPE VBAK-BSTNK,
            BNAME TYPE VBAK-BNAME,
            AEDAT TYPE VBAK-AEDAT,
          END OF ST_VBAK,
          BEGIN OF ST_VBAP,
            VBELN1 TYPE VBAP-VBELN,
            MATNR TYPE VBAP-MATNR,
            CHARG TYPE VBAP-CHARG,
            PSTYV TYPE VBAP-PSTYV,
            ABGRU TYPE VBAP-ABGRU,
            MEINS TYPE VBAP-MEINS,
            VKAUS TYPE VBAP-VKAUS,
            KWMENG TYPE VBAP-KWMENG,
            LPRIO TYPE VBAP-LPRIO,
            WERKS TYPE VBAP-WERKS,
            LGORT TYPE VBAP-LGORT,
            VSTEL TYPE VBAP-VSTEL,
            ROUTE TYPE VBAP-ROUTE,
            MVGR5 TYPE VBAP-MVGR5,
          END OF ST_VBAP,
          BEGIN OF ST_VBPA,
            VBELN TYPE VBPA-VBELN,
            KUNNR TYPE VBPA-KUNNR,
          END OF ST_VBPA,
          BEGIN OF ST_KNA1,
            KUNNR TYPE KNA1-KUNNR,
            NAME1 TYPE KNA1-NAME1,
            TELF1 TYPE KNA1-TELF1,
          END OF ST_KNA1,
          BEGIN OF ST_MAKT,
            MATNR TYPE MAKT-MATNR,
            MAKTX TYPE MAKT-MAKTX,
          END OF ST_MAKT,
          BEGIN OF ST_VBEP,
            VBELN TYPE VBEP-VBELN,
            ETENR TYPE VBEP-ETENR,
            WADAT TYPE VBEP-WADAT,
          END OF ST_VBEP,
          BEGIN OF ST_VBUP,
            VBELN TYPE VBUP-VBELN,
            LFSTA TYPE VBUP-LFSTA,
            GBSTA TYPE VBUP-GBSTA,
          END OF ST_VBUP,
          begin of st_finalHDR,
            VBELN TYPE VBAK-VBELN,
            ERDAT TYPE VBAK-ERDAT,
            ERZET TYPE VBAK-ERZET,
            ERNAM TYPE VBAK-ERNAM,
            AUDAT TYPE VBAK-AUDAT,
            LIFSK TYPE VBAK-LIFSK,
            VDATU TYPE VBAK-VDATU,
            VSBED TYPE VBAK-VSBED,
            BSTNK TYPE VBAK-BSTNK,
            BNAME TYPE VBAK-BNAME,
            AEDAT TYPE VBAK-AEDAT,
            KUNNR TYPE VBPA-KUNNR,
            NAME1 TYPE KNA1-NAME1,
            TELF1 TYPE KNA1-TELF1,
          end of st_finalHDR,
          BEGIN OF ST_FINALTEM,
            VBELN1 TYPE VBAP-VBELN,
            LPRIO TYPE VBAP-LPRIO,
            WERKS TYPE VBAP-WERKS,
            LGORT TYPE VBAP-LGORT,
            VSTEL TYPE VBAP-VSTEL,
            ROUTE TYPE VBAP-ROUTE,
            MVGR5 TYPE VBAP-MVGR5,
            MATNR TYPE VBAP-MATNR,
            CHARG TYPE VBAP-CHARG,
            PSTYV TYPE VBAP-PSTYV,
            ABGRU TYPE VBAP-ABGRU,
            MEINS TYPE VBAP-MEINS,
            VKAUS TYPE VBAP-VKAUS,
            KWMENG TYPE VBAP-KWMENG,
            MAKTX TYPE MAKT-MAKTX,
            ETENR TYPE VBEP-ETENR,
            WADAT TYPE VBEP-WADAT,
            LFSTA TYPE VBUP-LFSTA,
            GBSTA TYPE VBUP-GBSTA,
          END OF ST_FINALTEM.
    DATA:IT_VBAK TYPE STANDARD TABLE OF ST_VBAK,
         IT_VBAP TYPE STANDARD TABLE OF ST_VBAP,
         IT_VBPA TYPE STANDARD TABLE OF ST_VBPA,
         IT_KNA1 TYPE STANDARD TABLE OF ST_KNA1,
         IT_MAKT TYPE STANDARD TABLE OF ST_MAKT,
         IT_VBEP TYPE STANDARD TABLE OF ST_VBEP,
         IT_VBUP TYPE STANDARD TABLE OF ST_VBUP,
         IT_FINALHDR TYPE STANDARD TABLE OF ST_FINALHDR,
         IT_FINALTEM TYPE STANDARD TABLE OF ST_FINALTEM,
         WA_VBAK TYPE ST_VBAK,
         WA_VBAP TYPE ST_VBAP,
         WA_VBPA TYPE ST_VBPA,
         WA_KNA1 TYPE ST_KNA1,
         WA_MAKT TYPE ST_MAKT,
         WA_VBEP TYPE ST_VBEP,
         WA_VBUP TYPE ST_VBUP,
         WA_FINALHDR TYPE ST_FINALHDR,
         WA_FINALTEM TYPE ST_FINALTEM.
    DATA: NAME TYPE VRM_ID,
          LIST TYPE VRM_VALUES,
          VALUE LIKE LINE OF LIST,
          REPID TYPE SY-REPID,
         TY_KEYINFO TYPE SLIS_KEYINFO_ALV, " key information type.
         IT_FIELDCAT TYPE SLIS_T_FIELDCAT_ALV,
         WA_FIELDCAT TYPE SLIS_FIELDCAT_ALV,    " field catalog type
         IT_HEADER TYPE SLIS_TABNAME,    " table to store header data
         IT_ITEM TYPE SLIS_TABNAME. " table to store item data
    SELECTION-SCREEN BEGIN OF BLOCK B1 WITH FRAME TITLE TEXT-001.
    PARAMETERS:OPEN_ORD RADIOBUTTON GROUP g1 DEFAULT 'X',                  " DOWNLOAD TO APPLICATION SERVER
               ALL_ORD RADIOBUTTON GROUP g1,
               MY_ORD AS CHECKBOX.
    SELECTION-SCREEN END OF BLOCK B1.
    SELECTION-SCREEN BEGIN OF BLOCK B2 WITH FRAME TITLE TEXT-002.
    PARAMETERS:PF(25) AS LISTBOX VISIBLE LENGTH 20,  P_KUNNR TYPE VBAK-KUNNR,
               P_MATNR TYPE VBAP-MATNR,
               P_BSTNK TYPE VBAK-BSTNK.
    SELECTION-SCREEN END OF BLOCK B2.
    SELECTION-SCREEN BEGIN OF BLOCK B3 WITH FRAME TITLE TEXT-003.
    SELECT-OPTIONS:S_AUDAT FOR VBAK-AUDAT,
                   S_VBELN FOR VBAK-VBELN,
                   S_AUART FOR VBAK-AUART,
                   S_LPRIO FOR VBAP-LPRIO,
                   S_PRSDT FOR VBKD-PRSDT,
                   S_WADAT FOR VBEP-WADAT,
                   S_VSBED FOR VBAK-VSBED,
                   S_EDATU FOR VBEP-EDATU,
                   S_LIFSK FOR VBAK-LIFSK,
                   S_ERNAM FOR VBAK-ERNAM.
    SELECTION-SCREEN END OF BLOCK B3.
    SELECTION-SCREEN BEGIN OF BLOCK B4 WITH FRAME TITLE TEXT-004.
    SELECT-OPTIONS:S_VKORG FOR VBAK-VKORG,
                   S_VTWEG FOR VBAK-VTWEG,
                   S_SPART FOR VBAP-SPART,
                   S_VKGRP FOR VBAK-VKGRP,
                   S_VKBUR FOR VBAK-VKBUR,
                   S_WERKS FOR VBAP-WERKS.
    SELECTION-SCREEN END OF BLOCK B4.
    INITIALIZATION.
    NAME = 'PF'.
    VALUE-KEY = '1'.
    VALUE-TEXT = 'SHIP TO'.
    APPEND VALUE TO LIST.
    NAME = 'PF'.
    VALUE-KEY = '2'.
    VALUE-TEXT = 'SOLD TO'.
    APPEND VALUE TO LIST.
    NAME = 'PF'.
    VALUE-KEY = '3'.
    VALUE-TEXT = 'BILL TO'.
    APPEND VALUE TO LIST.
    CALL FUNCTION 'VRM_SET_VALUES'
    EXPORTING
    ID = NAME
    VALUES = LIST.
    REPID = SY-REPID.            " variable having the program name
    IT_HEADER = 'IT_FINALHDR'.
    IT_ITEM = 'IT_FINALTEM'.
    CLEAR TY_KEYINFO.
    TY_KEYINFO-HEADER01 = 'VBELN'." comparing the keys and relating the header and item internal tables
    TY_KEYINFO-ITEM01 = 'VBELN1'.
    START-OF-SELECTION.
    IF OPEN_ORD ='X'.
          PERFORM RETRIEVE_VBAK.
          PERFORM RETRIEVE_VBAP.
          PERFORM RETRIEVE_VBPA.
          PERFORM RETRIEVE_KNA1.
          PERFORM RETRIEVE_MAKT.
          PERFORM RETRIEVE_VBEP.
          PERFORM RETRIEVE_VBUP1.
    ELSE.
         PERFORM RETRIEVE_VBAK.
         PERFORM RETRIEVE_VBAP.
         PERFORM RETRIEVE_VBPA.
         PERFORM RETRIEVE_KNA1.
         PERFORM RETRIEVE_MAKT.
         PERFORM RETRIEVE_VBEP.
         PERFORM RETRIEVE_VBUP.
    ENDIF.
    IF IT_VBAK IS NOT INITIAL.
       LOOP AT IT_VBAK INTO WA_VBAK.
            READ TABLE IT_VBAP INTO WA_VBAP WITH KEY VBELN1 = WA_VBAK-VBELN.
                 CHECK SY-SUBRC EQ 0.
            READ TABLE IT_VBPA INTO WA_VBPA WITH KEY VBELN = WA_VBAP-VBELN1.
                 CHECK SY-SUBRC EQ 0.
            READ TABLE IT_KNA1 INTO WA_KNA1 WITH KEY KUNNR = WA_VBPA-KUNNR.
                 CHECK SY-SUBRC EQ 0.
            READ TABLE IT_MAKT INTO WA_MAKT WITH KEY MATNR = WA_VBAP-MATNR.
                 CHECK SY-SUBRC EQ 0.
            READ TABLE IT_VBEP INTO WA_VBEP WITH KEY VBELN = WA_VBAP-VBELN1.
                 CHECK SY-SUBRC EQ 0.
            READ TABLE IT_VBUP INTO WA_VBUP WITH KEY VBELN = WA_VBAP-VBELN1.
                 CHECK SY-SUBRC EQ 0.
                 WA_FINALHDR-VBELN = WA_VBAK-VBELN.
                 WA_FINALHDR-ERNAM = WA_VBAK-ERNAM.
                 WA_FINALHDR-ERDAT = WA_VBAK-ERDAT.
                 WA_FINALHDR-ERZET = WA_VBAK-ERZET.
                 WA_FINALHDR-AEDAT = WA_VBAK-AEDAT.
                 WA_FINALHDR-AUDAT = WA_VBAK-AUDAT.
                 WA_FINALHDR-LIFSK = WA_VBAK-LIFSK.
                 WA_FINALHDR-VDATU = WA_VBAK-VDATU.
                 WA_FINALHDR-VSBED = WA_VBAK-VSBED.
                 WA_FINALHDR-BNAME = WA_VBAK-BNAME.
                 WA_FINALHDR-BSTNK = WA_VBAK-BSTNK.
                 WA_FINALHDR-TELF1 = WA_KNA1-TELF1.
                 WA_FINALHDR-NAME1 = WA_KNA1-NAME1.
                 WA_FINALHDR-KUNNR = WA_VBPA-KUNNR.
                 WA_FINALTEM-VBELN1 = WA_VBAP-VBELN1.
                 WA_FINALTEM-LPRIO = WA_VBAP-LPRIO.
                 WA_FINALTEM-MATNR = WA_VBAP-MATNR.
                 WA_FINALTEM-CHARG = WA_VBAP-CHARG.
                 WA_FINALTEM-MAKTX = WA_MAKT-MAKTX.
                 WA_FINALTEM-LGORT = WA_VBAP-LGORT.
                 WA_FINALTEM-MVGR5 = WA_VBAP-MVGR5.
                 WA_FINALTEM-ETENR = WA_VBEP-ETENR.
                 WA_FINALTEM-KWMENG = WA_VBAP-KWMENG.
                 WA_FINALTEM-GBSTA = WA_VBUP-GBSTA.
                 WA_FINALTEM-LFSTA = WA_VBUP-LFSTA.
                 WA_FINALTEM-VSTEL = WA_VBAP-VSTEL.
                 WA_FINALTEM-PSTYV = WA_VBAP-PSTYV.
                 WA_FINALTEM-ABGRU = WA_VBAP-ABGRU.
                 WA_FINALTEM-MEINS = WA_VBAP-MEINS.
                 WA_FINALTEM-VKAUS = WA_VBAP-VKAUS.
                 WA_FINALTEM-WERKS = WA_VBAP-WERKS.
                 WA_FINALTEM-ROUTE = WA_VBAP-ROUTE.
                 WA_FINALTEM-WADAT = WA_VBEP-WADAT.
                 APPEND WA_FINALHDR TO IT_FINALHDR.
                 APPEND WA_FINALTEM TO IT_FINALTEM.
       ENDLOOP.
    ENDIF.
      SORT iT_FINALHDR.
      DELETE ADJACENT DUPLICATES FROM iT_FINALHDR COMPARING ALL FIELDS.
      SORT iT_FINALTEM.
      DELETE ADJACENT DUPLICATES FROM iT_FINALTEM COMPARING ALL FIELDS.
    *wa_fieldcat-d = 'X'.
    WA_FIELDCAT-TABNAME = 'IT_FINALHDR'.
    WA_FIELDCAT-FIELDNAME = 'VBELN'.
    WA_FIELDCAT-SELTEXT_L = 'SALES DOC NO'.
    WA_FIELDCAT-COL_POS = 1.
    APPEND WA_FIELDCAT TO IT_FIELDCAT.
    CLEAR WA_FIELDCAT.
    WA_FIELDCAT-TABNAME = 'IT_FINALHDR'.
    WA_FIELDCAT-FIELDNAME = 'ERNAM'.
    WA_FIELDCAT-SELTEXT_L = 'CREATED BY'.
    WA_FIELDCAT-COL_POS = 2.
    APPEND WA_FIELDCAT TO IT_FIELDCAT.
    CLEAR WA_FIELDCAT.
    WA_FIELDCAT-TABNAME = 'IT_FINALHDR'.
    WA_FIELDCAT-FIELDNAME = 'ERDAT'.
    WA_FIELDCAT-SELTEXT_L = 'CREATED ON'.
    WA_FIELDCAT-COL_POS = 3.
    APPEND WA_FIELDCAT TO IT_FIELDCAT.
    CLEAR WA_FIELDCAT.
    WA_FIELDCAT-TABNAME = 'IT_FINALHDR'.
    WA_FIELDCAT-FIELDNAME = 'ERZET'.
    WA_FIELDCAT-SELTEXT_L = 'CREATED TIME'.
    WA_FIELDCAT-COL_POS = 4.
    APPEND WA_FIELDCAT TO IT_FIELDCAT.
    CLEAR WA_FIELDCAT.
    WA_FIELDCAT-TABNAME = 'IT_FINALHDR'.
    WA_FIELDCAT-FIELDNAME = 'AEDAT'.
    WA_FIELDCAT-SELTEXT_L = 'CHANGED ON'.
    WA_FIELDCAT-COL_POS = 5.
    APPEND WA_FIELDCAT TO IT_FIELDCAT.
    CLEAR WA_FIELDCAT.
    WA_FIELDCAT-TABNAME = 'IT_FINALHDR'.
    WA_FIELDCAT-FIELDNAME = 'AUDAT'.
    WA_FIELDCAT-SELTEXT_L = 'DOCUMENT DATE'.
    WA_FIELDCAT-COL_POS = 6.
    APPEND WA_FIELDCAT TO IT_FIELDCAT.
    CLEAR WA_FIELDCAT.
    WA_FIELDCAT-TABNAME = 'IT_FINALHDR'.
    WA_FIELDCAT-FIELDNAME = 'LIFSK'.
    WA_FIELDCAT-SELTEXT_L = 'DELIVERY BLOCK'.
    WA_FIELDCAT-COL_POS = 7.
    APPEND WA_FIELDCAT TO IT_FIELDCAT.
    CLEAR WA_FIELDCAT.
    WA_FIELDCAT-TABNAME = 'IT_FINALHDR'.
    WA_FIELDCAT-FIELDNAME = 'VDATU'.
    WA_FIELDCAT-SELTEXT_L = 'REQ DEL. DATE'.
    WA_FIELDCAT-COL_POS = 8.
    APPEND WA_FIELDCAT TO IT_FIELDCAT.
    CLEAR WA_FIELDCAT.
    WA_FIELDCAT-TABNAME = 'IT_FINALHDR'.
    WA_FIELDCAT-FIELDNAME = 'VSBED'.
    WA_FIELDCAT-SELTEXT_L = 'SHIPPING CONDITION'.
    WA_FIELDCAT-COL_POS = 9.
    APPEND WA_FIELDCAT TO IT_FIELDCAT.
    CLEAR WA_FIELDCAT.
    WA_FIELDCAT-TABNAME = 'IT_FINALHDR'.
    WA_FIELDCAT-FIELDNAME = 'BNAME'.
    WA_FIELDCAT-SELTEXT_L = 'NAME OF THE ORDERER'.
    WA_FIELDCAT-COL_POS = 10.
    APPEND WA_FIELDCAT TO IT_FIELDCAT.
    CLEAR WA_FIELDCAT.
    WA_FIELDCAT-TABNAME = 'IT_FINALHDR'.
    WA_FIELDCAT-FIELDNAME = 'TELF1'.
    WA_FIELDCAT-SELTEXT_L = 'SHIP 2 PARTY TELEPHONE'.
    WA_FIELDCAT-COL_POS = 11.
    APPEND WA_FIELDCAT TO IT_FIELDCAT.
    CLEAR WA_FIELDCAT.
    WA_FIELDCAT-TABNAME = 'IT_FINALHDR'.
    WA_FIELDCAT-FIELDNAME = 'BSTNK'.
    WA_FIELDCAT-SELTEXT_L = 'PURCHASE ORDER NO'.
    WA_FIELDCAT-COL_POS = 12.
    APPEND WA_FIELDCAT TO IT_FIELDCAT.
    CLEAR WA_FIELDCAT.
    WA_FIELDCAT-TABNAME = 'IT_FINALHDR'.
    WA_FIELDCAT-FIELDNAME = 'KUNNR'.
    WA_FIELDCAT-SELTEXT_L = 'SHIP 2 PARTY'.
    WA_FIELDCAT-COL_POS = 13.
    APPEND WA_FIELDCAT TO IT_FIELDCAT.
    CLEAR WA_FIELDCAT.
    WA_FIELDCAT-TABNAME = 'IT_FINALHDR'.
    WA_FIELDCAT-FIELDNAME = 'NAME1'.
    WA_FIELDCAT-SELTEXT_L = 'SHIP 2 PARTY NAME'.
    WA_FIELDCAT-COL_POS = 14.
    APPEND WA_FIELDCAT TO IT_FIELDCAT.
    CLEAR WA_FIELDCAT.
    WA_FIELDCAT-TABNAME = 'IT_FINALTEM'.
    WA_FIELDCAT-FIELDNAME = 'VBELN1'.
    WA_FIELDCAT-SELTEXT_L = 'SALES DOC'.
    APPEND WA_FIELDCAT TO IT_FIELDCAT.
    CLEAR WA_FIELDCAT.
    WA_FIELDCAT-TABNAME = 'IT_FINALTEM'.
    WA_FIELDCAT-FIELDNAME = 'LPRIO'.
    WA_FIELDCAT-SELTEXT_L = 'DEL. PRIORITY'.
    APPEND WA_FIELDCAT TO IT_FIELDCAT.
    CLEAR WA_FIELDCAT.
    WA_FIELDCAT-TABNAME = 'IT_FINALTEM'.
    WA_FIELDCAT-FIELDNAME = 'MATNR'.
    WA_FIELDCAT-SELTEXT_L = 'MATERIAL'.
    APPEND WA_FIELDCAT TO IT_FIELDCAT.
    CLEAR WA_FIELDCAT.
    WA_FIELDCAT-TABNAME = 'IT_FINALTEM'.
    WA_FIELDCAT-FIELDNAME = 'CHARG'.
    WA_FIELDCAT-SELTEXT_L = 'BATCH'.
    APPEND WA_FIELDCAT TO IT_FIELDCAT.
    CLEAR WA_FIELDCAT.
    WA_FIELDCAT-TABNAME = 'IT_FINALTEM'.
    WA_FIELDCAT-FIELDNAME = 'MAKTX'.
    WA_FIELDCAT-SELTEXT_L = 'MAT DESC'.
    APPEND WA_FIELDCAT TO IT_FIELDCAT.
    CLEAR WA_FIELDCAT.
    WA_FIELDCAT-TABNAME = 'IT_FINALTEM'.
    WA_FIELDCAT-FIELDNAME = 'LGORT'.
    WA_FIELDCAT-SELTEXT_L = 'STORAGE LOC'.
    APPEND WA_FIELDCAT TO IT_FIELDCAT.
    CLEAR WA_FIELDCAT.
    WA_FIELDCAT-TABNAME = 'IT_FINALTEM'.
    WA_FIELDCAT-FIELDNAME = 'MVGR5'.
    WA_FIELDCAT-SELTEXT_L = 'MAT GROUP'.
    APPEND WA_FIELDCAT TO IT_FIELDCAT.
    CLEAR WA_FIELDCAT.
    WA_FIELDCAT-TABNAME = 'IT_FINALTEM'.
    WA_FIELDCAT-FIELDNAME = 'ETENR'.
    WA_FIELDCAT-SELTEXT_L = 'SCHED LINE NO'.
    APPEND WA_FIELDCAT TO IT_FIELDCAT.
    CLEAR WA_FIELDCAT.
    WA_FIELDCAT-TABNAME = 'IT_FINALTEM'.
    WA_FIELDCAT-FIELDNAME = 'KWMENG'.
    WA_FIELDCAT-SELTEXT_L = 'ORD QUANTITY'.
    APPEND WA_FIELDCAT TO IT_FIELDCAT.
    CLEAR WA_FIELDCAT.
    WA_FIELDCAT-TABNAME = 'IT_FINALTEM'.
    WA_FIELDCAT-FIELDNAME = 'GBSTA'.
    WA_FIELDCAT-SELTEXT_L = 'OVERALL STATUS'.
    APPEND WA_FIELDCAT TO IT_FIELDCAT.
    CLEAR WA_FIELDCAT.
    WA_FIELDCAT-TABNAME = 'IT_FINALTEM'.
    WA_FIELDCAT-FIELDNAME = 'LFSTA'.
    WA_FIELDCAT-SELTEXT_L = 'DEL. STATUS'.
    APPEND WA_FIELDCAT TO IT_FIELDCAT.
    CLEAR WA_FIELDCAT.
    WA_FIELDCAT-TABNAME = 'IT_FINALTEM'.
    WA_FIELDCAT-FIELDNAME = 'VSTEL'.
    WA_FIELDCAT-SELTEXT_L = 'SHIPPING POINT'.
    APPEND WA_FIELDCAT TO IT_FIELDCAT.
    CLEAR WA_FIELDCAT.
    WA_FIELDCAT-TABNAME = 'IT_FINALTEM'.
    WA_FIELDCAT-FIELDNAME = 'PSTYV'.
    WA_FIELDCAT-SELTEXT_L = 'ITEM CATEGORY'.
    APPEND WA_FIELDCAT TO IT_FIELDCAT.
    CLEAR WA_FIELDCAT.
    WA_FIELDCAT-TABNAME = 'IT_FINALTEM'.
    WA_FIELDCAT-FIELDNAME = 'ABGRU'.
    WA_FIELDCAT-SELTEXT_L = 'REASON 4 REJECTION'.
    APPEND WA_FIELDCAT TO IT_FIELDCAT.
    CLEAR WA_FIELDCAT.
    WA_FIELDCAT-TABNAME = 'IT_FINALTEM'.
    WA_FIELDCAT-FIELDNAME = 'MEINS'.
    WA_FIELDCAT-SELTEXT_L = 'BASE UOM'.
    APPEND WA_FIELDCAT TO IT_FIELDCAT.
    CLEAR WA_FIELDCAT.
    WA_FIELDCAT-TABNAME = 'IT_FINALTEM'.
    WA_FIELDCAT-FIELDNAME = 'VKAUS'.
    WA_FIELDCAT-SELTEXT_L = 'USAGE'.
    APPEND WA_FIELDCAT TO IT_FIELDCAT.
    CLEAR WA_FIELDCAT.
    WA_FIELDCAT-TABNAME = 'IT_FINALTEM'.
    WA_FIELDCAT-FIELDNAME = 'WERKS'.
    WA_FIELDCAT-SELTEXT_L = 'PLANT'.
    APPEND WA_FIELDCAT TO IT_FIELDCAT.
    CLEAR WA_FIELDCAT.
    WA_FIELDCAT-TABNAME = 'IT_FINALTEM'.
    WA_FIELDCAT-FIELDNAME = 'ROUTE'.
    WA_FIELDCAT-SELTEXT_L = 'ROUTE'.
    APPEND WA_FIELDCAT TO IT_FIELDCAT.
    CLEAR WA_FIELDCAT.
    WA_FIELDCAT-TABNAME = 'IT_FINALTEM'.
    WA_FIELDCAT-FIELDNAME = 'WADAT'.
    WA_FIELDCAT-SELTEXT_L = 'GOODS ISSUE DATE'.
    APPEND WA_FIELDCAT TO IT_FIELDCAT.
    CLEAR WA_FIELDCAT.
    *CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
    EXPORTING
      I_INTERFACE_CHECK                 = ' '
      I_BYPASSING_BUFFER                = ' '
      I_BUFFER_ACTIVE                   = ' '
      I_CALLBACK_PROGRAM                = REPID
      I_CALLBACK_PF_STATUS_SET          = ' '
      I_CALLBACK_USER_COMMAND           = ' '
      I_CALLBACK_TOP_OF_PAGE            = ' '
      I_CALLBACK_HTML_TOP_OF_PAGE       = ' '
      I_CALLBACK_HTML_END_OF_LIST       = ' '
      I_STRUCTURE_NAME                  =
      I_BACKGROUND_ID                   = ' '
      I_GRID_TITLE                      =
      I_GRID_SETTINGS                   =
      IS_LAYOUT                         =
      IT_FIELDCAT                       = IT_FIELDCAT
      IT_EXCLUDING                      =
      IT_SPECIAL_GROUPS                 =
      IT_SORT                           =
      IT_FILTER                         =
      IS_SEL_HIDE                       =
      I_DEFAULT                         = 'X'
      I_SAVE                            = ' '
      IS_VARIANT                        =
      IT_EVENTS                         =
      IT_EVENT_EXIT                     =
      IS_PRINT                          =
      IS_REPREP_ID                      =
      I_SCREEN_START_COLUMN             = 0
      I_SCREEN_START_LINE               = 0
      I_SCREEN_END_COLUMN               = 0
      I_SCREEN_END_LINE                 = 0
      I_HTML_HEIGHT_TOP                 = 0
      I_HTML_HEIGHT_END                 = 0
      IT_ALV_GRAPHICS                   =
      IT_HYPERLINK                      =
      IT_ADD_FIELDCAT                   =
      IT_EXCEPT_QINFO                   =
      IR_SALV_FULLSCREEN_ADAPTER        =
    IMPORTING
      E_EXIT_CAUSED_BY_CALLER           =
      ES_EXIT_CAUSED_BY_USER            =
    TABLES
       t_outtab                          = IT_FINALHDR
    EXCEPTIONS
      PROGRAM_ERROR                     = 1
      OTHERS                            = 2
    *IF sy-subrc <> 0.
    MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
            WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
    *ENDIF.
    CALL FUNCTION 'REUSE_ALV_HIERSEQ_LIST_DISPLAY'
      EXPORTING
      I_INTERFACE_CHECK              = ' '
       I_CALLBACK_PROGRAM             = REPID
      I_CALLBACK_PF_STATUS_SET       = ' '
      I_CALLBACK_USER_COMMAND        = ' '
      IS_LAYOUT                      =
       IT_FIELDCAT                    = IT_FIELDCAT
      IT_EXCLUDING                   =
      IT_SPECIAL_GROUPS              =
      IT_SORT                        =
      IT_FILTER                      =
      IS_SEL_HIDE                    =
      I_SCREEN_START_COLUMN          = 0
      I_SCREEN_START_LINE            = 0
      I_SCREEN_END_COLUMN            = 0
      I_SCREEN_END_LINE              = 0
      I_DEFAULT                      = 'X'
      I_SAVE                         = ' '
      IS_VARIANT                     =
      IT_EVENTS                      =
      IT_EVENT_EXIT                  =
        i_tabname_header               = IT_HEADER
        i_tabname_item                 = IT_ITEM
      I_STRUCTURE_NAME_HEADER        =
      I_STRUCTURE_NAME_ITEM          =
        is_keyinfo                     = TY_KEYINFO
      IS_PRINT                       =
      IS_REPREP_ID                   =
      I_BYPASSING_BUFFER             =
      I_BUFFER_ACTIVE                =
      IR_SALV_HIERSEQ_ADAPTER        =
      IT_EXCEPT_QINFO                =
      I_SUPPRESS_EMPTY_DATA          = ABAP_FALSE
    IMPORTING
      E_EXIT_CAUSED_BY_CALLER        =
      ES_EXIT_CAUSED_BY_USER         =
      tables
        t_outtab_header                = IT_FINALHDR
        t_outtab_item                  = IT_FINALTEM.
    EXCEPTIONS
      PROGRAM_ERROR                  = 1
      OTHERS                         = 2
    IF sy-subrc <> 0.
    MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
            WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
    ENDIF.
    *&      Form  RETRIEVE_VBAK
          text
    -->  p1        text
    <--  p2        text
    form RETRIEVE_VBAK .
    SELECT VBELN
           ERDAT
           ERZET
           ERNAM
           AUDAT
           LIFSK
           VDATU
           VSBED
           BSTNK
           BNAME
           AEDAT INTO TABLE IT_VBAK FROM VBAK WHERE VBELN IN S_VBELN AND
                                                    ERNAM IN S_ERNAM AND
                                                    AUDAT IN S_AUDAT AND
                                                    AUART IN S_AUART AND
                                                    LIFSK IN S_LIFSK AND
                                                    VKORG IN S_VKORG AND
                                                    VTWEG IN S_VTWEG AND
                                                    VSBED IN S_VSBED AND
                                                    VKGRP IN S_VKGRP AND
                                                    VKBUR IN S_VKBUR.
    IF SY-SUBRC NE 0.
       MESSAGE E099(ZMMCASE) WITH 'NO VBAK HDR DATA FOUND'.
    ENDIF.
    endform.                    " RETRIEVE_VBAK
    *&      Form  RETRIEVE_VBAP
          text
    -->  p1        text
    <--  p2        text
    form RETRIEVE_VBAP .
    SELECT VBELN
           MATNR
           CHARG
           PSTYV
           ABGRU
           MEINS
           VKAUS
           KWMENG
           LPRIO
           WERKS
           LGORT
           VSTEL
           ROUTE
           MVGR5 INTO TABLE IT_VBAP FROM VBAP
                      FOR ALL ENTRIES IN IT_VBAK
                      WHERE VBELN = IT_VBAK-VBELN AND
                            SPART IN S_SPART AND
                            LPRIO IN S_LPRIO.
    IF SY-SUBRC NE 0.
       MESSAGE E098(ZMMCASE) WITH 'NO DATA FOUND IN TABLE VBAP'.
    ENDIF.
    endform.                    " RETRIEVE_VBAP
    *&      Form  RETRIEVE_VBPA
          text
    -->  p1        text
    <--  p2        text
    form RETRIEVE_VBPA .
    SELECT VBELN
           KUNNR INTO TABLE IT_VBPA FROM VBPA
                      FOR ALL ENTRIES IN IT_VBAP
                      WHERE VBELN = IT_VBAP-VBELN1.
    IF SY-SUBRC NE 0.
       MESSAGE E097(ZMMCASE) WITH 'NO DATA FOUND IN TABLE VBPA'.
    ENDIF.
    endform.                    " RETRIEVE_VBPA
    *&      Form  RETRIEVE_KNA1
          text
    -->  p1        text
    <--  p2        text
    form RETRIEVE_KNA1 .
    SELECT KUNNR
           NAME1
           TELF1 INTO TABLE IT_KNA1 FROM KNA1
                      FOR ALL ENTRIES IN IT_VBPA
                      WHERE KUNNR = IT_VBPA-KUNNR.
    IF SY-SUBRC NE 0.
       MESSAGE E096(ZMMCASE) WITH 'NO DATA FOUND IN TABLE KNA1'.
    ENDIF.
    endform.                    " RETRIEVE_KNA1
    *&      Form  RETRIEVE_MAKT
          text
    -->  p1        text
    <--  p2        text
    form RETRIEVE_MAKT .
    SELECT MATNR
           MAKTX INTO TABLE IT_MAKT FROM MAKT
                      FOR ALL ENTRIES IN IT_VBAP
                      WHERE MATNR = IT_VBAP-MATNR.
    IF SY-SUBRC NE 0.
       MESSAGE E095(ZMMCASE) WITH 'NO DATA FOUND IN TABLE MAKT'.
    ENDIF.
    endform.                    " RETRIEVE_MAKT
    *&      Form  RETRIEVE_VBEP
          text
    -->  p1        text
    <--  p2        text
    form RETRIEVE_VBEP .
    SELECT VBELN
           ETENR
           WADAT INTO TABLE IT_VBEP FROM VBEP
                 FOR ALL ENTRIES IN IT_VBAP
                 WHERE VBELN = IT_VBAP-VBELN1 AND
                       EDATU IN S_EDATU AND
                       WADAT IN S_WADAT.
    IF SY-SUBRC NE 0.
       MESSAGE E094(ZMMCASE) WITH 'NO DATA FOUND IN TABLE VBEP'.
    ENDIF.
    endform.                    " RETRIEVE_VBEP
    *&      Form  RETRIEVE_VBUP
          text
    -->  p1        text
    <--  p2        text
    form RETRIEVE_VBUP .
    SELECT VBELN
           LFSTA
           GBSTA INTO TABLE IT_VBUP FROM VBUP
                 FOR ALL ENTRIES IN IT_VBAP
                 WHERE VBELN = IT_VBAP-VBELN1.
    IF SY-SUBRC NE 0.
       MESSAGE E093(ZMMCASE) WITH 'NO DATA FOUND IN TABLE VBUP'.
    ENDIF.
    endform.                    " RETRIEVE_VBUP
    *&      Form  RETRIEVE_VBUP1
          text
    -->  p1        text
    <--  p2        text
    form RETRIEVE_VBUP1 .
    SELECT A~VBELN
           A~LFSTA
           AGBSTA FROM VBUP AS A INNER JOIN VBAP AS B ON AVBELN = B~VBELN INTO TABLE IT_VBUP
                 FOR ALL ENTRIES IN IT_VBAP
                 WHERE A~VBELN = IT_VBAP-VBELN1 AND
                 GBSTA IN ('A','B').
    IF SY-SUBRC NE 0.
       MESSAGE E093(ZMMCASE) WITH 'NO DATA FOUND IN TABLE VBUP'.
    ENDIF.
    endform.                    " RETRIEVE_VBUP1

    Hi yes you can perform some action on that by useing that check boxes
    by creating some pushbuttons in SE41 PF-STATUS
    In order modify PF_STATUS of ALV grid report you need to perform the following steps:
    1. Update 'REUSE_ALV_GRID_DISPLAY' FM call to include:
    i_callback_pf_status_set = 'SET_PF_STATUS' statement.
    2. Create 'SET_PF_STATUS' FORM
    3. Create pf_status (i.e. 'ZNEWSTATUS').
    - It is recommend that you copy standard status'STANDARD' from function group SALV and modify it accordingly. ALV standard function codes always start with '&'.
    call function 'REUSE_ALV_GRID_DISPLAY'
    exporting
    i_callback_program = gd_repid
    i_callback_top_of_page = 'TOP-OF-PAGE'
    i_callback_pf_status_set = 'SET_PF_STATUS' "see FORM
    is_layout = gd_layout
    it_fieldcat = fieldcatalog[]
    i_save = 'X'
    tables
    t_outtab = it_ekko
    exceptions
    program_error = 1
    others = 2.
    FORM SET_PF_STATUS *
    FORM set_pf_status USING rt_extab TYPE slis_t_extab.
    SET PF-STATUS 'ZNEWSTATUS'.
    "Copy of 'STANDARD' pf_status from fgroup SALV
    ENDFORM.
    exmple2
    This example shows how to use checkboxes within an ALV Grid Control. You learn:
    (1) how to define a column for editable checkboxes for an attribute of your list
    (2) how to evaluate the checked checkboxes
    (3) how to switch between editable and non-editable checkboxes
    program bcalv_edit_05.
    Purpose:
    ~~~~~~~~
    This example shows how to use checkboxes within an ALV Grid Control.
    You learn:
    o how to define a column for editable checkboxes for an attribute
       of your list (see also remark below)
    o how to evaluate the checked checkboxes
    o how to switch between editable and non-editable checkboxes
    Important Remark
    ~~~~~~~~~~~~~~~~
    The checkbox functionality has been replaced by selection buttons
    in front of each row (field SEL_MODE of the layout structure
    set to 'A' or 'D'; when using the editable ALV Grid Control,
    these selection buttons are always visible).
    Class methods like GET_SELECTED_ROWS work only for this new
    functionality and not for checkboxes.
    Thus checkboxes should not be used for line selection but for
    a column as an additional or for an already existing attribute
    (like field SMOKER in SBOOK).
    To check program behavior
    ~~~~~~~~~~~~~~~~~~~~~~~~~
    Try out the functions displayed in the application toolbar:
    o The first sets all checked lines to initial values.
      (see form reset_selected_entries)
    o The seconds marks all checkboxes that are input enabled
    o The third unmarks all checkboxes that are input enabled
    o To try the forth, you have to select a line first using
      the selection buttons on the left.
      The function deactivates/activates a checkbox.
    Checkboxes may be locked/unlocked using a double click on the
    checkbox cell.
    Essential steps (search for '§')
    ~~~~~~~~~~~~~~~
    This example focusses on two aspects of checkboxes in an
    editable ALV Grid Control:
    A How to integrate, set, reset and evaluate checkboxes
    B What you must do to lock particular checkboxes against input
    A) Integrate, set, reset and evaluate checkboxes
    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    A1.Extend your output table by a checkbox field.
    A2.Add an entry for the checkbox in the fieldcatalog
    A3.Optionally, check checkboxes initially after selecting data.
    A4.Before you (a)set, (b)reset, (c)(de)activate or
       (d)evaluate checkboxes, you must check the input cells.
    B) Lock particular checkboxes against input
    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    B1.Extend your output table by a field to dis- or enable
        cells for input.
    B2.After selecting data,
        assign a style for each row of your checkbox column.
    B3.Use the layout structure to aquaint additional field to ALV.
    B4.Switch the style to dis- or enable a cell for input
    class lcl_event_receiver definition deferred.  "for event handling
    data: ok_code like sy-ucomm,
          save_ok like sy-ucomm,
          g_container type scrfname value 'BCALV_GRID_DEMO_0100_CONT1',
          g_grid  type ref to cl_gui_alv_grid,
          g_custom_container type ref to cl_gui_custom_container,
          g_event_receiver type ref to lcl_event_receiver,
          gt_fieldcat type lvc_t_fcat,
          gs_layout type lvc_s_layo,
          g_max type i value 100.
    *§A1.Extend your output table by a checkbox field.
        If you do not want to lock sole checkboxes against input
        you do not need field 'celltab'.
    types: begin of gs_outtab.
    types: checkbox type c.                "field for checkbox
    §B1.Extend your output table by a field to dis- or enable
        cells for input.
    types: celltab type lvc_t_styl.        "field to switch editability
            include structure sflight.
    types: end of gs_outtab.
    data: gt_outtab type gs_outtab occurs 0 with header line.
    LOCAL CLASSES
    This local class only handles event DOUBLE_CLICK.
    Wenn the user double clicks on a checkbox cell the status of
    this cell is switched from editable to not editable and vice versa.
    class lcl_event_receiver definition.
    public section.
    methods: catch_doubleclick
             for event double_click of cl_gui_alv_grid
             importing
                e_column
                es_row_no
                sender.
    endclass.
    class lcl_event_receiver implementation.
    method catch_doubleclick.
      data: ls_outtab type gs_outtab,
            ls_celltab type lvc_s_styl.
    Function:
    Switch between 'editable' and 'not editable' checkbox.
    If the user clicked on another column there is
    nothing to do.
      if e_column-fieldname ne 'CHECKBOX'.
        exit.
      endif.
      read table gt_outtab into ls_outtab index es_row_no-row_id.
    The loop is only needed if there are other columns that
    use checkboxes. At this point the loop could be
    replaced by a READ of the first line of CELLTAB.
          loop at ls_outtab-celltab into ls_celltab.
            if ls_celltab-fieldname eq 'CHECKBOX'.
    §B4.Switch the style to dis- or enable a cell for input
             if ls_celltab-style = cl_gui_alv_grid=>mc_style_enabled.
              ls_celltab-style = cl_gui_alv_grid=>mc_style_disabled.
             else.
              ls_celltab-style = cl_gui_alv_grid=>mc_style_enabled.
             endif.
             modify ls_outtab-celltab from ls_celltab.
            endif.
          endloop.
          modify gt_outtab from ls_outtab index es_row_no-row_id.
        call method sender->refresh_table_display.
    endmethod.
    endclass.
          MAIN                                                          *
    end-of-selection.
      call screen 100.
          MODULE PBO OUTPUT                                             *
    module pbo output.
      set pf-status 'MAIN100'.
      set titlebar 'MAIN100'.
      if g_custom_container is initial.
        perform create_and_init_alv.
      endif.
    endmodule.
          MODULE PAI INPUT                                              *
    module pai input.
      save_ok = ok_code.
      clear ok_code.
      case save_ok.
        when 'EXIT'.
          perform exit_program.
        when 'SELECT'.
          perform select_all_entries changing gt_outtab[].
        when 'DESELECT'.
          perform deselect_all_entries changing gt_outtab[].
        when 'RESET'.
          perform reset_selected_entries changing gt_outtab[].
        when 'SWITCH'.
          perform switch_activation changing gt_outtab[].
      endcase.
    endmodule.
          FORM EXIT_PROGRAM                                             *
    form exit_program.
      leave program.
    endform.
    *&      Form  BUILD_FIELDCAT
          text
         <--P_GT_FIELDCAT  text
    form build_fieldcat changing pt_fieldcat type lvc_t_fcat.
      data ls_fcat type lvc_s_fcat.
      call function 'LVC_FIELDCATALOG_MERGE'
           exporting
                i_structure_name = 'SFLIGHT'
           changing
                ct_fieldcat      = pt_fieldcat.
    *§A2.Add an entry for the checkbox in the fieldcatalog
      clear ls_fcat.
      ls_fcat-fieldname = 'CHECKBOX'.
    Essential: declare field as checkbox and
               mark it as editable field:
      ls_fcat-checkbox = 'X'.
      ls_fcat-edit = 'X'.
    do not forget to provide texts for this extra field
      ls_fcat-coltext = text-f01.
      ls_fcat-tooltip = text-f02.
      ls_fcat-seltext = text-f03.
    optional: set column width
      ls_fcat-outputlen = 10.
      append ls_fcat to pt_fieldcat.
    endform.
    *&      Form  CREATE_AND_INIT_ALV
          text
         <--P_GT_OUTTAB  text
         <--P_GT_FIELDCAT  text
         <--P_GS_LAYOUT  text
    form create_and_init_alv.
      data: lt_exclude type ui_functions.
      create object g_custom_container
             exporting container_name = g_container.
      create object g_grid
             exporting i_parent = g_custom_container.
      perform build_fieldcat changing gt_fieldcat.
    Exclude all edit functions in this example since we do not need them:
      perform exclude_tb_functions changing lt_exclude.
      perform build_data.
    *§ B3.Use the layout structure to aquaint additional field to ALV.
      gs_layout-stylefname = 'CELLTAB'.
      call method g_grid->set_table_for_first_display
           exporting is_layout             = gs_layout
                     it_toolbar_excluding  = lt_exclude
           changing  it_fieldcatalog       = gt_fieldcat
                     it_outtab             = gt_outtab[].
      create object g_event_receiver.
      set handler g_event_receiver->catch_doubleclick for g_grid.
    Set editable cells to ready for input initially
      call method g_grid->set_ready_for_input
       exporting
        i_ready_for_input = 1.
    endform.                               "CREATE_AND_INIT_ALV
    *&      Form  EXCLUDE_TB_FUNCTIONS
          text
         <--P_LT_EXCLUDE  text
    form exclude_tb_functions changing pt_exclude type ui_functions.
      data ls_exclude type ui_func.
      ls_exclude = cl_gui_alv_grid=>mc_fc_loc_copy_row.
      append ls_exclude to pt_exclude.
      ls_exclude = cl_gui_alv_grid=>mc_fc_loc_delete_row.
      append ls_exclude to pt_exclude.
      ls_exclude = cl_gui_alv_grid=>mc_fc_loc_append_row.
      append ls_exclude to pt_exclude.
      ls_exclude = cl_gui_alv_grid=>mc_fc_loc_insert_row.
      append ls_exclude to pt_exclude.
      ls_exclude = cl_gui_alv_grid=>mc_fc_loc_move_row.
      append ls_exclude to pt_exclude.
      ls_exclude = cl_gui_alv_grid=>mc_fc_loc_copy.
      append ls_exclude to pt_exclude.
      ls_exclude = cl_gui_alv_grid=>mc_fc_loc_cut.
      append ls_exclude to pt_exclude.
      ls_exclude = cl_gui_alv_grid=>mc_fc_loc_paste.
      append ls_exclude to pt_exclude.
      ls_exclude = cl_gui_alv_grid=>mc_fc_loc_paste_new_row.
      append ls_exclude to pt_exclude.
      ls_exclude = cl_gui_alv_grid=>mc_fc_loc_undo.
      append ls_exclude to pt_exclude.
    endform.                               " EXCLUDE_TB_FUNCTIONS
    *&      Form  build_data
          text
    -->  p1        text
    <--  p2        text
    form build_data.
      data: lt_sflight type table of sflight,
            ls_sflight type sflight,
            ls_celltab type lvc_s_styl,
            lt_celltab type lvc_t_styl,
            l_index type i.
      select * from sflight into table lt_sflight up to g_max rows.
      if sy-subrc ne 0.
    generate own entries if db-table is empty so that this example
    still works
        perform generate_entries changing lt_sflight.
      endif.
    *§A3.Optionally, check checkboxes initially after selecting data.
    (Omitted in this example)
      loop at lt_sflight into ls_sflight.
        move-corresponding ls_sflight to gt_outtab.
      if gt_outtab-connid eq '400'.
        gt_outtab-checkbox = 'X'.
      endif.
        append gt_outtab.
      endloop.
    §B2.After selecting data,
       assign a style for each row of your checkbox column.
    Initially, set all checkbox cells editable.
      ls_celltab-fieldname = 'CHECKBOX'.
      ls_celltab-style = cl_gui_alv_grid=>mc_style_enabled.
      loop at gt_outtab.
        l_index = sy-tabix.
        refresh lt_celltab.
        ls_celltab-fieldname = 'CHECKBOX'.
        ls_celltab-style = cl_gui_alv_grid=>mc_style_enabled.
        insert ls_celltab into table lt_celltab.
        insert lines of lt_celltab into table gt_outtab-celltab.
        modify gt_outtab index l_index.
      endloop.
    endform.                               " build_data
    *&      Form  generate_entries
          text
         <--P_LT_SLFIGHT  text
    form generate_entries changing pt_slfight type standard table.
    This form is only needed for the case that there is no
    data in database table SFLIGHT.
      data: ls_sflight type sflight,
            l_month(2) type c,
            l_day(2) type c,
            l_date(8) type c.
      ls_sflight-carrid = 'LH'.
      ls_sflight-connid = '0400'.
      ls_sflight-currency = 'DEM'.
      ls_sflight-planetype = '747-400'.
      ls_sflight-seatsmax = 660.
      do 110 times.
        ls_sflight-price = sy-index * 100.
        ls_sflight-seatsocc = 660 - sy-index * 6.
        ls_sflight-paymentsum = ls_sflight-seatsocc * ls_sflight-price.
        l_month = sy-index / 10 + 1.
        do 2 times.
          l_day = l_month + sy-index * 2.
          l_date+0(4) = '2000'.
          l_date4(2) = l_month0(2).
          l_date6(2) = l_day0(2).
          ls_sflight-fldate = l_date.
          append ls_sflight to pt_slfight.
        enddo.
      enddo.
    endform.                               " generate_entries
    *&      Form  select_all_entries
          text
         <--P_GT_OUTTAB  text
    form select_all_entries changing pt_outtab type standard table.
      data: ls_outtab type gs_outtab.
      data: l_valid type c,
            l_locked type c.
    *§A4ad. Before you (a)set, reset or (d)evaluate checkboxes,
          you must check the input cells.
    If all entries are ok, ALV transferes new values to the output
    table which you then can modify.
      call method g_grid->check_changed_data
                  importing
                     e_valid = l_valid.
      if l_valid eq 'X'.
        loop at pt_outtab into ls_outtab.
          perform check_lock using    ls_outtab
                             changing l_locked.
          if l_locked is initial
             and not ls_outtab-checkbox eq '-'.
            ls_outtab-checkbox = 'X'.
          endif.
          modify pt_outtab from ls_outtab.
        endloop.
        call method g_grid->refresh_table_display.
      endif.
    endform.                               " select_all_entries
    *&      Form  deselect_all_entries
          text
         <--P_GT_OUTTAB[]  text
    form deselect_all_entries changing pt_outtab type standard table.
      data: ls_outtab type gs_outtab.
      data: l_valid type c,
            l_locked type c.
    *§A4ad. Before you (a)set, reset or (d)evaluate checkboxes,
          you must check the input cells.
    If all entries are ok, ALV transferes new values to the output
    table which you then can modify.
      call method g_grid->check_changed_data
                  importing
                     e_valid = l_valid.
      if l_valid eq 'X'.
        loop at pt_outtab into ls_outtab.
          perform check_lock using    ls_outtab
                           changing l_locked.
          if l_locked is initial
             and not ls_outtab-checkbox eq '-'.
            ls_outtab-checkbox = ' '.
          endif.
          modify pt_outtab from ls_outtab.
        endloop.
        call method g_grid->refresh_table_display.
      endif.
    endform.                               " deselect_all_entries
    *&      Form  reset_selected_entries
          text
         <--P_GT_OUTTAB[]  text
    form reset_selected_entries changing pt_outtab type standard table.
      data: ls_outtab type gs_outtab.
      data: l_valid type c.
    *§A4b. Before you set, (b)reset or evaluate checkboxes,
         you must check the input cells.
    If all entries are ok, ALV transferes new values to the output
    table which you then can modify.
      call method g_grid->check_changed_data
                  importing
                     e_valid = l_valid.
      if l_valid eq 'X'.
        loop at pt_outtab into ls_outtab.
          if     not ls_outtab-checkbox is initial
             and not ls_outtab-checkbox eq '-'.
            clear ls_outtab.
            modify pt_outtab from ls_outtab.
          endif.
        endloop.
        call method g_grid->refresh_table_display.
      endif.
    endform.                               " reset_selected_entries
    form switch_activation changing pt_outtab type standard table.
      data: ls_outtab type gs_outtab.
      data: l_valid type c,
            lt_row_no type lvc_t_roid with header line.
    *§A4c. Before you set, reset, (c)(de)activate
         or evaluate checkboxes, you must check the input cells.
    If all entries are ok, ALV transferes new values to the output
    table which you then can modify.
      call method g_grid->check_changed_data
                  importing
                     e_valid = l_valid.
      if l_valid eq 'X'.
        call method g_grid->get_selected_rows
          importing
             et_row_no     = lt_row_no[].
        loop at lt_row_no.
           read table pt_outtab into ls_outtab index lt_row_no-row_id.
           if ls_outtab-checkbox ne '-'.
             ls_outtab-checkbox = '-'.
           else.
             ls_outtab-checkbox = ' '.
           endif.
           modify pt_outtab from ls_outtab index lt_row_no-row_id.
        endloop.
        call method g_grid->refresh_table_display.
      endif.
    endform.                               " switch_activation
    *&      Form  check_lock
          text
         -->P_LS_OUTTAB  text
         <--P_L_LOCKED  text
    form check_lock using    ps_outtab type gs_outtab
                    changing p_locked.
      data ls_celltab type lvc_s_styl.
      loop at ps_outtab-celltab into ls_celltab.
        if ls_celltab-fieldname = 'CHECKBOX'.
          if ls_celltab-style eq cl_gui_alv_grid=>mc_style_disabled.
            p_locked = 'X'.
          else.
            p_locked = space.
          endif.
        endif.
      endloop.
    endform.                               " check_lock

  • Problem with Custom container - cl_gui_custom_container/cl_gui_alv_grid

    Hi,
    I want to reuse the same custom container screen for a different data.
    First screen there will be button 1 and button 2
    if I click button 1 then calculate and display data  in custom container, if button 2 is clicked then calculate and display data with  in the same custom container.
    For this
    1. Created Custom container - CONTAINER
    2. In program defined and created custom container and custom alv grid
    g_custom_container TYPE REF TO cl_gui_custom_container,
            alv_grid                     TYPE REF TO cl_gui_alv_grid.
           IF g_custom_container IS INITIAL.
                CREATE OBJECT g_custom_container
                    EXPORTING
                  container_name = 'CONTAINER'.
                CREATE OBJECT alv_grid
                   EXPORTING
                    i_parent = g_custom_container.
          ENDIF.
    3. Display data using CALL METHOD alv_grid->set_table_for_first_display
       every thing works great for button 1
    4. when button 2 is clicked then calculate and display different set of data in same custom container which is used earlier.
    5. here I used
    call method alv_grid->free.
        call method g_custom_container->free.
    6. create above objects once again and tried to use
    call method alv_grid->set_table_for_first_display
    , to reuse the same custom container 'CONTAINER' again for a different set of data and getting ABAP dump.
    In debug mode, when I used the above method FREE for both ALV_GRID and G_CUSTOM_CONTAINER objects are not clearing.
    Please let me know how can I reuse the same container for a different set of data when button2 is pressed.
    Thanks in advance,
    Krishna
    Please use code tags to format your code and post in the correct forum
    Edited by: Rob Burbank on Oct 1, 2010 2:37 PM

    Hello Krishna
    I would recommend to use a different approach instead of trying to initialize your container instances:
    DATA:
      go_container_1 TYPE REF TO cl_gui_custom_container,
      go_container_2 TYPE REF TO cl_gui_custom_container,
      go_grid_1          TYPE REF TO cl_gui_alv_grid,
      go_grid_2          TYPE REF TO cl_gui_alv_grid.
    " NOTE: Do this coding BEFORE calling the screen
    * (1) Create 2 containers
    CREATE OBJECT g_container_1
                    EXPORTING
                  container_name = 'CONTAINER'.
    CREATE OBJECT g_container_2
                    EXPORTING
                  container_name = 'CONTAINER'.
    " NOTE: If it is not possible to use the same container name then either create an additional
    "            dummy screen having a second CUSTOM_CONTROL element or replace
    " the customer containers with docking containers -> here you do not need to give a container name
    * (2) Create 2 grid instances using a different container
    * (3) Link the first container to the screen using its LINK method:
      CALL METHOD go_container_1
        EXPORTING
           repid = <...>
          dynnr = <...>.
    * (4) Perhaps you need to define a second dummy screen to which you link the second container
    * (5) Display first grid instance (as default)
    Now when the user pushes button 2 (to display the second grid) link container_1 to the dummy screen
    and link container_2 to your main screen.
    Regards
      Uwe

Maybe you are looking for