工程变更号的创建CCAP_ECN_CREATE 实例

前台界面CC01

CCAP_ECN_CREATE 使用注意点请参考修改实例https://www.cnblogs.com/twttafku/p/14351983.html

 

FUNCTION zepe00_create_ecm.
*"--------------------------------------------------------------------
*"*"本地接口:
*"  IMPORTING
*"     REFERENCE(SYNC) TYPE  CHAR1 OPTIONAL
*"     REFERENCE(SUBJECT) TYPE  /AIFECC/TDM_CHANGE_SUBJECT
*"     REFERENCE(VALID_FROM) TYPE  /AIFECC/TDM_SHORT_TIMESTAMP
*"     REFERENCE(NOTE) TYPE  STRING
*"  EXPORTING
*"     REFERENCE(ECN) TYPE  AENNR
*"--------------------------------------------------------------------

  DATA ls_ecm_data    TYPE aenr_api01.
  DATA ls_object_bom  TYPE aenv_api01.
  DATA ls_object_mat  TYPE aenv_api01.
  DATA ls_object_doc  TYPE aenv_api01.
  DATA lt_text_header TYPE TABLE OF ccthead.
  DATA lt_text_lines  TYPE TABLE OF cctline.
  DATA lv_date        TYPE datum.
  DATA lv_time        TYPE uzeit.
  DATA lv_timestamp   TYPE /aifecc/tdm_short_timestamp.
  DATA lv_timezone    TYPE tznzone.
  DATA lo_plm_object_badi TYPE REF TO /aifecc/badi_plm_objects.

* change header
  lv_timestamp = valid_from.
  IF lv_timestamp IS INITIAL.
    GET TIME STAMP FIELD lv_timestamp.
  ENDIF.
  lv_timezone = 'UTC'.
  CONVERT TIME STAMP lv_timestamp TIME ZONE lv_timezone INTO DATE lv_date TIME lv_time.
  ls_ecm_data-descript = subject.
  WRITE lv_date TO ls_ecm_data-valid_from. "Bapi needs external date
  ls_ecm_data-reason_chg = note.
  ls_ecm_data-status     = '01'.

* relevant for BOM
  ls_object_bom-active     = abap_true.
  ls_object_bom-obj_requ   = abap_true.
  ls_object_bom-mgtrec_gen = abap_true.

* relevant for material
  ls_object_mat-active     = abap_true.
  ls_object_mat-obj_requ   = abap_true.
  ls_object_mat-mgtrec_gen = abap_true.

* relevant for document
  ls_object_doc-active     = abap_true.
  ls_object_doc-obj_requ   = abap_true.
  ls_object_doc-mgtrec_gen = abap_true.

* customer enhancement
  TRY.
    GET BADI lo_plm_object_badi.
    CALL BADI lo_plm_object_badi->assign_ecm_before
      CHANGING
        cs_ecm_data      = ls_ecm_data
        cs_object_bom    = ls_object_bom
        cs_object_mat    = ls_object_mat
        cs_object_doc    = ls_object_doc.
    CATCH cx_badi.
  ENDTRY.

  CALL FUNCTION 'CCAP_ECN_CREATE'
    EXPORTING
      change_header            = ls_ecm_data
      object_bom               = ls_object_bom
      object_mat               = ls_object_mat
      object_doc               = ls_object_doc
      fl_commit_and_wait       = 'X'
    IMPORTING
      change_no                = ecn
    TABLES
*     alt_dates                =
*     objmgrec                 =
*     effectivity              =
      textheader               = lt_text_header
      textlines                = lt_text_lines
    EXCEPTIONS
      change_no_already_exists = 1
      error                    = 2
      OTHERS                   = 3.

  IF sy-subrc <> 0.
    MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
  ENDIF.



ENDFUNCTION.

 

使用注意点请参考修改实例https://www.cnblogs.com/twttafku/p/14351983.html

上一篇:2021.1~2做题记录


下一篇:ABAP 调用程序时获取的数量,金额和日期字段会出现 逗号,-,负号等非法字段,所需要进行转化