iWay Trading Partner Manager Runtime Functions

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.


Top of page

x
Installation

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.


Top of page

x
TPA Function

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.

  1. Partner and system are related via partnersystem.

  2. Partner and message are related via partner <--> partnersystem <--> partnersystemmessages <--> messsagetype.

  3. 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:

  1. 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’)
  2. 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’)
  3. 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’)
  4. 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:

  1. _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.

  2. 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’)
  3. 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’)
  4. 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:

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.


Top of page

x
TPAW Function

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.

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)

Top of page

x
TPID Function

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)

Top of page

x
TPN Function

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)

Top of page

x
TPP Function

The TPP function is used to access any attribute (column) from a partner table (domain). It accepts four parameters:

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)

Top of page

x
TPR Function

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:

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:

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)

Top of page

x
TPS Function

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:

  1. SUBSTFROMCODE: Pass this in case substitution from code is needed.

  2. SUBSTFROMDOMAIN: Pass this in case substitution from domain is needed.

  3. SUBSTTOCODE: Pass this in case substitution to code is needed.

  4. SUBSTTODOMAIN: Pass this in case substitution to domain is needed.

The remaining parameters are:

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)

Top of page

x
TPT Function

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:

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.


Top of page

x
Configuring iTPM Custom Functions Using iWay Transformer

This section describes how to configure iTPM custom functions using iWay Transformer.



x
Procedure: How to Configure iTPM Custom Functions Using iWay Transformer
  1. Ensure that iTPM is installed and configured properly.
  2. Navigate to the following directory and locate the iwtpm.jar file:
    iwayhome\etc\manager\extensions
  3. Unzip the iwtpm.jar file under the following directory:
    iwayhome\tools\transformer\custom_functions

    A new subdirectory (com) is added:

    iwayhome\tools\transformer\custom_functions\com
  4. Create a new file called runtransformer.bat under the following directory:
    iwayhome\tools\transformer\bin
  5. Copy the following syntax into the runtransformer.bat file:
    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
  6. Save the runtransformer.bat file.
  7. Ensure that the following parameters have the correct values:
    • tpm_dbdriver 
    • tpm_dbpassword
    • tpm_dbusername
    • tpm_dburl
    • IWAY60
  8. Start iWay Transformer using the runtransformer.bat file users just created.
  9. In the Project Properties dialog box, point to the correct custom functions that are present under the following directory:
    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.


Top of page

x
Debugging Runtime Functions

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.



x
Procedure: How to Debug Runtime Functions

To debug runtime functions:

  1. If iSM is running as a service, stop the service.
  2. Open a new terminal window (for example, a DOS prompt) and navigate to the iwayhome directory.

    The iwayhome directory must contain iway60.cmd or ./iway60.sh, depending on which platform you are using.

  3. Start iSM in the terminal window using iway60.cmd or ./iway60.sh.

    Once started, the terminal window displays the following prompt:

    Note: If the Enter command:> prompt does not display, press Enter after iSM is started.

  4. Type funcs to check if all the iTPM runtime functions are installed properly, as shown in the following image.

  5. Type SET DEEP on at the command prompt to enable the DEEP debug level and to view the complete runtime information.

    Note: XML files are required to execute runtime functions.

  6. Create a simple XML file using the following format:
    <?xml version="1.0" encoding="UTF-8"?><noop/>
    located at C:\test.xml 
  7. Type the following command to start the test tool:
    tool testfuncs C:\test.xml 

    The funcs - > prompt displays, which allows you to execute iTPM runtime functions.

  8. Enter the iTPM runtime function you want to check and press Enter.

    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