其他分享
首页 > 其他分享> > ariba 数据补发

ariba 数据补发

作者:互联网

*&---------------------------------------------------------------------*
*& Report  Z_ARBA_PZB
*&
*&---------------------------------------------------------------------*
*&
*&
*&---------------------------------------------------------------------*

REPORT  z_arba_pzb.
TABLES:mara,ekpo,zbmm0005_po.
DATA:gt_mara LIKE TABLE OF mara WITH HEADER LINE.
*DATA:gt_mara_show LIKE TABLE OF mara WITH HEADER LINE.
DATA:gt_/arba/tvarv LIKE TABLE OF /arba/tvarv WITH HEADER LINE.
DATA:gt_/arba/tvarv_del LIKE TABLE OF /arba/tvarv WITH HEADER LINE.
DATA:gt_/arba/tvarv_res LIKE TABLE OF /arba/tvarv WITH HEADER LINE.
DATA: lc_cursor TYPE cursor.

selection-SCREEN BEGIN OF BLOCK bl2 WITH FRAME  TITLE TEXT-004.
  selection-SCREEN: BEGIN OF LINE,
    COMMENT 3(60) TEXT-005,
  END OF LINE,
  BEGIN OF LINE,
    COMMENT 3(60) TEXT-007,
  END OF LINE.
selection-SCREEN END OF BLOCK bl2.

SELECTION-SCREEN BEGIN OF BLOCK 001 WITH FRAME TITLE text-001.

SELECT-OPTIONS s_matnr FOR zbmm0005_po-matnr NO INTERVALS  .          "物料
SELECTION-SCREEN END OF BLOCK 001.


*/ARBA/EXTERNAL_SID   P       I EQ  CSOTExternalSystemP
*/ARBA/MATERIAL_MASTER_EXPORT MATNR S 1     I EQ  51CZ8560000001
*/ARBA/MATERIAL_MASTER_EXPORT MATNR S 2     I EQ  51CZ8560000002
*/ARBA/TEMP_DIRECTORY   P       I EQ  /ARBA/MASTERDATA
*DC_WAITTIME    P       I EQ  1
*FLUSH_MM_DOC_CHANGES   P       I EQ

*&---------------------------------------------------------------------*
DATA:lv_numb TYPE /arba/tvarv-numb.

OPEN CURSOR   WITH HOLD lc_cursor FOR SELECT * FROM mara WHERE  matnr IN s_matnr
*  and  ERSDA  BETWEEN '20201221' and '20201228'
 ORDER BY PRIMARY KEY .
DO.
  FETCH NEXT CURSOR lc_cursor INTO TABLE gt_mara PACKAGE SIZE 2000.
  IF sy-subrc <> 0.
    EXIT.
  ENDIF.
*->删除配置表上次发送过的数据
  FREE:gt_/arba/tvarv.
  SELECT * INTO CORRESPONDING FIELDS OF TABLE gt_/arba/tvarv
  FROM /arba/tvarv.

  LOOP AT gt_/arba/tvarv.
    IF gt_/arba/tvarv-name = '/ARBA/MATERIAL_MASTER_EXPORT'..
      MOVE-CORRESPONDING gt_/arba/tvarv TO gt_/arba/tvarv_del.
      APPEND gt_/arba/tvarv_del.CLEAR gt_/arba/tvarv_del."删除上次用过的物料相关数据

    ELSE.
      MOVE-CORRESPONDING gt_/arba/tvarv TO gt_/arba/tvarv_res.
      APPEND gt_/arba/tvarv_res.CLEAR gt_/arba/tvarv_res."其他数据
    ENDIF.
  ENDLOOP.

  DELETE /arba/tvarv FROM TABLE gt_/arba/tvarv_del."删除上次用过的物料相关数据
  EXEC SQL.
    COMMIT
  ENDEXEC.

  CLEAR:lv_numb.
  LOOP AT gt_mara.
    lv_numb = lv_numb  + 1.
    gt_/arba/tvarv_res-name = '/ARBA/MATERIAL_MASTER_EXPORT'..
    gt_/arba/tvarv_res-fieldname = 'MATNR'.
    gt_/arba/tvarv_res-type = 'S'.
    gt_/arba/tvarv_res-numb = lv_numb.
    gt_/arba/tvarv_res-sign = 'I'.
    gt_/arba/tvarv_res-opti = 'EQ'.
    gt_/arba/tvarv_res-low = gt_mara-matnr.
    APPEND gt_/arba/tvarv_res.CLEAR gt_/arba/tvarv_res."结果表 result
  ENDLOOP.
  MODIFY /arba/tvarv FROM TABLE gt_/arba/tvarv_res." 控制哪些物料需要进标准程序
  EXEC SQL.
    COMMIT
  ENDEXEC.
*&---------------------------------------------------------------------*
*->调用job进行发送
  PERFORM frm_create_job.
*  SUBMIT z_arba_master_send
*
*  AND RETURN
*  WITH p_cus3  = 'X'
*  WITH p_dc = 'X'
*  WITH p_flo   = 'X'
*  WITH  p_werks  = 'X'
*  WITH  p_matmas  = 'X'.
  EXEC SQL.
    COMMIT
  ENDEXEC.

ENDDO."

FREE:gt_/arba/tvarv_res.
SELECT * INTO CORRESPONDING FIELDS OF TABLE gt_/arba/tvarv
FROM /arba/tvarv WHERE name = '/ARBA/MATERIAL_MASTER_EXPORT' AND fieldname = 'MATNR' and type = 'S'. .



DELETE /arba/tvarv FROM TABLE gt_/arba/tvarv.
COMMIT WORK AND WAIT.

*&---------------------------------------------------------------------*
FORM frm_create_job.
  DATA: l_jobnumber TYPE btcjobcnt.
  DATA: l_jobname   TYPE btcjob VALUE 'ZSEND'.
  CALL FUNCTION 'ENQUE_SLEEP'
    EXPORTING
      seconds = 1. "

  "检查权限
  AUTHORITY-CHECK OBJECT 'S_BTCH_ADM' FOR USER sy-uname ID 'BTCADMIN' FIELD 'Y'.

  IF sy-subrc NE 0.
    MESSAGE  '没有权限'  TYPE   'E'. .
  ELSE.
    CALL FUNCTION 'JOB_OPEN'
      EXPORTING
        jobname          = l_jobname
      IMPORTING
        jobcount         = l_jobnumber
      EXCEPTIONS
        cant_create_job  = 1
        invalid_job_data = 2
        jobname_missing  = 3
        OTHERS           = 4.

    IF sy-subrc = 0.

      SUBMIT z_arba_master_send USER sy-uname
      VIA JOB l_jobname NUMBER l_jobnumber
      AND RETURN
      WITH p_cus3  = 'X'
      WITH p_dc = 'X'
      WITH p_flo   = 'X'
      WITH  p_werks  = 'X'
      WITH  p_matmas  = 'X'.
      IF sy-subrc = 0.

        DATA:lv_status TYPE tbtco-status.

        CALL FUNCTION 'ENQUE_SLEEP'
          EXPORTING
            seconds = 55. "
*        DO   .
*          CLEAR:lv_status.
*          CALL FUNCTION 'ENQUE_SLEEP'
*            EXPORTING
*              seconds = 20. "
*          SELECT SINGLE   status INTO lv_status FROM tbtco WHERE jobname = 'ZSEND' AND jobcount =  l_jobnumber.
*          IF sy-subrc = 0.
*            IF  lv_status = 'F'.
*              EXIT.
*            ENDIF.
*          ENDIF.
*        ENDDO.

        CALL FUNCTION 'JOB_CLOSE'
          EXPORTING
            jobcount             = l_jobnumber
            jobname              = l_jobname
            strtimmed            = 'X'
          EXCEPTIONS
            cant_start_immediate = 1
            invalid_startdate    = 2
            jobname_missing      = 3
            job_close_failed     = 4
            job_nosteps          = 5
            job_notex            = 6
            lock_failed          = 7
            OTHERS               = 8.
      ENDIF.

    ENDIF.

  ENDIF.

ENDFORM.                    "FRM_CREATE_JOB
*&---------------------------------------------------------------------*
*LOOP AT gt_mara.
*  lv_numb = lv_numb  + 1.
*  gt_/arba/tvarv_res-name = '/ARBA/MATERIAL_MASTER_EXPORT'..
*  gt_/arba/tvarv_res-fieldname = 'MATNR'.
*  gt_/arba/tvarv_res-type = 'S'.
*  gt_/arba/tvarv_res-numb = lv_numb.
*  gt_/arba/tvarv_res-sign = 'I'.
*  gt_/arba/tvarv_res-opti = 'EQ'.
*  gt_/arba/tvarv_res-low = gt_mara-matnr.
*
*  APPEND gt_/arba/tvarv_res.CLEAR gt_/arba/tvarv_res.
*ENDLOOP.

 

标签:ariba,gt,numb,补发,lv,arba,res,数据,tvarv
来源: https://www.cnblogs.com/ckstock/p/15659816.html