webMethods

webMethods

Join this online group to communicate across IBM product users and experts by sharing advice and best practices with peers and staying up to date regarding product enhancements.

 View Only
  • 1.  WMFlatFile converttostring

    Posted Fri May 07, 2021 12:18 PM

    I have been trawling through the forum and training but haven’t found an answer so far…
    I’m starting from a document with two types of records within and want to convert that to a csv format with two types of records.
    For argument’s sake, let’s say it’s a sales order (with some fields like salesordernumber, total price, shipping details,…) and within the sales order multiple sales line items (fields: sku number, unit price, quantity…).

    The required output is:
    OR1, salesordernumber, total price, address line, postcode
    OR2, salesordernumber, sku number1, unit price1, quantity1
    OR2, salesordernumber, sku number2, unit price2, quantity2

    A flatfile schema seems to indicate that you can have multiple record type definitions, which is what I like to think I need here.
    I gave it a go and it failed. I don’t know the inner workings of the wmflatfile:converttostring but I think it might not like the fact it has to loop over the line items.

    Do I need to do this in multiple steps to obtain the desired output? Any advice is welcome…


    #Integration-Server-and-ESB
    #webMethods


  • 2.  RE: WMFlatFile converttostring

    Posted Fri May 07, 2021 01:11 PM

    No you don’t, you can do it with a single call to convertToString. However, you need to make sure that in your ff schema that you have a record identifier that matches the repeating record elements in your document e.g.

    Make sure that the properties are set appropriately i.e. Ordered = false and Max Repeat = Unlimited.
    Also the reference in the document type must match the flat file record id i.e. OR1. Use the property “alternative name” If you want the record identifier in the file to be different to that in your document type.

    I have attached an example wm package for reference.

    JcScratch.zip (13.9 KB)


    #Integration-Server-and-ESB
    #webMethods


  • 3.  RE: WMFlatFile converttostring

    Posted Mon May 10, 2021 11:40 AM

    Thanks for that. I’ve just re-read my post and there’s one thing that I fear I haven’t conveyed. I’ve attached my example doc (created from a Json file I received).
    The main difference is that there’s a list of documents under the main document, and those will be OR2.

    MreyDoc.zip (3.6 KB)


    #Integration-Server-and-ESB
    #webMethods


  • 4.  RE: WMFlatFile converttostring

    Posted Tue May 11, 2021 04:47 AM

    I think I understand your problem now.
    You will need to first map the document that you received i.e. the one that you provided in your package to a document as defined by the flat file schema i.e. when you create your schema as I did, you will then have to click on the 'create document type" button shown in the toolbar

    You will then use a map prior to calling the convertToString to map your json deliveryRequest document to the ff document and then use that as the input to the convertToString service.
    regards,
    John.


    #Integration-Server-and-ESB
    #webMethods