Skip to Main Content

APEX

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

How to create two level heading of CR dynamically

Soukaina IDRISSIJul 20 2022

Hello Experts,
I hope all doing well.
Im using APEX21.2, and i want to create CR (I can choose the type of report, i mean i can switch to IR or IG) with two level heading dynamically.
Here is how my recent report looks like
image.pngThe expected result is:
image.pngSo, for that i created a function 'TWO_LEVEL_HEADER' that accepts as input two parameters p_from_fy , p_to_from_fy and returns the sequence of my header

create or replace FUNCTION "TWO_LEVEL_HEADER"
(p_from_fy IN NUMBER,
p_to_fy IN NUMBER)
RETURN VARCHAR2
IS
l_return VARCHAR2(1000);

BEGIN

FOR i IN (
  SELECT 
    DISTINCT ':' | | CASE
      WHEN doc_id LIKE 'one%'   THEN 'Subject'
      WHEN doc_id LIKE 'two%'   THEN 'Subject2'
      WHEN doc_id LIKE 'three%' THEN 'Subject3'
    END doc_type,
    fiscal_year yr
  FROM fiscal_tbl
  WHERE ( INSTR(doc_id, 'one') > 0 OR INSTR(doc_id, 'two') > 0 OR INSTR(doc_id, 'three') > 0)
    AND fiscal_year BETWEEN p_from_fy AND p_to_fy
    ORDER BY 2,1
) LOOP 

l_return := l_return || i.doc_type || ' ' || i.yr;
END LOOP;
l_return := LTrim(l_return, ':');
RETURN l_return;
END; 

After that i call this function in the Attributes tab of my region -> in Heading section like this:

<img src="https://objectstorage.us-phoenix-1.oraclecloud.com/p/BqK85Rn1zA5MP0vYiqbAdPgs7Z6OmMxw8SD3WCFVm5kY8uReidZ1KPIKkgJ1hCkG/n/axciphqpnohg/b/forums-legacy/o/uploads/7A5574IH0CVF/image.png" alt="image.png">return ' :'|| TWO_LEVEL_HEADER (2019,2022);

You can see demo, on apex.oracle.com with this credentials:
Workspace: ws_initiation
Username: demo
Password: azerty1234
I used the Application 91527 - Custom CR/ Page 2 - Custom Group Column

Thank you for help.

Comments
Post Details
Added on Jul 20 2022
9 comments
631 views