Question

IFS 10 UPD15 - PL/SQL advice needed to start background job for Batch_Create_Coll_Invoices__

  • 9 January 2024
  • 4 replies
  • 70 views

Badge +1

Hi community,

i have tried to call background job with PL/SQL developer for “Batch Create Collective Invoices”.

I took the parameter example from scheduled database task.

If this is run with same parameters through Scheduled database task, it won’t give error.

Goal is to have two scheduled Events, which would search customer’s either having Cycle interval 7 days and another with interval 30 days. Logic would find such customers and start “Batch Create Collective Invoices” background job for each found customer.

 

Code snippet to just test calling the “Batch Create Collective Invoices” standard API.

 

declare 
 
arg_ VARCHAR2(32000); 

BEGIN

  Client_SYS.Clear_Attr(arg_); 
  Client_SYS.Add_To_Attr('$COMPANY=', 'xx'||chr(10), arg_); 
  Client_SYS.Add_To_Attr('$CONTRACT=', 'xx'||chr(10), arg_); 
  Client_SYS.Add_To_Attr('$CURRENCY_CODE=', '%'||chr(10), arg_); 
  Client_SYS.Add_To_Attr('$CUSTOMER_NO=', 'xx'||chr(10), arg_); 
  Client_SYS.Add_To_Attr('$IVC_UNCONCT_CHG_SEPERATLY=', '0'||chr(10), arg_); 
  Client_SYS.Add_To_Attr('$PAY_TERM_ID=', '%'||chr(10), arg_); 
  Client_SYS.Add_To_Attr('$PLANNED_INVOICE_DATE_OFFSET=', '1'||chr(10), arg_); 
  arg_ := '!'||chr(10)||arg_;
  
  Transaction_SYS.Deferred_Call(
    'Invoice_Customer_Order_API.Batch_Create_Coll_Invoices__', 
    'MESSAGE', 
    arg_, 
    'Batch Create Invoices xx'
    ); 
  
END; 

 

Error seen in the background job.

 

ORA-06502: PL/SQL: numeric or value errorMessage 1905 not found; No message file for product=plsql, facility=PCM
ORA-06512: at "IFSAPP.INVOICE_CUSTOMER_ORDER_API", line 6484
ORA-06512: at "IFSAPP.INVOICE_CUSTOMER_ORDER_API", line 6544
ORA-06512: at line 1
ORA-06512: at "IFSAPP.TRANSACTION_SYS", line 1867
ORA-06512: at "IFSAPP.TRANSACTION_SYS", line 280
 ORA-06512: at "IFSAPP.INVOICE_CUSTOMER_ORDER_API", line 6484
ORA-06512: at "IFSAPP.INVOICE_CUSTOMER_ORDER_API", line 6544
ORA-06512: at line 1
ORA-06512: at "IFSAPP.TRANSACTION_SYS", line 1867
ORA-06512: at "IFSAPP.TRANSACTION_SYS", line 280
ORA-06512: at "IFSAPP.DEFERRED_JOB_API", line 2080

parameters copied from the Background job:

!
$COMPANY=xx
$CONTRACT=xx
$CURRENCY_CODE=%
$CUSTOMER_NO=%
$IVC_UNCONCT_CHG_SEPERATLY=0
$PAY_TERM_ID=%
$PLANNED_INVOICE_DATE_OFFSET=1


4 replies

Userlevel 2
Badge +1

Hi,

I don’t fully understand why you would want to have two schedules?

The intended way to run this is just to run the standard “Batch Create Collective Customer Invoices” once per day. That job will then scan all delivered order lines (or similar) and check against customers collective invoicing setup. If a customer is set up with cycle interval 7, and there was 7 or more days since last invoice date, then a collective invoice will be created for that customer. If 7 days have not passed yet, that customer will be skipped. If another customer is set up with 30 days cycle interval that will be used. One run of the background job can handle any number of cycle days setups and setups using specified days of month.

For each customer matching above criteria a new background job will be created to create that specific collective invoice.

If you really want to have your own search for which customers should get collective invoice generated I suggest using the same standard ways that IFS uses internally. As I kind of mentioned Batch_Create_Coll_Invoices___ is just a job that finds candidate customers (and invoice variants), and then creates a new background job for each. If you don’t want to use that IFS standard method of scanning all customer you co replace that with your own search, and then generate the second background job call to INVOICE_CUSTOMER_ORDER_API.Create_Collective_Invoice__ yourself for exactly those customers you want to be invoiced.

 

Badge +1

Thank you jaw for prompt reply! We will test this, if standard functionality will actually handle this. No need to invent wheel again. We were in believe that cycle interval is only informative field.

Userlevel 7
Badge +20

Hi @anttik 

I agree with @jaw about dig more into standard IFS functionality to handle your requirement.

On the technical side, Invoice_Customer_Order_API.Batch_Create_Coll_Invoices__ uses IFS Message as input, and if you really want to make your own background execution of this job, here’s how to do it.

-- Created by DSJ
declare
msg_ VARCHAR2(32000) := Message_SYS.Construct('');

BEGIN
Message_SYS.Add_Attribute(msg_, 'COMPANY', 'xx');
Message_SYS.Add_Attribute(msg_, 'CONTRACT', 'xx');
Message_SYS.Add_Attribute(msg_, 'CUSTOMER_NO', 'xx');
Message_SYS.Add_Attribute(msg_, 'CURRENCY_CODE', 'xx');
Message_SYS.Add_Attribute(msg_, 'PAY_TERM_ID', 'xx');
Message_SYS.Add_Attribute(msg_, 'PLANNED_INVOICE_DATE_OFFSET','xx');
Message_SYS.Add_Attribute(msg_, 'IVC_UNCONCT_CHG_SEPERATLY','xx');

Transaction_SYS.Deferred_Call(
'Invoice_Customer_Order_API.Batch_Create_Coll_Invoices__',
'MESSAGE',
msg_,
'Batch Create Invoices xx'
);

END;

 

Hope it helps!

Damith

Badge +1

Hi @dsj,

our preliminary tests shows, that standard way serves us well, good we used the Forum to ask.

Thank you also for the code example, i understand now my problem. This is good example for possible future cases, where input type is message.

Best Regards,

Antti

Reply