In this section: |
iWay Trading Partner Manager (iTPM) runtime functions allows users to retrieve the information from the iTPM repository via standard iWay runtime functions. For every iTPM runtime function there is corresponding custom function.
iTPM functions can be used as custom functions as well as runtime functions. Even though this section only describes runtime functions, this information is also applicable for custom functions.
Before continuing, validate the iSM installation. Runtime functions are installed during the iTPM installation (when the iwxtpm.jar file is copied to the etc\manager\extensions directory).
To check if runtime functions are installed properly navigate to the iSM command prompt and type funcs. A list of all the runtime functions, along with iSM runtime functions, is displayed.
iTPM runtime functions include _TPA, _TPAW, _TPID, _TPN, _TPP, _TPR, _TPS, and _TPT, which should be present in the list. The following sections provide details for each iTPM runtime function.
Note: iTPM runtime functions are overloaded, which means that the same function parameter can take ++ or a value. As a result, use caution when executing these functions.
The TPA function can be used to retrieve data for a domain from the iTPM repository. To better understand the TPA function, an understanding of iTPM schema and the relationship between various iTPM domains like partner, system, partnersystem, messagetype, and messageformat, is required. Domains are mapped directly to the database table.
Partner and system are related via partnersystem.
Partner and message are related via partner <--> partnersystem <--> partnersystemmessages <--> messsagetype.
Businessroute and partner are related via Businessroute <--> businesschannel <--> partner. Since Businesschannel can be incoming and outgoing so businessroute has two columns idBusinessChannelFrom and idBusinessChannelTo to map the incoming and outgoing data.
Having set the context for the relationship, consider the following use cases:
For a given partner (idPartner = 97) users need to know the associate system name (refer schema, system table has name column). Users can create the following TPA function:
_TPA(97,/partner/partnersystem/system,’name’,’default’)
For a given partner (idPartner = 97) users need to know the associate partner name (refer schema, partner table has name column). Users can create the following TPA function:
_TPA(97,/partner,’name’,’default’)
For a given partner (idPartner = 97) users need to know the contactName (refer schema, contact table has contactName column). Users can create the following TPA function:
_TPA(1,'/partner/contact','contactname','default’)
For a given businessroute (idBusinessRoute =1) users need to know the partnersystem name (refer schema, partnersystem table has name column) which is used for handling incoming messages. Users can create the following TPA function:
_TPA(1, '/BusinessRoute/BusinessChannelTo/PartnerSystem', ‘Name’, ‘no data found’)
Since the context here is outgoing, specify BusinessChannelTo. For incoming, use BusinessChannelFrom.
Another complex example is to know the messageformat name for an incoming channel for a given businessroute. Users can create the following TPA functions:
_TPA('1','/BusinessRoute/businesschannelfrom/partnersystemmessages/mess agetype/messageformat','Name','none found')
Users are putting partnersystemmessages and messagetype in the relationship because messageformat and businesschannel are not directly related as shown in the schema, but are related via partnersystemmessages and messagetype.
The TPA function can not only be used for accessing the direct column name specified in the schema but also the column name associated via metadata.
For a given partner (idPartner = 97) users need to know the associate system URL (refer schema, system table has no URL column) created via metadata and assigned a value. Users can create the following TPA function:
_TPA(97,/partner/partnersystem/system,’URL’,’default’)
For a given partner (idPartner = 97) users need to know the associate partner Region (refer schema, partner table has no Region column) created via metadata and assigned a value. Users can create the following TPA function:
_TPA(97,/partner, ‘Region’,’default’)
For a given businessroute (idBusinessRoute = 1) users need to know the partnersystem subdomain (refer schema, partnersystem table has no subdomain column) created via metadata and assigned a value which is used for handling incoming messages. Users can create the following TPA function:
_TPA(1, ‘/BusinessRoute/BusinessChannelTo/PartnerSystem’, ‘subdomain’,‘no data found’)
Also while running TPA function using the testfuncs tool, the TPA function displays the SQL that is being executed, which should help during debugging.
iTPM functions have the ability to take SQL conditions directly in runtime and custom function arguments. These SQL statements are appended directly to the SQL statement prepared for the runtime functions. For example:
_TPA(“and Description = \'112\' and Description = \'123 \'”, ”\BusinessRoute”, “Name”, “none found”)
For this SQL statement will have “and Description ='112' and Description ='123 '” appended to the SQL which in this case is:
select Name from BusinessRoute where 1 = 1 and Description ='112' and Description ='123 '
_TPA(“and Domainvalue =\'system 1\'”, ”\System”, “sap_client”, “default”)
For this SQL statement will have “and Domainvalue=\'system 1\'” appended to the SQL, which in this case will be:
select tp.DomainValue from TPAValue tp where 1 = 1 and tp.DomainCode='sap_client' and tp.DomainType= 'System' and Domainvalue='system 1'
_TPA(“and Name=\'system 1\'”, ”/System”, “sap_client”, “default”)
For this runtime function SQL statement will have “and Name=\'system 1\'”, ”/System” appended to the SQL statement, resulting in following SQL statement:
select tp.DomainValue from TPAValue tp where 1 = 1 and tp.DomainCode='sap_client' and tp.DomainType= 'System' and Name='system 1'
Since column name 'Name' does not exist for the TPAValue table, the following error will be returned:
Error while executing SQL [ select tp.DomainValue from TPAValue tp where 1 = 1 and tp.DomainCode='sap_client' and tp.DomainType= 'System' and Name='system 1'] : java.sql.SQLException: Invalid column name 'Name'.
This provides another powerful tool to the user for accessing the data.
Please note that the apostrophe character (') needs to be escaped as that is a special character in runtime functions.
In the event that TPA functions are retrieving values via SREGS, then the _CONCAT runtime function can be used to create the where clause string, which gets attached to the SQL statement. For example:
_tpa(_CONCAT(' and idpartner=2 and MEssagetype.Name = ',SREG(EDIMsgtype),' and MEssagetype.format_Name = ',SREG(EDIVers)) , /messagetype/businesschannelfrom/partnersystem/partner/partnersystemmessa ges/,'/PFlow','ddd' )
Full backward compatibility is maintained. As a result, _TPA(97,/partner, ‘Region’,’default’) will work without any change.
The TPAW function is used to check a domain code and update it with the passed value if it is found. This function can also be used to increment or decrement the values, which is useful when creating a new control number. The TPAW function works the same as the TPA function with the exception that if a domain code is found, then it is incremented. If the data is not incremented, then the string “TPAW, Data not updated” is returned. Otherwise, the updated value is returned.
domainId
domain
domainCode
Operator (++ and -- or new Domain Value)
For example:
_TPAW(1,'system','controlnumber','++')
This example will increment the controlnumber by 1 in case it is found and will return the incremented value. In the event that the incremented value is not a number, then it will throw an exception and will return the exception.
Note: Use caution while passing the values. Passing the wrong values could make the system unstable.
For example:
The TPAW function has the following signature:
_TPAW(domainId, domain, domainCode, Operator)
The TPID function returns the unique ID for the table based on a column name and the value that is passed. The return value can then be used in conjunction with other runtime functions. This function accepts four parameters and returns a unique table ID:
For example _TPID('system','Name','HL7_K346') returns systemid from the system table where Name = 'HL7_K346'.
Note: The WhereClause parameter is optional and is used to specify the where clause, which can be any of the following:
This function can be used in conjunction with other runtime functions (for example, TPA function).
For example:
_TPA(_TPID('system','Name','HL7_K346'),'/system','AdapterTarget','Q_Defau lt')
The TPA function returns the AdapterTarget value from a system table where systemid = _TPID('system','Name','HL7_K346').
The TPID function has the following signature:
_TPID(Domain, DomainProperty, DomainValue, DomainWhereClause)
The TPN runtime function returns a trading partner name that is defined in a particular domain. This function accepts two parameters:
For example executing _TPN('403815327','DUNS') will return a trading partner name where domain code = 'DUNS' and Domain ID = '403815327'. Running this function will execute the following underlying SQL:
SELECT DISTINCT Partner.Name FROM Partner, BusinessChannel, BusinessRoute, partnercodesub WHERE Partner.idPartner = BusinessChannel.partner_idpartner
AND ((BusinessChannel.idBusinessChannel = BusinessRoute.idBusinessChannelFrom AND partnercodesub.FromDomain = 'DUNS'
AND partnercodesub.FromCode = 403815327) OR ((BusinessChannel.idBusinessChannel = BusinessRoute.idBusinessChannelTo
AND partnercodesub.ToDomain = 'DUNS' AND partnercodesub.ToCode = 403815327)))
AND BusinessRoute.idBusinessRoute = partnercodesub.BusinessRoute_idTradeRoute
Note that the TPN value is acquired from the incoming businesschannel as well as the outgoing businesschannel.
The usage for the TPN function is:
_TPN(Domain, Domain Value)
The TPP function is used to access any attribute (column) from a partner table (domain). It accepts four parameters:
PartenerName
AttributeName
Default value for no data
Default Value
The fourth value is currently the default value that is returned. However, it is reserved for future use.
For example:
_TPP('walmart','buname','Default','No Data Found')
This example returns the attribute buname from a partner where partnername is walmart. In case ‘walmart’ is found but buname attribute is empty, 'Default' is returned. In the event that 'walmart' is not found, then the TPP function will return the “NO_DATA_FOUND” string.
The TPP function has the following signature:
_TPP(PartnerName, AttributeName, Default Value for no data, Default Value)
The TPR function returns trading partner routes for a given message type and is useful in determining where to send the messages based on the message type, domain, or code. The TPR function accepts five parameters:
messagetype
fromDomain
fromCode
toDomain
toCode
Apart from the messagetype parameter, passing empty values to the TPR function will cause this function to ignore that value and create a result set based on the values that are passed. The messagetype parameter becomes the mandatory parameter and the remaining parameters are all optional. The TPR function can return multiple values and data is returned in XML format.
For example:
Executing _TPR('ProductCatalogUpdate',,'5790000243433', , '5790001669133') returns:
<TPR><FROM><DOMAIN></DOMAIN><CODE>5790000243433</CODE></FROM><TO><DOMA IN></DOMAIN><CODE>5790001669133</CODE><MESSAGETYPE>ProductCatalogUpdat e</MESSAGETYPE><ROUTEID>2103</ROUTEID><SYSTEMID>1472</SYSTEMID></TO></ TPR>
Executing _TPR('DemandForecast','ZVMI','DCR_010', 'ZVMI', '02200650')returns:
<TPR> <FROM><DOMAIN>ZVMI</DOMAIN><CODE>DCR_010</CODE></FROM><TO><DOMAIN>ZVMI </DOMAIN><CODE>02200650</CODE><MESSAGETYPE>DemandForecast</MESSAGETYPE ><ROUTEID>208</ROUTEID><SYSTEMID>24</SYSTEMID></TO><TO><DOMAIN>ZVMI</D OMAIN><CODE>02200650</CODE><MESSAGETYPE>DemandForecast</MESSAGETYPE><R OUTEID>210</ROUTEID><SYSTEMID>87</SYSTEMID></TO></TPR>
Executing _TPR('Invoice',,'5790000243433',, '5790001669133') returns:
<TPR><FROM><DOMAIN></DOMAIN><CODE>5790000243433</CODE></FROM><TO><DOMA IN></DOMAIN><CODE>5790001669133</CODE><MESSAGETYPE>Invoice</MESSAGETYP E><ROUTEID>2100</ROUTEID><SYSTEMID>1472</SYSTEMID></TO></ TPR>
It is expected that the process flow calling the TPR function will take the output XML and iterate over it to get the correct ROUTEID and send the messages accordingly to these ROUTEID instances.
The TPR function has the following signature:
_TPR(messagetype, fromDomain, fromCode, toDomain ,toCode)
The TPS function returns substitution codes for the given BusinessRoute and partnercodesub. Code substitutions in iTPM are related to translations at the partnersytem level.
The TPS function accepts six parameters. The first parameter (SubstitionValueName) should be one of the following values to determine which substitution value to return:
SUBSTFROMCODE: Pass this in case substitution from code is needed.
SUBSTFROMDOMAIN: Pass this in case substitution from domain is needed.
SUBSTTOCODE: Pass this in case substitution to code is needed.
SUBSTTODOMAIN: Pass this in case substitution to domain is needed.
The remaining parameters are:
RouteID
FromDomain
FromCode
ToDomain
ToCode
For example:
_TPS('SUBSTFROMCODE',1,'DUNS',403815327,'Buyer',0000100075) returns the substituted From Code where routeid = 1 and fromdomain = 'DUNS' and fromcode = '403815327' and toDomain = 'Buyer' and toCode = '0000100075'
Substitution is done based on the lookup performed in the partnercodesub table.
In the event that no substitution is found, then the “NO_DATA_FOUND” string is returned.
The TPS function has the following signature:
_TPS(SubstitionValueName, RouteID, FromDomain, FromCode, ToDomain, ToCode)
The TPT runtime function provides a mechanism for retrieving code substitution values from one message format to another. This should not be confused with Partner Code substitutions that are obtained using the TPS function. TPT code substitutions are purely for message level translations (for example, the MeasurementValue field for Partner A is KG while Partner B expects LBS).
The TPT function accepts four parameters:
formatname
formatfrom
formatto
code
The TPT function has the following signature:
_TPT(formatname,formatfrom,formatto,code)
If a substitution is found the function returns the substituted value, else it returns the passed value.
The following SQL statement is run within the application function logic:
select SubstCode from codesubstitution where name=#formatname# and StandardFrom=(select idStandard from standard where Name = #formatFrom# ) and StandardTo=(select idStandard from standard where Name = #formatTo# ) and Code=#code#
In addition, the application function logic checks if substcode is null or not. If substcode is null, then #code# is returned.
This section describes how to configure iTPM custom functions using iWay Transformer.
iwayhome\etc\manager\extensions
iwayhome\tools\transformer\custom_functions
A new subdirectory (com) is added:
iwayhome\tools\transformer\custom_functions\com
iwayhome\tools\transformer\bin
cls
set tpm_dbdriver=com.mysql.jdbc.Driver
set tpm_dbpassword=root
set tpm_dbusername=root
set tpm_dburl=jdbc:mysql://localhost/tpm
set IWAY60=E:\iway60
set path=%IWAY60%\bin;%PATH%
java -version
set CLASSPATH=%IWAY60%\lib\iway60.jar;%IWAY60%\lib\iwutil.jar;%IWAY60S M%\lib\iwtransw.jar;%IWAY60%\lib\iwtranse.jar;%IWAY60%\lib\j2ee.ja r
set CLASSPATH=%CLASSPATH%;%IWAY60%\lib\commons-dbcp-1.2.2.jar;%IWAY60% \lib\spring.jar
set CLASSPATH=%CLASSPATH%;%IWAY60%\lib\commons-pool-1.3.jar
set CLASSPATH=%CLASSPATH%;%IWAY60%\lib\ibatis-2.3.0.677.jar;
set CLASSPATH=%CLASSPATH%;%IWAY60%\lib\jtds 1.2.2.jar
set CLASSPATH=%CLASSPATH%;%IWAY60%\lib\iwcore.jar
set CLASSPATH=%CLASSPATH%;%IWAY60%\lib\iwrepository.jar
set CLASSPATH=%CLASSPATH%;%IWAY60%\lib\iwaf.jar
set CLASSPATH=%CLASSPATH%;%IWAY60%\lib\iwafcont.jar
set CLASSPATH=%CLASSPATH%;%IWAY60%\lib\iwafjca.jar
set CLASSPATH=%CLASSPATH%;%IWAY60%\lib\iwutil.jar;
set CLASSPATH=%CLASSPATH%;%IWAY60%\lib\iwtranse.jar;
set CLASSPATH=%CLASSPATH%;%IWAY60%\lib\mysql-connector-java-3.1.13-bin.j ar
java -Dtpm_debug=true -Dtpm_dbdriver=%tpm_dbdriver% Dtpm_dbusername=%tpm_dbusername% -Dtpm_dbpassword=%tpm_dbpassword% -Dtpm_dburl=%tpm_dburl% -DIWAY60=%IWAY60% -cp %IWAY60%\tools\transformer\custom_functions;%CLASSPATH% com.iwaysoftware.transform.workbench.IxteWorkbench
tpm_dbdriver
tpm_dbpassword
tpm_dbusername
tpm_dburl
IWAY60
iwayhome\tools\transformer\custom_functions\com\ibi\tpm\customfunction
Note: Once all the custom functions are defined, they can be imported as template. For more information, see the iWay Transformer User's Guide.
Debugging iTPM runtime functions can be difficult if you are debugging directly from the process flow or other iSM components. As a best practice, it is recommended to first use iTPM runtime functions directly from the iSM command prompt. This requires access to the iSM command prompt. If iSM is running on a remote machine, then remote access to that machine is also required.
To debug runtime functions:
The iwayhome directory must contain iway60.cmd or ./iway60.sh, depending on which platform you are using.
Once started, the terminal window displays the following prompt:
Note: If the Enter command:> prompt does not display, press Enter after iSM is started.
Note: XML files are required to execute runtime functions.
<?xml version="1.0" encoding="UTF-8"?><noop/> located at C:\test.xml
tool testfuncs C:\test.xml
The funcs - > prompt displays, which allows you to execute iTPM runtime functions.
For example:
_tpid("PARTNER","ftpport","90","geq”)
This will produce output with the last line reading <tpids><tpid>1</tpid><tpid>2</tpid><tpid>3</tpid></tpids>, as shown in the following image.
Note: The SQL statement is executed with the iTPM runtime function along with the other debug statements.
iWay Software |