1.Class ALV 的双击、F4事件
2.Call Transaction :Vendor、PO
REPORT z_scm_maintain_ekko_ci .
TABLES: ekko.
DATA: BEGIN OF itab OCCURS 0 ,
flag ,
werks LIKE ekpo-werks,
ebeln LIKE ekko-ebeln,
lifnr LIKE ekko-lifnr,
name1 LIKE lfa1-name1,
telf1 LIKE lfa1-telf1,
aedat LIKE ekko-aedat,
zzreagree LIKE ekko-zzreagree,
zzredate LIKE ekko-zzredate,
zzrereason LIKE ekko-zzrereason,
zzreperson LIKE ekko-zzreperson,
zzremode LIKE ekko-zzremode,
zzpostatus LIKE ekko-zzpostatus,
END OF itab .
DATA: ok_code LIKE sy-ucomm .
DATA: l_valid(1) TYPE c.
DATA: go_grid TYPE REF TO cl_gui_alv_grid,
go_custom_container TYPE REF TO cl_gui_custom_container.
DATA: gt_fieldcat TYPE lvc_t_fcat,
gs_fieldcat TYPE lvc_s_fcat,
gs_variant TYPE disvariant ,
gt_sort TYPE lvc_t_sort,
gs_sort TYPE lvc_s_sort,
gt_filt TYPE lvc_t_filt,
gs_filt TYPE lvc_s_filt,
ls_cell TYPE lvc_s_styl,
sla TYPE lvc_s_layo,
gt_f4 TYPE lvc_t_f4,
gs_f4 TYPE lvc_s_f4.
DATA: lt_exclude TYPE ui_functions.
PARAMETERS p_werks LIKE ekpo-werks OBLIGATORY.
SELECT-OPTIONS:
s_ebeln FOR ekko-ebeln ,
s_lifnr FOR ekko-lifnr,
s_aedat FOR ekko-aedat ."OBLIGATORY.
DATA cl_gui_alv_grid.
*---------------------------------------------------------------------*
* CLASS lcl_event_receiver DEFINITION
*---------------------------------------------------------------------*
CLASS lcl_event_receiver DEFINITION.
PUBLIC SECTION.
METHODS handle_f4
FOR EVENT onf4 OF cl_gui_alv_grid
IMPORTING e_fieldname
es_row_no
er_event_data
et_bad_cells.
METHODS catch_doubleclick
FOR EVENT double_click OF cl_gui_alv_grid
IMPORTING e_row
e_column
es_row_no .
ENDCLASS. "lcl_event_receiver DEFINITION
*---------------------------------------------------------------------*
* CLASS lcl_event_receiver IMPLEMENTATION
*---------------------------------------------------------------------*
CLASS lcl_event_receiver IMPLEMENTATION.
METHOD handle_f4.
PERFORM f4 USING e_fieldname
es_row_no
er_event_data
et_bad_cells.
ENDMETHOD. "handle_f4
METHOD catch_doubleclick.
PERFORM atdoubleclick USING e_row
e_column
es_row_no.
ENDMETHOD.
ENDCLASS. "lcl_event_receiver IMPLEMENTATION
DATA: event_receiver TYPE REF TO lcl_event_receiver.
INITIALIZATION.
* gd_repid = sy-repid.
PERFORM fieldcat_init USING gt_fieldcat[].
START-OF-SELECTION.
CALL SCREEN '100'.
*&---------------------------------------------------------------------*
*& Module USER_COMMAND_0100 INPUT
*&---------------------------------------------------------------------*
MODULE user_command_0100 INPUT.
CASE ok_code.
WHEN 'EXIT' OR 'BACK'.
LEAVE PROGRAM.
WHEN 'SAVE'.
PERFORM save.
WHEN 'ALL'.
PERFORM all.
WHEN 'NONE'.
PERFORM none.
ENDCASE.
CLEAR ok_code .
ENDMODULE. " USER_COMMAND_0100 INPUT
*&---------------------------------------------------------------------*
*& Form load_data_into_grid
*&---------------------------------------------------------------------*
FORM load_data_into_grid.
SELECT ekko~ebeln
ekko~lifnr
ekko~aedat
ekko~zzreagree
ekko~zzredate
ekko~zzrereason
ekko~zzreperson
ekko~zzremode
ekko~zzpostatus
lfa1~name1
lfa1~telf1
ekpo~werks
FROM ekko INNER JOIN ekpo ON ekko~ebeln = ekpo~ebeln AND
ekpo~ebelp = '00010'
INNER JOIN lfa1 ON ekko~lifnr = lfa1~lifnr
INTO CORRESPONDING FIELDS OF TABLE itab
WHERE ekko~ebeln IN s_ebeln AND
ekko~lifnr IN s_lifnr AND
ekko~aedat IN s_aedat AND
ekpo~werks = p_werks.
sla-cwidth_opt = 'X'.
sla-zebra = 'X'.
sla-no_toolbar = 'X'.
* sla-edit = 'X' .
CALL METHOD go_grid->set_table_for_first_display
EXPORTING
is_variant = gs_variant
i_save = 'A'
is_layout = sla
* IT_TOOLBAR_EXCLUDING =
CHANGING
it_outtab = itab[]
it_fieldcatalog = gt_fieldcat[]
EXCEPTIONS
invalid_parameter_combination = 1
program_error = 2
too_many_lines = 3
OTHERS = 4.
CALL METHOD go_grid->set_ready_for_input "??????
EXPORTING
i_ready_for_input = 1.
ENDFORM. " load_data_into_grid
*&--------------------------------------------------------------------*
*& Form fieldcat_init
*&--------------------------------------------------------------------*
FORM fieldcat_init USING rt_fieldcat TYPE lvc_t_fcat.
DATA: ls_fieldcat TYPE lvc_s_fcat.
CLEAR ls_fieldcat.
ls_fieldcat-fieldname = 'FLAG'.
ls_fieldcat-scrtext_l = 'Flag'.
ls_fieldcat-checkbox = 'X'.
ls_fieldcat-edit = 'X'.
ls_fieldcat-key = 'X'.
APPEND ls_fieldcat TO rt_fieldcat .
CLEAR ls_fieldcat.
PERFORM frm_catlg_set USING:
'WERKS' '' '门店' '' 'WERKS' 'EKPO' rt_fieldcat,
'EBELN' '' 'PO号码' '' 'EBELN' 'EKKO' rt_fieldcat,
'AEDAT' '' 'PO日期' '' 'AEDAT' 'EKKO' rt_fieldcat,
'LIFNR' '' '供应商' '' 'LIFNR' 'EKKO' rt_fieldcat, "
'NAME1' '' '供应商名称' '' 'NAME1' 'LFA1' rt_fieldcat,
'TELF1' '' '供应商电话' '' 'TELF1' 'LFA1' rt_fieldcat,
'ZZREAGREE' '' '是否同意' 'X' 'ZZREAGREE' 'EKKO' rt_fieldcat,
'ZZREDATE' '' '日期' 'X' 'ZZREDATE' 'EKKO' rt_fieldcat,
'ZZREPERSON' '' '回复人' 'X' 'ZZREPERSON' 'EKKO' rt_fieldcat,
'ZZREMODE' '' '退货方式' 'X' 'ZZREMODE' 'EKKO' rt_fieldcat,
'ZZPOSTATUS' '' 'PO状态' 'X' 'ZZPOSTATUS' 'EKKO' rt_fieldcat,
'ZZREREASON' '' '不同意原因' 'X' 'ZZREREASON' 'EKKO' rt_fieldcat.
gs_f4-fieldname = 'ZZREPERSON'.
gs_f4-register = 'X'.
gs_f4-getbefore = 'X'.
gs_f4-chngeafter = 'X'.
INSERT gs_f4 INTO TABLE gt_f4.
ENDFORM. "fieldcat_init
*---------------------------------------------------------------------*
* FORM frm_catlg_set *
*---------------------------------------------------------------------*
FORM frm_catlg_set USING p_field p_key p_text p_edit ref_f ref_t
rt_fieldcat TYPE lvc_t_fcat .
DATA: tmp_fieldcat TYPE lvc_s_fcat.
tmp_fieldcat-fieldname = p_field.
tmp_fieldcat-key = p_key .
tmp_fieldcat-scrtext_l = p_text.
tmp_fieldcat-edit = p_edit.
tmp_fieldcat-f4availabl = 'X'.
tmp_fieldcat-ref_field = ref_f.
tmp_fieldcat-ref_table = ref_t.
APPEND tmp_fieldcat TO rt_fieldcat .
CLEAR tmp_fieldcat .
ENDFORM. " FRM_CATLG_SET
*&---------------------------------------------------------------------*
*& Form change
*&---------------------------------------------------------------------*
FORM change .
IF go_grid->is_ready_for_input( ) = 0.
CALL METHOD go_grid->set_ready_for_input
EXPORTING
i_ready_for_input = 1.
ELSE.
CALL METHOD go_grid->check_changed_data "????????????
IMPORTING
e_valid = l_valid.
CALL METHOD go_grid->set_ready_for_input
EXPORTING
i_ready_for_input = 0.
CALL METHOD go_grid->refresh_table_display.
ENDIF.
ENDFORM. " change
*&--------------------------------------------------------------------*
*& Form f4
*&--------------------------------------------------------------------*
FORM f4 USING r_fieldname TYPE lvc_fname
rs_row_no TYPE lvc_s_roid
rr_event_data TYPE REF TO cl_alv_event_data
rt_bad_cells TYPE lvc_t_modi.
rr_event_data->m_event_handled = 'X'.
ENDFORM. " F4
*&---------------------------------------------------------------------*
*& Module STATUS_0100 OUTPUT
*&---------------------------------------------------------------------*
MODULE status_0100 OUTPUT.
SET PF-STATUS 'MAIN100'.
gs_variant-report = sy-repid.
IF go_grid IS INITIAL.
CREATE OBJECT go_grid
EXPORTING
i_parent = cl_gui_container=>screen0.
CREATE OBJECT event_receiver.
SET HANDLER event_receiver->handle_f4 FOR go_grid.
CALL METHOD go_grid->register_f4_for_fields
EXPORTING
it_f4 = gt_f4.
SET HANDLER event_receiver->catch_doubleclick FOR go_grid.
IF sy-batch IS INITIAL.
CALL METHOD go_grid->register_edit_event
EXPORTING
i_event_id = cl_gui_alv_grid=>mc_evt_enter.
ENDIF.
PERFORM load_data_into_grid.
ENDIF.
ENDMODULE. " STATUS_0100 OUTPUT
*&---------------------------------------------------------------------*
*& Form save
*&---------------------------------------------------------------------*
FORM save.
CALL METHOD go_grid->check_changed_data
IMPORTING
e_valid = l_valid.
IF l_valid = 'X'.
LOOP AT itab WHERE flag = 'X'.
UPDATE ekko SET
zzreagree = itab-zzreagree
zzredate = itab-zzredate
zzrereason = itab-zzrereason
zzreperson = itab-zzreperson
zzremode = itab-zzremode
zzpostatus = itab-zzpostatus
WHERE ebeln = itab-ebeln .
IF sy-subrc NE 0.
MESSAGE e000(z900) WITH 'Update Error!'.
ENDIF.
ENDLOOP.
IF sy-subrc = 0.
MESSAGE i000(z900) WITH 'Update Success!'.
ENDIF.
ELSE.
MESSAGE e000(z900) WITH 'Data Error'.
ENDIF.
ENDFORM. " save
*&---------------------------------------------------------------------*
*& Form all
*&---------------------------------------------------------------------*
FORM all.
LOOP AT itab.
itab-flag = 'X'.
MODIFY itab.
ENDLOOP.
CALL METHOD go_grid->refresh_table_display.
ENDFORM. " all
*&---------------------------------------------------------------------*
*& Form none
*&---------------------------------------------------------------------*
FORM none.
LOOP AT itab.
itab-flag = ' '.
MODIFY itab.
ENDLOOP.
CALL METHOD go_grid->refresh_table_display.
ENDFORM. " none
*&---------------------------------------------------------------------*
*& Form atdoubleclick
*&---------------------------------------------------------------------*
FORM atdoubleclick USING p_e_row
p_e_column
p_es_row_no.
READ TABLE itab INDEX p_e_row.
IF p_e_column = 'EBELN'.
SET PARAMETER ID 'BES' FIELD itab-ebeln.
CALL FUNCTION 'ME_DISPLAY_PURCHASE_DOCUMENT'
EXPORTING
i_ebeln = itab-ebeln
i_enjoy = 'X'.
ELSEIF p_e_column = 'LIFNR'.
CALL FUNCTION 'MMPUR_VENDOR_DISPLAY'
EXPORTING
im_lifnr = itab-lifnr
im_ekorg = 'B000'.
ENDIF.
ENDFORM. " atdoubleclick
阅读(6193) | 评论(2) | 转发(0) |