标签:submit call code ice pos open select wait initial
DATA: p_groupid LIKE apqi-groupid. DATA: p_user LIKE sy-uname. * PERFORM bdc_open_group. * PERFORM pre_bdc. * PERFORM bdc_insert_group. * PERFORM bdc_close_group . * PERFORM get_session_state USING p_groupid . * PERFORM write_error. ************************************************************** FORM bdc_open_group . CONCATENATE sy-datum sy-uzeit INTO p_groupid. CALL FUNCTION ‘BDC_OPEN_GROUP‘ "open session EXPORTING client = sy-mandt * DEST = FILLER8 group = p_groupid * HOLDDATE = FILLER8 keep = ‘X‘ user = p_user * RECORD = FILLER1 * IMPORTING * QID = EXCEPTIONS client_invalid = 1 destination_invalid = 2 group_invalid = 3 group_is_locked = 4 holddate_invalid = 5 internal_error = 6 queue_error = 7 running = 8 system_lock_error = 9 user_invalid = 10 OTHERS = 11. ENDFORM. " BDC_OPEN_GROUP ************************************************************ FORM pre_bdc . REFRESH bdcdata. PERFORM bdc_dynpro USING ‘SAPLMR1M‘ ‘0300‘. PERFORM bdc_field USING ‘BDC_CURSOR‘ ‘G_BUDAT‘. PERFORM bdc_field USING ‘BDC_OKCODE‘ ‘=CANC‘. PERFORM bdc_field USING ‘RBKPV-BELNR‘ i_belnr. PERFORM bdc_field USING ‘RBKPV-GJAHR‘ i_gjahr. PERFORM bdc_field USING ‘UF05A-STGRD‘ i_stgrd. PERFORM bdc_field USING ‘G_BUDAT‘ i_budat. ENDFORM. ************************************************************* FORM bdc_insert_group . CALL FUNCTION ‘BDC_INSERT‘ EXPORTING tcode = tcode TABLES dynprotab = bdcdata EXCEPTIONS internal_error = 1 not_open = 2 queue_error = 3 tcode_invalid = 4 printing_invalid = 5 posting_invalid = 6 OTHERS = 7. ENDFORM. " BDC_INSERT_GROUP ********************************************************* FORM bdc_close_group . CALL FUNCTION ‘BDC_CLOSE_GROUP‘ EXCEPTIONS not_open = 1 queue_error = 2 OTHERS = 3. SUBMIT rsbdcsub WITH mappe EQ p_groupid WITH von EQ sy-datum WITH bis EQ sy-datum WITH fehler EQ ‘.‘ EXPORTING LIST TO MEMORY AND RETURN. WAIT UP TO 10 SECONDS . ENDFORM. " BDC_CLOSE_GROUP ********************************************************** FORM get_session_state USING p_session. CLEAR: itab1,itab1[]. itab1-groupid = p_groupid. itab1-belnr = i_belnr. itab1-gjahr = i_gjahr. itab1-stgrd = i_stgrd. itab1-budat = i_budat. itab1-erdat = sy-datum. itab1-uzeit = sy-uzeit. itab1-ernam = sy-uname. itab1-text = i_text. APPEND itab1. PERFORM insert_zszd219. SELECT SINGLE apqi~mandant apqi~groupid apqi~qid apqi~qstate apql~temseid INTO (ijob-mandant,ijob-groupid,ijob-qid,ijob-qstate,ijob-temseid) FROM apqi INNER JOIN apql ON apql~mandant = apqi~mandant AND apql~groupid = apqi~groupid AND apql~qid = apqi~qid WHERE apqi~groupid = p_session AND apqi~datatyp = ‘BDC‘ AND apqi~mandant = sy-mandt . IF sy-subrc = 0 AND ijob-qstate = ‘F‘. READ TABLE itab1 INDEX 1. itab1-state = ‘F‘. MODIFY itab1 INDEX 1. PERFORM insert_zszd219. WRITE: / ‘Cancel Invoice Sucessful‘. ELSEIF sy-subrc = 0 AND ijob-qstate <> ‘F‘. PERFORM read_bdc_log_plain TABLES logtable USING ijob-temseid ijob-mandant. ELSEIF sy-subrc <> 0. WRITE:/ ‘Job name: ‘,p_session,‘ has not finish.‘. ENDIF. CHECK NOT bdclm[] IS INITIAL. LOOP AT itab1. READ TABLE bdclm WITH KEY tcode = ‘MR8M‘ tcnt = sy-tabix. CHECK sy-subrc = 0. MOVE-CORRESPONDING itab1 TO errtab. IF bdclm-mart = ‘E‘. errtab-mess = bdclm-longtext. ELSE. errtab-mess = ‘Cancel Invoice Sucessful‘. ENDIF. APPEND errtab. CLEAR errtab. ENDLOOP. ENDFORM. ********************************************************* FORM write_error . DATA: count TYPE i. count = 0. LOOP AT errtab. IF count = 0. FORMAT COLOR 3 ON. WRITE: /01 errtab. FORMAT COLOR 3 OFF. SKIP 1. ELSE. WRITE: /01 errtab. ENDIF. count = 1. ENDLOOP. ENDFORM. " WRITE_ERROR
标签:submit call code ice pos open select wait initial
原文地址:https://www.cnblogs.com/wangxiaowen/p/8992349.html