Skip to Content
avatar image
Former Member

Total Count of records of Target structure in XSLT

Hi,

Am new to the XSLT coding.

Could you please help me in providing the code for the total count of the records and the sum of the values of a field for the Target structure at the trailer.

I have provided the target structure and my source is Idoc.

In my scenario the Records are generated based on the Field - RecID.And am going to provide the constant values as shown in the structure

Which parameters i have to use to access the Target structure

Occurrence of Header and Trailer is 1 and the occurrence of Details are unbounded.

Header

Rec0

Details

Rec1

RecID = 1

Amount

Field2

Rec2

RecID = 2

Field3

Field4

Trailer

Count of Records - Count(RecID)

Total Sum of field (Amount) - sum(Amount)

Thanks & Records

Balu

Add comment
10|10000 characters needed characters exceeded

  • Follow
  • Get RSS Feed

2 Answers

  • avatar image
    Former Member
    Mar 04, 2013 at 09:22 AM

    Hi,

    You must be mapping some element in input file to generate RecId and Amount. You can use the same fields with functions count and sum.

    Regards,

    Beena

    Add comment
    10|10000 characters needed characters exceeded

    • Former Member

      Hi Beena,

      But for the RecID am giving the constants as mentioned above.

      I have tried with many options in the coding..it doesn't gone well.

      so, i have seeked ur help.

      thanks & regards,

      Balu

  • avatar image
    Former Member
    Mar 04, 2013 at 09:24 AM

    Hi Balu ,

    Try this below code.

    for counting --- count(ns0:MessageType/RecordSet/Details/Rec1/RecID)

    for sum --- sum(ns0:MessageType/RecordSet/Details/Rec1/Amount)

    or

    sum(//Amount)

    Thanks,

    Dhileep

    Add comment
    10|10000 characters needed characters exceeded

    • Former Member Former Member

      Hi Beena,

      Thanks for ur reply

      For the RecID i am assigning the constant 1 & 2 for the Record1 & record2 respectively.

      and for the Amount field am getting from the source filed /Idoc/E1EDIKU2/MOABETR.

      At my target file the details records (for Eg : 1,2,1,2,1,2) can come n times and i have to count the records based on the RecID. Along with this the Amount has many input values and i have to sum up all those and have to provide at my trailer.

      Thanks & Regards,

      Balu