cancel
Showing results for 
Search instead for 
Did you mean: 

Total Count of records of Target structure in XSLT

Former Member
0 Kudos

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

Accepted Solutions (0)

Answers (2)

Answers (2)

Former Member
0 Kudos

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

Former Member
0 Kudos

Hi Dhileep,

The structure i have given is the Target one.And are you sure that can we access by the using count and sum directly.

Former Member
0 Kudos

Balu...

Please can you provide the source and target structures, and share some more information about logic to generate the target structure.

Former Member
0 Kudos

Hi,

Can you please provide input xml and logic how you are generatiing recid and amount fields?

Regards,

Beena

Former Member
0 Kudos

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

Former Member
0 Kudos

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

Former Member
0 Kudos

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