SAP 文本框 简单实例
REPORT ZTEST001. DATA: OK_CODE LIKE SY-UCOMM, SAVE_OK LIKE SY-UCOMM. DATA: REF_EDIT_CTN TYPE REF TO CL_GUI_CUSTOM_CONTAINER, REF_EDIT TYPE REF TO CL_GUI_TEXTEDIT. TYPES: OUTTXT(100). DATA: GTLINE TYPE STANDARD TABLE OF OUTTXT, GWLINE TYPE OUTTXT. *----------------------------------------------------------------------* * SCREEN * *----------------------------------------------------------------------* *PARAMETERS PARA TYPE CHAR10. *----------------------------------------------------------------------* * START-OF-SELECTION. * *----------------------------------------------------------------------* START-OF-SELECTION. CALL SCREEN 100. CALL METHOD REF_EDIT->GET_TEXT_AS_R3TABLE * EXPORTING * ONLY_WHEN_MODIFIED = FALSE IMPORTING TABLE = GTLINE * IS_MODIFIED = * EXCEPTIONS * ERROR_DP = 1 * ERROR_CNTL_CALL_METHOD = 2 * ERROR_DP_CREATE = 3 * POTENTIAL_DATA_LOSS = 4 * OTHERS = 5 . IF SY-SUBRC <> 0. * Implement suitable error handling here ENDIF. LOOP AT GTLINE INTO GWLINE. WRITE:/ GWLINE. ENDLOOP. *----------------------------------------------------------------------* * * *----------------------------------------------------------------------* *&---------------------------------------------------------------------* *& Module STATUS_0100 OUTPUT *&---------------------------------------------------------------------* * text *----------------------------------------------------------------------* MODULE STATUS_0100 OUTPUT. SET PF-STATUS 'ZTEST001_GS'. * SET TITLEBAR ''. CHECK REF_EDIT IS INITIAL. CREATE OBJECT REF_EDIT_CTN EXPORTING * PARENT = CONTAINER_NAME = 'C' * STYLE = * LIFETIME = lifetime_default * REPID = * DYNNR = * NO_AUTODEF_PROGID_DYNNR = * EXCEPTIONS * CNTL_ERROR = 1 * CNTL_SYSTEM_ERROR = 2 * CREATE_ERROR = 3 * LIFETIME_ERROR = 4 * LIFETIME_DYNPRO_DYNPRO_LINK = 5 * OTHERS = 6 . IF SY-SUBRC <> 0. MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4. ENDIF. CREATE OBJECT REF_EDIT EXPORTING * MAX_NUMBER_CHARS = * STYLE = 0 WORDWRAP_MODE = cl_gui_textedit=>WORDWRAP_AT_FIXED_POSITION WORDWRAP_POSITION = -1 WORDWRAP_TO_LINEBREAK_MODE = cl_gui_textedit=>true * FILEDROP_MODE = DROPFILE_EVENT_OFF PARENT = REF_EDIT_CTN * LIFETIME = * NAME = * EXCEPTIONS * ERROR_CNTL_CREATE = 1 * ERROR_CNTL_INIT = 2 * ERROR_CNTL_LINK = 3 * ERROR_DP_CREATE = 4 * GUI_TYPE_NOT_SUPPORTED = 5 * OTHERS = 6 . IF SY-SUBRC <> 0. * MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO * WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4. ENDIF. ENDMODULE. *&---------------------------------------------------------------------* *& Module USER_COMMAND_0100 INPUT *&---------------------------------------------------------------------* * text *----------------------------------------------------------------------* MODULE USER_COMMAND_0100 INPUT. SAVE_OK = OK_CODE. CASE SAVE_OK. WHEN 'BACK' OR 'EXIT'. LEAVE TO SCREEN 0. WHEN 'CANC'. LEAVE TO SCREEN 0. WHEN 'CLR'. CLEAR GTLINE[]. CALL METHOD REF_EDIT->SET_TEXT_AS_R3TABLE EXPORTING TABLE = GTLINE EXCEPTIONS ERROR_DP = 1 ERROR_DP_CREATE = 2 OTHERS = 3 . IF SY-SUBRC <> 0. * Implement suitable error handling here ENDIF. ENDCASE. ENDMODULE.