Auto-Generate a report to generate the "Result Key" IFS24 R2
Hello Community,
I hope you are all doing well.
I am currently working on an Event Action that sends an email and would like to include a report—specifically the "NCR Report"—as an attachment. I have already configured the logic for the Event Action, but I need to automate the generation of the report so it gets archived in the Archive Report page, thereby creating a Result Key. fyi. I do not need to generate the email attachment via PDF_REPORT_CREATED , because I need to generate the report via code to be able to archive or create the Result Key.
My main question is: how can I programmatically generate this report and have it archived in the Archive Report page to obtain the Result Key? Are there any code examples or APIs I can use for this purpose?
Additionally, I’m trying to trace the internal calls in IFS Cloud 24R2 but haven’t been able to identify the specific API responsible for this. I’ve tried using the inspection tools, but the report execution doesn’t seem to show a clear API call.
Any insights, examples, or guidance would be greatly appreciated!
Page 1 / 1
Hi @ZTC ZTC JGOTA
Here is a sample code for creating an archive record for NCR Report
select column_name parameter, column_value default_value from report_column_definition where report_id = 'NCR_REP' and column_query is not null
Hope it helps!
Damith
@dsj on the ball as usual.
Here’s a bit of extra I currently employ if you want to use the same block to create the PDF file in the report document archive as well, rather than just the result set.
This is a generic procedure I created that can take up to 20 Parameters (9 in the NCR Report Above for instance), although it does require providing the language_code and layout_name (obviously it could also be modified to grab the default values for lang_code and layout_name if none are provided in the attribute).
It outputs the result key and the print job id, so that the call handler can then manipulate the report document archive entry based on those keys.
PROCEDURE report_new_instance_and_print(attr_ in varchar2, result_key_out_ out number, print_job_id_out_ out number) IS
if report_param_ is null or report_param_value_ is null then -- Procedure not called properly, no report parameter such as report ID provided, exit procedure RETURN; END IF;
-- Create Report Parameters Attr client_sys.clear_attr(real_parameter_attr_); IF param_1_ is not null then client_sys.add_to_attr(param_1_, nvl(param_1_value_, ''), real_parameter_attr_); end if;
IF param_2_ is not null then client_sys.add_to_attr(param_2_, nvl(param_2_value_, ''), real_parameter_attr_); end if;
IF param_3_ is not null then client_sys.add_to_attr(param_3_, nvl(param_3_value_, ''), real_parameter_attr_); end if;
IF param_4_ is not null then client_sys.add_to_attr(param_4_, nvl(param_4_value_, ''), real_parameter_attr_); end if;
IF param_5_ is not null then client_sys.add_to_attr(param_5_, nvl(param_5_value_, ''), real_parameter_attr_); end if;
if param_6_ is not null then client_sys.add_to_attr(param_6_, nvl(param_6_value_, ''), real_parameter_attr_); end if;
IF param_7_ is not null then client_sys.add_to_attr(param_7_, nvl(param_7_value_, ''), real_parameter_attr_); end if;
IF param_8_ is not null then client_sys.add_to_attr(param_8_, nvl(param_8_value_, ''), real_parameter_attr_); end if;
IF param_9_ is not null then client_sys.add_to_attr(param_9_, nvl(param_9_value_, ''), real_parameter_attr_); end if;
IF param_10_ is not null then client_sys.add_to_attr(param_10_, nvl(param_10_value_, ''), real_parameter_attr_); end if;
IF param_11_ is not null then client_sys.add_to_attr(param_11_, nvl(param_11_value_, ''), real_parameter_attr_); end if;
IF param_12_ is not null then client_sys.add_to_attr(param_12_, nvl(param_12_value_, ''), real_parameter_attr_); end if;
IF param_13_ is not null then client_sys.add_to_attr(param_13_, nvl(param_13_value_, ''), real_parameter_attr_); end if;
IF param_14_ is not null then client_sys.add_to_attr(param_14_, nvl(param_14_value_, ''), real_parameter_attr_); end if;
IF param_15_ is not null then client_sys.add_to_attr(param_15_, nvl(param_15_value_, ''), real_parameter_attr_); end if;
IF param_16_ is not null then client_sys.add_to_attr(param_16_, nvl(param_16_value_, ''), real_parameter_attr_); end if;
IF param_17_ is not null then client_sys.add_to_attr(param_17_, nvl(param_17_value_, ''), real_parameter_attr_); end if;
IF param_18_ is not null then client_sys.add_to_attr(param_18_, nvl(param_18_value_, ''), real_parameter_attr_); end if;
IF param_19_ is not null then client_sys.add_to_attr(param_19_, nvl(param_19_value_, ''), real_parameter_attr_); end if;
IF param_20_ is not null then client_sys.add_to_attr(param_20_, nvl(param_20_value_, ''), real_parameter_attr_); end if;
-- Create new archive instance to obtain result_key Archive_API.New_Instance(result_key_, real_report_attr_, real_parameter_attr_);
-- Setup new PrintJob with Result Key obtained above. job_attr is left null to avoid a physical print happening Print_Job_API.New_Print_Job(print_job_id_, job_attr_, job_contents_attr_);
-- Execute Print Job to create PDF File Print_Job_API.Print(print_job_id_);