近日有兄弟问我TC中F4的问题,因为忙,一直没有搞,今天清闲些,研究了一下,程序如下:
REPORT z_barry_tc_f4 .
CONTROLS: tc01 TYPE TABLEVIEW USING SCREEN 0100.
TYPES: BEGIN OF ty_itab,
carrid TYPE spfli-carrid,
connid TYPE spfli-connid,
END OF ty_itab.
DATA: itab TYPE TABLE OF ty_itab ,
wa TYPE ty_itab .
DATA: progname TYPE sy-repid,
dynnum TYPE sy-dynnr,
dynpro_values TYPE TABLE OF dynpread,
field_value LIKE LINE OF dynpro_values .
DATA: ok_code LIKE sy-ucomm.
START-OF-SELECTION.
wa-carrid = 'A01'.
wa-connid = '0001'.
APPEND wa TO itab.
CALL SCREEN 100.
*---------------------------------------------------------------------*
* MODULE TC01_change_tc_attr OUTPUT *
*---------------------------------------------------------------------*
MODULE tc01_change_tc_attr OUTPUT.
DESCRIBE TABLE itab LINES tc01-lines.
ENDMODULE.
*---------------------------------------------------------------------*
* MODULE TC01_modify INPUT *
*---------------------------------------------------------------------*
MODULE tc01_modify INPUT.
READ TABLE itab INTO wa INDEX tc01-current_line
TRANSPORTING NO FIELDS .
IF sy-subrc = 0 .
MODIFY itab FROM wa INDEX tc01-current_line.
ELSE.
INSERT wa INTO itab INDEX tc01-current_line.
ENDIF.
ENDMODULE.
*&---------------------------------------------------------------------*
*& Module status_0100 OUTPUT
*&---------------------------------------------------------------------*
MODULE status_0100 OUTPUT.
SET PF-STATUS 'MAIN100'.
progname = sy-repid.
dynnum = sy-dynnr.
ENDMODULE. " status_0100 OUTPUT
*&---------------------------------------------------------------------*
*& Module USER_COMMAND_0100 INPUT
*&---------------------------------------------------------------------*
MODULE user_command_0100 INPUT.
CASE ok_code.
WHEN 'BACK'.
LEAVE PROGRAM.
ENDCASE.
ENDMODULE. " USER_COMMAND_0100 INPUT
*&---------------------------------------------------------------------*
*& Module showf4 INPUT
*&---------------------------------------------------------------------*
MODULE showf4 INPUT.
DATA: l_selline LIKE sy-stepl,
d_values TYPE TABLE OF dynpread,
f_value LIKE LINE OF dynpro_values .
DATA: tmpitab LIKE itab.
CLEAR tmpitab.
GET CURSOR LINE l_selline.
CALL FUNCTION 'DYNP_VALUES_READ'
EXPORTING
dyname = progname
dynumb = dynnum
request = 'A'
TABLES
dynpfields = d_values.
READ TABLE d_values INTO f_value
WITH KEY fieldname = 'WA-CARRID'
stepl = l_selline.
SELECT carrid connid
FROM spfli
INTO CORRESPONDING FIELDS OF TABLE tmpitab
WHERE carrid = f_value-fieldvalue.
CALL FUNCTION 'F4IF_INT_TABLE_VALUE_REQUEST'
EXPORTING
retfield = 'CONNID'
dynpprog = progname
dynpnr = dynnum
dynprofield = 'CONNECTION'
value_org = 'S'
TABLES
value_tab = tmpitab.
ENDMODULE. " showf4 INPUT
***************
PROCESS BEFORE OUTPUT.
MODULE status_0100.
MODULE tc01_change_tc_attr.
LOOP AT itab
INTO wa
WITH CONTROL tc01
CURSOR tc01-current_line.
ENDLOOP.
PROCESS AFTER INPUT.
MODULE user_command_0100.
LOOP AT itab.
CHAIN.
FIELD wa-carrid.
FIELD wa-connid.
MODULE tc01_modify ON CHAIN-REQUEST.
ENDCHAIN.
ENDLOOP.
PROCESS ON VALUE-REQUEST.
FIELD wa-connid MODULE showf4.
阅读(6105) | 评论(2) | 转发(0) |