This is to create multiple PTO (or ATO) Items in Sales Orders through an API.
This is a very often requirement to any client.
Pre-requisites:
1) A BOM should be defined for that Model Item.
Steps:
1) Get the Configurator ID and Revision number for that model item.
2) Populate the headers level records for the API Call.
/*****************INITIALIZE HEADER RECORD******************************/ l_header_rec := oe_order_pub.g_miss_header_rec;
/*****************POPULATE REQUIRED ATTRIBUTES **********************************/
l_header_rec.operation := oe_globals.g_opr_create;
l_header_rec.order_source_id := l_order_source_id; l_header_rec.orig_sys_document_ref := rec_stg_hdr_all.category_room; l_header_rec.order_type_id := l_trans_type_id;
l_header_rec.sold_to_org_id := l_cust_account_id;
l_header_rec.price_list_id := l_price_list_id;
l_header_rec.invoice_to_org_id := l_bill_id;
l_header_rec.ship_to_org_id := l_ship_id;
l_header_rec.salesrep_id := g_salesrep_id;
l_header_rec.ordered_date := SYSDATE;
l_header_rec.operation := oe_globals.g_opr_create;
l_header_rec.created_by := g_user_id;
l_header_rec.creation_date := SYSDATE;
l_header_rec.last_update_date := SYSDATE;
l_header_rec.transactional_curr_code := g_trans_curr_code;
l_header_rec.org_id := g_org_id;
3) Assiging Line items:
/*****************INITIALIZE ACTION REQUEST RECORD*************************************/
l_action_request_tbl(l_count) := oe_order_pub.g_miss_request_rec; --****************INITIALIZE LINE RECORD******************************** l_line_tbl (l_count) := oe_order_pub.g_miss_line_rec;
l_line_tbl (l_count).orig_sys_document_ref := rec_stg_hdr.category_room;
l_line_tbl (l_count).orig_sys_line_ref := l_count;
l_line_tbl (l_count).inventory_item_id := rec_stg_hdr.top_model_item_id;
l_line_tbl (l_count).request_date := SYSDATE;
l_line_tbl (l_count).line_number := l_count;
l_line_tbl (l_count).ordered_quantity := 1;
l_line_tbl (l_count).operation := oe_globals.g_opr_create;
l_line_tbl (l_count).tax_exempt_flag := g_tax_exempt_flag;
l_line_tbl (l_count).config_header_id := p_config_header_id;
l_line_tbl (l_count).item_type_code := g_item_type_code;
l_line_tbl (l_count).config_rev_nbr := p_config_rev_nbr;
l_line_tbl (l_count).top_model_line_index := l_count;
l_line_tbl (l_count).link_to_line_index := NULL;
l_line_tbl (l_count).created_by := g_user_id;
l_line_tbl (l_count).creation_date := SYSDATE;
l_line_tbl (l_count).last_update_date := SYSDATE;
l_line_tbl (l_count).line_type_id := l_line_trans_type_id;
The intersting here is
we need to populate the two columns while creating with the API.
l_line_tbl (l_count).top_model_line_index := l_count;
l_line_tbl (l_count).link_to_line_index := NULL;