Topic Options
#55481 - 11/14/17 10:43 AM Addition of XML variables together to get Total
symo68 Offline
OL Newbie

Registered: 08/19/15
Posts: 4
Loc: London/Edinburgh
Probably an easy fix for someone......

I have some XML data for use with printing totals etc, but the data is missing one vital total. I have been informed that this data is not going to the passed, and the only solution is to "add up" the rows to get the total. I have a field which repeats any number of times which needs adding up. I assume I would be using the add function......

The field that repeats is:

CFS_NET_PRICE_EXCL_TAX which can be found in the G_INVOICE_LINE_SUMMARY row (which can appear any number of times)

Here is the Planet Press talk where I hope to introduce the calculation (as I don't think I need to introduce a new loop, when this one should suffice)

&Sum_Max:=XmlCount('/XXRFGSCMINV[1]/LIST_G_INVOICE[1]/G_INVOICE['+inttostr(&actual_inv)+']/LIST_G_INVOICE_LINE_SUMMARY[1]/G_INVOICE_LINE_SUMMARY')
for(&actual_Sum, 1, 1, &Sum_Max)

=========> thought something could be introduced here...... global variable definition, store the value found in CFS_NET_PRICE_EXCL_TAX, and repeat, adding the next value found in CFS_NET_PRICE_EXCL_TAX until the loop is complete


&line_Max:=XmlCount('/XXRFGSCMINV[1]/LIST_G_INVOICE[1]/G_INVOICE['+inttostr(&actual_inv)+']/LIST_G_INVOICE_LINE_SUMMARY[1]/G_INVOICE_LINE_SUMMARY['+inttostr(&actual_Sum)+']/LIST_G_INVOICE_LINES[1]/G_INVOICE_LINES')
for(&actual_line, 1, 1, &line_Max)
execpage('Data_Page')
if(XmlGet('/XXRFGSCMINV[1]/LIST_G_GLOBAL_ATTRIBUTES[1]/G_GLOBAL_ATTRIBUTES[1]/ORGANIZATION[1]')='RESCM EDC-SIT OU and IO')
&translated_y:=&translated_y+0.32
elseif
&translated_y:=&translated_y+0.16
endif
endfor
endfor

So, my question is simple...

How can I, using the loop above, add together all occurrences of CFS_NET_PRICE_EXCL_TAX, and print them as a grand total.

Failing that, what is the easiest way of adding XML variables together using Planet Press talk to create a total which can be used somewhere else within the logic.

Any guidance would be appreciated

Thanks
Martyn

Top
#55485 - 11/15/17 07:45 AM Re: Addition of XML variables together to get Total [Re: symo68]
Hunt3r Offline
OL Newbie

Registered: 02/13/17
Posts: 11
Hi,

Without testing and seeing the XML file, I would say this:

Code:
&Sum_Max:=XmlCount('/XXRFGSCMINV[1]/LIST_G_INVOICE[1]/G_INVOICE['+inttostr(&actual_inv)+']/LIST_G_INVOICE_LINE_SUMMARY[1]/G_INVOICE_LINE_SUMMARY')

%reset global variable
&CFS_NET_PRICE_EXCL_TAX_SUM := 0
for(&actual_Sum, 1, 1, &Sum_Max)
        %defining a new variable is not necessary
        define(&actual_CFS_NET_PRICE_EXCL_TAX_SUM, integer, 0)

        %get data as int
        &actual_CFS_NET_PRICE_EXCL_TAX_SUM := strtoint(XmlGet('/XXRFGSCMINV[1]/LIST_G_INVOICE[1]/G_INVOICE['+inttostr(&actual_inv)+']/LIST_G_INVOICE_LINE_SUMMARY[1]/G_INVOICE_LINE_SUMMARY['+inttostr(&actual_Sum)+']'+'/CFS_NET_PRICE_EXCL_TAX[1]'))

        %adding to global variable
        &CFS_NET_PRICE_EXCL_TAX_SUM := &CFS_NET_PRICE_EXCL_TAX_SUM + &actual_CFS_NET_PRICE_EXCL_TAX_SUM
        %...
endfor

%you can use the &CFS_NET_PRICE_EXCL_TAX_SUM anywhere

Top