display sum of amount with each record in target file

Last post 06-08-2012 9:08 AM by sudhakar.reddyinfo@gmail.com. 9 replies.
Page 1 of 1 (10 items)
Sort Posts: Previous Next
  • 05-31-2012 4:14 AM

    display sum of amount with each record in target file

    Hi,

    I have following data in source file.

    rno rname amount

    --- -------------- ------------

    1  s  2000

    2 d  3000

    3 a  4000

    But i need target file like this

    1   s   2000  9000

    2    d   3000  9000

    3    a   4000  9000

     

    Thanks in Advance.............

  • 06-05-2012 11:41 AM In reply to

    Re: display sum of amount with each record in target file

    You'll need to provide additional details if you want to get a better response. There's unfortunately not much to work on. Its looks like you might be working with an Ascii and need additional spaces between each record. Could you provide information on your Source and Target? Is this actual data from your target output?
  • 06-05-2012 11:08 PM In reply to

    Re: display sum of amount with each record in target file

    Hi,

    Thanks for your suggession.

    i have the source data(ASCII delimited) like follows.

     Record No  Account No  First Name    Payment

     1                 10019            Bobbi             100.00

     2                 10023           Bruce              120.00

     3                 10024           Bruce              125.00

     4                  10025          Butch              130.00

     5                  10026          Calla                135.00

    --------------------------------------------------------------------------------------

    In Target file (ASCII File) i need output as follows

     Record No  Account No  First Name    Payment     SumAmt

     1                 10019            Bobbi             100.00         610.00

     2                 10023           Bruce              120.00         610.00

     3                 10024           Bruce              125.00         610.00

     4                  10025          Butch              130.00         610.00

     5                  10026          Calla               135.00         610.00

    ------------------------------------------------------------------------------------------

    In target SumAmt filed displays a value is sum of Payment Field of all records(100+120+125+130+135=610).

     

    Thanks,

    Sudhakar

  • 06-06-2012 1:46 AM In reply to

    • Mr E
    • Top 100 Contributor
    • Joined on 03-25-2011
    • Posts 60

    Re: display sum of amount with each record in target file

    Process the file twice from a process? Once with a NULL output target that adds up the amounts and sets the process variable, the second time use that process variable in your last column.

  • 06-06-2012 6:19 AM In reply to

    Re: display sum of amount with each record in target file

    Hi,

     Thanks a lot for answer. I have one question. Is it possible on map designer? or should i use process designer? Please let me know.

     

    Thanks,

    Sudhakar.

  • 06-06-2012 8:45 AM In reply to

    • jdd
    • Top 25 Contributor
    • Joined on 04-04-2005
    • Posts 363

    Re: display sum of amount with each record in target file

    Could be done easily in a map. Just store the sum in a variable and the source fields in a djRowset. At the end (onEOF), write out all your records from the rowset.

    http://docs.pervasive.com/products/integration/di/wwhelp/wwhimpl/js/html/wwhelp.htm#href=rifl/DJRowSet_Object_Type.html

  • 06-06-2012 9:30 AM In reply to

    Re: display sum of amount with each record in target file

    There are many ways to do this. But all of them include making two passes over the data. This could be done in two maps. The First map aggregates all the data from "Payment" into a single variable lets call it pSumPayment. The Second Map will remap the data from the source to a new target that has a new field called sum payment. The target field expression for sum payment will always return the value in pSumPayment. You might also want to account for special cases such as null or zero as well.
  • 06-07-2012 3:50 AM In reply to

    Re: display sum of amount with each record in target file

    How can i write DJRowSet records to target file at EOF? The target file is ascii file.

  • 06-07-2012 8:14 AM In reply to

    • jdd
    • Top 25 Contributor
    • Joined on 04-04-2005
    • Posts 363

    Re: display sum of amount with each record in target file

     There is an onEOF event in the Source General event handlers. That's where you add your ClearMapPut action. Use the rowset.size in the count parameter of your ClearMapPut. Write something in the CounterVariable parameter like cntr. In your target field expression, to grab the first field in the rowset - your expression would be rowset.value(cntr,1).

  • 06-08-2012 9:08 AM In reply to

    Re: display sum of amount with each record in target file

    Hi,

     

    Thanks a lot.

Page 1 of 1 (10 items)