采购信息记录bapi
作者:互联网
记录获取
* Call Function Module to check the Info Record
CALL FUNCTION 'BAPI_INFORECORD_GETLIST' "#EC CI_USAGE_OK[2438131]
EXPORTING
VENDOR = C_W_ORGA-LIFNR
MATERIAL_LONG = C_W_ORGA-MATNR
TABLES
INFORECORD_GENERAL = LIT_INFORE_GEN
INFORECORD_PURCHORG = LIT_INFORE_PUR.
记录创建
DATA:
LIT_EINA TYPE MEWIEINA_T,
LW_EINA TYPE MEWIEINA,
LIT_EINAX TYPE MEWIEINAX_T,
LW_EINAX TYPE MEWIEINAX_TY,
LIT_EINE TYPE MEWIEINE_T,
LW_EINE TYPE MEWIEINE_TY,
LIT_EINEX TYPE MEWIEINEX_T,
LW_EINEX TYPE MEWIEINEX_TY,
LIT_VALIDITY TYPE MEWIVALIDITY_TT,
LW_VALIDITY TYPE MEWIVALIDITY_TY,
LIT_CONDITION TYPE MEWICONDITION_TT,
LW_CONDITION TYPE MEWICONDITION_TY,
LV_INDEX TYPE NUM.
DATA:LW_A017 TYPE TYP_W_A017.
CLEAR:C_IT_RETURN.
LW_EINA-MATERIAL = U_W_ORGA-MATNR.
LW_EINA-VENDOR = U_W_ORGA-LIFNR.
* CW_EINA-BASE_UOM = 'EA'.
* CW_EINA-PO_UNIT = 'EA'.
LW_EINA-CONV_NUM1 = 1."转换分子
LW_EINA-CONV_DEN1 = 1."转换分母
LW_EINAX-MATERIAL = 'X'.
LW_EINAX-VENDOR = 'X'.
* CW_EINAX-BASE_UOM = 'X'.
* CW_EINAX-PO_UNIT = 'X'.
LW_EINAX-CONV_NUM1 = 'X'.
LW_EINAX-CONV_DEN1 = 'X'.
APPEND LW_EINA TO LIT_EINA.
CLEAR LW_EINA.
APPEND LW_EINAX TO LIT_EINAX.
CLEAR LW_EINAX.
LOOP AT U_IT_PLANT_DATA ASSIGNING FIELD-SYMBOL(<LW_PLANT_DATA>)
WHERE KUNNR = U_W_ORGA-KUNNR.
LV_INDEX = LV_INDEX + 1.
LW_EINE-EINE_INDX = LV_INDEX.
* PIR 类型值:0 标准 2 寄售 3 分包合同 P 管道1 可记帐
LW_EINE-PURCH_ORG = U_W_ORGA-VKORG1.
* LW_EINE-PLANT = U_W_ORGA-WERKS1.
LW_EINE-PLANT = <LW_PLANT_DATA>-WERKS.
LW_EINE-INFO_TYPE = '0'.
LW_EINE-CONV_NUM1 = 1. "转换分子
LW_EINE-CONV_DEN1 = 1 ."转换分母
LW_EINE-PLND_DELRY = U_W_ORGA-ZSPLT.
READ TABLE U_IT_FIXED_VAL INTO DATA(LW_FIXED_VAL)
WITH KEY KEY1 = CNS_EKGRP
KEY2 = CNS_PIR. "#EC CI_STDSEQ
LW_EINE-PUR_GROUP = LW_FIXED_VAL-VALUE1.
LW_EINE-NRM_PO_QTY = U_W_ORGA-MINBM.
* MOD CTF-1732 ACN_SHIJ 2020/09/06 END
LW_EINE-MIN_PO_QTY = U_W_ORGA-MINBM.
APPEND LW_EINE TO LIT_EINE.
CLEAR LW_EINE.
LW_EINEX-EINE_INDX = LV_INDEX.
LW_EINEX-PURCH_ORG = 'X'.
LW_EINEX-PLANT = 'X'.
LW_EINEX-INFO_TYPE = 'X'.
LW_EINEX-CONV_NUM1 = 'X'.
LW_EINEX-CONV_DEN1 = 'X'.
LW_EINEX-PLND_DELRY = 'X'.
LW_EINEX-PUR_GROUP = 'X'.
LW_EINEX-NRM_PO_QTY = 'X'.
LW_EINEX-MIN_PO_QTY = 'X'.
APPEND LW_EINEX TO LIT_EINEX.
CLEAR LW_EINEX.
LW_VALIDITY-EINE_INDX = LV_INDEX.
LW_VALIDITY-PLANT = <LW_PLANT_DATA>-WERKS.
IF U_W_ORGA-ZCPUVT IS INITIAL.
LW_VALIDITY-VALID_TO = CNS_ZCPUVT.
ELSE.
LW_VALIDITY-VALID_TO = U_W_ORGA-ZCPUVT.
ENDIF.
LW_VALIDITY-VALID_FROM = U_W_ORGA-ZCPUVF.
READ TABLE U_IT_A017 INTO LW_A017 WITH KEY
LIFNR = U_W_ORGA-LIFNR
MATNR = U_W_ORGA-MATNR
* EKORG = U_W_PUR_ORG-EKORG
EKORG = U_W_ORGA-VKORG1
WERKS = <LW_PLANT_DATA>-WERKS
DATBI = LW_VALIDITY-VALID_TO.
IF LW_A017-KNUMH IS NOT INITIAL.
LW_VALIDITY-SERIAL_ID = LW_A017-KNUMH.
ELSE.
LW_VALIDITY-SERIAL_ID = 'A' && <LW_PLANT_DATA>-WERKS && '00001'.
ENDIF.
APPEND LW_VALIDITY TO LIT_VALIDITY.
CLEAR LW_VALIDITY.
LW_CONDITION-EINE_INDX = LV_INDEX.
LW_CONDITION-COND_TYPE = 'ZP00'.
IF LW_A017-KNUMH IS NOT INITIAL.
LW_CONDITION-SERIAL_ID = LW_A017-KNUMH.
LW_CONDITION-CHANGE_ID = 'U' .
ELSE.
LW_CONDITION-SERIAL_ID = 'A' && <LW_PLANT_DATA>-WERKS && '00001'.
LW_CONDITION-CHANGE_ID = 'I' .
ENDIF.
LW_CONDITION-COND_VALUE = U_W_ORGA-ZCPUPR.
LW_CONDITION-CURRENCY = U_W_ORGA-ZCPUC.
APPEND LW_CONDITION TO LIT_CONDITION.
CLEAR LW_CONDITION.
IF ( U_W_ORGA-ZNPPR IS NOT INITIAL
AND U_W_ORGA-ZNPUC IS NOT INITIAL
AND U_W_ORGA-ZNPVF IS NOT INITIAL
AND U_W_ORGA-ZNPVT IS NOT INITIAL ).
LW_VALIDITY-EINE_INDX = LV_INDEX.
LW_VALIDITY-PLANT = <LW_PLANT_DATA>-WERKS.
LW_VALIDITY-VALID_TO = U_W_ORGA-ZNPVT.
LW_VALIDITY-VALID_FROM = U_W_ORGA-ZNPVF.
READ TABLE U_IT_A017 INTO LW_A017 WITH KEY
LIFNR = U_W_ORGA-LIFNR
MATNR = U_W_ORGA-MATNR
EKORG = U_W_ORGA-VKORG1
WERKS = <LW_PLANT_DATA>-WERKS
DATBI = LW_VALIDITY-VALID_TO.
IF LW_A017-KNUMH IS NOT INITIAL.
LW_VALIDITY-SERIAL_ID = LW_A017-KNUMH.
ELSE.
LW_VALIDITY-SERIAL_ID = 'A' && <LW_PLANT_DATA>-WERKS && '00002'.
ENDIF.
APPEND LW_VALIDITY TO LIT_VALIDITY.
CLEAR LW_VALIDITY.
LW_CONDITION-EINE_INDX = LV_INDEX.
LW_CONDITION-COND_TYPE = 'ZP00'.
IF LW_A017-KNUMH IS NOT INITIAL.
LW_CONDITION-SERIAL_ID = LW_A017-KNUMH.
LW_CONDITION-CHANGE_ID = 'U' .
ELSE.
LW_CONDITION-SERIAL_ID = 'A' && <LW_PLANT_DATA>-WERKS && '00002'.
LW_CONDITION-CHANGE_ID = 'I' .
ENDIF.
LW_CONDITION-COND_VALUE = U_W_ORGA-ZNPPR.
LW_CONDITION-CURRENCY = U_W_ORGA-ZNPUC.
APPEND LW_CONDITION TO LIT_CONDITION.
CLEAR LW_CONDITION.
ENDIF.
ENDLOOP.
CALL FUNCTION 'ME_INFORECORD_MAINTAIN_MULTI'
TABLES
T_EINA = LIT_EINA
T_EINAX = LIT_EINAX
T_EINE = LIT_EINE
T_EINEX = LIT_EINEX
COND_VALIDITY = LIT_VALIDITY
CONDITION = LIT_CONDITION
RETURN = C_IT_RETURN.
CALL FUNCTION 'BAPI_INFORECORD_GETLIST' "#EC CI_USAGE_OK[2438131]
EXPORTING
VENDOR = C_W_ORGA-LIFNR
* MATERIAL = LV_MATNR18
*> DEL CR1747 2021/05/24 ----------------------------------------------*
* PURCH_ORG = LW_PUR_ORG-EKORG
* PLANT = C_W_ORGA-WERKS1
*< DEL CR1747 2021/05/24 ----------------------------------------------*
MATERIAL_LONG = C_W_ORGA-MATNR
TABLES
INFORECORD_GENERAL = LIT_INFORE_GEN
INFORECORD_PURCHORG = LIT_INFORE_PUR.
标签:bapi,记录,ORGA,VALIDITY,LIT,LW,EINE,采购,CONDITION 来源: https://www.cnblogs.com/lingxiaoj/p/14814321.html