ALV F8 event + Checkbox?

Hi,
1. How to catch F8 event in an ALV?
2. How to determine witch checkbox is checked.
tnx!
Simple ALV example:
TYPE-POOLS: slis.
DATA: g_repid LIKE sy-repid,
gs_print            TYPE slis_print_alv,
gt_list_top_of_page TYPE slis_t_listheader,
gt_events           TYPE slis_t_event,
gt_sort             TYPE slis_t_sortinfo_alv,
gs_layout           TYPE slis_layout_alv,
gt_fieldcat         TYPE slis_t_fieldcat_alv,
fieldcat_ln LIKE LINE OF gt_fieldcat,
col_pos TYPE i.
DATA: BEGIN OF itab,
sel,
  field1(5) TYPE c,
  field2(5) TYPE c,
  field3(5) TYPE p DECIMALS 2,
END OF itab.
DATA: BEGIN OF itab1 OCCURS 0.
        INCLUDE STRUCTURE itab.
DATA: END OF itab1.
DATA: BEGIN OF itab_fieldcat OCCURS 0.
        INCLUDE STRUCTURE itab.
DATA: END OF itab_fieldcat.
INITIALIZATION.
  g_repid = sy-repid.
" PERFORM print_build    USING gs_print.      "Print PARAMETERS
  gs_layout-box_fieldname = 'SEL'.
START-OF-SELECTION.
* TEST DATA
  MOVE 'TEST1' TO itab1-field1.
  MOVE 'TEST1' TO itab1-field2.
  MOVE '10.00' TO itab1-field3.
  APPEND itab1.
  MOVE 'TEST2' TO itab1-field1.
  MOVE 'TEST2' TO itab1-field2.
  MOVE '20.00' TO itab1-field3.
  APPEND itab1.
  DO 5 TIMES.
    APPEND itab1.
  ENDDO.
END-OF-SELECTION.
  PERFORM build.
  PERFORM call_alv.
*&      Form  BUILD
*       text
FORM build.
* DATA FIELD CATALOG
* Explain Field Description to ALV
  DATA: fieldcat_in TYPE slis_fieldcat_alv.
  CLEAR fieldcat_in.
  fieldcat_ln-fieldname = 'FIELD1'.
  fieldcat_ln-tabname   = 'ITAB1'.
*FIELDCAT_LN-NO_OUT    = 'X'.  "FIELD NOT DISPLAY, CHOOSE FROM LAYOUT
  fieldcat_ln-key       = ' '.   "SUBTOTAL KEY
  fieldcat_ln-no_out    = ' '.
  fieldcat_ln-seltext_l = 'HEAD1'.
  APPEND fieldcat_ln TO gt_fieldcat.
  CLEAR fieldcat_in.
  fieldcat_ln-fieldname = 'FIELD2'.
  fieldcat_ln-tabname   = 'ITAB1'.
  fieldcat_ln-no_out    = 'X'.
  fieldcat_ln-seltext_l = 'HEAD2'.
  APPEND fieldcat_ln TO gt_fieldcat.
  CLEAR fieldcat_in.
  fieldcat_ln-fieldname     = 'FIELD3'.
  fieldcat_ln-tabname       = 'ITAB1'.
  fieldcat_ln-ref_fieldname = 'MENGE'. "<- REF FIELD IN THE DICTIONNARY
  fieldcat_ln-ref_tabname   = 'MSEG'.  "<- REF TABLE IN THE DICTIONNARY
  fieldcat_ln-no_out        = ' '.
  fieldcat_ln-do_sum        = 'X'.   "SUM UPON DISPLAY
  APPEND fieldcat_ln TO gt_fieldcat.
* DATA SORTING AND SUBTOTAL
  DATA: gs_sort TYPE slis_sortinfo_alv.
  CLEAR gs_sort.
  gs_sort-fieldname = 'FIELD1'.
  gs_sort-spos      = 1.
  gs_sort-up        = 'X'.
  gs_sort-subtot    = 'X'.
  APPEND gs_sort TO gt_sort.
  CLEAR gs_sort.
  gs_sort-fieldname = 'FIELD2'.
  gs_sort-spos      = 2.
  gs_sort-up        = 'X'.
*GS_SORT-SUBTOT    = 'X'.
  APPEND gs_sort TO gt_sort.
ENDFORM.                    "BUILD
*&      Form  CALL_ALV
*       text
FORM call_alv.
* ABAP List Viewer
  CALL FUNCTION 'REUSE_ALV_LIST_DISPLAY'
  EXPORTING
  i_callback_program = g_repid
* I_CALLBACK_PF_STATUS_SET = ' '
* I_CALLBACK_USER_COMMAND = ' '
  i_structure_name = 'ITAB1'
  is_layout =  gs_layout
  it_fieldcat = gt_fieldcat[]
    it_sort = gt_sort[]
    it_events = gt_events[]
    is_print = gs_print
  TABLES
  t_outtab = itab1
  EXCEPTIONS
  program_error = 1
  OTHERS = 2.
ENDFORM.                    "CALL_ALV

Hi,
stil not working..:(
Please, could you use my code and fil up with yours?
TYPE-POOLS: slis.
DATA: g_repid LIKE sy-repid,
gs_print            TYPE slis_print_alv,
gt_list_top_of_page TYPE slis_t_listheader,
gt_events           TYPE slis_t_event,
gt_sort             TYPE slis_t_sortinfo_alv,
gs_layout           TYPE slis_layout_alv,
gt_fieldcat         TYPE slis_t_fieldcat_alv,
fieldcat_ln LIKE LINE OF gt_fieldcat,
col_pos TYPE i.
DATA: BEGIN OF itab,
sel,
  field1(5) TYPE c,
  field2(5) TYPE c,
  field3(5) TYPE p DECIMALS 2,
END OF itab.
DATA: BEGIN OF itab1 OCCURS 0.
        INCLUDE STRUCTURE itab.
DATA: END OF itab1.
DATA: BEGIN OF itab_fieldcat OCCURS 0.
        INCLUDE STRUCTURE itab.
DATA: END OF itab_fieldcat.
INITIALIZATION.
  g_repid = sy-repid.
  " PERFORM print_build    USING gs_print.      "Print PARAMETERS
  gs_layout-box_fieldname = 'SEL'.
START-OF-SELECTION.
* TEST DATA
  MOVE 'TEST1' TO itab1-field1.
  MOVE 'TEST1' TO itab1-field2.
  MOVE '10.00' TO itab1-field3.
  APPEND itab1.
  MOVE 'TEST2' TO itab1-field1.
  MOVE 'TEST2' TO itab1-field2.
  MOVE '20.00' TO itab1-field3.
  APPEND itab1.
  DO 5 TIMES.
    APPEND itab1.
  ENDDO.
  gs_layout-get_selinfos = 'X'.
END-OF-SELECTION.
  PERFORM build.
  PERFORM call_alv.
*&      Form  BUILD
*       text
FORM build.
* DATA FIELD CATALOG
* Explain Field Description to ALV
  DATA: fieldcat_in TYPE slis_fieldcat_alv.
  CLEAR fieldcat_in.
  fieldcat_ln-fieldname = 'FIELD1'.
  fieldcat_ln-tabname   = 'ITAB1'.
*FIELDCAT_LN-NO_OUT    = 'X'.  "FIELD NOT DISPLAY, CHOOSE FROM LAYOUT
  fieldcat_ln-key       = ' '.   "SUBTOTAL KEY
  fieldcat_ln-no_out    = ' '.
  fieldcat_ln-seltext_l = 'HEAD1'.
  APPEND fieldcat_ln TO gt_fieldcat.
  CLEAR fieldcat_in.
  fieldcat_ln-fieldname = 'FIELD2'.
  fieldcat_ln-tabname   = 'ITAB1'.
  fieldcat_ln-no_out    = 'X'.
  fieldcat_ln-seltext_l = 'HEAD2'.
  APPEND fieldcat_ln TO gt_fieldcat.
  CLEAR fieldcat_in.
  fieldcat_ln-fieldname     = 'FIELD3'.
  fieldcat_ln-tabname       = 'ITAB1'.
  fieldcat_ln-ref_fieldname = 'MENGE'. "<- REF FIELD IN THE DICTIONNARY
  fieldcat_ln-ref_tabname   = 'MSEG'.  "<- REF TABLE IN THE DICTIONNARY
  fieldcat_ln-no_out        = ' '.
  fieldcat_ln-do_sum        = 'X'.   "SUM UPON DISPLAY
  APPEND fieldcat_ln TO gt_fieldcat.
* DATA SORTING AND SUBTOTAL
  DATA: gs_sort TYPE slis_sortinfo_alv.
  CLEAR gs_sort.
  gs_sort-fieldname = 'FIELD1'.
  gs_sort-spos      = 1.
  gs_sort-up        = 'X'.
  gs_sort-subtot    = 'X'.
  APPEND gs_sort TO gt_sort.
  CLEAR gs_sort.
  gs_sort-fieldname = 'FIELD2'.
  gs_sort-spos      = 2.
  gs_sort-up        = 'X'.
*GS_SORT-SUBTOT    = 'X'.
  APPEND gs_sort TO gt_sort.
ENDFORM.                    "BUILD
*&      Form  CALL_ALV
*       text
FORM call_alv.
* ABAP List Viewer
  CALL FUNCTION 'REUSE_ALV_LIST_DISPLAY'
  EXPORTING
  i_callback_program = g_repid
* I_CALLBACK_PF_STATUS_SET = ' '
  i_callback_user_command = 'form_user'
  i_structure_name = 'ITAB1'
  is_layout =  gs_layout
  it_fieldcat = gt_fieldcat[]
  it_sort = gt_sort[]
  it_events = gt_events[]
  is_print = gs_print
  TABLES
  t_outtab = itab1
  EXCEPTIONS
  program_error = 1
  OTHERS = 2.
ENDFORM.                    "CALL_ALV
*&      Form  form_user
*       text
FORM form_user.
  CASE sy-ucomm.
    WHEN 'ENTER' OR 'SPACE'.                                " for F8
***do coding
  ENDCASE.
ENDFORM.                    "form_user

Similar Messages

  • In ALV End_of_list Event  Scrolling Option

    Hi Experts,
    In ALV END_OF_LIST Event if I want to display more records approx:50 .
    iam able to display using Reuse_Alv_Commentary_Write But .Due to high volume of Records Its Overlaping Main List  I need to drag Manually.
    My Question : is There any option where Scrolling is Available for Reuse_Alv_Commentary.
    Thank You.Please Reply.

    Hi,
    Use do_sum = 'X', in the fieldcatalog for the fields for which you need to do the summation.
    Best Regards,
    Durga Naresh Bayireddy

  • ALV  ONF4 event

    Hi All,
    I have used the ALV onF4 event for F4 help for a field in an ALV display....But the problem is that this is not getting triggered on pressing F4.....
    What might be the problem..
    I have referred the program : BCALV_EDIT_08.
    -SatyaPriya

    Hi ,
      Please check whether you have created the class to handle events and also set the handlers for it.
    Regards
    Arun

  • ALV Print event in Custom Button

    Hi,
    I have requirement to call ALV print event in Custom Button after some condition. Can anyone give me the solution or link to achieve this requirement.
    Thank in advance.

    Hi Mani,
    On that ALV button event, write the following code.
      DATA lo_component TYPE REF TO if_wd_component.
      DATA lo_appl      TYPE REF TO if_wd_application.
      lo_component = wd_comp_controller->wd_get_api( ).
      lo_appl      = lo_component->get_application( ).
      lo_appl->print_page( ).
      DATA lo_app_info TYPE REF TO if_wd_rr_application .
      lo_app_info = lo_appl->get_application_info( ).
      DATA lv_app_name TYPE string .
      lv_app_name = lo_app_info->get_name( ).
    It helps you to print the table contents. Hope this helps you.
    Thanks
    KH

  • Wrong messagetype while processing in an alv grid event

    Hello,
    a brief discription of my problem:
    I am processing a standard SAP form "PERIODE_PRUEFEN" which calls the function "READ_CUSTOMIZED_MESSAGE". The routine is called inside an event-handler of the ALV Grid event 'user_command'. The messagetype is selected from a customising table 'T100C'. Despite the messagetype 'W' the program is always aborted with an 'E' message.
    What I have tried so far:
    1. I debugged the SAP standard transaction 'fb08' which runs exactly the same functions with the same values and it works.
    2. I changed the messagetype in the debugger - no success
    3. I searched the SAP notes, but theres nothing about my problem
    I guess the problem is somewhere in the ALV Grid event, because this is the only difference between the SAP standard an my program. Maybe the message is processed wrong while beeing called within an event.
    It would be great to get some useful hints to solve this problem

    Hi,
    The ABAP runtime environment handles messages according to the type declared in the MESSAGE statement and the context in which the message was sent.
    The behaviour of message type 'W' in a dialog is different from a report program.
    Run demo program DEMO_MESSAGES, select Main Program, Type 'W' and execute. You will get an error message instead of warning message.
    This behaviour is well documeneted in the on-line help for MESSAGE statement.
    Regards,
    Rao A

  • ACTIONS ON ALV REPORT FOR CHECKBOX?

    hi All,
    i have to display ALVreport with one of the columns has checkbox.whenever user presses any checkbox,in repected row values have to be validated and updated in DataBase.
    My First Doubt is,How can i get the column of checkBoxes in ALV Report.?
    2.How can i add action for that checkBox?
    Regards,
    Ravi.

    Hi Ravi,
    Your requirement can be achieved by creating a custom function in your ALV.
    We create a button in the ALV toolbar with text 'Confirm'. When user clicks on this, a popup screen is called for confirmation. Based on the input we set the flag.
    To accomplish this, When defining the configuration model of the ALV, do the following
    Assume that we get the model of the ALV into lo_list
    lo_list = lo_ref_interfacecontroller->get_model( ).
    DATA:
    * Generate an object for self defined functions
        lo_self_functions          TYPE REF TO if_salv_wd_function_settings,
    * Generate an object for button 'Confirm'
        lo_button_conf          TYPE REF TO cl_salv_wd_fe_button,
    * Set Self-defined functions
    * 'Confirm' Button
      lo_self_functions ?= lo_list.
      lo_self_function = lo_self_functions->create_function( 'CONFIRM' ).
      CREATE OBJECT lo_button_conf.
      CLEAR l_text.
      l_text = 'Confirm'
      lo_button_sel_all->set_text( l_text ).
      lo_button_sel_all->set_image_source( '< Any icon name >' ).
      lo_button_sel_all->set_image_first( 'X' ).
      lo_self_function->set_editor( lo_button_conf ).
    In the methods tab, Create a event handler for ON_FUNCTION event of the ALV.
    ONFUNTION     Event Handler     ON_FUNCTION     ON_FUNCTION     INTERFACECONTROLLER     alv_name
    In the ONFUNCTION method, Do the following.
      DATA:
        l_window                  TYPE REF TO if_wd_window,
        l_componentcontroller_api TYPE REF TO if_wd_component,
        l_window_manager          TYPE REF TO if_wd_window_manager,
        l_api                     TYPE REF TO if_wd_view_controller,
        lt_text                   TYPE string_table,
        l_text_line               TYPE string.
    * Based on the function selected, set the selection
      CASE  r_param->id.
        WHEN 'CONFIRM'.
    * Call the confirmation for popup
      l_api = wd_this->wd_get_api( ).
      l_componentcontroller_api = wd_comp_controller->wd_get_api( ).
      l_window_manager = l_componentcontroller_api->get_window_manager( ).
      CALL METHOD l_window_manager->create_popup_to_confirm
        EXPORTING
          text            = lt_text
          button_kind     = if_wd_window=>co_buttons_yesno
          message_type    = if_wd_window=>co_msg_type_question
          window_position = if_wd_window=>co_center
        RECEIVING
          result          = l_window.
      CALL METHOD l_window->subscribe_to_button_event
        EXPORTING
          button            = if_wd_window=>co_button_yes
          action_name       = 'YES'
          action_view       = l_api
          is_default_button = abap_false.
      CALL METHOD l_window->subscribe_to_button_event
         EXPORTING
           button            = if_wd_window=>co_button_no
           action_name       = 'NO'
           action_view       = l_api
           is_default_button = abap_false.
      l_window->open( ).
      ENDCASE.
    Create 2 actions with names YES and NO ( As mentioned in the subscription.
    In these actions, bases on the inputs, set the flag to a context attribute and update the same in the table you wanted.
    Hope this is what you want.
    Regards,
    Sravan Varagani.

  • ALV - Problem with checkbox.

    Dear All,
    I have created an ALV Grid Control and have one column as a check box.
    when i tick one checkbox in a line item i pop up a message saying "Do you wish to continue".
    If the user selects NO then i automatically want to deselect the checkbox.
    I tried clearing the work area of the internal table in the data change event.
    But when the alv is refreshed the checkbox is still ticked.What should be done to avoid this.
    Is freeing the custom container and creating it again everytime the user selects NO  a good option?
    Kindly suggest.
    Regards,
    Varun

    In ALV you put check box like
    X_FIELDCAT-FIELDNAME = 'CHK'.
    X_FIELDCAT-TABNAME = 'ITAB'.
    X_FIELDCAT-COL_POS = 1.
    X_FIELDCAT-INPUT = 'X'.
    X_FIELDCAT-EDIT = 'X'.
    X_FIELDCAT-CHECKBOX = 'X'.
    APPEND X_FIELDCAT TO IT_FIELDCAT.
    CLEAR X_FIELDCAT.
    in between you put logic
    IF CHK = 'X'
    *---popup_to_continue_yes_no
        PERFORM POPUP_TO_CONT_YES_NO.
    endif.
    FORM POPUP_TO_CONT_YES_NO .
      CALL FUNCTION 'POPUP_CONTINUE_YES_NO'
        EXPORTING
          TEXTLINE1 = 'Click OK to leave program'
          TITEL     = 'POPUP_CONTINUE_YES_NO'
        IMPORTING
          ANSWER    = ANS.
      IF ANS = 'J'.
        LEAVE PROGRAM.
      ENDIF.
    ENDFORM.                    " POPUP_TO_CONT_YES_NO

  • ALV Report Event

    Hi All
    Can you please tell me 'under which event do we write fieldcatalog ' in ALV Report.
    Thanks in Advance!
    Kiran

    Hi
    We fetch the data in start-of-selection and write the ALV related data in end of selection
    See the sample report
    report ZRGRIRNA no standard page heading
           line-count 65
           line-size 255
           message-id mm.
                       GR IR Detail Report                               *
    Description          : The output has to be displayed
                           in the ALV Grid format with the Selection     *
                           screen appearing on the output. In The Output *
                           Subtotals for Vendor, Plant, Period, Material,*
                           Valuation Class, Purchase Order,Cost Center,  *
                           Cost Element and Receipt Date are displayed   *
                           after sorting the data by same fields.        *
    Declaration for Tables
    tables: t001,      " Company Codes
            t001w,     " Plants/Branches
            lfa1,      " Vendor Master
            ska1,      " GL Account Master
            mara,      " Material Master
            mbew,      " Material Valuation
            ekko,      " PO Header Data
            cska,      " Cost Elements
            csks,      " Cost Centers
            bsis,      " GL Accounts: Open Items Data
            bkpf.      " Accounting Doc: Header Data
    Type-pools
    Type pools for ALV display
    type-pools : slis.
    Global variables
    data: g_repid       like sy-repid,
          g_exit        type c,
          g_events      type slis_t_event,
          g_list_top_of_page type slis_t_listheader,
          g_exit_caused_by_caller,
          g_exit_caused_by_user type slis_exit_by_user,
          g_top_of_page  type slis_formname value 'TOP_OF_PAGE',
          g_variant like disvariant,
          g_save.
    Declaration for Constants
    constants : c_x  type c  value 'X',         " Flag
                c_c  type c  value 'C',         " Flag
                c_l  type c  value 'L',         " Flag
                c_a  type c  value 'A',         " Line Type
                c_h  type c  value 'H',         " Dr/Cr
                c_s  type c  value 'S',         " Line Type
                c_mkpf(4) type c value 'MKPF'.  " Table
    Declaration of Internal Tables
    Internal Table for BSIS Table data
    data: begin of i_bsis occurs 0,
            bukrs like bsis-bukrs,          " Company Code
            hkont like bsis-hkont,          " GR IR Account
            gjahr like bsis-gjahr,          " Fiscal Year
            belnr like bsis-belnr,          " Acc Document
            buzei like bsis-buzei,          " Item No
            budat like bsis-budat,          " Receipt Date(Posting)
            monat like bsis-monat,          " Period
          end of i_bsis.
    Internal Table for BSEG Table data
    data: begin of i_bseg occurs 0,
            bukrs like bsis-bukrs,          " Company Code
            belnr like bsis-belnr,          " Acc Document
            buzei like bsis-buzei,          " Item No
            gjahr like bsis-gjahr,          " Fiscal Year
            shkzg like bseg-shkzg,          " Dr/Cr Indicator
            lifnr like bseg-lifnr,          " Vendor Code
            matnr like bseg-matnr,          " Material No
            ebeln like bseg-ebeln,          " Purchase Order
            ebelp like bseg-ebelp,          " PO Item
            werks like bseg-werks,          " Plant
            menge like bseg-menge,          " PO Quantity
            meins like bseg-meins,          " UOM
            dmbtr like bseg-dmbtr,          " Amount in Local Currency
            wrbtr like bseg-wrbtr,          " Amount in Trans.Currency
          end of i_bseg.
    Internal Table for BKPF Table data
    data: begin of i_bkpf occurs 0,
            bukrs like bkpf-bukrs,          " Company Code
            belnr like bkpf-belnr,          " Acc Document
            gjahr like bkpf-gjahr,          " Fiscal Year
            waers like bkpf-waers,          " Trans. Currency
            awkey like bkpf-awkey,          " Object Key
            awtyp like bkpf-awtyp,          " Reference Procedure
          end of i_bkpf.
    Internal Table for MSEG Table data
    data: begin of i_mseg occurs 0,
            mblnr like mseg-mblnr,          " Material Document
            mjahr like mseg-mjahr,          " Fiscal Year
            bwart like mseg-bwart,          " Movement Type
            matnr like mseg-matnr,          " Material No
            menge like mseg-menge,          " PO Quantity
            meins like mseg-meins,          " UOM
          end of i_mseg.
    Internal Table for MBEW Table data
    data: begin of i_mbew occurs 0,
            matnr like mbew-matnr,          " Material No
            werks like mbew-bwkey,          " Plant
            bklas like mbew-bklas,          " Valuation Class
          end of i_mbew.
    Internal Table for EKPO Table data
    data: begin of i_ekpo occurs 0,
            ebeln like ekpo-ebeln,          " Purchase Order
            ebelp like ekpo-ebelp,          " PO Item
            matnr like ekpo-matnr,          " Material No
            txz01 like ekpo-txz01,          " Material Text
          end of i_ekpo.
    Internal Table for EKKN Table data
    data: begin of i_ekkn occurs 0,
            ebeln like ekkn-ebeln,          " Purchase Order
            ebelp like ekkn-ebelp,          " PO Item
            kostl like ekkn-kostl,          " Cost Center
            sakto like ekkn-sakto,          " Cost Element
          end of i_ekkn.
    Internal Table for LFA1 Table data
    data: begin of i_lfa1 occurs 0,
            lifnr like lfa1-lifnr,          " Vendor
            name1 like lfa1-name1,          " Name
          end of i_lfa1.
    Declaration of Output Internal Table
    data: begin of i_final occurs 0,
            lifnr like lfa1-lifnr,     " Vendor
            werks like bseg-werks,     " Plant
            monat like bsis-monat,     " Period
            matnr like mara-matnr,     " Material Number
            bklas like mbew-bklas,     " Val Class
            ebeln like bseg-ebeln,     " PO
            kostl like ekkn-kostl,     " Cost Center
            sakto like ekkn-sakto,     " Cost Element
            budat like bsis-budat,     " Rec. Date
            name1 like lfa1-name1,     " Vendor Name
            belnr like bsis-belnr,     " FI Document
            bwart like mseg-bwart,     " Movement Type
            txz01 like ekpo-txz01,     " Material Text
            menge like bseg-menge,     " Quantity
            meins like bseg-meins,     " UOM
            dmbtr like bseg-dmbtr,     " Local Amount
            wrbtr like bseg-wrbtr,     " Tran.Amount
            waers like bkpf-waers,     " Tran.Currency
            status type c,             " Material Status
          end of i_final.
    Internal table to hold field catgory data
    data:  i_fldcat  type slis_t_fieldcat_alv.   " Table - field catgory
    Internal table to hold Sort/Subtotals criteria data
    data:  i_sort  type slis_t_sortinfo_alv.     " Table - sort/Subtotals
    Structure
    data:  x_layout   type slis_layout_alv,      " Structure-layout
           x_fldcat   like line of i_fldcat,     " Structure-field catagory
           x_sort     like line of i_sort.       " Structure-Sort/Subtotals
           Selection screen
    selection-screen : begin of block b1 with frame title text-000.
    parameters:
       p_bukrs like t001-bukrs obligatory,          " Company Code
       p_grira like ska1-saknr default '0241101000' obligatory. " Account
    select-options:
       s_budat for bkpf-budat,        " Posting Date
       s_werks for t001w-werks,       " Plant
       s_lifnr for lfa1-lifnr,        " Vendor
       s_matnr for mara-matnr,        " Material Number
       s_kostl for csks-kostl,        " Cost Center
       s_kstar for cska-kstar,        " Cost Element
       s_ebeln for ekko-ebeln,        " Purchase Order
       s_monat for bsis-monat.        " Period
    selection-screen skip.
    parameters:
       p_incmt as checkbox default 'X',
       p_incnm as checkbox default 'X'.
    selection-screen end of block b1.
    Initialization
    initialization.
      g_repid = sy-repid.
      perform layout_init using x_layout.
      perform eventtab_build using g_events[].
      g_variant-report = g_repid.
      g_save           = 'A'.
    At selection screen
    at selection-screen.
    Validation of Selection Screen Fields
      perform validate_screen.
    Start of selection
    start-of-selection.
    Read Data from Database Tables
      perform read_data.
    End of selection
    end-of-selection.
    Build layout report layout.
      perform populate_layout_stucture.
    Perform build_field_catalog and Sort Table
      perform build_field_catalog.
      perform build_sort_totals.
    List Header for Top-Of-Page
      perform comment_build using g_list_top_of_page[].
    Call list viewer function module
      perform call_list_viewer .
    ****************Form - Routines**************************************
          Form        : layout_init
          Description : Form to Build layout for list display
    form layout_init using rs_layout type slis_layout_alv.
      rs_layout-detail_popup      = c_x.
    endform.
    Form         : Eventtab_build
    Description  : Registration of events to happen during list display
    form eventtab_build using rt_events type slis_t_event.
    Registration of events to happen during list display
      data: ls_event type slis_alv_event.
      call function 'REUSE_ALV_EVENTS_GET'
           exporting
                i_list_type = 0
           importing
                et_events   = rt_events.
      read table rt_events with key name = slis_ev_top_of_page
                               into ls_event.
      if sy-subrc = 0.
        move g_top_of_page to ls_event-form.
        append ls_event to rt_events.
      endif.
    endform.                                   "eventtab_build
          Form : top_of_page
    form top_of_page.
      call function 'REUSE_ALV_COMMENTARY_WRITE'
           exporting
             I_LOGO             = 'ENJOYSAP_LOGO'
                it_list_commentary = g_list_top_of_page.
    endform.
          Form validate_screen
    Validation of Selection Screen fields
    form validate_screen.
    Validation of Company Code
      clear t001.
      if not p_bukrs is initial.
        select single bukrs
          into t001-bukrs
          from t001
          where bukrs eq p_bukrs.
        if sy-subrc <> 0.
          message e899 with 'Enter Valid Company Code'(012).
        endif.
      endif.
    Validation of GL Account (GR/IR)
      clear ska1.
      if not p_grira is initial.
        select saknr
          into ska1-saknr
          from ska1
          up to 1 rows
          where saknr eq p_grira.
        endselect.
        if sy-subrc <> 0.
          message e899 with 'Enter Valid GR/IR Account'(013).
        endif.
      endif.
    Validation of Vendor Code
      clear lfa1.
      if not s_lifnr[] is initial.
        select single lifnr
          into lfa1-lifnr
          from lfa1
          where lifnr in s_lifnr.
        if sy-subrc <> 0.
          message e899 with 'Enter Valid Vendor'(001).
        endif.
      endif.
    Validation of Plant Code
      clear t001w.
      if not s_werks[] is initial.
        select single werks
          into t001w-werks
          from t001w
          where werks in s_werks.
        if sy-subrc <> 0.
          message e899 with 'Enter Valid Plant'(014).
        endif.
      endif.
    Validation of Material Code
      clear mara.
      if not s_matnr[] is initial.
        select single matnr
          into mara-matnr
          from mara
          where matnr in s_matnr.
        if sy-subrc <> 0.
          message e899 with 'Enter Valid Material'(015).
        endif.
      endif.
    Validation of Purchase Order
      clear ekko.
      if not s_ebeln[] is initial.
        select single ebeln
          into ekko-ebeln
          from ekko
          where ebeln in s_ebeln.
        if sy-subrc <> 0.
          message e899 with 'Enter Valid Purchase Order'(016).
        endif.
      endif.
    Validation of Cost Center
      clear csks.
      if not s_kostl[] is initial.
        select kostl
          into csks-kostl
          from csks
          up to 1 rows
          where kostl in s_kostl.
        endselect.
        if sy-subrc <> 0.
          message e899 with 'Enter Valid Cost Center'(017).
        endif.
      endif.
    Validation of Cost Element
      clear cska.
      if not s_kstar[] is initial.
        select kstar
          into cska-kstar
          from cska
          up to 1 rows
          where kstar in s_kstar.
        endselect.
        if sy-subrc <> 0.
          message e899 with 'Enter Valid Cost Element'(018).
        endif.
      endif.
    endform.                          "validate_screen
    *&      Form  read_data
    Read the Data from the database Tables
    form read_data.
    Get the Accounting Documents for the GR/IR Account Entered on
    Selection Screen
      clear i_bsis.
      refresh i_bsis.
      select bukrs           " Company Code
             hkont           " GR IR Account
             gjahr           " Fiscal Year
             belnr           " Acc Document
             buzei           " Item No
             budat           " Receipt Date(Posting)
             monat           " Period
       into table i_bsis
       from  bsis
       where  bukrs = p_bukrs
         and  hkont = p_grira
         and  budat in s_budat
         and  monat in s_monat .
      if sy-subrc <> 0.
        message i899 with 'No data found'(043).
        g_exit = c_x.
        stop.
      endif.
      sort i_bsis by bukrs hkont gjahr belnr buzei.
    Get the Vendor,PO,Material,Qty details from BSEG Table
      if not i_bsis[] is initial.
        clear i_bseg.
        refresh i_bseg.
        select bukrs           " Company Code
               belnr           " Acc Document
               buzei           " Item No
               gjahr           " Fiscal Year
               shkzg           " Dr/Cr Indicator
               lifnr           " Vendor Code
               matnr           " Material No
               ebeln           " Purchase Order
               ebelp           " PO Item
               werks           " Plant
               menge           " PO Quantity
               meins           " UOM
               dmbtr           " Amount in Local Currency
               wrbtr           " Amount in Trans.Currency
        into table i_bseg
        from   bseg
        for all entries in i_bsis
        where  bukrs = p_bukrs
        and    belnr = i_bsis-belnr
        and    gjahr = i_bsis-gjahr
        and    buzei = i_bsis-buzei
        and    lifnr in s_lifnr
        and    werks in s_werks
        and    matnr in s_matnr
        and    ebeln in s_ebeln.
        sort i_bseg by bukrs belnr buzei gjahr.
    Select the Trans.Currency from BKPF Table
        clear i_bkpf.
        refresh i_bkpf.
        select bukrs           " Company Code
               belnr           " Acc Document
               gjahr           " Fiscal Year
               waers           " Trans. Currency
               awkey           " Object Key
               awtyp           " Reference Procedure
        into table i_bkpf
        from   bkpf
        for all entries in i_bsis
        where  bukrs = p_bukrs
        and    belnr = i_bsis-belnr
        and    gjahr = i_bsis-gjahr.
      endif.
      sort i_bkpf by bukrs belnr gjahr.
    Get the Quantity and UOM of Material from MSEG Table
      if not i_bkpf[] is initial.
        clear i_mseg.
        refresh i_mseg.
        select mblnr           " Material Document
               mjahr           " Fiscal Year
               bwart           " Movement Type
               matnr           " Material No
               menge           " PO Quantity
               meins           " UOM
          into table i_mseg
          from   mseg
          for all entries in i_bkpf
          where  mblnr = i_bkpf-awkey(10).
      endif.
      sort i_mseg by mblnr mjahr.
    Get the Material And Description from EKPO Table
      if not i_bseg[] is initial.
        clear i_ekpo.
        refresh i_ekpo.
        select ebeln           " Purchase Order
               ebelp           " PO Item
               matnr           " Material No
               txz01           " Material Text
        into table i_ekpo
        from   ekpo
        for all entries in i_bseg
        where  ebeln = i_bseg-ebeln
        and    ebelp = i_bseg-ebelp.
        sort i_ekpo by ebeln ebelp.
    Get the Valuation Class from MBEW Table
        clear i_mbew.
        refresh i_mbew.
        select matnr           " Material No
               bwkey           " Plant
               bklas           " Valuation Class
        into table i_mbew
        from   mbew
        for all entries in i_bseg
        where  matnr = i_bseg-matnr
        and    bwkey = i_bseg-werks.
        sort i_mbew by matnr werks.
    Get the Cost Center and Cost Element of the PO from EKKN Table
        clear i_ekkn.
        refresh i_ekkn.
        select ebeln           " Purchase Order
               ebelp           " PO Item
               kostl           " Cost Center
               sakto           " Cost Element
        into table i_ekkn
        from   ekkn
        for all entries in i_bseg
        where  ebeln = i_bseg-ebeln
        and    ebelp = i_bseg-ebelp
        and    kostl in s_kostl
        and    sakto in s_kstar.
        sort i_ekkn by ebeln ebelp.
    Get the Vendor Name
        clear i_lfa1.
        refresh i_lfa1.
        select lifnr            " Vendor
               name1            " Name
        into table i_lfa1
        from   lfa1
        for all entries in i_bseg
        where  lifnr = i_bseg-lifnr.
      endif.
      sort i_lfa1 by lifnr.
    Move the data to Final Output Internal Table
      loop at i_bsis.
        i_final-belnr = i_bsis-belnr.     " FI Document
        i_final-monat = i_bsis-monat.     " Period
        i_final-budat = i_bsis-budat.     " Rec. Date
    Read the Transaction Currency from BKPF Internal Table
        read table i_bkpf with key bukrs = i_bsis-bukrs
                                   belnr = i_bsis-belnr
                                   gjahr = i_bsis-gjahr
                                   binary search.
        if sy-subrc = 0.
          i_final-waers = i_bkpf-waers.     " Tran.Currency
    Read the Movement Type for all Material Related
    Documents from MSEG Internal Table
          if i_bkpf-awtyp = c_mkpf.
            read table i_mseg with key mblnr = i_bkpf-awkey(10)
                                       mjahr = i_bkpf-awkey+10(4).
            if sy-subrc = 0.
              i_final-bwart = i_mseg-bwart.     " Movement Type
            endif.
          endif.
        endif.
    Read Vendor, Plant, PO Document, Local And Trans.Amounts
    from BSEG Internal Table
        read table i_bseg with key bukrs = i_bsis-bukrs
                                   belnr = i_bsis-belnr
                                   gjahr = i_bsis-gjahr
                                   buzei = i_bsis-buzei
                                   binary search.
        if sy-subrc = 0.
          i_final-lifnr = i_bseg-lifnr.     " Vendor
          i_final-werks = i_bseg-werks.     " Plant
          i_final-ebeln = i_bseg-ebeln.     " PO
          i_final-dmbtr = i_bseg-dmbtr.     " Local Amount
          i_final-wrbtr = i_bseg-wrbtr.     " Tran.Amount
          i_final-menge = i_bseg-menge.     " Quantity
          i_final-meins = i_bseg-meins.     " UOM
    For Credit Indicator(SHKZG = H) amounts should be (-)ve
          if i_bseg-shkzg = c_h.
            i_final-dmbtr = i_final-dmbtr * -1.
            i_final-wrbtr = i_final-wrbtr * -1.
            i_final-menge = i_final-menge * -1.
          endif.
    Read the Material and its Description from EKPO Internal Table
          read table i_ekpo with key ebeln = i_bseg-ebeln
                                     ebelp = i_bseg-ebelp
                                     matnr = i_bseg-matnr
                                     binary search.
          if sy-subrc = 0.
            i_final-matnr = i_ekpo-matnr.     " Material Number
            i_final-txz01 = i_ekpo-txz01.     " Material Text
    Populate the Material Status depending on the Input Checkbox
    On Selection Screen
            if not i_ekpo-matnr is initial.
              i_final-status = c_x.
            endif.
          endif.
    Read the PO related Cost Element and Cost Centers
    from EKKN Internal Table
          read table i_ekkn with key ebeln = i_bseg-ebeln
                                     ebelp = i_bseg-ebelp
                                     binary search.
          if sy-subrc = 0.
            i_final-kostl = i_ekkn-kostl.     " Cost Center
            i_final-sakto = i_ekkn-sakto.     " Cost Element
          endif.
    Read the Valuation Class from MBEW Internal Table
          read table i_mbew with key matnr = i_bseg-matnr
                                     werks = i_bseg-werks
                                     binary search.
          if sy-subrc = 0.
            i_final-bklas = i_mbew-bklas.     " Val Class
          endif.
    Read the Vendor Name from LFA1 Internal Table
          read table i_lfa1 with key lifnr = i_bseg-lifnr
                                     binary search.
          if sy-subrc = 0.
            i_final-name1 = i_lfa1-name1.     " Vendor Name
          endif.
        endif.
        append i_final.
        clear i_final.
      endloop.
      sort i_final by lifnr werks monat matnr.
    Depending on the check Box Selected display the data
      if p_incmt = c_x and p_incnm ne c_x.
        delete i_final where matnr eq space.
      elseif p_incnm = c_x and p_incmt ne c_x.
        delete i_final where matnr ne space.
      endif.
    endform.           "Read Data
         Form        : populate_layout_stucture
         Description : Populating the layout structure
    form populate_layout_stucture.
      clear x_layout .
    Layout properties
      x_layout-zebra                = c_x.
      x_layout-detail_popup         = c_x.
      x_layout-detail_initial_lines = c_x.
      x_layout-colwidth_optimize    = c_x.
    endform.                    " populate_layout_stucture
         Form        : build_field_catalog
         Description : Building the field catalog data
    form build_field_catalog.
      call function 'REUSE_ALV_FIELDCATALOG_MERGE'
           exporting
                i_program_name         = g_repid
                i_internal_tabname     = 'I_FINAL'
                i_inclname             = g_repid
           changing
                ct_fieldcat            = i_fldcat
           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.
    Getting the Header text for the coloums
      loop at i_fldcat into x_fldcat where fieldname = 'LIFNR' or
                                           fieldname = 'NAME1' or
                                           fieldname = 'WERKS' or
                                           fieldname = 'MONAT' or
                                           fieldname = 'MATNR' or
                                           fieldname = 'BKLAS' or
                                           fieldname = 'EBELN' or
                                           fieldname = 'KOSTL' or
                                           fieldname = 'SAKTO' or
                                           fieldname = 'BUDAT' or
                                           fieldname = 'BELNR' or
                                           fieldname = 'BWART' or
                                           fieldname = 'TXZ01' or
                                           fieldname = 'MENGE' or
                                           fieldname = 'MEINS' or
                                           fieldname = 'DMBTR' or
                                           fieldname = 'WRBTR' or
                                           fieldname = 'WAERS' or
                                           fieldname = 'STATUS'.
        if x_fldcat-fieldname = 'LIFNR'.
          x_fldcat-seltext_l   = 'Vendor'(003).
          x_fldcat-seltext_m   = 'Vendor'(003).
          x_fldcat-seltext_s   = 'Vendor'(003).
          x_fldcat-reptext_ddic = 'Vendor'(003).
          x_fldcat-inttype   = c_c.
        endif.
        if x_fldcat-fieldname = 'NAME1'.
          x_fldcat-seltext_l   = 'Vendor Name'(002).
          x_fldcat-seltext_m   = 'Vendor Name'(002).
          x_fldcat-seltext_s   = 'Vendor Name'(002).
          x_fldcat-reptext_ddic = 'Vendor Name'(002).
          x_fldcat-inttype   = c_c.
        endif.
        if x_fldcat-fieldname = 'WERKS'.
          x_fldcat-seltext_l   = 'Plant'(010).
          x_fldcat-seltext_m   = 'Plant'(010).
          x_fldcat-seltext_s   = 'Plant'(010).
          x_fldcat-reptext_ddic   = 'Plant'(010).
          x_fldcat-ddictxt   = c_l.
        endif.
        if x_fldcat-fieldname = 'MONAT'.
          x_fldcat-seltext_l   = 'Period'(011).
          x_fldcat-seltext_m   = 'Period'(011).
          x_fldcat-seltext_s   = 'Period'(011).
          x_fldcat-reptext_ddic   = 'Period'(011).
          x_fldcat-ddictxt   = c_l.
        endif.
        if x_fldcat-fieldname = 'MATNR'.
          x_fldcat-seltext_l   = 'Material'(004).
          x_fldcat-seltext_m   = 'Material'(004).
          x_fldcat-seltext_s   = 'Material'(004).
          x_fldcat-reptext_ddic   = 'Material'(004).
          x_fldcat-ddictxt   = c_l.
        endif.
        if x_fldcat-fieldname = 'BKLAS'.
          x_fldcat-seltext_l   = 'Valuation Class'(009).
          x_fldcat-seltext_m   = 'Valuation Class'(009).
          x_fldcat-seltext_s   = 'Valuation Class'(009).
          x_fldcat-reptext_ddic   = 'Valuation Class'(009).
          x_fldcat-ddictxt   = c_l.
        endif.
        if x_fldcat-fieldname = 'EBELN'.
          x_fldcat-seltext_l   = 'Purchase Order'(005).
          x_fldcat-seltext_m   = 'Purchase Order'(005).
          x_fldcat-seltext_s   = 'Purchase Order'(005).
          x_fldcat-reptext_ddic   = 'Purchase Order'(005).
          x_fldcat-ddictxt   = c_l.
        endif.
        if x_fldcat-fieldname = 'KOSTL'.
          x_fldcat-seltext_l   = 'Cost Center'(006).
          x_fldcat-seltext_m   = 'Cost Center'(006).
          x_fldcat-seltext_s   = 'Cost Center'(006).
          x_fldcat-reptext_ddic   = 'Cost Center'(006).
          x_fldcat-ddictxt   = c_l.
        endif.
        if x_fldcat-fieldname = 'SAKTO'.
          x_fldcat-seltext_l   = 'Cost Element'(007).
          x_fldcat-seltext_m   = 'Cost Element'(007).
          x_fldcat-seltext_s   = 'Cost Element'(007).
          x_fldcat-reptext_ddic   = 'Cost Element'(007).
          x_fldcat-ddictxt   = c_l.
        endif.
        if x_fldcat-fieldname = 'BUDAT'.
          x_fldcat-seltext_l   = 'Receipt Date'(008).
          x_fldcat-seltext_m   = 'Receipt Date'(008).
          x_fldcat-seltext_s   = 'Receipt Date'(008).
          x_fldcat-reptext_ddic   = 'Receipt Date'(008).
          x_fldcat-ddictxt   = c_l.
        endif.
        if x_fldcat-fieldname = 'BELNR'.
          x_fldcat-seltext_l   = 'Acc.Document'(100).
          x_fldcat-seltext_m   = 'Acc.Document'(100).
          x_fldcat-seltext_s   = 'Acc.Document'(100).
          x_fldcat-reptext_ddic   = 'Acc.Document'(100).
          x_fldcat-ddictxt   = c_l.
        endif.
        if x_fldcat-fieldname = 'BWART'.
          x_fldcat-seltext_l   = 'Movement Type'(101).
          x_fldcat-seltext_m   = 'Movement Type'(101).
          x_fldcat-seltext_s   = 'Movement Type'(101).
          x_fldcat-reptext_ddic   = 'Movement Type'(101).
          x_fldcat-ddictxt   = c_l.
        endif.
        if x_fldcat-fieldname = 'TXZ01'.
          x_fldcat-seltext_l   = 'Material Text'(102).
          x_fldcat-seltext_m   = 'Material Text'(102).
          x_fldcat-seltext_s   = 'Material Text'(102).
          x_fldcat-reptext_ddic   = 'Material Text'(102).
          x_fldcat-ddictxt   = c_l.
        endif.
        if x_fldcat-fieldname = 'MENGE'.
          x_fldcat-seltext_l   = 'Quantity'(103).
          x_fldcat-seltext_m   = 'Quantity'(103).
          x_fldcat-seltext_s   = 'Quantity'(103).
          x_fldcat-reptext_ddic   = 'Quantity'(103).
          x_fldcat-ddictxt   = c_l.
          x_fldcat-do_sum    = c_x.
        endif.
        if x_fldcat-fieldname = 'MEINS'.
          x_fldcat-seltext_l   = 'UOM'(104).
          x_fldcat-seltext_m   = 'UOM'(104).
          x_fldcat-seltext_s   = 'UOM'(104).
          x_fldcat-reptext_ddic   = 'UOM'(104).
          x_fldcat-ddictxt   = c_l.
        endif.
        if x_fldcat-fieldname = 'DMBTR'.
          x_fldcat-seltext_l   = 'Amount in Local Curr'(105).
          x_fldcat-seltext_m   = 'Amount in Local Curr'(105).
          x_fldcat-seltext_s   = 'Amount in Local Curr'(105).
          x_fldcat-reptext_ddic   = 'Amount in Local Curr'(105).
          x_fldcat-ddictxt   = c_l.
          x_fldcat-do_sum    = c_x.
        endif.
        if x_fldcat-fieldname = 'WRBTR'.
          x_fldcat-seltext_l   = 'Amount in Trans.Curr'(106).
          x_fldcat-seltext_m   = 'Amount in Trans.Curr'(106).
          x_fldcat-seltext_s   = 'Amount in Trans.Curr'(106).
          x_fldcat-reptext_ddic   = 'Amount in Trans.Curr'(106).
          x_fldcat-ddictxt   = c_l.
          x_fldcat-do_sum    = c_x.
        endif.
        if x_fldcat-fieldname = 'WAERS'.
          x_fldcat-seltext_l   = 'Trans.Currency'(107).
          x_fldcat-seltext_m   = 'Trans.Currency'(107).
          x_fldcat-seltext_s   = 'Trans.Currency'(107).
          x_fldcat-reptext_ddic   = 'Trans.Currency'(107).
          x_fldcat-ddictxt   = c_l.
        endif.
        if x_fldcat-fieldname = 'STATUS'.
          x_fldcat-seltext_l   = 'Material Status'(019).
          x_fldcat-seltext_m   = 'Material Status'(019).
          x_fldcat-seltext_s   = 'Material Status'(019).
          x_fldcat-reptext_ddic   = 'Material Status'(019).
          x_fldcat-ddictxt   = c_l.
        endif.
        modify i_fldcat from x_fldcat index sy-tabix.
      endloop.
    endform.                    " build_field_catalog
         Form        : build_sort_totals
         Description : Building the Criteria for Sort/Subtotals
    form build_sort_totals.
      x_sort-fieldname = 'LIFNR'.
      x_sort-tabname   = 'I_FINAL'.
      x_sort-spos      =  1.
      x_sort-up        =  c_x.
      x_sort-subtot    = c_x.
      append x_sort to i_sort.
      clear  x_sort.
      x_sort-fieldname = 'WERKS'.
      x_sort-tabname   = 'I_FINAL'.
      x_sort-spos      =  2.
      x_sort-up        =  c_x.
      x_sort-subtot    = c_x.
      append x_sort to i_sort.
      clear  x_sort.
      x_sort-fieldname = 'MONAT'.
      x_sort-tabname   = 'I_FINAL'.
      x_sort-spos      =  3.
      x_sort-up        =  c_x.
      x_sort-subtot    = c_x.
      append x_sort to i_sort.
      clear  x_sort.
      x_sort-fieldname = 'MATNR'.
      x_sort-tabname   = 'I_FINAL'.
      x_sort-spos      =  4.
      x_sort-up        =  c_x.
      x_sort-subtot    = c_x.
      append x_sort to i_sort.
      clear  x_sort.
      x_sort-fieldname = 'BKLAS'.
      x_sort-tabname   = 'I_FINAL'.
      x_sort-spos      =  5.
      x_sort-up        =  c_x.
      x_sort-subtot    = c_x.
      append x_sort to i_sort.
      clear  x_sort.
      x_sort-fieldname = 'EBELN'.
      x_sort-tabname   = 'I_FINAL'.
      x_sort-spos      =  6.
      x_sort-up        =  c_x.
      x_sort-subtot    = c_x.
      append x_sort to i_sort.
      clear  x_sort.
      x_sort-fieldname = 'KOSTL'.
      x_sort-tabname   = 'I_FINAL'.
      x_sort-spos      =  7.
      x_sort-up        =  c_x.
      x_sort-subtot    = c_x.
      append x_sort to i_sort.
      clear  x_sort.
      x_sort-fieldname = 'SAKTO'.
      x_sort-tabname   = 'I_FINAL'.
      x_sort-spos      =  8.
      x_sort-up        =  c_x.
      x_sort-subtot    = c_x.
      append x_sort to i_sort.
      clear  x_sort.
      x_sort-fieldname = 'BUDAT'.
      x_sort-tabname   = 'I_FINAL'.
      x_sort-spos      =  9.
      x_sort-up        =  c_x.
      x_sort-subtot    = c_x.
      append x_sort to i_sort.
      clear  x_sort.
    endform.                    " build_sort_totals
      Form        : comment_build
      Description : This form is used to display the Report Header(ALV)
    form comment_build using lt_top_of_page type
                                            slis_t_listheader.
      data: l_line type slis_listheader,
            l_heading1 like rs38m-repti,
            l_date(10), l_time(8).
      clear l_line.
      l_heading1 = 'GR/IR DETAIL REPORT'(021).
      g_repid = sy-repid.
      write sy-uzeit to l_time.
      write sy-datum to l_date.
      l_line-typ = c_h.
      move l_heading1 to l_line-info.
      append l_line to lt_top_of_page.
      clear l_line.
      l_line-typ  = c_s.
      concatenate 'System:'(023) sy-sysid
                  'Date:'(024) l_date
                  ' Time:'(025)
                  l_time into l_line-info.
      append l_line to lt_top_of_page.
      concatenate 'Report:'(026) g_repid
                  ' User:'(027) sy-uname into
                  l_line-info.
      append l_line to lt_top_of_page.
      l_line-typ = c_a.
      move 'SELECTION CRITERIA:'(028) to l_line-info.
      append l_line to lt_top_of_page.
      concatenate ' Company Code : '(029)
                  p_bukrs into l_line-info.
      append l_line to lt_top_of_page.
      concatenate ' GR/IR Account: '(030)
                  p_grira into l_line-info.
      append l_line to lt_top_of_page.
      concatenate ' Posting Date : '(032) s_budat-low
                  ' To: '(031) s_budat-high into l_line-info.
      append l_line to lt_top_of_page.
      concatenate ' Plant : '(033) s_werks-low
                  ' To: '(031) s_werks-high into l_line-info.
      append l_line to lt_top_of_page.
      concatenate ' Vendor: '(034) s_lifnr-low
                  ' To: '(031) s_lifnr-high into l_line-info.
      append l_line to lt_top_of_page.
      concatenate ' Material: '(035) s_matnr-low
                  ' To: '(031) s_matnr-high into l_line-info.
      append l_line to lt_top_of_page.
      concatenate ' Cost Center : '(036) s_kostl-low
                  ' To: '(031) s_kostl-high into l_line-info.
      append l_line to lt_top_of_page.
      concatenate ' Cost Element: '(037) s_kstar-low
                  ' To: '(031) s_kstar-high into l_line-info.
      append l_line to lt_top_of_page.
      concatenate ' Purchase Order: '(038) s_ebeln-low
                  ' To: '(031) s_ebeln-high into l_line-info.
      append l_line to lt_top_of_page.
      concatenate ' Period : '(039) s_monat-low
                  ' To: '(031) s_monat-high into l_line-info.
      append l_line to lt_top_of_page.
      concatenate ' Include Material Items: '(040)
                  p_incmt into l_line-info.
      append l_line to lt_top_of_page.
      concatenate ' Include Non-Material Items: '(041)
                  p_incnm into l_line-info.
      append l_line to lt_top_of_page.
    endform.
         Form        : call_list_viewer
         Description : This form is used to display the grid through ALV
    form call_list_viewer.
      call function 'REUSE_ALV_GRID_DISPLAY'
           exporting
                i_callback_program      = g_repid
                is_layout               = x_layout
                it_fieldcat             = i_fldcat[]
                i_default               = c_x
                it_sort                 = i_sort[]
                i_save                  = g_save
                is_variant              = g_variant
                it_events               = g_events[]
           importing
                e_exit_caused_by_caller = g_exit_caused_by_caller
                es_exit_caused_by_user  = g_exit_caused_by_user
           tables
                t_outtab                = i_final
           exceptions
                program_error           = 1
                others                  = 2.
      if sy-subrc <> 0.
        write: / 'Problem in calling the ALV report'(042).
      endif.
    endform.                    " call_list_viewer
    <b>Reward points for useful Answers</b>
    Regards
    Anji

  • ALV Report Output Checkbox

    Hi,
    I'm developing an ALV Report. The output of the report contains a checkbox for each row. There are 2 buttons in the Application bar namely 'Select-ALL' and 'DeSelect-ALL'. The requirement is when I click either of the button it should select or deselect all the checkbox. The problem is when i click either the button first time its not working but when i click for second time its working. Basically It needs 2 clicks for the operation. Can anybody suggest a solution how to make work of the program at the first clck itself.
    Thanks,
    Kaarthick

    Since your program is working in debugging mode, It might be some problem pertaining to some time delay or lag, or a refresh problem.
    So save your code once again activate it and shut down your saplogon and after couple of minutes log in again.
    I faced a similar problem, it was working in debugging and not when executed directly, it was some lag problem only.

  • Drop Down List in ALV with Event handler

    Hi All ,
    I have created an ALV grid with a dropdown as one of the columns. This all works fine, except that I want to be able to react to a change in the value of each line's dropdown the next column values should change according to the user selection in the 1st column .
    Is this possible?
    As an example, I have a table of records with one column as a dropdown called " Replace Function Module "   and in 2nd column i have call function of that Replace Function Module , If a  change in " Replace Function Module " should change the call function of in the 2nd column .
    I am using these objects lvc_t_drop , lvc_s_drop and  the method  " set_drop_down_table ",
    Please Can any 1 tel me how to do this with any event handler ar any other way !

    Hi,
    You need to use event handler for this. Check if the below link gives some direction.
    [http://www.sdn.sap.com/irj/sdn/go/portal/prtroot/docs/library/uuid/cda3992d-0e01-0010-90b2-c4e1f899ac01|http://www.sdn.sap.com/irj/sdn/go/portal/prtroot/docs/library/uuid/cda3992d-0e01-0010-90b2-c4e1f899ac01]
    I guess you should create a method inside which you call the FM using the FM name from the selected cell in ALV.
    I have not tried it out, but its worth a try.
    Hope this helps!
    Regards,
    Saumya

  • ALV grid with checkbox

    Hello,
      I am facing a problem in getting the refreshed value of the checkbox field in the internal table.
    I will explain you what is the program does ,  first i am displaying the set of values with the internal table with the checkbox clicked.
    Then user will uncheck some of the rows and then he presses a button to do the respective action .
    When i press the button , in the usercommand form , i am trying to capture the checked rows . Here it is not displaying with the modified internal table , but it displays the internal table with all the checkbox field value as blank.
    I have used the GLOBAL_SVC FM and check_changed_data , refresh_table  before the usercommand action . Still it is not displaying . When i click the checkbox and then highlight the whole row , then click the button it is displaying the updated internal table.
    My doubt is always we have to click the checkbox and hightlight the whole row or is there any way to get the updated value of the internal table when the checkbox is just clicked.?
    Thanks,
    kevin

    Why don't you set a handler for event DATA_CHANGED  and change data everytime you (de)select checkbox in the frontend. It's much more convenient as you keep control on any actions that user perform.
    @christian
    From help.sap.com
    There is no guarantee that an automation queue will be sent when you call CL_GUI_CFW=>FLUSH. The queue recognizes whether it contains any return values. If this is not the case, it is not sent.
    More on this [here|http://help.sap.com/saphelp_nw2004s/helpdata/en/e0/9424f2f16e11d2bdd8080009b4534c/frameset.htm]
    So if he wants to ensure that synchronization takes place, he should rather use [CL_GUI_CFW=>UPDATE_VIEW|http://help.sap.com/saphelp_nw2004s/helpdata/en/e0/9424f7f16e11d2bdd8080009b4534c/frameset.htm]
    Regards
    Marcin

  • ALV Tree event registration doesn't work

    Hello Experts,
    the following is the registration-form which shall register a item-double-click event to my alv-tree-object. when doing the double-click it doesn't open my own methods in the event-handler class but the standard ones and nothing happens further.
    Any ideas?
    Many thanks in advance!
    Tobias
    FORM register_events.
      DATA: lt_events TYPE cntl_simple_events,
            l_event TYPE cntl_simple_event.
      CALL METHOD g_alv_tree->get_registered_events
        IMPORTING
          events = lt_events.
      l_event-eventid = cl_gui_column_tree=>eventid_item_double_click.
      APPEND l_event TO lt_events.
      CALL METHOD g_alv_tree->set_registered_events
        EXPORTING
          events                    = lt_events
        EXCEPTIONS
          cntl_error                = 1
          cntl_system_error         = 2
          illegal_event_combination = 3.
      IF sy-subrc <> 0.
        MESSAGE x208(00) WITH 'ERROR'.                          "#EC NOTEXT
      ENDIF.
      CREATE OBJECT event_handler.
      SET HANDLER event_handler->handle_item_double_click FOR g_alv_tree.
    ENDFORM.

    It doesn't matter where I place my double-click. The standard event handling "handle_event" is called.
    Instead of this I would like to have my coding.....
    Changing the cl_gui_alv_tree to cl_gui_column_tree doesn't work since my tree isn't a reference of column_tree but of alv_tree. So I would have to rebuild nearly the entire tree. This cannot be a solution since I guess the double-click item should work anyway.
    What I am wondering furthermore is my button declaration not being displayed. The following is my fieldcatalog declaration:
    FORM create_tree_fc.
      DATA: ls_fc TYPE lvc_s_fcat.
      DATA: lo_descrref   TYPE REF TO cl_abap_typedescr.
      DATA: lo_tableref TYPE REF TO cl_abap_tabledescr.
      DATA: lo_structref TYPE REF TO cl_abap_structdescr.
      FIELD-SYMBOLS: <fs_str> TYPE abap_compdescr.
      lo_tableref ?= cl_abap_tabledescr=>describe_by_data( lt_report_tree ).
      lo_descrref ?= lo_tableref->get_table_line_type( ).
      lo_structref ?= lo_descrref.
      CLEAR gt_fc[].
      LOOP AT lo_structref->components ASSIGNING <fs_str>.
        CLEAR ls_fc.
        ls_fc-fieldname = <fs_str>-name.
        ls_fc-intlen = <fs_str>-length.
        ls_fc-inttype = <fs_str>-type_kind.
        ls_fc-decimals = <fs_str>-decimals.
        CASE <fs_str>-name.
          WHEN 'PROCESS_TYPE'.
            ls_fc-tooltip = 'Process Type'.
            ls_fc-coltext = 'Process Type'.
            ls_fc-emphasize = 'C110'.
            ls_fc-no_sum = 'X'.
            ls_fc-style = cl_gui_column_tree=>item_class_button.
            ls_fc-outputlen = 20.
          WHEN 'SMI_PROJECT'.
            ls_fc-tooltip = 'Project Relation'.
            ls_fc-coltext = 'Project'.
            ls_fc-hotspot = 'X'.
            ls_fc-no_sum = 'X'.
            ls_fc-style = CL_GUI_ALV_GRID=>MC_STYLE_DISABLED.
            ls_fc-outputlen = <fs_str>-length.
          WHEN 'TRORDER_NUMBER'.
            ls_fc-tooltip = 'ID of Transport Request'.
            ls_fc-coltext = 'Transport Request'.
            ls_fc-no_sum = 'X'.
            ls_fc-style = CL_GUI_ALV_GRID=>MC_STYLE_HOTSPOT.
            ls_fc-outputlen = 30.
        ENDCASE.
        APPEND ls_fc TO gt_fc.
      ENDLOOP.
    ENDFORM.
    Edited by: Tobias Fickinger on Jun 10, 2009 9:59 AM
    Edited by: Tobias Fickinger on Jun 10, 2009 10:00 AM
    Edited by: Tobias Fickinger on Jun 10, 2009 10:03 AM

  • Capturing the ALV Grid Event

    Hi Experts,
    I am working on ALV Grid , Data is Displayed in Grid well , But Can Any one please tell me how can i capture the event (back,exit and cancel) which is persent on standard toolbar on ALV Gried output .
    Rgds,
    Premraj

    Hello PremRaj ,
    Please find an dummy program to capture the events below:
    TYPE-POOLS slis.
    DATA: ITAB_EVENTS TYPE slis_t_event,
          WA_EVENTS TYPE SLIS_ALV_EVENT.
    DATA: IT_END TYPE SLIS_T_LISTHEADER,
          WA_END TYPE SLIS_LISTHEADER.
    ** This function module will get all the events present in alv into internal table itab_events*
    CALL FUNCTION 'REUSE_ALV_EVENTS_GET'
    EXPORTING
      I_LIST_TYPE           = 0
    IMPORTING
       ET_EVENTS             = ITAB_EVENTS
    EXCEPTIONS
      LIST_TYPE_WRONG       = 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.
    ** With this read table statement itab_events is read for the desired event*+
    READ TABLE itAB_eventS INTO wa_eventS WITH KEY name = 'END_OF_LIST'.
      wa_eventS-form = 'END'.
      MODIFY itAB_eventS FROM wa_eventS INDEX sy-tabix.
      CLEAR wa_eventS.
    *Pass the ITAB_EVENTS created in this Function Module
    CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
    EXPORTING
        IT_EVENTS                         = ITAB_EVENTS
    IMPORTING
       E_EXIT_CAUSED_BY_CALLER           =
       ES_EXIT_CAUSED_BY_USER            =
       TABLES
         t_outtab                          = it_tab
    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.
    *READ TABLE itAB_eventS INTO wa_eventS WITH KEY name = 'END_OF_LIST'.
    wa_eventS-form = 'END'.
    MODIFY itAB_eventS FROM wa_eventS INDEX sy-tabix.
    CLEAR wa_eventS.
    *in these statements ,the second line will automatically try to call subroutine with name end.
    FORM END.
    WA_END-TYP = 'S'.
    WA_END-KEY = TEXT-004.
    WA_END-INFO = SY-DATUM.
    APPEND WA_end TO IT_END.
    CLEAR WA_END.
    CALL FUNCTION 'REUSE_ALV_COMMENTARY_WRITE'
      EXPORTING
        it_list_commentary       = IT_END
      I_LOGO                   =
      I_END_OF_LIST_GRID       =
      I_ALV_FORM               =
    ENDFORM.
    Hope it helps you.
    Thanks Mansi
    Code Formatted by: Alvaro Tejada Galindo on Jan 8, 2009 11:02 AM
    Edited by: MANSI  ASNANI on Jan 9, 2009 7:31 AM

  • ALV List with checkboxes

    Hello experts,
    I'm working on an object where in I need to display an ALV List (using Funct Modules) with checkboxes.
    When I select the checkboxes,and click on a button (Eg.Refresh Button) , I need to get all the details of the selected rows (checked rows) in a seperate ALV List (in a Dailog).
    Could any one of u please suggest me about selecting the row which has been checked(Checkboxes in ALV ).
    Thanks in advance.
    Sanghamitra

    Hi sangha,
    1. To get a taste of it,
       just copy paste this program.
    2. It will display alv (t001)
       It will show CHECKBOXES (besides every row)
       TICK some rows,
      and DOUBLE-CLICK ON any row.
    3.  It will display all the row numbers which have been checked/ticked.
    4.
    report abc.
    TYPE-POOLS : slis.
    Data
    DATA : BEGIN OF itab OCCURS 0.
            INCLUDE STRUCTURE t001.
    DATA : flag tyPE c,
           END OF itab.
    DATA : alvfc TYPE slis_t_fieldcat_alv.
    DATA : alvly TYPE slis_layout_alv.
    Select Data
    SELECT * FROM t001 INTO TABLE itab.
    *------- Field Catalogue
    CALL FUNCTION 'REUSE_ALV_FIELDCATALOG_MERGE'
      EXPORTING
        i_program_name         = sy-repid
        i_internal_tabname     = 'ITAB'
        i_inclname             = sy-repid
      CHANGING
        ct_fieldcat            = alvfc
      EXCEPTIONS
        inconsistent_interface = 1
        program_error          = 2
        OTHERS                 = 3.
    Display
    alvly-box_fieldname = 'FLAG'.
    CALL FUNCTION 'REUSE_ALV_LIST_DISPLAY'
      EXPORTING
        it_fieldcat             = alvfc
        i_callback_program      = sy-repid "<-------Important
        i_callback_user_command = 'ITAB_USER_COMMAND' "<------ Important
        is_layout               = alvly
      TABLES
        t_outtab                = itab
      EXCEPTIONS
        program_error           = 1
        OTHERS                  = 2.
    CALL BACK FORM
    FORM itab_user_command USING whatcomm TYPE sy-ucomm whatrow TYPE
    slis_selfield.
      data : msg(100) type c.
      LOOP AT itab.
        if itab-flag = 'X'.
          msg = sy-tabix.
          condense msg.
          concatenate 'Row Number ' msg ' ' into msg
          separated by space.
          message msg type 'I'.
        endif.
      ENDLOOP.
    ENDFORM. "ITAB_user_command
    regards,
    amit m.

  • ALV Grid: event for user return in ALV Grid Control

    Hi developers,
    i'm wanna do something after a user has pressed the return button in a alv grid control. For that i need probably a event. But i can not find a proper event in the documentation. Could one of you guys help me?
    Best regards christian

    Hi Christian
    ALV grid is an encapsulated object, so it seems there is no way, you ought to implement the data_changed event. So if you want to make bulk data input and after trigger the event by pressing the return key, you should make the ALV Grid get your changes after pressing the key but not after a cell change of a modified cell.
    To set this attribute:
    CALL METHOD gr_alvgrid->register_edit_event
         EXPORTING i_event_id = cl_gui_alv_grid=>mc_evt_enter .
    This way "data_changed" event will be triggered whenever you press the return key while editing.
    For some more information you can also refer to the tutorial <a href="https://www.sdn.sap.comhttp://www.sdn.sap.comhttp://www.sdn.sap.com/irj/servlet/prt/portal/prtroot/com.sap.km.cm.docs/documents/a1-8-4/an%20easy%20reference%20for%20alv%20grid%20control.pdf">"An Easy Reference for ALV Grid Control"</a>.
    Regards
    *--Serdar <a href="https://www.sdn.sap.com:443http://www.sdn.sap.comhttp://www.sdn.sap.com/irj/servlet/prt/portal/prtroot/com.sap.sdn.businesscard.sdnbusinesscard?u=qbk%2bsag%2bjiw%3d">[ BC ]</a>

Maybe you are looking for

  • Getting an Intel iMac up and running from G5 software and data

    Towards the end of this year I will be updating from a G5 iSight to whatever mid-model new iMac is available. I will be doing this solely because I want to work extensively with HD video. I have spent an hour or so checking these forums for potential

  • SNMPv3 on Cisco 2960-S Switch to NCS

    Can anyone point me to some good instructions on how to set up SNMPv3 on a Cisco Catalyst 2960-S switch in order to manage it with Cisco Prime NCS?

  • Strange  java.text.ParseException  using  Calender

    Hi here i am using code in jsp which get Calender date parameter and using SimpleDateFormat it parse date as According to sql server date format. it works file . 1) but when i try to to add same row again (which are already preselect date) it call "U

  • Illustrator will not start...

    Very annoyed... such bad timing! I just restarted illustrator as it was getting sketchy, (as it does) only to find it will not restart... Error loading plugins, as you can see they are all stock plugins as I have no extras turned on. Have done a Mach

  • VBAK,VBRP,VBRK for all entries on I_VRPMA:Please help

    Hi, I need to join 3 tables VBRK,VBAK,VBRP Tables.Actually to improve the performance first i retrieved matnr and belnr(billing records) from VRPMA Table into I_VRPMA where s_vkorg,s_fkdat,s_fkart.(selection screen) Now i need to fetch billing record