Printing Dynamic Images in XML Reports using RDF

There is often a requirement to print dynamic logos in reports. The logos printed will vary as per the legal entity or the operating unit. The process is fairly simple if the number of the legal entities or operating units is very few. This can be achieved by using if-else blocks in report header or by creating a sub-template with logos as it content. However, if the number is high ,this approach is really time consuming. A simpler approach is to achieve it is discussed below assuming the legal entity as on of the report parameters.

Prerequisites:

  1. The image files must be named uniquely. e.g If there are 3 legal entities (A,B and C), the files can be named as A.gif, B.gif and C.gif
  2. The file format should be gif.

Steps:

  1. Place the image files in $OA_MEDIA directory.
  2. Place a dummy image (.gif) in the template where the logo is to be displayed.
  3. Edit the image properties (Right click on dummy image and select Format Picture) as shown in the picture below:

In the Alt Text Description enter the below text:

url:{//CP_IMAGE}

Format Picture

4. Create a Placeholder CP_IMAGE at report level with type as character.

5. The final step is to dynamically populate CP_IMAGE. To achieve this, add the below code in beforeReport Trigger.

SELECT prof.NAME legal_entity
	,'${OA_MEDIA}/' || prof.legal_entity_identifier || '.gif' IMAGE
	,prof.legal_entity_identifier
INTO :cp_le
	,:cp_image
FROM xle_registrations reg
	,xle_entity_profiles prof
	,hr_operating_units ou
	,hr_locations_all hrl
	,fnd_territories_tl ter
WHERE reg.source_table = 'XLE_ENTITY_PROFILES'
	AND reg.source_id = prof.legal_entity_id
	AND prof.legal_entity_id = ou.default_legal_context_id
	AND reg.location_id = hrl.location_id
	AND prof.legal_entity_id = :p_legal_entity
	AND ter.LANGUAGE = USERENV('LANG')
	AND ter.territory_code = hrl.country
	AND ROWNUM = 1;