RE:[sap-log-sd] How do i verify the entries in table s066 is accurate with open sales order

Posted by Tung Ho (SAP SD FUNCTIONAL ANALYST)
on Jul 25 at 10:34 AM
Hello Lou -- Below is the code we use in production to locate incorrect info in s066 and s067. You wont have to run the program below with Solution Manager.

Let me know if you want a text copy sent.


*&-------------------*
*& Report Z_CREDIT_VALUE_COMPARE
*&
*&-------------------*
*&
*&
*&-------------------*

*&-------------------*
*& Report Z_CREDIT_VALUE_COMPARE *
*& *
*&-------------------*
*& Compare simulated new credit values with database credit values *
*& *
*&-------------------*

REPORT z_credit_value_compare LINE-SIZE 147.

*--- Global Data Declarations --------------*
DATA: BEGIN OF ls_results,
kkber LIKE vbak-kkber,
knkli LIKE vbak-knkli,
cmwae LIKE vbak-cmwae,
oeikw LIKE s066-oeikw,
olikw LIKE s067-olikw,
ofakw LIKE s067-ofakw,
END OF ls_results,
lt_results LIKE TABLE OF ls_results.

DATA: BEGIN OF ls_s066_67,
kkber LIKE s066-kkber,
knkli LIKE s066-knkli,
cmwae LIKE s066-cmwae,
END OF ls_s066_67,
lt_s066_67 LIKE TABLE OF ls_s066_67.

DATA: BEGIN OF ls_values.
INCLUDE STRUCTURE ls_results.
DATA: oeikw_db LIKE s066-oeikw,
olikw_db LIKE s067-olikw,
ofakw_db LIKE s067-ofakw,
END OF ls_values,
lt_wrong_values LIKE TABLE OF ls_values.

DATA: counter_all TYPE i,
counter_inc TYPE i.

SELECT-OPTIONS: knkli FOR ls_results-knkli MATCHCODE OBJECT debi,
kkber FOR ls_results-kkber MATCHCODE OBJECT h_t014.

PARAMETERS: protb DEFAULT 'X' NO-DISPLAY,
tracs DEFAULT 'X' NO-DISPLAY,
noblock DEFAULT 'X' NO-DISPLAY.

*--- Macro Definition ----------------------*
DEFINE write_val.
write (20) &1 currency &3.
if &1 ne &2.
write (20) &2 currency &3 color col_negative intensified off.
else.
write (20) &2 currency &3.
endif.
END-OF-DEFINITION.

*--- Start of selection --------------------*
START-OF-SELECTION.
* simulate re-creation of open credit values
SUBMIT rvkred07 AND RETURN EXPORTING LIST TO MEMORY
WITH knkli IN knkli
WITH kkber IN kkber
WITH protb EQ protb
WITH tracs EQ tracs
WITH noblock EQ noblock.

* import the results from RVKRED07
IMPORT lt_results FROM MEMORY ID 'CREDIT_RESULTS_RVKRED07'.

* check for S066 and S067 entries ...
SELECT * FROM s066 INTO CORRESPONDING FIELDS OF TABLE lt_s066_67
WHERE kkber IN kkber AND
knkli IN knkli AND
oeikw NE 0.
SELECT * FROM s067 APPENDING CORRESPONDING FIELDS OF TABLE lt_s066_67
WHERE kkber IN kkber AND
knkli IN knkli AND
( olikw NE 0 OR
ofakw NE 0 ).
SORT lt_s066_67.
DELETE ADJACENT DUPLICATES FROM lt_s066_67 COMPARING kkber knkli.
SORT lt_results.
* ... and add to lt_results when nothing was calculated from RVKRED07
LOOP AT lt_s066_67 INTO ls_s066_67.
READ TABLE lt_results WITH KEY kkber = ls_s066_67-kkber
knkli = ls_s066_67-knkli
TRANSPORTING NO FIELDS
BINARY SEARCH.
IF sy-subrc NE 0.
MOVE-CORRESPONDING ls_s066_67 TO ls_results.
INSERT ls_results INTO lt_results INDEX sy-tabix.
ENDIF.
ENDLOOP.

* compare simulated credit values with database values
LOOP AT lt_results INTO ls_results.
MOVE-CORRESPONDING ls_results TO ls_values.
ADD 1 TO counter_all.
CALL FUNCTION 'SD_CREDIT_EXPOSURE'
EXPORTING
kkber = ls_values-kkber
knkli = ls_values-knkli
IMPORTING
open_delivery = ls_values-olikw_db
open_invoice = ls_values-ofakw_db
open_order = ls_values-oeikw_db.
* collect wrong values in internal table
IF ls_values-oeikw NE ls_values-oeikw_db OR
ls_values-olikw NE ls_values-olikw_db OR
ls_values-ofakw NE ls_values-ofakw_db.
APPEND ls_values TO lt_wrong_values.
ADD 1 to counter_inc.
ENDIF.
CLEAR ls_values.
ENDLOOP.

*--- End of selection -------------------*
END-OF-SELECTION.
FORMAT COLOR COL_NORMAL ON.
* display results
write: / 'Crdt ', (10)'Cust', (8)'Curr', (19)'Open SO Target', (19)'Open SO Actual', (19)'Open Dlv Target', (19)'Open Dlv Actual', (20)'Open Billing Doc Tgt' ,(20)'Open Billing Doc Act'.
write: / 'Area'.
LOOP AT lt_wrong_values INTO ls_values.
WRITE: / ls_values-kkber COLOR COL_KEY,
ls_values-knkli COLOR COL_KEY,
ls_values-cmwae COLOR COL_KEY.
write_val ls_values-oeikw ls_values-oeikw_db ls_values-cmwae.
write_val ls_values-olikw ls_values-olikw_db ls_values-cmwae.
write_val ls_values-ofakw ls_values-ofakw_db ls_values-cmwae.
ENDLOOP.

* no wrong credit values
IF sy-subrc NE 0.
WRITE text-001.
ENDIF.

* number of analysed credit accounts
ULINE.
WRITE: / text-002 COLOR COL_KEY, AT 65 counter_all COLOR COL_TOTAL,
/ text-003 COLOR COL_KEY, AT 65 counter_inc COLOR COL_TOTAL.

*--- End of program --------------------*

---------------Original Message---------------
From: Louis Corato
Sent: Monday, July 25, 2011 9:24 AM
Subject: How do i verify the entries in table s066 is accurate with open sales order

Thanks, Tung - It's very interesting that SAP would provide a "Z" report in a note. I notice that we also have to be running Solution Manager with the Data Consistency Cockpit. I'll have to ask my Basis guys if we're running that cockpit function. If so, we'll probably want to put this report into production.

Thanks for the info! - Lou

__.____._
Copyright © 2011 Toolbox.com and message author.

Toolbox.com 4343 N. Scottsdale Road Suite 280, Scottsdale, AZ 85251
Mark as helpful
View this online
  
Popular White Papers

In the Spotlight
Earn Recognition for Your Contributions at Toolbox for IT. Gain Points for Community Achievements
_.____.__