使用事务码SE38,运行程序:RC1_IDOC_SET_STATUS
可以修改IDOC的状态,
注意:
1.修改完成后要退出后修改才会提交,猜是程序中修改完成后没有COMMIT.
2.确认要修改时,需取消选择屏幕上的测试选择。
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 |
*&---------------------------------------------------------------------* *& Report RC1_IDOC_SET_STATUS * *& * *&---------------------------------------------------------------------* *& * *& * *&---------------------------------------------------------------------* REPORT RC1_IDOC_SET_STATUS . TABLES: EDIDC. SELECTION-SCREEN BEGIN OF BLOCK 1. SELECT-OPTIONS: P_IDOC FOR EDIDC-DOCNUM NO INTERVALS. PARAMETERS: P_MESTYP LIKE EDIDC-MESTYP. SELECTION-SCREEN END OF BLOCK 1. SELECTION-SCREEN BEGIN OF BLOCK 2. PARAMETERS : P_STATUS LIKE EDIDS-STATUS DEFAULT 51 OBLIGATORY, P_STANEU LIKE EDIDS-STATUS DEFAULT 68 OBLIGATORY. SELECTION-SCREEN END OF BLOCK 2. PARAMETERS P_TEST AS CHECKBOX DEFAULT 'X'. DATA: L_EDIDC_TAB LIKE EDIDC OCCURS 1 WITH HEADER LINE, L_IDOC_STATUS_TAB LIKE BDIDOCSTAT OCCURS 1 WITH HEADER LINE, L_LINES LIKE SY-TABIX, L_IDOC_CONTROL LIKE EDIDC, L_ZAEHLER LIKE SY-TABIX. IF P_MESTYP <> SPACE. SELECT * INTO TABLE L_EDIDC_TAB FROM EDIDC WHERE MESTYP = P_MESTYP AND STATUS = P_STATUS. ELSEIF NOT P_IDOC[] IS INITIAL. LOOP AT P_IDOC. SELECT * FROM EDIDC WHERE DOCNUM = P_IDOC-LOW. L_EDIDC_TAB = EDIDC. APPEND L_EDIDC_TAB. ENDSELECT. ENDLOOP. ELSE. EXIT. ENDIF. DESCRIBE TABLE L_EDIDC_TAB LINES L_LINES. IF P_TEST = 'X'. WRITE: L_LINES, ' IDOCs werden umgesetzt.'(001). EXIT. ELSE. LOOP AT L_EDIDC_TAB. CLEAR L_IDOC_STATUS_TAB. REFRESH L_IDOC_STATUS_TAB. L_IDOC_STATUS_TAB-DOCNUM = L_EDIDC_TAB-DOCNUM. L_IDOC_STATUS_TAB-STATUS = P_STANEU. APPEND L_IDOC_STATUS_TAB. CALL FUNCTION 'IDOC_STATUS_WRITE_TO_DATABASE' EXPORTING IDOC_NUMBER = L_EDIDC_TAB-DOCNUM IMPORTING IDOC_CONTROL = L_IDOC_CONTROL TABLES IDOC_STATUS = L_IDOC_STATUS_TAB EXCEPTIONS IDOC_FOREIGN_LOCK = 1 IDOC_NOT_FOUND = 2 IDOC_STATUS_RECORDS_EMPTY = 3 IDOC_STATUS_INVALID = 4 DB_ERROR = 5 OTHERS = 6. ADD 1 TO L_ZAEHLER. * Um Überlauf der Sperrtabelle zu verhindern, bei großer Anzahl IDOCs IF L_ZAEHLER = 1000. CALL FUNCTION 'DEQUEUE_ALL'. CLEAR L_ZAEHLER. ENDIF. IF SY-SUBRC <> 0. WRITE : / 'Fehler:'(002), SY-SUBRC. ENDIF. ENDLOOP. WRITE: L_LINES, ' IDOCs wurden umgesetzt.'(003). ENDIF. |