Você está na página 1de 12

13/10/2017 Exibirorigem

Problema

Vocdeterminouqueexistemvaloresdecrditoinconsistentesnosistema.Comoissopodeserfeito,vocpodelerAQUI.
Existeumexemplodisponvelparaamesmaatualizaoerrada.Comisso,oproblemapodeserrecriadoporissopossvel
depuraroclculodovalordecrditoparadescobrirporquenoomesmoesperado.

Anlise
Porfavor,leiaAQUIcomoovalordocrditocalculado.
LeiaAQUIcomofuncionaaatualizaodecrdito.
LeiaAQUIcomovaloreserradospodemsercorrigidos.
LeiaAQUIcomoaatualizaodovalordecrditopodeserrastreada/registrada.
Porfavor,leiaAQUIporpossveismotivosdeinconsistncias.

Soluo

Contextotcnico:

TabelaS066: Valordopedidodevendaaberto

OEIKW Valordecrditodeordemdevendaaberto(linhasdecronograma)

TabelaS067: Abrirvaloresdeentregaefaturamento

OLIKW Valordecrditodeentregaaberta

OFAKW Valordecrditodecobranaaberta

Atualizargrupos:

Ogrupodeatualizaomantidoparaareadecontroledecrdito(transaoOB45).

Atualizargrupo Observao

NenhumaatualizaodedocumentosSD

000012 Valordeordemabertonoeixodotempo,entregaecobranadovalordo AtualizaodeS066eS067


documento

000015 Valorabertododocumentodeentregaecobrana SomenteoS067ser


atualizado

000018 Valordeentregaabertoparaaordemdocliente,abrirovalordodocumentode SomenteoS067ser


cobrana atualizado

OgrupoAtualizaopodeserdinmicoalteradopelosistemamaissobreissoAQUI.IssofeitonoprogramaLMCSBF10.

CdigodecodificaorelevanteSD:
https://wiki.scn.sap.com/wiki/plugins/viewsource/viewpagesrc.action?pageId=399379774 1/12
13/10/2017 Exibirorigem

LMCS1F10Ordemdevenda

formaoffene_werte_eint OEIKW FORM.Cmpre_calculate(SAPLVKMP)

deoffene_werte_erm OLIKW FORM.Cmpre_calculate(SAPLVKMP)

OLIKWAU FORM.Cmpre_calculate(SAPLVKMP)

ifopendeliveryvalueinsalesorderisused(updategroup000018)

Thiscodingmightbepassed4timesforeachscheduleline:

1.oldcreditvalue(withSUPKZ=''or'1')
2.newcreditvalue(withSUPKZ='2'or'3')
3.oldforMC30(withSUPKZ=''or'1')
4.newforMC30(withSUPKZ='2'or'3')

LMCS5F10Delivery

formoffene_werte_eint OEIKW FORMcmpre_calculate(SAPLVKMP)

formoffene_werte_lips OLIKW FORMcmpre_calculate(SAPLVKMP)

OLIKWAU FORMcmpre_calculate(SAPLVKMP)

formoffene_werte_erm

erlmenge_l(sumofdeliveredquantity)
erlmenge_f(sumofinvoicedquantitysubstractfromsalesordervalueiffkrel=orderrelatedandsubstractfrom
deliveryvalueiffkrel=deliveryrelated)
faklmeng(invoiceddeliveryquantity)

LMCS6F10Invoice

formoffene_werte_vbrp opendel.value FORMcmpre_calculate(SAPLVKMP)


...changingowv_mcvbrpolikw

openinvoicevalue FORMcmpre_calculate(SAPLVKMP)
...changingowv_mcvbrpofakw

openitem(FI) FORMcmpre_calculate(SAPLVKMP)
...changingxmcvbrp(xmcvbrpcmpre)

ThecreditvaluecalculationisdoneintheFormCMPRE_CALCULATE(SAPLVKMP).

SetabreakpointintheForminsidesoitstopseverytimewhenthecalculationiscalled.ThisyoucandoeitherviaSAPLVKMP
orSAPDBKMV:

GotoSE38:enterSAPLVKMPorSAPDBKMV
DisplaytheSourceCode

https://wiki.scn.sap.com/wiki/plugins/viewsource/viewpagesrc.action?pageId=399379774 2/12
13/10/2017 Exibirorigem

Searchforcmpre_calculate:

Clickontheblueline(doesn'tmatterwhichone),itwilljumptotheform.HereinSAPDBKMVtheformiscalledwitha
perform,doubleclickontheformcmpre_calculate,andinsidetheformsetabreakpoint:

https://wiki.scn.sap.com/wiki/plugins/viewsource/viewpagesrc.action?pageId=399379774 3/12
13/10/2017 Exibirorigem

Goaheadandcreatethesalesorderwiththeexampledata.Entersoldtoparty,materialandquantity.Ensurethatcreditprice
andconfirmedquantityispresentintheitemssotherewillbeacreditvaluecalculationforsure(HINT:ifpossible,ensurethat
onlyoneschedulelineexistsintheitemtounderstandthedebuggingbetterforthefirsttimes).

Creditvaluecalculationhappens:

eitherwhenyousavethedocumentor
whenyouenteraposition,incasetheflag'Itemcheck'ismarkedinOVA8fortherelevantcombination:

Whenyousaveadocumentthecalculationiscalledseveraltimes.Themainfunctionmodule:

salesorder:MCV_STATISTICS_ORDER
delivery:MCV_STATISTICS_DELIVERY
invoice:MCV_STATISTICS_INVOICE

Theprocessisexplainedthroughasalesordercreation.MCV_STATISTICS_ORDERwillcallthecreditvaluecalculationin
followingcases:

1.firsttherewillbeanupdatesimulationfortheactivatedcreditcheck(staticordynamic):
SD_ORDER_CREDIT_CHECK>...>MCV_STATISTICS_ORDER>MCV_STATISTICS_DIALOG_ORDER

https://wiki.scn.sap.com/wiki/plugins/viewsource/viewpagesrc.action?pageId=399379774 4/12
13/10/2017 Exibirorigem

AsthebreakpointissetinsidetheCMPRE_CALCULATEform,itwillstopinthiscallatleast3times(foreveryschedule
lineineveryposition),ateverypossiblecreditvaluecalculation(OLIKW,OLIKWAUandOEIKW).Inthiscasenormal
procedureisused(updategroup12withdeliveryrelatedinvoicing)sotheopensalesordercreditvaluewillbe
calculatedandupdatedintoS066OEIKW.SomakesureyouareattherightcreditvaluecalculationbypressingF7and
checkingwhichcalculationiscalledexactly.FortheOEIKWthisisdoneinfromOFFENE_WERTE_EINT:

Ifthispositionhas2schedulelines,itwillstopforbothlines:

https://wiki.scn.sap.com/wiki/plugins/viewsource/viewpagesrc.action?pageId=399379774 5/12
13/10/2017 Exibirorigem

Ifopendeliveryvalueisusedinthesalesorder(updategroup18),thefieldOLIKWAUwillbecalculated.Pleaseread
HEREmoreaboutthis.InthiscaseCMPRE_CALCULATEiscalledfromtheformOFFENE_WERTE_ERM:

https://wiki.scn.sap.com/wiki/plugins/viewsource/viewpagesrc.action?pageId=399379774 6/12
13/10/2017 Exibirorigem

2.ThesamewillbecalledagainifthestatisticupdateloggingisactivatedbeforehandfortheMC30transaction.Howthis
canbedone,pleasereadHERE.InthiscasetheaboveiscalledagainfromSTATISTIK_UPDATE>
MCV_STATISTICS_ORDER>MCV_STATISTICS_LOG_ORDER:

IfloggingforMC30isnotactive,thisstepisnotexecuted.
3.Asleastforthestatisticupdatethecalculationiscalledagain:STATISTIK_UPDATE>MCV_STATISTICS_ORDER>
MCV_STATISTICS_DIALOG_ORDER:

https://wiki.scn.sap.com/wiki/plugins/viewsource/viewpagesrc.action?pageId=399379774 7/12
13/10/2017 Exibirorigem

ThevaluescalculatedinthisstepwillbeupdatedintoS066andS067.Ifthereisnomodificationinthesystemwith
userexitsorenhancementswhichinfluencesthevalues,thevaluesfromtheabove3callstacksshouldbethesame.

BasedontheabovemakesureyouareattherightcallatthecorrectCMPRE_CALCULATEformtoinvestigatefurther.When
youstopatthebreakpointinsidetheform>pressF7tocomeout>scrolluptoseeatwhichcreditvaluefieldcalculationyou
are.Whenyouareattherightone,inthisexampleatOEIKWcalculation,checkthefields,withthattheperform
CMPRE_CALCULATEwascalled:

https://wiki.scn.sap.com/wiki/plugins/viewsource/viewpagesrc.action?pageId=399379774 8/12
13/10/2017 Exibirorigem

CMPRE:isthecreditpricehandedoverfromthepricingresultintoVBAP.Thisshouldhaveavalue.

OLFMNG:istheopenschedulelinequantity,theconfirmedquantityoftheschedulelinethatisstillopenfordelivery.OLFMNG
iscalculateddynamicallyduringsalesorderprocessing.Ifitiszero,itneedstobeinvetsigatedfurtherwhy.Inthisexample
thepositionhas2schedulelinesandtheconfirmedquantityispresentinthesecondscheduleline:

https://wiki.scn.sap.com/wiki/plugins/viewsource/viewpagesrc.action?pageId=399379774 9/12
13/10/2017 Exibirorigem

TheSDtablesinthestatisticcalculationsstartswithXMC*,ifyouneedtochecksomethingthere.

TheLOOPfortheXMCVBEPontheschedulelinesyoucanfindonestepoutsideinthecallstackhierarchy,intheform
MCINF_UPDATE_ALL:

https://wiki.scn.sap.com/wiki/plugins/viewsource/viewpagesrc.action?pageId=399379774 10/12
13/10/2017 Exibirorigem

AlsohereabitmoreaboveinthecodingyoucanfindtheloopatXMCVBAPifyouhavemorepositions,youcanseta
breakpointherealso:

Ifafieldcontainsadifferentvalueasexpected,youcansetbreakpointsinthecallstackandwithawatchpointonthefieldfind
theplacewherethevaluefortheaffectedfieldisdetermined.

AlsopleasepayattentiontothefieldSUPKZ.Thisdecidesifavalueisbookedintothestatisticsorbookedoutfromthe
statistics.SUPKZhasastrongrelationshipwiththeUPDKZfieldintheXtables.Inmostofthecasesinconsistentcredit
valuesareupdatedduetoamodificationofthefieldUPDKZ.MoreonthisyoureadHERE.

Ifyouchangei.e.asalesorder,intheaboveexampletherewillbe4linesintheXMCVBAPtable,twolineswithSUPKZ=1
andtwolineswithSUPKZ=2:

https://wiki.scn.sap.com/wiki/plugins/viewsource/viewpagesrc.action?pageId=399379774 11/12
13/10/2017 Exibirorigem

Ifyouchangeasalesdocument,statisticupdateisalwaysdone.Dependingonwhichfieldswerechanged,theupdatedvalues
mightbechanged.Ifanoncreditmanagementrelevantfieldischanged,thevalueswhicharebookedoutarethesameasthe
bookedin,sobasicallytheopencreditvaluedidnotchange,justtechnicallythereisabookinandabookout.Thisyoucansee
alsowithMC30:

Ifyoucreateadeliveryorinvoice,youproceedthesamewayasaboveandensurethatyouchecktherightvaluesattheright
place.

https://wiki.scn.sap.com/wiki/plugins/viewsource/viewpagesrc.action?pageId=399379774 12/12

Você também pode gostar