Short example on how to use system-link to update XA (MAPICS) table.
This example includes some procedures.

System_Link Users Guide

the below snippet runs out of the job scheduler.
** Binding directory – “UTLITIES”
2 procedures GETDATE & UPDDAT

System-Link is an INFOR/XA MAPICS tool to allow integration from external non-IBM i system.
Awesome idea for extending the life of your product!

[cc lang=”php”]
H DFTACTGRP(*NO) OPTION(*SRCSTMT: *NODEBUGIO) BNDDIR(‘UTILITIES’)

d CalendarName s 10 inz(‘RBS INVCAL’)
d Cymd s 7 0 inz
d MyReturnhandleID…
d s 30
d InWarehouse s 3 inz(‘1’)
d InDate s D
d InEnvironment s 2 inz(‘MM’)

/copy qprcsrc,GETDATE_CP
/copy qprcsrc,UPDPDAT_CP

DateDS = GetDate() ;

clear cymd;
exec sql
SELECT G3AAWN
into :Cymd

FROM CALNDR
where
G3AAWN > :DATEDS.CYMD0 and
G3ABPR = ‘RBS INVCAL’
order by g3aawn
fetch first row only;

// convert cymd to isodate
test(de) *cymd Cymd;
if not%error;
InDate = %date(cymd:*cymd);
reset MyReturnhandleID;
SystemLinkDS =
UpdatePlanningDate(MyReturnhandleID:InWarehouse:
Indate:InEnvironment);
endif;

*inlr = *on;

[/cc]

GETDATE procedure

Procedure uses system link to create XML to update Planning Date
The procedures in this program are all base procedures to create XML and post back into XA.
We will provide them in a later post — or if you’d like them please ask.

[cc lang=”php”]
H NOMAIN EXPROPTS(*RESDECPOS)
* PROGRAM – UPDPDAT
* PURPOSE – Update date for planning by warehouse
* WRITTEN – 10/05/18
* AUTHOR – Jamie Flanary

d Dec8 s 8 0 Inz
d MyEnvironment s 2 Inz(‘TT’)
d MyErrorBack s 7 Inz
d MyWarehouse s 3 Inz
d MyReturnhandleID…
d s 30 Inz
d MyDate s D Inz
d MyPassword s 10 Inz
d MyUser s 10 Inz
d MyValueString s 200 varying Inz
d MyXMLString s 65535 varying Inz
*
* Begin Procedure
*
p UpdatePlanningDate…
p B export

/copy qprcsrc,CRTENTI_CP
/copy qprcsrc,FMTXMLS_CP
/copy qprcsrc,GETHNDL_CP
/copy qprcsrc,GETSLUP_CP
/copy qprcsrc,GETSLHD_CP
/copy qprcsrc,PRCSYSL_CP

* Procedure Interface
d UpdatePlanningDate…
d pi 75000
d InReturnhandleID…
d 30
d InWarehouse 3
d InDate D
d InEnvironment 2 const options(*nopass:*omit)
d InUser 10 const options(*nopass:*omit)
d InPassword 10 const options(*nopass:*omit)

/free
clear MyErrorBack;
reset MyEnvironment;
reset MyUser;
reset MyPassword;
reset MyReturnhandleID;
reset MyXMLString;

//In Environment passed or not passed
if %parms >= 4;
MyEnvironment = InEnvironment;
endif;

//was userid and password passed?
if %parms >= 6;
MyUser = InUser;
MyPassword = Inpassword;
else;
CredentialsDS = GetSystemLinkCredentials();
MyUser = CredentialsDS.User;
Mypassword = CredentialsDS.password;
endif;

// this returns the current seesion handler
reset MyReturnhandleID;
MyReturnhandleID= GetSystemLinkHandle();

// return the XML Header
MyXMLString =
GetSystemLinkXMLHeader(‘Y’: MyEnvironment: MyUser: MyPassword);

// need to create the session Handle String
MyXMLString = %trimr(MyXMLString) + ‘ ‘ +
‘;

MyXMLString = %trimr(MyXMLString) + ‘ ‘ +
‘ +
‘ +
‘;

Myvaluestring = InWarehouse;
MyXMLString =
FormatAndAppendXML(
MyXMLString:
‘warehouse’:
MyValueString);

MyXMLString = %trimr(MyXMLString) + ‘ ‘ +
‘ ‘;

// use the isodate format to ex. 20181006
Dec8 = %dec(InDate);
Myvaluestring = %editc(Dec8:’Z’);

MyXMLString =
FormatAndAppendXML(
MyXMLString:
‘relatedPlanningInformation.currentDate’:
MyValueString);

// close the XML string
MyXMLString = %trimr(MyXMLString) + ‘ ‘ +
‘‘;

SystemLinkDS =
ProcessSystemLinkCommand(MyXMLString);
MyErrorBack = ‘*None’;
return SystemLinkDS;

/end-free
p UpdatePlanningDate…
p e

[/cc]

upddat

upddat_CP

Updating Planning Date XA (MAPICS)
Tagged on:                 

Leave a Reply

Your email address will not be published.