Short example on how to use system-link to update XA (MAPICS) table.
This example includes some procedures.
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!
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 | 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; |
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.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 | 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) + ' ' + '<Request sessionHandle="*current" workHandle="*new" ' + 'broker="EJB" maxIdle="1000"> '; MyXMLString = %trimr(MyXMLString) + ' ' + '<Update name="updateObject_Warehouse" ' + 'domainClass="com.mapics.mm.Warehouse"> ' + '<ApplyTemplate><![CDATA[(none)]]></ApplyTemplate> ' + '<DomainEntity> <Key> '; Myvaluestring = InWarehouse; MyXMLString = FormatAndAppendXML( MyXMLString: 'warehouse': MyValueString); MyXMLString = %trimr(MyXMLString) + ' ' + '</Key> '; // 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) + ' ' + '</DomainEntity></Update></Request></System-Link>'; SystemLinkDS = ProcessSystemLinkCommand(MyXMLString); MyErrorBack = '*None'; return SystemLinkDS; /end-free p UpdatePlanningDate... p e |
Updating Planning Date XA (MAPICS)