如何使用选择屏幕在db中插入数据到自定义表?是否有标准类或方法可以使用或需要创建自定义类?要求:用户在添加选择界面页面输入后,点击"添加"按钮,数据将被插入到db中各自的自定义表中。从这里开始怎么走?
REPORT YTEST3.
tables YNAH_CUS_OBJ_REQ.
tables sscrfields.
type-pools : slis.
"DATA: flag TYPE c.
"DATA it_ucomm TYPE TABLE OF sy-ucomm.
TYPES: BEGIN OF TY_YNAH_CUS_OBJ_REQ, "CREATE STRUCTURE -1
REQID TYPE YNAH_REQ_ID,
REQUESTOR TYPE YNAH_REQUESTOR,
BUSINESS_OWNER TYPE YNAH_BUS_OWN,
FUNCTIONAL_OWNER TYPE YNAH_FUNC_OWN,
REQNUM TYPE YNAH_SERVICE_REQ_NUM,
PROJECT_ID TYPE YNAH_PRO_ID,
SYSTEM_ID TYPE YNAH_SYS_ID,
FUNCTIONAL_AREA TYPE YNAH_FUNC_AREA,
REQUEST_DATE TYPE YNAH_REQ_DATE,
REQUEST_TIME TYPE YNAH_REQ_TIME,
END OF TY_YNAH_CUS_OBJ_REQ.
DATA: IT_YNAH_CUS_OBJ_REQ TYPE TABLE OF TY_YNAH_CUS_OBJ_REQ,
WA_YNAH_CUS_OBJ_REQ TYPE TY_YNAH_CUS_OBJ_REQ.
DATA: it_fcat TYPE slis_t_fieldcat_alv.
DATA: wa_fcat TYPE slis_fieldcat_alv.
DATA MYALV TYPE REF TO CL_SALV_TABLE.
DATA MYFUNCTIONS TYPE REF TO CL_SALV_FUNCTIONS_LIST.
DATA MYCOLUMNS TYPE REF TO CL_SALV_COLUMNS_TABLE.
**********SELECTION-SCREENS*********************
*SELECTION-SCREEN FOR RADIO BUTTON 1
SELECTION-SCREEN BEGIN OF BLOCK menu WITH FRAME TITLE text-000.
selection-screen begin of line.
PARAMETER : P_SEARCH RADIOBUTTON GROUP g1 USER-COMMAND ONE DEFAULT 'X'.
selection-screen comment 7(9) for field p_search.
PARAMETER : P_ADD RADIOBUTTON GROUP g1.
selection-screen comment (9) for field p_add.
selection-screen end of line.
*SELECTION-SCREEN FOR RADIO BUTTON 1
SELECTION-SCREEN BEGIN OF BLOCK rad1 WITH FRAME TITLE text-001.
SELECT-OPTIONS:
s_reqid FOR WA_YNAH_CUS_OBJ_REQ-REQID MODIF ID ONE,
s_req FOR WA_YNAH_CUS_OBJ_REQ-REQUESTOR NO-EXTENSION NO INTERVALS MODIF ID ONE,
s_date FOR WA_YNAH_CUS_OBJ_REQ-REQUEST_DATE MODIF ID ONE.
SELECTION-SCREEN: BEGIN OF LINE,
pushbutton 55(12) BUT1 user-command search MODIF ID ONE.
SELECTION-SCREEN END OF LINE.
SELECTION-SCREEN END OF BLOCK rad1.
*SELECTION-SCREEN FOR RADIO BUTTON 2
SELECTION-SCREEN BEGIN OF BLOCK rad2 WITH FRAME TITLE text-002.
PARAMETER:
p_req TYPE TY_YNAH_CUS_OBJ_REQ-REQUESTOR MODIF ID TWO,
p_busown TYPE TY_YNAH_CUS_OBJ_REQ-BUSINESS_OWNER MODIF ID TWO,
p_funown TYPE TY_YNAH_CUS_OBJ_REQ-FUNCTIONAL_OWNER MODIF ID TWO,
p_srvreq TYPE TY_YNAH_CUS_OBJ_REQ-REQNUM MODIF ID TWO,
p_proid TYPE TY_YNAH_CUS_OBJ_REQ-PROJECT_ID MODIF ID TWO,
p_sysid TYPE TY_YNAH_CUS_OBJ_REQ-SYSTEM_ID MODIF ID TWO,
p_funare TYPE TY_YNAH_CUS_OBJ_REQ-FUNCTIONAL_AREA MODIF ID TWO.
SELECTION-SCREEN: BEGIN OF LINE,
pushbutton 55(12) BUT2 user-command add MODIF ID TWO.
SELECTION-SCREEN END OF LINE.
SELECTION-SCREEN END OF BLOCK rad2.
SELECTION-SCREEN END OF BLOCK menu.
*---------------------------
AT SELECTION-SCREEN OUTPUT.
*---------------------------
BUT1 = 'SEARCH'.
BUT2 = 'ADD'.
*CLICK OF FIRST RADIO BUTTON
"IF p_search = 'X'.
LOOP AT SCREEN.
IF screen-group1 = 'ONE'.
IF P_SEARCH = 'X'.
screen-invisible = '0'.
screen-active = '1'.
ELSE.
screen-invisible = '1'.
screen-active = '0'.
ENDIF.
MODIFY SCREEN.
ENDIF.
IF screen-group1 = 'TWO'.
IF P_ADD = 'X'.
screen-invisible = '0'.
screen-active = '1'.
ELSE.
screen-invisible = '1'.
screen-active = '0' .
ENDIF.
MODIFY SCREEN.
ENDIF.
ENDLOOP.
at selection-screen. "after processing user input
case SSCRFIELDS.
when 'SEARCH'.
SSCRFIELDS-UCOMM = 'ONLI'.
endcase.
"fetch data using select for SEARCH
START-OF-SELECTION.
SELECT *
FROM YNAH_CUS_OBJ_REQ "Database
INTO CORRESPONDING FIELDS OF TABLE IT_YNAH_CUS_OBJ_REQ "Into internal table
WHERE
REQID in s_reqid and
REQUESTOR in s_req and
REQUEST_DATE in s_date.
TRY.
CALL METHOD CL_SALV_TABLE=>FACTORY
IMPORTING
R_SALV_TABLE = MYALV
CHANGING
T_TABLE = IT_YNAH_CUS_OBJ_REQ.
CATCH CX_SALV_MSG.
ENDTRY.
MYCOLUMNS = MYALV->GET_COLUMNS( ).
MYCOLUMNS->SET_OPTIMIZE( ).
MYFUNCTIONS = MYALV->GET_FUNCTIONS( ).
MYFUNCTIONS->SET_ALL( ).
CALL METHOD MYALV->DISPLAY.
我在你的代码中没有看到任何INSERT
或MODIY
语句。你不需要任何自定义类。查看帮助查看这些语句
TABLES YNAH_CUS_OBJ_REQ.
DATA WA TYPE YNAH_CUS_OBJ_REQ.
WA-REQID = '1'.
WA-REQUESTOR = p_req.
WA-BUSINESS_OWNER = p_busown.
...<<<add other fields also>>>
INSERT INTO YNAH_CUS_OBJ_REQ VALUES WA.