User Hooks are a feature that allows customizing the application in a way that is less invasive and that can be easily disabled for diagnosing problems with the customization. Hooks are code that is conditionally executed by some application packages. The condition is that the hook has to be enabled.
Hook calls are interleaved in some of ASO APIs, mostly on public APIs. There are two types of Hooks:
Pre-processing Hooks: Are hooks that execute (if enabled) before the API does any actual processing. These are good for modifying/adding information so the API can proceed with that change in place. These hooks are of type B (from Before)
Post-processing Hooks: Are hooks that execute (if enabled) after the API did all processing. Post hooks are usually good for cleanup of a pre-hook or for further processing after the vanilla API has finished work. These hooks are of type A (from After).
Below are the Steps to Implement Custom Hooks in ASO .
Requirement for Implementation in my Case - In my example I want to use Freight Terms at the iStore to be used as Qualifier to derive the item price in Shopping Cart in iStore, but Freight Terms is not supported as Qualifier for iStore ,and to fulfilfill this requirement , I have implemented custom hook to used Freight Terms as Qualifier from the iStore.
Implementation Steps
To implement this custom hook, I have used ASO Pre-user hook API to populate ASO_PRICING_INT.G_HEADER_REC.freight_terms_code prior to the pricing call.(I have referred metalink note 400550.1 for my implementation).
Step#1 –
Create the Package Body ASO_QUOTE_CUHK (Package Specification for this Package already exists in System).Make sure all the functions that are available in the specifications got created in the Body
Step#2-
Modify the Package Body
In Procedure Create_quote_PRE(
Add following Code
-----------------
BEGIN
P_hd_Shipment_Rec.FREIGHT_TERMS_CODE := 'Due'; -- IMPORTANT ( Write the code to populate Freight Term from iStore).
x_return_Status:='S';
END;
------------------
PLEASE , please make sure you add "x_return_Status:='S'"
Step#3-
Similarly in Procedure Update_quote_PRE , Add
BEGIN
If P_Hd_Shipment_Tbl.Count>0 Then
P_Hd_Shipment_Tbl(1).Freight_Terms_Code := 'Due'; -- IMPORTANT , we need to populate the Value from iStore
IF aso_debug_pub.g_debug_flag = 'Y' THEN
Aso_Debug_Pub.Add('P_hd_Shipment_tbl(1).FREIGHT_TERMS_CODE: '||P_Hd_Shipment_Tbl(1).Freight_Terms_Code);
End If;
x_return_Status:='S';
end if;
END;
PLEASE , please make sure you add "x_return_Status:='S'"
Step#4- Run
Select * From Jtf_User_Hooks
Where Pkg_Name Like 'ASO_QUOTE_PUB'
And User_Hook_Type = 'C'
and api_name in ('CREATE_QUOTE', 'UPDATE_QUOTE').
1. and verify that we have data for api_name in ('CREATE_QUOTE', 'UPDATE_QUOTE') and User_hook_type =C and Processing type = B and A.
2. If we don't have data for api_name in ('CREATE_QUOTE', 'UPDATE_QUOTE') then we need to run asocruhk.sql.
Step#5-
Execute
Update Jtf_User_Hooks
Set Execute_Flag = 'Y'
Where Upper(Pkg_Name) = 'ASO_QUOTE_PUB'
And UPPER(API_NAME) = 'CREATE_QUOTE'
And User_Hook_Type = 'C'
and processing_type='B'
Update Jtf_User_Hooks
Set Execute_Flag = 'Y'
Where Upper(Pkg_Name) = 'ASO_QUOTE_PUB'
And Upper(Api_Name) = 'UPDATE_QUOTE'
And User_Hook_Type = 'C'
and processing_type='B'
That’s all , after successful implementations of above steps ,my customer was able to use “Freight Charges Captured at iStore” as Qualifier to derive the Price.
No comments:
Post a Comment