Showing posts with label JDE. Show all posts
Showing posts with label JDE. Show all posts

Monday, 31 March 2014

BI Publisher Sub templates and calling them conditionally

I had a few issues today that sent me off on an oddesy to learn about sub templates and how to use them . and now I've had a fiddle with them they have totally revised my approach to writing templates.  there really dead useful :).

 I'm working on one of our company invoices and  was having quite an unpleasant time trying to work out how the hell to make this template work . like every one else out there I should imagine our invoices can have  lots of different ways to display a line item and you can have any number of line items on a page how on earth was I going to cope with invoices that went over to more than one page ?????   this is the type of thing that on more than one ocasion has reduced me and Mike to sobbing wrecks and reaching for the poultry with one hand and the Whisky with the other when we tried to do this with transform

dead easy it turns out.

This where sub templates come in .  Sub templates are small templates in there own right that you can either store in another RTF document  or stick at the bottom of your template out of the way (which is what i did  in this case) 

My first issue was to make sure the header and footer on each page were there and displayed properly . I  had one header section which is displayed on every page  and 2 footers. one which is displayed on the last page  and one  on all the others . so I created these  as sub templates.  to do that i just wrapped them in <?Template:?> tags  like this 













then i just popped <?call-Template: PageHeadder?> in the  header of my word RTF Template. 

Next I tackled the footer issue by doing exactly the same I created 2 Templates  a page footer one and an last page footer one  then used a choose statement to choose which one to display in the footer  using a bit of code like this 

<?choose:?>
          <?when:PrintTax_ID5=“Y“?><?call:PageFooterWithTax?><?end when?>
           <?otherwise:?><?call:PageFooterNoTax?><?end otherwise?>
<?end choose?>


finally I created a sub template for each of the different line types i had  and used exactly the same technique to call the sub template for the line type i wanted to display .  yet again  no swearing sobbing or poultry bothering required 

Tuesday, 18 March 2014

BI Publisher Conditional Character Spacing on a Field

I have just come across an interesting issue  that took a little bit of brain scrambling to sort out.  I had a field that I had to display in two different ways 

 if the field was on the last page of my document I needed to display the date  with 2 spaces between each of the characters   a bit like 1  8  0  3  2  0  1  4

for any other page i had to display     "***VOID***" with normal spacing.

now id managed to get my if statement working fine  to display eather the date or void but the spacing issue became a major headache.

i tried all sorts of XSL_FO combinations to no avail  them a eureka moment .  I could add two fields . id use word to increase the character spacing on one field   and leave the second field with normal spacing.

in the absence of discovering a better way to do it all in one field (Hope fully some one more experienced can sugest that)  hers the code in my feilds  that i used to resolve the issue


word field formatted to double space the chars 
<?xdoxslt:ifelse(Current_stub_number___Local_ID46 !=  Stub_Total___Local_ID66, '' ,G_L_Date2___Local_ID64)?>


second word field formatted as normal 
<?xdoxslt:ifelse(Current_stub_number___Local_ID46 !=  Stub_Total___Local_ID66, ' * * * VOID * * * ' ,'')?>


to increase the spacing on the first field  clicking on the little arrow at the bottom of the font  ribbon brings up the following where you can  increase and decrease character spacing over a field paragraph etc etc in word


so eather the single spaced or the double spaced field is shown 

Extended Function Support in RTF templates BI Publisher

ok while hunting round the interwebz for a way of taking a date and turning it into a sub string a character at a time  (don't ask its a finance report thing  SHUDDER !)  I stumbled across this incredibly cool Oracle document  that shows loads of SQL , XSL, and FO elements and functions and how to do them in BI Publisher  well cool and extremely Useful  thank you Oracle   thank you Oracle Techno Pixies :)


extremely cool  and useful Linky

Friday, 14 March 2014

Using a Case statement in BI Publisher

This is really useful  and surprisingly easy   if you need to display multiple different pieces of information   on part of the document that depend on a value or values in  the XML  you can use a load of  "if"  or "if:else"  statements   but its much easier neater and more brain friendly to use a case statement like the following

where Company_ID199   is the tag in The tag in the XML that you want to make the decision based on


<?choose:?>
             <?when:Company_ID199=‘00040‘?>Test <?end when?>
             <?when:Company_ID199=‘00041‘?>Test 2<?end when?>
             <?otherwise:?> Test3<?end otherwise?> 
<?end choose?>

Wednesday, 12 March 2014

Conditional Sections In BI Publisher

One issue that was always a major headache for us with Transform was the Terms and Conditions pages which are attached to the end of all our sales documents .  when ever there was an update to the T&C's we would have to slog through each of the sales documents to see which copy of the T&C's it was calling and then do it all over again for the copies in french . Frustrating  as I'm sure you can imagine .

So to get around all that we decided to just have one T&C's document and add it as a second template to the report definitions . that way we only ever need to update one document . but we did have to build in some conditional logic to display the different sections of the T&C's in English and french.  to do that we used Conditional Regions.   these are great you rap a paragraph or a table  or what ever you fancy in some conditional code and it either displays or dosent depending on the logic in the conditional statement the following explains it really well and is shamelessly pilfered from some of the oracle documentation

11.4.5 Inserting and Editing Conditional Regions

A conditional region is an area that is surrounded by a conditional statement. If the statement tests true, the area is displayed in the report; if the condition tests false, the area is suppressed from the report.
For example, your data contains salary and position information for all employees. Your report contains a table that displays the employee, position, and salary. You want your report to display salary information for managers only. Using the insert conditional region functionality, you can select the region that contains the employee table and insert the condition that the position element must equal manager.
To insert a conditional region:

  1. Select the region that you want to apply the condition to. For example, if you want to display a table only for a certain condition, select the region that contains the table. Note that the region must be inside a loop.
  2. From the BI Publisher toolbar select Insert, then Conditional Region.
    The following figure shows the Conditional Region dialog:
    This image is an example of the Conditional Region dialog.
  3. Enter the following fields:
    • Data field - Select the field to test for the condition.
    • Select the data type of the field: Number or Date/Text.
    • Select the comparison operator for the data field. Options are:
      • Equal to
      • Not equal to
      • Greater than
      • Less than
      • Greater than or equal to
      • Less than or equal to
      • Enter the value to define the condition, or select from the list of data elements to define a conditional relationship based on the value of another data element.

Getting BI Publisher to print out multiple copies based on a value in the XML



I found a few pages with descriptions on how to do this but none were particularly clear so for the sake of my and Mikes Sanity ive made a simpler example using one of our reports 

 you put the whole template page inside a double for each loop like this  

the green highlighted bit is the full path to the xml field holding the number of copies  
(the +1 ive highlighted in yellow is in  there because the number of copies in the XML i was using  is set to zero its a number of ADDITIONAL copies field  hence the plus 1 :)  you wouldent normally need that bit   )  .  

and you need to add the second for each loop to say  go of and do everything on the report

<?for-each@section:xdoxslt:foreach_number($_XDOCTX,1,/R42530V/DETAIL_1_S4_Group/Total_1_S7/On_Ship_To_Connect_to_Level_Break_S5/NbrOfCopies_ID150 + 1,1)?> 

                 <?for-each:/R42530V?>
                         //  The rest of the Template goes in here //
                <?end for-each?>

<?end for-each?>

Storing Values in Variables in your BI Publisher Template

Mike came up against an interesting issue the other day . he needed to access a value in the XML output from JDE on a different page . the trouble was the value was blank on the second page.  after a bit of digging I came across this  code which lets you store values in the XSL on your RTF template as variables

/*initialize a variable*/
<?xdoxslt:set_variable($_XDOCTX, ‘counter’, 0)?> or  
<?xdoxslt:set_variable($_XDOCTX,‘test‘,“wibble")?> 

/*get a variable*/
<?xdoxslt:get_variable($_XDOCTX, ‘test’)?>   

/*update the variable’s value by adding the current value to MY_CNT, which is XML element */
<?xdoxslt:set_variable($_XDOCTX, ‘counter’, xdoxslt:get_variable($_XDOCTX, ‘counter’) + MY_CNT)?>

/* accessing the variables */
<?xdoxslt:get_variable($_XDOCTX, ‘counter’)?>

/*Working in a loop*/
<?xdoxslt:set_variable($_XDOCTX, ‘counter’, 0)?>
<?for-each:G1?>

/*increment the counter*/
<?xdoxslt:set_variable($_XDOCTX, ‘counter’, xdoxslt:get_variable($_XDOCTX, ‘counter’) + 1)?>
<?end for-each?>

<?xdoxslt:get_variable($_XDOCTX, ‘counter’)?>

Friday, 7 March 2014

Bursting Like A Boss

Hey Charlie  .......
                                               Hey  Mike whassup  ?

You know that check document you did the RTF template for the other day  ...... 

I remember

well its looking great fantastic table  lay out skills there and the detail on the font is ...

ok whats up  ???

 well try not to freak out but  they want it to output  to specific printers based on the bank account numbers

Bugger! ok you lay out the candles  and I'll go get the chicken

hold on hold on before you do anything drastic remember your a vegetarian and besides since Chad is still getting feathers out of the server room after last time I doubt hes going to let you try that again  . have you considered voodoo anonymous ? any how  I think we can do it with this bursting malarkey thing

It actually turns out to be quite easy to do , relatively painless and no chickens were harmed in the process .the burst process is actually pretty powerful and allows you to  output to specific printers and or email addresses depending on one or more fields in the XML Output

So to sort out the issue we had where we wanted to send our document to a specific printer depending on the value of the bank account this is how we did it

 in the report definition object on the bursting page   you want to do the following


1. Tick Burst Report
2. Pop the full absolute path to the tag you want to burst on into the burst field box
3. Tick Printer and then Data Driven Delivery
4. Hit the Data Driven Printer Mapping Button
5. Hit the  Add Printer mapping Row exit and it will take you to the following screen


6. Give your mapping a name I called mine " Bank Account"
7. Fill in the columns put the value you want to send to a specific printer in the first column and the Printer in the second one .I had bank accounts in the first and printers in the second
8.  Click ok to take you back to the previous screen
9.  Map your XML tag to the XML mapping name
10. click ok and your ready to go .

nice and easy and no unnecessary poultry bothering required   

ITS ALIVE ALIVE !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

well here goes

 * Fought with relevant search engines to find a suitable blog      check   

* worked out how to add Mike as a fellow admin and poster      check

* swigged huge amounts of coffee                                               check

* braced to start posting with all the issues we've found so far      check  

AAAAND were off LOL  

Stay tuned people over the next few days I'll start to post the issues we have hit so far and the clever devious  sneaky and down right dodgy (seriously there were goats and chickens involved) methods we have found so far to resolve  the fiddly bits and foibles we have discovered with BI Publisher  , and we will keep on documenting all of the issues we find and how we solved them so hopefully it will save  you guys some brain ache.   oh and if we get stuck there may be some pleading and sobbing for help involved  its not pretty but it does work  LOL

ttfn
Charlie