I have uncounted a problem in an SQLRPGLE program. It is used as an API program to send mails to users when something is wrong with an order.
To sketch the workings of the program, we have an autostart job that start a program (program A) that look at every order created to see if all the data in it is ok. If not it calls a mail API program.
In Program A there are several API calls to the send mail. In the API mail program we do an SQL insert in a table called FCMAILS (as logging).
In program A only 1 call always goes wrong. This results after some testing in a SQLSTATE 08003. Meaning 'application process not in a connected state'. The program does not crash, or give any sysopr notification. It also does not write a record in the file FCMAILS.
Does anybody has an idea how to solve this problem? I have been looking at a the SQLCONNECT command for AS400 but don't find a lot of info over it and I don't want to make it worse than it already is.
/free
// save body to text file for loading into clob
BodyObj_Data = Body;
BodyObj_Len = %len(Body);
callp GenGuid(GUID);
exec sql
insert into fcmails(
Guid,SendUser,Program,Sender,Recipient,RecipientCc,RecipientBcc,
Subject,Body) values
(:GUID,:SendUser,:Program,:Sender,:Recipient,:RecipientCc,
:RecipientBcc,:Subject,:BodyObj);
if sqlstate <> '00000';
callp XSndMsg(' ':'SYSOP':'Mail Error: P:' + Program +' S:'+sqlstate+
' subj:' +Subject);
endif;
// trigger mail program
callp SndDtaQ('APIMAILDTQ':'FCDTA500':%Size(GUID):
GUID);
return *on;
/end-free
PapiCreateMail E