Posted: Wed Aug 20, 2008 10:35 am Post subject: Алгоритм заполнения инфоструктуры S066
Здравствуйте,
стоит задача разобраться, почему в таблицу S066 (Open orders: credit management) попала отрицательная сумма. Кто-нибудь знает, как заполняется эта таблица?
Age: 170 Joined: 04 Oct 2007 Posts: 1218 Location: Санкт-Петербург
Posted: Wed Aug 20, 2008 11:06 am Post subject:
Для получения суммы открытых заказов по покупателю в саповских транзакциях часто используется ФМ 'SD_CREDIT_EXPOSURE', как раз использующая инфоструктуры s066, s067.
Когда стояла задача расчета сумм в другой валюте, отличной от валюты в этих инфосистемах, пришлось расчитывать суммы руками:
Code:
*&---------------------------------------------------------------------*
*& Form SD_CREDIT_EXPOSURE2
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* -->p_kkber LIKE T014-KKBER
* -->p_knkli LIKE KNKK-KNKLI
* <--p_open_delivery LIKE S067-OLIKW
* <--p_open_invoice LIKE S067-OFAKW
* <--p_open_order LIKE S066-OEIKW
*----------------------------------------------------------------------*
FORM SD_CREDIT_EXPOSURE2 USING p_kkber LIKE T014-KKBER
p_knkli LIKE KNKK-KNKLI
CHANGING
p_open_delivery LIKE S067-OLIKW
p_open_invoice LIKE S067-OFAKW
p_open_order LIKE S066-OEIKW.
TABLES: VBCOM, FACOM, LICOM, vbco7, TVBST, RV60A.
DATA: BEGIN OF POSTAB OCCURS 50,
VBELN LIKE VBUP-VBELN,
POSNR LIKE VBUP-POSNR,
END OF POSTAB.
DATA: BEGIN OF SELTAB OCCURS 6.
INCLUDE STRUCTURE RKASK.
DATA: END OF SELTAB.
DATA: BEGIN OF VBPOSTAB OCCURS 200.
INCLUDE STRUCTURE VBMTV. " Listanzeigen-Struktur
DATA: END OF VBPOSTAB.
DATA: BEGIN OF FAPOSTAB OCCURS 200.
INCLUDE STRUCTURE FAMTV.
DATA: SPART LIKE TVTA-SPART,
END OF FAPOSTAB.
DATA: BEGIN OF LLIMTV OCCURS 200.
INCLUDE STRUCTURE LIMTV.
DATA: END OF LLIMTV.
LOOP AT FAPOSTAB.
p_open_invoice = p_open_invoice + FApostab-NETWR.
ENDLOOP.
* get open delivery
DATA: BEGIN OF LVBUK OCCURS 0001.
INCLUDE STRUCTURE VBUK .
DATA: END OF LVBUK .
DATA: BEGIN OF LVLKPA OCCURS 0001.
INCLUDE STRUCTURE VLKPA .
DATA: END OF LVLKPA .
DATA: BEGIN OF LLIKP OCCURS 0001.
INCLUDE STRUCTURE LIKP .
DATA: END OF LLIKP .
DATA: BEGIN OF LLIPS OCCURS 0001.
INCLUDE STRUCTURE LIPS .
DATA: END OF LLIPS .
DATA: POSTAB_TFILL LIKE SY-TABIX.
DATA: ACTIV LIKE LIMTV-ACTIV VALUE '0'. "Listverarbeitung
DATA: B_ZAEHLER LIKE SY-TABIX.
DATA: LV LIKE SY-TABIX.
DATA: LV2 LIKE SY-TABIX.
DATA: LV3 LIKE SY-TABIX.
DATA: LV4 LIKE SY-TABIX.
DATA: LIPS_TABIX LIKE SY-TABIX.
DATA: LIMTV_TABIX LIKE SY-TABIX.
DATA: BEGIN OF LIKP_KEY,
MANDT LIKE LIKP-MANDT,
VBELN LIKE LIKP-VBELN,
END OF LIKP_KEY.
DATA: BEGIN OF LIPS_KEY,
MANDT LIKE LIPS-MANDT,
VBELN LIKE LIPS-VBELN,
POSNR LIKE LIPS-POSNR,
END OF LIPS_KEY.
DATA: OK(1) TYPE C.
REFRESH: POSTAB.
SELECT *
INTO TABLE LVLKPA
FROM VLKPA
WHERE ( PARVW = LICOM-PARVW )
AND ( VKORG = LICOM-VKORG )
AND ( KUNAG = LICOM-KUNDE )
ORDER BY VBELN.
IF POSTAB_TFILL > 0.
LOOP AT LVLKPA.
POSTAB-VBELN = LVLKPA-VBELN.
APPEND POSTAB.
MOVE LVLKPA-KUNNR TO LLIMTV-KUNNR .
MOVE LVLKPA-LFART TO LLIMTV-LFART .
MOVE LVLKPA-VBELN TO LLIMTV-VBELN .
MOVE LVLKPA-VKORG TO LLIMTV-VKORG .
LLIMTV-ACTIV = ACTIV.
APPEND LLIMTV.
ENDLOOP.
SELECT * FROM VBUK INTO TABLE LVBUK FOR ALL ENTRIES IN POSTAB
WHERE VBELN = POSTAB-VBELN
ORDER BY PRIMARY KEY.
LOOP AT LLIMTV.
DATA: FELDNAME(10) TYPE C.
CLEAR OK.
VBUK_KEY-MANDT = SY-MANDT.
VBUK_KEY-VBELN = LLIMTV-VBELN.
READ TABLE LVBUK WITH KEY VBUK_KEY BINARY SEARCH.
CHECK SY-SUBRC = 0.
IF LICOM-VBOFF = ' ' OR
LVBUK-WBSTK = 'A' OR LVBUK-WBSTK = 'B'.
LLIMTV-STATUS = LVBUK-WBSTK.
FELDNAME = 'WBSTA'.
OK = 'X'.
IF LICOM-STAT_DAZU = 'X'.
TVBST-SPRAS = SY-LANGU.
TVBST-TBNAM = 'VBUK'.
TVBST-FDNAM = FELDNAME.
TVBST-STATU = LLIMTV-STATUS.
CALL FUNCTION 'RV_DOCUMENT_STATUS_TEXTS'
EXPORTING
TVBST_WA = TVBST
IMPORTING
* RETURNCODE = I01
TEXT = LLIMTV-STATUS_BEZ.
ENDIF.
ENDIF.
IF OK = ' '.
DELETE LLIMTV.
READ TABLE POSTAB WITH KEY VBELN = LLIMTV-VBELN
BINARY SEARCH.
IF SY-SUBRC = 0.
DELETE POSTAB INDEX SY-TABIX.
ENDIF.
ELSE.
MODIFY LLIMTV.
ENDIF.
ENDLOOP.
DESCRIBE TABLE LLIMTV LINES SY-TFILL.
IF SY-TFILL > 0.
* je nach Zugriffsart werden Auftragsk_pfe eingelesen
IF LICOM-ZUART CA 'AC'.
SELECT * FROM LIKP INTO TABLE LLIKP FOR ALL ENTRIES IN POSTAB
WHERE VBELN = POSTAB-VBELN
ORDER BY PRIMARY KEY.
ENDIF.
IF LICOM-ZUART CA 'AB'.
SELECT * FROM LIPS INTO TABLE LLIPS FOR ALL ENTRIES IN POSTAB
WHERE VBELN = POSTAB-VBELN
AND MATNR NE SPACE
ORDER BY PRIMARY KEY.
ENDIF.
DESCRIBE TABLE LLIMTV LINES LV3.
LV4 = 0.
DO.
LV4 = LV4 + 1.
LIMTV_TABIX = LV4.
IF LV4 > LV3. EXIT. ENDIF.
READ TABLE LLIMTV INDEX LV4.
IF SY-SUBRC NE 0. EXIT. ENDIF.
* es wurden also nur Kopfindices gelesen
IF LICOM-ZUART CA 'AC'.
* K_pfe sollen gelesen werden
LIKP_KEY-MANDT = SY-MANDT.
LIKP_KEY-VBELN = LLIMTV-VBELN.
READ TABLE LLIKP WITH KEY LIKP_KEY BINARY SEARCH.
IF SY-SUBRC = 0.
IF LICOM-ZUART = 'C'.
DELETE LLIKP INDEX SY-TABIX.
ENDIF.
MOVE LLIKP-KUNNR TO LLIMTV-KUNNR .
MOVE LLIKP-LFART TO LLIMTV-LFART .
LLIMTV-ACTIV = ACTIV.
MODIFY LLIMTV INDEX LV4.
ELSE.
DELETE LLIMTV INDEX LV4. LV4 = LV4 - 1.
CHECK 1 = 2.
ENDIF.
ENDIF.
IF LICOM-ZUART CA 'AB'.
* Positionen sollen gelesen werden
LV = 0.
DO.
IF LV = 0.
LIKP_KEY-MANDT = SY-MANDT.
LIKP_KEY-VBELN = LLIMTV-VBELN.
READ TABLE LLIPS WITH KEY LIKP_KEY BINARY SEARCH.
IF SY-SUBRC NE 0. LV2 = 0. EXIT. ENDIF.
LIPS_TABIX = SY-TABIX.
LV = LV + 1.
MOVE LLIPS-POSNR TO LLIMTV-POSNR .
MOVE LLIPS-VBELN TO LLIMTV-VBELN .
LLIMTV-ACTIV = ACTIV.
MODIFY LLIMTV INDEX LV4.
ELSE.
LIPS_TABIX = LIPS_TABIX + 1.
READ TABLE LLIPS INDEX LIPS_TABIX.
IF SY-SUBRC NE 0 OR
LLIPS-VBELN NE LLIMTV-VBELN.
EXIT.
ENDIF.
LV = LV + 1.
MOVE LLIPS-POSNR TO LLIMTV-POSNR .
MOVE LLIPS-VBELN TO LLIMTV-VBELN .
LLIMTV-ACTIV = ACTIV.
APPEND LLIMTV.
LIMTV_TABIX = SY-TABIX.
ENDIF.
ENDDO.
ENDIF.
ENDDO.
ENDIF.
DATA l_netwr LIKE VBAP-NETWR.
LOOP AT LLIPS.
CLEAR l_netwr.
SELECT SINGLE netwr INTO l_netwr FROM VBAP
WHERE vbeln = LLIPS-vgbel AND posnr = LLIPS-vgpos.
IF SY-SUBRC IS INITIAL.
p_open_delivery = p_open_delivery + l_netwr.
ENDIF.
ENDLOOP.
ENDIF.
* addition open delivery
RANGES : s_kunnr FOR vbco7-kunnr.
RANGES : s_lland FOR vbco7-lland.
RANGES : s_fkart FOR vbco7-fkart.
RANGES : S_VBELN FOR VBCO7-VBELN.
RANGES : s_sortkri FOR vbco7-sortkri.
RANGES : s_vtweg FOR vbco7-vtweg.
RANGES : s_spart FOR vbco7-spart.
RANGES : s_vstel FOR vbco7-vstel.
DATA : it_fvkdfi LIKE vkdfif OCCURS 50 WITH HEADER LINE.
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum You cannot attach files in this forum You can download files in this forum
All product names are trademarks of their respective companies. SAPNET.RU websites are in no way affiliated with SAP AG. SAP, SAP R/3, R/3 software, mySAP, ABAP, BAPI, xApps, SAP NetWeaver and any other are registered trademarks of SAP AG. Every effort is made to ensure content integrity. Use information on this site at your own risk.