IBM webMethods Hybrid Integration

IBM webMethods Hybrid Integration

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.


#TechXchangePresenter
 View Only
Expand all | Collapse all

documentList HELP

  • 1.  documentList HELP

    Posted Wed April 04, 2007 07:53 PM

    I need some help from the wM Experts as I am stuck on this!!! :slight_smile:

    I got the following:

    -ListFileinDirectory
    –LOOP /filenameList (go over every file in dir)
    —getFile
    —converToValues
    —CloseStream
    —LOOP /FileRecord/Record1
    ----MAP (loads Document List from Record1)
    —SQLBatchInsert (adapter services inserts data into Oracle)

    Somehow I need to create a document list of 5,000 records at a time so the BatchInsert will do SQL insert of only 5,000 records at a time. So for example. If Record1 LOOP will have 10,000 I need to split that into 2. So the loop will load the document list with first 5,000 records then do the insert then go back and load the document list with remaining 5,000 records out of the initial 10,000.

    Thanks!!
    SMS


    #webMethods
    #Integration-Server-and-ESB
    #Flow-and-Java-services


  • 2.  RE: documentList HELP

    Posted Wed April 04, 2007 08:36 PM

    I recommend using modulo to do the split.

    Create a few variables in your pipeline:
    maxPerBatch = 5000
    currentCount = 0

    When in your loop increment currentCount by one.

    Do a branch that checks for currentCount % maxPerBatch == 0
    (that is, currentCount modulo maxPerBatch equals 0)

    If true branch out and do your batch insert.

    Oh, also you need to handle the situation where the last batch is less than 5000 but still needs to be inserted. Another branch or a branch after your loop should do the trick which activates only if the last batch size is > 0.

    Make sense?

    P.S. Modulo is easy in java: n % m is about all it takes.


    #webMethods
    #Flow-and-Java-services
    #Integration-Server-and-ESB


  • 3.  RE: documentList HELP

    Posted Wed April 04, 2007 08:48 PM

    Kind of lost here… Could you kindly please walk me step by step in the flow?

    S


    #Flow-and-Java-services
    #Integration-Server-and-ESB
    #webMethods


  • 4.  RE: documentList HELP

    Posted Wed April 04, 2007 09:18 PM

    Sure. I am including a sample SW_Samples.zip that shows a simple example of this type of functionality without using any java services. Instead i added a few extra variables:

    currentBatchCount and nextBatchCount to allow me to use the divideints builtin service to simulate modulo.

    If you step through the code (put some values into the array - particularly put more than three values in) so that you can see it execute the branch only when currentCount % maxBatchCount == 0 (sic - actually when currentBatchCount != nextBatchCount).

    !!!
    -greg
    SW_Samples.zip (6.12 KB)


    #webMethods
    #Flow-and-Java-services
    #Integration-Server-and-ESB


  • 5.  RE: documentList HELP

    Posted Wed April 04, 2007 11:28 PM

    Depending on your situation, you may want to look at similar solution but using java Svcs. You can pass your documentList with the maxPerBatch variable and it will output the broken up documentList.


    #webMethods
    #Flow-and-Java-services
    #Integration-Server-and-ESB


  • 6.  RE: documentList HELP

    Posted Thu April 05, 2007 04:20 PM

    Greg, This is exacly what I needed!!! … Thank You for the Help!!


    #webMethods
    #Integration-Server-and-ESB
    #Flow-and-Java-services


  • 7.  RE: documentList HELP

    Posted Thu April 05, 2007 06:17 PM


  • 8.  RE: documentList HELP

    Posted Thu April 12, 2007 05:17 PM

    Greg,

    I added two things to the flow where XX are

    –MAP
    –LOOP
    —MAP
    —MAP
    —pub.list:appendToStringList (create inputLoad string list) XX
    —BRANCH
    ----SEQ %currentBatchCount% != %nextBatchCount
    ----MAP (Batch achieved do BatchInsertSQL from inputLoad)
    ----MAP (drop inputLoad) XX
    —SEQ $default
    ----MAP (do nothing no batch yet)
    —MAP
    –SEQ (do partial batch here)

    Everytime it LOOPs a single value is passed in “inputs” and I need to take that value and store in the stringList (inputLoad) so when the Batch is acchived I can take that inputLoad and the the BatchInsertSQL. For some reason when I use the appeneToStringList trans the list is not being build. I am only getting single value in the inputLoad and when the LOOP loops again it passes the new value overwritting the previouse one instead of appending. Would you have any idea why?

    Thanks,
    SMS


    #Integration-Server-and-ESB
    #webMethods
    #Flow-and-Java-services


  • 9.  RE: documentList HELP

    Posted Thu April 12, 2007 07:25 PM

    Ok, I got it. I linked items backwords.


    #webMethods
    #Flow-and-Java-services
    #Integration-Server-and-ESB