ERP 2.50:Developers Guide/How To Use an Extension Point
Languages: |
Objective
The objective of this how-to is to show how you can use an existing extension point of a PL Function. There is a complete list of available extension points in the Reference section of the Developers Guide
Any time that it is desired to modify the behavior or to extend an already existing process it is possible to take advantage of an Extension Point. In the Inter-company documents are used to create matching documents when orders and invoices are completed. Other usage example could be to generate a work requirement when a sales order for a manufactured product is completed. In this section I’m going to explain how a developer can develop a new procedure to be executed by an existing Extension Point.
To use an Extension Point we just need a PL Procedure following some simple rules:
- The procedure only has one input parameter, the execution instance id.
- It has to retrieve the needed parameters that are available from the ad_ep_instance_para table.
- It has to update the output parameters in the ad_ep_instance_para table.
- Possible exceptions are just raised.
And declare the procedure in the Application Dictionary. To declare it you just need to set the name of the procedure in the Procedures tab for the Extension Point where it has to be executed.
Let us look at it based on the example.
Inter-company Documents example
As said above, this module generates a new matching order when another order is completed. To achieve that requirement we developed the INTERCO_CREATE_ORDER procedure. It retrieves the parameter values using the given ad_ep_instance_id. And it does the necessary actions to generate the new order. At the end the Message parameter is updated appending a new message, so the user knows the Document number of the generated matching order.
Below is a summary of the INTERCO_CREATE_ORDER procedure. We can see how the above logic is implemented. At the beginning the param values are retrieved using the Cur_Params cursor. Later in the code is updated the p_Message variable with the document number of the generated matching order. And finally the Message parameter is updated in the AD_EP_Instance_Para appending the p_Message variable. Notice also how the Exception block just raises the exceptions so they can be caught later in the main procedure that calls the procedure.
CREATE OR REPLACE PROCEDURE INTERCO_CREATE_ORDER(p_ep_instance IN VARCHAR2) ... BEGIN FOR Cur_Params IN ( SELECT * FROM ad_ep_instance_para WHERE ad_ep_instance_id = p_ep_instance) LOOP IF (cur_params.parametername LIKE 'DocAction') THEN p_docaction := Cur_Params.p_string; ELSIF (cur_params.parametername LIKE 'Record_ID') THEN p_record_id := cur_params.p_string; ELSIF (cur_params.parametername LIKE 'User') THEN p_user := cur_params.p_string; ELSIF (cur_params.parametername LIKE 'Message') THEN p_message := cur_params.p_text; ELSIF (cur_params.parametername LIKE 'Result') THEN p_result := cur_params.p_number; END IF; END LOOP; ... p_message:='@INTERCO_ordCreated@' || v_DocumentNo; ... UPDATE ad_ep_instance_para SET p_text = (CASE WHEN p_text IS NULL OR p_text='' THEN p_message ELSE TO_CHAR(p_text) || '<BR>'|| p_message END) WHERE ad_ep_instance_id = p_ep_instance AND parametername LIKE 'Message'; EXCEPTION WHEN OTHERS THEN DBMS_OUTPUT.PUT_LINE('INTERCO_CREATE_ORDER exception') ; RAISE; END INTERCO_CREATE_ORDER;
Languages: |
ERP 2.50:Developers Guide/How to develop dbsourcemanager | ERP 2.50:Developers Guide/How To Use a dbsm from a newer version of ob