{-----------------------------------------------------------------------
'
' procedure for the order manager
'
'----------------------------------------------------------------------------------}
{....................................AGENT INFO..............................................}
start_agent_info
AgentName = "ORDER_MANAGER"
AgentDescr = ""
AgentLanguage = ""
__timer_interval = 0
__is_registered = 1
__delete_on_termination = 0
end_agent_info
{....................................PRODUCTION CODE..................................................}
{..............................................................................new order}
start_bpm_activity "new order"
start_bpm_subactivity "Order elements"
rec = bpm_getrecid()
if (rec = 0) then
call OpenForm("ptAppend","ORD_E01.FM","WORK.ORDER",1,"?=ORDER")
else
expr = strcat(rec,"=ORDER")
call OpenForm("ptEdit","ORD_E01.FM","WORK.ORDER",1,expr)
endif
end_bpm_subactivity
end_bpm_activity
{..................................................................................construct product}
start_bpm_activity "construct product"
start_bpm_subactivity "Product"
rec = __params[1]
expr = strcat(rec,"=PRODUCT")
call OpenForm("ptEdit","PROD_E01.FM","WORK.PRODUCT",1,expr)
end_bpm_subactivity
end_bpm_activity
{..................................................................................ship order}
start_bpm_activity "ship order"
start_bpm_subactivity "Order to ship"
rec = __params[1]
expr = strcat(rec,"=ORDER")
call OpenForm("ptEdit","ORD_E01.FM","WORK.ORDER",1,expr)
end_bpm_subactivity
end_bpm_activity
{.....................................CONTROL CODE......................................................}
{.................................ACTION CODE................................................
This agent has as job to coordinate (that' why we call it a coordinator agent) the activities of
a "luxury cars service facility".
The salesmen (any user) can put an order
All the products of the order must be constructed
All the products start constructing at the same time (parallel split with an undefined number of splits!)
After all products are finished then shipment can be follow
At any time the salesman (__activation_user) can see the progress of the order and can keep informed the customer
The agent follows the events in real time (at the time that they are happen!)
}
start_action
{ press F8 for next step }
call bpm_setprocedureowner(__activation_user) {.....set the procedure owner}
{(1)....any user can put a new customer order}
callwait bpm_assign_job ( "new order" , __activation_user , "" , 0)
ord_id = bpm_getrecid(1,__au_step) {......get the record id of the service request}
customer = LookUp("ORDER","ORDER",ord_id,"CUSTOMER","")
call bpm_setprocedurecomment(customer) {.....set the procedures comment}
{...................................put all product in array variables}
start_sql "_DAT" "KOSMOS"
SELECT PRODUCT.*
FROM PRODUCT
WHERE (PRODUCT.ORDER = :P)
end_sql
call RunEmbSQL("_DAT",ord_id)
q = QueryByName("_DAT")
count = TRecordCount(q) ;
call TFirst(q)
for i = 1 to count
prod_id[i] = TGetFld(q;"PRODUCT")
prod = TGetFld(q;"PRODUCT_NAME")
quant = TGetFld(q;"QUANTITY")
comm[i] = strcat("PROD=", prod, " Q=", quant )
call TNext(q)
next
call FreeEmbSQL("_DAT")
{..................................start the production of products (all start at the same time}
split_for i = 1 to count
{(2)....construct every product requested ...parallel split}
call bpm_setstepcomment(comm[i])
callwait bpm_assign_job ( "construct product" , "" , "PRODUCTION" , 0 , prod_id[i] )
next_branch
{(3)....when all products have been constructed then ship the order}
callwait bpm_assign_job ( "ship order" , "" , "TRANSPORTATION" , 0 , ord_id )
{------------------------------------ end of procedure ---------------------------------------------}
end_action
|