PR 修改保存的增强 ME_UPDATE_REQUISITION
阅读原文时间:2023年07月14日阅读:2

FUNCTION me_update_requisition.
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""$"$\SE:(1) Function Module ME_UPDATE_REQUISITION, Start A
*$*$-Start: (1)---------------------------------------------------------------------------------$*$*
ENHANCEMENT 1 YHSBC_MM_SAVE_FOR_EBAN_FIELDS. "active version

*&start changed by robin 20140412 ECDK917957
*&据IP取得相关登录用户并作修改:
CALL FUNCTION 'YH_BC_MM_SAVE_EBAN_FIELDS'
TABLES
XEBAN_TAB = XEBAN
YEBAN_TAB = YEBAN.
*&END CHANGED BY ROBIN 20140304

ENDENHANCEMENT.
ENHANCEMENT 1 YH_PR_SAVE_ENHANCEMENT. "active version
CALL FUNCTION 'YH_PR_SAVE_EXIST'
TABLES
xeban = XEBAN
yeban = YEBAN
.
*
ENDENHANCEMENT.
*$*$-End: (1)---------------------------------------------------------------------------------$*$*
*"----------------------------------------------------------------------
*"*"Update Function Module:
*"
*"*"Global Interface:
*" IMPORTING
*" VALUE(XPREXT) TYPE MEREQ_T_UPREXT OPTIONAL
*" VALUE(MEREQX) TYPE MEREQ_T_UMEREQX OPTIONAL
*" TABLES
*" XEBAN STRUCTURE UEBAN
*" XEBKN STRUCTURE UEBKN
*" YEBAN STRUCTURE UEBAN
*" YEBKN STRUCTURE UEBKN
*" DRS_ITEMS TYPE MMPUR_DRS_ITEMS_TTY OPTIONAL
*"----------------------------------------------------------------------
*- fuellen Altstruktur Banf -----------------------------------------
CLEAR oeban.
LOOP AT yeban.
MOVE yeban TO oeban.
APPEND oeban.
ENDLOOP.
SORT oeban BY banfn bnfpo.

*------- Check if EhP4 switch is on----------------------------------*
DATA lv_ehp4_sfws_p2pse TYPE xfeld.
DAta ls_eban type eban.
lv_ehp4_sfws_p2pse = ''.
lv_ehp4_sfws_p2pse = cl_ops_switch_check=>mm_sfws_p2pse( ).

REFRESH: db_eban, db_eban_u, db_ebub, db_ebub_d.
REFRESH: tebav.

*------- Positionen Loeschen ------------------------------------------*
LOOP AT oeban.
IF oeban-kz EQ 'D'.
MOVE-CORRESPONDING oeban TO eban.
MOVE eban TO db_eban.
APPEND db_eban.
*------- Umlagerungsindex ---------------------------------------------*
* IF EBAN-PSTYP EQ '7'.
IF eban-reswk NE space AND eban-bsakz NE 'R' AND
eban-matnr NE space AND
eban-ebakz EQ space AND
eban-loekz EQ space AND
eban-menge GT eban-bsmng.
MOVE-CORRESPONDING eban TO ebub.
MOVE ebub TO db_ebub_d.
APPEND db_ebub_d.
ENDIF.
ENDIF.

ENHANCEMENT-POINT EHP603_ME_UPDATE_REQUISITION_1 SPOTS ES_SAPLEBNU_P2P.
*$*$-Start: EHP603_ME_UPDATE_REQUISITION_1------------------------------------------------------$*$*
ENHANCEMENT 1 MM_SFWS_EBNU. "active version
*-------Create change pointer for TREX
PERFORM trex_change_pointer USING oeban-banfn
oeban-kz.
ENDENHANCEMENT.
*$*$-End: EHP603_ME_UPDATE_REQUISITION_1------------------------------------------------------$*$*

IF lv_ehp4_sfws_p2pse EQ 'X'.
* MOVE-CORRESPONDING oeban to ls_eban.
CALL FUNCTION 'ME_TREX_TRIGGER_PR'
EXPORTING
IV_BANFN = oeban-banfn
IV_BNFPO = oeban-bnfpo
IV_EBAN_CHANGEID = oeban-kz
* IT_CHANGED_PR = IT_CHANGED_PR
.

* CALL FUNCTION 'ME_TREX_TRIGGER_PR'
* EXPORTING
* IS_BANFN = oeban-banfn
* IS_BNFPO = oeban-bnfpo
** IS_EBAN = ls_eban
** IS_EBKN = IS_EBKN
** IS_EBAN_TECH = IS_EBAN_TECH
* IV_EBAN_CHANGEID = oeban-kz
** IV_EBKN_CHANGEID = IV_EBKN_CHANGEID
** IV_EBAN_TECH_CHANGEID = IV_EBAN_TECH_CHANGEID
.
ENDIF.
ENDLOOP.

DESCRIBE TABLE db_eban LINES sy-tfill.
IF sy-tfill GT 0.
DELETE eban FROM TABLE db_eban.
IF sy-subrc NE 0.
MESSAGE a809 WITH 'EBAN'.
ENDIF.
REFRESH db_eban.
ENDIF.

REFRESH: db_eban, db_eban_u.
REFRESH: tebav.

* 1. Runde verbuchen der Banfen per Array-Operationen
*------- Banfen verbuchen ---------------------------------------------*
LOOP AT xeban.
MOVE xeban TO eban.
*------- Neue Banf/Banfposition ---------------------------------------*
IF xeban-kz EQ 'I'.
MOVE xeban TO db_eban.
APPEND db_eban.

*------- Umlagerungsindex ---------------------------------------------*
* IF EBAN-PSTYP EQ '7'.
IF eban-reswk NE space AND eban-bsakz NE 'R' AND
eban-matnr NE space AND
eban-ebakz EQ space AND
eban-loekz EQ space AND
eban-menge GT eban-bsmng.
MOVE-CORRESPONDING eban TO ebub.
MOVE ebub TO db_ebub.
APPEND db_ebub.
ENDIF.

ENDIF.
*------- Geaenderte Banf/Banfposition ---------------------------------*
IF xeban-kz EQ 'U'.
* MOVE XEBAN TO DB_EBAN_U.
* APPEND DB_EBAN_U.
MOVE-CORRESPONDING xeban TO tebav.
APPEND tebav.
ENDIF.
ENHANCEMENT-POINT ehp603_me_update_requisition_2 SPOTS es_saplebnu_p2p.
*$*$-Start: EHP603_ME_UPDATE_REQUISITION_2------------------------------------------------------$*$*
ENHANCEMENT 2 MM_SFWS_EBNU. "active version
*-------Create change pointer for TREX
PERFORM trex_change_pointer USING xeban-banfn
xeban-kz.
ENDENHANCEMENT.
*$*$-End: EHP603_ME_UPDATE_REQUISITION_2------------------------------------------------------$*$*

IF lv_ehp4_sfws_p2pse EQ 'X'.
* MOVE-CORRESPONDING Xeban to ls_eban.

CALL FUNCTION 'ME_TREX_TRIGGER_PR'
EXPORTING
IV_BANFN = xeban-banfn
IV_BNFPO = xeban-bnfpo
IV_EBAN_CHANGEID = xeban-kz
* IT_CHANGED_PR = IT_CHANGED_PR
.

* CALL FUNCTION 'ME_TREX_TRIGGER_PR'
* EXPORTING
* IS_BANFN = xeban-banfn
* IS_BNFPO = xeban-bnfpo
** IS_EBAN = ls_eban
** IS_EBKN = IS_EBKN
** IS_EBAN_TECH = IS_EBAN_TECH
* IV_EBAN_CHANGEID = xeban-kz
** IV_EBKN_CHANGEID = IV_EBKN_CHANGEID
** IV_EBAN_TECH_CHANGEID = IV_EBAN_TECH_CHANGEID
* .
ENDIF.
ENDLOOP.
DESCRIBE TABLE db_eban LINES sy-tfill.
IF sy-tfill GT 0.
INSERT eban FROM TABLE db_eban.
IF sy-subrc NE 0.
MESSAGE a807 WITH 'EBAN'.
ENDIF.
REFRESH db_eban.
ENDIF.
*ESCRIBE TABLE DB_EBAN_U LINES SY-TFILL.
DESCRIBE TABLE tebav LINES sy-tfill.
IF sy-tfill GT 0.
* UPDATE EBAN FROM TABLE DB_EBAN_U.
UPDATE ebav FROM TABLE tebav.
IF sy-subrc NE 0.
MESSAGE a808 WITH 'EBAN'.
ENDIF.
* REFRESH DB_EBAN_U.
REFRESH tebav.
ENDIF.
*2. RUNDE --> UMFELDAKTIONEN
*------- Banfen verbuchen ---------------------------------------------*
LOOP AT xeban.
MOVE xeban TO eban.
*------- Neue Banf/Banfposition ---------------------------------------*
IF xeban-kz EQ 'I'.

*------- Index RSDB für Positionen mit ARSNR --------------------------*
IF NOT eban-arsnr IS INITIAL AND
NOT eban-arsps IS INITIAL.
CALL FUNCTION 'RSDB_CREATE_WITH_EBAN'
EXPORTING
banfn = eban-banfn
bnfpo = eban-bnfpo
rsnum = eban-arsnr
rspos = eban-arsps
EXCEPTIONS
parameters_not_specified = 02
record_already_exist = 03.
IF sy-subrc NE 0.
MESSAGE a807 WITH 'RSDB'.
ENDIF.
ENDIF.
ENDIF.
*------- Geaenderte Banf/Banfposition ---------------------------------*
IF xeban-kz EQ 'U'.
*------- Index RSDB für Positionen mit ARSNR fortschreiben ------------*
MOVE-CORRESPONDING eban TO bsnkey.
READ TABLE oeban WITH KEY bsnkey BINARY SEARCH.
IF sy-subrc EQ 0.
IF eban-reswk NE oeban-reswk OR eban-matnr NE oeban-matnr.
*---- Lieferwerk oder Material hat sich geändert ----------------------*
*---- Umlagerungsindex für altes Lieferwerk/altes Material löschen ----*
IF oeban-reswk NE space AND oeban-bsakz NE 'R' AND
oeban-matnr NE space AND
oeban-ebakz EQ space AND
oeban-loekz EQ space AND
oeban-menge GT oeban-bsmng.
MOVE-CORRESPONDING oeban TO ebub.
MOVE ebub TO db_ebub_d.
APPEND db_ebub_d.
ENDIF.
*---- Umlagerungsindex für neues Lieferwerk/neues Material hinzufügen -*
IF eban-reswk NE space AND eban-bsakz NE 'R' AND
eban-matnr NE space AND
eban-ebakz EQ space AND
eban-loekz EQ space AND
eban-menge GT eban-bsmng.
MOVE-CORRESPONDING eban TO ebub.
MOVE ebub TO db_ebub.
APPEND db_ebub.
ENDIF.
ELSE.
* Umlagerungsindex aufbauen/löschen je nach Loekz und Ebakz
IF eban-reswk NE space AND eban-bsakz NE 'R' AND
eban-matnr NE space.
IF oeban-ebakz EQ space AND
oeban-loekz NE 'X' AND
oeban-menge GT oeban-bsmng AND
( eban-ebakz NE space OR eban-loekz EQ 'X' OR
eban-menge LE eban-bsmng ).
*--- löschen
MOVE-CORRESPONDING eban TO db_ebub_d.
APPEND db_ebub_d.
ELSE.
IF ( oeban-ebakz NE space OR oeban-loekz EQ 'X' OR
oeban-menge LE oeban-bsmng ) AND
eban-ebakz EQ space AND eban-loekz NE 'X' AND
eban-menge GT eban-bsmng.
*--- hinzufügen
MOVE-CORRESPONDING eban TO db_ebub.
APPEND db_ebub.
ENDIF.
ENDIF.
ENDIF.
ENDIF.
IF NOT eban-arsnr IS INITIAL AND
NOT eban-arsps IS INITIAL.
IF eban-loekz EQ space AND
oeban-loekz NE space AND
eban-estkz NE 'F'. "QNL
CALL FUNCTION 'RSDB_CREATE_WITH_EBAN'
EXPORTING
banfn = eban-banfn
bnfpo = eban-bnfpo
rsnum = eban-arsnr
rspos = eban-arsps
EXCEPTIONS
parameters_not_specified = 02
record_already_exist = 03.
IF sy-subrc NE 0.
MESSAGE a807 WITH 'RSDB'.
ENDIF.
ENDIF.
IF eban-loekz NE space AND
oeban-loekz EQ space AND
eban-estkz NE 'F'.
CALL FUNCTION 'RSDB_DELETE_WITH_EBAN'
EXPORTING
banfn = eban-banfn
bnfpo = eban-bnfpo
rsnum = eban-arsnr
rspos = eban-arsps
EXCEPTIONS
parameters_not_specified = 01
record_not_exist = 02.
IF sy-subrc NE 0.
* MESSAGE a809 WITH 'RSDB'. "402007
ENDIF.
ENDIF.
ENDIF.
ENDIF.
ENDIF.

ENHANCEMENT-POINT ehp603_me_update_requisition_3 SPOTS es_saplebnu_p2p.
*$*$-Start: EHP603_ME_UPDATE_REQUISITION_3------------------------------------------------------$*$*
ENHANCEMENT 3 MM_SFWS_EBNU. "active version
*-------Create change pointer for TREX
PERFORM trex_change_pointer USING xeban-banfn
xeban-kz.
ENDENHANCEMENT.
*$*$-End: EHP603_ME_UPDATE_REQUISITION_3------------------------------------------------------$*$*

IF lv_ehp4_sfws_p2pse EQ 'X'.
* MOVE-CORRESPONDING Xeban to ls_eban.

CALL FUNCTION 'ME_TREX_TRIGGER_PR'
EXPORTING
IV_BANFN = xeban-banfn
IV_BNFPO = xeban-bnfpo
IV_EBAN_CHANGEID = xeban-kz
* IT_CHANGED_PR = IT_CHANGED_PR
.
*
* CALL FUNCTION 'ME_TREX_TRIGGER_PR'
* EXPORTING
* IS_BANFN = xeban-banfn
* IS_BNFPO = xeban-bnfpo
** IS_EBAN = LS_EBAN
** IS_EBKN = IS_EBKN
** IS_EBAN_TECH = IS_EBAN_TECH
* IV_EBAN_CHANGEID = xeban-kz
** IV_EBKN_CHANGEID = IV_EBKN_CHANGEID
** IV_EBAN_TECH_CHANGEID = IV_EBAN_TECH_CHANGEID
* .
ENDIF.
ENDLOOP.

* Fortschreiben neuer Umlagerungsindizes
PERFORM ebub_fortschreiben TABLES db_ebub db_ebub_d.

REFRESH: db_ebkn.

*------- Kontierungen Loeschen ----------------------------------------*
LOOP AT yebkn.
MOVE yebkn TO oebkn.
IF oebkn-kz EQ 'D'.
* MOVE OEBKN TO EBKN.
MOVE-CORRESPONDING oebkn TO db_ebkn.
APPEND db_ebkn.
ENDIF.
ENDLOOP.
DESCRIBE TABLE db_ebkn LINES sy-tfill.
IF sy-tfill GT 0.
DELETE ebkn FROM TABLE db_ebkn.
IF sy-subrc NE 0.
MESSAGE a809 WITH 'EBKN'.
ENDIF.
REFRESH db_ebkn.
ENDIF.

REFRESH: db_ebkn, db_ebkn_u.

*------- Kontierungspositionen ----------------------------------------*
LOOP AT xebkn.
MOVE-CORRESPONDING xebkn TO ebkn.
*------ Kontierungsposition hinzufuegen -------------------------------*
IF xebkn-kz EQ 'I'.
MOVE-CORRESPONDING xebkn TO db_ebkn.
APPEND db_ebkn.
ENDIF.
*------ Kontierungsposition aendern -----------------------------------*
IF xebkn-kz EQ 'U'.
MOVE-CORRESPONDING xebkn TO db_ebkn_u.
APPEND db_ebkn_u.
ENDIF.

ENDLOOP.

DESCRIBE TABLE db_ebkn LINES sy-tfill.
IF sy-tfill GT 0.
INSERT ebkn FROM TABLE db_ebkn.
IF sy-subrc NE 0.
MESSAGE a807 WITH 'EBKN'.
ENDIF.
REFRESH db_ebkn.
ENDIF.
DESCRIBE TABLE db_ebkn_u LINES sy-tfill.
IF sy-tfill GT 0.
UPDATE ebkn FROM TABLE db_ebkn_u.
IF sy-subrc NE 0.
MESSAGE a808 WITH 'EBKN'.
ENDIF.
REFRESH db_ebkn_u.
ENDIF.

*- Update Quota
CALL FUNCTION 'ME_UPDATE_QUOTA_FROM_REQ' "361414
TABLES
xeban = xeban
yeban = yeban.

* MM-PUR/APO #124738
* Interface BTE 01000710
IF CL_OPS_SWITCH_CHECK=>LO_MM_SD_SFWS_DM_SC( )
EQ CL_OPS_SWITCH_CHECK=>SWITCH_ACTIVE_TRUE AND LINES( DRS_ITEMS ) GT 0. "Perform the call only when DRS_ITEMS are filled

CALL FUNCTION 'OUTBOUND_CALL_01000710_E' "DRS items should be send over to APO
TABLES
T_XEBAN = xeban
T_XEBKN = xebkn
T_YEBAN = yeban
T_YEBKN = yebkn
IT_DRS_ITEMS = DRS_ITEMS.
ELSE.
CALL FUNCTION 'OUTBOUND_CALL_01000710_E'
TABLES
t_xeban = xeban
t_xebkn = xebkn
t_yeban = yeban
t_yebkn = yebkn
EXCEPTIONS
OTHERS = 1.
ENDIF.
*
*------- Update additional data PREXT NCF KH ----------------------*

DATA: lt_prext_db TYPE mereq_t_prext,
lt_prext_db_u TYPE mereq_t_prext,
ls_prext LIKE LINE OF lt_prext_db,
ls_xprext LIKE LINE OF xprext.

LOOP AT xprext INTO ls_xprext.
CLEAR ls_prext.
MOVE-CORRESPONDING ls_xprext TO ls_prext.
CASE ls_xprext-kz.
WHEN 'I'.
APPEND ls_prext TO lt_prext_db.
WHEN 'U'.
APPEND ls_prext TO lt_prext_db_u.
ENDCASE.
ENDLOOP.
DESCRIBE TABLE lt_prext_db LINES sy-tfill.
IF sy-tfill GT 0.
INSERT prext FROM TABLE lt_prext_db.
IF sy-subrc NE 0.
MESSAGE a807 WITH 'PREXT'.
ENDIF.
ENDIF.
DESCRIBE TABLE lt_prext_db_u LINES sy-tfill.
IF sy-tfill GT 0.
UPDATE prext FROM TABLE lt_prext_db_u.
IF sy-subrc NE 0.
MESSAGE a808 WITH 'PREXT'.
ENDIF.
ENDIF.

*-------update x-fields in case of holding a document-----------------*

* mereqx can only contain entries in case of holding a document
CHECK NOT mereqx IS INITIAL.

DATA: lt_mereqx_db TYPE mereq_t_mereqx,
lt_mereqx_db_u TYPE mereq_t_mereqx,
lt_mereqx_db_d TYPE mereq_t_mereqx, " Note 1490525
l_tabname TYPE tabname, " Note 1490525
ls_mereqx LIKE LINE OF lt_mereqx_db,
ls_umereqx LIKE LINE OF mereqx.

LOOP AT mereqx INTO ls_umereqx.
CLEAR ls_mereqx.
MOVE-CORRESPONDING ls_umereqx TO ls_mereqx.
CASE ls_umereqx-kz.
WHEN 'I'.
APPEND ls_mereqx TO lt_mereqx_db.
WHEN 'U'.
APPEND ls_mereqx TO lt_mereqx_db_u.
WHEN 'D'. " Note 1490525
APPEND ls_mereqx to lt_mereqx_db_d. " Note 1490525
ENDCASE.
ENDLOOP.
DESCRIBE TABLE lt_mereqx_db LINES sy-tfill.
IF sy-tfill GT 0.
INSERT mereqx FROM TABLE lt_mereqx_db.
IF sy-subrc NE 0.
MESSAGE a807 WITH 'MEREQX'.
ENDIF.
ENDIF.
DESCRIBE TABLE lt_mereqx_db_u LINES sy-tfill.
IF sy-tfill GT 0.
UPDATE mereqx FROM TABLE lt_mereqx_db_u.
IF sy-subrc NE 0.
MESSAGE a808 WITH 'MEREQX'.
ENDIF.
ENDIF.

L_TABNAME = 'MEREQX'. " Note 1490525
DESCRIBE TABLE lt_mereqx_db_d LINES sy-tfill. " Note 1490525
IF sy-tfill GT 0. " Note 1490525
DELETE (l_tabname) FROM table lt_mereqx_db_d. " Note 1490525
IF sy-subrc NE 0. " Note 1490525
MESSAGE a809 WITH 'MEREQX'. " Note 1490525
ENDIF. " Note 1490525
ENDIF. " Note 1490525

ENDFUNCTION.

手机扫一扫

移动阅读更方便

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

你可能感兴趣的文章