Pf status and user command in factory method - OOPS ALV in ABAP
1. Goto SE38.
2. Give program name and click on create.
3. Give title and click on save.
4. Write code.
REPORT zab_rp_oops_pfstatus_ucomm.
TABLES: ekko,ekpo.
TYPES: BEGIN OF ty_ekko,
ebeln TYPE ekko-ebeln,
bukrs TYPE ekko-bukrs,
bstyp TYPE ekko-bstyp,
bsart TYPE ekko-bsart,
END OF ty_ekko.
TYPES: BEGIN OF ty_ekpo,
ebeln TYPE ekpo-ebeln,
ebelp TYPE ekpo-ebelp,
matnr TYPE ekpo-matnr,
werks TYPE ekpo-werks,
END OF ty_ekpo.
DATA: lt_ekko TYPE TABLE OF ty_ekko,
lr_ekko TYPE ty_ekko,
lt_ekpo TYPE TABLE OF ty_ekpo,
lr_ekpo TYPE ty_ekpo.
DATA: lo_salv1 TYPE REF TO cl_salv_table,
lo_salv2 TYPE REF TO cl_salv_table,
lo_events TYPE REF TO cl_salv_events_table,
lo_grid TYPE REF TO cl_gui_alv_grid,
lt_rows TYPE lvc_t_row,
lr_rows TYPE lvc_s_row.
SELECT-OPTIONS: s_ebeln FOR ekko-ebeln.
CLASS a DEFINITION.
PUBLIC SECTION.
METHODS handler FOR EVENT added_function OF cl_salv_events_table IMPORTING e_salv_function.
ENDCLASS.
CLASS a IMPLEMENTATION.
METHOD handler.
CALL FUNCTION 'GET_GLOBALS_FROM_SLVC_FULLSCR'
IMPORTING
e_grid = lo_grid.
CALL METHOD lo_grid->get_selected_rows
IMPORTING
et_index_rows = lt_rows.
READ TABLE lt_rows INTO lr_rows INDEX 1.
IF sy-subrc = 0.
READ TABLE lt_ekko INTO lr_ekko INDEX lr_rows-index.
IF sy-subrc = 0.
SELECT ebeln ebelp matnr werks
FROM ekpo
INTO TABLE lt_ekpo
WHERE ebeln EQ lr_ekko-ebeln.
TRY.
CALL METHOD cl_salv_table=>factory
IMPORTING
r_salv_table = lo_salv2
CHANGING
t_table = lt_ekpo.
CATCH cx_salv_msg.
ENDTRY.
CALL METHOD lo_salv2->if_salv_gui_om_table_action~display.
ENDIF.
ENDIF.
ENDMETHOD.
ENDCLASS.
START-OF-SELECTION.
IF s_ebeln IS INITIAL.
MESSAGE 'Pls enter purchasing doc number' TYPE 'E'.
ELSE.
SELECT ebeln
bukrs
bstyp
bsart
FROM ekko
INTO TABLE lt_ekko
WHERE ebeln IN s_ebeln.
ENDIF.
SET PF-STATUS 'ZPF_STATUS'.
TRY.
CALL METHOD cl_salv_table=>factory
IMPORTING
r_salv_table = lo_salv1
CHANGING
t_table = lt_ekko.
CATCH cx_salv_msg.
ENDTRY.
CALL METHOD lo_salv1->if_salv_gui_om_table_info~set_screen_status
EXPORTING
report = sy-repid
pfstatus = 'ZPF_STATUS'.
CALL METHOD lo_salv1->if_salv_gui_om_table_info~get_event
RECEIVING
value = lo_events.
DATA: lo_object TYPE REF TO a.
CREATE OBJECT lo_object.
SET HANDLER lo_object->handler FOR lo_events.
CALL METHOD lo_salv1->if_salv_gui_om_table_action~display.
AT USER-COMMAND.
CASE sy-ucomm.
WHEN 'BACK'.
LEAVE TO SCREEN 0.
ENDCASE.
***************************pf-status************************
* Double clicks on zpf_status.
* Expand application toolbar. Give name & double clicks.
* Give Required fields.
* Expand function keys and give name [BACK].
* Check and activate.
***************************end pf-status********************
Input
Output
Select row & After Click on display button.
Comments
Post a Comment