Tuesday, 7 May 2013

Multiple picture in oracle XML reports


Dynamic Images

Made it back from Nashville with a pile of requests for blog entries, I'll try and cover them over the next few weeks ... top of the list of requests was how to handle dynamic images in a layout template. There are several ways to tackle this depending on where your images are going to be at runtime. The scenario is, that I have three organizations in my company and they each have their own logo; at runtime, based on the organization I am generating a report for the output should show their logo. Lets assume we have the following XML data for all of these examples:

<INVOICELIST>
 <IMG_DIR>/images</IMG_DIR>
 <IMG_SERVER>http://xdo.us.oracle.com</IMG_SERVER>
 <IMG_DIR_PATH>c:temp</IMG_DIR_PATH>
 <G_VENDOR_NAME>
  <ORG>1</ORG>
  <IMGFILE>Org1.gif</IMGFILE>
  <VENDOR_NAME>Nuts and Bolts Limited</VENDOR_NAME>
  <ADDRESS>1 El Camino Real, Redwood City, CA 94065</ADDRESS>
   <G_INVOICE_NUM>
    <SET_OF_BOOKS_ID>124</SET_OF_BOOKS_ID>
    <GL_DATE>10-NOV-04</GL_DATE>
    ...
 </G_VENDOR_NAME>
 <G_VENDOR_NAME>
  <ORG>2</ORG>
  <IMGFILE>Org2.gif</IMGFILE>
  <VENDOR_NAME>Tick Tock Clocks</VENDOR_NAME>
  ...
</INVOICELIST>


So our XML references an image directory(IMG_DIR) on our server(IMG_SERVER) and the full path to the image directory (IMG_DIR_PATH) on our server, then each invoice has the organization ID and the image name to be used. So we can tackle this one of three ways:
1. Embed the three logos into the template directly
2. Reference the images on the disk and use a dynamic image
3. Reference the images via a URL

Embedding in the template

This is the simplest method, if we have three images, one for each organization we can add them all to the template and wrap them in conditional statements to show/hide them.

DynImg1:

The simplest method is to use three 'if' statements, you could equally use a 'choose' statement to get the same effect. See DynamicImg1.rtf template here. If you have alot of images and/or need dynamic images in multiple templates; you could put a template function either else where in the template or ina completely separate template altogether and then call it from the main templates. See DynamicImg2.rtf for an example in the zip file

Using dynamic images

We can also just add a single dummy image to the template and at runtime point to the correct image file either on the file system or via a URL. We can build the file location of the image quite easily using the XSL concat() function.  Note at runtime the incoming image will be resized (if necessary) to fit the same dimensions as the dummy image.
So in the Web tab of the image properties we have:

DynImg2:

File System: url:{concat(../IMG_DIR_PATH,'/',IMGFILE)} See DynamicImg3.rtf
URL: url:{concat(../IMG_SERVER,'/',../IMG_DIR,'/',IMGFILE)} See DynamicImg4.rtf

Notice we use '../' to get a level up from the G_VENDOR_NAME level for the root level values we need to construct the path or URL i.e. ../IMG_DIR_PATH.

If you are an E Business Suite user you can also make use of the OA_MEDIA directory. XML Publisher will resolve this value at runtime. So for an image in the OA_MEDIA directory you could use:

url:{?${OA_MEDIA}/IMGFILE?}
==============================================================================

4 comments:

  1. Hi,
    I have a question. If my report has multiple suppliers and each supplier has its own logo. Under each supplier there are many invoices. And my report has to display the corresponding logo for each supplier. i.e., 1st supplier - its logo and its N invoices. Next 2nd supplier and same thing.. how do we achieve this? Could you pls explain? TIA

    ReplyDelete
  2. P.S. Im new to dynamic and multiple images concept. Kindly clarify accordingly.
    TIA

    ReplyDelete
  3. Hi,

    There are two ways one is explained above from OA media and second is to call dynamically from IF condition

    ReplyDelete
  4. The King Casino - CommunityKhabar
    The https://jancasino.com/review/merit-casino/ King หารายได้เสริม Casino is the only casino near the casino. https://septcasino.com/review/merit-casino/ All casino games are legal communitykhabar and the game variety is huge! The games are casino-roll.com also available at any of the

    ReplyDelete

CREATING A SUPPLIER IN R12 (Functional and SUPPLIERS IN TCA)

Who is a Supplier? Let us now understand who is a Supplier with the help of a simple example: We consider us as a business, who sell...