SubscribeEvent

The on execute hook for the SubscribeEvent of BII X contains the following code:

#pragma used dll oppmmmbl002sb00 | business object Y
#pragma used dll oppmmmbl003sb00 | business object Z

#define CHECK_RET(retval, ...)
^		if retval <> 0 then
^			dal.set.error.message(…)
^			return(DALHOOKERROR)
^		endif

long	requestY		| request xml for Y
long	requestZ		| request xml for Z
long	responseY	| response xml from Y
long	responseZ	| response xml from Z
long	resultY			| result xml from Y
long	resultZ			| result xml from Z
boolean	anyEventActionLeft	| whether request contains any non-standard events
long	retl				| return value to be checked
long	duml			| dummy variable

| forward request to Y
retl = replaceBdeNameInRequest(i.request, “Y”, requestY)
CHECK_RET(retl)
retl = ppmmm.bl002sb00.SubscribeEvent(requestY, responseY, resultY)
duml = xmlDelete(requestY)
if retl = 0 then
	duml = xmlDelete(responseY)
else
	o.result = resultY
	o.response = 0
	dal.set.error.message(…)
	|* Failed to execute SubscribeEvent for Y which implements X
	return(DALHOOKERROR)
endif

| forward request to Z
retl = replaceBdeNameInRequest(i.request, “Z”, requestZ)
CHECK_RET(retl)
retl = ppmmm.bl003sb00.SubscribeEvent(requestZ, responseZ, resultZ)
duml = xmlDelete(requestZ)
if retl = 0 then
	duml = xmlDelete(responseZ)
else
	| limitation: the request for Y already succeeded; we must merge resultZ into 
	| the response information area instead?
	o.result = resultZ
	o.response = 0
	dal.set.error.message(…)
	|* Failed to execute SubscribeEvent for Z which implements X
	return(DALHOOKERROR)
endif

| determine request for default handling of X
retl = removeStandardEventsFromRequest(i.request, anyEventActionLeft)
| note: strictly speaking we are not allowed to change input parameter i.request,
| but we cannot avoid this here
CHECK_RET(retl)
if anyEventActionLeft then
	| note: must not do this if no event actions left, because then we will get a 
	| subscription for all standard event actions on X, which is incorrect!
	io.default = true	  | to make sure a subscription is created for X for specific events
else
	| we are ready
	o.response = xmlNewNode(“SubscribeEventResponse”)
endif

return(0) | OK

Y and Z will get the default implementation for SubscribeEvent().