ALV report using OOPS concept.

Hi,
Please help me in writing ALV report using OOPS concept as i have never used this concept before.Please post a clear picture for this.
Thanks in advance.

Hi
Refer this code:
REPORT zcls_alv_oops MESSAGE-ID z1.
TABLES : mara.
Types Declaration..\
TYPES :
BEGIN OF t_mara,
matnr TYPE matnr,
mtart TYPE mtart,
maktx TYPE maktx,
END OF t_mara,
BEGIN OF t_marc,
matnr TYPE matnr,
werks TYPE werks_d,
mtart TYPE mtart,
maktx TYPE maktx,
END OF t_marc.
Internal Tables Declaration..\
DATA :
i_mara TYPE TABLE OF t_mara,
i_marc TYPE TABLE OF t_marc,
i_fcat1 TYPE lvc_t_fcat,
i_fcat2 TYPE lvc_t_fcat.
Constants Declaration..\
CONSTANTS :
c_cont1 TYPE scrfname VALUE 'CONT1',
c_cont2 TYPE scrfname VALUE 'CONT2'.
SELECTION-SCREEN BEGIN OF BLOCK b1 WITH FRAME.
SELECT-OPTIONS:
s_matnr FOR mara-matnr NO INTERVALS.
SELECTION-SCREEN SKIP 1.
PARAMETERS :
p_hotspt RADIOBUTTON GROUP r1 DEFAULT 'X',
p_bttn RADIOBUTTON GROUP r1.
SELECTION-SCREEN END OF BLOCK b1.
\* Class forward referncing.
CLASS lcl_rcvr_class DEFINITION DEFERRED.
\* Pointers Declaration..
DATA :
lp_rcvr TYPE REF TO lcl_rcvr_class,
lp_cont1 TYPE REF TO cl_gui_custom_container,
lp_cont2 TYPE REF TO cl_gui_custom_container,
lp_grid1 TYPE REF TO cl_gui_alv_grid,
lp_grid2 TYPE REF TO cl_gui_alv_grid.
\* Local Class Definiton.
CLASS lcl_rcvr_class DEFINITION.
PUBLIC SECTION.
METHODS :
hotspot_click FOR EVENT hotspot_click OF cl_gui_alv_grid
IMPORTING e_row_id e_column_id es_row_no,
handle_double_click FOR EVENT double_click OF cl_gui_alv_grid
IMPORTING e_row e_column.
ENDCLASS.
\* Local Class Implementation.
CLASS lcl_rcvr_class IMPLEMENTATION.
METHOD hotspot_click.
DATA :
wa_mara TYPE t_mara,
wa_marc TYPE t_marc.
DATA :
l_index TYPE sy-tabix.
READ TABLE i_mara INTO wa_mara INDEX e_row_id-index.
IF sy-subrc EQ 0.
REFRESH i_marc.
SELECT matnr
werks
INTO TABLE i_marc
FROM marc
WHERE matnr EQ wa_mara-matnr.
IF sy-subrc EQ 0.
LOOP AT i_marc INTO wa_marc.
l_index = sy-tabix.
wa_marc-mtart = wa_mara-mtart.
wa_marc-maktx = wa_mara-maktx.
MODIFY i_marc FROM wa_marc INDEX l_index
TRANSPORTING mtart maktx.
ENDLOOP.
CALL SCREEN 200.
ELSE.
MESSAGE e121 WITH text-005 wa_mara-matnr.
ENDIF.
ENDIF.
ENDMETHOD.
METHOD handle_double_click.
DATA :
wa_mara TYPE t_mara,
wa_marc TYPE t_marc.
DATA :
l_index TYPE sy-tabix.
READ TABLE i_mara INTO wa_mara INDEX e_row-index.
IF sy-subrc EQ 0.
REFRESH i_marc.
SELECT matnr
werks
INTO TABLE i_marc
FROM marc
WHERE matnr EQ wa_mara-matnr.
IF sy-subrc EQ 0.
LOOP AT i_marc INTO wa_marc.
l_index = sy-tabix.
wa_marc-mtart = wa_mara-mtart.
wa_marc-maktx = wa_mara-maktx.
MODIFY i_marc FROM wa_marc INDEX l_index
TRANSPORTING mtart maktx.
ENDLOOP.
CALL SCREEN 200.
ELSE.
MESSAGE e121 WITH text-005 wa_mara-matnr.
ENDIF.
ENDIF.
ENDMETHOD.
ENDCLASS.
\* Start of Selection
START-OF-SELECTION.
\* Extract the Material Master data for the Input Material.
SELECT a~matnr
a~mtart
b~maktx
INTO TABLE i_mara
FROM mara AS a
INNER JOIN makt AS b
ON a~matnr EQ b~matnr
WHERE a~matnr IN s_matnr
AND b~spras EQ sy-langu.
END-OF-SELECTION.
IF NOT i_mara\[\] IS INITIAL.
\* Call Screen to display the Material Master data.
CALL SCREEN 100.
ELSE.
MESSAGE s121 WITH text-006.
ENDIF.
\*& Module DISP_GRID OUTPUT
\* text
MODULE disp_grid OUTPUT.
\* Build the Field catelog for Material Master data.
PERFORM build_fcat.
\* Display the Material Master data using ALV.
PERFORM disp_alv.
ENDMODULE. " DISP_GRID OUTPUT
\*& Module USER_COMMAND_0100 INPUT
\* text
MODULE user_command_0100 INPUT.
\*when exit or cancel is clicked program has to come out
CASE sy-ucomm.
WHEN 'EXIT' OR 'CANC'.
LEAVE PROGRAM.
WHEN 'BACK'.
LEAVE TO SCREEN 0.
ENDCASE.
ENDMODULE. " USER_COMMAND_0100 INPUT
\*& Form build_fcat
\* text
\* \--> p1 text
\* <-\- p2 text
FORM build_fcat.
DATA : ws_fcat TYPE lvc_s_fcat.
ws_fcat-fieldname = 'MATNR'.
ws_fcat-scrtext_m = text-001.
ws_fcat-tabname = 'I_MARA'.
IF p_hotspt EQ 'X'.
ws_fcat-hotspot = 'X'.
ENDIF.
APPEND ws_fcat TO i_fcat1.
CLEAR ws_fcat.
ws_fcat-fieldname = 'MTART'.
ws_fcat-scrtext_m = text-002.
ws_fcat-tabname = 'I_MARA'.
APPEND ws_fcat TO i_fcat1.
CLEAR ws_fcat.
ws_fcat-fieldname = 'MAKTX'.
ws_fcat-scrtext_m = text-003.
ws_fcat-tabname = 'I_MARA'.
APPEND ws_fcat TO i_fcat1.
CLEAR ws_fcat.
ENDFORM. " build_fcat
\*& Form disp_alv
\* text
\* \--> p1 text
\* <-\- p2 text
FORM disp_alv.
IF lp_cont1 IS INITIAL.
\* Create the Container Object of Material Master.
CREATE OBJECT lp_cont1
EXPORTING
container_name = c_cont1
EXCEPTIONS
cntl_error = 1
cntl_system_error = 2
create_error = 3
lifetime_error = 4
lifetime_dynpro_dynpro_link = 5
others = 6 .
IF sy-subrc NE 0.
MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ELSE.
\* Create the Object for Grid of Material Master.
CREATE OBJECT lp_grid1
EXPORTING
i_parent = lp_cont1
EXCEPTIONS
error_cntl_create = 1
error_cntl_init = 2
error_cntl_link = 3
error_dp_create = 4
others = 5.
IF sy-subrc NE 0.
MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ELSE.
\* Dipslay Material Master data by calling method.
CALL METHOD lp_grid1->set_table_for_first_display
CHANGING
it_outtab = i_mara
it_fieldcatalog = i_fcat1
EXCEPTIONS
invalid_parameter_combination = 1
program_error = 2
too_many_lines = 3
OTHERS = 4.
IF sy-subrc NE 0.
MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ELSE.
\* Set Handler for the Hot Spot Event.
CREATE OBJECT lp_rcvr.
IF p_hotspt EQ 'X'.
SET HANDLER lp_rcvr->hotspot_click FOR lp_grid1.
ELSE.
SET HANDLER lp_rcvr->handle_double_click FOR lp_grid1.
ENDIF.
ENDIF.
ENDIF.
ENDIF.
ENDIF.
ENDFORM. " disp_alv
\*& Module STATUS_0100 OUTPUT
\* text
MODULE status_0100 OUTPUT.
SET PF-STATUS 'MAIN_STAT'.
SET TITLEBAR 'T_100'.
ENDMODULE. " STATUS_0100 OUTPUT
\*& Module STATUS_0200 OUTPUT
\* text
MODULE status_0200 OUTPUT.
SET PF-STATUS 'PLANT_STAT'.
SET TITLEBAR 'T_200'.
ENDMODULE. " STATUS_0200 OUTPUT
\*& Module DISP_GRID_plant OUTPUT
\* text
MODULE disp_grid_plant OUTPUT.
\* Build the Field catelog for Material Plant data.
PERFORM build_fcat_plant.
\* Display the Material Master Plant data using ALV.
PERFORM disp_alv_plant.
ENDMODULE. " DISP_GRID_plant OUTPUT
\*& Module USER_COMMAND_0200 INPUT
\* text
MODULE user_command_0200 INPUT.
\*when exit or cancel is clicked program has to come out
CASE sy-ucomm.
WHEN 'EXIT' OR 'CANC'.
LEAVE PROGRAM.
WHEN 'BACK'.
LEAVE TO SCREEN 0.
ENDCASE.
ENDMODULE. " USER_COMMAND_0200 INPUT
\*& Form build_fcat_plant
\* text
\* \--> p1 text
\* <-\- p2 text
FORM build_fcat_plant.
DATA : ws_fcat TYPE lvc_s_fcat.
ws_fcat-fieldname = 'MATNR'.
ws_fcat-scrtext_m = text-001.
ws_fcat-tabname = 'I_MARC'.
APPEND ws_fcat TO i_fcat2.
CLEAR ws_fcat.
ws_fcat-fieldname = 'WERKS'.
ws_fcat-scrtext_m = text-004.
ws_fcat-tabname = 'I_MARC'.
APPEND ws_fcat TO i_fcat2.
CLEAR ws_fcat.
ws_fcat-fieldname = 'MTART'.
ws_fcat-scrtext_m = text-002.
ws_fcat-tabname = 'I_MARC'.
APPEND ws_fcat TO i_fcat2.
CLEAR ws_fcat.
ws_fcat-fieldname = 'MAKTX'.
ws_fcat-scrtext_m = text-003.
ws_fcat-tabname = 'I_MARC'.
APPEND ws_fcat TO i_fcat2.
CLEAR ws_fcat.
ENDFORM. " build_fcat_plant
\*& Form disp_alv_plant
\* text
\* \--> p1 text
\* <-\- p2 text
FORM disp_alv_plant.
IF lp_cont2 IS INITIAL.
\* Create the Container Object of Material Plant data.
CREATE OBJECT lp_cont2
EXPORTING
container_name = c_cont2
EXCEPTIONS
cntl_error = 1
cntl_system_error = 2
create_error = 3
lifetime_error = 4
lifetime_dynpro_dynpro_link = 5
others = 6.
IF sy-subrc NE 0.
MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ELSE.
\* Create the Object for Grid of Material Plant data.
CREATE OBJECT lp_grid2
EXPORTING
i_parent = lp_cont2
EXCEPTIONS
error_cntl_create = 1
error_cntl_init = 2
error_cntl_link = 3
error_dp_create = 4
others = 5.
IF sy-subrc NE 0.
MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ELSE.
\* Dipslay Material Plant data by calling method.
CALL METHOD lp_grid2->set_table_for_first_display
CHANGING
it_outtab = i_marc
it_fieldcatalog = i_fcat2
EXCEPTIONS
invalid_parameter_combination = 1
program_error = 2
too_many_lines = 3
OTHERS = 4.
IF sy-subrc NE 0.
MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ENDIF.
ENDIF.
ENDIF.
ELSE.
\* Call method 'REFRESH_TABLE_DISPLAY' to refresh the grid data.
CALL METHOD lp_grid2->refresh_table_display.
ENDIF.
ENDFORM. " disp_alv_plant
Thanks
Vasudha

Similar Messages

  • Creating ALV reports using OOP concept

    After creating many reports i found out that 90% of the coding in a report is copy paste i.e. only 10% of coding effort is required which includes
        creating the custom data types and internal table variables  ...
        populating the data
        creating screen,GUI status and GUI title
    Just copy paste the below code and do as stated  :
    *ALV TEMPLATE
    *create screen no. 2000
    *change flow logic in screen if necessary
    *create GUI status and GUI title
    *change selection texts and text symbols*
    REPORT  Y_TEMPLATE_ALV.
    TABLES : ."use if range of values required on selection screen.
    DATA: zcl_alvgrid        TYPE REF TO cl_gui_alv_grid,
           zcl_ccontainer     TYPE REF TO cl_gui_docking_container,
           wa_layout    TYPE lvc_s_layo,
           it_fieldcat  TYPE STANDARD TABLE OF lvc_s_fcat,
           wa_fieldcat  TYPE lvc_s_fcat,
           z_document         TYPE REF TO cl_dd_document,
           o_docking TYPE REF TO cl_gui_docking_container,"Docking Container
           o_split TYPE REF TO cl_gui_easy_splitter_container, "Splitter
           o_top_container TYPE REF TO cl_gui_container,   "Top Container
           o_bottom_container TYPE REF TO cl_gui_container."Bottom Container
    TYPES : BEGIN OF TY_FINAL,
    "All columns which are to be displayed in the report should be included here
    END OF TY_FINAL.
    *Add additional Internal Tables's if data is to be extracted from multiple tables
    *Then loop at main table and Read the other tables
    DATA :IT_DATA TYPE STANDARD TABLE OF , "data extracted from tables can be stored in this internal table variable ..
           WA_DATA TYPE ,
           iT_alv      TYPE STANDARD TABLE OF TY_FINAL, " pass to  the method SET_TABLE_FOR_FIRST_DISPLAY of class
    ZCL_ALVGRID [Already done ; its  just fyi]
           WA_alv      TYPE                   TY_FINAL.
    DATA :V_CLN(255) TYPE C, " For no. of records
           V_LINE TYPE I. " for conversion of integer to character
    *                 Selection Screen                                     *
    SELECTION-SCREEN BEGIN OF BLOCK B1 WITH FRAME TITLE TEXT-001.
    PARAMETERS:
    SELECT-OPTIONS: " PARAMETERS and Range on selection screen
    SELECTION-SCREEN END OF BLOCK B1.
    AT SELECTION-SCREEN OUTPUT.
    *                        START  OF  SELECTION                          *
    START-OF-SELECTION.
    *  SELECT * FROM INTO CORRESPONDING FIELDS OF TABLE IT_DATA WHERE ....in ....
       IF SY-SUBRC = 0.
         LOOP AT IT_DATA INTO WA_DATA.
           MOVE-CORRESPONDING WA_DATA TO wa_alv. " if data is fetched from only one table
           APPEND wa_alv TO it_alv.
           CLEAR : wa_alv,WA_DATA.
         ENDLOOP.
         DESCRIBE TABLE it_alv LINES V_LINE.
         V_CLN = V_LINE.
       ENDIF.
    END-OF-SELECTION.
       PERFORM DISPLAY_ALV.
    *&      Module  STATUS  OUTPUT
    *       text
    MODULE STATUS_2000 OUTPUT.
       SET PF-STATUS 'STATUS'.
       SET TITLEBAR 'ALV'.
    *  ** Creating Docking Container
       CREATE OBJECT o_docking
       EXPORTING
    *    side = cl_gui_docking_container=>dock_at_right
         ratio = '95'.
       IF sy-subrc EQ 0.
    * Splitting the Docking container
         CREATE OBJECT o_split
         EXPORTING
           parent        = o_docking
           sash_position = 05 "Position of Splitter Bar (in Percent)
           with_border   = 0. "With Border = 1 Without Border = 0
    *   Placing the containers in the splitter
         o_top_container = o_split->top_left_container .
         o_bottom_container = o_split->bottom_right_container .
    *   Creating the document
         CREATE OBJECT z_document
         EXPORTING
           style = 'ALV_GRID'.
       ENDIF.
    * Calling the methods for dynamic text
       CALL METHOD z_document->add_text
       EXPORTING
         TEXT         = 'No. of Records:'
         sap_emphasis = cl_dd_area=>strong. " For bold
    * Adding GAP
       CALL METHOD z_document->add_gap
       EXPORTING
         width = 10.
    * Adding Text
       CALL METHOD z_document->add_text
       EXPORTING
         TEXT = v_cln.
    * Adding Line
       CALL METHOD z_document->new_line.
    * Display the data
       CALL METHOD z_document->display_document
       EXPORTING
         parent = o_top_container.
       IF zcl_alvgrid IS INITIAL .
    *----Creating ALV Grid instance
         CREATE OBJECT zcl_alvgrid
         EXPORTING
           i_parent          = o_bottom_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.
    * Calling the method of ALV to process top of page
         CALL METHOD zcl_alvgrid->list_processing_events
         EXPORTING
           i_event_name = 'TOP_OF_PAGE'
           i_dyndoc_id  = z_document.
    * Preparing field catalog.
         PERFORM T_FIELDCAT USING:
                    '1'        'BRNCD'      'BRAND'.
    *          'Column no' 'FIELDNAME' 'Column Heading' 
         WA_LAYOUT-CWIDTH_OPT = 'X'.
         WA_LAYOUT-ZEBRA = 'X'.
         WA_LAYOUT-SEL_MODE =  'A'.
    * Setting table for first display
         CALL METHOD ZCL_ALVGRID->SET_TABLE_FOR_FIRST_DISPLAY
         EXPORTING
           IS_LAYOUT                     = WA_LAYOUT
         CHANGING
           IT_OUTTAB                     = it_alv
           IT_FIELDCATALOG               = IT_FIELDCAT
         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.
       ELSE.
         CALL METHOD ZCL_ALVGRID->REFRESH_TABLE_DISPLAY
         EXCEPTIONS
           FINISHED = 1
           OTHERS   = 2.
         IF SY-SUBRC <> 0.
           MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
           WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
         ENDIF.
       ENDIF.
    ENDMODULE.                 " STATUS  OUTPUT
    MODULE USER_COMMAND_2000 INPUT.
       DATA: V_OK_CODE TYPE SY-UCOMM,
             V_SAVE_OK TYPE SY-UCOMM.
       V_OK_CODE = SY-UCOMM.
       V_SAVE_OK = V_OK_CODE.
       CASE SY-UCOMM.
         WHEN 'BACK'.
           SET SCREEN 1000.
         WHEN 'EXIT'.
           LEAVE program.
         WHEN OTHERS.
           SET SCREEN 1000.
       ENDCASE.
       CLEAR V_SAVE_OK.
       SET SCREEN 0.
       LEAVE SCREEN.
    ENDMODULE.                 " USER_COMMAND_2000  INPUT
    *&      Form  T_FIELDCAT
    *       text
    *      -->x   text
    *      -->y   text
    *      -->z   text
    FORM T_FIELDCAT  USING VALUE(X) TYPE ANY
           VALUE(Y) TYPE ANY
           VALUE(Z) TYPE ANY.
       WA_FIELDCAT-COL_POS = X.
       WA_FIELDCAT-FIELDNAME = Y.
       WA_FIELDCAT-COLTEXT  = Z.
       APPEND WA_FIELDCAT TO IT_FIELDCAT.
       CLEAR WA_FIELDCAT.
    ENDFORM.                      " T_FIELDCAT
    *&      Form  DISPLAY_ALV
    *       text
    *  -->  p1        text
    *  <--  p2        text
    FORM DISPLAY_ALV .
       IF NOT it_alv[] IS INITIAL.
         CALL SCREEN 2000.
       ELSE.
         MESSAGE 'No data for Display' TYPE 'I'.
       ENDIF.
    ENDFORM.                    " DISPLAY_ALV

    Hello Jay,
    Calling methods, creating instances, casting etc are not OOP. When you say you've developed an OO-report you think OO, refer to this blog to see what i mean - Global Data in ABAP OO Programs
    BR,
    Suhas

  • Sub total in ALV GRID using oops concept

    Hi,
    If Plant (VBAP-WERKS) is not the same for all items on a Sales Order (VBAK-VBELN is the same for al items) then create a separate line on the report for each different plant specified in the line items.  Copy all fields from the original order line except for plant and Net Value.  Net Value should be the total of item Net Values for all items with the same plant in the order.
    Example:
    Data:
    Order----                     Item-             Plant-                                     Net Value---
    123----          010-               3467-                      100.00---
    123----          020-               7865-                      50.00---
    123----          030-               3467-                     80.50---
    Report:
    Order-                     Plant-                  Net Value---
    123-          3467-                  180.50---
    123-          7865-                   50.00----
    I need to dispaly the Report format in ALV Grid using oops concept...
    no need of calling any function modules.
    Regards,
    Nithya

    Hi
    Here is example code
    This is the method to be called:
    get_subtotals
    Use
    Returns the current subtotals of the ALV Grid Control. Having created totals for at least one column, users can calculate at most nine subtotals. The list is sorted by the values of one or several columns (called the subtotals column). If a value is changed in the subtotals column, the subtotal is displayed (this is also referred to as control level change).
    Integration
    Before you access the subtotals value, you use the method get_sort_criteria to get the sort table . One row of this table describes properties of a column in the output table.
    • If the field SUBTOT is set for a column in this table, the column is a subtotals column.
    • The field SPOS then indicates at which level (see below) the subtotal has been calculated.
    • The field FIELDNAME contains the name of the subtotals column in the output table.
    Based on this information, you specifically access the values of the tables passed (using reference variables COLLECT01 to COLLECT09).
    Features
    CALL METHOD <ref. var. to CL_GUI_ALV_GRID>->get_subtotals
    IMPORTING
    EP_COLLECT00 = <reference variable of type REF TO DATA>
    EP_COLLECT01 = <reference variable of type REF TO DATA>
    EP_COLLECT02 = <reference variable of type REF TO DATA>
    EP_COLLECT03 = <reference variable of type REF TO DATA>
    EP_COLLECT04 = <reference variable of type REF TO DATA>
    EP_COLLECT05 = <reference variable of type REF TO DATA>
    EP_COLLECT06 = <reference variable of type REF TO DATA>
    EP_COLLECT07 = <reference variable of type REF TO DATA>
    EP_COLLECT08 = <reference variable of type REF TO DATA>
    EP_COLLECT09 = <reference variable of type REF TO DATA>
    ET_GROUPLEVELS = <ínternal table of type LVC_T_GRPL>.
    In order to access the values of EP_COLLECT00 to EP_COLLECT09, you use ASSIGN to dereference the relevant reference variable in a field symbol of your output table type (see below).
    Parameters
    Meaning
    EP_COLLECT00
    Points to the totals line. Since there is only one totals line which, in addition, has a unique totalling area, no further information is available for this table in table ET_GROUPLEVELS.
    get_subtotals
    EP_COLLECT01 to EP_COLLECT09
    Point to the subtotals line. For each subtotals level, there is one reference variable. Each of these variables points to an internal table that has the type of the output table. EP_COLLECT01 points to the subtotal at the hightest level, while EP_COLLECT02 points to the subtotal at the second highest level, and so on. The levels are derived from the sort priority (field SPOS in the sort table ). The column by which the data was sorted first, is the highest subtotals level.
    ET_GROUPLEVELS
    Manages all indexes for the individual control levels. The fields of the table have the following meaning:
    • INDEX_FROM, INDEX_TO: Rows of the output table for which the subtotal was created
    • LEVEL: Subtotals level (see above)
    • COUNTER: Number of rows for which the subtotal was created
    • COMPRESS: For this subtotals line, the user has hidden the associated rows.
    • COLLECT: Indicates the subtotals table (01-09) in which the values are stored
    For an overview, see Methods of Class CL_GUI_ALV_GRID
    Activities

  • Alv report using oops ABAP

    hi friendz,
    can any one of u give an example, how to build alv report using oops abap ?
    thanks in advance.
    points for sure
    regards,
    Vijaya

    Hi Vijaya,
    I hope the following code upto your requirement.
    *& Report  ZMAT_ALV_GRID                                               *
    REPORT  ZCL_CLASS1.
    TYPES: BEGIN OF T_MARA,
             MATNR TYPE MARA-MATNR,
             MAKTX TYPE MAKT-MAKTX,
             WERKS TYPE MARD-WERKS,
             LGORT TYPE MARD-LGORT,
             LABST TYPE MARD-LABST,
           END OF T_MARA.
    *DATA: IT_MARA TYPE STANDARD TABLE OF T_MARA.
    DATA: IT_MARA TYPE T_MARA OCCURS 0.
    DATA: O_CONT TYPE REF TO CL_GUI_CUSTOM_CONTAINER,
          O_GRID TYPE REF TO CL_GUI_ALV_GRID.
    DATA: X_FLDCAT TYPE LVC_S_FCAT.
    DATA: IT_FLDCAT TYPE LVC_T_FCAT.
    DATA: I_LAYOUT TYPE LVC_S_LAYO.
    DATA: X_SORT TYPE LVC_S_SORT.
    DATA: I_SORT TYPE LVC_T_SORT.
    TABLES: MARA.
    SELECT-OPTIONS: S_MATNR FOR MARA-MATNR.
    PARAMETERS: P_CHK AS CHECKBOX.
    START-OF-SELECTION.
      PERFORM GET_DATA.
      PERFORM GENERATE_FLDCAT.
      PERFORM GENERATE_LAYOUT.
      PERFORM DO_SORT.
      SET SCREEN 100.
    *&      Module  STATUS_0100  OUTPUT
          text
    MODULE STATUS_0100 OUTPUT.
       SET PF-STATUS 'MAIN'.
    SET TITLEBAR 'xxx'.
       PERFORM BUILD_ALV.
    ENDMODULE.                 " STATUS_0100  OUTPUT
    *&      Module  USER_COMMAND_0100  INPUT
          text
    MODULE USER_COMMAND_0100 INPUT.
      CASE SY-UCOMM.
        WHEN 'BACK'.
          LEAVE PROGRAM.
      ENDCASE.
    ENDMODULE.                 " USER_COMMAND_0100  INPUT
    *&      Form  BUILD_ALV
          text
    FORM BUILD_ALV .
    CREATE OBJECT O_CONT
       EXPORTING
          CONTAINER_NAME              = 'MAT_CONTAINER'
       EXCEPTIONS
         CNTL_ERROR                  = 1
         CNTL_SYSTEM_ERROR           = 2
         CREATE_ERROR                = 3
         LIFETIME_ERROR              = 4
         LIFETIME_DYNPRO_DYNPRO_LINK = 5
         others                      = 6.
         CREATE OBJECT O_GRID
           EXPORTING
              I_PARENT          = O_CONT
           EXCEPTIONS
             ERROR_CNTL_CREATE = 1
             ERROR_CNTL_INIT   = 2
             ERROR_CNTL_LINK   = 3
             ERROR_DP_CREATE   = 4
             others            = 5.
    CALL METHOD O_GRID->SET_TABLE_FOR_FIRST_DISPLAY
       EXPORTING
       I_BUFFER_ACTIVE               =
       I_BYPASSING_BUFFER            =
       I_CONSISTENCY_CHECK           =
       I_STRUCTURE_NAME              =
       IS_VARIANT                    =
       I_SAVE                        =
       I_DEFAULT                     = ' '
         IS_LAYOUT                     = I_LAYOUT
       IS_PRINT                      =
       IT_SPECIAL_GROUPS             =
       IT_TOOLBAR_EXCLUDING          =
       IT_HYPERLINK                  =
       IT_ALV_GRAPHICS               =
       IT_EXCEPT_QINFO               =
       CHANGING
         IT_OUTTAB                     = IT_MARA
         IT_FIELDCATALOG               = IT_FLDCAT[]
         IT_SORT                       = I_SORT
       IT_FILTER                     =
      EXCEPTIONS
        INVALID_PARAMETER_COMBINATION = 1
        PROGRAM_ERROR                 = 2
        TOO_MANY_LINES                = 3
        others                        = 4.
    ENDFORM.                    " BUILD_ALV
    *&      Form  GET_DATA
          text
    FORM GET_DATA .
    SELECT A~MATNR
          B~MAKTX
          C~WERKS
          C~LGORT
          C~LABST
    INTO TABLE IT_MARA
    FROM MARA AS A
    INNER JOIN MAKT AS B
    ON BMATNR = AMATNR
    INNER JOIN MARD AS C
    ON CMATNR = AMATNR
    WHERE A~MATNR IN S_MATNR
    AND   B~SPRAS = SY-LANGU.
    ENDFORM.                    " GET_DATA
    *&      Form  GENERATE_FLDCAT
          text
    FORM GENERATE_FLDCAT .
    *CALL FUNCTION 'LVC_FIELDCATALOG_MERGE'
      EXPORTING
      I_BUFFER_ACTIVE              =
       I_STRUCTURE_NAME             = 'ZSMARA'
      I_CLIENT_NEVER_DISPLAY       = 'X'
      I_BYPASSING_BUFFER           =
      I_INTERNAL_TABNAME           = ' '
    CHANGING
       CT_FIELDCAT                  = IT_FLDCAT
    EXCEPTIONS
      INCONSISTENT_INTERFACE       = 1
      PROGRAM_ERROR                = 2
      OTHERS                       = 3.
    X_FLDCAT-COL_POS = 1.
    X_FLDCAT-FIELDNAME = 'MATNR'.
    X_FLDCAT-OUTPUTLEN = '18'.
    X_FLDCAT-REPTEXT = 'Material No'.
    APPEND X_FLDCAT TO IT_FLDCAT.
    X_FLDCAT-COL_POS = 2.
    X_FLDCAT-FIELDNAME = 'MAKTX'.
    X_FLDCAT-OUTPUTLEN = '48'.
    X_FLDCAT-REPTEXT = 'Material Desc'.
    X_FLDCAT-TOOLTIP = 'Material Desc'.
    APPEND X_FLDCAT TO IT_FLDCAT.
    X_FLDCAT-COL_POS = 3.
    X_FLDCAT-FIELDNAME = 'WERKS'.
    X_FLDCAT-OUTPUTLEN = '5'.
    X_FLDCAT-REPTEXT = 'Plant'.
    X_FLDCAT-TOOLTIP = 'Plant'.
    APPEND X_FLDCAT TO IT_FLDCAT.
    X_FLDCAT-COL_POS = 4.
    X_FLDCAT-FIELDNAME = 'LGORT'.
    X_FLDCAT-OUTPUTLEN = '5'.
    X_FLDCAT-REPTEXT = 'S.Loc'.
    X_FLDCAT-TOOLTIP = 'S.Loc'.
    APPEND X_FLDCAT TO IT_FLDCAT.
    X_FLDCAT-COL_POS = 5.
    X_FLDCAT-FIELDNAME = 'LABST'.
    X_FLDCAT-OUTPUTLEN = '20'.
    X_FLDCAT-REPTEXT = 'Quantity'.
    X_FLDCAT-TOOLTIP = 'Quantity'.
    X_FLDCAT-DO_SUM = 'X'.
    APPEND X_FLDCAT TO IT_FLDCAT.
    ENDFORM.                    " GENERATE_FLDCAT
    *&      Form  GENERATE_LAYOUT
          text
    FORM GENERATE_LAYOUT .
      I_LAYOUT-ZEBRA = 'X'.
      I_LAYOUT-FRONTEND = 'X'.
      I_LAYOUT-GRID_TITLE = 'ALV GRID USING OOPS'.
      I_LAYOUT-NUMC_TOTAL = 'X'.
    ENDFORM.                    " GENERATE_LAYOUT
    *&      Form  DO_SORT
          text
    FORM DO_SORT .
    X_SORT-FIELDNAME = 'MATNR'.
    X_SORT-UP = 'X'.
    X_SORT-SUBTOT = 'X'.
    IF P_CHK = 'X'.
       X_SORT-EXPA = SPACE.
    ELSE.
       X_SORT-EXPA = 'X'.
    ENDIF.
    APPEND X_SORT TO I_SORT.
    ENDFORM.                    " DO_SORT
    inorder to execute this code perfectly, do the following things.
    1. Create a Graphical Screen 100.
    2. Place a Custom Control on that screen and give name as MAT_CONTAINER.
    3. activate the screen.
    and execute the program.
      if this suits requirement award points.
    satish

  • ALV reports using OOPS

    Hi frnds,
            I want to write an alv report program using oops concepts.CAn anybody send me a simple code to generate an alv reports?
    Thanks a lot in advance.

    Hi
    http://www.sapdev.co.uk/reporting/alv/alvobjgrid/alvobject_sort.htm
    *& Report  ZLCL_ALV_INVOICE                                            *
    REPORT  ZLCL_ALV_INVOICE                        .
    TABLES: VBRK.
    DATA: ITAB LIKE VBRP OCCURS 1 WITH HEADER LINE.
    DATA: O_CONT TYPE REF TO CL_GUI_CUSTOM_CONTAINER,
          O_GRID TYPE REF TO CL_GUI_ALV_GRID.
    START-OF-SELECTION.
      SET SCREEN 100.
    *&      Form  GET_DATA
          text
    FORM GET_DATA .
      SELECT *
        FROM VBRP
        INTO TABLE ITAB
        WHERE VBELN = VBRK-VBELN.
    ENDFORM.                    " GET_DATA
    *&      Module  STATUS_0100  OUTPUT
          text
    MODULE STATUS_0100 OUTPUT.
      SET PF-STATUS 'MENU'.
      IF O_CONT IS INITIAL.
        CREATE OBJECT O_CONT
          EXPORTING
        CONTAINER_NAME              = 'INV_CONT' "Screen custom control name
          EXCEPTIONS
            CNTL_ERROR                  = 1
            CNTL_SYSTEM_ERROR           = 2
            CREATE_ERROR                = 3
            LIFETIME_ERROR              = 4
            LIFETIME_DYNPRO_DYNPRO_LINK = 5
            OTHERS                      = 6
        IF SY-SUBRC <> 0.
          MESSAGE I000(Z00) WITH 'Error in custom container'.
          EXIT.
        ENDIF.
        CREATE OBJECT O_GRID
          EXPORTING
            I_PARENT          = O_CONT "Custom container class object
          EXCEPTIONS
            ERROR_CNTL_CREATE = 1
            ERROR_CNTL_INIT   = 2
            ERROR_CNTL_LINK   = 3
            ERROR_DP_CREATE   = 4
            OTHERS            = 5.
        IF SY-SUBRC <> 0.
          MESSAGE I000(Z00) WITH 'Error in alv grid linking'.
          EXIT.
        ENDIF.
      ENDIF.
    ENDMODULE.                 " STATUS_0100  OUTPUT
    *&      Module  USER_COMMAND_0100  INPUT
          text
    MODULE USER_COMMAND_0100 INPUT.
      CASE SY-UCOMM.
        WHEN 'BACK'.
          LEAVE PROGRAM.
      ENDCASE.
    ENDMODULE.                 " USER_COMMAND_0100  INPUT
    *&      Module  SHOW_ALV_GRID  INPUT
          text
    MODULE SHOW_ALV_GRID INPUT.
      PERFORM GET_DATA.
      CALL METHOD O_GRID->SET_TABLE_FOR_FIRST_DISPLAY
        EXPORTING
          I_STRUCTURE_NAME              = 'VBRP'
        CHANGING
          IT_OUTTAB                     = ITAB[]
        EXCEPTIONS
          INVALID_PARAMETER_COMBINATION = 1
          PROGRAM_ERROR                 = 2
          TOO_MANY_LINES                = 3
          OTHERS                        = 4.
      IF SY-SUBRC <> 0.
        MESSAGE I000(Z00) WITH 'Error in showing alv grid'.
        EXIT.
      ENDIF.
    ENDMODULE.                 " SHOW_ALV_GRID  INPUT
    you can understand very easily

  • Disbable button on alv report using oops

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

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

  • How to send mail with out attachment in a report using oops concept

    Hi Abap Experts,
                     My requirement is i have to send a mail with out attaching any documents this is a report using oops conceopt how can i acheive it .

    Hi Saeed,
    Please search SDN before posting. There are so may threads for the same.
    Check out the standard reports--
    bcs_example_1, bcs_example_2, .. bcs_example_7
    Howard

  • Attaining Hot spot in ALV Tree Using OOPS concept

    Hi All,
    In our requirement we are displaying the data in ALV Tree Using OOPS.
    We need to achieve hot spot on one of the header field.
    I am using  Class 'CL_GUI_ALV_TREE'
    Ex:
    CreditAccnt/ Company codes            DSO    DDSO
    26                                                   15        15
       8000                                              5          5
       8545                                             10        10
    In the above example for every credit accnt in header we r displaying the values ( DSO ,DDSO) for all company codes.
    Now we require hot spot on Credit Accnt 26. Such that when user clicks on the credit accnt it should navigate to another transaction.
    NOTE: we havent build any field catalogue for field CreditAccnt/ Company codes .

    Hi,
    You can refer to the tutorial -
    https://www.sdn.sap.com/irj/servlet/prt/portal/prtroot/com.sap.km.cm.docs/library/abap/an%20easy%20reference%20for%20alv%20grid%20control.pdf
    Or try using the code below-
    CLASS lcl_event_receiver DEFINITION
    CLASS lcl_event_receiver DEFINITION.
    PUBLIC SECTION.
    CLASS-METHODS:
    Hot Spot Click
    handle_hotspot
    FOR EVENT hotspot_click OF cl_gui_alv_grid
    IMPORTING e_row_id
    e_column_id
    es_row_no,
    ENDCLASS.
    Implementation
    *& Method handle_hotspot
    This method is called when the user clicks on a hotspot to drill down.
    The following types are exported from the ALV
    LVC_S_ROW
    LVC_S_COL
    LVC_S_ROID
    METHOD handle_hotspot.
    The hotspot processing coded in the form below.
    PERFORM f9802_handle_hotspot USING e_row_id
    e_column_id
    es_row_no.
    ENDMETHOD.
    *& Form f9802_handle_hotspot
    This form is called when the user clicks on a hotspot on the ALV grid
    The parameters are of type
    -->P_E_ROW text
    -->P_E_COL text
    -->P_E_ROID text
    FORM f9802_handle_hotspot USING p_row
    p_col
    p_roid.
    DATA: lw_output LIKE LINE OF i_output.
    READ TABLE i_output INDEX p_row INTO lw_output.
    SET PARAMETER ID 'MAT' FIELD lw_output-matnr.
    CALL TRANSACTION 'MM02' AND SKIP FIRST SCREEN.
    ENDFORM. " f9802_handle_hotspot
    FORM f9300_modify_field_cat TABLES p_fieldcat STRUCTURE lvc_s_fcat.
    Field-symbols: <lfs_fieldcat> TYPE lvc_s_fcat.
    LOOP AT p_fieldcat ASSIGNING <lfs_fieldcat>.
    CASE <lfs_fieldcat>-fieldname.
    WHEN 'MATNR'.
    <lfs_fieldcat>-hotspot = c_x.
    <lfs_fieldcat>-key = c_x.
    WHEN OTHERS.
    ENDCASE.
    ENDLOOP.
    ENDFORM.
    In PBO,
    module STATUS_9001 output.
    Set handlers for events
    SET HANDLER o_eventreceiver->handle_hotspot FOR o_Alvgrid.
    ENDMODULE.
    Hope this helps

  • ALV grid using oops concepts

    HI all,
              Is it necessary to use container for ALV grid using classes.If not then please help me with a sample code.

    REPORT  z_alv_using_oops_conepts MESSAGE-ID z_OOPS.
    TABLES: ekko, ekpo.
    CLASS lcl_event_receiver DEFINITION DEFERRED.
    DATA: ok_code             TYPE sy-ucomm,
          gx_fcat1            TYPE lvc_s_fcat,
          gt_fcat1            TYPE STANDARD TABLE OF lvc_s_fcat,
          gx_fcat2            TYPE lvc_s_fcat,
          gt_fcat2            TYPE STANDARD TABLE OF lvc_s_fcat,
          gx_layout1          TYPE lvc_s_layo,
          gx_layout2          TYPE lvc_s_layo,
          gx_variant          TYPE disvariant,
          g_custom_container1 TYPE REF TO cl_gui_custom_container,
          g_custom_container2 TYPE REF TO cl_gui_custom_container,
          grid1               TYPE REF TO cl_gui_alv_grid,
          grid2               TYPE REF TO cl_gui_alv_grid,
          g_container1        TYPE scrfname VALUE 'MAIN_REPORT_LIST',
          g_container2        TYPE scrfname VALUE 'SECOND_REPORT_LIST',
          gv_event_rec1       TYPE REF TO lcl_event_receiver,
          gv_event_rec2       TYPE REF TO lcl_event_receiver,
          gv_repid            TYPE sy-repid,
          gt_final1           TYPE STANDARD TABLE OF ekko,
          gt_final2           TYPE STANDARD TABLE OF ekpo,
          gt_final3           TYPE STANDARD TABLE OF ekpo,
          gx_final            TYPE ekko,
          gx_final1           TYPE ekpo.
    INITIALIZATION.
      SELECTION-SCREEN                                              *
    SELECTION-SCREEN BEGIN OF BLOCK blk3 WITH FRAME .
    SELECT-OPTIONS:
          s_ebeln             FOR ekko-ebeln obligatory,
          s_ebelp             FOR ekpo-ebelp,
          s_bukrs             FOR ekko-bukrs,
          s_bsart             FOR ekko-bsart.
    SELECTION-SCREEN END OF BLOCK blk3.
    LOCAL CLASSES: Definition
    *===============================================================
    class lcl_event_receiver: local class to
                            define and handle own functions.
    Definition:
    ~~~~~~~~~~~
    CLASS lcl_event_receiver DEFINITION.
      PUBLIC SECTION.
        METHODS:
        hotspot_click1
            FOR EVENT hotspot_click OF cl_gui_alv_grid
                IMPORTING e_row_id
                          e_column_id,
        hotspot_click2
           FOR EVENT hotspot_click OF cl_gui_alv_grid
                IMPORTING e_row_id
                          e_column_id.
      PRIVATE SECTION.
    ENDCLASS.                    "lcl_event_receiver DEFINITION
          CLASS lcl_event_receiver IMPLEMENTATION
    CLASS lcl_event_receiver IMPLEMENTATION.
      METHOD hotspot_click1.
        DATA: lv_tabix TYPE sy-tabix,
              lx_final TYPE ekko.
        READ TABLE gt_final1 INTO gx_final INDEX e_row_id.
        IF sy-subrc = 0.
          gt_final3 = gt_final2.
          DELETE gt_final3 WHERE ebeln NE gx_final-ebeln.
          IF NOT g_custom_container2 IS INITIAL.
            CALL METHOD grid2->refresh_table_display.
            CALL METHOD grid1->refresh_table_display.
          ENDIF.
        ELSE.
          MESSAGE s000 WITH text-003.
          LEAVE LIST-PROCESSING.
        ENDIF.
      ENDMETHOD.                    "hotspot_click1
      METHOD hotspot_click2.
        READ TABLE gt_final3 INTO gx_final1 INDEX e_row_id.
        IF sy-subrc = 0.
          SET PARAMETER ID 'BES' FIELD gx_final-ebeln.
          CALL TRANSACTION 'ME23N' AND SKIP FIRST SCREEN.
        ENDIF.
      ENDMETHOD.                    "button_click1
    ENDCLASS.                    "lcl_event_receiver IMPLEMENTATION
      START-OF-SELECTION                                                 *
    START-OF-SELECTION.
      SELECT * FROM ekko INTO TABLE gt_final1 WHERE ebeln IN s_ebeln
                                              AND   bukrs IN s_bukrs
                                              AND   bsart IN s_bsart.
      IF sy-subrc = 0.
       SELECT * FROM ekpo INTO TABLE gt_final2 FOR ALL ENTRIES IN gt_final1
                                              WHERE ebeln = gt_final1-ebeln
                                               AND ebelp IN s_ebelp.
        IF sy-subrc = 0.
          gt_final3 = gt_final2.
        ENDIF.
      ENDIF.
      PERFORM sub_get_fieldcat CHANGING gt_fcat1.
      PERFORM sub_get_fieldcat CHANGING gt_fcat2.
      END-OF-SELECTION                                                   *
    END-OF-SELECTION.
      PERFORM display_process.
      CALL SCREEN 9000.
    MODULE pbo OUTPUT
    MODULE pbo OUTPUT.
      SET PF-STATUS 'MAIN100'.
      gx_layout1-grid_title = 'Purchase Order Header'.
      gx_layout1-zebra      = 'X'.
      gx_layout1-info_fname = 'COLOR_LINE'.
      gx_layout1-sel_mode   = 'X'.
      gx_layout2-grid_title = 'Purchase Order Items'.
      gx_layout2-zebra      = 'X'.
      gx_layout1-stylefname = 'CB'.
    gs_layout1-excp_led   = gc_check.
    gs_layout1-excp_group = gc_check.
      gv_repid = sy-repid.
      gx_variant-report = gv_repid.
      READ TABLE gt_final1 INTO gx_final INDEX 1.
      IF sy-subrc = 0.
        DELETE gt_final3 WHERE ebeln NE gx_final-ebeln.
      ENDIF.
      IF g_custom_container1 IS INITIAL.
        CREATE OBJECT g_custom_container1
          EXPORTING
            container_name = g_container1.
        CREATE OBJECT grid1
          EXPORTING
            i_parent = g_custom_container1.
        CALL METHOD grid1->set_table_for_first_display
          EXPORTING
            is_layout       = gx_layout1
            is_variant      = gx_variant
            i_save          = 'U'
            i_default       = 'X'
            i_structure_name = 'EKKO'
          CHANGING
            it_outtab       = gt_final1
            it_fieldcatalog = gt_fcat1.
        CALL METHOD cl_gui_control=>set_focus
          EXPORTING
            control = grid1.
      ENDIF.
      IF g_custom_container2 IS INITIAL.
        CREATE OBJECT g_custom_container2
          EXPORTING
            container_name = g_container2.
        CREATE OBJECT grid2
          EXPORTING
            i_parent = g_custom_container2.
        CALL METHOD grid2->set_table_for_first_display
          EXPORTING
            is_layout       = gx_layout2
            is_variant      = gx_variant
            i_save          = 'U'
            i_default       = 'X'
            i_structure_name = 'EKPO'
          CHANGING
            it_outtab       = gt_final3
            it_fieldcatalog = gt_fcat2.
        CALL METHOD cl_gui_control=>set_focus
          EXPORTING
            control = grid2.
      ENDIF.
      CREATE OBJECT gv_event_rec1.
      SET HANDLER gv_event_rec1->hotspot_click1 FOR grid1.
    CREATE OBJECT gv_event_rec2.
      SET HANDLER gv_event_rec1->hotspot_click2 FOR grid2.
      IF gt_final2 IS INITIAL.
        MESSAGE i000 WITH 'No Items exist for the Purchase Order'.
      ENDIF.
    ENDMODULE.                    "PBO OUTPUT
          MODULE PAI INPUT                                              *
    MODULE pai INPUT.
    To react on oi_custom_events:
      CALL METHOD cl_gui_cfw=>dispatch.
      CASE ok_code.
        WHEN 'EXIT'.
          PERFORM exit_program.
          LEAVE PROGRAM.
        WHEN 'BACK'.
          LEAVE TO SCREEN 0.
        WHEN 'CANCEL'.
          LEAVE TO SCREEN 0.
      ENDCASE.
      CLEAR ok_code.
    ENDMODULE.                    "PAI INPUT
          FORM EXIT_PROGRAM                                             *
    FORM exit_program.
      CALL METHOD grid1->free.
      CALL METHOD grid2->free.
      CALL METHOD cl_gui_cfw=>flush.
      IF sy-subrc NE 0.
        CALL FUNCTION 'POPUP_TO_INFORM'
          EXPORTING
            titel = gv_repid
            txt2  = sy-subrc
            txt1  = 'Error in Flush'(009).
      ENDIF.
    ENDFORM.                    "EXIT_PROGRAM
    *&      Form  display_process
          text
    -->  p1        text
    <--  p2        text
    FORM display_process .
      DATA: a LIKE sy-ucomm.
      DO 100 TIMES.
        DO 300 TIMES.
          GET TIME.
        ENDDO.
        a(3) = sy-index.a+3 = '%'.
        CALL FUNCTION 'SAPGUI_PROGRESS_INDICATOR'
          EXPORTING
            percentage = sy-index
            text       = a.
      ENDDO.
    ENDFORM.                    " display_process
    *&      Form  sub_get_fieldcat
          text
         <--P_GT_FCAT1  text
    FORM sub_get_fieldcat  CHANGING lt_fcat  TYPE lvc_t_fcat.
      gx_fcat1-fieldname = 'EBELN'.
      gx_fcat1-tabname   = 'gt_final1'.
      gx_fcat1-hotspot   = 'X'.
      APPEND gx_fcat1 TO lt_fcat.
    ENDFORM.                    " sub_get_fieldcat

  • END_OF_PAGE in alv report using oops

    Experts,
    Could you please give me the solution for the below issue?
    Requirement is like this:
    I have to display two grids in my report, and in that one grid will have top-of-page and other one will
    have end-of-page. Here, I am able to display the data in the top-of-page but not able to display the data in
    end of page. (Here I am using cl_gui_alv_grid : Class and Event is: END_OF_LIST.).
    I gone through the BCALV_TEST_GRID_EVENTS, but that is not helpful to me.
    Please anyone can you send the code snippet for the above one.
    Thanks...
    Sridhar..

    Hi,
    In the class cl_salv_table you have method get_event get the event from the method.
    Pass u r end of page iver here .it raises the event end of page
    thanks

  • ALV Report using OOPS - Back button(F3) flow not correct

    Hi,
    When i try to execute my report (F8) and it goes to output screen perfectly.
    Then if i hit back button(F3) it comes to selection screen that's also fine.
    after then if i hit back button(F3) then it goes to output screen again.
    actually it has to go to the SE38 - program screen
    My GUI logic:
    *&  Include           ZSD_GUILOGIC
    *&      Module  init_0100  OUTPUT
          text
    MODULE init_0100 OUTPUT.
      call method cl_gui_cfw=>dispatch.
    create the report object
        if my_report is initial.
          CREATE OBJECT MY_REPORT
            EXPORTING
              SO_VKORG = so_vkorg[]
              SO_VTWEG = so_vtweg[]
              SO_DATE  = so_date[].
        endif.
      IF my_CUSTOM_CONTAINER IS INITIAL.
        CREATE OBJECT my_CUSTOM_CONTAINER
          EXPORTING
            CONTAINER_NAME = _CONTAINER.
        CREATE OBJECT my_GRID1
          EXPORTING
            I_PARENT = my_CUSTOM_CONTAINER.
        int_tab = my_report->RETURN_RESULT( ).
        CALL METHOD my_GRID1->SET_TABLE_FOR_FIRST_DISPLAY
          EXPORTING
            is_variant       = my_layout
            i_save           = 'A'
            i_default        = 'X'
            I_STRUCTURE_NAME = structure
          CHANGING
            IT_OUTTAB        = int_tab[].
      else.
    container actually exists.
        int_tab = my_report->RETURN_RESULT( ).
        MY_grid1->refresh_table_display( ).
      endif.
    ENDMODULE.                 " init_0100  OUTPUT
    *&      Module  USER_COMMAND_0100  INPUT
          text
    MODULE USER_COMMAND_0100 INPUT.
      to react on oi_custom_events:
      CASE OK_CODE.
        WHEN 'EXIT'.
          PERFORM EXIT_PROGRAM.
        when 'BACK'.
          clear: my_report, my_CUSTOM_CONTAINER, my_grid1, int_tab.
         leave
          CALL SELECTION-SCREEN 1000.
        WHEN 'REFRESH'.
         int_tab = my_report->RETURN_RESULT( ).
        WHEN OTHERS.
       do nothing
      ENDCASE.
      CLEAR OK_CODE.
    ENDMODULE.                 " USER_COMMAND_0100  INPUT
    *&      Form  EXIT_PROGRAM
          text
    -->  p1        text
    <--  p2        text
    FORM EXIT_PROGRAM .
      LEAVE PROGRAM.
    ENDFORM.                    " EXIT_PROGRAM
    *&      Module  STATUS_0100  OUTPUT
          text
    MODULE STATUS_0100 OUTPUT.
      SET PF-STATUS 'MAIN0100'.
    SET TITLEBAR 'xxx'.
    ENDMODULE.                 " STATUS_0100  OUTPUT

    HI,
    Thanks for ur replies.
    I am calling selection screen 100 like this.
    REPORT  ZSD_.
    INCLUDE ZSD__TOP.
    INCLUDE ZSD_LCL000.
    INCLUDE ZSD_GUILOGIC.
    initialization.
      move 'IEQ000' to so_vrsio.
      append so_vrsio.
      move 'IEQ' to so_date.
      so_date-low  = sy-datum.
      so_date-high = sy-datum.
      append so_date.
    start-of-selection.
    set the layout
      perform prepare_layout changing my_layout.
    Thanks
    Praba
    set the structure
      structure = 'ZSD_LEVEL0'.
    call the processing screen 0100
    set screen '0100'.

  • Regarding ALV using OOPS Concept

    Hi Experts,
    Can abody explain to me how can i disable some settings in the tool bar of ALV Grid using oops concept??

    Hi Alex,
    You can perform this step, before you call set_table_for_first_display and pass that to this call.
    **Exculude all unnecessary standard function in ALV
      PERFORM exclude_tb_functions CHANGING lt_exclude.
    CALL METHOD g_grid->set_table_for_first_display
        EXPORTING
      is_layout            = gs_layout
          is_variant           = l_variant
          i_save               = 'A'
          it_toolbar_excluding = lt_exclude
        CHANGING
          it_fieldcatalog      = gt_fieldcat
          it_sort              = gt_sort[]
          it_outtab            = it_final[].
    You can exclude all unwanted function in the subroutine.
    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.
    ENDFORM.                    " exclude_tb_functions
    This will give you complete the solution for your query.
    Thanks
    Lakshmi

  • End of page in ALV display using OOPS

    Hi all,
       How can i display end of page or footer in ALV display using OOPS concept.
    Thanks,
    vinit

    Hi ,
    Try using this code.
    First add a handler method in your handler class definition as:
    e.g. METHOD handle__end_of_page
    FOR EVENT print_end_of_page OF cl_gui_alv_grid .
    Then implement the method in the implementation part of your local class.
    e.g. METHOD handle_print_end_of_page .
    WRITE:/ 'Flights Made on ', sy-datum .
    ENDMETHOD .
    And register this method as the handler.
    SET HANDLER gr_event_handler->handle_print_end_of_page FOR gr_alvgrid .
    Hope this helps.
    Regards,
    Janaki.

  • ALV Report Development using OOPs concept

    complete details of " ALV Report Development using OOPs concept".
    Thanks in advance ...

    hi Sudharshan,
    please use these sample codes to understand about OOALV
    BC_ALV_GRID_CONTROL
    BC_ALVHIERGRID1_D100
    BC_ALVHIERGRID1_D210
    BC_ALVHIERGRID1_HIER
    BC_ALV_DEMO_HTML_D0100
    BC_ALV_GRID_CONTROL
    BC_ALVEXCEL
    BC_ALVEXCEL_D100
    BC_ALVEXCEL_D210
    BC_ALVEXCEL_HIER
    BC_ALVEXCEL_SAP_TEMPL
    BC_ALVEXCEL_SAP_TEMPL_F01
    BC_ALVEXCEL_SAP_TEMPL_TOP
    BC_ALVEXCELTOP
    BC_ALVHIERGRID1_D100
    BC_ALVHIERGRID1_D210
    BC_ALVHIERGRID1_HIER
    BC_ALVHIERTOP
    For learning OOPS-ALV in every SAP their is transaction named ZALV
    or try the following links:
    http://help.sap.com/printdocu/core/Print46c/en/data/pdf/BCSRVALV/BCSRVALV.pdf
    The ALV object Grid methods allow the same functionality as ALV grid report function modules but are displayed within
    a screen (dialog program). SAP has provided a suit of programs which demonstrate how to For examples see standard SAP
    programs as detailed below:
    BCALV_EDIT_01 This report illustrates the simplest case of using an editable/noneditable ALV Grid Control.
    BCALV_EDIT_02 This report illustrates how to set chosen cells of an ALV Grid Control editable.
    BCALV_EDIT_03 In this example the user may change values of fields SEATSOCC (occupied seats) and/or PLANETYPE.
    The report checks the input value(s) semantically and provides protocol messages in case of error
    BCALV_EDIT_04 This report illustrates how to add and remove lines to a table using the ALV Grid Control and how to
    implement the saving of the new data.
    BCALV_EDIT_05 This example shows how to use checkboxes within an ALV Grid Control. You learn:
    (1) how to define a column for editable checkboxes for an attribute of your list
    (2) how to evaluate the checked checkboxes
    (3) how to switch between editable and non-editable checkboxes
    BCALV_EDIT_06 This example shows how to define a dropdown listbox for all cells of one column in an editable ALV
    Grid Control.
    BCALV_EDIT_07 This example shows how to define dropdown listboxes for particular cells of your output table.
    BCALV_EDIT_08 This report implements an ALV Grid Control with an application specific F4 help. The following aspects
    are dealt with:
    (1) how to replace the standard f4 help
    (2) how to pass the selected value to the ALV Grid Control
    (3) how to build an f4 help, whose value range depend on a value of another cell.

  • Help needed Displaying ALV  Secondary list without using oops concept

    Hi Experts
    Help needed Displaying ALV  Secondary list without using oops concept.
    its urgent
    regds
    rajasekhar

    hi chk this code
    ******************TABLES DECLARATION*****************
    TABLES : VBAP,MARA.
    *****************TYPE POOLS**************************
    TYPE-POOLS : SLIS.
    ****************INTERNAL TABLES**********************
    DATA : BEGIN OF IT_VBAP OCCURS 0,
    VBELN LIKE VBAP-VBELN, "SALES DOCUMENT
    POSNR LIKE VBAP-POSNR, "SALES DOCUMENT ITEM
    MATNR LIKE VBAP-MATNR, "MATERIAL NUMBER
    END OF IT_VBAP.
    ****************TEMPORARY VARIABLES******************
    DATA : V_VBELN LIKE VBAP-VBELN."SALES DOCUMENT
    DATA : V_MTART LIKE MARA-MTART. "MATERIAL TYPE
    *****************FIELD CATALOG***********************
    DATA : IT_FIELDCAT TYPE SLIS_T_FIELDCAT_ALV,
           WA_FIELDCAT TYPE SLIS_FIELDCAT_ALV.
    ****************LAYOUT*******************************
    DATA : WA_LAYOUT TYPE SLIS_LAYOUT_ALV.
    ***************VARIANT*******************************
    DATA : G_VARIANT LIKE DISVARIANT.
    ****************SAVE*********************************
    DATA : G_SAVE(1) TYPE C.
    *****************EVENTS******************************
    DATA : XS_EVENTS TYPE SLIS_ALV_EVENT,
           G_EVENTS TYPE SLIS_T_EVENT.
    ******************PF STATUS**************************
    DATA : PF_STATUS TYPE SLIS_FORMNAME VALUE 'SET_PF_STATUS'.
    ******************USER COMMAND************************
    DATA : USER_COMMAND TYPE SLIS_FORMNAME VALUE 'SET_USER_COMMAND',
           R_UCOMM LIKE SY-UCOMM.
    ****************SELECTION SCREEN************************
    SELECT-OPTIONS : S_VBELN FOR VBAP-VBELN.
    ***************AT SELECTION SCREEN*********************
    AT SELECTION-SCREEN.
      PERFORM VALIDATE.
    **************START-OF-SELECTION**************************
    START-OF-SELECTION.
      PERFORM GET_DETAILS.
      PERFORM FIELDCAT.
      PERFORM LAYOUT.
      PERFORM VARIANT.
      PERFORM SAVE.
      PERFORM EVENTS.
      PERFORM ALV_DISPLAY.
    *********************FORMS*******************************************
    *&      Form  validate
          text
    -->  p1        text
    <--  p2        text
    FORM VALIDATE .
      SELECT SINGLE VBELN
                    FROM VBAP
                    INTO V_VBELN
                    WHERE VBELN IN S_VBELN.
      IF SY-SUBRC <> 0.
        MESSAGE E000 WITH 'enter valid vbeln'.
      ENDIF.
    ENDFORM.                    " validate
    *&      Form  get_details
          text
    -->  p1        text
    <--  p2        text
    FORM GET_DETAILS .
      SELECT VBELN
             POSNR
             MATNR
             FROM VBAP
             INTO TABLE IT_VBAP
             WHERE VBELN IN S_VBELN.
      IF SY-SUBRC <> 0.
        MESSAGE E000 WITH 'no details found'.
      ENDIF.
    ENDFORM.                    " get_details
    *&      Form  fieldcat
          text
    -->  p1        text
    <--  p2        text
    FORM FIELDCAT .
      WA_FIELDCAT-TABNAME = 'IT_VBAP'.
      WA_FIELDCAT-FIELDNAME = 'VBELN'.
      WA_FIELDCAT-OUTPUTLEN = 10.
      WA_FIELDCAT-SELTEXT_L = 'SALES DOC'.
      APPEND WA_FIELDCAT TO IT_FIELDCAT.
      CLEAR WA_FIELDCAT.
      WA_FIELDCAT-TABNAME = 'IT_VBAP'.
      WA_FIELDCAT-FIELDNAME = 'POSNR'.
      WA_FIELDCAT-OUTPUTLEN = 6.
      WA_FIELDCAT-SELTEXT_L = 'ITEM'.
      APPEND WA_FIELDCAT TO IT_FIELDCAT.
      CLEAR WA_FIELDCAT.
      WA_FIELDCAT-TABNAME = 'IT_VBAP'.
      WA_FIELDCAT-FIELDNAME = 'MATNR'.
      WA_FIELDCAT-OUTPUTLEN = 18.
      WA_FIELDCAT-SELTEXT_L = 'MATERIAL NO'.
      APPEND WA_FIELDCAT TO IT_FIELDCAT.
      CLEAR WA_FIELDCAT.
    ENDFORM.                    " fieldcat
    *&      Form  LAYOUT
          text
    -->  p1        text
    <--  p2        text
    FORM LAYOUT .
      WA_LAYOUT-ZEBRA = 'X'.
    ENDFORM.                    " LAYOUT
    *&      Form  VARIANT
          text
    -->  p1        text
    <--  p2        text
    FORM VARIANT .
      CLEAR G_VARIANT.
      G_VARIANT-REPORT = SY-REPID.
    ENDFORM.                    " VARIANT
    *&      Form  SAVE
          text
    -->  p1        text
    <--  p2        text
    FORM SAVE .
      CLEAR G_SAVE.
      G_SAVE = 'A'.
    ENDFORM.                    " SAVE
    *&      Form  EVENTS
          text
    -->  p1        text
    <--  p2        text
    FORM EVENTS .
      CLEAR XS_EVENTS.
      XS_EVENTS-NAME = SLIS_EV_TOP_OF_PAGE.
      XS_EVENTS-FORM = 'TOP_OF_PAGE'.
      APPEND XS_EVENTS TO G_EVENTS.
    ENDFORM.                    " EVENTS
    *&      Form  TOP_OF_PAGE
          text
    FORM TOP_OF_PAGE.
      WRITE :/ ' INTELLI GROUP'.
    ENDFORM.                    "TOP_OF_PAGE
    *&      Form  ALV_DISPLAY
          text
    -->  p1        text
    <--  p2        text
    FORM ALV_DISPLAY .
      CALL FUNCTION 'REUSE_ALV_LIST_DISPLAY'
       EXPORTING
      I_INTERFACE_CHECK              = ' '
      I_BYPASSING_BUFFER             =
      I_BUFFER_ACTIVE                = ' '
         I_CALLBACK_PROGRAM             = SY-REPID
         I_CALLBACK_PF_STATUS_SET       = PF_STATUS
         I_CALLBACK_USER_COMMAND        = USER_COMMAND
      I_STRUCTURE_NAME               =
         IS_LAYOUT                      = WA_LAYOUT
         IT_FIELDCAT                    = IT_FIELDCAT
      IT_EXCLUDING                   =
      IT_SPECIAL_GROUPS              =
      IT_SORT                        =
      IT_FILTER                      =
      IS_SEL_HIDE                    =
      I_DEFAULT                      = 'X'
         I_SAVE                         = G_SAVE
         IS_VARIANT                     = G_VARIANT
         IT_EVENTS                      = G_EVENTS
      IT_EVENT_EXIT                  =
      IS_PRINT                       =
      IS_REPREP_ID                   =
      I_SCREEN_START_COLUMN          = 0
      I_SCREEN_START_LINE            = 0
      I_SCREEN_END_COLUMN            = 0
      I_SCREEN_END_LINE              = 0
    IMPORTING
      E_EXIT_CAUSED_BY_CALLER        =
      ES_EXIT_CAUSED_BY_USER         =
        TABLES
          T_OUTTAB                       = IT_VBAP
       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.                    " ALV_DISPLAY
    *&      Form  SET_PF_STATUS
          text
    FORM SET_PF_STATUS USING EXTAB TYPE SLIS_T_EXTAB.
      SET PF-STATUS 'Z50651_PFSTATUS' EXCLUDING EXTAB.
    ENDFORM.                    "SET_PF_STATUS
    *&      Form  SET_USER_COMMAND
          text
    FORM SET_USER_COMMAND USING R_UCOMM
                                RS_SELFIELD TYPE SLIS_SELFIELD.
      CASE R_UCOMM.
        WHEN 'DC'.
          READ TABLE IT_VBAP INDEX RS_SELFIELD-TABINDEX.
          IF SY-SUBRC = 0.
            SELECT SINGLE MTART
                          FROM MARA
                          INTO V_MTART
                          WHERE MATNR = IT_VBAP-MATNR.
            IF SY-SUBRC <> 0.
       MESSAGE E000 WITH 'NO MATERIAL DESCRIPTION FOR SELECTED MATERIAL NO'.
            ELSE.
              WRITE :/ 'MATERIAL NO :',IT_VBAP-MATNR.
              WRITE :/ 'MATERIAL TYPE :' , V_MTART.
            ENDIF.
          ENDIF.
        WHEN 'BACK'.
          LEAVE TO SCREEN 0.
        WHEN 'EXIT'.
          LEAVE TO SCREEN 0.
        WHEN 'CLOSE'.
          CALL TRANSACTION 'SE38'.
      ENDCASE.
    REPORT  Z_ALV_INTERACTIVE  MESSAGE-ID ZMSG_50651
                                    LINE-SIZE 100
                                    LINE-COUNT 60
                                    NO STANDARD PAGE HEADING.
    ******************TABLES DECLARATION*****************
    TABLES : VBAP,MARA.
    *****************TYPE POOLS**************************
    TYPE-POOLS : SLIS.
    ****************INTERNAL TABLES**********************
    DATA : BEGIN OF IT_VBAP OCCURS 0,
    VBELN LIKE VBAP-VBELN, "SALES DOCUMENT
    POSNR LIKE VBAP-POSNR, "SALES DOCUMENT ITEM
    MATNR LIKE VBAP-MATNR, "MATERIAL NUMBER
    END OF IT_VBAP.
    ****************TEMPORARY VARIABLES******************
    DATA : V_VBELN LIKE VBAP-VBELN."SALES DOCUMENT
    DATA : V_MTART LIKE MARA-MTART. "MATERIAL TYPE
    *****************FIELD CATALOG***********************
    DATA : IT_FIELDCAT TYPE SLIS_T_FIELDCAT_ALV,
           WA_FIELDCAT TYPE SLIS_FIELDCAT_ALV.
    ****************LAYOUT*******************************
    DATA : WA_LAYOUT TYPE SLIS_LAYOUT_ALV.
    ***************VARIANT*******************************
    DATA : G_VARIANT LIKE DISVARIANT.
    ****************SAVE*********************************
    DATA : G_SAVE(1) TYPE C.
    *****************EVENTS******************************
    DATA : XS_EVENTS TYPE SLIS_ALV_EVENT,
           G_EVENTS TYPE SLIS_T_EVENT.
    ******************PF STATUS**************************
    DATA : PF_STATUS TYPE SLIS_FORMNAME VALUE 'SET_PF_STATUS'.
    ******************USER COMMAND************************
    DATA : USER_COMMAND TYPE SLIS_FORMNAME VALUE 'SET_USER_COMMAND',
           R_UCOMM LIKE SY-UCOMM.
    ****************SELECTION SCREEN************************
    SELECT-OPTIONS : S_VBELN FOR VBAP-VBELN.
    ***************AT SELECTION SCREEN*********************
    AT SELECTION-SCREEN.
      PERFORM VALIDATE.
    **************START-OF-SELECTION**************************
    START-OF-SELECTION.
      PERFORM GET_DETAILS.
      PERFORM FIELDCAT.
      PERFORM LAYOUT.
      PERFORM VARIANT.
      PERFORM SAVE.
      PERFORM EVENTS.
      PERFORM ALV_DISPLAY.
    *********************FORMS*******************************************
    *&      Form  validate
          text
    -->  p1        text
    <--  p2        text
    FORM VALIDATE .
      SELECT SINGLE VBELN
                    FROM VBAP
                    INTO V_VBELN
                    WHERE VBELN IN S_VBELN.
      IF SY-SUBRC <> 0.
        MESSAGE E000 WITH 'enter valid vbeln'.
      ENDIF.
    ENDFORM.                    " validate
    *&      Form  get_details
          text
    -->  p1        text
    <--  p2        text
    FORM GET_DETAILS .
      SELECT VBELN
             POSNR
             MATNR
             FROM VBAP
             INTO TABLE IT_VBAP
             WHERE VBELN IN S_VBELN.
      IF SY-SUBRC <> 0.
        MESSAGE E000 WITH 'no details found'.
      ENDIF.
    ENDFORM.                    " get_details
    *&      Form  fieldcat
          text
    -->  p1        text
    <--  p2        text
    FORM FIELDCAT .
      WA_FIELDCAT-TABNAME = 'IT_VBAP'.
      WA_FIELDCAT-FIELDNAME = 'VBELN'.
      WA_FIELDCAT-OUTPUTLEN = 10.
      WA_FIELDCAT-SELTEXT_L = 'SALES DOC'.
      APPEND WA_FIELDCAT TO IT_FIELDCAT.
      CLEAR WA_FIELDCAT.
      WA_FIELDCAT-TABNAME = 'IT_VBAP'.
      WA_FIELDCAT-FIELDNAME = 'POSNR'.
      WA_FIELDCAT-OUTPUTLEN = 6.
      WA_FIELDCAT-SELTEXT_L = 'ITEM'.
      APPEND WA_FIELDCAT TO IT_FIELDCAT.
      CLEAR WA_FIELDCAT.
      WA_FIELDCAT-TABNAME = 'IT_VBAP'.
      WA_FIELDCAT-FIELDNAME = 'MATNR'.
      WA_FIELDCAT-OUTPUTLEN = 18.
      WA_FIELDCAT-SELTEXT_L = 'MATERIAL NO'.
      APPEND WA_FIELDCAT TO IT_FIELDCAT.
      CLEAR WA_FIELDCAT.
    ENDFORM.                    " fieldcat
    *&      Form  LAYOUT
          text
    -->  p1        text
    <--  p2        text
    FORM LAYOUT .
      WA_LAYOUT-ZEBRA = 'X'.
    ENDFORM.                    " LAYOUT
    *&      Form  VARIANT
          text
    -->  p1        text
    <--  p2        text
    FORM VARIANT .
      CLEAR G_VARIANT.
      G_VARIANT-REPORT = SY-REPID.
    ENDFORM.                    " VARIANT
    *&      Form  SAVE
          text
    -->  p1        text
    <--  p2        text
    FORM SAVE .
      CLEAR G_SAVE.
      G_SAVE = 'A'.
    ENDFORM.                    " SAVE
    *&      Form  EVENTS
          text
    -->  p1        text
    <--  p2        text
    FORM EVENTS .
      CLEAR XS_EVENTS.
      XS_EVENTS-NAME = SLIS_EV_TOP_OF_PAGE.
      XS_EVENTS-FORM = 'TOP_OF_PAGE'.
      APPEND XS_EVENTS TO G_EVENTS.
    ENDFORM.                    " EVENTS
    *&      Form  TOP_OF_PAGE
          text
    FORM TOP_OF_PAGE.
      WRITE :/ ' INTELLI GROUP'.
    ENDFORM.                    "TOP_OF_PAGE
    *&      Form  ALV_DISPLAY
          text
    -->  p1        text
    <--  p2        text
    FORM ALV_DISPLAY .
      CALL FUNCTION 'REUSE_ALV_LIST_DISPLAY'
       EXPORTING
      I_INTERFACE_CHECK              = ' '
      I_BYPASSING_BUFFER             =
      I_BUFFER_ACTIVE                = ' '
         I_CALLBACK_PROGRAM             = SY-REPID
       I_CALLBACK_PF_STATUS_SET         = PF_STATUS
         I_CALLBACK_USER_COMMAND        = USER_COMMAND
      I_STRUCTURE_NAME               =
         IS_LAYOUT                      = WA_LAYOUT
         IT_FIELDCAT                    = IT_FIELDCAT
      IT_EXCLUDING                   =
      IT_SPECIAL_GROUPS              =
      IT_SORT                        =
      IT_FILTER                      =
      IS_SEL_HIDE                    =
      I_DEFAULT                      = 'X'
         I_SAVE                         = G_SAVE
        IS_VARIANT                      = G_VARIANT
         IT_EVENTS                      = G_EVENTS
      IT_EVENT_EXIT                  =
      IS_PRINT                       =
      IS_REPREP_ID                   =
      I_SCREEN_START_COLUMN          = 0
      I_SCREEN_START_LINE            = 0
      I_SCREEN_END_COLUMN            = 0
      I_SCREEN_END_LINE              = 0
    IMPORTING
      E_EXIT_CAUSED_BY_CALLER        =
      ES_EXIT_CAUSED_BY_USER         =
        TABLES
          T_OUTTAB                       = IT_VBAP
       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.                    " ALV_DISPLAY
    *&      Form  SET_PF_STATUS
          text
    FORM SET_PF_STATUS USING EXTAB TYPE SLIS_T_EXTAB.
      SET PF-STATUS 'STANDARD' EXCLUDING EXTAB.
    ENDFORM.                    "SET_PF_STATUS
    *&      Form  SET_USER_COMMAND
          text
    FORM SET_USER_COMMAND USING R_UCOMM
                                RS_SELFIELD TYPE SLIS_SELFIELD.
      CASE R_UCOMM.
        WHEN 'DC'.
          READ TABLE IT_VBAP INDEX RS_SELFIELD-TABINDEX.
          IF SY-SUBRC = 0.
            SELECT SINGLE MTART
                          FROM MARA
                          INTO V_MTART
                          WHERE MATNR = IT_VBAP-MATNR.
            IF SY-SUBRC <> 0.
       MESSAGE E000 WITH 'NO MATERIAL DESCRIPTION FOR SELECTED MATERIAL NO'.
            ELSE.
              WRITE :/ 'MATERIAL NO :',IT_VBAP-MATNR.
              WRITE :/ 'MATERIAL TYPE :' , V_MTART.
      SUBMIT SLIS_DUMMY WITH P_MATNR EQ IT_VBAP-MATNR
                        WITH P_MTART EQ V_MTART.
            ENDIF.
          ENDIF.
        WHEN 'BACK'.
          LEAVE TO SCREEN 0.
        WHEN 'EXIT'.
          LEAVE TO SCREEN 0.
        WHEN 'CLOSE'.
          CALL TRANSACTION 'SE38'.
      ENDCASE.
    plz reward if useful

Maybe you are looking for

  • My 3D is not working in Photoshop CS5. All of the options are greyed out

    Hi, I just installed the photoshop CS5 but find out my 3D is not working, all of the options are greyed out. I have checked on the openGL menu in preference but still not work. I have core i7 and intel HD graphics 3000 with up to 1760MB dynamic video

  • My Exceed is not working with Solaris 9 Box

    What are the neccessary changes do i need to make on solaris 9 box in order to see the Solaris 9 screen on my Window XP desktop. I have enabled the following setting such as ./dtlogin -daemon enable But still it keep XDMCP timed out. Any body has any

  • BT Infinity Variable Speed

    I had BT Infinity installed on 27 July, previously no problems with BT Broadband. After 10 day bedding in period the speed was variable, and on occaision dropped to below 1 Mbps, although it could provide 37+ Mbps for a lot of the time. BT Engineer a

  • "Send to back" sending too far back?

    Why does the "send to back" command send stuff all the way behind the scenes? Why not just to the furthest position for the objects in your presentation?

  • From where could i find detail info on FI-SD interface..

    Thank you very much. Anybody provide the link from help.sap.com...?? Thanks