/* Copyright 2020 Siemens Digital Industries Software ================================================== Copyright 2020. Siemens Product Lifecycle Management Software Inc. All Rights Reserved. ================================================== Copyright 2020 Siemens Digital Industries Software */ /** @file Contains declarations of the publish APIs of Product Master Automation. */ #ifndef PMA0_AUTOMATION_H #define PMA0_AUTOMATION_H #include #include /** @defgroup PMA0AUTOMATION Product Master Automation
This module contains the declaration of APIs used during generation/updation of Engineering BOM from Design BOM and vice-versa.
The term "Source" refers to the input structure and "Target" refers to the output structure.
ex. For generating Engineerig BOM from a Design BOM, Design BOM is the source structure and Engineering BOM is the target structure.
This process involves creating target items and target structure.
While generating a target Item corresponding to a source Item, Find or Create of target item is performed.
The OOTB find logic is based on Part Design alignment
The OOTB create logic uses the prefix/suffix specified in the preferences @c Pma0_EBOM_Prefix_Suffix
and @c Pma0_DBOM_Prefix_Suffix to set @c item_id, @c object_name properties on target Item CreateInput.
In addition, @c object_desc property is copied on the target Item CreateInput.

The above OOTB Find or create logic is customizable using following 2 User Exits.
These User Exits are invoked from both the ITKs - #PMA0_generate_engineering_bom, #PMA0_generate_design_bom.

For more details about Find or Create customization follow the below documentation.
Find: @code int CustomPartType::Custom_find_parts( METHOD_message_t *, va_list args ) { int iFail = ITK_ok; try { va_list largs; va_copy(largs, args); const tag_t pSrcDesignType = static_cast(va_arg(largs, void *)); //In this example, we want the custom find logic to be executed for Designs of type "CustomDesign" scoped_smptr srcDesignTypeName; rs = TCTYPE_ask_name2(pSrcDesignType, &srcDesignTypeName); if (std::string(srcDesignTypeName.getString()) != "CustomDesign") { //Following error must be added to error stack and returned, //when we do not want to proceed with the custom logic. int ifail = PMA0AUTOMATION_user_exit_skip_execution; ERROR_store(ERROR_severity_error, ifail); return ifail; } const std::vector * pSrcDesignLines = static_cast*>( va_arg( largs, void * ) ); std::map * pSrcDsgnLineToFoundPart = static_cast *>( va_arg( largs, void * ) ); va_end( largs ); for( auto srcLine : *pSrcDesignLines ) { tag_t foundPart = NULLTAG; //Custom find logic based on srcLine if( found ) { ( *pSrcDsgnLineToFoundPart ).insert( { srcLine,foundPart } ); } } } } @endcode
Create:
  • When the User Exit is not overridden, system creates the target ITEMs using default createInput.
  • This User Exit should be overridden for custom ITEM types when the custom ITEM type has mandatory properties to be populated from @p source_lines. @note To override the User Exit, attach the extension to BO operation BMF_Pma0_find_target_items_for_sources on source Item. The arguments of the extension should exactly match the arguments of this User Exit.
  • The output map contains the target item createInputs against sources. All the input sources should have a corresponding target createInput.
@code int CustomPartType::Custom_populate_creI_for_parts( METHOD_message_t *, va_list args ) { int iFail = ITK_ok; try { va_list largs; va_copy( largs, args ); const tag_t pSrcDesignType = static_cast(va_arg(largs, void *)); //In this example, we want the custom find logic to be executed for Designs of type "CustomDesign" scoped_smptr srcDesignTypeName; rs = TCTYPE_ask_name2(pSrcDesignType, &srcDesignTypeName); if (std::string(srcDesignTypeName.getString()) != "CustomDesign") { //Following error must be added to error stack and returned, //when we do not want to proceed with the custom logic. int ifail = PMA0AUTOMATION_user_exit_skip_execution; ERROR_store(ERROR_severity_error, ifail); return ifail; } const std::vector * pSrcDesignLines = static_cast*>( va_arg( largs, void * ) ); std::map * pSrcDsgnLineToPartCreI = static_cast *>( va_arg( largs, void * ) ); va_end( largs ); for( auto srcLine : *pSrcDesignLines ) { tag_t partCreInput = NULLTAG; //populate createInput of the target type for mandatory properties to be derived from srcLine ( *pSrcDsgnLineToPartCreI ).insert( { srcLine,partCreInput } ); } } } @endcode @{ */ #ifdef __cplusplus extern "C" { #endif /** Generates an Engineering BOM structure corresponding to the input design sources. @note The following preferences must be appropriately set prior to calling this ITK:
  • @c Pma0_EBOM_Prefix_Suffix
  • @c Pma0_DBOM_skip_node_conditions
  • @c Pma0_DBOM_skip_occurrence_conditions
  • @c Pma0_Part_Design_Type
  • @c Pma0_EBOMRoot_DBOMRoot_Type
  • @c Pma0_ChildItemType_RevOccType
@returns
  • #ITK_ok on success.
  • #PF_INVALID if value provided for the preference @c Pma0_EBOM_Prefix_Suffix, @c Pma0_EBOM_skip_node_conditions, @c Pma0_DBOM_skip_occurrence_conditions, @c Pma0_Part_Design_Type, @c Pma0_EBOMRoot_DBOMRoot_Type, @c Pma0_ChildItemType_RevOccType is invalid.
  • #PMA0AUTOMATION_input_root_skipped if the Engineering BOM structure cannot be generated for the input @p dbom_source, because it is configured to be skipped (through preference @c Pma0_skip_node_conditions) and it does not contain any unskipped parent.
  • #PMA0AUTOMATION_invalid_part_or_design if the Part object for source object Design @p dbom_sources was not created because it is not a valid type. The supported type is Design.
  • #PMA0AUTOMATION_no_item_rev if the Engineering BOM top line is unconfigured.
  • #AOM_inst_read_protected if there is no read access or revision not configured on topline
  • #AOM_inst_write_protected if current logged in user have no write access on target BOM Line in drag drop.
  • #PMA0AUTOMATION_nodes_not_processed if the engineering node creation fails or if the engineering node and design node linking/alignment fails.
  • #PMA0AUTOMATION_invalid_source_selection if the root design node is drag-dropped which is a representation of product.
  • #PMA0AUTOMATION_target_node_skipped if the root target node is configured to be skipped.
*/ extern PMA0AUTOMATION_API int PMA0_generate_engineering_bom( tag_t dbom_source, /**< (I) Design BOM source BOMLine */ logical is_part_ebom, /**< (I) Specifies whether to create a Engineering BOM root item as part or product. It is required when @p ebom_target is #NULLTAG. */ tag_t* ebom_target /**< (O)Top line of the generated engineering BOM.*/ ); /** Generates a Design BOM structure corresponding to the input part sources. @note The following preferences must be appropriately set prior to calling this ITK:
  • @c Pma0_DBOM_Prefix_Suffix
  • @c Pma0_EBOM_skip_node_conditions
  • @c Pma0_EBOM_skip_occurrence_conditions
  • @c Pma0_Part_Design_Type
  • @c Pma0_EBOMRoot_DBOMRoot_Type
@returns
  • #ITK_ok on success.
  • #PF_INVALID if value provided for the preference @c Pma0_DBOM_Prefix_Suffix, @c Pma0_DBOM_skip_node_conditions, @c Pma0_EBOM_skip_occurrence_conditions, @c Pma0_Part_Design_Type, @c Pma0_EBOMRoot_DBOMRoot_Type, @c Pma0_ChildItemType_RevOccType is invalid.
  • #PMA0AUTOMATION_input_root_skipped if the Design BOM structure cannot be generated for the input @p ebom_source, because it is configured to be skipped (through preference @c Pma0_skip_node_conditions) and it does not contain any unskipped parent.
  • #PMA0AUTOMATION_invalid_part_or_design if the Design object for source object Part was not created because it is not a valid type. The supported type is Part.
  • #PMA0AUTOMATION_no_item_rev if the Design BOM top line is unconfigured.
  • #AOM_inst_read_protected if there is no read access or revision not configured on topline
  • #AOM_inst_write_protected if current logged in user have no write access on target BOM Line in drag drop.
  • #PMA0AUTOMATION_nodes_not_processed if the design node creation fails or if the engineering node and design node linking/alignment fails.
  • #PMA0AUTOMATION_invalid_source_selection if the product is drag-dropped on a design node.
  • #PMA0AUTOMATION_target_node_skipped if the root target node is configured to be skipped.
*/ extern PMA0AUTOMATION_API int PMA0_generate_design_bom( tag_t ebom_source, /**< (I) Engineering BOM source BOMLine */ tag_t* dbom_target /**< (O)Top line of the generated design BOM.*/ ); /** Updates the engineering BOM structure linked to the design BOM structure starting from a given design top line.
The engineering structure is updated as per the default action specified on the design BOMLine property @c pma0UpdateAction. @note The following preferences must be appropriately set prior to calling this ITK:
  • @c Pma0_EBOM_Prefix_Suffix
  • @c Pma0_DBOM_skip_node_conditions
  • @c Pma0_DBOM_skip_occurrence_conditions
  • @c Pma0_Part_Design_Type
  • @c Pma0_EBOMRoot_DBOMRoot_Type
  • @c Pma0_ChildItemType_RevOccType
@returns
  • #ITK_ok on success
  • #PF_INVALID if value provided for the preference @c Pma0_DBOM_Prefix_Suffix, @c Pma0_DBOM_skip_node_conditions, @c Pma0_Part_Design_Type, @c Pma0_EBOMRoot_DBOMRoot_Type, @c Pma0_ChildItemType_RevOccType is invalid.
  • #PMA0AUTOMATION_input_root_skipped if the Engineering BOM structure cannot be updated for the input @p dbom_source, because it is configured to be skipped (through preference @c Pma0_skip_node_conditions) and it does not contain any unskipped parent.
  • #PMA0AUTOMATION_no_item_rev if the Design BOM top line is unconfigured.
  • #PMA0AUTOMATION_invalid_part_or_design if the Part object for source object Design @p dbom_source was not created because it is not a valid type. The supported type is Design.
  • #AOM_inst_read_protected if there is no read access or revision not configured on topline
  • #AOM_inst_write_protected if current logged in user have no write access on Engineering BOM Line.
  • Possibly other errors.
*/ extern PMA0AUTOMATION_API int PMA0_update_engineering_bom( tag_t dbom_source, /**< (I) Top BOMLine of design BOM structure.*/ tag_t* ebom_updated_target /**< (O) Top BOMLine in updated engineering BOM structure*/ ); /** Updates the design BOM structure linked to the engineering BOM structure starting from a given engineering top line.
The design structure is updated as per the default action specified on the engineering BOMLine property @c pma0UpdateAction. @note The following preferences must be appropriately set prior to calling this ITK:
  • @c Pma0_DBOM_Prefix_Suffix
  • @c Pma0_EBOM_skip_node_conditions
  • @c Pma0_EBOM_skip_occurrence_conditions
  • @c Pma0_Part_Design_Type
  • @c Pma0_EBOMRoot_DBOMRoot_Type
@returns
  • #ITK_ok on success
  • #PF_INVALID if value provided for the preference @c Pma0_DBOM_Prefix_Suffix, @c Pma0_DBOM_skip_node_conditions, @c Pma0_Part_Design_Type, @c Pma0_EBOMRoot_DBOMRoot_Type, @c Pma0_ChildItemType_RevOccType is invalid.
  • #PMA0AUTOMATION_input_root_skipped if the Design BOM structure cannot be updated for the input @p ebom_source, because it is configured to be skipped (through preference @c Pma0_skip_node_conditions) and it does not contain any unskipped parent.
  • #PMA0AUTOMATION_no_item_rev if the Engineering BOM top line is unconfigured.
  • #PMA0AUTOMATION_invalid_part_or_design if the Design object for source object Part @p dbom_source was not created because it is not a valid type. The supported type is Part.
  • #AOM_inst_read_protected if there is no read access or revision not configured on topline
  • #AOM_inst_write_protected if current logged in user have no write access on Design BOM Line.
  • Possibly other errors.
*/ extern PMA0AUTOMATION_API int PMA0_update_design_bom( tag_t ebom_source, /**< (I) Top BOMLine of engineering BOM structure.*/ tag_t* dbom_updated_target /**< (O) Top BOMLine in updated design BOM structure*/ ); #ifdef __cplusplus } #endif /** @} */ #include #endif #pragma once