主要用USERCOMMAND来实现。
1.选择界面定义需要传输的参数ID:
SELECT-OPTIONS:s_banfn FOR eban-banfn memory id BAN , "采购申请号
s_matnr FOR marc-matnr memory id MAT, "物料号码 后增加
这个ID后面的就是传输的字段了,后面会用到的。
2.调用ALV的时候增加 usercommand事件:
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
i_callback_program = w_repid
i_callback_user_command = 'USER_COMMAND'
is_layout = i_layout
it_fieldcat = i_fieldcat_alv[]
it_events = i_events[]
i_save = 'A'
TABLES
t_outtab = inner_tab.
3.usercommand事件:
FORM user_command USING i_ucomm LIKE sy-ucomm
is_selfield TYPE slis_selfield. CASE i_ucomm.
WHEN '&DATA_SAVE'.
PERFORM save_detail.
WHEN '&IC1'. " Pick
case is_selfield-fieldname.
when 'BANFN'. "如果双击采购申请,则进入ME52N
READ TABLE inner_tab INDEX is_selfield-tabindex.
IF sy-subrc EQ 0.
SET PARAMETER ID 'BAN' FIELD inner_tab-banfn.
CALL TRANSACTION 'ME52N' AND SKIP FIRST SCREEN.
ENDIF.
WHEN 'MATNR'. "如果双击物料号码,则进入MD04
READ TABLE inner_tab INDEX is_selfield-tabindex.
IF sy-subrc EQ 0.
SET PARAMETER ID 'MAT' FIELD inner_tab-matnr.
SET PARAMETER ID 'WRK' FIELD inner_tab-werks.
CALL TRANSACTION 'MD04' AND SKIP FIRST SCREEN.
ENDIF.
ENDCASE.