I found this when lurking about the interwebs looking for a way to check if a field existed in the XML
• To define behavior when the element is present and the value is not null, use the following:
<?if:element_name!=?> desired behavior when the element exists and is not null <?end if?>
• To define behavior when the element is present, but is null, use the following:
<?if:element_name and element_name="?> desired behavior when the element exists but value is null <?end if?>
• To define behavior when the element is not present, use the following:
<?if:not(element_name)?> desired behavior when the element is not present <?end if?>
Survivors of a long and bitter JDE Transform installation (you cant imagine the horror man !! ) Mike , Jamie, Roger and Charlie are Four Developers working with the infinitely superior BI publisher to handle all our ERP produced documents. this blog is a place for us to post all of the fiddly bits foibles and general head scratching we have discovered along the way to help out our fellow code monkeys out there
Showing posts with label Developer. Show all posts
Showing posts with label Developer. Show all posts
Tuesday, 1 April 2014
Wednesday, 19 March 2014
BI Publisher Storeing a substring of an XML tag into a variable
this gave me a bit of a headache I had a task where i needed to chop of the last character of one of the XML tags so I could use it in some of the logic statements further down in the code . this did the trick OptioPrinterName_ID180 is the name of the XML tag i wanted to chop the end off and store and 1 at the end is the number of characters to chop
<?xdoxslt:set_variable($_XDOCTX, ‘optioChar’,xdoxslt:right(OptioPrinterName_ID180,1))?>
Then further down in the code when i needed to reference the variable for my logic i Referenced it as follows
<?choose:?>
<?when:xdoxslt:get_variable($_XDOCTX, ‘optioChar’)=‘A‘?>Test<?end when?>
<?otherwise:?>Test2<?end otherwise?>
<?end choose?>
<?xdoxslt:set_variable($_XDOCTX, ‘optioChar’,xdoxslt:right(OptioPrinterName_ID180,1))?>
Then further down in the code when i needed to reference the variable for my logic i Referenced it as follows
<?choose:?>
<?when:xdoxslt:get_variable($_XDOCTX, ‘optioChar’)=‘A‘?>Test<?end when?>
<?otherwise:?>Test2<?end otherwise?>
<?end choose?>
Location:
Stubbins, Bury, Lancashire BL0, UK
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
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 * * * ' ,'')?>
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
extremely cool and useful Linky
Labels:
BI Publisher,
Developer,
FO,
Function Guide,
Functions,
JDE,
RTF,
SQL,
Substring,
Template,
XSL
Location:
Stubbins, Bury, Lancashire BL0, UK
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?>
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?>
Labels:
BI Publisher,
Case Statement,
Developer,
JDE,
RTF,
Template
Location:
Stubbins, Bury, Lancashire BL0, UK
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
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:
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:
- 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.
-
From the BI Publisher toolbar select Insert, then
Conditional Region.
The following figure shows the Conditional Region dialog:
-
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.
Labels:
BI Publisher,
Conditional Sections,
Developer,
JDE,
RTF,
Template
Location:
Stubbins, Bury, Lancashire BL0, UK
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?>
Labels:
BI Publisher,
Developer,
JDE,
Print Multiple Copies,
RTF,
Template
Location:
Stubbins, Bury, Lancashire BL0, UK
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’)?>
Location:
Stubbins, Bury, Lancashire BL0, UK
Subscribe to:
Posts (Atom)