SAP 创建,修改工作中心实例代码
SE24
CL_PP_WORK_CENTER_BO
Work Center API Business Object
UPDATE_CAPACITY Update Capacity
GET_INSTANCE Get instance of class CL_PP_WORK_CENTER_BO
CREATE_WORK_CENTER Create Work Center
UPDATE_WORK_CENTER Update Work Center
CREATE_WRKCTR_CAPACITY_MAPPING Create Work Center Capacity Mapping
CREATE_COST_CENTER_ALLOCATION Create Work Center Cost Center Allocation
UPDATE_CAPACITY_INTERVAL_SHIFT Update Capacity, Interval or Shift
CREATE_WRKCTRCAP_INTVL_SHIFT Create Interval or Shift
READ_WORK_CENTER_BY_ID Read Work Center by given ID
READ_CAPACITY_BY_ID Read Capacity by given ID
READ_WORK_CENTER_BY_NAME Read Work Center by Work Center Name and Plant
*&---------------------------------------------------------------------*
*& Report ZCR02
*&---------------------------------------------------------------------*
*& CR02 更改工作中心 CRAP_WORKCENTER_CHANGE
*&---------------------------------------------------------------------*
REPORT ZCR02 NO STANDARD PAGE HEADING.
DATA: GT_RETURN TYPE BAPIRET2_TAB.
SELECTION-SCREEN: BEGIN OF BLOCK SCR1 WITH FRAME TITLE TEXT-101.
PARAMETERS: P_WERKS TYPE RC68A-WERKS OBLIGATORY DEFAULT '1001',
P_ARBPL TYPE RC68A-ARBPL OBLIGATORY DEFAULT 'WO19'.
SELECTION-SCREEN END OF BLOCK SCR1.
SELECTION-SCREEN: BEGIN OF BLOCK SCR2 WITH FRAME TITLE TEXT-102.
PARAMETERS: P_KTSCH TYPE P3003-KTSCH OBLIGATORY DEFAULT 'ZPP01',
P_STEXT TYPE P1000-STEXT OBLIGATORY DEFAULT '核武器打磨车间'.
SELECTION-SCREEN END OF BLOCK SCR2.
INITIALIZATION.
START-OF-SELECTION.
PERFORM FRM_UPDATE_WORK_CENTER USING 'X' P_WERKS P_ARBPL P_KTSCH P_STEXT CHANGING GT_RETURN.
IF GT_RETURN IS INITIAL.
PERFORM FRM_DISPLAY USING '修改成功'.
ELSE.
PERFORM FRM_DISPLAY USING GT_RETURN.
ENDIF.
FORM FRM_DISPLAY USING DATA.
CHECK DATA IS NOT INITIAL.
CALL METHOD CL_DEMO_OUTPUT=>DISPLAY
EXPORTING
DATA = DATA.
ENDFORM.
FORM FRM_UPDATE_WORK_CENTER USING LV_NO_COMMIT TYPE XFELD
LV_WERKS TYPE RC68A-WERKS
LV_ARBPL TYPE RC68A-ARBPL
LV_KTSCH TYPE P3003-KTSCH
LV_STEXT TYPE P1000-STEXT
CHANGING LT_RETURN TYPE BAPIRET2_TAB.
DATA: LO_WRKCENTER_API TYPE REF TO CL_PP_WORK_CENTER_BO.
DATA: IS_CRHD TYPE CRHD,
IS_CRHD_API01 TYPE CRHD_API01,
IS_CRHD_API02 TYPE CRHD_API02,
IS_CRHD_API03 TYPE CRHD_API03,
IS_CRHD_API05 TYPE CRHD_API05,
IS_CRHD_API08 TYPE CRHD_API08,
IS_CRHD_API01X TYPE CRHD_API01X,
IS_CRHD_API02X TYPE CRHD_API02X,
IS_CRHD_API03X TYPE CRHD_API03X.
CREATE OBJECT LO_WRKCENTER_API.
SELECT SINGLE *
INTO CORRESPONDING FIELDS OF IS_CRHD
FROM CRHD
WHERE CRHD~OBJTY = 'A'
AND CRHD~BEGDA <= SY-DATUM
AND CRHD~ENDDA >= SY-DATUM
AND CRHD~ARBPL = LV_ARBPL
AND CRHD~WERKS = LV_WERKS.
IS_CRHD_API01-ARBPL = IS_CRHD-ARBPL.
IS_CRHD_API01-WERKS = IS_CRHD-WERKS.
IS_CRHD_API01-VERWE = IS_CRHD-VERWE.
IS_CRHD_API01-KTEXT = LV_STEXT.
IS_CRHD_API03-KTSCH = LV_KTSCH.
IS_CRHD_API03X-KTSCH = 'X'.
IS_CRHD_API03X-CHANGE_FLG = 'U'.
CALL METHOD LO_WRKCENTER_API->UPDATE_WORK_CENTER
EXPORTING
IS_CRHD = IS_CRHD
IS_CRHD_API01 = IS_CRHD_API01
IS_CRHD_API02 = IS_CRHD_API02
IS_CRHD_API03 = IS_CRHD_API03
IS_CRHD_API05 = IS_CRHD_API05
IS_CRHD_API08 = IS_CRHD_API08
IS_CRHD_API01X = IS_CRHD_API01X
IS_CRHD_API02X = IS_CRHD_API02X
IS_CRHD_API03X = IS_CRHD_API03X
IV_NO_COMMIT = LV_NO_COMMIT
IV_LANGUAGE = SY-LANGU
IMPORTING
ET_RETURN = LT_RETURN.
ENDFORM.
相关函数
CRAP_WORKCENTER_CHANGE API work centers: update work center
CRAP_WORKCENTER_CREATE API work centers: create work center
DMC_MIG_WORKCENTER Migration of work center