ABAP-创建货源清单
阅读原文时间:2023年07月11日阅读:2

CALL FUNCTION 'ME_DIRECT_INPUT_SOURCE_LIST'

*&---------------------------------------------------------------------*
*& Report YTST_USE_019_003
*&
*&---------------------------------------------------------------------*
*&
*&
*&---------------------------------------------------------------------*

REPORT YTST_FF_006.

TABLES:MARA,
EORD.

DATA:GT_EORDU TYPE STANDARD TABLE OF EORDU,
WA_EORDU TYPE EORDU,
GT_XEORD TYPE STANDARD TABLE OF EORDU.
DATA:GT_EORD TYPE STANDARD TABLE OF EORD,
WA_EORD TYPE EORD.

SELECTION-SCREEN BEGIN OF BLOCK B3 WITH FRAME TITLE TEXT-.

SELECT-OPTIONS:S_MATNR FOR MARA-MATNR MODIF ID WH NO INTERVALS NO-EXTENSION,
S_WERKS FOR EORD-WERKS MODIF ID WH NO INTERVALS NO-EXTENSION,
S_LIFNR FOR EORD-LIFNR MODIF ID WH NO INTERVALS NO-EXTENSION.
PARAMETER:P_VDATU LIKE EORD-VDATU.
*PARAMETER:P_LIFNR LIKE EORD-LIFNR.

SELECTION-SCREEN BEGIN OF BLOCK B4 WITH FRAME TITLE TEXT-.
PARAMETER:RB_CJ RADIOBUTTON GROUP G2 DEFAULT 'X',
RB_XG RADIOBUTTON GROUP G2.
SELECTION-SCREEN END OF BLOCK B4.

SELECTION-SCREEN END OF BLOCK B3.

DATA:L_ERR TYPE STRING,
L_TEXT TYPE STRING.

IF RB_CJ EQ 'X'.
*&创建货源清单
WA_EORDU-MATNR = S_MATNR-LOW.
WA_EORDU-WERKS = S_WERKS-LOW.
WA_EORDU-LIFNR = S_LIFNR-LOW.
WA_EORDU-EKORG = 'P001'.
WA_EORDU-VDATU = P_VDATU.
WA_EORDU-BDATU = ''.
WA_EORDU-FLIFN = 'X'.
WA_EORDU-KZ = 'I'.
SELECT SINGLE MEINS
INTO WA_EORDU-MEINS
FROM EINA
WHERE MATNR EQ S_MATNR-LOW
AND LIFNR EQ S_LIFNR-LOW.
APPEND WA_EORDU TO GT_EORDU.

* CALL FUNCTION 'ME_DIRECT_INPUT_SOURCE_LIST'
* EXPORTING
* I_MATNR =
* I_WERKS =
** I_MT06E =
** I_NO_MATERIAL_READ =
** ACTIVITY = 'V'
** I_VORGA =
** I_LOGSY =
* TABLES
* T_EORD =
** EXCEPTIONS
** PLANT_MISSING =
** MATERIAL_MISSING =
** OTHERS =
* .
* IF SY-SUBRC <> .
** Implement suitable error handling here
* ENDIF.
*
*CALL FUNCTION 'ME_DIRECT_INPUT_INFORECORD'
* EXPORTING
** ACTIVITY = 'V'
* I_EINA =
** I_EINE =
** O_EINA =
** O_EINE =
** I_NO_SUPPOSE =
** I_VORGA =
** I_SKIP_NR_CHECK =
** IMPORTING
** E_EINA =
** E_EINE =
** TABLES
** T_HEAD =
** T_LINE =
** EXCEPTIONS
** TEXTNAME_INVALID =
** OTHERS =
* .
*IF SY-SUBRC <> .
** Implement suitable error handling here
*ENDIF.

CALL FUNCTION 'ME_DIRECT_INPUT_SOURCE_LIST'
EXPORTING
I_MATNR = S_MATNR-LOW
I_WERKS = S_WERKS-LOW
TABLES
T_EORD = GT_EORDU
EXCEPTIONS
PLANT_MISSING =
MATERIAL_MISSING =
ERROR_MESSAGE =
OTHERS = .

IF SY-SUBRC <> .
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4
INTO L_TEXT.
L_ERR = 'FAIL'.
* CONTINUE.
ELSE.
CALL FUNCTION 'ME_POST_SOURCE_LIST_NEW'
EXPORTING
I_MATNR = S_MATNR-LOW.
IF SY-SUBRC <> .
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
L_ERR = 'FAIL'.
* CONTINUE.
ENDIF.
CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'
EXPORTING
WAIT = 'X'.
IF SY-SUBRC <> .
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
L_ERR = 'FAIL'.
* CONTINUE.
ENDIF.

IF L\_ERR NE 'FAIL'.  
  L\_ERR = '创建货源清单成功'.  
ENDIF.

ENDIF.
ELSE.
*&修改货源清单
SELECT *
INTO TABLE GT_EORD
FROM EORD
WHERE MATNR EQ S_MATNR-LOW
AND WERKS EQ S_WERKS-LOW.

* WA_EORDU-MATNR = S_MATNR-LOW.
* WA_EORDU-WERKS = S_WERKS-LOW.
* WA_EORDU-LIFNR = S_LIFNR-LOW.
* WA_EORDU-EKORG = 'P001'.
* WA_EORDU-VDATU = P_VDATU.
* WA_EORDU-BDATU = ''.
* WA_EORDU-FLIFN = 'X'.
* WA_EORDU-KZ = 'I'.
* SELECT SINGLE MEINS
* INTO WA_EORDU-MEINS
* FROM EINA
* WHERE MATNR EQ S_MATNR-LOW
* AND LIFNR EQ S_LIFNR-LOW.
* APPEND WA_EORDU TO GT_EORD.

MOVE-CORRESPONDING GT_EORD TO GT_XEORD.
LOOP AT GT_XEORD INTO WA_EORDU.
WA_EORDU-LIFNR = S_LIFNR-LOW.
WA_EORDU-VDATU = P_VDATU.
WA_EORDU-KZ = 'I'.
MODIFY GT_XEORD FROM WA_EORDU TRANSPORTING LIFNR VDATU.
ENDLOOP.

* CALL FUNCTION 'ME_UPDATE_SOURCES_OF_SUPPLY'
** EXPORTING
** DOCUMENT_NUMBER = ' '
** I_CHANGEDOCUMENT =
* TABLES
* XEORD =
* YEORD =
*
CALL FUNCTION 'ME_UPDATE_SOURCES_OF_SUPPLY'
TABLES
XEORD = GT_XEORD
YEORD = GT_EORD.
IF SY-SUBRC = .
COMMIT WORK AND WAIT.
L_ERR = 'SUCCESS'.
ELSE.
ROLLBACK WORK.
L_ERR = 'FAIL'.
ENDIF.
ENDIF.

WRITE:L_ERR,
L_TEXT.

手机扫一扫

移动阅读更方便

阿里云服务器
腾讯云服务器
七牛云服务器

你可能感兴趣的文章