竟然直接insert 表
FUNCTION ME_UPDATE_QUOTA.
*"----------------------------------------------------------------------
*"*"Verbuchungsfunktionsbaustein:
*"
*"*"Lokale Schnittstelle:
*" TABLES
*" XEQUK STRUCTURE EQUKU
*" XEQUP STRUCTURE UEQUP
*" YEQUK STRUCTURE EQUKU
*" YEQUP STRUCTURE UEQUP
*"----------------------------------------------------------------------
* 84973 3.1I 14.10.1997 CFREFRESH: DB_EQUK, DB_EQUK_U, DB_EQUP.CLEAR: NEQUK, NEQUP.
REFRESH: NEQUK, NEQUP.
***********************************************************************
* Aendern oder Hinzufuegen Quotenköpfe EQUK *
***********************************************************************
LOOP AT XEQUK.MOVE XEQUK TO NEQUK.APPEND NEQUK.
ENDLOOP.*--- Sortieren für binäres Lesen mit Key -----------------------------*
SORT NEQUK ASCENDING BY MATNR WERKS BDATU.*--- Loop über alte Daten --------------------------------------------*
LOOP AT YEQUK.MOVE-CORRESPONDING YEQUK TO EQUKKEY.READ TABLE NEQUK WITH KEY EQUKKEY BINARY SEARCH.IF SY-SUBRC NE 0.
* MOVE YEQUK TO EQUK.
* PERFORM EQUK_LOESCHEN.MOVE YEQUK TO DB_EQUK.APPEND DB_EQUK.ELSE.
* MOVE NEQUK TO EQUK.
* PERFORM EQUK_AENDERN.MOVE NEQUK TO DB_EQUK_U.APPEND DB_EQUK_U.ENDIF.
ENDLOOP.* Löschen Quotierungsköpfe über Array-Delete
DESCRIBE TABLE DB_EQUK LINES SY-TFILL.
IF SY-TFILL GT 0.DELETE EQUK FROM TABLE DB_EQUK.IF SY-SUBRC NE 0.MESSAGE A809(ME) WITH 'EQUK'.ENDIF.REFRESH DB_EQUK.
ENDIF.
*
* Update Quotierungsköpfe über Array-Update
DESCRIBE TABLE DB_EQUK_U LINES SY-TFILL.
IF SY-TFILL GT 0.UPDATE EQUK FROM TABLE DB_EQUK_U.IF SY-SUBRC NE 0.MESSAGE A808(ME) WITH 'EQUK'.ENDIF.
* REFRESH DB_EQUK_U. "67116
ENDIF.
*
*
REFRESH: DB_EQUK.*--- Loop über neue Daten --------------------------------------------*
LOOP AT NEQUK.IF NEQUK-KZ EQ 'I'. "neupos Neue Saetze ---> Insert
* MOVE NEQUK TO EQUK.
* PERFORM EQUK_HINZUFUEGEN.MOVE-CORRESPONDING NEQUK TO EQUKKEY. "67116READ TABLE DB_EQUK_U WITH KEY EQUKKEY. "67116CHECK SY-SUBRC NE 0. "67116MOVE NEQUK TO DB_EQUK.APPEND DB_EQUK.ENDIF.
ENDLOOP.
REFRESH DB_EQUK_U. "67116* Insert Quotierungsköpfe über Array-Insert
DESCRIBE TABLE DB_EQUK LINES SY-TFILL.
IF SY-TFILL GT 0.INSERT EQUK FROM TABLE DB_EQUK.(直接插入数据)IF SY-SUBRC NE 0.MESSAGE A807(ME) WITH 'EQUK'.ENDIF.REFRESH DB_EQUK.
ENDIF.
************************************************************************
* Aendern oder Hinzufuegen Orderbuchsaetze EQUP *
***********************************************************************
LOOP AT XEQUP.MOVE XEQUP TO NEQUP.APPEND NEQUP.
ENDLOOP.*--- Sortieren für binäres Lesen mit Key -----------------------------*
SORT NEQUP ASCENDING BY QUNUM QUPOS.*--- Loop über alte Daten --------------------------------------------*
LOOP AT YEQUP.MOVE-CORRESPONDING YEQUP TO EQUPKEY.READ TABLE NEQUP WITH KEY EQUPKEY BINARY SEARCH.IF SY-SUBRC NE 0.
* MOVE YEQUP TO EQUP.
* PERFORM EQUP_LOESCHEN.MOVE YEQUP TO DB_EQUP.APPEND DB_EQUP.ELSE.NEQUP-KZ = 'U'. "84973MODIFY NEQUP INDEX SY-TABIX. "84973IF NEQUP-QUMNG EQ YEQUP-QUMNG.
*--- Quotenmenge wird nicht auf DB geschrieben ------------------------*MOVE NEQUP TO EQUP.PERFORM EQUP_AENDERN.ELSE.
*--- Quotenmenge wird auf DB geschrieben ------------------------------*SELECT SINGLE * FROM EQUPWHERE QUNUM = NEQUP-QUNUMAND QUPOS = NEQUP-QUPOS.IF SY-SUBRC EQ 0.
*--- neu berechnen der Quotenmenge, da inzwischen evtl. weitere -------*
*--- updates aus den Belegen heraus stattgefunden haben -------*NEQUP-QUMNG = EQUP-QUMNG - YEQUP-QUMNG + NEQUP-QUMNG.MOVE NEQUP TO EQUP.PERFORM EQUP_AENDERN.ENDIF.ENDIF.ENDIF.
ENDLOOP.* Löschen Quotierungspos über Array-Delete
DESCRIBE TABLE DB_EQUP LINES SY-TFILL.
IF SY-TFILL GT 0.DELETE EQUP FROM TABLE DB_EQUP.IF SY-SUBRC NE 0.MESSAGE A809(ME) WITH 'EQUP'.ENDIF.REFRESH DB_EQUP.
ENDIF.
*
*
REFRESH: DB_EQUP.*--- Loop über neue Daten --------------------------------------------*
LOOP AT NEQUP.IF NEQUP-KZ EQ 'I'. "neupos Neue Saetze ---> Insert
* MOVE NEQUP TO EQUP.
* PERFORM EQUP_HINZUFUEGEN.MOVE NEQUP TO DB_EQUP.APPEND DB_EQUP.ENDIF.
ENDLOOP.* Insert Quotierungspos über Array-Insert
DESCRIBE TABLE DB_EQUP LINES SY-TFILL.
IF SY-TFILL GT 0.INSERT EQUP FROM TABLE DB_EQUP. (直接插入数据)IF SY-SUBRC NE 0.MESSAGE A807(ME) WITH 'EQUP'.ENDIF.REFRESH DB_EQUP.
ENDIF.
*ENDFUNCTION.