• ALV后加DIALOG练习


    操作的是请求号的表,E070,E07T,E070A

    添加带表控件的Table  Control 在自定义按钮,删除原来的按钮

     待补充

    *屏幕调用第一次 PBO
    *屏幕操作 PAI->PBO
    *下拉列表 VRM_SET_VALUES
    *下拉列表onchange  给下拉列表添加功能码
    *PBO对屏幕参数的改变不能影响屏幕操作对屏幕参数的改变,POB中屏幕参数操作要判断或改到PAI中(依据OK_CODE判断)
    *焦点设一个全局变量  PAI赋值,PBO设置,清空值
    *SET CURSOR FIELD '控件名' LINE 行数 OFFSET 列数.   不是table的LINE后不写
    *OK_CODE在PAI后要清空,用OK_SAVE备份,防止滚轮双击等操作再次调用之前的UCOMM
    *同步数据使用全删除后在全导入
    *
    CXTAB_COLUMN----Table Control的列控制信息结构
    *CXTAB_COLUMN-SCREEN-NAME、INPUT、

    REPORT ZTEST034. INCLUDE ZTEST034_TOP. INCLUDE ZTEST034_100_PBO. INCLUDE ZTEST034_100_PAI. INCLUDE ZTEST034_FORM. INITIALIZATION. S_TRKORR-SIGN = 'I'. S_TRKORR-OPTION = 'CP'. S_TRKORR-LOW = 'DEV*'. APPEND S_TRKORR. S_AS4USE-SIGN = 'I'. S_AS4USE-OPTION = 'EQ'. S_AS4USE-LOW = SY-UNAME. APPEND S_AS4USE. AT SELECTION-SCREEN OUTPUT. AT SELECTION-SCREEN. START-OF-SELECTION. PERFORM GET_DATA. END-OF-SELECTION. PERFORM ALV_DISPLAY. *&---------------------------------------------------------------------* *& Form GET_DATA *&---------------------------------------------------------------------* * text *----------------------------------------------------------------------* * --> p1 text * <-- p2 text *----------------------------------------------------------------------* FORM GET_DATA . "E070表中请求号包括上下两层请求号,STRKORR为上层请求号 "要查出所有符合条件请求号 SELECT * FROM E070 INTO CORRESPONDING FIELDS OF TABLE gt_trans WHERE ( TRKORR IN S_TRKORR OR STRKORR IN S_TRKORR ) AND TRSTATUS IN S_TRSTAT AND AS4USER IN S_AS4USE. IF gt_trans IS NOT INITIAL. SELECT TRKORR AS4TEXT FROM E07T INTO CORRESPONDING FIELDS OF TABLE GT_E07T FOR ALL ENTRIES IN gt_trans WHERE TRKORR = gt_trans-TRKORR AND LANGU = '1'. SELECT * FROM E070A INTO CORRESPONDING FIELDS OF TABLE GT_E070A1 FOR ALL ENTRIES IN gt_trans WHERE TRKORR = gt_trans-TRKORR. ENDIF. GT_E070A2[] = GT_E070A[]. ENDFORM. " GET_DATA *&---------------------------------------------------------------------* *& Form ALV_DISPLAY *&---------------------------------------------------------------------* * text *----------------------------------------------------------------------* * --> p1 text * <-- p2 text *----------------------------------------------------------------------* FORM ALV_DISPLAY . PERFORM BUILD_FIELDCAT. PERFORM DEAL_DATA. PERFORM ALV_GRID. ENDFORM. " ALV_DISPLAY *&---------------------------------------------------------------------* *& Form DEAL_DATA *&---------------------------------------------------------------------* * text *----------------------------------------------------------------------* * --> p1 text * <-- p2 text *----------------------------------------------------------------------* FORM DEAL_DATA . LOOP AT GT_TRANS INTO GW_TRANS. IF GW_TRANS-TRSTATUS = 'D'. GW_TRANS-TRSTATUS_TX = '可修改的'. ELSEIF GW_TRANS-TRSTATUS = 'L'. GW_TRANS-TRSTATUS_TX = '可修改,受保护'. ELSEIF GW_TRANS-TRSTATUS = 'O'. GW_TRANS-TRSTATUS_TX = '已开始释放'. ELSEIF GW_TRANS-TRSTATUS = 'R'. GW_TRANS-TRSTATUS_TX = '已释放'. ELSEIF GW_TRANS-TRSTATUS = 'N'. GW_TRANS-TRSTATUS_TX = '已释放(含对已修复对象的导入保护)'. ENDIF. READ TABLE GT_E07T WITH KEY TRKORR = gw_trans-TRKORR. IF SY-SUBRC = 0. GW_TRANS-AS4TEXT = GT_E07T-AS4TEXT. ENDIF. MODIFY GT_TRANS FROM GW_TRANS. CLEAR: GW_TRANS,GT_E07T. ENDLOOP. ENDFORM. " DEAL_DATA *&---------------------------------------------------------------------* *& Form BUILD_FIELDCAT *&---------------------------------------------------------------------* * text *----------------------------------------------------------------------* * --> p1 text * <-- p2 text *----------------------------------------------------------------------* FORM BUILD_FIELDCAT . DEFINE %%FIELD. CLEAR:GW_FIELDCAT. GW_FIELDCAT-FIELDNAME = &1. GW_FIELDCAT-COLTEXT = &2. APPEND GW_FIELDCAT TO GT_FIELDCAT. END-OF-DEFINITION. %%FIELD 'TRKORR' '请求' . %%FIELD 'TRFUNCTION' '请求类型' . %%FIELD 'TRSTATUS_TX' '状态' . %%FIELD 'TARSYSTEM' '目标系统' . %%FIELD 'KORRDEV' '类别' . %%FIELD 'AS4USER' '所有者' . %%FIELD 'AS4DATE' '上次更改日期' . %%FIELD 'AS4TIME' '上次更改时间' . %%FIELD 'STRKORR' '高级别请求' . %%FIELD 'AS4TEXT' '请求描述' . %%FIELD 'RESULT' '结果' . ENDFORM. " BUILD_FIELDCAT *&---------------------------------------------------------------------* *& Form ALV_GRID *&---------------------------------------------------------------------* * text *----------------------------------------------------------------------* * --> p1 text * <-- p2 text *----------------------------------------------------------------------* FORM ALV_GRID . GW_LAYOUT-ZEBRA = 'X'. GW_LAYOUT-CWIDTH_OPT = 'X'. GW_LAYOUT-SEL_MODE = 'D'. GW_LAYOUT-BOX_FNAME = 'MARK'. CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY_LVC' EXPORTING I_CALLBACK_PROGRAM = SY-REPID I_CALLBACK_PF_STATUS_SET = 'GC_PF_STATUS' I_CALLBACK_USER_COMMAND = 'USER_COMMAND' IS_LAYOUT_LVC = GW_LAYOUT IT_FIELDCAT_LVC = GT_FIELDCAT * I_DEFAULT = 'X' I_SAVE = 'A' TABLES T_OUTTAB = GT_TRANS[] * EXCEPTIONS * PROGRAM_ERROR = 1 * OTHERS = 2 . IF SY-SUBRC <> 0. * MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO * WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4. ENDIF. ENDFORM. " ALV_GRID *&---------------------------------------------------------------------* *& Form GC_PF_STATUS *&---------------------------------------------------------------------* * text *----------------------------------------------------------------------* * --> p1 text * <-- p2 text *----------------------------------------------------------------------* FORM GC_PF_STATUS USING RT_EXTAB TYPE SLIS_T_EXTAB. * 设置标题栏 SET TITLEBAR 'TITAL001'. SET PF-STATUS 'STATUS001' EXCLUDING RT_EXTAB. ENDFORM. "GC_PF_STATUS *&---------------------------------------------------------------------* *& Form USER_COMMAND *&---------------------------------------------------------------------* * text *----------------------------------------------------------------------* * --> p1 text * <-- p2 text *----------------------------------------------------------------------* FORM USER_COMMAND USING P_UCOMM LIKE SY-UCOMM P_SELFIELD TYPE SLIS_SELFIELD. P_SELFIELD-REFRESH = 'X'."自动刷新 CASE P_UCOMM. * WHEN '&F03'. * LEAVE TO SCREEN 0. * WHEN '&F15' OR '&F12'. * LEAVE PROGRAM. WHEN 'UPDATE'."R->D LOOP AT GT_TRANS INTO GW_TRANS WHERE MARK = 'X' AND TRSTATUS = 'R'. UPDATE E070 SET TRSTATUS = 'D' WHERE TRKORR = GW_TRANS-TRKORR. IF SY-SUBRC = 0. COMMIT WORK . GW_TRANS-TRSTATUS = 'D'. GW_TRANS-TRSTATUS_TX = '可修改'. GW_TRANS-RESULT = '修改成功'. ENDIF. MODIFY GT_TRANS FROM GW_TRANS. CLEAR: GW_TRANS. ENDLOOP. WHEN 'UPDATE2'."D->R LOOP AT GT_TRANS INTO GW_TRANS WHERE MARK = 'X' AND TRSTATUS = 'D' AND TRFUNCTION = 'K'. READ TABLE GT_E070A1 INTO GW_E070A WITH KEY TRKORR = gw_trans-TRKORR ATTRIBUTE = 'EXPTIMESTAMP'. "E070A属性只对类型为K的请求号存在,所以根据上层判断 IF SY-SUBRC = 0. UPDATE E070 SET TRSTATUS = 'R' WHERE ( TRKORR = GW_TRANS-TRKORR OR STRKORR = GW_TRANS-TRKORR )."修改库表 IF SY-SUBRC = 0. COMMIT WORK . GW_TRANS-TRSTATUS = 'R'. GW_TRANS-TRSTATUS_TX = '已释放'. GW_TRANS-RESULT = '修改成功'. ENDIF. MODIFY GT_TRANS FROM GW_TRANS. "修改ALV内表中的下层请求号,方便展示 MODIFY GT_TRANS FROM GW_TRANS TRANSPORTING TRSTATUS TRSTATUS_TX RESULT WHERE STRKORR = GW_TRANS-TRKORR. ELSE. GW_TRANS-RESULT = '属性EXPTIMESTAMP不存在,请手动释放'. ENDIF. CLEAR: GW_TRANS. ENDLOOP. WHEN 'ATTRI'."显示修改请求号的属性,DIALOG练习 LOOP AT GT_TRANS INTO GW_TRANS WHERE MARK = 'X' AND TRSTATUS = 'D' AND TRFUNCTION = 'K'. LOOP AT GT_E070A1 INTO GW_E070A WHERE TRKORR = gw_trans-TRKORR. APPEND GW_E070A TO GT_E070A. CLEAR:GW_E070A. ENDLOOP. CLEAR:GW_TRANS. ENDLOOP. GT_E070A2[] = GT_E070A[]. READ TABLE GT_TRANS INTO GW_TRANS WITH KEY MARK = 'X' TRSTATUS = 'D' TRFUNCTION = 'K'. IF SY-SUBRC = 0. CALL SCREEN 0100. ELSE. MESSAGE '请选择一行类型为K、状态可修改的数据!!!' TYPE 'I'. ENDIF. ENDCASE. ENDFORM. "USER_COMMAND *&---------------------------------------------------------------------* *& Form TABLE_E070A_MODIFY *&---------------------------------------------------------------------* * text *----------------------------------------------------------------------* * --> p1 text * <-- p2 text *----------------------------------------------------------------------* FORM TABLE_E070A_MODIFY . DATA: lcx_error TYPE REF TO cx_root, "cx_sy_sql_error . "cx_sy_open_sql_db."异常 lcx_error2 TYPE REF TO cx_root," err_text TYPE c LENGTH 1000. DATA: L_ANSWER, L_NUM TYPE I. DATA: LT_E070A LIKE E070A OCCURS 0, LW_E070A LIKE LINE OF LT_E070A. * TRY."想利用哈希表关键字段不能重复来判断内表有重复数据,哈希表数据重复异常直接爆红,catch不到 * GT_E070A_HASH[] = GT_E070A[]. * CATCH cx_root INTO lcx_error2. * err_text = lcx_error->IF_MESSAGE~GET_TEXT( ). * MESSAGE err_text TYPE 'E'. * ENDTRY. "保存前弹出提示消息 CALL FUNCTION 'POPUP_TO_CONFIRM_STEP' EXPORTING TEXTLINE1 = TEXT-T01 TITEL = TEXT-T02 IMPORTING ANSWER = L_ANSWER. CHECK L_ANSWER = 'J'. LOOP AT GT_E070A INTO GW_E070A."GT_E070A多了一个line字段 LW_E070A-TRKORR = GW_E070A-TRKORR. LW_E070A-POS = GW_E070A-POS. LW_E070A-ATTRIBUTE = GW_E070A-ATTRIBUTE. LW_E070A-REFERENCE = GW_E070A-REFERENCE. APPEND LW_E070A TO LT_E070A. CLEAR:LW_E070A,GW_E070A. ENDLOOP. "检查主键重复 SORT GT_E070A BY TRKORR POS. LOOP AT LT_E070A INTO LW_E070A. AT NEW POS. L_NUM = 0. ENDAT. L_NUM = L_NUM + 1. IF L_NUM >= 2. MESSAGE '存在主键重复内容!!!' TYPE 'E'. ENDIF. ENDLOOP. TRY. DELETE FROM E070A WHERE TRKORR = E070-TRKORR. MODIFY E070A FROM TABLE LT_E070A. CATCH cx_sy_open_sql_db INTO lcx_error. err_text = lcx_error->IF_MESSAGE~GET_TEXT( ). SY-SUBRC = 4. ENDTRY. IF SY-SUBRC <> 0. ROLLBACK WORK. MESSAGE err_text TYPE 'E'. ELSE. COMMIT WORK. MESSAGE '同步成功!!!' TYPE 'S'. ENDIF. ENDFORM. " TABLE_E070A_MODIFY *&---------------------------------------------------------------------* *& Form LIST_TABLE_MODIFY *&---------------------------------------------------------------------* * text *----------------------------------------------------------------------* * --> p1 text * <-- p2 text *----------------------------------------------------------------------* FORM LIST_TABLE_MODIFY . CLEAR: GT_E070A[]."清空GT_E070A[],利用GT_E070A2[]只把下拉框中请求号的属性传入GT_E070A[] READ TABLE GT_TRANS INTO GW_TRANS WITH KEY TRKORR = E070-TRKORR. E070-TRKORR = GW_TRANS-TRKORR. E070-TRSTATUS = GW_TRANS-TRSTATUS. MAKT-MAKTX = GW_TRANS-TRSTATUS_TX. E070-AS4USER = GW_TRANS-AS4USER. E07T-AS4TEXT = GW_TRANS-AS4TEXT. LOOP AT GT_E070A2 INTO GW_E070A WHERE TRKORR = E070-TRKORR. APPEND GW_E070A TO GT_E070A. CLEAR:GW_E070A. ENDLOOP. CLEAR GW_TRANS. ENDFORM. " LIST_TABLE_MODIFY

    include 

    *&---------------------------------------------------------------------*
    *&  包括                ZTEST034_TOP
    *&---------------------------------------------------------------------*
    
    TYPE-POOLS:SLIS,vrm.
    TABLES:E070,E070A,E07T,MAKT.
    
    DATA: GW_LAYOUT TYPE LVC_S_LAYO,
          GW_FIELDCAT TYPE LVC_S_FCAT,
          GT_FIELDCAT TYPE LVC_T_FCAT.
    
    
    TYPES:BEGIN OF gy_trans,
          MARK(1),
          TRKORR      TYPE TRKORR,     "请求/任务
          TRFUNCTION  TYPE TRFUNCTION, "请求/任务的类型
          TRSTATUS    TYPE TRSTATUS,   "请求/任务状态
          TRSTATUS_tx(20),
          TARSYSTEM   TYPE TR_TARGET,  "请求的传输目标
          KORRDEV     TYPE TRCATEG,    "请求或任务类型
          AS4USER     TYPE TR_AS4USER, "请求或任务的所有者
          AS4DATE     TYPE AS4DATE,    "最后更改的日期
          AS4TIME     TYPE AS4TIME,    "上次更改时间
          STRKORR     TYPE STRKORR,    "高级别请求
          AS4TEXT        TYPE AS4TEXT,    "资源库对象的简短描述
          RESULT(100),
          END OF gy_trans.
    
    TYPES:BEGIN OF GY_E070A ,
          LINE      TYPE CHAR1,
          TRKORR    TYPE TRKORR,
          POS       TYPE DDPOSITION,
          ATTRIBUTE TYPE TRATTR,
          REFERENCE TYPE TRVALUE,
          END OF GY_E070A.
    
    DATA: gw_trans TYPE gy_trans,
          gt_trans TYPE gy_trans OCCURS 0.
    
    DATA: GT_E070A TYPE GY_E070A OCCURS 0 ,
          GT_E070A1 TYPE GY_E070A OCCURS 0 ,
          GT_E070A2 TYPE GY_E070A OCCURS 0 ,
          GT_E070A_HASH TYPE HASHED TABLE OF GY_E070A WITH UNIQUE KEY TRKORR POS,
          GW_E070A TYPE GY_E070A.
    
    DATA: BEGIN OF GT_E07T OCCURS 0,
          TRKORR  TYPE TRKORR,
          AS4TEXT TYPE AS4TEXT,
          END OF GT_E07T.
    
    SELECTION-SCREEN BEGIN OF BLOCK b1 WITH FRAME TITLE text-001.
      SELECT-OPTIONS: S_TRKORR   FOR E070-TRKORR,
                      S_TRSTAT   FOR E070-TRSTATUS,
                      S_AS4USE  FOR E070-AS4USER.
    SELECTION-SCREEN END OF BLOCK b1.
    
    *&SPWIZARD: DECLARATION OF TABLECONTROL 'Z34_E070A' ITSELF
    CONTROLS: Z34_E070A TYPE TABLEVIEW USING SCREEN 0100.
    
    DATA:     GS_COLS TYPE CXTAB_COLUMN."Table Control的列控制信息结构
    *&SPWIZARD: LINES OF TABLECONTROL 'Z34_E070A'
    DATA:     G_Z34_E070A_LINES  LIKE SY-LOOPC.
    
    DATA:     OK_CODE LIKE SY-UCOMM,"屏幕功能码
              OK_SAVE LIKE SY-UCOMM."屏幕功能码备份
    
    DATA:     G_LINE TYPE I,"全局焦点,PAI赋值,PBO使用设定焦点,PBO最后清空
              G_GUISTATUE(50)."显示修改按钮
    *&---------------------------------------------------------------------*
    *&  包括                ZTEST034_PBO
    *&---------------------------------------------------------------------*
    
    
    *&---------------------------------------------------------------------*
    *&      Module  STATUS_0100  OUTPUT
    *&---------------------------------------------------------------------*
    *       text
    *----------------------------------------------------------------------*
    MODULE STATUS_0100 OUTPUT.
      "修改gui按钮是否显示
      DATA: FCODE LIKE SY-UCOMM OCCURS 0 WITH HEADER LINE.
      IF G_GUISTATUE = 'DISPLAY' OR G_GUISTATUE IS INITIAL.
        APPEND 'INSR' TO FCODE.
        APPEND 'DELE' TO FCODE.
        SET PF-STATUS 'STATUS002' EXCLUDING FCODE.
      ELSEIF G_GUISTATUE = 'EDIT'.
        SET PF-STATUS 'STATUS002'.
      ENDIF.
    
      SET TITLEBAR 'TITAL002'.
    ENDMODULE.                 " STATUS_0100  OUTPUT
    *&---------------------------------------------------------------------*
    *&      Module  SET_DIS_EDIT  OUTPUT
    *&---------------------------------------------------------------------*
    *       text
    *----------------------------------------------------------------------*
    MODULE SET_DIS_EDIT OUTPUT.
      "TC字段输入输出切换
      "隐藏某列用字段长度 vislength = 0 设置,
      IF G_GUISTATUE = 'DISPLAY'.
        LOOP AT Z34_E070A-COLS INTO GS_COLS.
          IF GS_COLS-SCREEN-NAME = 'GW_E070A-TRKORR' OR GS_COLS-SCREEN-NAME = 'GW_E070A-POS' OR
              GS_COLS-SCREEN-NAME = 'GW_E070A-ATTRIBUTE' OR GS_COLS-SCREEN-NAME = 'GW_E070A-REFERENCE'.
    
            GS_COLS-SCREEN-INPUT = '0'.
          ENDIF.
          MODIFY  Z34_E070A-COLS FROM GS_COLS.
        ENDLOOP.
      ELSEIF G_GUISTATUE = 'EDIT'.
        LOOP AT Z34_E070A-COLS INTO GS_COLS.
          IF GS_COLS-SCREEN-NAME = 'GW_E070A-TRKORR' OR GS_COLS-SCREEN-NAME = 'GW_E070A-POS' OR
              GS_COLS-SCREEN-NAME = 'GW_E070A-ATTRIBUTE' OR GS_COLS-SCREEN-NAME = 'GW_E070A-REFERENCE'.
    
            GS_COLS-SCREEN-INPUT = '1'."可输入
            IF GS_COLS-SCREEN-NAME = 'GW_E070A-TRKORR' OR GS_COLS-SCREEN-NAME = 'GW_E070A-POS'.
              GS_COLS-SCREEN-REQUIRED = '1'."必输
            ENDIF.
          ENDIF.
          MODIFY  Z34_E070A-COLS FROM GS_COLS.
        ENDLOOP.
      ENDIF.
    ENDMODULE.                 " SET_DIS_EDIT  OUTPUT
    *&---------------------------------------------------------------------*
    *&      Module  SET_HEADER  OUTPUT
    *&---------------------------------------------------------------------*
    *       text
    *----------------------------------------------------------------------*
    MODULE SET_HEADER OUTPUT.
      DATA: L_FIELD TYPE VRM_ID,
            LT_VALUES TYPE VRM_VALUES,
            LW_VALUE LIKE LINE OF LT_VALUES.
      DATA: LINE TYPE I.
    
      IF LT_VALUES IS INITIAL.
        CLEAR: GT_E070A[]."清空GT_E070A[],利用GT_E070A2[]只把下拉框中请求号的属性传入GT_E070A[]
        LINE = 1.
        LOOP AT GT_TRANS INTO GW_TRANS WHERE MARK = 'X' AND TRSTATUS = 'D' AND TRFUNCTION = 'K'.
          IF LINE = 1."初始值
            E070-TRKORR = GW_TRANS-TRKORR.
            E070-TRSTATUS = GW_TRANS-TRSTATUS.
            MAKT-MAKTX = GW_TRANS-TRSTATUS_tx."描述字段,名字随便起的
            E070-AS4USER = GW_TRANS-AS4USER.
            E07T-AS4TEXT = GW_TRANS-AS4TEXT.
            LOOP AT GT_E070A2 INTO GW_E070A WHERE TRKORR = E070-TRKORR.
              APPEND GW_E070A TO GT_E070A.
              CLEAR:GW_E070A.
            ENDLOOP.
          ENDIF.
          LW_VALUE-KEY = GW_TRANS-TRKORR.
          LW_VALUE-TEXT = GW_TRANS-TRKORR.
          APPEND LW_VALUE TO LT_VALUES.
          CLEAR:GW_TRANS,LW_VALUE.
          LINE = LINE + 1.
        ENDLOOP.
    
        CALL FUNCTION 'VRM_SET_VALUES'
          EXPORTING
            ID     = 'E070-TRKORR'
            VALUES = LT_VALUES.
      ENDIF.
    ENDMODULE.                 " SET_HEADER  OUTPUT
    
    *&SPWIZARD: OUTPUT MODULE FOR TC 'Z34_E070A'. DO NOT CHANGE THIS LINE!
    *&SPWIZARD: UPDATE LINES FOR EQUIVALENT SCROLLBAR
    MODULE Z34_E070A_CHANGE_TC_ATTR OUTPUT.
      DESCRIBE TABLE GT_E070A LINES Z34_E070A-lines.
    ENDMODULE.                    "Z34_E070A_CHANGE_TC_ATTR OUTPUT
    
    *&SPWIZARD: OUTPUT MODULE FOR TC 'Z34_E070A'. DO NOT CHANGE THIS LINE!
    *&SPWIZARD: GET LINES OF TABLECONTROL
    MODULE Z34_E070A_GET_LINES OUTPUT.
      G_Z34_E070A_LINES = SY-LOOPC.
    ENDMODULE.                    "Z34_E070A_GET_LINES OUTPUT
    *&---------------------------------------------------------------------*
    *&      Module  SET_CURSOR  OUTPUT
    *&---------------------------------------------------------------------*
    *       text
    *----------------------------------------------------------------------*
    MODULE SET_CURSOR OUTPUT.
      "设置焦点
      SET CURSOR FIELD 'GW_E070A-TRKORR' LINE G_LINE.
      CLEAR:G_LINE.
    ENDMODULE.                 " SET_CURSOR  OUTPUT
    *&---------------------------------------------------------------------*
    *&  包括                ZTEST034_PAI
    *&---------------------------------------------------------------------*
    
    *&SPWIZARD: INPUT MODULE FOR TC 'Z34_E070A'. DO NOT CHANGE THIS LINE!
    *&SPWIZARD: MODIFY TABLE
    MODULE Z34_E070A_MODIFY INPUT.
    
      IF GW_E070A-ATTRIBUTE = 'EXPTIMESTAMP' .
        MESSAGE '未释放请求号添加EXPTIMESTAMP属性后将无法释放' TYPE 'W'.
      ENDIF.
    
      MODIFY GT_E070A
        FROM GW_E070A
        INDEX Z34_E070A-CURRENT_LINE.
      "添加到属性的总表里,保持数据一致
      APPEND GW_E070A TO GT_E070A2.
    ENDMODULE.
    
    *&SPWIZARD: INPUT MODUL FOR TC 'Z34_E070A'. DO NOT CHANGE THIS LINE!
    *&SPWIZARD: MARK TABLE
    MODULE Z34_E070A_MARK INPUT.
      DATA: g_Z34_E070A_wa2 like line of GT_E070A.
        if Z34_E070A-line_sel_mode = 1
        and GW_E070A-LINE = 'X'.
         loop at GT_E070A into g_Z34_E070A_wa2
           where LINE = 'X'.
           g_Z34_E070A_wa2-LINE = ''.
           modify GT_E070A
             from g_Z34_E070A_wa2
             transporting LINE.
         endloop.
      endif.
      MODIFY GT_E070A
        FROM GW_E070A
        INDEX Z34_E070A-CURRENT_LINE
        TRANSPORTING LINE.
    ENDMODULE.
    
    *&SPWIZARD: INPUT MODULE FOR TC 'Z34_E070A'. DO NOT CHANGE THIS LINE!
    *&SPWIZARD: PROCESS USER COMMAND
    MODULE Z34_E070A_USER_COMMAND INPUT.
    *  OK_CODE = SY-UCOMM.
      OK_SAVE = OK_CODE.
      PERFORM USER_OK_TC USING    'Z34_E070A'
                                  'GT_E070A'
                                  'LINE'
                         CHANGING OK_CODE.
    *  SY-UCOMM = OK_CODE.
      CLEAR:OK_CODE.
    ENDMODULE.
    *&---------------------------------------------------------------------*
    *&  包括                ZTEST034_FORM
    *&---------------------------------------------------------------------*
    *----------------------------------------------------------------------*
    *   INCLUDE TABLECONTROL_FORMS                                         *
    *----------------------------------------------------------------------*
    
    *&---------------------------------------------------------------------*
    *&      Form  USER_OK_TC                                               *
    *&---------------------------------------------------------------------*
     FORM USER_OK_TC USING    P_TC_NAME TYPE DYNFNAM
                              P_TABLE_NAME
                              P_MARK_NAME
                     CHANGING P_OK      LIKE SY-UCOMM.
    
    *&SPWIZARD: BEGIN OF LOCAL DATA----------------------------------------*
       DATA: L_OK              TYPE SY-UCOMM,
             L_OFFSET          TYPE I.
    *&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 P_OK.
         WHEN 'BACK'.
           LEAVE TO SCREEN 0.
         WHEN 'CANCLE' OR 'EXIT'.
           LEAVE PROGRAM.
         WHEN 'ANZG'.
           PERFORM DIS_EDIT.
         WHEN 'INSR'.                      "insert row
           PERFORM FCODE_INSERT_ROW USING    P_TC_NAME
                                             P_TABLE_NAME.
           CLEAR P_OK.
    
         WHEN 'DELE'.                      "delete row
           PERFORM FCODE_DELETE_ROW USING    P_TC_NAME
                                             P_TABLE_NAME
                                             P_MARK_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 .
         WHEN 'SAVE'.
           PERFORM TABLE_E070A_MODIFY.
         WHEN 'ZLIST001'.
           PERFORM LIST_TABLE_MODIFY.
    
    
           CLEAR P_OK.
    
    *     WHEN 'SASCEND'   OR
    *          'SDESCEND'.                  "sort column
    *       PERFORM FCODE_SORT_TC USING P_TC_NAME
    *                                   l_ok.
    
       ENDCASE.
    
     ENDFORM.                              " USER_OK_TC
    
    *&---------------------------------------------------------------------*
    *&      Form  FCODE_INSERT_ROW                                         *
    *&---------------------------------------------------------------------*
     FORM fcode_insert_row
                   USING    P_TC_NAME           TYPE DYNFNAM
                            P_TABLE_NAME             .
    
    *&SPWIZARD: BEGIN OF LOCAL DATA----------------------------------------*
       DATA L_LINES_NAME       LIKE FELD-NAME.
       DATA L_SELLINE          LIKE SY-STEPL.
       DATA L_LASTLINE         TYPE I.
       DATA L_LINE             TYPE I.
       DATA L_TABLE_NAME       LIKE FELD-NAME.
       FIELD-SYMBOLS <TC>                 TYPE CXTAB_CONTROL.
       FIELD-SYMBOLS <TABLE>              TYPE STANDARD TABLE.
       FIELD-SYMBOLS <LINES>              TYPE I.
    *&SPWIZARD: END OF LOCAL DATA------------------------------------------*
    
       ASSIGN (P_TC_NAME) TO <TC>.
    
    *&SPWIZARD: get the table, which belongs to the tc                     *
       CONCATENATE P_TABLE_NAME '[]' INTO L_TABLE_NAME. "table body
       ASSIGN (L_TABLE_NAME) TO <TABLE>.                "not headerline
    
    *&SPWIZARD: get looplines of TableControl                              *
       CONCATENATE 'G_' P_TC_NAME '_LINES' INTO L_LINES_NAME.
       ASSIGN (L_LINES_NAME) TO <LINES>.
    
    *&SPWIZARD: get current line                                           *
       GET CURSOR LINE L_SELLINE.
       IF SY-SUBRC <> 0.                   " append line to table
         L_SELLINE = <TC>-LINES + 1.
    *&SPWIZARD: set top line                                               *
         IF L_SELLINE > <LINES>.
           <TC>-TOP_LINE = L_SELLINE - <LINES> + 1 .
         ELSE.
           <TC>-TOP_LINE = 1.
         ENDIF.
       ELSE.                               " insert line into table
         L_SELLINE = <TC>-TOP_LINE + L_SELLINE - 1.
         L_LASTLINE = <TC>-TOP_LINE + <LINES> - 1.
       ENDIF.
    *&SPWIZARD: set new cursor line                                        *
       L_LINE = L_SELLINE - <TC>-TOP_LINE + 1.
    
    *&SPWIZARD: insert initial line                                        *
       INSERT INITIAL LINE INTO <TABLE> INDEX L_SELLINE.
       <TC>-LINES = <TC>-LINES + 1.
    *&SPWIZARD: set cursor                                                 *
       SET CURSOR LINE L_LINE.
       "赋值全局焦点
       G_LINE = L_LINE.
    
     ENDFORM.                              " FCODE_INSERT_ROW
    
    *&---------------------------------------------------------------------*
    *&      Form  FCODE_DELETE_ROW                                         *
    *&---------------------------------------------------------------------*
     FORM fcode_delete_row
                   USING    P_TC_NAME           TYPE DYNFNAM
                            P_TABLE_NAME
                            P_MARK_NAME   .
    
    *&SPWIZARD: BEGIN OF LOCAL DATA----------------------------------------*
       DATA L_TABLE_NAME       LIKE FELD-NAME.
    
       FIELD-SYMBOLS <TC>         TYPE cxtab_control.
       FIELD-SYMBOLS <TABLE>      TYPE STANDARD TABLE.
       FIELD-SYMBOLS <WA>.
       FIELD-SYMBOLS:<MARK_FIELD>,<FIELD1>,<FIELD2>,<FIELD3>,<FIELD4>.
    *&SPWIZARD: END OF LOCAL DATA------------------------------------------*
    
       ASSIGN (P_TC_NAME) TO <TC>.
    
    *&SPWIZARD: get the table, which belongs to the tc                     *
       CONCATENATE P_TABLE_NAME '[]' INTO L_TABLE_NAME. "table body
       ASSIGN (L_TABLE_NAME) TO <TABLE>.                "not headerline
    
    *&SPWIZARD: delete marked lines                                        *
       DESCRIBE TABLE <TABLE> LINES <TC>-LINES.
    
       LOOP AT <TABLE> ASSIGNING <WA>.
    
    *&SPWIZARD: access to the component 'FLAG' of the table header         *
         ASSIGN COMPONENT P_MARK_NAME OF STRUCTURE <WA> TO <MARK_FIELD>.
    
         IF <MARK_FIELD> = 'X'.
    
           "删除到属性的总表里,保持数据一致,再单个请求号属性表的操作之前
           ASSIGN COMPONENT 'TRKORR' OF STRUCTURE <WA> TO <FIELD1>.
           ASSIGN COMPONENT 'POS' OF STRUCTURE <WA> TO <FIELD2>.
           ASSIGN COMPONENT 'ATTRIBUTE' OF STRUCTURE <WA> TO <FIELD3>.
           ASSIGN COMPONENT 'REFERENCE' OF STRUCTURE <WA> TO <FIELD4>.
    
           DELETE GT_E070A2 WHERE TRKORR = <FIELD1> AND POS = <FIELD2>
                            AND  ATTRIBUTE = <FIELD3>
                            AND REFERENCE = <FIELD4>.
           "单个请求号属性表的操作
           DELETE <TABLE> INDEX SYST-TABIX.
           IF SY-SUBRC = 0.
             <TC>-LINES = <TC>-LINES - 1.
           ENDIF.
    
         ENDIF.
       ENDLOOP.
       "删除完成后,从第一行继续
       G_LINE = 1.
     ENDFORM.                              " FCODE_DELETE_ROW
    
    *&---------------------------------------------------------------------*
    *&      Form  COMPUTE_SCROLLING_IN_TC
    *&---------------------------------------------------------------------*
    *       text
    *----------------------------------------------------------------------*
    *      -->P_TC_NAME  name of tablecontrol
    *      -->P_OK       ok code
    *----------------------------------------------------------------------*
     FORM COMPUTE_SCROLLING_IN_TC USING    P_TC_NAME
                                           P_OK.
    *&SPWIZARD: BEGIN OF LOCAL DATA----------------------------------------*
       DATA L_TC_NEW_TOP_LINE     TYPE I.
       DATA L_TC_NAME             LIKE FELD-NAME.
       DATA L_TC_LINES_NAME       LIKE FELD-NAME.
       DATA L_TC_FIELD_NAME       LIKE FELD-NAME.
    
       FIELD-SYMBOLS <TC>         TYPE cxtab_control.
       FIELD-SYMBOLS <LINES>      TYPE I.
    *&SPWIZARD: END OF LOCAL DATA------------------------------------------*
    
       ASSIGN (P_TC_NAME) TO <TC>.
    *&SPWIZARD: get looplines of TableControl                              *
       CONCATENATE 'G_' P_TC_NAME '_LINES' INTO L_TC_LINES_NAME.
       ASSIGN (L_TC_LINES_NAME) TO <LINES>.
    
    
    *&SPWIZARD: is no line filled?                                         *
       IF <TC>-LINES = 0.
    *&SPWIZARD: yes, ...                                                   *
         L_TC_NEW_TOP_LINE = 1.
       ELSE.
    *&SPWIZARD: no, ...                                                    *
         CALL FUNCTION 'SCROLLING_IN_TABLE'
              EXPORTING
                   ENTRY_ACT             = <TC>-TOP_LINE
                   ENTRY_FROM            = 1
                   ENTRY_TO              = <TC>-LINES
                   LAST_PAGE_FULL        = 'X'
                   LOOPS                 = <LINES>
                   OK_CODE               = P_OK
                   OVERLAPPING           = 'X'
              IMPORTING
                   ENTRY_NEW             = L_TC_NEW_TOP_LINE
              EXCEPTIONS
    *              NO_ENTRY_OR_PAGE_ACT  = 01
    *              NO_ENTRY_TO           = 02
    *              NO_OK_CODE_OR_PAGE_GO = 03
                   OTHERS                = 0.
       ENDIF.
    
    *&SPWIZARD: get actual tc and column                                   *
       GET CURSOR FIELD L_TC_FIELD_NAME
                  AREA  L_TC_NAME.
    
       IF SYST-SUBRC = 0.
         IF L_TC_NAME = P_TC_NAME.
    *&SPWIZARD: et actual column                                           *
           SET CURSOR FIELD L_TC_FIELD_NAME LINE 1.
         ENDIF.
       ENDIF.
    
    *&SPWIZARD: set the new top line                                       *
       <TC>-TOP_LINE = L_TC_NEW_TOP_LINE.
    
    
     ENDFORM.                              " COMPUTE_SCROLLING_IN_TC
    
    *&---------------------------------------------------------------------*
    *&      Form  FCODE_TC_MARK_LINES
    *&---------------------------------------------------------------------*
    *       marks all TableControl lines
    *----------------------------------------------------------------------*
    *      -->P_TC_NAME  name of tablecontrol
    *----------------------------------------------------------------------*
    FORM FCODE_TC_MARK_LINES USING P_TC_NAME
                                   P_TABLE_NAME
                                   P_MARK_NAME.
    *&SPWIZARD: EGIN OF LOCAL DATA-----------------------------------------*
      DATA L_TABLE_NAME       LIKE FELD-NAME.
    
      FIELD-SYMBOLS <TC>         TYPE cxtab_control.
      FIELD-SYMBOLS <TABLE>      TYPE STANDARD TABLE.
      FIELD-SYMBOLS <WA>.
      FIELD-SYMBOLS <MARK_FIELD>.
    *&SPWIZARD: END OF LOCAL DATA------------------------------------------*
    
      ASSIGN (P_TC_NAME) TO <TC>.
    
    *&SPWIZARD: get the table, which belongs to the tc                     *
       CONCATENATE P_TABLE_NAME '[]' INTO L_TABLE_NAME. "table body
       ASSIGN (L_TABLE_NAME) TO <TABLE>.                "not headerline
    
    *&SPWIZARD: mark all filled lines                                      *
      LOOP AT <TABLE> ASSIGNING <WA>.
    
    *&SPWIZARD: access to the component 'FLAG' of the table header         *
         ASSIGN COMPONENT P_MARK_NAME OF STRUCTURE <WA> TO <MARK_FIELD>.
    
         <MARK_FIELD> = 'X'.
      ENDLOOP.
    ENDFORM.                                          "fcode_tc_mark_lines
    
    *&---------------------------------------------------------------------*
    *&      Form  FCODE_TC_DEMARK_LINES
    *&---------------------------------------------------------------------*
    *       demarks all TableControl lines
    *----------------------------------------------------------------------*
    *      -->P_TC_NAME  name of tablecontrol
    *----------------------------------------------------------------------*
    FORM FCODE_TC_DEMARK_LINES USING P_TC_NAME
                                     P_TABLE_NAME
                                     P_MARK_NAME .
    *&SPWIZARD: BEGIN OF LOCAL DATA----------------------------------------*
      DATA L_TABLE_NAME       LIKE FELD-NAME.
    
      FIELD-SYMBOLS <TC>         TYPE cxtab_control.
      FIELD-SYMBOLS <TABLE>      TYPE STANDARD TABLE.
      FIELD-SYMBOLS <WA>.
      FIELD-SYMBOLS <MARK_FIELD>.
    *&SPWIZARD: END OF LOCAL DATA------------------------------------------*
    
      ASSIGN (P_TC_NAME) TO <TC>.
    
    *&SPWIZARD: get the table, which belongs to the tc                     *
       CONCATENATE P_TABLE_NAME '[]' INTO L_TABLE_NAME. "table body
       ASSIGN (L_TABLE_NAME) TO <TABLE>.                "not headerline
    
    *&SPWIZARD: demark all filled lines                                    *
      LOOP AT <TABLE> ASSIGNING <WA>.
    
    *&SPWIZARD: access to the component 'FLAG' of the table header         *
         ASSIGN COMPONENT P_MARK_NAME OF STRUCTURE <WA> TO <MARK_FIELD>.
    
         <MARK_FIELD> = SPACE.
      ENDLOOP.
    ENDFORM.                                          "fcode_tc_mark_lines
    *&---------------------------------------------------------------------*
    *&      Form  DIS_EDIT
    *&---------------------------------------------------------------------*
    *       text 编辑与显示的切换
    *----------------------------------------------------------------------*
    *  -->  p1        text
    *  <--  p2        text
    *----------------------------------------------------------------------*
    FORM DIS_EDIT .
      IF G_GUISTATUE IS INITIAL OR G_GUISTATUE = 'DISPLAY'.
        G_GUISTATUE = 'EDIT'.
      ELSEIF G_GUISTATUE = 'EDIT'.
        G_GUISTATUE = 'DISPLAY'.
      ENDIF.
    ENDFORM.                    " DIS_EDIT
  • 相关阅读:
    程序员你写的代码,被爆出黑产了!
    .NET面试题系列之面向对象
    .NET必问的面试题系列之基本概念和语法
    xamarin开发android收集的一些工具
    C#爬虫使用代理刷csdn文章浏览量
    我们必须要知道的RESTful服务最佳实践
    MVP架构在xamarin android中的简单使用
    使用Xamarin实现跨平台移动应用开发(转载)
    博客园app for xamarin android一款简洁阅读的博客园android客户端
    vs2019企业版密钥
  • 原文地址:https://www.cnblogs.com/CtrlS/p/10451531.html
Copyright © 2020-2023  润新知