FUNCTION ZBAPI_NETWORK_COMP_CHANGE.
*"----------------------------------------------------------------------
*"*"Local interface:
*" TABLES
*" INPUT STRUCTURE ZBAPI_NETWORK_COMP_CHANGE OPTIONAL
*" OUTPUT STRUCTURE ZBAPI_NETWORK_COMP_CHANGE_OUT OPTIONAL
*"----------------------------------------------------------------------
DATA: G_INFO TYPE STRING.
DATA:FLAG(1),
m_MESSAGE(100),
m_DATE TYPE D,
m_RSNUM TYPE RESB-RSNUM,
m_RSPOS TYPE RESB-RSPOS,
m_RSART TYPE RESB-RSART,
m_ENMNG TYPE RESB-ENMNG.
DATA:NUMBER TYPE BAPI_NETWORK_LIST-NETWORK,
I_COMPONENTS_CHANGE TYPE TABLE OF BAPI_NETWORK_COMP_CHANGE WITH HEADER LINE,
I_COMPONENTS_CHANGE_UPDATE TYPE TABLE OF BAPI_NETWORK_COMP_CNG_UPD WITH HEADER LINE,
E_MESSAGE_TABLE TYPE TABLE OF BAPI_METH_MESSAGE WITH HEADER LINE.
DATA:t_OBJNR TYPE AFVC-OBJNR,
m_STAT TYPE JEST-STAT.
LOOP AT INPUT.
CLEAR m_RSNUM.
CLEAR m_RSPOS.
CLEAR m_RSART.
CLEAR m_ENMNG.
CLEAR NUMBER.
SELECT SINGLE
ENMNG
INTO m_ENMNG
FROM RESB
WHERE AUFNR = INPUT-AUFNR
AND VORNR = INPUT-ACTIVITY
AND POSNR = INPUT-POSNR
AND XLOEK <> ‘X‘.
MOVE-CORRESPONDING INPUT TO OUTPUT.
* 以下代码如果活动TECO之后,则不允许新增物料
CLEAR t_OBJNR.
CLEAR m_STAT.
SELECT SINGLE
B~OBJNR
INTO t_OBJNR
FROM CAUFV AS A INNER JOIN AFVC AS B ON A~AUFPL = B~AUFPL
WHERE A~AUFNR = INPUT-AUFNR
AND B~VORNR = INPUT-ACTIVITY.
SELECT SINGLE
A~STAT
INTO m_STAT
FROM JEST AS A INNER JOIN TJ02T AS B ON A~STAT = B~ISTAT AND B~SPRAS = ‘1‘
WHERE A~OBJNR = t_OBJNR
AND B~TXT04 = ‘TECO‘
AND A~INACT <> ‘X‘.
IF m_STAT <> ‘‘.
IF INPUT-ENTRY_QUANTITY < m_ENMNG.
OUTPUT-FLAG = ‘E‘.
CONCATENATE ‘修改失败:‘ ‘数量不能小于提货数!‘ INTO OUTPUT-MESSAGE.
APPEND OUTPUT.
CLEAR OUTPUT.
ELSE.
SELECT SINGLE
RSNUM
RSPOS
RSART
INTO (m_RSNUM,m_RSPOS,m_RSART )
FROM RESB
WHERE AUFNR = INPUT-AUFNR
AND VORNR = INPUT-ACTIVITY
AND POSNR = INPUT-POSNR
AND XLOEK <> ‘X‘.
* 在结尾的时候,保存记录
* AT END OF AUFNR.
CALL FUNCTION ‘BAPI_NETWORK_COMP_CHANGE‘
EXPORTING
NUMBER = NUMBER
TABLES
I_COMPONENTS_CHANGE = I_COMPONENTS_CHANGE
I_COMPONENTS_CHANGE_UPDATE = I_COMPONENTS_CHANGE_UPDATE
E_MESSAGE_TABLE = E_MESSAGE_TABLE.
CLEAR E_MESSAGE_TABLE.
LOOP AT E_MESSAGE_TABLE WHERE MESSAGE_TYPE = ‘E‘ OR MESSAGE_TYPE = ‘A‘.
FLAG = ‘X‘.
OUTPUT-FLAG = ‘E‘.
CONCATENATE OUTPUT-MESSAGE ‘&‘ E_MESSAGE_TABLE-MESSAGE_TEXT INTO OUTPUT-MESSAGE.
ENDLOOP.
IF FLAG = ‘X‘.
CALL FUNCTION ‘BAPI_TRANSACTION_ROLLBACK‘.
ELSE.
CALL FUNCTION ‘BAPI_TRANSACTION_COMMIT‘.
WAIT UP TO 1 SECONDS.
OUTPUT-FLAG = ‘S‘.
LOOP AT E_MESSAGE_TABLE WHERE MESSAGE_TYPE = ‘I‘ OR MESSAGE_TYPE = ‘S‘.
m_MESSAGE = E_MESSAGE_TABLE-MESSAGE_TEXT.
ENDLOOP.
CONCATENATE ‘修改成功:‘ m_MESSAGE INTO OUTPUT-MESSAGE.
ENDIF.
APPEND OUTPUT.
CLEAR OUTPUT.
CLEAR I_COMPONENTS_CHANGE.
REFRESH I_COMPONENTS_CHANGE.