Skip to main content

Good morning everyone,

I am having a problem passing a screen parameter/variable to a custom menu block.
I am sending code to a background job, as IFS gives me an error using UTL_FILE directly in the custom menu block.

The invoice_id_ variable in the main block works and returns the value of &INVOICE_ID, however in the background job text within the stmt variable, the same variable invoice_id_ does not return the value of &INVOICE_ID, it returns :__g_Bind.n.0] and I am unable to understand why this doesn’t work.

 

DECLARE

  attr_ VARCHAR2(32000);
  sql_msg_ VARCHAR2(32000);
  stmt_ VARCHAR2(32000);

  invoice_id_ VARCHAR2(240) := &INVOICE_ID || '.PDF';
BEGIN

stmt_ := 'DECLARE

  invoice_id_ VARCHAR2(240) := &INVOICE_ID || ''.PDF'';

BEGIN
  UTL_FILE.FCOPY(''BIAL_INVOICE_SCAN_LB'', invoice_id_, ''BIAL_PDF'', invoice_id_, 1, NULL);
END;';

  sql_msg_ := Message_SYS.Construct('SUP_INV_ANA_SAVE_PDF');
  Message_SYS.Add_Attribute(sql_msg_, 'SQL', stmt_);
  Client_SYS.Clear_Attr(attr_);
  Client_SYS.Add_To_Attr('SQL_DATA_', sql_msg_, attr_);
  Client_SYS.Add_To_Attr('MSG_', '', attr_);

  Transaction_SYS.Deferred_Call(
  'Fnd_Event_Action_API.Action_Executeonlinesql',
  'PARAMETER',
  attr_,
  Language_SYS.Translate_Constant('Event', 'NOTRANS: Event - SUP_INV_ANA_SAVE_PDF', NULL));

--  Error_Sys.Record_General('Error',invoice_id_);

END;

 

Thanks in advance for your help,

Carlos Mendes

Ok, problem solved.

All I had to do was concatenate the value of &INVOICE_ID with the stmt string, instead of trying to “incorporate” it within the string.
 

DECLARE

  attr_ VARCHAR2(32000);
  sql_msg_ VARCHAR2(32000);
  stmt_ VARCHAR2(32000);

BEGIN

  stmt_ := 'DECLARE 
  invoice_id_ VARCHAR2(240) :=''' || &INVOICE_ID || '.PDF'';

BEGIN
  UTL_FILE.FCOPY(''BIAL_INVOICE_SCAN_LB'', invoice_id_, ''BIAL_PDF'', invoice_id_, 1, NULL);
END;';

  sql_msg_ := Message_SYS.Construct('SUP_INV_ANA_SAVE_PDF');
  Message_SYS.Add_Attribute(sql_msg_, 'SQL', stmt_);
  Client_SYS.Clear_Attr(attr_);
  Client_SYS.Add_To_Attr('SQL_DATA_', sql_msg_, attr_);
  Client_SYS.Add_To_Attr('MSG_', '', attr_);

  Transaction_SYS.Deferred_Call(
  'Fnd_Event_Action_API.Action_Executeonlinesql',
  'PARAMETER',
  attr_,
  Language_SYS.Translate_Constant('Event', 'NOTRANS: Event - SUP_INV_ANA_SAVE_PDF', NULL));

END;

 


Reply