*&

---------------------------------------------------------------------*
*& Report ZKRS1_ALV_OOPS
*&
*&---------------------------------------------------------------------*
*&
*&
*&---------------------------------------------------------------------*
REPORT zkrs1_alv_oops.
TYPES : BEGIN OF ty_vbap,
vbeln TYPE vbap-vbeln,
posnr TYPE vbap-posnr,
matnr TYPE vbap-matnr,
pmatn TYPE vbap-pmatn,
matkl TYPE vbap-matkl,
pstyv TYPE vbap-pstyv,
prodh TYPE vbap-prodh,
netwr TYPE vbap-netwr,
END OF ty_vbap.

DATA : it_vbap TYPE TABLE OF ty_vbap,
it_fcat TYPE lvc_t_fcat,
wa_layo TYPE lvc_s_layo,
g_ok_code TYPE sy-ucomm.
DATA : grid TYPE REF TO cl_gui_alv_grid,
cont TYPE REF TO cl_gui_custom_container,
g_name TYPE scrfname VALUE 'ALV'.
TABLES : vbap.
*----------------------------------------------------------------------*
*
CLASS d_event DEFINITION
*----------------------------------------------------------------------*
*
*----------------------------------------------------------------------*
CLASS d_event DEFINITION.
PUBLIC SECTION.
METHODS : do_dc FOR EVENT
IMPORTING
do_hc FOR EVENT
IMPORTING
ENDCLASS.

double_click OF cl_gui_alv_grid
e_row e_column es_row_no ,
hotspot_click OF cl_gui_alv_grid
e_row_id e_column_id es_row_no .
"d_event DEFINITION

*----------------------------------------------------------------------*
*
CLASS d_event IMPLEMENTATION
*----------------------------------------------------------------------*
*
*----------------------------------------------------------------------*
CLASS d_event IMPLEMENTATION.

. BREAK-POINT. METHOD do_hc. SELECT vbeln posnr matnr pmatn matkl pstyv prodh netwr FROM vbap INTO TABLE it_vbap WHERE vbeln IN s_vbeln. ENDCLASS. DELETE it_vbap INDEX e_row-index. PERFORM dis_alv. SELECT-OPTIONS : s_vbeln FOR vbap-vbeln. PERFORM get_data. ENDMETHOD. CALL METHOD grid->refresh_table_display. IF e_column-fieldname = 'MATNR'.METHOD do_dc. ENDMETHOD. *&---------------------------------------------------------------------* *& Form get_data *&---------------------------------------------------------------------* * text *----------------------------------------------------------------------* * --> p1 text * <-. " get_data *&---------------------------------------------------------------------* *& Form dis_alv *&---------------------------------------------------------------------* * text *----------------------------------------------------------------------* * --> p1 text * <-. START-OF-SELECTION .p2 text *----------------------------------------------------------------------* FORM dis_alv . ENDIF.p2 text *----------------------------------------------------------------------* FORM get_data . "do_dc "do_hc "d_event IMPLEMENTATION DATA : event TYPE REF TO d_event . ENDFORM.

" dis_alv *&---------------------------------------------------------------------* *& Module STATUS_0100 OUTPUT *&---------------------------------------------------------------------* * text *----------------------------------------------------------------------* MODULE status_0100 OUTPUT. LEAVE PROGRAM.CALL SCREEN 100. CREATE OBJECT grid EXPORTING i_parent . IF grid IS INITIAL. " USER_COMMAND_0100 INPUT *&---------------------------------------------------------------------* *& Form call_alv *&---------------------------------------------------------------------* * text *----------------------------------------------------------------------* * --> p1 text * <-. CASE g_ok_code. PERFORM call_alv. ENDFORM. CREATE OBJECT event. CREATE OBJECT cont EXPORTING container_name = g_name . ENDCASE.p2 text *----------------------------------------------------------------------* FORM call_alv . SET PF-STATUS 'MAIN'. ENDMODULE. = cont . * SET TITLEBAR 'xxx'. " STATUS_0100 OUTPUT *&---------------------------------------------------------------------* *& Module USER_COMMAND_0100 INPUT *&---------------------------------------------------------------------* * text *----------------------------------------------------------------------* MODULE user_command_0100 INPUT. ENDMODULE. WHEN 'BACK'.

ENDIF. ENDFORM. IF sy-subrc <> 0. * * * * * * * * * * * * * * * * * * * * * * * CALL METHOD grid->set_table_for_first_display EXPORTING I_BUFFER_ACTIVE = I_BYPASSING_BUFFER = I_CONSISTENCY_CHECK = I_STRUCTURE_NAME = IS_VARIANT = I_SAVE = I_DEFAULT = 'X' is_layout = wa_layo IS_PRINT = IT_SPECIAL_GROUPS = IT_TOOLBAR_EXCLUDING = IT_HYPERLINK = IT_ALV_GRAPHICS = IT_EXCEPT_QINFO = IR_SALV_ADAPTER = CHANGING it_outtab = it_vbap it_fieldcatalog = it_fcat IT_SORT = IT_FILTER = EXCEPTIONS INVALID_PARAMETER_COMBINATION = 1 PROGRAM_ERROR = 2 TOO_MANY_LINES = 3 others = 4 . SET HANDLER event->do_hc FOR grid. CALL METHOD grid->refresh_table_display . " call_alv *&---------------------------------------------------------------------* *& Form gen_fcat *&---------------------------------------------------------------------* * text *----------------------------------------------------------------------* . MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4. ENDIF. PERFORM gen_layput . ELSE. PERFORM gen_fcat.SET HANDLER event->do_dc FOR grid.

wa_fcat-coltext = 'SO'. CLEAR wa_fcat. ENDIF. wa_fcat-fieldname = 'PRODH' . wa_fcat-fieldname wa_fcat-coltext = wa_fcat-hotspot = APPEND wa_fcat TO CLEAR wa_fcat.* --> p1 text * <-. 'X'. CLEAR wa_fcat. APPEND wa_fcat TO it_fcat. MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4. CLEAR wa_fcat. * * ** * ** ** ** * * ** ** ** ** * * ** ** * CALL FUNCTION 'LVC_FIELDCATALOG_MERGE' EXPORTING I_BUFFER_ACTIVE = i_structure_name = 'VBAP' I_CLIENT_NEVER_DISPLAY = 'X' I_BYPASSING_BUFFER = I_INTERNAL_TABNAME = CHANGING ct_fieldcat = it_fcat EXCEPTIONS INCONSISTENT_INTERFACE = 1 PROGRAM_ERROR = 2 OTHERS = 3 . CLEAR wa_fcat. DATA : wa_fcat TYPE lvc_s_fcat. APPEND wa_fcat TO it_fcat. wa_fcat-coltext = 'Prod. APPEND wa_fcat TO it_fcat.p2 text *----------------------------------------------------------------------* FORM gen_fcat . wa_fcat-coltext = 'Item Cat'. it_fcat.Hierarchy'. APPEND wa_fcat TO it_fcat. wa_fcat-coltext = 'Item'. wa_fcat-fieldname = 'VBELN' . wa_fcat-fieldname = 'PSTYV' . wa_fcat-coltext = 'Mat Cat'. = 'MATNR' . wa_fcat-coltext = 'Mat type'. 'Material'. wa_fcat-fieldname = 'POSNR' . wa_fcat-fieldname = 'MATKL' . APPEND wa_fcat TO it_fcat. wa_fcat-fieldname = 'PMATN' . IF sy-subrc <> 0. CLEAR wa_fcat. .

ENDFORM. APPEND wa_fcat TO it_fcat. CLEAR wa_fcat.APPEND wa_fcat TO it_fcat. wa_fcat-coltext = 'Price'.p2 text *----------------------------------------------------------------------* FORM gen_layput . CLEAR wa_fcat. " gen_layput . ENDFORM. wa_layo-sel_mode = 'D'. " gen_fcat *&---------------------------------------------------------------------* *& Form gen_layput *&---------------------------------------------------------------------* * text *----------------------------------------------------------------------* * --> p1 text * <-. wa_fcat-fieldname = 'NETWR' .

Sign up to vote on this title
UsefulNot useful