Generally to default a Sales Order Attribute programmatically, we need to set the attribute value in its global record, ont_header_def_hdlr.g_record.
Lets take an example of defaulting ATTRIBUTE1 field of sales order header for which we dont have a defaulting rule. To set ATTRIBUTE1 we need to consider another attribute which has a defaulting rule associate it as a DUMMY defaulting rule. In this example lets consider ‘Shipping Method’ as dummy defaulting rule. For ‘Shipping Method’ select a defaulting source as ‘PL/SQL API’ and call a package with below logic.
The below logic is just to use ‘Shipping Method’ as dummy defaulting rule and set the value for attribute1 by setting it to ont_header_def_hdlr.g_record.attribute1 and return ‘Shipping Method’ value to ‘Shipping Method’ defaulting itself.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 | FUNCTION xx_so_header_att_default_f ( p_database_object_name IN VARCHAR2, p_attribute_code IN VARCHAR2 ) /* ************************************************************************* ** ** ** Name: XX_SO_HEADER_ATT_DEFAULT_F ** ** Type of Object: Function ** ** Description: To default attribute1 of sales order ** ** Parameters: ** ** p_database_object_name VARCHAR2 ** ** p_attribute_code VARCHAR2 ** ** Returns: VARCHAR2 ** ** Note: Though this custom API is called for 'Shipping Method' ** ** defaulting rule, this logic is nothing to do with ** ** 'Shipping Method'. This is just to default DFF attribute1 ** ** This function always Returns the value which is already ** ** there in Shipping Method ** ** ** ****************************************************************************/ RETURN VARCHAR2 AS l_header_rec oe_ak_order_headers_v%ROWTYPE; l_attribute_context apps.oe_order_headers_all.CONTEXT%TYPE := 'XYZ_CONTEXT'; l_attribute1 apps.oe_order_headers_all.attribute1%TYPE := 'XYZ_ATT1_VALUE'; l_shipping_method_code app.oe_order_headers_all.shipping_method_code%TYPE; BEGIN l_header_rec := ont_header_def_hdlr.g_record; l_shipping_method_code := ont_header_def_hdlr.g_record.shipping_method_code; ---------------------------------------------------------------------------- --Setting Context and Attribute1 of Order Header by assigning value to a run --time record type collection ---------------------------------------------------------------------------- ont_header_def_hdlr.g_record.CONTEXT := l_attribute_context; ont_header_def_hdlr.g_record.attribute1 := l_attribute1; -------------------------- --Returning Shipping Method -------------------------- RETURN l_shipping_method_code; -- EXCEPTION WHEN OTHERS THEN IF oe_msg_pub.check_msg_level (oe_msg_pub.g_msg_lvl_unexp_error) THEN oe_msg_pub.add_exc_msg ('OE_Default_PVT', 'CUSTOM_DEFAULT_RULE'); END IF; RAISE fnd_api.g_exc_unexpected_error; END xx_so_header_att_default_f; |
We can default any attribute programmatically which is present in the ont_header_def_hdlr.g_record, Usually all columns of sales order header are present in this global record.
Similarly you can use ont_line_def_hdlr.g_record to default any attribute on sales order line level.
Do drop a comment if you need any additional information on implementing this.