CALL FUNCTION 'ME_DIRECT_INPUT_SOURCE_LIST'

Function module IDOC_INPUT_SRCLST

FUNCTION IDOC_INPUT_SRCLST.
*"----------------------------------------------------------------------
*"*"Lokale Schnittstelle:
*" IMPORTING
*" VALUE(INPUT_METHOD) LIKE BDWFAP_PAR-INPUTMETHD
*" VALUE(MASS_PROCESSING) LIKE BDWFAP_PAR-MASS_PROC
*" EXPORTING
*" VALUE(WORKFLOW_RESULT) LIKE BDWF_PARAM-RESULT
*" VALUE(APPLICATION_VARIABLE) LIKE BDWF_PARAM-APPL_VAR
*" VALUE(IN_UPDATE_TASK) LIKE BDWFAP_PAR-UPDATETASK
*" VALUE(CALL_TRANSACTION_DONE) LIKE BDWFAP_PAR-CALLTRANS
*" TABLES
*" IDOC_CONTRL STRUCTURE EDIDC
*" IDOC_DATA STRUCTURE EDIDD
*" IDOC_STATUS STRUCTURE BDIDOCSTAT
*" RETURN_VARIABLES STRUCTURE BDWFRETVAR
*" SERIALIZATION_INFO STRUCTURE BDI_SER
*" EXCEPTIONS
*" WRONG_FUNCTION_CALLED
*"----------------------------------------------------------------------
ENHANCEMENT-POINT IDOC_INPUT_SRCLST_G1 SPOTS ES_SAPLMEAI.
*$*$-Start: IDOC_INPUT_SRCLST_G1----------------------------------------------------------------$*$*
ENHANCEMENT 1 MGV_GENERATED_IDOC_INPUT_SR000. "active version
*{ALE Begin} generation http://intranet.sap.com/materialversion
CALL FUNCTION 'MGV_ALE_ADD_INTERNAL_MATNR'
TABLES
idoc_data = idoc_data
idoc_contrl = idoc_contrl
EXCEPTIONS
NUMBER_MISMATCH = 1
OTHERS = 2.
*{ALE End} generation
ENDENHANCEMENT.
*$*$-End: IDOC_INPUT_SRCLST_G1----------------------------------------------------------------$*$*

DATA: F_IDOC_CONTROL LIKE EDIDC,
F_IDOC_STATUS LIKE BDIDOCSTAT,
F_E1EORDH LIKE E1EORDH,
SUBRC LIKE SY-SUBRC.

DATA: T_IDOC_DATA LIKE EDIDD OCCURS 0 WITH HEADER LINE,
T_EORD LIKE EORD OCCURS 0 WITH HEADER LINE,
T_EORDU LIKE EORDU OCCURS 0 WITH HEADER LINE,
lt_tupel TYPE STANDARD TABLE OF metup WITH DEFAULT KEY,"1389182
ls_tupel TYPE metup.

DATA: BEGIN OF F_EORDKEY,
MATNR LIKE EORD-MATNR,
WERKS LIKE EORD-WERKS,
END OF F_EORDKEY.

*--- refresh workflow result
WORKFLOW_RESULT = C_WF_RESULT_OK.

CLEAR SERIALIZATION_INFO.
REFRESH SERIALIZATION_INFO.
*- serialization info get
CALL FUNCTION 'IDOC_SERIALIZATION_CHECK'
TABLES
IDOC_SERIAL = SERIALIZATION_INFO
IDOC_DATA = IDOC_DATA
IDOC_CONTROL = IDOC_CONTRL.

* Initialization
CALL FUNCTION 'ME_INITIALIZE_SOURCE_LIST'.

LOOP AT IDOC_CONTRL.
F_IDOC_CONTROL = IDOC_CONTRL.

* check idoc type
IF F_IDOC_CONTROL-IDOCTP <> C_IDOCTP_SRCLST01.
RAISE WRONG_FUNCTION_CALLED.
ENDIF.

* Read data records for each idoc
REFRESH T_IDOC_DATA.
LOOP AT IDOC_DATA WHERE DOCNUM = F_IDOC_CONTROL-DOCNUM.
T_IDOC_DATA = IDOC_DATA.
APPEND T_IDOC_DATA.
ENDLOOP.

* refresh target tables
CLEAR: T_EORD, F_IDOC_STATUS, SUBRC, F_E1EORDH, T_EORDU, lt_tupel."1389182
REFRESH: T_EORD, T_EORDU.

* check skipped entries
PERFORM CHECK_SERIAL_SRCLST
TABLES
SERIALIZATION_INFO
USING F_IDOC_CONTROL-DOCNUM
F_IDOC_STATUS
SUBRC.
* error occurs in check of skipped entries
IF SUBRC <> 0.
IDOC_STATUS = F_IDOC_STATUS.
IDOC_STATUS-DOCNUM = F_IDOC_CONTROL-DOCNUM.
APPEND IDOC_STATUS.

RETURN_VARIABLES-WF_PARAM = C_WF_PAR_PROCESSED_IDOCS.
RETURN_VARIABLES-DOC_NUMBER = F_IDOC_CONTROL-DOCNUM.
APPEND RETURN_VARIABLES.
RETURN_VARIABLES-WF_PARAM = C_WF_PAR_APPL_OBJECTS.
F_EORDKEY-MATNR = SPACE.
F_EORDKEY-WERKS = SPACE.
RETURN_VARIABLES-DOC_NUMBER = F_EORDKEY.
APPEND RETURN_VARIABLES.
CONTINUE.
ENDIF.

* fill application structures
PERFORM FILL_APPL_STRUCTURES_SRCLST
TABLES T_IDOC_DATA
T_EORD
USING F_IDOC_CONTROL
F_IDOC_STATUS
F_E1EORDH
SUBRC.
* error occurs in filling application structures
IF SUBRC <> 0.
IDOC_STATUS = F_IDOC_STATUS.
IDOC_STATUS-DOCNUM = F_IDOC_CONTROL-DOCNUM.
APPEND IDOC_STATUS.

RETURN_VARIABLES-WF_PARAM = C_WF_PAR_ERROR_IDOCS.
RETURN_VARIABLES-DOC_NUMBER = F_IDOC_CONTROL-DOCNUM.
APPEND RETURN_VARIABLES.
WORKFLOW_RESULT = C_WF_RESULT_ERROR.
CONTINUE.
ENDIF.

LOOP AT T_EORD.
T_EORDU = T_EORD.
T_EORDU-KZ = C_FLAG_INSERT.
APPEND T_EORDU.
* create MRP relevant information
CLEAR ls_tupel. "1389182
ls_tupel-matnr = t_eord-matnr.
ls_tupel-werks = t_eord-werks.
ls_tupel-read = abap_true.
INSERT ls_tupel INTO TABLE lt_tupel.
ENDLOOP.
SORT T_EORDU BY ZEORD.

CALL FUNCTION 'ME_DIRECT_INPUT_SOURCE_LIST'
EXPORTING
I_MATNR = F_E1EORDH-MATNR
I_WERKS = F_E1EORDH-WERKS
I_VORGA = C_CODE_ALE
I_LOGSY = F_E1EORDH-LOGSY
TABLES
T_EORD = T_EORDU
EXCEPTIONS
PLANT_MISSING = 1
MATERIAL_MISSING = 2
ERROR_MESSAGE = 4
OTHERS = 3.

SUBRC = SY-SUBRC.
IF SUBRC <> 0.
CLEAR IDOC_STATUS.
IDOC_STATUS-DOCNUM = F_IDOC_CONTROL-DOCNUM.
IDOC_STATUS-STATUS = C_IDOC_STAT_INPUT_ERROR.
IDOC_STATUS-MSGID = SY-MSGID.
IDOC_STATUS-MSGTY = SY-MSGTY.
IDOC_STATUS-MSGNO = SY-MSGNO.
IDOC_STATUS-MSGV1 = SY-MSGV1.
IDOC_STATUS-MSGV2 = SY-MSGV2.
IDOC_STATUS-MSGV3 = SY-MSGV3.
IDOC_STATUS-MSGV4 = SY-MSGV4.
IDOC_STATUS-UNAME = SY-UNAME.
IDOC_STATUS-REPID = SY-REPID.
APPEND IDOC_STATUS.

RETURN_VARIABLES-WF_PARAM = C_WF_PAR_ERROR_IDOCS.
RETURN_VARIABLES-DOC_NUMBER = F_IDOC_CONTROL-DOCNUM.
APPEND RETURN_VARIABLES.
WORKFLOW_RESULT = C_WF_RESULT_ERROR.
CONTINUE.
ELSE.
CLEAR IDOC_STATUS.
IDOC_STATUS-DOCNUM = F_IDOC_CONTROL-DOCNUM.
IDOC_STATUS-STATUS = C_IDOC_STAT_IS_POSTED.
IDOC_STATUS-MSGID = C_MSG_ID_ME. "391782
IDOC_STATUS-MSGTY = C_MSG_TY_I.
IDOC_STATUS-MSGNO = '877'. "391782
IDOC_STATUS-MSGV1 = F_E1EORDH-MATNR.
IDOC_STATUS-MSGV2 = F_E1EORDH-WERKS.
IDOC_STATUS-UNAME = SY-UNAME.
IDOC_STATUS-REPID = SY-REPID.
APPEND IDOC_STATUS.

RETURN_VARIABLES-WF_PARAM = C_WF_PAR_PROCESSED_IDOCS.
RETURN_VARIABLES-DOC_NUMBER = F_IDOC_CONTROL-DOCNUM.
APPEND RETURN_VARIABLES.
RETURN_VARIABLES-WF_PARAM = C_WF_PAR_APPL_OBJECTS.
F_EORDKEY-MATNR = F_E1EORDH-MATNR.
F_EORDKEY-WERKS = F_E1EORDH-WERKS.
RETURN_VARIABLES-DOC_NUMBER = F_EORDKEY.
APPEND RETURN_VARIABLES.
CONTINUE.
ENDIF.

ENDLOOP. "<------------------------- idoc_contrl.

CALL FUNCTION 'ME_POST_SOURCE_LIST_NEW'.
* trigger MRP update
CALL FUNCTION 'ME_WRITE_DISP_RECORD_SOS' IN UPDATE TASK "1389182
TABLES
eord_alt = t_eord
eord_neu = t_eordu
tupel = lt_tupel.

CALL CUSTOMER-FUNCTION '002'
EXPORTING
MESSAGE_TYPE = F_IDOC_CONTROL-MESTYP.

IN_UPDATE_TASK = C_TRUE.

ENDFUNCTION.

05-28 18:26