{"id":145,"date":"2014-12-04T20:44:51","date_gmt":"2014-12-05T01:44:51","guid":{"rendered":"http:\/\/www.dev-notes.com\/blog\/2014\/12\/04\/using-pl-sql-to-call-ifs-apis\/"},"modified":"2014-12-04T20:44:51","modified_gmt":"2014-12-05T01:44:51","slug":"using-pl-sql-to-call-ifs-apis","status":"publish","type":"post","link":"https:\/\/www.dev-notes.com\/blog\/2014\/12\/04\/using-pl-sql-to-call-ifs-apis\/","title":{"rendered":"Using PL\/SQL to call IFS APIs"},"content":{"rendered":"<p>IFS is an ERP system built by the Swedish software firm Industrial and Financial Systems AB.  It exposes most of its functionality for automation, customization, etc.  Below is an example of how we can use a quick script (to be executed by tools such as SQL*Plus) to automate the batch creation of detail lines in a Customer Order.  Many of the other exposed APIs offered by IFS can be called in a similar manner.<\/p>\n<pre class=\"code\">\ndeclare\n\tinfo_\tvarchar2(4000) := '';\n\tattr_\tvarchar2(4000) := '';\n\tobjid_\tvarchar2(2000) := '';\n\tobjversion_\tvarchar2(2000) := '';\n\n\tcursor recs_ is\n\tselect order_no, cust_id, part_no, qty, unit_cost \n\tfrom my_tmp_worklist_tab;\nbegin\n\tfor rec_ in recs_ loop\n\t\tClient_Sys.Clear_Attr(attr_);\n\t\tinfo_ := '';\n\t\tobjid_ := '';\n\t\tobjversion_ := '';\n\n\t\t-- Add attributes to the Customer Order detail line\n\t\tClient_Sys.Add_To_Attr('ORDER_NO', rec_.order_no, attr_);\n\t\tClient_Sys.Add_To_Attr('DELIVER_TO_CUSTOMER_NO', rec_.cust_id, attr_);\n\t\tClient_Sys.Add_To_Attr('CATALOG_NO', rec_.part_no, attr_);\n\t\tClient_Sys.Add_To_Attr('PART_NO', rec_.part_no, attr_);\n\t\tClient_Sys.Add_To_Attr('BUY_QTY_DUE', rec_.qty, attr_);\n\t\tClient_Sys.Add_To_Attr('DESIRED_QTY', rec_.qty, attr_);\n\t\tClient_Sys.Add_To_Attr('REVISED_QTY_DUE', rec_.qty, attr_);\n\t\tClient_Sys.Add_To_Attr('COST', rec_.unit_cost, attr_);\n\t\tClient_Sys.Add_To_Attr('PLANNED_DELIVERY_DATE', sysdate+7, attr_);\n\t\t-- ... There may be other fields you may wish to populate...\n\n\t\t-- Example of how to update an already-established attribute\n\t\tif (rec_.unit_cost = 0) then\n\t\t\tClient_Sys.Set_Item_Value('COST', '0.01', attr_);\n\t\tend if;\n\t\t\n\t\tbegin\n\t\t\tCustomer_Order_line_API.New__(info_, objid_, objversion_, attr_, 'DO');\n\t\texception\n\t\t\twhen other then\n\t\t\tinfo_ := sqlerrm;\n\t\t\tdbms_output.put_line('Cust Order ' || rec_.order_no || ' error: ' || info_);\n\t\tend;\n\n\t\tcommit;    \n   end loop;   \nend;\n<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>This article provides a quick sample on how to call an IFS API from a custom program.<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[20],"tags":[],"class_list":["post-145","post","type-post","status-publish","format-standard","hentry","category-oracle"],"_links":{"self":[{"href":"https:\/\/www.dev-notes.com\/blog\/wp-json\/wp\/v2\/posts\/145","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.dev-notes.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.dev-notes.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.dev-notes.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.dev-notes.com\/blog\/wp-json\/wp\/v2\/comments?post=145"}],"version-history":[{"count":0,"href":"https:\/\/www.dev-notes.com\/blog\/wp-json\/wp\/v2\/posts\/145\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.dev-notes.com\/blog\/wp-json\/wp\/v2\/media?parent=145"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.dev-notes.com\/blog\/wp-json\/wp\/v2\/categories?post=145"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.dev-notes.com\/blog\/wp-json\/wp\/v2\/tags?post=145"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}