Monday 29 October 2018

Understand Loops in BI Publisher: for-each vs for-each-group vs for-each: current-group




xml grouping

SUPPLIERS
INVOICES

Required:
SUPPLIERS
CURRENCY
INVOICES

‘for-each-group’ to regroup to show the invoices by currenc, [<?for-each-group:G_INVOICE_NUM;INVOICE_CURRENCY_CODE?>]

  • This is specifying that we want to create a new group ‘INVOICE_CURRENCY_CODE’ based on the original ‘G_INVOICE_NUM’ group.
  • We now have ‘for-each:current-group()’  to refer to the new INVOICE_CURRENCY_CODE group we have just created.
  • Note: we cannot refer to the group as INVOICE_CURRENCY_CODE as this group is only created at runtime.
  • sum (current-group()/ENT_AMT) for the entered amount, again we use the current-group() tag to refer to the new ‘INVOICE_CURRENCY_CODE’ group.

I



<?for-each:G_VENDOR_NAME?>


<?for-each-group:G_INVOICE_NUM;INVOICE_CURRENCY_CODE?>
Currency: USD
Invoice Number
Type
Invoice Date
GL Date
Entered Amount
Accounted Amount
<?for-each:current-group()?>
<?INVOICE_NUM?>
<?INV_TYPE?>
<?INVOICE_DATE?>
<?GL_DATE?>
<?ENT_AMT?>
<?ACCTD_AMT?>
<?end for-each?>

Total for <?INVOICE_CURRENCY_CODE?>
<? sum(current-group()/ENT_AMT)?>
<?format-number(sum(current-group()/ACCTD_AMT),"#,###.00","Euro")?>
<?end for-each-group?>


<?split-by-page-break:?>

<?end for-each?>



-------------
Output
-------------




Currency: EUR
Invoice Number
Type
Invoice Date
GL Date
Entered Amount
Accounted Amount
981110
Standard
10-NOV-07
10-NOV-07
122
122


Total for EUR
122
122.00
Currency: FIM
Invoice Number
Type
Invoice Date
GL Date
Entered Amount
Accounted Amount
100000
Standard
28-MAY-07
28-MAY-07
122
20.33

100001
Standard
28-MAY-07
28-MAY-07
200
33.33

1
Standard
03-JUN-07
03-JUN-07
400
66.67

100004
Standard
28-MAY-07
28-MAY-07
100
16.67

00s
Standard
07-JUN-07
07-JUN-07
100
16.67

FI1009
Standard
10-MAY-07
10-MAY-07
1220
203.33


Total for FIM
2142
357.00

No comments:

Post a Comment