Yesterdays challenge is to replace a scheduled timed event with a dynamic process. Give's us an opportunity to try REST from RPGLE using new
SYSTOOLS HTTPGETCLOB.
The program is simple and just prompts the Web programming to capture funds and invoice order in ERP backend. Responds with OK and if not send me an E-mail.
Very cool and once I managed to get all the special chatters in the right place works great. This can also be done in a CLLE with RUNSQL command and CREATE TABLE AS. I initially blew it in CLLE and reported to IBM could not get it working. They came back a few days later, right after I got RPGLE version working, and informed me that '+' continuation line character had a space before and that was causing SQL to fail with SQLSTT 38000. DUH!
The next step is a SOAP message so we can trade data between web and back end ERP.
I wish I had the time to learn PowerRuby. I believe I can do this with Ruby as well.
My next endeavor is
JSON to link back end VAI ERP to
DESK.COM. Again I think
PowerRuby can help and really need to figure out how to get there.
//******************Begin
sub-routines*******************************
//********************************************************************
// Run web service and check response
//********************************************************************
begsr xxxx;
// Change Job CCSID to 37
CmdStr = 'CHGJOB CCSID(37)';
callp(e) ExcCmd(%trim(CmdStr) : %len(%trim(CmdStr)));
// Call Web Service Action=doInvoicing
Exec SQL
SELECT data into :m_data FROM
(VALUES(SYSTOOLS.HTTPGETCLOB
('http://xxxxxx.xxxxxxxx.com/xxx/+
xxxxxxx.cfm?action=doinvoicing',+
'<httpHeader
connectTimeout="10000"> +
</httpHeader>'))) WS(data);
// Change Job CCSID to system default
CmdStr = 'CHGJOB CCSID(65535)';
callp(e) ExcCmd(%trim(CmdStr) : %len(%trim(CmdStr)));
// If Web service response not OK - send Email
if m_data <> 'OK';
exsr email_err;
EndIf;
endsr;
//********************************************************************
// Send email if
failed to get response from Web
//********************************************************************
begsr email_err;
// Build send email
command
CmdStr = 'SNDMAIL RECIPIENT((RICHARD xxxxxxxx@xxxxxxxx.COM))';
CmdStr = %trim(CmdStr) + ' SENDER(QCAPIBMI xxxxxx@xxxxxxxxx.COM)';
CmdStr = %trim(CmdStr) + ' SUBJECT(' + Quote + 'PO Receipt processed';
CmdStr = %trim(CmdStr) + ' ***Web Capture funds not processed ***';
CmdStr = %trim(CmdStr) + Quote + ') MESSAGE(' + Quote;
CmdStr = %trim(CmdStr) + 'EDIARDSCF failed to receive response OK';
CmdStr = %trim(CmdStr) + ' *** Contact WEB ***';
CmdStr = %trim(CmdStr) + Quote + ')';
// Send email
callp(e) ExcCmd(%trim(CmdStr) : %len(%trim(CmdStr)));
EndSr;
~Richard
One man's crappy software is another man's full time job. ~Jessica Gaston, 2008