33
SmartPlant Materials Using the Site API Version 2011 R1 SP2 (7.1.2) November 2014 DMAR1-PE-200128C

SPMAT 7.1.x with 11g - SmartPlant Materials Using the Site APIspmat.hec.co.kr/marian_webentry/Pdfs/INT-Site.pdf · 2014. 11. 6. · Version 2011 R1 SP2 (7.1.2) ... Other Documentation

  • Upload
    others

  • View
    2

  • Download
    1

Embed Size (px)

Citation preview

Page 1: SPMAT 7.1.x with 11g - SmartPlant Materials Using the Site APIspmat.hec.co.kr/marian_webentry/Pdfs/INT-Site.pdf · 2014. 11. 6. · Version 2011 R1 SP2 (7.1.2) ... Other Documentation

SmartPlant Materials Using the Site API

Version 2011 R1 SP2 (7.1.2)

November 2014

DMAR1-PE-200128C

Page 2: SPMAT 7.1.x with 11g - SmartPlant Materials Using the Site APIspmat.hec.co.kr/marian_webentry/Pdfs/INT-Site.pdf · 2014. 11. 6. · Version 2011 R1 SP2 (7.1.2) ... Other Documentation

Copyright Copyright © 2009-2014 Intergraph® Corporation. All Rights Reserved. Intergraph is part of Hexagon.

Including software, file formats, and audiovisual displays; may be used pursuant to applicable software license agreement; contains confidential and proprietary information of Intergraph and/or third parties which is protected by copyright law, trade secret law, and international treaty, and may not be provided or otherwise made available without proper authorization from Intergraph Corporation.

U.S. Government Restricted Rights Legend Use, duplication, or disclosure by the government is subject to restrictions as set forth below. For civilian agencies: This was developed at private expense and is "restricted computer software" submitted with restricted rights in accordance with subparagraphs (a) through (d) of the Commercial Computer Software - Restricted Rights clause at 52.227-19 of the Federal Acquisition Regulations ("FAR") and its successors, and is unpublished and all rights are reserved under the copyright laws of the United States. For units of the Department of Defense ("DoD"): This is "commercial computer software" as defined at DFARS 252.227-7014 and the rights of the Government are as specified at DFARS 227.7202-3.

Unpublished - rights reserved under the copyright laws of the United States.

Intergraph Corporation 300 Intergraph Way Huntsville, AL 35813

Documentation Documentation shall mean, whether in electronic or printed form, User's Guides, Installation Guides, Reference Guides, Administrator's Guides, Customization Guides, Programmer's Guides, Configuration Guides and Help Guides delivered with a particular software product.

Other Documentation Other Documentation shall mean, whether in electronic or printed form and delivered with software or on Intergraph Smart Support, SharePoint, or box.net, any documentation related to work processes, workflows, and best practices that is provided by Intergraph as guidance for using a software product.

Terms of Use a. Use of a software product and Documentation is subject to the End User License Agreement ("EULA") delivered with the

software product unless the Licensee has a valid signed license for this software product with Intergraph Corporation. If the Licensee has a valid signed license for this software product with Intergraph Corporation, the valid signed license shall take precedence and govern the use of this software product and Documentation. Subject to the terms contained within the applicable license agreement, Intergraph Corporation gives Licensee permission to print a reasonable number of copies of the Documentation as defined in the applicable license agreement and delivered with the software product for Licensee's internal, non-commercial use. The Documentation may not be printed for resale or redistribution.

b. For use of Documentation or Other Documentation where end user does not receive a EULA or does not have a valid licenseagreement with Intergraph, Intergraph grants the Licensee a non-exclusive license to use the Documentation or Other Documentation for Licensee’s internal non-commercial use. Intergraph Corporation gives Licensee permission to print a reasonable number of copies of Other Documentation for Licensee’s internal, non-commercial. The Other Documentation may not be printed for resale or redistribution. This license contained in this subsection b) may be terminated at any time and for any reason by Intergraph Corporation by giving written notice to Licensee.

Disclaimer of Warranties Except for any express warranties as may be stated in the EULA or separate license or separate terms and conditions, Intergraph Corporation disclaims any and all express or implied warranties including, but not limited to the implied warranties of merchantability and fitness for a particular purpose and nothing stated in, or implied by, this document or its contents shall be considered or deemed a modification or amendment of such disclaimer. Intergraph believes the information in this publication is accurate as of its publication date.

The information and the software discussed in this document are subject to change without notice and are subject to applicable technical product descriptions. Intergraph Corporation is not responsible for any error that may appear in this document.

The software, Documentation and Other Documentation discussed in this document are furnished under a license and may be used or copied only in accordance with the terms of this license. THE USER OF THE SOFTWARE IS EXPECTED TO MAKE THE FINAL EVALUATION AS TO THE USEFULNESS OF THE SOFTWARE IN HIS OWN ENVIRONMENT.

Intergraph is not responsible for the accuracy of delivered data including, but not limited to, catalog, reference and symbol data. Users should verify for themselves that the data is accurate and suitable for their project work.

2 SmartPlant Materials Using the Site API

Page 3: SPMAT 7.1.x with 11g - SmartPlant Materials Using the Site APIspmat.hec.co.kr/marian_webentry/Pdfs/INT-Site.pdf · 2014. 11. 6. · Version 2011 R1 SP2 (7.1.2) ... Other Documentation

Limitation of Damages IN NO EVENT WILL INTERGRAPH CORPORATION BE LIABLE FOR ANY DIRECT, INDIRECT, CONSEQUENTIAL INCIDENTAL, SPECIAL, OR PUNITIVE DAMAGES, INCLUDING BUT NOT LIMITED TO, LOSS OF USE OR PRODUCTION, LOSS OF REVENUE OR PROFIT, LOSS OF DATA, OR CLAIMS OF THIRD PARTIES, EVEN IF INTERGRAPH CORPORATION HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.

UNDER NO CIRCUMSTANCES SHALL INTERGRAPH CORPORATION’S LIABILITY EXCEED THE AMOUNT THAT INTERGRAPH CORPORATION HAS BEEN PAID BY LICENSEE UNDER THIS AGREEMENT AT THE TIME THE CLAIM IS MADE. EXCEPT WHERE PROHIBITED BY APPLICABLE LAW, NO CLAIM, REGARDLESS OF FORM, ARISING OUT OF OR IN CONNECTION WITH THE SUBJECT MATTER OF THIS DOCUMENT MAY BE BROUGHT BY LICENSEE MORE THAN TWO (2) YEARS AFTER THE EVENT GIVING RISE TO THE CAUSE OF ACTION HAS OCCURRED.

IF UNDER THE LAW RULED APPLICABLE ANY PART OF THIS SECTION IS INVALID, THEN INTERGRAPH LIMITS ITS LIABILITY TO THE MAXIMUM EXTENT ALLOWED BY SAID LAW.

Export Controls Intergraph Corporation’s software products and any third-party Software Products obtained from Intergraph Corporation, its subsidiaries, or distributors (including any Documentation, Other Documentation or technical data related to these products) are subject to the export control laws and regulations of the United States. Diversion contrary to U.S. law is prohibited. These Software Products, and the direct product thereof, must not be exported or re-exported, directly or indirectly (including via remote access) under the following circumstances:

a. To Cuba, Iran, North Korea, Sudan, or Syria, or any national of these countries. b. To any person or entity listed on any U.S. government denial list, including but not limited to, the U.S. Department of Commerce

Denied Persons, Entities, and Unverified Lists, http://www.bis.doc.gov/complianceandenforcement/liststocheck.htm, the U.S. Department of Treasury Specially Designated Nationals List, http://www.treas.gov/offices/enforcement/ofac/, and the U.S. Department of State Debarred List, http://www.pmddtc.state.gov/compliance/debar.html.

c. To any entity when Licensee knows, or has reason to know, the end use of the Software Product is related to the design, development, production, or use of missiles, chemical, biological, or nuclear weapons, or other un-safeguarded or sensitive nuclear uses.

d. To any entity when Licensee knows, or has reason to know, that an illegal reshipment will take place. e. Any questions regarding export or re-export of these Software Products should be addressed to Intergraph Corporation’s Export

Compliance Department, Huntsville, Alabama 35894, USA.

Trademarks Intergraph, the Intergraph logo, Intergraph Smart, PDS, SmartPlant, SmartMarine, FrameWorks, I-Sketch, IntelliShip, ISOGEN, SmartSketch, SPOOLGEN, SupportManager, SupportModeler, Sapphire, and FreeView are trademarks or registered trademarks of Intergraph Corporation or its subsidiaries in the United States and other countries. Microsoft and Windows are registered trademarks of Microsoft Corporation. MicroStation is a registered trademark of Bentley Systems, Inc. Other brands and product names are trademarks of their respective owners.

SmartPlant Materials Using the Site API 3

Page 4: SPMAT 7.1.x with 11g - SmartPlant Materials Using the Site APIspmat.hec.co.kr/marian_webentry/Pdfs/INT-Site.pdf · 2014. 11. 6. · Version 2011 R1 SP2 (7.1.2) ... Other Documentation

4 SmartPlant Materials Using the Site API

Page 5: SPMAT 7.1.x with 11g - SmartPlant Materials Using the Site APIspmat.hec.co.kr/marian_webentry/Pdfs/INT-Site.pdf · 2014. 11. 6. · Version 2011 R1 SP2 (7.1.2) ... Other Documentation

Contents Preface .......................................................................................................................................................... 7

Documentation Comments ..................................................................................................................... 7

Introduction .................................................................................................................................................. 9

Project Defaults ....................................................................................................................................... 9

Exporting .................................................................................................................................................... 11

Verification of Data Synchronization ..................................................................................................... 12

Importing .................................................................................................................................................... 13

Receiving .............................................................................................................................................. 13 Issuing ................................................................................................................................................... 13 Forecasting ........................................................................................................................................... 14

WRITE_FA_HEADER .................................................................................................................... 14 Material Transfer ............................................................................................................................ 20 Stores Requisitions ......................................................................................................................... 21

Utilities ........................................................................................................................................................ 23

Appendix: API Procedures and Functions ............................................................................................. 25

Index ........................................................................................................................................................... 33

SmartPlant Materials Using the Site API 5

Page 6: SPMAT 7.1.x with 11g - SmartPlant Materials Using the Site APIspmat.hec.co.kr/marian_webentry/Pdfs/INT-Site.pdf · 2014. 11. 6. · Version 2011 R1 SP2 (7.1.2) ... Other Documentation

Contents

6 SmartPlant Materials Using the Site API

Page 7: SPMAT 7.1.x with 11g - SmartPlant Materials Using the Site APIspmat.hec.co.kr/marian_webentry/Pdfs/INT-Site.pdf · 2014. 11. 6. · Version 2011 R1 SP2 (7.1.2) ... Other Documentation

This document describes the Site API.

Documentation Comments Send documentation comments or suggestions to [email protected] (mailto:[email protected]?subject=documentation comments).

Preface

SmartPlant Materials Using the Site API 7

Page 8: SPMAT 7.1.x with 11g - SmartPlant Materials Using the Site APIspmat.hec.co.kr/marian_webentry/Pdfs/INT-Site.pdf · 2014. 11. 6. · Version 2011 R1 SP2 (7.1.2) ... Other Documentation

Preface

8 SmartPlant Materials Using the Site API

Page 9: SPMAT 7.1.x with 11g - SmartPlant Materials Using the Site APIspmat.hec.co.kr/marian_webentry/Pdfs/INT-Site.pdf · 2014. 11. 6. · Version 2011 R1 SP2 (7.1.2) ... Other Documentation

S E C T I O N 1

The Site API is designed for data exchange of site data with external systems. The functionality is provided by the database package m_api_site. All necessary type and function definitions required by the user are accessible in the package specification (which is unwrapped).

Please note that this documentation assumes that the user is familiar with the Oracle data types RECORD and TABLE as well as the use of functions and procedures.

The Site API consists of an export and an import part. While the export part provides functions to get the data necessary for an external system to handle site functionality, the import part provides functions to transfer receiving and issuing data back to SmartPlant Materials.

Project Defaults The export operation is enabled by setting the project default ZI_SITE_API to Y on A.20.12. This default can be set only on the product group/project level, but not for a specific discipline. Modification of the project default is not possible if site data already exists.

If some of the tables used in the Site API contain data defined in the product group, it is also necessary to set the value of the project default in the product group to Y.

Data of tables that are not assigned to any project at all (like unit groups, units, NLS, and so forth) are always exported if ZI_SITE_API is set to Y for at least one project.

Introduction

SmartPlant Materials Using the Site API 9

Page 10: SPMAT 7.1.x with 11g - SmartPlant Materials Using the Site APIspmat.hec.co.kr/marian_webentry/Pdfs/INT-Site.pdf · 2014. 11. 6. · Version 2011 R1 SP2 (7.1.2) ... Other Documentation

Introduction

10 SmartPlant Materials Using the Site API

Page 11: SPMAT 7.1.x with 11g - SmartPlant Materials Using the Site APIspmat.hec.co.kr/marian_webentry/Pdfs/INT-Site.pdf · 2014. 11. 6. · Version 2011 R1 SP2 (7.1.2) ... Other Documentation

S E C T I O N 2

The following data tables are available for export:

M_COMPANIES

M_PROJECTS

M_NLS

M_APPL_ROLES

M_DISCIPLINES

M_USERS

M_WAREHOUSES

M_WAREHOUSE_NLS

M_LOCATIONS

M_LOCATION_NLS

M_SITE_MATL_STATUS

M_SITE_MATL_STATUS_NLS

M_UNITS

M_UNIT_GROUPS

M_STATUS

M_WH_TO_USERS

M_SHIPMENT_GROUPS

M_PO_HEADERS

M_PO_LINE_ITEMS

M_PO_HEADER_NLS

M_COMMODITY_CODES

M_COMMODITY_CODE_NLS

M_COMMODITY_CODE_LAYOUTS

M_IDENTS

M_IDENT_NLS

M_LIST_NODES

M_LIST_NODE_NLS

M_LIST_POS

M_HEATS

Exporting

SmartPlant Materials Using the Site API 11

Page 12: SPMAT 7.1.x with 11g - SmartPlant Materials Using the Site APIspmat.hec.co.kr/marian_webentry/Pdfs/INT-Site.pdf · 2014. 11. 6. · Version 2011 R1 SP2 (7.1.2) ... Other Documentation

Exporting M_SUPPLIERS

M_ITEM_SHIPS

M_USER_SECURITIES

M_HEAT_DETAILS

For each table, the package specification contains a RECORD TYPE definition containing all fields available for export and a TABLE TYPE definition (a table containing the individual records). These TYPE definitions are used as output parameters by the export functions.

The package specification lists all export functions (the names always start with get_). Input parameters are the date from which all changes are requested and the proj_id (only for tables with a proj_id). The output parameter is always of type TABLE OF RECORD (see above).

Verification of Data Synchronization After each call to an export procedure, the function check_export can be called to check the number of inserts, updates, and deletes on the external system. The function check_export checks the number of inserts, updates, and deletes for a specific table for the same user that started the data request. The return values are OK / FAIL.

12 SmartPlant Materials Using the Site API

Page 13: SPMAT 7.1.x with 11g - SmartPlant Materials Using the Site APIspmat.hec.co.kr/marian_webentry/Pdfs/INT-Site.pdf · 2014. 11. 6. · Version 2011 R1 SP2 (7.1.2) ... Other Documentation

S E C T I O N 3

The import feature supports the functionality of screens C.20.01, C.20.03, and C.20.22.01 in SmartPlant Materials. Only the creation of new data is supported (esi_status = N).

Input parameters are a record containing the import data and a commit indicator. Setting this parameter to Y ends the function in the case of successful processing with a commit.

Output parameters are the result code (containing the error code) and the error message. In the case of successful execution of the API procedure/function, the values of these two output parameters are not defined.

A return value of -1 of the import functions always indicates an error.

Receiving The import operation consists of the following functions:

write_mrr_header - Returns the MRR_ID from SmartPlant Materials.

write_mrr_header_nls - Returns 0 for successful execution.

write_inv_receipts - Returns the INV_RECEIPT_ID from SmartPlant Materials.

write_heat_details - Returns the HD_ID from SmartPlant Materials.

post_mrr - Returns 0 for successful execution.

A call to the post function is only successful if all previous inserts for an MRR have succeeded. In the case of an error, the cycle write_mrr_header, write_mrr_header_nls, and write_inv_receipts must be started again. In this case, all data belonging to the MRR causing the error is deleted.

The import data is always checked for compliance with SmartPlant Materials business rules. Otherwise, the import is rejected with error code -20000. The error message contains detailed information.

Issuing The import operation consists of the following functions:

write_mir_header - Returns the MIR_ID from SmartPlant Materials.

write_mir_header_nls - Returns 0 for successful execution.

write_inv_issues - Returns the IIS_ID from SmartPlant Materials.

post_mir - Returns 0 for successful execution.

mir_results - Returns the data from write_inv_issues.

A call to the post function is only successful if all previous inserts for a MIR have succeeded. In the case of an error, the cycle write_mir_header, write_mir_header_nls, and write_inv_issues

Importing

SmartPlant Materials Using the Site API 13

Page 14: SPMAT 7.1.x with 11g - SmartPlant Materials Using the Site APIspmat.hec.co.kr/marian_webentry/Pdfs/INT-Site.pdf · 2014. 11. 6. · Version 2011 R1 SP2 (7.1.2) ... Other Documentation

Importing must be started again. In this case, all the data belonging to the MIR causing the error is deleted.

The import data is always checked for compliance with SmartPlant Materials business rules. Otherwise, the import is rejected with error code -20000. The error message contains detailed information.

Forecasting For forecast and reservation runs, the following functions are available:

write_fa_header - Returns the FAH_ID from SmartPlant Materials.

write_fa_header_nls - Returns 0 for successful execution.

start_fah - Returns 0 for successful execution.

fah_results - Returns the data from start_fah.

WRITE_FA_HEADER Topics Work package priorities ................................................................. 14 List of commodity codes and sizes ................................................ 15 Attribute values .............................................................................. 17 Templates ...................................................................................... 20

Work package priorities Along with the name of the drawing, the following additional information can be submitted with the API to deal with the priorities of work packages with respect to reservation of material:

Priority

RoS Date

Priority Type

Attribute

Attribute Sort Order

Implementation FUNCTION write_fa_header( p_proj_id IN m_user_securities.proj_id%TYPE,

p_fah IN fa_header_rec,

p_ln IN ln_tab_type,

p_wh IN wh_array,

auto_assign_wh_ind IN VARCHAR2,

p_commit IN VARCHAR2,

p_result OUT NUMBER,

14 SmartPlant Materials Using the Site API

Page 15: SPMAT 7.1.x with 11g - SmartPlant Materials Using the Site APIspmat.hec.co.kr/marian_webentry/Pdfs/INT-Site.pdf · 2014. 11. 6. · Version 2011 R1 SP2 (7.1.2) ... Other Documentation

Importing p_message OUT VARCHAR2,

p_wp IN wp_array,

p_fah_template IN fa_header_template_rec )

RETURN m_fa_headers.fah_id%TYPE

The wp_array has the following incoming values to deal with the priorities of work packages:

p_wp(1).order_seq := 1;

p_wp(1).ros_date := '03-Jul-2014';

p_wp(1).priority_type := 'WP';

p_wp(1).attr_code := 'ATTRIBUTE';

p_wp(1).attr_sort := 'ASC';

The example above shows how to assign values. If these values are not filled in, the defaults apply.

List of commodity codes and sizes You can reserve material driven by a set of commodity codes and sizes.

You can pass a list of commodity codes and sizes along with each drawing. If all items on a drawing are needed, SmartPlant Construction does not pass a list of commodity codes and sizes. As for the tagged items, the tag number becomes the commodity code, and this allows you to pass a list of tagged items.

Implementation The wp_array is a PL/SQL table with two dimensions inside the API. The content of this PL/SQL table is passed into the function write_fa_header and the values are stored in a database table M_API_COMM_CODES to track the data.

Here is an extract of the function specification:

TYPE cc_rec IS RECORD

( commodity_code m_commodity_codes.commodity_code%TYPE,

input_1 m_idents.input_1%TYPE,

input_2 m_idents.input_2%TYPE,

input_3 m_idents.input_3%TYPE,

input_4 m_idents.input_4%TYPE,

input_5 m_idents.input_5%TYPE );

TYPE cc_array IS TABLE OF cc_rec INDEX BY BINARY_INTEGER;

TYPE wp_rec IS RECORD

( WP_ID m_work_packs.wp_id%TYPE

,WP_CODE m_work_packs.wp_code%TYPE

,WP_TYPE m_work_packs.wp_type%TYPE DEFAULT 'S'

SmartPlant Materials Using the Site API 15

Page 16: SPMAT 7.1.x with 11g - SmartPlant Materials Using the Site APIspmat.hec.co.kr/marian_webentry/Pdfs/INT-Site.pdf · 2014. 11. 6. · Version 2011 R1 SP2 (7.1.2) ... Other Documentation

Importing ,LOCKED_IND m_work_packs.locked_ind%TYPE DEFAULT 'N'

,PRIORITY_TYPE m_work_packs.priority_type%TYPE DEFAULT 'WP'

,M_USR_ID m_work_packs.m_usr_id%TYPE

,ATTR_CODE m_attrs.attr_code%TYPE

,AQC1_CODE m_adm_query_conds.aqc_code%TYPE

,AQC2_CODE m_adm_query_conds.aqc_code%TYPE

,AQC3_CODE m_adm_query_conds.aqc_code%TYPE

,AQC4_CODE m_adm_query_conds.aqc_code%TYPE

,AQC5_CODE m_adm_query_conds.aqc_code%TYPE

,ORDER_SEQ m_wp_to_fahs.order_seq%TYPE

,ROS_DATE m_wp_to_fahs.ros_date%TYPE

,ATTR_SORT m_wp_to_fahs.attr_sort%TYPE

,API_CC_TAB cc_array

,API_ATTR_TAB attr_array);

TYPE wp_array IS TABLE OF wp_rec INDEX BY BINARY_INTEGER;

Here is an example of incoming values:

p_wp(1).api_cc_tab(1).commodity_code := '165201ETOF2E205';

p_wp(1).api_cc_tab(1).input_1 := 0;

p_wp(1).api_cc_tab(1).input_2 := 0;

p_wp(1).api_cc_tab(1).input_3 := 0;

p_wp(1).api_cc_tab(1).input_4 := 0;

p_wp(1).api_cc_tab(1).input_5 := 0;

p_wp(1).api_cc_tab(2).commodity_code := '165201EFOF2J042';

p_wp(1).api_cc_tab(2).input_1 := 0;

p_wp(1).api_cc_tab(2).input_2 := 0;

p_wp(1).api_cc_tab(2).input_3 := 0;

p_wp(1).api_cc_tab(2).input_4 := 0;

p_wp(1).api_cc_tab(2).input_5 := 0;

16 SmartPlant Materials Using the Site API

Page 17: SPMAT 7.1.x with 11g - SmartPlant Materials Using the Site APIspmat.hec.co.kr/marian_webentry/Pdfs/INT-Site.pdf · 2014. 11. 6. · Version 2011 R1 SP2 (7.1.2) ... Other Documentation

Importing To limit the forecast run/reservation run to the incoming values, a Where condition (for idents) is automatically generated and attached to the generated work package.

The following is the MV_WHERE view created for the Where condition:

CREATE OR REPLACE FORCE VIEW M_SYS.MV_WHERE_10000000538 (IDENT, LN_ID, LP_ID, RLI_ID)

AS

SELECT IDENT , NULL, NULL, NULL

FROM mvp_idents i, mvp_commodity_codes cc

WHERE i.commodity_id = cc.commodity_id

AND EXISTS (SELECT 1 FROM m_api_comm_codes apcc

WHERE apcc.commodity_code = cc.commodity_code

AND NVL(apcc.input_1,-1) = NVL(i.input_1,-1)

AND NVL(apcc.input_2,-1) = NVL(i.input_2,-1)

AND NVL(apcc.input_3,-1) = NVL(i.input_3,-1)

AND NVL(apcc.input_4,-1) = NVL(i.input_4,-1)

AND NVL(apcc.input_5,-1) = NVL(i.input_5,-1)

AND apcc.aqc_id = 10000000538)

The incoming values are stored in the M_API_COMM_CODES table.

Attribute values You can reserve specific materials based on their attribute values, for example, if you want to reserve materials needed for shop, field, or installation.

Some information related to usage or destination of material is not a property of the component, but a property of the BOM position. For example, if a component is a shop, field, or installation component, this is indicated by a BOM property. The property (attribute) values are evaluated so that a list of attributes and values per work package can be passed. SmartPlant Materials translates the attributes and values into a Where condition for list positions.

SmartPlant Materials Using the Site API 17

Page 18: SPMAT 7.1.x with 11g - SmartPlant Materials Using the Site APIspmat.hec.co.kr/marian_webentry/Pdfs/INT-Site.pdf · 2014. 11. 6. · Version 2011 R1 SP2 (7.1.2) ... Other Documentation

Importing Implementation The wp_array is a PL/SQL table with two dimensions inside the API. The content of this PL/SQL table is passed into the function write_fa_header and the values are stored in a database table M_API_ATTRS to track the data.

Here is an extract of the function specification:

TYPE attr_rec IS RECORD

( attr_code m_attrs.attr_code%TYPE,

attr_value m_attr_values.attr_value%TYPE );

TYPE attr_array IS TABLE OF attr_rec INDEX BY BINARY_INTEGER;

TYPE wp_rec IS RECORD

( WP_ID m_work_packs.wp_id%TYPE

,WP_CODE m_work_packs.wp_code%TYPE

,WP_TYPE m_work_packs.wp_type%TYPE DEFAULT 'S'

,LOCKED_IND m_work_packs.locked_ind%TYPE DEFAULT 'N'

,PRIORITY_TYPE m_work_packs.priority_type%TYPE DEFAULT 'WP'

,M_USR_ID m_work_packs.m_usr_id%TYPE

,ATTR_CODE m_attrs.attr_code%TYPE

,AQC1_CODE m_adm_query_conds.aqc_code%TYPE

,AQC2_CODE m_adm_query_conds.aqc_code%TYPE

,AQC3_CODE m_adm_query_conds.aqc_code%TYPE

,AQC4_CODE m_adm_query_conds.aqc_code%TYPE

,AQC5_CODE m_adm_query_conds.aqc_code%TYPE

,ORDER_SEQ m_wp_to_fahs.order_seq%TYPE

,ROS_DATE m_wp_to_fahs.ros_date%TYPE

,ATTR_SORT m_wp_to_fahs.attr_sort%TYPE

,API_CC_TAB cc_array

,API_ATTR_TAB attr_array);

TYPE wp_array IS TABLE OF wp_rec INDEX BY BINARY_INTEGER;

Here are examples of incoming values:

p_wp(1).api_attr_tab(1).attr_code := 'UNIT_SECT';

p_wp(1).api_attr_tab(1).attr_value := 'HUMBUG';

p_wp(1).api_attr_tab(2).attr_code := 'PURC_DEST';

p_wp(1).api_attr_tab(2).attr_value := 'HH';

p_wp(1).api_attr_tab(3).attr_code := 'DES_AREA';

p_wp(1).api_attr_tab(3).attr_value := 'SCHWARZ';

18 SmartPlant Materials Using the Site API

Page 19: SPMAT 7.1.x with 11g - SmartPlant Materials Using the Site APIspmat.hec.co.kr/marian_webentry/Pdfs/INT-Site.pdf · 2014. 11. 6. · Version 2011 R1 SP2 (7.1.2) ... Other Documentation

Importing To limit the forecast run/reservation run to the incoming values, a Where condition (for list positions) is automatically generated and attached to the generated work package.

The following is the MV_WHERE view created for the Where condition:

CREATE OR REPLACE FORCE VIEW M_SYS.MV_WHERE_10000000516 (IDENT, LN_ID, LP_ID, RLI_ID)

AS

SELECT NULL, NULL, TAB_3.LP_ID, NULL FROM

MVP_LIST_POS TAB_3,

MVP_LIST_POS_VALUES TAB_101,

MVP_API_ATTRS A_101,

MVP_LIST_POS_VALUES TAB_102,

MVP_API_ATTRS A_102,

MVP_LIST_POS_VALUES TAB_103,

MVP_API_ATTRS A_103,

SYS.DUAL

WHERE 1 = 1

AND TAB_101.ATTR_ID = 500195

AND TAB_101.LP_ID = TAB_3.LP_ID

AND TAB_101.ATTR_ID = A_101.ATTR_ID

AND TAB_101.ATTR_VALUE = 'HUMBUG'

AND TAB_102.ATTR_ID = 500342

AND TAB_102.LP_ID = TAB_3.LP_ID

AND TAB_102.ATTR_ID = A_102.ATTR_ID

AND TAB_102.ATTR_VALUE = 'HH'

AND TAB_103.ATTR_ID = 500252

AND TAB_103.LP_ID = TAB_3.LP_ID

AND TAB_103.ATTR_ID = A_103.ATTR_ID

AND TAB_103.ATTR_VALUE = 'SCHWARZ'

SmartPlant Materials Using the Site API 19

Page 20: SPMAT 7.1.x with 11g - SmartPlant Materials Using the Site APIspmat.hec.co.kr/marian_webentry/Pdfs/INT-Site.pdf · 2014. 11. 6. · Version 2011 R1 SP2 (7.1.2) ... Other Documentation

Importing The incoming values are stored in the M_API_ATTRS table.

Templates You can use the forecast/reservation templates so that there is more control on priorities or warehouses being used. You can pass the name of any existing forecast/reservation run. All run options, BOM options, and calculate options of the template are used as defaults for the newly generated run. The template includes the header page and the list of assigned warehouses.

Implementation The order_seq value in wh_array controls the order sequence of attached warehouses.

Here are examples of incoming values:

wh_code(1).wh_code := 'MW-WH1';

wh_code(1).order_seq := 1;

wh_code(2).wh_code := 'MW-WH2';

wh_code(2).order_seq := 2;

If these values are not filled in, the defaults apply.

Material Transfer The import operation consists of the following functions:

write_mtr_header - Returns the MTR_ID from SmartPlant Materials.

write_mtr_header_nls - Returns 0 for successful execution.

write_inv_transfers - Returns the ITR_ID from SmartPlant Materials.

post_mtr - Returns 0 for successful execution.

A call to the post function is only successful if all previous inserts for an MTR have succeeded. In the case of an error, the cycle write_mtr_header, write_mtr_header_nls, and write_inv_transfers must be started again. In this case, all data belonging to the MTR causing the error is deleted.

The import data is always checked for compliance with SmartPlant Materials business rules. Otherwise, the import is rejected with error code -20000. The error message contains detailed information.

20 SmartPlant Materials Using the Site API

Page 21: SPMAT 7.1.x with 11g - SmartPlant Materials Using the Site APIspmat.hec.co.kr/marian_webentry/Pdfs/INT-Site.pdf · 2014. 11. 6. · Version 2011 R1 SP2 (7.1.2) ... Other Documentation

Importing

Stores Requisitions The import operation consists of the following functions:

write_srr_header - Imports stores requisition header information and returns the m_stores_req_rpts.srr_id from SmartPlant Materials.

write_srr_header_nls - Imports the language dependent stores requisition short description and description and returns 0 for a successful execution.

write_stores_requisitions - Imports stores requisition details and returns the m_stores_requisitions.srs_id from SmartPlant Materials.

The import data is always checked for compliance with SmartPlant Materials business rules. Otherwise, the import is rejected with error code -20000. The error message contains detailed information.

SmartPlant Materials Using the Site API 21

Page 22: SPMAT 7.1.x with 11g - SmartPlant Materials Using the Site APIspmat.hec.co.kr/marian_webentry/Pdfs/INT-Site.pdf · 2014. 11. 6. · Version 2011 R1 SP2 (7.1.2) ... Other Documentation

Importing

22 SmartPlant Materials Using the Site API

Page 23: SPMAT 7.1.x with 11g - SmartPlant Materials Using the Site APIspmat.hec.co.kr/marian_webentry/Pdfs/INT-Site.pdf · 2014. 11. 6. · Version 2011 R1 SP2 (7.1.2) ... Other Documentation

S E C T I O N 4

The following functions/procedures are not necessary for external programs working with the Site API. These functions are used for internal purposes only, and for technical reasons are defined in the package specification:

enable_site_api - Enables all triggers used for writing changes to the export tables.

By default, all triggers are enabled after installation of the Site API.

disable_site_api - Disables all triggers used for writing changes to the export tables.

This procedure should only be called if the Site API is not used at all.

version - Returns information about the currently installed version of the Site API.

get_esi_active - For internal API use only.

get_esi_active_all - For internal API use only.

get_pg_code - For internal API use only.

get_ident - Returns the current ident (current session).

get_ident_code - Returns the current ident code (current session).

get_commodity_id - Returns the current commodity ID (current session).

get_commodity_code - Returns the current commodity code (current session).

Utilities

SmartPlant Materials Using the Site API 23

Page 24: SPMAT 7.1.x with 11g - SmartPlant Materials Using the Site APIspmat.hec.co.kr/marian_webentry/Pdfs/INT-Site.pdf · 2014. 11. 6. · Version 2011 R1 SP2 (7.1.2) ... Other Documentation

Utilities

24 SmartPlant Materials Using the Site API

Page 25: SPMAT 7.1.x with 11g - SmartPlant Materials Using the Site APIspmat.hec.co.kr/marian_webentry/Pdfs/INT-Site.pdf · 2014. 11. 6. · Version 2011 R1 SP2 (7.1.2) ... Other Documentation

A P P E N D I X A

All procedures and functions of the M_API_SITE package are listed below, with the corresponding tables and the purpose.

Proc/Func Name Table Purpose

F build_query_cond Build the query conditions for C.30.01.02 Assigned Work Packages

F check_export

F check_tag_master_detail

Check split tag

F check_undo Check Undo Forecast/Reservation Run

F create_rr_from_fr Create a reservation run from an existing forecast run

P delete_mir Delete unposted MIR

P disable_site_api Deactivation of export triggers

P enable_site_api Activation of export triggers

P exec_ddl Procedure creates the views and the grants

P fah_results Retrieving forecast/reservation run results

P get_actual_polis_data

M_ACTUAL_POLIS

P get_appl_role_data M_APPL_ROLES Selects roles data from m_appl_roles

Appendix: API Procedures and Functions

SmartPlant Materials Using the Site API 25

Page 26: SPMAT 7.1.x with 11g - SmartPlant Materials Using the Site APIspmat.hec.co.kr/marian_webentry/Pdfs/INT-Site.pdf · 2014. 11. 6. · Version 2011 R1 SP2 (7.1.2) ... Other Documentation

Appendix: API Procedures and Functions Proc/Func Name Table Purpose

P get_bin_loc_data M_BIN_LOCATIONS Bin Locations

P get_bin_loc_loc_data

M_BIN_LOC_LOCATIONS Bin Location Warehouse Locations

P get_bin_loc_nls_data

M_BIN_LOCATION_NLS Bin Location NLS

P get_bin_loc_wh_data

M_BIN_LOC_WAREHOUSES Bin Location Warehouses

P get_c4001_totals Get total quantities from C4001

F get_cascade_del_proj_id

Get proj_id for detail tables for cascade delete

P get_cc_layout_data M_COMMODITY_CODE_LAYOUTS

P get_cc_nls_data M_COMMODITY_CODE_NLS

F get_commodity_code

M_COMMODITY_CODES Returns the current commodity code (current session)

P get_commodity_code_data

M_COMMODITY_CODES

F get_commodity_id M_COMMODITY_CODES Returns the current commodity ID (current session)

P get_company_data M_COMPANIES Selects company data from m_companies

P get_discipline_data M_DISCIPLINES Selects discipline data from m_disciplines

F get_esi_active Get interface status (enabled Y/N)

F get_esi_active_all Get interface status (enabled Y/N) for tables without proj_id

P get_heat_data M_HEATS Heat numbers

26 SmartPlant Materials Using the Site API

Page 27: SPMAT 7.1.x with 11g - SmartPlant Materials Using the Site APIspmat.hec.co.kr/marian_webentry/Pdfs/INT-Site.pdf · 2014. 11. 6. · Version 2011 R1 SP2 (7.1.2) ... Other Documentation

Appendix: API Procedures and Functions Proc/Func Name Table Purpose

P get_heat_detail_data

M_HEAT_DETAILS Heat number details

F get_ident M_IDENTS Returns the current ident (current session)

F get_ident_code M_IDENTS Returns the current ident code (current session)

P get_ident_nls_data M_IDENT_NLS

P get_idents_data M_IDENTS

P get_item_ship_data M_ITEM_SHIPS

F get_ivi_id_by_uk

P get_list_node_data M_LIST_NODES

P get_list_node_nls_data

M_LIST_NODE_NLS

P get_list_pos_data M_LIST_POS

P get_location_data M_LOCATIONS Selects warehouse location data from m_locations

P get_location_nls_data

M_LOCATION_NLS Selects the language dependent location descriptions from m_location_nls

P get_lp_by_ident_tag

Get list position by ident or tag_number

P get_lp_values M_LIST_POS_VALUES

P get_mat_stat_data M_SITE_MATL_STATUS Selects receiving status data from m_site_matl_status

P get_mat_stat_nls_data

M_SITE_MATL_STATUS_NLS Selects the language dependent receiving status description from m_site_matl_status_nls

F get_max_run_num Get the max run number of

SmartPlant Materials Using the Site API 27

Page 28: SPMAT 7.1.x with 11g - SmartPlant Materials Using the Site APIspmat.hec.co.kr/marian_webentry/Pdfs/INT-Site.pdf · 2014. 11. 6. · Version 2011 R1 SP2 (7.1.2) ... Other Documentation

Appendix: API Procedures and Functions Proc/Func Name Table Purpose

ber a forecast run

P get_nls_data M_NLS Selects language data from m_nls

F get_pg_code Returns the product group for project

P get_po_line_data M_PO_LINE_ITEMS

P get_poh_data M_PO_HEADERS Purchase order header

P get_poh_nls_data M_PO_HEADER_NLS Language dependent purchase order description

P get_project_data M_PROJECTS Selects project data from m_projects

P get_shipment_group_data

M_SHIPMENT_GROUPS

P get_status_data M_STATUS Selects status data from m_status

P get_supplier_data M_SUPPLIERS

F get_sysdate Returns the current date

P get_unit_data M_UNITS Selects unit data from m_units

P get_unit_group_data

M_UNIT_GROUPS Selects unit group data from m_unit_groups

P get_user_data M_USERS Selects user data from m_users

P get_user_sec_data M_USER_SECURITIES Selects user securities data from m_user_securities

P get_warehouse_data

M_WAREHOUSES Selects warehouse data from m_warehouses

P get_warehouse_nls_data

M_WAREHOUSE_NLS Selects the language dependent warehouse descriptions from m_warehouse_nls

28 SmartPlant Materials Using the Site API

Page 29: SPMAT 7.1.x with 11g - SmartPlant Materials Using the Site APIspmat.hec.co.kr/marian_webentry/Pdfs/INT-Site.pdf · 2014. 11. 6. · Version 2011 R1 SP2 (7.1.2) ... Other Documentation

Appendix: API Procedures and Functions Proc/Func Name Table Purpose

P get_wh_user_data M_WH_TO_USERS Selects warehouse to user data from m_wh_to_users

P mir_results Retrieving MIR data

P mrr_results Retrieving MRR data

F new_run Create a new run of an existing forecast run

F post_mir Posting of a MIR

F post_mrr Posting of an MRR

F post_mtr Posting of an MTR

P set_cascade_del_proj_id

Get proj_id for detail tables for cascade delete

P set_login_env Set the login environment (us_id)

F start_fah Start forecast/reservation run

F undo_node Undo BOM node of Forecast/Reservation Run

F undo_pos Undo BOM position of Forecast/Reservation Run

F undo_run Undo Forecast/Reservation Run

F unpost_mrr Revert the posting of an MRR

F write_exp_ctrl Inserts trace records into m_esi_export_ctrls table

F write_fa_header Import forecast/reservation run

F write_fa_header_nls

Import language dependent forecast/reservation run description

SmartPlant Materials Using the Site API 29

Page 30: SPMAT 7.1.x with 11g - SmartPlant Materials Using the Site APIspmat.hec.co.kr/marian_webentry/Pdfs/INT-Site.pdf · 2014. 11. 6. · Version 2011 R1 SP2 (7.1.2) ... Other Documentation

Appendix: API Procedures and Functions Proc/Func Name Table Purpose

F write_heat_detail Import heat details

F write_inv_issues Import inventory issues

F write_inv_receipts Import MRR line items

F write_inv_transfers Import material transfer details

F write_mir_header Import material issue report (MIR)

F write_mir_header_nls

Import language dependent MIR description

F write_mrr_header Import material receiving report (MRR)

F write_mrr_header_nls

Import language dependent MRR description

F write_mtr_header Import material transfer report (MTR)

F write_mtr_header_nls

Import language dependent MTR description

F write_osd Import over, short & damaged report (OSD)

F write_osd_nls Import language dependent OSD description

F write_srr_header Import stores requisition report (SRR)

F write_srr_header_nls

Import language dependent SRR description

F write_stores_requisitions

Import stores requisition details

F write_work_pack Import work package

30 SmartPlant Materials Using the Site API

Page 31: SPMAT 7.1.x with 11g - SmartPlant Materials Using the Site APIspmat.hec.co.kr/marian_webentry/Pdfs/INT-Site.pdf · 2014. 11. 6. · Version 2011 R1 SP2 (7.1.2) ... Other Documentation

Appendix: API Procedures and Functions Proc/Func Name Table Purpose

F write_work_pack_details

Import work package details

F write_work_pack_nls

Import language dependent work package description

SmartPlant Materials Using the Site API 31

Page 32: SPMAT 7.1.x with 11g - SmartPlant Materials Using the Site APIspmat.hec.co.kr/marian_webentry/Pdfs/INT-Site.pdf · 2014. 11. 6. · Version 2011 R1 SP2 (7.1.2) ... Other Documentation

Appendix: API Procedures and Functions

32 SmartPlant Materials Using the Site API

Page 33: SPMAT 7.1.x with 11g - SmartPlant Materials Using the Site APIspmat.hec.co.kr/marian_webentry/Pdfs/INT-Site.pdf · 2014. 11. 6. · Version 2011 R1 SP2 (7.1.2) ... Other Documentation

A Appendix

API Procedures and Functions • 25 Attribute values • 17

E Exporting • 11

F Forecasting • 14

I Importing • 13 Introduction • 9 Issuing • 13

L List of commodity codes and sizes • 15

M Material Transfer • 20

P Preface • 7 Project Defaults • 9

R Receiving • 13

S Stores Requisitions • 21

T Templates • 20

U Utilities • 23

V Verification of Data Synchronization • 12

W Work package priorities • 14 WRITE_FA_HEADER • 14

Index

SmartPlant Materials Using the Site API 33