data:beginof itab occurs0. includestructure mara. data:mark type char1. data:endof itab.
data:beginof item occurs0. includestructure t001l. data:mark type char1. data:endof item.
DATA:OK_CODE LIKE SY-UCOMM, S_OK_CODE LIKE SY-UCOMM.
select * from mara into corresponding fieldsoftable itab . select * from t001l into corresponding fieldsoftable item .
*&SPWIZARD: DECLARATION OF TABLECONTROL 'MYTC' ITSELF CONTROLS: MYTC TYPE TABLEVIEW USINGSCREEN0120.
*&SPWIZARD: LINES OF TABLECONTROL 'MYTC' DATA:G_MYTC_LINESLIKE SY-LOOPC.
setSCREEN120."调用屏幕,需要自己增加
*&SPWIZARD: OUTPUT MODULE FOR TC 'MYTC'. DO NOT CHANGE THIS LINE! *&SPWIZARD: UPDATE LINES FOR EQUIVALENT SCROLLBAR MODULE MYTC_CHANGE_TC_ATTR OUTPUT. DESCRIBETABLE ITAB LINES MYTC-lines. ENDMODULE.
*&SPWIZARD: OUTPUT MODULE FOR TC 'MYTC'. DO NOT CHANGE THIS LINE! *&SPWIZARD: GET LINES OF TABLECONTROL MODULE MYTC_GET_LINES OUTPUT. G_MYTC_LINES = SY-LOOPC. ENDMODULE.
*&SPWIZARD: INPUT MODULE FOR TC 'MYTC'. DO NOT CHANGE THIS LINE! *&SPWIZARD: MODIFY TABLE MODULE MYTC_MODIFY INPUT. MODIFY ITAB INDEX MYTC-CURRENT_LINE. ENDMODULE.
*&SPWIZARD: INPUT MODUL FOR TC 'MYTC'. DO NOT CHANGE THIS LINE! *&SPWIZARD: MARK TABLE MODULE MYTC_MARK INPUT. DATA: g_MYTC_wa2 likelineof ITAB. if MYTC-line_sel_mode = 1 and ITAB-MARK = 'X'. loopat ITAB into g_MYTC_wa2 where MARK = 'X'. g_MYTC_wa2-MARK = ''. modify ITAB from g_MYTC_wa2 transporting MARK. endloop. endif. MODIFY ITAB INDEX MYTC-CURRENT_LINE TRANSPORTING MARK. ENDMODULE.
*&SPWIZARD: INPUT MODULE FOR TC 'MYTC'. DO NOT CHANGE THIS LINE! *&SPWIZARD: PROCESS USER COMMAND MODULE MYTC_USER_COMMAND INPUT. OK_CODE = SY-UCOMM.
*&---------------------------------------------------------------------* *&FormUSER_OK_TC* *&---------------------------------------------------------------------* FORM USER_OK_TC USINGP_TC_NAME TYPE DYNFNAM P_TABLE_NAME P_MARK_NAME CHANGING P_OKLIKE SY-UCOMM.
*&SPWIZARD: BEGIN OF LOCAL DATA----------------------------------------* DATA: L_OKTYPE SY-UCOMM, L_OFFSETTYPEI. *&SPWIZARD: END OF LOCAL DATA------------------------------------------*
*&SPWIZARD: Table control specific operations* *&SPWIZARD: evaluate TC name and operations* SEARCH P_OK FOR P_TC_NAME. IF SY-SUBRC <> 0. EXIT. ENDIF. L_OFFSET = STRLEN( P_TC_NAME ) + 1. L_OK = P_OK+L_OFFSET. *&SPWIZARD: execute general and TC specific operations* CASE L_OK. WHEN'INSR'. "insert row PERFORM FCODE_INSERT_ROW USINGP_TC_NAME P_TABLE_NAME. CLEAR P_OK.
WHEN'P--'OR"top of list 'P-'OR"previous page 'P+'OR"next page 'P++'."bottom of list PERFORM COMPUTE_SCROLLING_IN_TC USING P_TC_NAME L_OK. CLEAR P_OK. *WHEN 'L--'."total left *PERFORM FCODE_TOTAL_LEFT USING P_TC_NAME. * *WHEN 'L-'."column left *PERFORM FCODE_COLUMN_LEFT USING P_TC_NAME. * *WHEN 'R+'."column right *PERFORM FCODE_COLUMN_RIGHT USING P_TC_NAME. * *WHEN 'R++'."total right *PERFORM FCODE_TOTAL_RIGHT USING P_TC_NAME. * WHEN'MARK'."mark all filled lines PERFORM FCODE_TC_MARK_LINES USING P_TC_NAME P_TABLE_NAME P_MARK_NAME. CLEAR P_OK.
WHEN'DMRK'."demark all filled lines PERFORM FCODE_TC_DEMARK_LINES USING P_TC_NAME P_TABLE_NAME P_MARK_NAME . CLEAR P_OK.
*WHEN 'SASCEND'OR *'SDESCEND'."sort column *PERFORM FCODE_SORT_TC USING P_TC_NAME *l_ok.
ENDCASE.
ENDFORM." USER_OK_TC
*&---------------------------------------------------------------------* *&FormFCODE_INSERT_ROW* *&---------------------------------------------------------------------* FORM fcode_insert_row USINGP_TC_NAMETYPE DYNFNAM P_TABLE_NAME.
*&SPWIZARD: BEGIN OF LOCAL DATA----------------------------------------* DATA L_LINES_NAMELIKE FELD-NAME. DATA L_SELLINELIKE SY-STEPL. DATA L_LASTLINETYPEI. DATA L_LINETYPEI. DATA L_TABLE_NAMELIKE FELD-NAME. FIELD-SYMBOLS TYPE CXTAB_CONTROL. FIELD-SYMBOLS
TYPESTANDARDTABLE. FIELD-SYMBOLS TYPEI. *&SPWIZARD: END OF LOCAL DATA------------------------------------------*
ASSIGN (P_TC_NAME) TO.
*&SPWIZARD: get the table, which belongs to the tc* CONCATENATE P_TABLE_NAME '[]'INTO L_TABLE_NAME. "table body ASSIGN (L_TABLE_NAME) TO
."not headerline
*&SPWIZARD: get looplines of TableControl* CONCATENATE'G_' P_TC_NAME '_LINES'INTO L_LINES_NAME. ASSIGN (L_LINES_NAME) TO.
*&SPWIZARD: get current line* GETCURSORLINE L_SELLINE. IF SY-SUBRC <> 0." append line to table L_SELLINE = -LINES + 1. *&SPWIZARD: set top line* IF L_SELLINE > . -TOP_LINE = L_SELLINE - + 1 . ELSE. -TOP_LINE = 1. ENDIF. ELSE." insert line into table L_SELLINE = -TOP_LINE + L_SELLINE - 1. L_LASTLINE = -TOP_LINE + - 1. ENDIF. *&SPWIZARD: set new cursor line* L_LINE = L_SELLINE - -TOP_LINE + 1.