Beruflich Dokumente
Kultur Dokumente
GetStarted
Solutions Support Training Community Developer
Partner About
Community / Blogs
ApprovalWorkflowforPricing
Condition
October30,2013 | 678Views |
TanmayVyas
morebythisauthor
SAPBusinessWorkflow
share
0 share
0 tweet share
0
Follow
BusinessScenario:
Forthepurposeofdemo,considertheconditiontypeforCustomer
Discount (K007). This document provides a custom solution for
developingApprovalWorkflowforConditionRecords.
Aprocessor(salesclerk)cancreateandchangeconditionrecords
viaVK11/VK12transactions.Itisnecessarytodisablethe
processingstatusfieldinordertopreventthesalesclerkfrom
accidentlysettingthestatusasReleased.
CalltransactionSHD0.EntertransactioncodeasVK11and
ZtransactionvariantZVAR_VK.ClickonCreatebutton.
EnterConditiontypeK007andhitEnteronthesubsequent
Popupscreen.
https://blogs.sap.com/2013/10/30/approvalworkflowforpricingcondition/ 2/33
1/23/2017 ApprovalWorkflowforPricingCondition|SAPBlogs
EnteranyCustomernumber,AmountandSetProcessing
statusasBlocked
SetProcessingstatusfieldasOutputOnlyandWith
Contentonthesubsequentpopupscreen.(screenvariant)
https://blogs.sap.com/2013/10/30/approvalworkflowforpricingcondition/ 3/33
1/23/2017 ApprovalWorkflowforPricingCondition|SAPBlogs
HitSaveandthenEnteronthenextpopupscreen.
SavetheTransactionVariantZVAR_VKandScreenvariant
ZVAR_VK_1307.GotoStandardVariantstabandactivate
TransactionVariantZVAR_VK.ThissetsZVAR_VKas
defaulttransactionvariantforVK11transaction.
https://blogs.sap.com/2013/10/30/approvalworkflowforpricingcondition/ 4/33
1/23/2017 ApprovalWorkflowforPricingCondition|SAPBlogs
TransactionVK11nowhastheProcessingStatusasanon
editablecolumnwithDefaultvalueas1(Blocked)
CallTransactionSHD0andactivatethesameTransaction
variantZVAR_VKforConditionChangetransactionVK12.
Similarly,screenvariantscanbecreatedforothercondition
typesandassignedtothistransactionvariant.
Fore.g.TransactionVK12nowhastheProcessingStatusasa
noneditable column with Default value as 1 (Blocked) for
conditiontypePR01
https://blogs.sap.com/2013/10/30/approvalworkflowforpricingcondition/ 5/33
1/23/2017 ApprovalWorkflowforPricingCondition|SAPBlogs
ExtendBusinessObjectBUS3005(Condition)
CalltransactionSWO1(BusinessObjectBuilder)andcreate
objecttypeZZBUS3005
ProvideObjectname,Descriptionandunderlyingprogram
name.Supertypeindicatesthatthisobjecttypeisinherited
fromstandardSAPbusinessobjecttypeBUS3005.
ChangeObjectReleasestatustoImplemented
https://blogs.sap.com/2013/10/30/approvalworkflowforpricingcondition/ 6/33
1/23/2017 ApprovalWorkflowforPricingCondition|SAPBlogs
CreateCustomEvents
PlacecursoronEventsandclickCreate.Onthe
subsequentpopupscreenprovideeventnameCreated.
ThiseventwillserveasTriggeringeventfortheCondition
RecordApprovalWorkflow.
Placecursoroneventandchangeitsreleasestatusto
implemented
https://blogs.sap.com/2013/10/30/approvalworkflowforpricingcondition/ 7/33
1/23/2017 ApprovalWorkflowforPricingCondition|SAPBlogs
CreateEventParameters
PlacecursoroneventandchooseParameters.
https://blogs.sap.com/2013/10/30/approvalworkflowforpricingcondition/ 8/33
1/23/2017 ApprovalWorkflowforPricingCondition|SAPBlogs
ConfigureWorkflowTriggeringeventsonChangeDocument
https://blogs.sap.com/2013/10/30/approvalworkflowforpricingcondition/ 9/33
1/23/2017 ApprovalWorkflowforPricingCondition|SAPBlogs
CalltransactionSWEC(EventLinkageforChange
Documents)andclickonNewEntries
Samplecode:
FUNCTION z_fill_event_cont.
*-
**Local Interface:
* IMPORTING
CDOBJECTCL OPTIONAL
OPTIONAL
OPTIONAL
* TABLES
OPTIONAL
*-
https://blogs.sap.com/2013/10/30/approvalworkflowforpricingcondition/ 10/33
1/23/2017 ApprovalWorkflowforPricingCondition|SAPBlogs
swc_set_table event_container
ChangeDoc_Pos changedocument_position.
ENDFUNCTION.
AlsoaddanewentryforChangedEvent.
CreateCustomAttributes
PlacecursoronAttributesandclickCreate.HitYesonthe
subsequentpopup.
ProvidetablenameasKONHandselectthefieldsas
shown.(Morefieldscanbechosenifrequiredwithin
https://blogs.sap.com/2013/10/30/approvalworkflowforpricingcondition/ 11/33
1/23/2017 ApprovalWorkflowforPricingCondition|SAPBlogs
Workflow.)
ClickCreateonallsubsequentpopupscreenstocreateall
selectedattributes
CreateCustomMethods
ReviewPricingConditionThismethodisusedtopresenta
customapprovalscreentotheReviewer(Salesmanager)
CreateanewfunctionZ_REVIEW_CONDanddesigna
customApprovalscreenthatlistsOld/Newvaluesofthe
PricingConditionrecordandApprove/RejectButtons.
https://blogs.sap.com/2013/10/30/approvalworkflowforpricingcondition/ 12/33
1/23/2017 ApprovalWorkflowforPricingCondition|SAPBlogs
SampleScreen
FunctionmoduleZ_REVIEW_CONDcanbedevelopedwith
the assumption that Change Document table is passed to it
fromworkflow.
For each relevant field in the Change Document table
capture the old and new values and display on custom
screen.
FetchCustomernumberfromConditiontable.(A307inthis
example)
Capture the Review Result as A for Approved and R for
RejectedandpassitasExportingparameter.
Samplecode:
LOOP AT it_changedoc_items.
CASE it_changedoc_items-fname.
* Discount changed
WHEN KBETR.
MOVE it_changedoc_items-value_old TO
v_old_discount.
MOVE it_changedoc_items-value_new TO
https://blogs.sap.com/2013/10/30/approvalworkflowforpricingcondition/ 13/33
1/23/2017 ApprovalWorkflowforPricingCondition|SAPBlogs
v_new_discount.
WHEN DATAB.
WRITE:
it_changedoc_items-value_old TO
wa_old-valid_from,
it_changedoc_items-value_new TO
wa_new-valid_from.
WHEN DATBI.
WRITE:
it_changedoc_items-value_old TO
wa_old-valid_to,
it_changedoc_items-value_new TO
wa_new-valid_to.
WHEN OTHERS.
ENDCASE.
ENDLOOP.
https://blogs.sap.com/2013/10/30/approvalworkflowforpricingcondition/ 14/33
1/23/2017 ApprovalWorkflowforPricingCondition|SAPBlogs
functionparameters.
AutogeneratedCode:
DATA:
https://blogs.sap.com/2013/10/30/approvalworkflowforpricingcondition/ 15/33
1/23/2017 ApprovalWorkflowforPricingCondition|SAPBlogs
OCCURS 0.
createdby.
condtype.
swc_get_table container
ChangeDocumentTable
changedocumenttable.
EXPORTING
im_createdby = createdby
im_cond_type_name = condtype
IMPORTING
ex_review_result =
reviewresult
TABLES
changedocument_position =
changedocumenttable
EXCEPTIONS
OTHERS = 01.
CASE sy-subrc.
WHEN 0. OK
WHEN OTHERS. to be
implemented
ENDCASE.
swc_set_element container
ReviewResult reviewresult.
https://blogs.sap.com/2013/10/30/approvalworkflowforpricingcondition/ 16/33
1/23/2017 ApprovalWorkflowforPricingCondition|SAPBlogs
swc_set_table container
ChangeDocumentTable
changedocumenttable.
end_method.
ReleasePricingConditionThismethodisusedtoRelease
theblockontheConditionrecordafterApproval.
PlacecursoronMethodandclickCreate.Onthe
subsequentpopupscreenprovidemethodname
ReleaseCond.ThismethodisaBackgroundmethod.
PlacecursoronmethodReleaseCondandclickProgramto
writemethodcode.
https://blogs.sap.com/2013/10/30/approvalworkflowforpricingcondition/ 17/33
1/23/2017 ApprovalWorkflowforPricingCondition|SAPBlogs
SampleCode:
container.
DATA :
kotab,
swc_get_property self
Application l_appl.
swc_get_property self
Usage l_usage.
swc_get_property self
Table l_cond_tab.
swc_get_property self
ConditionType l_cond_type.
CLEAR l_cond_tab_name.
EXPORTING
rt_kotabnr = l_cond_tab
rt_kvewe = l_usage
https://blogs.sap.com/2013/10/30/approvalworkflowforpricingcondition/ 18/33
1/23/2017 ApprovalWorkflowforPricingCondition|SAPBlogs
IMPORTING
rt_kotab = l_cond_tab_name.
MOVE l_cond_tab_name TO
v_sel_tab_name.
as RELEASED
UPDATE (v_sel_tab_name)
SET kbstat = 2
kfrst =
conditionrecordno.
IF sy-subrc EQ 0.
ENDIF.
end_method.
PlacecursoronmethodReleaseCondandchangeits
releasestatustoimplemented
SaveandGenerateobjecttypeZZBUS3005
https://blogs.sap.com/2013/10/30/approvalworkflowforpricingcondition/ 19/33
1/23/2017 ApprovalWorkflowforPricingCondition|SAPBlogs
SetupBusinessObjectDelegation
CalltransactionSWO1andclickonSetting>Delegate
AddNewEntry
Thissettingcausesallthenewmethods,attributesandevents
fromZZBUS3005(subtype)willbeavailablewithinobjecttype
BUS3005(supertype)whenitisusedinanyWorkflow.
BuildtemplateforPricingConditionWorkflow
https://blogs.sap.com/2013/10/30/approvalworkflowforpricingcondition/ 20/33
1/23/2017 ApprovalWorkflowforPricingCondition|SAPBlogs
CalltransactionSWDDWorkflowBuilder.ClickSaveand
providenamefortheWorkflowtemplate
ClickonBasicDatatabtosetuptriggeringevents
GotoStartEventstabandsetupCreatedandChanged
eventsofBusinessObjectBUS3005asthetriggeringevents
forthisworkflowtemplate.
Activatetheeventlinkages.
https://blogs.sap.com/2013/10/30/approvalworkflowforpricingcondition/ 21/33
1/23/2017 ApprovalWorkflowforPricingCondition|SAPBlogs
Foreachevent,setupstartcondition>(Conditiontype=
K007)
CreateWorkflowContainervariableChangeDoc_Pos
https://blogs.sap.com/2013/10/30/approvalworkflowforpricingcondition/ 22/33
1/23/2017 ApprovalWorkflowforPricingCondition|SAPBlogs
SetvariableChangeDoc_PospropertyasImportand
Multiline.ThisindicatesthattheChangeDocumenttablewill
bepassedtotheWorkflowfromtheTriggeringEvent
SimilarlycreateWorkflowContainervariableBUS3005of
objecttypeBUS3005andsetitspropertyasImport
Parameter.
GotoStartEventsunderBasicDataandsetuptheData
bindingasshownforbothevents.Thissettingpassesdata
fromEventcontainertoWorkflowcontainerduringthe
triggeringoftheWorkflow
https://blogs.sap.com/2013/10/30/approvalworkflowforpricingcondition/ 23/33
1/23/2017 ApprovalWorkflowforPricingCondition|SAPBlogs
AddanewActivitystepforgeneratingaReviewtask.
ChooseCreatetask
https://blogs.sap.com/2013/10/30/approvalworkflowforpricingcondition/ 24/33
1/23/2017 ApprovalWorkflowforPricingCondition|SAPBlogs
MakesurethatChangeDocumenttableispassedtothetask
andReviewResultisretrievedbacktoWorkflow.
https://blogs.sap.com/2013/10/30/approvalworkflowforpricingcondition/ 25/33
1/23/2017 ApprovalWorkflowforPricingCondition|SAPBlogs
SetthetaskasGeneralTask
UseRule00000168todetermineApproverasthemanager
oftheUser(whocreates/changesaconditionrecord)
AddaconditionsteptodeterminetheResultofApproval.
https://blogs.sap.com/2013/10/30/approvalworkflowforpricingcondition/ 26/33
1/23/2017 ApprovalWorkflowforPricingCondition|SAPBlogs
AddnewActivitystepforReleasingConditionRecordin
background.
ChooseCreatetask
https://blogs.sap.com/2013/10/30/approvalworkflowforpricingcondition/ 27/33
1/23/2017 ApprovalWorkflowforPricingCondition|SAPBlogs
PasstheBusinessObjectinstancetothistask
SaveandactivateWorkflowTemplate
WorkingDEMO
UsercreatesaConditionrecordforConditiontypeK007.
InitiallytheprocessingstatusisBLOCKED
https://blogs.sap.com/2013/10/30/approvalworkflowforpricingcondition/ 28/33
1/23/2017 ApprovalWorkflowforPricingCondition|SAPBlogs
OnSAVE,theWorkflowgetstriggeredandApprovalitemis
routedtotheManageroftheUserwhocreatedtheCondition
record.
Atthistime,thecustomerdiscountisnotreflectedintheOrder
https://blogs.sap.com/2013/10/30/approvalworkflowforpricingcondition/ 29/33
1/23/2017 ApprovalWorkflowforPricingCondition|SAPBlogs
TheSalesManagercanviewthefollowingReviewScreenby
executingtheApprovalWorkitem.(Oldvaluesareblank
sincethisisanewcondition)
OnApproval,theConditionRecordisreleasedandcustomer
discountisnowappliedontotheGrossPriceoftheOrder.
AlertModerator
https://blogs.sap.com/2013/10/30/approvalworkflowforpricingcondition/ 30/33
1/23/2017 ApprovalWorkflowforPricingCondition|SAPBlogs
8Comments
YoumustbeLoggedontocommentorreplytoapost.
ODManikandan
October31,2013at7:10am
VeryNicematerial
Regards,
OD
RonenWeisz
January29,2014at7:24pm
Ihavebeenlookingforawaytodothisforalongtime,
andseeingthewholeprocessasyoushoweditwasveryhelpful.
Onequestion,doyouknowofanywaytodotheconditionupdatewitha
functionmoduleandnotwithadirectupdate?
Ronen
JyotiPrakash
May2,2014at11:52am
Tanmay
Nice&elaborateddocumentation.Keepthegoodwork&wordmoving.
Thanks.
BestWishes,
JP
https://blogs.sap.com/2013/10/30/approvalworkflowforpricingcondition/ 31/33
1/23/2017 ApprovalWorkflowforPricingCondition|SAPBlogs
satishkumarpulijala
May2,2014at5:27pm
hitanmayvyas
Nicematerial
thanku
satish
anandkumarradhakrishnan
May3,2014at7:08am
GoodExplanation!!Thanksalot
WallaceFerreiraeSilva
February5,2016at4:19pm
HiTanmay,
Ifapprovaluserclickcancelbuttoninareviewscreenworkitemis
completed.
Ithinktomovereleasecodeforreviewscreen,becausethemethod
mustbeasynchronousanddontacceptexportparameter.
Howdoyouimplementcancelbuttoninworkflow?
Thanksinadvance.
Wallace
TanmayVyas Postauthor
February22,2016at8:58pm
https://blogs.sap.com/2013/10/30/approvalworkflowforpricingcondition/ 32/33
1/23/2017 ApprovalWorkflowforPricingCondition|SAPBlogs
HiWallace,
InthegivenscenarioIhaveusedaSynchronousmethod
fortheReviewtask.OnclickofCancelbuttonYoucan
usemacroexit_cancelledtoCANCELtheprocessingofthe
workitembutstillkeeptheworkitemwithintheApprovers
inbox.
Tanmay
WallaceFerreiraeSilva
February23,2016at12:41pm
ThanksTanmay,
Iusedassychronousmethodwithsucesss.But
inVK11andVK12whenuserentermoreone
lineintabelcontrolkbstatnotfilledwithscreen
variant.
Howdosolvedthisissue?
Thanksinadvanceandcongratsgreatjob!
https://blogs.sap.com/2013/10/30/approvalworkflowforpricingcondition/ 33/33