IBM Sterling Transformation Extender

Sterling Transformation Extender

Come for answers, stay for best practices. All we're missing is you.


#Sterling
#Supplychain
 View Only
Expand all | Collapse all

RUN function and deserilization

  • 1.  RUN function and deserilization

    Posted 09/30/09 05:56 AM

    Originally posted by: SystemAdmin


    Hi All,
    I have tried to use RUN function to parse text string like this

    TYPE/TRSA/NAME/SOME NAME/NUMB/25/DATE/20040914TYPE/AGTC/NAME/SOME NAME2/NUMB/25/DATE/20040914

    to the XML structure

    <contractList>
    <contract>
    <type>TRSA</type>
    <name>SOME NAME</name>
    <num>25</num>
    <date>2004-09-14</date>
    </contract>
    <contract>
    <type>AGTC</type>
    <name>SOME NAME2</name>
    <num>25</num>
    <date>2004-09-14</date>
    </contract>
    </contractList>

    For that reason I have created 2 type trees representing "contractList" data structure: in the form of XML and in the form of separated text.
    I also realised executable map1 that transformes separated text to the XML document.

    But after that I have to use this map in a Map Rule in the other transformation map2. I wrote map rule like this:

    =RUN("TO_XML_CONTRACT_LIST", " -OE1" + ECHOIN(1, textContractList)

    The deal is that RUN function returns text string but I have to get contractList structure.
    Is it possible to deserialize text string to the appropriate data structure by the WTX?
    #IBMSterlingTransformationExtender
    #IBM-Websphere-Transformation-Extender
    #DataExchange


  • 2.  Re: RUN function and deserilization

    Posted 09/30/09 07:43 AM

    Originally posted by: SystemAdmin


    Even though RUN returns a text string, if you pass that text string as an input to a second executable map it will be treated as whatever type definition you give it in that second map.

    So, for your second executable map you would define the input card for your XML file using a TypeName of "Document XML". This would allow the fully typed data to be available in the second map.

    If this doesn't make sense, let me know and I'll provide a more detailed example.
    #IBMSterlingTransformationExtender
    #DataExchange
    #IBM-Websphere-Transformation-Extender


  • 3.  Re: RUN function and deserilization

    Posted 09/30/09 08:34 AM

    Originally posted by: SystemAdmin


    Thanks Mike.
    As I understand I can't use output of the RUN execution as an input for the functional map, am I right?
    #IBMSterlingTransformationExtender
    #IBM-Websphere-Transformation-Extender
    #DataExchange


  • 4.  Re: RUN function and deserilization

    Posted 09/30/09 09:18 AM

    Originally posted by: SystemAdmin


    You can use RUN output as input to a functional map, but remember that the RUN output will be a text string. This means that the functional map's input card would also have to be a text string.
    #DataExchange
    #IBM-Websphere-Transformation-Extender
    #IBMSterlingTransformationExtender


  • 5.  Re: RUN function and deserilization

    Posted 09/30/09 11:02 AM

    Originally posted by: SystemAdmin


    It means that I can't use RUN output as a structured data type in the current executable map from which RUN function invoked.
    It is the next stupid WTX feature I've found.
    Without external executable map I can't parse compicated text data,
    but when I create it I can't deal with RUN result. Excellent!
    We will open PMR.
    #DataExchange
    #IBMSterlingTransformationExtender
    #IBM-Websphere-Transformation-Extender


  • 6.  Re: RUN function and deserilization

    Posted 09/30/09 01:02 PM

    Originally posted by: Rich_McFate


    sanremo,

    It sounds like you're trying to embed XML into another structure. The RUN() function is the right way to do that, but your original target tree is probably incorrect.

    Let's say you're trying to do this:

    RecordA
    RecordB
    <embeddeded XML>
    RecordC

    You should define your original target tree like so:

    RecordA
    RecordB
    text_item
    RecordC

    When you call the Run() function for the text_item, you get back the XML structure you're looking for.

    What you don't want to do is start with this:

    RecordA
    RecordB
    XSD
    Element
    Element
    Element
    RecordC

    You're right. You can't put the RUN() function call at the XSD element and have it give you what you're looking for.

    The key is that whatever structure you're trying to create with RUN() needs to be removed from the original target tree and replaced with a simple text item.
    #IBMSterlingTransformationExtender
    #IBM-Websphere-Transformation-Extender
    #DataExchange


  • 7.  Re: RUN function and deserilization

    Posted 10/01/09 04:05 AM

    Originally posted by: SystemAdmin


    Rich, thanks a lot for your answer.
    We don't want to use embeded xml.
    The deal is that we have to parse complex text string and there is no enough possibilities to parse string data by the means of WTX functions (for example, there is no regular expression support, am I right?).

    TYPE/TRSA/NAME/some text/NUMB/25/DATE/20040914TYPE/AGTC/NAME/some text/NUMB/25/DATE/20040914

    should be converted to the data structure:

    <contractList>
    <contract>
    <type>TRSA</type>
    <name>some text</name>
    <num>25</num>
    <date>2004-09-14</date>
    </contract>
    <contract>
    <type>AGTC</type>
    <name>some text</name>
    <num>25</num>
    <date>2004-09-14</date>
    </contract>
    </contractList>

    And we don't know how to realise required cyclic text-processing with WTX functions.
    So we tried to do this with external map and additional type tree.
    Using text field in the initial type tree instead of structired data can be a good workaround but it's not a solution!
    And of course it will be inconvenient for our customers.
    #DataExchange
    #IBMSterlingTransformationExtender
    #IBM-Websphere-Transformation-Extender


  • 8.  Re: RUN function and deserilization

    Posted 09/30/09 11:22 AM

    Originally posted by: SystemAdmin


    As I mentioned earlier you can send the RUN output as an input to an executable map, where it can be deserialized. Without seeing the entire scope of what you are trying to do, it's hard to suggest other alternatives. For example, you may be able to use the REFORMAT function to accomplish what you want, if your text and XML type trees are organized properly.

    In WTX I've always been able to find or build the right function to do what was needed. It sounds like you are trying to use the RUN command like a hammer, where a wrench might work better.
    #IBMSterlingTransformationExtender
    #IBM-Websphere-Transformation-Extender
    #DataExchange


  • 9.  Re: RUN function and deserilization

    Posted 10/01/09 04:36 AM

    Originally posted by: SystemAdmin


    Mike, thank you for your attention.
    How we can use "RUN output as an input to an executable map"?
    Does it mean that we shoud invoke another RUN function?
    If I'm right it implies that "I can't use RUN output as a structured data type in the current executable map from which RUN function invoked." as I mentioned above.

    As concerns the REFORMAT function, we have tried to use it, but have failed (unfortunatly there are no examples in the infocenter).
    If you help us we will be very appreciated for your help.
    So we have:
    • text string (delimiter-separated format)
    • type tree 1 describing data in the text string
    • data structure in the type tree 2 describing the same data in the XML format
    • executable map where data text string located in the input card (is described by LMF type tree) and where output card is described by the type tree 2

    How we can use those artifacts and REFORMAT function to initialise data structure in the type tree 2 with the data from the text string?
    #IBM-Websphere-Transformation-Extender
    #DataExchange
    #IBMSterlingTransformationExtender


  • 10.  Re: RUN function and deserilization

    Posted 10/01/09 11:30 AM

    Originally posted by: SystemAdmin


    I'm still not exactly clear why you need to convert the original "contract" text to XML. But, assuming that you need to do that using the RUN function, here's what I would do based on what I understand from your earlier posts.

    (1) MAIN_MAP (executable map): This is the map you are currently working on. For this example I'm assuming you want it to have two inputs
    • Input 1: XML_Contract_List
    • Input 2: Other_Data
    • Output 1: Your_Reponse_File

    (2) TO_XML_CONTRACT_LIST (executable map): This is the map that converts your Text Contract List to your XML Contract List.
    • Input 1: Text_Contract_List
    • Output 1: XML_Contract_List

    (3) STUB_MAP (executable map): This is a new map that you will execute from the launcher, command line or script instead of "MAIN_MAP". This map will RUN "MAIN_MAP" and "TO_XML_CONTRACT_LIST". Its inputs and outputs are defined as simple text "blobs" of unlimited size.
    • Input 1: Text_Contract_List
    • Input 2: Other_Data
    • Output 1: Your_Response_File

    Here is the rule that you will enter in the Your_Response_File output card of STUB_MAP. It passes the RUN results for TO_XML_CONTRACT_LIST, and Other_Data to a functional map that will RUN "MAIN_MAP".

    =f_Run_Main_Map(
    RUN("TO_XML_CONTRACT_LIST", ECHOIN(1, Text_Contract_List) + " -OE1"),
    Other_Data
    )

    (4) f_Run_Main_Map (functional map): Here are the inputs/outputs for the functional map and the command that runs MAIN_MAP. Note that I've renamed Input 1 to reflect that it is now an XML text blob.
    • Input 1: XML_Contract_List
    • Input 2: Other_Data
    • Output 1: Your_Response_File

    = RUN("MAIN_MAP", ECHOIN(1, XML_Contract_List) + ECHOIN(2, Other_Data) + " -OE1")

    I generally use some variation of STUB_MAP for production maps. This allows me to pre-process the input data when there are customer specific variations or other data that needs to be converted as you have in your example, It also gives me a place to process errors returned by the MAIN_MAP.

    Final comment: I realize that these are an extra few steps that in an ideal software tool shouldn't be necessary, but they only take about five minutes to create a stub map. If I have the option, I would prefer to adjust the type tree definitions to simplify the mapping rules but that is not always possible. I don't know of any ideal software tools. They all have their quirks that you learn to deal with so that you can complete one project and move on to the next one.
    #IBM-Websphere-Transformation-Extender
    #IBMSterlingTransformationExtender
    #DataExchange


  • 11.  Re: RUN function and deserilization

    Posted 10/01/09 09:33 AM

    Originally posted by: Rich_McFate


    I guess I still don't understand the problem. Transforming that text string into that XML is not difficult in executable mapping rules.

    I'm not clear on why you need the Run() function at all.
    #IBM-Websphere-Transformation-Extender
    #DataExchange
    #IBMSterlingTransformationExtender


  • 12.  Re: RUN function and deserilization

    Posted 10/01/09 10:48 AM

    Originally posted by: SystemAdmin


    Rich, Am I right that WTX doesn't provide ability
    1) to realize cyclic processing in the Map Rule
    2) to use regular expressions
    3) to use temporary variables in the Map Rule

    If so, it's not possible to parse that text string to the approapriate xml-format.
    #IBM-Websphere-Transformation-Extender
    #IBMSterlingTransformationExtender
    #DataExchange


  • 13.  Re: RUN function and deserilization

    Posted 10/01/09 11:58 AM

    Originally posted by: Rich_McFate


    "Rich, Am I right that WTX doesn't provide ability
    1) to realize cyclic processing in the Map Rule
    2) to use regular expressions
    3) to use temporary variables in the Map Rule"

    If I understand your scenario, you don't need any of the above to do what you're trying to do.

    My underlying assumption here is that the target card is either pointing to an .XSD, or to at tree that was imported from an .XSD. If that is not accurate, then what follows is not relevant and I would need you to give me a better description of what the target is.

    I see two possibilities:

    1. -- that the text string is described in the source tree as a delimited group.

    1.a -- the delimited group is a list of named components. In this case, you simply drag the source omponents into the XML target elements. No further parsing is necessary.

    1.b -- the delimited group contains a single text_item (1:s). In this case, you may index the source into your target XML. e.g. type = text_item[2]:Record:.:File. No further parsing is necessary.

    1.c -- the delimited group consists of name-value pairs with no reliable sequencing. In this case, the record should have a group component e.g. VALUE_PAIR (1:s), which in turn has two text item conponents: Name and Value. You create the XML thusly: type = Lookup(Value:.:File where Name:.:File = "TYPE"). This is my best guess as to the real situation. It simply means you haven't defined the data in your Type Tree in such a way as to make the best use of WTX's parsing capabilities.

    2. -- that your record is presented as a single text item embedded in a larger structure.

    You can use the WTX Word() function to extract the data from a specific location in the string.

    In any case, I am confident the problem has a solution without cyclic processing (not a term I'm familiar with) regular expressions, or temporary variables.
    #DataExchange
    #IBMSterlingTransformationExtender
    #IBM-Websphere-Transformation-Extender