BAPI_PRODORDCONF_CREATE_TT Reporter

Note

First use BAPI_PROCORDCONF_GET_TT_PROP to get the data of a process (rated working hours)

However, the test found that some work orders were not taken out during the work hours, and now I forget it manually

Then use

BAPI_PRODORDCONF_CREATE_TT Production order report

 

 

 

demo

 

*ol

  loop at gt_alv.

*    read table gt_aufm_sum with key aufnr = gt_alv-aufnr binary search.

*    if sy-subrc = 0.

* 1. Data settings that need to be updated

    clear propose.

* propose-quantity = cn_flagx. "Update quantity

    propose-date_and_time = cn_flagx. "Update job time

    propose-goodsmovement = cn_flagx. "Update goods movement

 

* 2. Operating time

    clear: timetickets,timetickets[].

    timetickets-conf_no = gt_alv-rueck. "Confirm

* timetickets-orderid = gt_alv-aufnr. "Ticket number

* timetickets-operation = gt_alv-vornr. "operation number

*    timetickets-sequence      = gt_alv-aplfl.  "

    timetickets-yield = gt_alv-menge. "Ticket production quantity

    append timetickets.

    clear  timetickets.

 

* 3. Goods movement attributes

* The first assignment, used to get the relevant default attribute value

    clear: goodsmovements,goodsmovements[].

    goodsmovements-orderid = gt_alv-aufnr. "Production order number

    goodsmovements-order_itno = gt_alv-vornr. "Operation number

    append goodsmovements.

    clear  goodsmovements.

 

* 4. Call BAPI to get the default attribute value

    call function 'BAPI_PRODORDCONF_GET_TT_PROP'

      exporting

        propose = propose

      importing

        return             = return

      tables

        timetickets = timetickets

        goodsmovements     = goodsmovements

        link_conf_goodsmov = link_conf_goodsmov

        detail_return      = return_detail.

 

* 5. Output abnormal information

*      if return-type = 'E' or return-type = 'A'.

*        concatenate '错误:' return-message into return-message.

*        lv_result = cn_flagx.

*      endif.

*

*      loop at return_detail where type is not initial.

*        if return_detail-type = 'E' or return_detail-type = 'A'.

*          concatenate '错误:' return_detail-message into return-message.

*          lv_result = cn_flagx.

*        endif.

*      endloop.

 

    loop at timetickets.

      timetickets-postg_date = gt_alv-budat.

      timetickets-conf_activity1 = gt_alv-vgw01 * gt_alv-menge. "Some tickets cannot read standard working hours

      timetickets-conf_acti_unit1 = gt_alv-vge01.

      timetickets-conf_activity2 = gt_alv-vgw02 * gt_alv-menge.

      timetickets-conf_acti_unit2 = gt_alv-vge02.

      timetickets-conf_activity3 = gt_alv-vgw03 * gt_alv-menge.

      timetickets-conf_acti_unit3 = gt_alv-vge03.

      timetickets-conf_activity4 = gt_alv-vgw04 * gt_alv-menge.

      timetickets-conf_acti_unit4 = gt_alv-vge04.

      timetickets-conf_activity5 = gt_alv-vgw05 * gt_alv-menge.

      timetickets-conf_acti_unit5 = gt_alv-vge05.

      timetickets-conf_activity6 = gt_alv-vgw06 * gt_alv-menge.

      timetickets-conf_acti_unit6 = gt_alv-vge06.

      modify timetickets.

    endloop.

 

* 7. Call BAPI and report to work for confirmation

    clear: return, return[].

    clear: return_detail, return_detail[].

    call function 'BAPI_PRODORDCONF_CREATE_TT'

      exporting

        post_wrong_entries = '1'

        testrun ='' "Identified as X, it is a trial run, not submitted to the system

      importing

        return             = return

      tables

        timetickets = timetickets

        goodsmovements     = goodsmovements

        link_conf_goodsmov = link_conf_goodsmov

        detail_return      = return_detail.

 

    clear lv_result.

    read table return with key type = 'E'.

    if sy-subrc = 0.

      concatenate '错误:' return-message into return-message.

      lv_result = cn_flagx.

    endif.

    loop at return_detail where type is not initial.

      if return_detail-type = 'E' or return_detail-type = 'A'.

        concatenate '错误:' return_detail-message into return-message.

        lv_result = cn_flagx.

      endif.

    endloop.

 

    if lv_result ne cn_flagx.

      call function 'BAPI_TRANSACTION_COMMIT'

        exporting

          wait = 'X'.

      gt_alv-rtype = 'S'.

      gt_alv-rtmsg ='Success'.

 

*Total number of production lines

      read table timetickets index 1.

      lt_ztpp0032n-zzline = gt_alv-zzline.

      lt_ztpp0032n-budat = gt_alv-budat.

      lt_ztpp0032n-lmnga = gt_alv-menge.

      lt_ztpp0032n-ism01 = timetickets-conf_activity1..

      lt_ztpp0032n-aedat = sy-datum.

      lt_ztpp0032n-aezet = sy-uzeit.

      lt_ztpp0032n-aenam = sy-uname.

      append lt_ztpp0032n.

    else.

      call function 'BAPI_TRANSACTION_ROLLBACK'.

      gt_alv-rtype = 'E'.

      gt_alv-rtmsg = return-message.

    endif.

*    endif.

    modify gt_alv.

  endloop.

 

Guess you like

Origin blog.csdn.net/cylcylcylcylwo/article/details/113929504