Create Edit Delete in Oops ALV

Hi Experts,
I need to create an ALV which will provide all the functionality of Create, Edit, Save and Delete records and update the Custom table accordingly.
I want to design it as follows -
1. Display should be in non-ediatble mode initially (because I don't want to make it completely ediatble at all times)
2. When the user clicks Create button a new line appends at the bottom and the ALV has to be made editable, for the values to be entered at the new row appended.
3. When the user presses Save, again the ALV goes into non-ediatble mode.
4. When the user presses Edit Button, the ALV is open for editing and again the whole ALV is editable. After Editing, the user will select those particular lines through Box Button and Press on Save Button to enable those particular lines to be modified and saved in ALV. Again at the press of Save button, the ALV will switch to Non-modifiable view.
5. For Deletion, select the particular line/lines through Box Button and Click on Delete.
This is how I plan to achieve the Create, Edit, Delete Functionality.
Can you please confirm the feasibilty of this Design, whether it is achievable.
There is some option of dynamically changing the Field Catalogue. If it is there, I'm thinking of utilising it for switching the modes on click of Create, Edit and Save Buttons. Click/Edit --> Modifiable. Save --> Non-modifiable.
Please do give your comments on the above functionality and feasibility. If you are knowing a different or easy approach please do share it. If you have done it then please do share it.
Thanks & Regards
Tanu

Plz ask your specific requirement otherwise mosarator will block the thread...

Similar Messages

  • Create-Edit-Delete page using ADF Faces & Toplink

    Hi,
    i want to build simple apps like this one : http://andrejusb.blogspot.com/2007/06/create-edit-and-delete-operations-in.html
    It's using ADF BC. How could it be done using ADF Toplink ?
    Thanks,
    Best Regards,
    Ricky

    Ricky,
    If you're using JDeveloper 10.1.3, take a look at the ADF learning center. Under the heading "Experienced Java Developers", on the right, you'll see a sample, tutorial and developer guide covering the ADF Faces/TopLink technology stack.
    Blaise

  • Edit field in OOPS ALV on button click

    Hello All,
    I have created an ALV using set_table_for_first_display, where one of the field is set to editable mode I have two buttons, one for save data and other to change data. Initially when the layout is displayed for first time, all the fields should be in non-editable mode and if user click on change button that particular field gets in editable mode.
    How  can I achieve this?
    Regards,
    Sachin

    Check the below code to enable or disable user input for the Edit cells...
          IF GO_GRID->IS_READY_FOR_INPUT( ) EQ 0.
    * Set edit enabled cells ready for input
            CALL METHOD GO_GRID->SET_READY_FOR_INPUT
              EXPORTING
                I_READY_FOR_INPUT = 1.
          ELSE.
    * Lock edit enabled cells against input
            CALL METHOD GO_GRID->SET_READY_FOR_INPUT
              EXPORTING
                I_READY_FOR_INPUT = 0.
          ENDIF.

  • Create screen when creating OOP ALV

    hi everybody
    I have created an OOP ALV but I dont know how to attach it to a screen, i know its tcode se51, but i dnt know how to link it to the ALV
    can anybody help me?

    Hello,
    I think first you have to check some standard sap program :
    BCALV_EDIT_01                  Switch on and off the ready-for-input status of the entire grid
    BCALV_EDIT_02                  Define ready-for-input status at cell level                   
    BCALV_EDIT_03                  Verification of modified cells                                
    BCALV_EDIT_04                  Delete and append rows                                        
    BCALV_EDIT_05                  Checkboxes                                                    
    BCALV_EDIT_06                  Dropdown Listbox at Column Level                              
    BCALV_EDIT_07                  Dropdown Listbox at Cell Level                                
    BCALV_EDIT_08                  Integrate Non-Standard F4 Help                                
    there simple process like you have to add a container on a screen
        and in report program
    create an instance
    data  g_container TYPE scrfname VALUE 'ZGW_CONTAINER',
          grid1  TYPE REF TO cl_gui_alv_grid.
    where zgw_container is conatiner name which is asing to screen
    then call the method set_table_for_first_display of class cl_gui_alv_grid .
    pass the require parameter to that method.
        CALL METHOD GRID1->SET_TABLE_FOR_FIRST_DISPLAY
          EXPORTING
    *    I_BUFFER_ACTIVE               =
    *    I_BYPASSING_BUFFER            =
    *    I_CONSISTENCY_CHECK           =
    *    I_STRUCTURE_NAME              =    'ZGW3RE007'
        IS_VARIANT                    =    GS_VARIANT
            I_SAVE                        =    'A'
    *    I_DEFAULT                     = 'X'
            IS_LAYOUT                     =     GS_LAYOUT
    *    IS_PRINT                      =
    *    IT_SPECIAL_GROUPS             =
           IT_TOOLBAR_EXCLUDING          =  lt_exclude
    *    IT_HYPERLINK                  =
    *    IT_ALV_GRAPHICS               =
    *    IT_EXCEPT_QINFO               =
    *    IR_SALV_ADAPTER               =
          CHANGING
            IT_OUTTAB                     =    GT_OUTTAB[]
            IT_FIELDCATALOG               =    WA1_FIELDCATALOG
    *    IT_SORT                       =
    *    IT_FILTER                     =
    *  EXCEPTIONS
    *    INVALID_PARAMETER_COMBINATION = 1
    *    PROGRAM_ERROR                 = 2
    *    TOO_MANY_LINES                = 3
    *    others                        = 4
        IF SY-SUBRC <> 0.
    * MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
    *            WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
        ENDIF.
    or read this pdf document.
    http://www.sap-partner.hu/ABAP_HELP_INFO/An%20Easy%20Reference%20for%20ALV%20Grid%20Control.pdf
    Thanks
    Anirudh Saini

  • How to view/edit/delete the user created profile in oracle 9i? Very Urgent

    Friends,
    I logged in as system in oracle 9i.
    SQL> create profile testpro limit
    2 idle_time 1;
    Profile created.
    SQL> alter user scott profile testpro;
    User altered.
    Then i logged in to sqlplusw as a scott user.
    and i waited for 10 mins after that.
    sql> select * from cat;
    its working......
    how come? i have already set a idle time to 1 minute.
    Please correct me if im wrong.
    Also, how can i view/edit/delete the user created profile.
    Thanks & Regards
    Sathyguy
    Message was edited by:
    sathyguy

    The resource limits set for a profile are enforced only when you enable resource limitation for the database.
    Enabling and Disabling Resource Limits While the Database is Open
    ALTER SYSTEM SET RESOURCE_LIMIT = TRUE;
    http://download-west.oracle.com/docs/cd/B10501_01/server.920/a96521/users.htm#15451
    Manu

  • Can VMD_EI_API handle Create, Edit, and Delete Vendor Master records?

    Hi Everyone,
    I have a development that requires to create, edit, and delete vendor master records through a webportal ui. Technically, it will be a background process in SAP because it must not have a dialog screen. In my search so far, there is no standard BAPI or Function module that can handle this one.
    Can the class VMD_EI_API handle the requirements?
    Regards,
    John

    Hi,
    Yes, You can use this class to create/modify/delete vendor master data. You can find in SCN documents with example how use it.
    Jarek

  • Problem with OOPS ALv-field editable

    hi experts,
             I am displaying one report using OOPS ALV. Now i am inserting a line in the output, so some mandatory fields are automatically filled up in the new line, and i am trying to fill  new values for the remaining empty fields, So initially they are non-editable in the fieldcatalog.if i click on the 'INSERT LINE' button then only the fields shud be input enabled, how to do this.
                           Thanks in advance,

    maybe sample report BCALV_EDIT_04 might help you there.

  • OOP ALV - Setting specific records as editable

    Hello everyone,
    Is there a way for an ALV grid/OOP ALV to set certain fields as editable?
    I have tried setting specific columns as editable through field catalog setup, but I don't need all records of that column to be editable. I just need specific records to be editable. Is this possible with ALV or I have no other choice but to use Table Control?
    Please help.
    Sincerely,
    Ice

    Hi Ice,
    this code will work 4 u.
    *& Report  ZDEMO_ALVGRID_EDIT                                          *
    *& Example of a simple ALV Grid Report                                 *
    *& The basic ALV grid, Enhanced to display specific fields as          *
    *& editable depending on field value                                   *
    REPORT  ZDEMO_ALVGRID_EDIT                 .
    TABLES:     ekko.
    TYPE-POOLS: slis.                                 "ALV Declarations
    *Data Declaration
    TYPES: BEGIN OF t_ekko,
      ebeln TYPE ekpo-ebeln,
      ebelp TYPE ekpo-ebelp,
      statu TYPE ekpo-statu,
      aedat TYPE ekpo-aedat,
      matnr TYPE ekpo-matnr,
      menge TYPE ekpo-menge,
      meins TYPE ekpo-meins,
      netpr TYPE ekpo-netpr,
      peinh TYPE ekpo-peinh,
      field_style  TYPE lvc_t_styl, "FOR DISABLE
    END OF t_ekko.
    DATA: it_ekko TYPE STANDARD TABLE OF t_ekko INITIAL SIZE 0,
          wa_ekko TYPE t_ekko.
    *ALV data declarations
    DATA: fieldcatalog TYPE slis_t_fieldcat_alv WITH HEADER LINE.
    DATA: it_fieldcat TYPE lvc_t_fcat,     "slis_t_fieldcat_alv WITH HEADER LINE,
          wa_fieldcat TYPE lvc_s_fcat,
          gd_tab_group TYPE slis_t_sp_group_alv,
          gd_layout    TYPE lvc_s_layo,     "slis_layout_alv,
          gd_repid     LIKE sy-repid.
    *Start-of-selection.
    START-OF-SELECTION.
      PERFORM data_retrieval.
      PERFORM set_specific_field_attributes.
      PERFORM build_fieldcatalog.
      PERFORM build_layout.
      PERFORM display_alv_report.
    *&      Form  BUILD_FIELDCATALOG
          Build Fieldcatalog for ALV Report
    FORM build_fieldcatalog.
      wa_fieldcat-fieldname   = 'EBELN'.
      wa_fieldcat-scrtext_m   = 'Purchase Order'.
      wa_fieldcat-col_pos     = 0.
      wa_fieldcat-outputlen   = 10.
      wa_fieldcat-emphasize   = 'X'.
      wa_fieldcat-key         = 'X'.
      APPEND wa_fieldcat TO it_fieldcat.
      CLEAR  wa_fieldcat.
      wa_fieldcat-fieldname   = 'EBELP'.
      wa_fieldcat-scrtext_m   = 'PO Item'.
      wa_fieldcat-col_pos     = 1.
      APPEND wa_fieldcat TO it_fieldcat.
      CLEAR  wa_fieldcat.
      wa_fieldcat-fieldname   = 'STATU'.
      wa_fieldcat-scrtext_m   = 'Status'.
      wa_fieldcat-col_pos     = 2.
      APPEND wa_fieldcat TO it_fieldcat.
      CLEAR  wa_fieldcat.
      wa_fieldcat-fieldname   = 'AEDAT'.
      wa_fieldcat-scrtext_m   = 'Item change date'.
      wa_fieldcat-col_pos     = 3.
      APPEND wa_fieldcat TO it_fieldcat.
      CLEAR  wa_fieldcat.
      wa_fieldcat-fieldname   = 'MATNR'.
      wa_fieldcat-scrtext_m   = 'Material Number'.
      wa_fieldcat-col_pos     = 4.
      APPEND wa_fieldcat TO it_fieldcat.
      CLEAR  wa_fieldcat.
      wa_fieldcat-fieldname   = 'MENGE'.
      wa_fieldcat-scrtext_m   = 'PO quantity'.
      wa_fieldcat-col_pos     = 5.
      APPEND wa_fieldcat TO it_fieldcat.
      CLEAR  wa_fieldcat.
      wa_fieldcat-fieldname   = 'MEINS'.
      wa_fieldcat-scrtext_m   = 'Order Unit'.
      wa_fieldcat-col_pos     = 6.
      APPEND wa_fieldcat TO it_fieldcat.
      CLEAR  wa_fieldcat.
      wa_fieldcat-fieldname   = 'NETPR'.
      wa_fieldcat-scrtext_m   = 'Net Price'.
      wa_fieldcat-edit        = 'X'. "sets whole column to be editable
      wa_fieldcat-col_pos     = 7.
      wa_fieldcat-outputlen   = 15.
      wa_fieldcat-datatype     = 'CURR'.
      APPEND wa_fieldcat TO it_fieldcat.
      CLEAR  wa_fieldcat.
      wa_fieldcat-fieldname   = 'PEINH'.
      wa_fieldcat-scrtext_m   = 'Price Unit'.
      wa_fieldcat-col_pos     = 8.
      APPEND wa_fieldcat TO it_fieldcat.
      CLEAR  wa_fieldcat.
    ENDFORM.                    " BUILD_FIELDCATALOG
    *&      Form  BUILD_LAYOUT
          Build layout for ALV grid report
    FORM build_layout.
    Set layout field for field attributes(i.e. input/output)
      gd_layout-stylefname = 'FIELD_STYLE'.
      gd_layout-zebra             = 'X'.
    ENDFORM.                    " BUILD_LAYOUT
    *&      Form  DISPLAY_ALV_REPORT
          Display report using ALV grid
    FORM display_alv_report.
      gd_repid = sy-repid.
    call function 'REUSE_ALV_GRID_DISPLAY'
      CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY_LVC'
           EXPORTING
                i_callback_program      = gd_repid
               i_callback_user_command = 'USER_COMMAND'
                is_layout_lvc               = gd_layout
                it_fieldcat_lvc             = it_fieldcat
                i_save                  = 'X'
           TABLES
                t_outtab                = it_ekko
           EXCEPTIONS
                program_error           = 1
                OTHERS                  = 2.
      IF sy-subrc <> 0.
    MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
            WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
      ENDIF.
    ENDFORM.                    " DISPLAY_ALV_REPORT
    *&      Form  DATA_RETRIEVAL
          Retrieve data form EKPO table and populate itab it_ekko
    FORM data_retrieval.
      SELECT ebeln ebelp statu aedat matnr menge meins netpr peinh
       UP TO 10 ROWS
        FROM ekpo
        INTO  CORRESPONDING FIELDS OF TABLE it_ekko.
    ENDFORM.                    " DATA_RETRIEVAL
    *&      Form  set_specific_field_attributes
          populate FIELD_STYLE table with specific field attributes
    form set_specific_field_attributes .
      DATA ls_stylerow TYPE lvc_s_styl .
      DATA lt_styletab TYPE lvc_t_styl .
    Populate style variable (FIELD_STYLE) with style properties
    The NETPR field/column has been set to editable in the fieldcatalog...
    The following code sets it to be disabled(display only) if 'NETPR'
    is gt than 10.
      LOOP AT it_ekko INTO wa_ekko.
        IF wa_ekko-netpr GT 10.
          ls_stylerow-fieldname = 'NETPR' .
          ls_stylerow-style = cl_gui_alv_grid=>mc_style_disabled.
                                                 "set field to disabled
          APPEND ls_stylerow  TO wa_ekko-field_style.
          MODIFY it_ekko FROM wa_ekko.
        ENDIF.
      ENDLOOP.
    endform.                    " set_specific_field_attributes
    kindly reward if found helpful.
    cheers,
    Hema.

  • Auto create View/Edit/Delete cfm pages for databsae records? Anyone remember CF Studio?

    Anyone use Recordmaster wizard from back in the CF Studio
    days?? Sometimes I really miss it! Is there anything comparable
    available today for the current toolset (CFeclipse or Dreamweaver)?
    RecordMaster was a little automated wizard thing that you could
    just point to a DSN and a table, and it would build a nifty set of
    basic pages to do admin stuff, namely view, add, edit and delete
    records. Very good start to build quick and dirty admin pages, and
    super easy.
    There was even a little built in Studio wizard that would
    generate record view/edit/delete pages. All just basic cfm, no
    cfc's.
    Anyhing? I've got to build some admin type pages here on a
    table with lots of fields and don't want to do it all from scratch.
    If I can't find anything, I may search my CD archives for an old
    version of Studio just to use RecordMaster! What do others use for
    fast creation of database record admin pages???
    -Jeff

    Not exactly what you are looking for, but take a look at
    reactor (
    http://www.alagad.com/go/products-and-projects/reactor-for-coldfusion).
    It will create a database abstration layer on-the-fly for simple
    CRUD operations. A similar solution would be Illudium PU-36 (
    http://cfcgenerator.riaforge.org/).
    Similar concept to reactor, but used for one-time
    generation.

  • How to create editable ALV grid/list

    Hi,
    I want to create editable ALV grid/list so that user can modify the data in the ALV.
    And when user presses save button data will get saved in Z table.
    I dont know how to create editable ALV so could anybody please help me regarding this?
    Thanks & regards,
    Sameer Dhuke

    HI
    check the demo programs BCALV_FULLSCREEN_GRID_EDIT
    BCALV_GRID_EDIT
    BCALV_TEST_GRID_EDIT_01
    BCALV_TEST_GRID_EDITABLE
    REUSE_ALV_GRID EDITABLE
    ALV Grid editable fields
    Just to make things a bit easy
    In the layout,there is a property called edit, make it 'X' for the particular field whichever you want to make editable.
    Hope this helps,
    Suruchi
    Message was edited by:
            Suruchi Mahajan

  • How do I define Field-Catalog and Event-Catalog in OOPs ALV

    Hi All,
    This is the piece of the code on which I'm working upon. This program is giving an exception "No Field-Catalog Found". 
    I'm new to OOPs ALV. Could anybody please tell me how to define the field-catalog and event-catalog in this.
    module PBO output.
          IF g_custom_container IS INITIAL.
              CREATE OBJECT g_custom_container EXPORTING CONTAINER_NAME = 'CCCONTAINER'.
              CREATE OBJECT g_grid             EXPORTING I_PARENT       = g_custom_container.
          CALL METHOD g_grid->set_table_for_first_display
              EXPORTING I_STRUCTURE_NAME = 'IT_MATERIAL'
                        is_layout = layout
              CHANGING IT_OUTTAB         = gt_it_material.
          ENDIF.
      endmodule.
    Regards,
    Saurabh

    hi,
    chk this sampl ceode.
    TYPE-POOLS: slis.
    CLASS lcl_event_receiver DEFINITION DEFERRED.
    TABLES : zmpets_shipactiv, zmpets_chargebk, zmpets_shiphdr.
    DATA : BEGIN OF int_crb OCCURS 0,
           sel TYPE char1,
           icon TYPE icon_d,
           pernr LIKE zmpets_cil-pernr,
           vorna LIKE pa0002-vorna,
           movreason LIKE zmpets_shiphdr-movreason,
           shipdocnum LIKE zmpets_chargebk-shipdocnum,
           createdon LIKE zmpets_chargebk-createdon,
           chargeamount LIKE zmpets_chargebk-chargeamount,
           version LIKE zmpets_shipactiv-version,
           activity LIKE zmpets_shipactiv-activity,
           vendor LIKE zmpets_shiphdr-vendor,
          smtp_addr LIKE adr6-smtp_addr,
           empperid LIKE zmpets_167doc-empperid,
           celltab TYPE lvc_t_styl,
           END OF int_crb.
    DATA : int_crb_ver LIKE int_crb OCCURS 0 WITH HEADER LINE.
    DATA : int_crb_mail LIKE int_crb OCCURS 0 WITH HEADER LINE.
    DATA : int_shipactiv LIKE zmpets_shipactiv OCCURS 0 WITH HEADER LINE.
    DATA: gt_fieldcatalog TYPE lvc_t_fcat.
    DATA : wf_flag TYPE i.
    DATA : wf_res TYPE c.
    DATA : wf_tabix TYPE sy-tabix.
    DATA: BEGIN OF int_sin OCCURS 0,
          shipdocnum LIKE zmpets_chargebk-shipdocnum,
            shipdocnum LIKE zmpets_shipactiv-petsdocnumber,
          END OF int_sin.
    DATA: objpack   LIKE sopcklsti1 OCCURS 2 WITH HEADER LINE.
    DATA: objhead   LIKE solisti1 OCCURS 1 WITH HEADER LINE.
    DATA: objbin    LIKE solisti1 OCCURS 10 WITH HEADER LINE.
    DATA: objtxt    LIKE solisti1 OCCURS 10 WITH HEADER LINE.
    DATA: reclist   LIKE somlreci1 OCCURS 5 WITH HEADER LINE.
    DATA: doc_chng  LIKE sodocchgi1.
    DATA: tab_lines LIKE sy-tabix.
    DATA l_num(3).
    DATA: ok_code            LIKE          sy-ucomm,
          w_repid            LIKE          sy-repid,
          wl_sno             TYPE          i         VALUE 0,
          w_max              TYPE          i         VALUE 100,
          wf_layout          TYPE          lvc_s_layo,
          cont_on_main       TYPE          scrfname   VALUE  'GRID_CONTROL',
          cont_on_dialog     TYPE          scrfname   VALUE 'GRID_CONTROL',
          grid1              TYPE          REF TO cl_gui_alv_grid,
          grid2              TYPE          REF TO cl_gui_alv_grid,
          custom_container1  TYPE          REF TO cl_gui_custom_container,
          custom_container2  TYPE          REF TO cl_gui_custom_container,
          event_receiver     TYPE          REF TO lcl_event_receiver,
          lt_exclude         TYPE          ui_functions,
          ls_celltab         TYPE          lvc_s_styl,
          lt_celltab         TYPE          lvc_t_styl.
    SELECTION-SCREEN BEGIN OF BLOCK b3 WITH FRAME TITLE text-001.
    PARAMETERS : p_cash AS CHECKBOX.
    SELECTION-SCREEN END OF BLOCK b3.
    PERFORM fieldcatalog_init USING gt_fieldcatalog[].
    Selection-Screen----
    SELECTION-SCREEN  BEGIN OF BLOCK b1 WITH FRAME TITLE text-002.
    SELECT-OPTIONS:s_chdate FOR zmpets_chargebk-createdon,
                   s_pernr FOR zmpets_shiphdr-pernr,
                   s_mvrsn FOR zmpets_shiphdr-movreason,
                   s_sin FOR zmpets_chargebk-shipdocnum NO INTERVALS
    NO-EXTENSION.
    SELECTION-SCREEN  END OF BLOCK b1.
    PERFORM f_clear_fields.
    CALL SCREEN 100.
          CLASS lcl_event_receiver DEFINITION
    CLASS lcl_event_receiver DEFINITION.
      PUBLIC SECTION.
        METHODS:
        handle_toolbar
            FOR EVENT toolbar OF cl_gui_alv_grid
                IMPORTING e_object e_interactive,
        handle_user_command
            FOR EVENT user_command OF cl_gui_alv_grid
                IMPORTING e_ucomm.
      PRIVATE SECTION.
    ENDCLASS.                    "lcl_event_receiver DEFINITION
          CLASS lcl_event_receiver IMPLEMENTATION
    CLASS lcl_event_receiver IMPLEMENTATION.
      METHOD handle_toolbar.
    § 2.In event handler method for event TOOLBAR: Append own functions
      by using event parameter E_OBJECT.
        DATA: ls_toolbar  TYPE stb_button.
    append a separator to normal toolbar
        CLEAR ls_toolbar.
        MOVE 3 TO ls_toolbar-butn_type.
        APPEND ls_toolbar TO e_object->mt_toolbar.
        CLEAR ls_toolbar.
    new button -
        MOVE 'PROCESSED' TO ls_toolbar-function.
        MOVE icon_execute_object TO ls_toolbar-icon.
        MOVE 'Process the Record'(110) TO ls_toolbar-quickinfo.
        MOVE ' Process '(200) TO ls_toolbar-text.
        MOVE ' ' TO ls_toolbar-disabled.
        APPEND ls_toolbar TO e_object->mt_toolbar.
      ENDMETHOD.                    "handle_toolbar
      METHOD handle_user_command.
    § 3.In event handler method for event USER_COMMAND: Query your
      function codes defined in step 2 and react accordingly.
        DATA: lt_rows TYPE lvc_t_row.
        CASE e_ucomm.
          WHEN 'PROCESSED'.
            CALL FUNCTION 'POPUP_TO_CONFIRM_STEP'
                     EXPORTING
                      defaultoption        = 'N'
      textline1     = 'Do you want to process the selected documents?'
              TEXTLINE2            = ' '
                       titel                = 'Process Documents'
              START_COLUMN         = 25
              START_ROW            = 6
              CANCEL_DISPLAY       = 'X'
                    IMPORTING
                      answer               = wf_res.
    *--IF THE USER CONFIRMS 'YES',
            IF wf_res = 'J'.
              PERFORM f_modify_activity.
              CALL METHOD grid1->refresh_table_display.
           PERFORM SENDINGMAIL.
            ENDIF.
        ENDCASE.
      ENDMETHOD.                           "handle_user_command
    ENDCLASS.                    "lcl_event_receiver IMPLEMENTATION
    MODULE pbo_100 OUTPUT
    MODULE pbo_100 OUTPUT.
      SET PF-STATUS 'MAIN100'.
      SET TITLEBAR 'MAIN100'.
      w_repid = sy-repid.
      IF custom_container1 IS INITIAL.
    *get the data from charge back table
        PERFORM select_table_chb.
    create a custom container control for our ALV Control
        CREATE OBJECT custom_container1
            EXPORTING
                container_name = cont_on_main
            EXCEPTIONS
                cntl_error = 1
                cntl_system_error = 2
                create_error = 3
                lifetime_error = 4
                lifetime_dynpro_dynpro_link = 5.
        IF sy-subrc NE 0.
    add your handling, for example
          CALL FUNCTION 'POPUP_TO_INFORM'
            EXPORTING
              titel = w_repid
              txt2  = sy-subrc
              txt1  = 'The control could not be created'(510).
        ENDIF.
        CREATE OBJECT grid1
                  EXPORTING i_parent = custom_container1.
    Set a titlebar for the grid control
        wf_layout-grid_title = 'Charge Back'(100).
    allow to select multiple lines
        wf_layout-sel_mode = 'C'.
        wf_layout-stylefname = 'CELLTAB'.
    Exclude all edit functions in this example since we do not need them:
        PERFORM exclude_tb_functions CHANGING lt_exclude.
        CALL METHOD grid1->set_table_for_first_display
                   EXPORTING
                I_BUFFER_ACTIVE               =
                I_CONSISTENCY_CHECK           =
                I_STRUCTURE_NAME              =
                IS_VARIANT                    =
                I_SAVE                        =
                I_DEFAULT                     = 'X'
                     is_layout                     = wf_layout
                IS_PRINT                      =
                IT_SPECIAL_GROUPS             =
                  it_toolbar_excluding          = lt_exclude
                IT_HYPERLINK                  =
                IT_ALV_GRAPHICS               =
              CHANGING
                it_outtab                     = int_crb[]
                it_fieldcatalog               = gt_fieldcatalog.
        CREATE OBJECT event_receiver.
        SET HANDLER event_receiver->handle_user_command FOR grid1.
        SET HANDLER event_receiver->handle_toolbar FOR grid1.
        CALL METHOD grid1->set_toolbar_interactive.
      ENDIF.                               "IF grid1 IS INITIAL
      CALL METHOD cl_gui_control=>set_focus
        EXPORTING
          control = grid1.
    ENDMODULE.                    "pbo_100 OUTPUT
    MODULE pai_100 INPUT
    MODULE pai_100 INPUT.
      CASE ok_code.
        WHEN 'EXIT'.
          PERFORM f_clear_fields.
          LEAVE PROGRAM.
        WHEN 'CANCEL'.
          PERFORM f_clear_fields.
          LEAVE TO SCREEN 0.
        WHEN 'BACK'.
          PERFORM f_clear_fields.
          LEAVE TO SCREEN 0.
      ENDCASE.
      CLEAR ok_code.
    ENDMODULE.                    "pai_100 INPUT
    **&      Form  select_table_chb
          text
    FORM select_table_chb.
      IF p_cash = 'X'.
    *Consider the pending documents also.
    *get the documents which are not processed yet,
    *Doctype -> 06 = Charge Back document type.
        SELECT zmpets_shiphdrpernr pa0002vorna
         zmpets_shiphdrmovreason zmpets_chargebkshipdocnum
         zmpets_chargebkcreatedon zmpets_chargebkchargeamount
         zmpets_shipactivversion zmpets_shipactivactivity
    zmpets_shiphdr~vendor
       adr6~smtp_addr
    zmpets_167doc~empperid
                 INTO CORRESPONDING FIELDS OF TABLE int_crb_ver
                 FROM zmpets_chargebk
                 JOIN zmpets_shiphdr
               ON zmpets_chargebkshipdocnum = zmpets_shiphdrshipdocno
                 JOIN zmpets_shipactiv
         ON zmpets_chargebkshipdocnum = zmpets_shipactivpetsdocnumber
                 JOIN pa0002
                 ON zmpets_shiphdrpernr = pa0002pernr
                    JOIN lfa1
                    ON lfa1lifnr = zmpets_shiphdrvendor
                    JOIN adr6
                    ON adr6addrnumber = lfa1adrnr
                 JOIN zmpets_167doc
                 ON zmpets_167docpernr = pa0002pernr
                           WHERE zmpets_shipactiv~doctype = '06'
                        zmpets_shipactiv~activity NE '30'
                      ZMPETS_CHARGEBK~CREATEDON IN s_chdate
                      AND ZMPETS_SHIPHDR~pernr IN s_pernr
                      AND ZMPETS_SHIPHDR~MOVREASON IN s_mvrsn
                      AND ZMPETS_CHARGEBK~SHIPDOCNUM IN s_sin
                           AND zmpets_chargebk~loekz NE 'X'
                           AND zmpets_shipactiv~loekz NE 'X'
                           AND zmpets_shiphdr~loekz NE 'X'.
        IF sy-subrc <> 0.
    *Message is 'No Pending Documents Available.'.
          MESSAGE s196(zm050).
        ELSE.
          LOOP AT int_crb_ver.
    *Not yet processed. set to red
            int_crb_ver-icon = '@0A@'.
            MODIFY int_crb_ver.
          ENDLOOP.
          PERFORM f_filter_data_pending.
        ENDIF.
      ELSE.
    *Get the document details from pa0002,zmpets_shipactiv,ZMPETS_CHARGEBK
    *table.
    *Consider document type as '01'  during the selection.
    *Doctype -> 06 = Charge Back document type.
        SELECT zmpets_shiphdrpernr pa0002vorna zmpets_shiphdr~movreason
        zmpets_chargebkshipdocnum zmpets_chargebkcreatedon
    zmpets_chargebkchargeamount zmpets_shipactivversion
    zmpets_shipactivactivity zmpets_shiphdrvendor
    *adr6~smtp_addr
    zmpets_167doc~empperid
                 INTO CORRESPONDING FIELDS OF TABLE int_crb_ver
                 FROM zmpets_chargebk
                 JOIN zmpets_shiphdr
                 ON zmpets_chargebkshipdocnum = zmpets_shiphdrshipdocno
                 JOIN zmpets_shipactiv
           ON zmpets_chargebkshipdocnum = zmpets_shipactivpetsdocnumber
                 JOIN pa0002
                 ON zmpets_shiphdrpernr = pa0002pernr
                JOIN lfa1
                    ON lfa1lifnr = zmpets_shiphdrvendor
                    JOIN adr6
                    ON adr6addrnumber = lfa1adrnr
                     JOIN zmpets_167doc
                     ON zmpets_167docpernr = pa0002pernr
                           WHERE zmpets_chargebk~createdon IN s_chdate
                           AND zmpets_shiphdr~pernr IN s_pernr
                           AND zmpets_shiphdr~movreason IN s_mvrsn
                           AND zmpets_chargebk~shipdocnum IN s_sin
                          AND zmpets_shipactiv~activity NE '30'
                           AND zmpets_shipactiv~doctype = '06'
                           AND zmpets_chargebk~loekz NE 'X'
                           AND zmpets_shipactiv~loekz NE 'X'
                           AND zmpets_shiphdr~loekz NE 'X'.
        IF sy-subrc <> 0.
    *Message is 'No Charge Back Documents Available.'.
          MESSAGE s201(zm050).
        ELSE.
          PERFORM f_filter_data.
        ENDIF.
      ENDIF.
    ENDFORM.                    "select_table_chb
    *&      Form  UPDATE_RECORDS
          text
    -->  p1        text
    <--  p2        text
    FORM update_records TABLES p_et_index_rows
                                    STRUCTURE lvc_s_row.
      DATA: ls_selected_line LIKE lvc_s_row,
              lf_row_index TYPE lvc_index.
      LOOP AT p_et_index_rows INTO ls_selected_line.
        lf_row_index = ls_selected_line-index.
      ENDLOOP.
    ENDFORM.                    " UPDATE_RECORDS
    **&      Form  fieldcatalog_init
          text
         -->P_GT_FIELDCATALOG[]  text
    FORM fieldcatalog_init  USING lt_fieldcatalog TYPE lvc_t_fcat.
      DATA: ls_fieldcatalog TYPE lvc_s_fcat.
      CLEAR ls_fieldcatalog.
      ls_fieldcatalog-fieldname = 'SEL'.
      ls_fieldcatalog-tabname  = 'INT_CRB'.
      ls_fieldcatalog-datatype = 'C'.
      ls_fieldcatalog-col_pos  = 1.
      ls_fieldcatalog-edit     = 'X'.
      ls_fieldcatalog-reptext  = 'Select for Processing'.
      ls_fieldcatalog-coltext  = 'Select for Processing'.
      ls_fieldcatalog-seltext  = 'Select for Processing'.
      ls_fieldcatalog-tooltip  = 'Select for Processing'.
      ls_fieldcatalog-checkbox = 'X'.
      ls_fieldcatalog-key = 'X'.
      APPEND ls_fieldcatalog TO lt_fieldcatalog.
      CLEAR ls_fieldcatalog.
      ls_fieldcatalog-fieldname = 'ICON'.
      ls_fieldcatalog-tabname   = 'INT_CRB'.
      ls_fieldcatalog-datatype  = 'CHAR'.
      ls_fieldcatalog-col_pos    = 2.
      ls_fieldcatalog-intlen     = '4'.
      ls_fieldcatalog-reptext   =  'Status'.
      ls_fieldcatalog-coltext   =  'Status'.
      ls_fieldcatalog-seltext   =  'Status'.
      ls_fieldcatalog-tooltip   =  'Status'.
      APPEND ls_fieldcatalog TO lt_fieldcatalog.
      CLEAR ls_fieldcatalog.
      ls_fieldcatalog-fieldname = 'PERNR'.
      ls_fieldcatalog-tabname   = 'INT_CRB'.
      ls_fieldcatalog-datatype  = 'NUMC'.
      ls_fieldcatalog-col_pos   = 2.
      ls_fieldcatalog-intlen    = '8'.
      ls_fieldcatalog-reptext   =  'Employee Number'.
      ls_fieldcatalog-coltext   =  'Employee Number'.
      ls_fieldcatalog-seltext   =  'Employee Number'.
      ls_fieldcatalog-tooltip   =  'Employee Number'.
      ls_fieldcatalog-key = 'X'.
      APPEND ls_fieldcatalog TO lt_fieldcatalog.
      CLEAR ls_fieldcatalog.
      ls_fieldcatalog-fieldname  = 'VORNA'.
      ls_fieldcatalog-tabname    = 'INT_CRB'.
      ls_fieldcatalog-col_pos    =  3 .
      ls_fieldcatalog-datatype   = 'CHAR'.
      ls_fieldcatalog-outputlen      = '20'.
      ls_fieldcatalog-reptext    = 'Employee Name'.
      ls_fieldcatalog-coltext    = 'Employee Name'.
      ls_fieldcatalog-seltext    = 'Employee Name'.
      ls_fieldcatalog-tooltip    = 'Employee Name'.
    ls_fieldcatalog-key      = 'X'.
      APPEND ls_fieldcatalog TO lt_fieldcatalog.
      CLEAR ls_fieldcatalog.
      ls_fieldcatalog-fieldname  = 'MOVREASON'.
      ls_fieldcatalog-tabname    = 'INT_CRB'.
      ls_fieldcatalog-col_pos    =  4.
      ls_fieldcatalog-datatype   = 'NUMC'.
      ls_fieldcatalog-outputlen  = '10'.
      ls_fieldcatalog-reptext    = 'Move Reason'.
      ls_fieldcatalog-coltext    = 'Move Reason'.
      ls_fieldcatalog-seltext    = 'Move Reason'.
      ls_fieldcatalog-tooltip    = 'Move Reason'.
    ls_fieldcatalog-key      = 'X'.
      APPEND ls_fieldcatalog TO lt_fieldcatalog.
      CLEAR ls_fieldcatalog.
      ls_fieldcatalog-fieldname = 'SHIPDOCNUM'.
      ls_fieldcatalog-tabname   = 'INT_CRB'.
      ls_fieldcatalog-datatype  = 'NUMC'.
      ls_fieldcatalog-outputlen = '10'.
      ls_fieldcatalog-col_pos   =  5.
      ls_fieldcatalog-reptext   = 'Shipping Document Number'.
      ls_fieldcatalog-coltext   = 'Shipping Document Number'.
      ls_fieldcatalog-seltext   = 'Shipping Document Number'.
      ls_fieldcatalog-tooltip   = 'Shipping Document Number'.
    ls_fieldcatalog-key = 'X'.
      APPEND ls_fieldcatalog TO lt_fieldcatalog.
      CLEAR ls_fieldcatalog.
      ls_fieldcatalog-fieldname = 'CREATEDON'.
      ls_fieldcatalog-tabname   = 'INT_CRB'.
      ls_fieldcatalog-col_pos   = 6.
      ls_fieldcatalog-datatype  = 'DATS'.
      ls_fieldcatalog-outputlen = '8'.
      ls_fieldcatalog-reptext   = 'Created On'.
      ls_fieldcatalog-coltext   = 'Created On'.
      ls_fieldcatalog-seltext   = 'Created On'.
      ls_fieldcatalog-tooltip   = 'Created On'.
    ls_fieldcatalog-DO_sum      = 'X'.
      APPEND ls_fieldcatalog TO lt_fieldcatalog.
      CLEAR ls_fieldcatalog.
      ls_fieldcatalog-fieldname = 'CHARGEAMOUNT'.
      ls_fieldcatalog-tabname   = 'INT_CRB'.
      ls_fieldcatalog-col_pos   = 7.
      ls_fieldcatalog-datatype  = 'CURR'.
      ls_fieldcatalog-outputlen = '13'.
      ls_fieldcatalog-reptext   = 'Charge Back Amount'.
      ls_fieldcatalog-coltext   = 'Charge Back Amount'.
      ls_fieldcatalog-seltext   = 'Charge Back Amount'.
      ls_fieldcatalog-tooltip   = 'Charge Back Amount'.
    ls_fieldcatalog-DO_sum      = 'X'.
      APPEND ls_fieldcatalog TO lt_fieldcatalog.
      CLEAR ls_fieldcatalog.
    ENDFORM.                    "fieldcatalog_init
    *&      Form  f_modify_activity
    Modify the activity to 79 in zmpets_shipaciv table.
    -->  p1        text
    <--  p2        text
    FORM f_modify_activity .
      REFRESH int_crb_mail.
      int_crb_mail[] = int_crb[].
    *All the document number which is to be processed is stored in
    *the internel table 'INT_SIN'.
      LOOP AT int_crb INTO int_crb.
        IF int_crb-sel ='X'.
          MOVE int_crb-shipdocnum TO int_sin.
          APPEND int_sin.
          CLEAR int_sin.
    *Removing the processed documents.
          DELETE int_crb.
        ENDIF.
        CLEAR int_crb.
      ENDLOOP.
    *Get the details from shipactiv table.
      IF int_sin[] IS NOT INITIAL.
        SELECT * FROM zmpets_shipactiv
            INTO TABLE int_shipactiv
              FOR ALL ENTRIES IN int_sin
                    WHERE petsdocnumber = int_sin-shipdocnum.
    *Modify the activity code, version, actual date and last changed date.
        SORT int_shipactiv BY petsdocnumber version DESCENDING.
        CLEAR wf_tabix.
        LOOP AT int_shipactiv.
          wf_tabix = sy-tabix.
          AT NEW petsdocnumber.
            READ TABLE int_shipactiv INDEX wf_tabix.
            int_shipactiv-activity = '030'.
            int_shipactiv-version = int_shipactiv-version + 1.
            int_shipactiv-actdate = sy-datum.
            int_shipactiv-lastchangedby = sy-uname.
            int_shipactiv-lastchangedt = sy-datum.
    *Modify the data base table
            MODIFY zmpets_shipactiv FROM int_shipactiv.
          ENDAT.
          CLEAR int_shipactiv.
          AT LAST.
    *Message is 'Data Processed Successfully.'.
            MESSAGE s203(zm050).
          ENDAT.
        ENDLOOP.
    *-send mail to the vendor and employee that the shipment is cleared for
        LOOP AT int_crb_mail WHERE sel = 'X'.
          PERFORM f_send_mail.
        ENDLOOP.
        REFRESH int_crb_mail.
       CALL SELECTION-SCREEN 1000.
      ELSE.
    *Message is 'No Data Selected for Processing.'.
        MESSAGE s200(zm050).
      ENDIF.
    ENDFORM.                    " f_modify_activity
    *&      Form  f_clear_fields
          text
    -->  p1        text
    <--  p2        text
    FORM f_clear_fields .
      CLEAR int_crb.
      CLEAR int_crb_ver.
      CLEAR int_sin.
      REFRESH int_crb.
      REFRESH int_crb_ver.
      REFRESH int_sin.
      CLEAR int_shipactiv.
      REFRESH int_shipactiv.
      CLEAR wf_flag.
      CLEAR wf_tabix.
    ENDFORM.                    " f_clear_fields
    *&      Form  f_filter_data
          text
    -->  p1        text
    <--  p2        text
    FORM f_filter_data .
    *Take the latest Version Data.
    *take all the activities, including the activity '30'.
    then put the details in internal table 'INT_CRB'.
      SORT int_crb_ver BY shipdocnum version DESCENDING.
      CLEAR wf_tabix.
      CLEAR int_crb.
      REFRESH int_crb.
      LOOP AT int_crb_ver.
        wf_tabix = sy-tabix.
        AT NEW shipdocnum.
          READ TABLE int_crb_ver INDEX wf_tabix.
          MOVE-CORRESPONDING int_crb_ver TO int_crb.
          APPEND int_crb.
          CLEAR int_crb.
        ENDAT.
      ENDLOOP.
      IF int_crb[] IS INITIAL.
    *Message is 'No Records Available.'.
        MESSAGE s202(zm050).
      ELSE.
        CLEAR wf_tabix.
        LOOP AT int_crb.
          wf_tabix = sy-tabix.
          REFRESH lt_celltab.
          ls_celltab-fieldname = 'SEL'.
          IF int_crb-activity = '030'.
            ls_celltab-style = cl_gui_alv_grid=>mc_style_disabled.
    *status becomes green. ie processed
            int_crb-icon = '@08@'. "Green
          ELSE.
            ls_celltab-style = cl_gui_alv_grid=>mc_style_enabled.
    *status set to red. ie not yet processed
            int_crb-icon = '@0A@'. "Red
          ENDIF.
          INSERT ls_celltab INTO TABLE lt_celltab.
          INSERT LINES OF lt_celltab INTO TABLE int_crb-celltab.
          MODIFY int_crb INDEX wf_tabix.
        ENDLOOP.
      ENDIF.
    ENDFORM.                    " f_filter_data
    *&      Form  f_filter_data
          text
    -->  p1        text
    <--  p2        text
    FORM f_filter_data_pending.
    *Take the latest Version Data.
    *take all the activities, including the activity '30'.
    *then filter it with out the activities '30' and having the lastest
    *version. then put the details in internal table 'INT_CRB'.
      SORT int_crb_ver BY shipdocnum version DESCENDING.
      CLEAR wf_tabix.
      CLEAR int_crb.
      REFRESH int_crb.
      LOOP AT int_crb_ver.
        wf_tabix = sy-tabix.
        AT NEW shipdocnum.
          READ TABLE int_crb_ver INDEX wf_tabix.
          IF int_crb_ver-activity NE '030'.
            MOVE-CORRESPONDING int_crb_ver TO int_crb.
            APPEND int_crb.
            CLEAR int_crb.
          ENDIF.
        ENDAT.
      ENDLOOP.
      IF int_crb[] IS INITIAL.
    *Message is 'No Records Available.'.
        MESSAGE s202(zm050).
      ENDIF.
    ENDFORM.                    " f_filter_data_pending
    *&      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  f_send_mail
          text
    -->  p1        text
    <--  p2        text
    FORM f_send_mail .
    *store the vendor name, vendor email id , employee name and employee
    *email id in the internal table int_crb
    Creation of the document to be sent
      CLEAR doc_chng.
      REFRESH objpack.
      REFRESH objhead.
      REFRESH  reclist.
      REFRESH objtxt.
    File Name
      doc_chng-obj_name = 'SHIPMENT'.
    Mail Subject
      CONCATENATE 'Shipment Document No.' int_crb_mail-shipdocnum
      'Cleared.'
      INTO doc_chng-obj_descr SEPARATED BY ' '.
    Mail Contents
      objtxt-line = 'Hi,'.
      APPEND objtxt.
      objtxt-line = ' '.
      APPEND objtxt.
      CONCATENATE 'Shipment Document Number ' int_crb_mail-shipdocnum
    ' cleared for move.' INTO objtxt-line SEPARATED BY ' '.
      APPEND objtxt.
      objtxt-line = ' '.
      APPEND objtxt.
      CLEAR  objtxt.
      objtxt-line = 'Regards '.
      APPEND objtxt.
      objtxt-line = ' '.
      APPEND objtxt.
      objtxt-line = 'SAP '.
      APPEND objtxt.
      CLEAR  objtxt.
      APPEND objtxt.
      DESCRIBE TABLE objtxt LINES tab_lines.
      READ TABLE objtxt INDEX tab_lines.
      doc_chng-doc_size = ( tab_lines - 1 ) * 255 + STRLEN(
    objtxt ).
    Creation of the entry for the compressed document
      CLEAR objpack-transf_bin.
      objpack-head_start = 1.
      objpack-head_num = 0.
      objpack-body_start = 1.
      objpack-body_num = tab_lines.
      objpack-doc_type = 'RAW'.
      APPEND objpack.
    Completing the recipient list
    target recipent
      CLEAR reclist.
      reclist-receiver = int_crb_mail-empperid. "employee email ID
      "wf_empperid.
      reclist-express  = 'X'.
      reclist-rec_type = 'U'.
      APPEND reclist.
    copy recipents
    CLEAR reclist.
    reclist-receiver = 'anversha.shahul@'."int_crb_mail-smtp_addr
    reclist-express  = 'X'.
    reclist-rec_type = 'U'.
    reclist-copy     = 'X'.
    APPEND reclist.
    Sending the document
      CALL FUNCTION 'SO_NEW_DOCUMENT_ATT_SEND_API1'
        EXPORTING
          document_data              = doc_chng
        TABLES
          packing_list               = objpack
          object_header              = objhead
       contents_bin               = objbin
          contents_txt               = objtxt
          receivers                  = reclist
        EXCEPTIONS
          too_many_receivers         = 1
          document_not_sent          = 2
          operation_no_authorization = 4
          OTHERS                     = 99.
      COMMIT WORK.
      SUBMIT rsconn01
                    WITH mode = 'INT'
                    WITH output = ' '
                      AND RETURN.
    ENDFORM.                    " f_send_mail
    rgds
    anver
    pls mark hlpful answers

  • How to raise error message from PAI of oops ALV report

    Hi All,
    I have a requirement to raise error message form editable oops alv . After entering the data and then press SAVE button .
    Please help.
    Thanks in Advance

    HI SK,
    Write a Local class (Event Handeler) to handel the events. In Editable ALV once the user enter a value, CL_GUI_ALV_GRID will raise an event called DATA_CHANGED.
    1. Define and Implement a local class to handle that event.
    In the implementation of this class you need to get data from imported object to an internal table, then compare the same with the ALV output table.
    * Local Class to handler the events raised from the ALV Grid
    CLASS LCL_EVENT_HANDLER DEFINITION.
    PUBLIC SECTION.
    * Method to handel EDIT event, DATA_CHANGED of CL_GUI_ALV_GRID
      METHODS : ON_DATA_CHANGE FOR EVENT DATA_CHANGED OF CL_GUI_ALV_GRID
                           IMPORTING ER_DATA_CHANGED.
    ENDCLASS.
    * Event handler class Implementation
    CLASS LCL_EVENT_HANDLER IMPLEMENTATION.
      METHOD ON_DATA_CHANGE.
        DATA : LT_MODIFY TYPE LVC_T_MODI,
                   LS_MODIFY TYPE LVC_S_MODI.
    * Copying changed data into intenal table from Object
        LT_MODIFY = ER_DATA_CHANGED->MT_MOD_CELLS.
    * Modifying the ouptut table with the changed values
        IF LT_MODIFY[] IS NOT INITIAL.
              *Compare the ALV Output table with LT_MODIFY
        ENDIF.
      ENDMETHOD.
    ENDCLASS.
    Then raise  a message on required condition in the same method.
    Note: To trigger the above method, you need to set event handler before displaying ALV (before calling method SET_TABLE_FOR_FIRST_DISPLAY)
    * Creating object for the Local event handler class
      CREATE OBJECT GR_HANDLER.
    * Set handler (call method of Event_handler) to handler Edit event
      SET HANDLER GR_HANDLER->ON_DATA_CHANGE FOR  GR_GRID.
    Regards,
    Vijay

  • How to set a selected checkbox in output internal table of oops ALV grid

    Hi All,
    i have a checkbox as first column in my ALV grid output using oops alv, when i select some checkbox, that rows have to be selected and i need to process only selected rows in user command.
    i have given the below code also in fieldcatolg.
    f_fldcat-fieldname = 'checkbox'.
    f_fldcat-tabname ='gi_output'
    f_fldcat-checkbox = 'X'.
    f_fldcat-edit = 'X'.
    but the checkbox is not getting set in internal table when i select some checkboxes.
    can anybody explain y the checkbox in internal table not getting set?
    Thanks,
    Srilakshmi.

    Hi,
    i tried already whatever u said, but still not resolved.Pasted my code below..can u please look into it.
    MODULE pbo OUTPUT.
      PERFORM init_container.
      PERFORM prepare_field_catalog.
      PERFORM prepare_layout.
      PERFORM display_output.
    ENDMODULE.                 " PBO  OUTPUT
    *&      Module  PAI  INPUT
          text
    MODULE pai INPUT.
       DATA: lt_rows TYPE lvc_t_row.
      CASE gv_okcode.
        WHEN gc_exit OR gc_back OR gc_canc. " Finish program
          LEAVE PROGRAM.
          when 'PRINT'.
           CALL METHOD gv_grid->get_selected_rows
                     IMPORTING et_index_rows = lt_rows.
            CALL METHOD cl_gui_cfw=>flush.
      ENDCASE.
    ENDMODULE.                 " PAI  INPUT
    *&      Form  INIT_CONTAINER
          text
    FORM init_container .
      CREATE OBJECT gv_custom_container
        EXPORTING
          container_name = gc_container.
      CREATE OBJECT gv_grid
        EXPORTING
          i_parent = gv_custom_container.
      CREATE OBJECT gv_document
        EXPORTING
          style = 'ALV_GRID'.
    *&      Form  PREPARE_FIELD_CATALOG
          text
    FORM prepare_field_catalog .
      PERFORM fill_catalog USING:
    'Table Name'   'Field Name' 'NoZero'   'sel-text'
      'GI_OUTPUT'  'CHECKBOX'   ' '           text-013  'X',
      'GI_OUTPUT'  'KUNNR'      'X'           text-003  ' ',
      'GI_OUTPUT'  'NAME1'      ' '           text-004  ' ',
      'GI_OUTPUT'  'BELNR'      'X'           text-005  ' ',
      'GI_OUTPUT'  'BLART'      ' '           text-006  ' ',
      'GI_OUTPUT'  'BUDAT'      ' '           text-007  ' ',
      'GI_OUTPUT'  'BLDAT'      ' '           text-008  ' ',
      'GI_OUTPUT'  'DMBTR'      ' '           text-009  ' ',
      'GI_OUTPUT'  'WAERS'      ' '           text-010  ' '.
    ENDFORM.                    " PREPARE_FIELD_CATALOG
    *&      Form  FILL_CATALOG
          text
    FORM fill_catalog  USING    fv_tabname
                                fv_fldname
                                fv_nozero
                                fv_seltxt
                                fv_checkbox.
      DATA f_fldcat TYPE lvc_s_fcat.
      f_fldcat-fieldname     = fv_fldname.
      f_fldcat-tabname       = fv_tabname.
      f_fldcat-no_zero       = fv_nozero.
      f_fldcat-coltext       = fv_seltxt.
      f_fldcat-checkbox      = fv_checkbox.
      IF fv_checkbox = gc_x.
        f_fldcat-edit = gc_x.
      ENDIF.
      APPEND f_fldcat TO gi_fieldcat.
    ENDFORM.                    " FILL_CATALOG
    *&      Form  PREPARE_LAYOUT
          text
    FORM prepare_layout .
      gs_layout-info_fname = 'COL'.
      gs_layout-cwidth_opt = gc_x.
      gs_layout-zebra      = gc_x.
      gs_layout-no_toolbar = gc_x.
      gs_layout-no_rowmark = '1'.
      gs_layout-sel_mode = 'A'.
    ENDFORM.                    " PREPARE_LAYOUT
    *&      Form  DISPLAY_OUTPUT
          text
    FORM display_output .
      CALL METHOD gv_grid->set_table_for_first_display
        EXPORTING
          is_layout       = gs_layout
        CHANGING
          it_outtab       = gi_output
          it_fieldcatalog = gi_fieldcat.
      CREATE OBJECT event_receiver.
      SET HANDLER event_receiver->handle_user_command FOR gv_grid.
    CALL METHOD cl_gui_control=>set_focus EXPORTING control = gv_grid.
    ENDFORM.                    " DISPLAY_OUTPUT

  • Runtime error while trying to execute custom F4 help in OOP ALV grid.

    Dear All,
    I am trying to add custom search help for one of my column in ALV grid. I'm using OOP ALV, when i click for search help for that column, the system shows runtime error like below.
    I am new to OOP concept and tried to follow program BCALV_EDIT_03. But not getting this error occur. Please help me.
    With regards.

    Hi,
    In order to be able to provide a search help for a field in an ALV you must do the following things.
    1) The field where F4 help need to be attached needs to be made editable.
    2) Create an event handler class to handle the ONF4 event. You can refer the following code:
        CLASS lcl_alv1_handler DEFINITION.
        PUBLIC SECTION.
           "Tohandle F4 helps
           METHODS handle_f4 FOR EVENT onf4 OF cl_gui_alv_grid
                   IMPORTING e_fieldname e_fieldvalue es_row_no er_event_data
                             et_bad_cells e_display.
        ENDCLASS.
       CLASS lcl_alv1_handler IMPLEMENTATION.
          METHOD handle_f4.
    CASE e_fieldname.
         WHEN 'LIFNR'.               "Set F4 for courier vendor
             SELECT lifnr name1 FROM lfa1 INTO TABLE lt_lifnr.
           IF lt_lifnr IS NOT INITIAL.
             CALL FUNCTION 'F4IF_INT_TABLE_VALUE_REQUEST'
               EXPORTING
                 retfield           = 'LIFNR'
                 window_title   = 'Vendors'
                 value_org       = 'S'
               TABLES
                 value_tab       = lt_lifnr
                 return_tab      = lt_return
               EXCEPTIONS
                 parameter_error = 1
                 no_values_found = 2
                 OTHERS          = 3.
             IF sy-subrc = 0.
               READ TABLE gt_final INTO wa_final_t INDEX es_row_no-row_id.
               IF sy-subrc = 0.
                 READ TABLE lt_return INTO wa_return INDEX 1.
                 IF sy-subrc = 0.
                   CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT'
                     EXPORTING
                       input  = wa_return-fieldval
                     IMPORTING
                       output = lv_lifnr.
                   wa_final_t-lifnr  = lv_lifnr.
                   MODIFY gt_final FROM wa_final_t INDEX es_row_no-row_id.
                 ENDIF.
               ENDIF.
             ENDIF.
           ENDIF.
          ENDCASE.
             CALL METHOD o_alv->refresh_table_display.
          ENDMETHOD.
       ENDCLASS.
        In the above method, GT_FINAL-LIFNR is being overwritten by the LIFNR you had selected       from F4 help. So we will call the refresh_table_display after it to see the result in the ALV.
    3) After creating the ALV object, add the fields to which the F4 has to be added. For this you
        need to declare an internal table based on  lvc_t_f4. Use the following code. Here O_ALV is    my ALV object.:
       CREATE OBJECT o_container
           EXPORTING
             container_name              = 'CUSTCON'
           EXCEPTIONS
             cntl_error                  = 1
             cntl_system_error           = 2
             create_error                = 3
             lifetime_error              = 4
             lifetime_dynpro_dynpro_link = 5
             OTHERS                      = 6.
         IF sy-subrc <> 0.
    *     MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
    *                WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
         ENDIF.
         CREATE OBJECT o_alv
           EXPORTING
             i_parent          = o_container
           EXCEPTIONS
             error_cntl_create = 1
             error_cntl_init   = 2
             error_cntl_link   = 3
             error_dp_create   = 4
             OTHERS            = 5.
         IF sy-subrc <> 0.
    *     MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
    *                WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
         ENDIF.
       CLEAR : gt_f4, wa_f4.
       wa_f4-fieldname   = 'LIFNR'.
       wa_f4-register    = 'X'.
       wa_f4-getbefore   = space.
       wa_f4-chngeafter  = space.
       APPEND wa_f4 TO gt_f4.
       Here I am assigning F4 to LIFNR field in the final internal table that is displayed using ALV.
       After this register this field for F4.
        CALL METHOD o_alv->register_f4_for_fields
           EXPORTING
              it_f4 = gt_f4.
       CREATE OBJECT o_alv_handler.
       SET HANDLER : o_alv_handler->handle_f4 FOR o_alv1.
       The object o_alv_handler is created based on the event handler class.
    I hope that this will solve your issue. Revert if this is solved.
    Rgards,
    Abijith

  • Event handling in oops alv

    hi experts,
    event double click.
    when double click  on vbeln it should go to va03 transaction . how would i do that in oops alv.

    hai,
    you can go through code below .
    *& Report  Z_CLARIFY                                                   *
    REPORT  Z_CLARIFY                               .
    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 = 'SCR100_CUST'.
      "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
    there are many such examples
    goto->se38->type bcalv* and press f4, u can see many examples.
    Reward points if helpful.
    Thanks and regards
    Swetha Singh.

Maybe you are looking for