SAP 文本框实例

SAP 文本框 简单实例

 

 

  1 REPORT ZTEST001.
  2 
  3 DATA: OK_CODE LIKE SY-UCOMM,
  4       SAVE_OK LIKE SY-UCOMM.
  5 
  6 DATA: REF_EDIT_CTN TYPE REF TO CL_GUI_CUSTOM_CONTAINER,
  7       REF_EDIT     TYPE REF TO CL_GUI_TEXTEDIT.
  8 
  9 TYPES: OUTTXT(100).
 10 DATA: GTLINE TYPE STANDARD TABLE OF OUTTXT,
 11       GWLINE TYPE OUTTXT.
 12 *----------------------------------------------------------------------*
 13 * SCREEN                                                               *
 14 *----------------------------------------------------------------------*
 15 *PARAMETERS PARA TYPE CHAR10.
 16 
 17 *----------------------------------------------------------------------*
 18 * START-OF-SELECTION.                                                  *
 19 *----------------------------------------------------------------------*
 20 START-OF-SELECTION.
 21 
 22  CALL SCREEN 100.
 23 
 24  CALL METHOD REF_EDIT->GET_TEXT_AS_R3TABLE
 25 *   EXPORTING
 26 *     ONLY_WHEN_MODIFIED     = FALSE
 27    IMPORTING
 28      TABLE                  = GTLINE
 29 *     IS_MODIFIED            =
 30 *   EXCEPTIONS
 31 *     ERROR_DP               = 1
 32 *     ERROR_CNTL_CALL_METHOD = 2
 33 *     ERROR_DP_CREATE        = 3
 34 *     POTENTIAL_DATA_LOSS    = 4
 35 *     OTHERS                 = 5
 36          .
 37  IF SY-SUBRC <> 0.
 38 *  Implement suitable error handling here
 39  ENDIF.
 40 
 41  LOOP AT GTLINE INTO GWLINE.
 42    WRITE:/ GWLINE.
 43  ENDLOOP.
 44 
 45 *----------------------------------------------------------------------*
 46 *                                                                      *
 47 *----------------------------------------------------------------------*
 48 *&---------------------------------------------------------------------*
 49 *&      Module  STATUS_0100  OUTPUT
 50 *&---------------------------------------------------------------------*
 51 *       text
 52 *----------------------------------------------------------------------*
 53 MODULE STATUS_0100 OUTPUT.
 54   SET PF-STATUS 'ZTEST001_GS'.
 55 *  SET TITLEBAR ''.
 56 
 57   CHECK REF_EDIT IS INITIAL.
 58 
 59   CREATE OBJECT REF_EDIT_CTN
 60     EXPORTING
 61 *      PARENT                      =
 62       CONTAINER_NAME               = 'C'
 63 *      STYLE                       =
 64 *      LIFETIME                    = lifetime_default
 65 *      REPID                       =
 66 *      DYNNR                       =
 67 *      NO_AUTODEF_PROGID_DYNNR     =
 68 *    EXCEPTIONS
 69 *      CNTL_ERROR                  = 1
 70 *      CNTL_SYSTEM_ERROR           = 2
 71 *      CREATE_ERROR                = 3
 72 *      LIFETIME_ERROR              = 4
 73 *      LIFETIME_DYNPRO_DYNPRO_LINK = 5
 74 *      OTHERS                      = 6
 75       .
 76   IF SY-SUBRC <> 0.
 77    MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
 78               WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
 79   ENDIF.
 80 
 81   CREATE OBJECT REF_EDIT
 82     EXPORTING
 83 *      MAX_NUMBER_CHARS       =
 84 *      STYLE                  = 0
 85       WORDWRAP_MODE          = cl_gui_textedit=>WORDWRAP_AT_FIXED_POSITION
 86       WORDWRAP_POSITION      = -1
 87       WORDWRAP_TO_LINEBREAK_MODE = cl_gui_textedit=>true
 88 *      FILEDROP_MODE          = DROPFILE_EVENT_OFF
 89       PARENT                 = REF_EDIT_CTN
 90 *      LIFETIME               =
 91 *      NAME                   =
 92 *    EXCEPTIONS
 93 *      ERROR_CNTL_CREATE      = 1
 94 *      ERROR_CNTL_INIT        = 2
 95 *      ERROR_CNTL_LINK        = 3
 96 *      ERROR_DP_CREATE        = 4
 97 *      GUI_TYPE_NOT_SUPPORTED = 5
 98 *      OTHERS                 = 6
 99       .
100   IF SY-SUBRC <> 0.
101 *   MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
102 *              WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
103   ENDIF.
104 
105 ENDMODULE.
106 *&---------------------------------------------------------------------*
107 *&      Module  USER_COMMAND_0100  INPUT
108 *&---------------------------------------------------------------------*
109 *       text
110 *----------------------------------------------------------------------*
111 MODULE USER_COMMAND_0100 INPUT.
112 
113   SAVE_OK = OK_CODE.
114 
115   CASE SAVE_OK.
116     WHEN 'BACK' OR 'EXIT'.
117       LEAVE TO SCREEN 0.
118     WHEN 'CANC'.
119       LEAVE TO SCREEN 0.
120     WHEN 'CLR'.
121       CLEAR GTLINE[].
122 
123       CALL METHOD REF_EDIT->SET_TEXT_AS_R3TABLE
124         EXPORTING
125           TABLE           = GTLINE
126         EXCEPTIONS
127           ERROR_DP        = 1
128           ERROR_DP_CREATE = 2
129           OTHERS          = 3
130               .
131       IF SY-SUBRC <> 0.
132 *       Implement suitable error handling here
133       ENDIF.
134 
135   ENDCASE.
136 ENDMODULE.

 

posted @ 2017-11-08 16:32  明大叔  阅读(1379)  评论(0编辑  收藏  举报