Sunteți pe pagina 1din 8

ott-99-0063

Page 1 of 8

Title: Call to AS/400 RPG Program from C Business Function


Abstract: This document provides a reference for developers and business partners who are interested in creating calls from within C business functions to RPG programs residing on the AS/400.

Overview
The purpose of this document is to provide a reference for developers and business partners who are interested in creating calls from within C business functions to RPG programs residing on the AS/400. Included in this document are a description of the business purpose, pre-requisite setup requirements for implementing calls from PeopleSoft EnterpriseOne, and an overview of how a call is made. Examples of calls are included, and will be used to explain the process.

Purpose
By following the steps outlined in this document and referring to the examples described, developers and business partners who need to call RPG programs from C business functions should be able to create their own calls. This process was first implemented when PeopleSoft EnterpriseOne, in partnership with ITLS Corporation, developed a method of utilizing ITLSs advanced shipment processing functionality within the framework of the current order processing. This method enables PeopleSoft EnterpriseOne clients to use the Shipper Management System (SMS) by sending a call from a PeopleSoft EnterpriseOne business application to the AS/400. Through the SMS interface, clients have access to tools residing on the AS/400 which are not available in the PeopleSoft EnterpriseOne environment. The ITLS examples described in this document are for informational and reference purposes only, and are not intended to be exact templates for other applications. Because requirements vary for each application, actual implementation may be different from the processes and procedures described in this document.

Setup Considerations
Before you implement a call from PeopleSoft EnterpriseOne to an RPG program, the following things must be in place: 1. PeopleSoft EnterpriseOne business function specifications must reside on the AS/400 server. That is, the business function must have its Object Configuration Manager (OCM) mappings set to run on the AS/400. Anything required by the RPG program must be resident. This is a one-time setup that you need to perform initially before implementing calls from within a PeopleSoft EnterpriseOne C business function to an RPG program; you need not do this setup every time. 2. Ensure that the production library list on the AS/400 where the RPG program is going to run is set up to access all the servers and common copy subroutines required by the RPG

file://F:\Oracle\One World\Dev Tools\C Business Functions\Call CLP\calls to an rpg pro...

22/07/2011

ott-99-0063

Page 2 of 8

program. For example, for the ITLS solution, the library list includes the XS7300 Complementary Products Constant file server, and the I7300 copy module. 3. The RPG program must be compiled and exist as an object on the AS/400. 4. All necessary tables and files required by the RPG program must exist in the DB2 data library on the AS/400. Be sure the data library on the AS/400 is part of the library list for the RPG program.

Setup Caveats
If tables do not exist in DB2 on the AS/400, do not use replication as a means of getting tables into DB2. For example, if the Sales Order header (F4210) and Sales Order Detail (F4211) exist in an Oracle database, do not try to replicate the header and file to DB2 on the AS/400. The RPG program may try to do an update to these items, and these updates wont be reflected in Oracle. Do not use tables that use PeopleSoft EnterpriseOne table triggers. Tables that have defined table triggers and are mapped to DB2 on the AS/400 will not be triggered when accessed by the RPG program.

Functional Overview
This section describes the general process of how a call is made to an RPG program from within a PeopleSoft EnterpriseOne C business function. Following a brief description of the general process is a specific example used in the ITLS implementation. The process for creating a call can be summarized in the following main steps: 1. On the PeopleSoft EnterpriseOne side, define the data structure for the business function that will do the call to the RPG program. Map the C data structure to match the RPG parameter list as closely as possible. (The parameter list on the RPG side must match the defined C data structure.) Before you proceed, derive C business function parameters from that end. As an example, following is the data structure for the ITLS function that calls the RPG program SMR9100: Data Item DOCO SHAN DCTO KCOO ACT EV01 RNT ERRT AA12 MCU SECFRQ PROV PROC MISC Data Structure Description mnDocumentOrderInvoice mnAddressNumberShipTo szOrderType szCompanyKeyOrderNo szActionCodesNotAllowed cEverestEventPoint01 mnRouteNumber szTypeofError szAlphaSpecData12 szCostCenter mnChangeFrequency cPriceOverrideCode cNoticeToProceed mnMinServToCalculate I I/O I I I I I I Required Y Y Y Y Y Y N N N N Y N N N Assign Zero "S", "D", "M" '1' Notes

file://F:\Oracle\One World\Dev Tools\C Business Functions\Call CLP\calls to an rpg pro...

22/07/2011

ott-99-0063

Page 3 of 8

PID VERS

szProgramID szVersion

I I

Y Y

"SMR9100"

2. Define the business functions "if defines." 3. The data structure loaded in the business function makes the call to the RPG program. (If it compiles on the AS/400 server, make sure the call is compiled.) 4. Tables resident on the AS/400 are updated.

The ITLS Solution


As an example, the following steps are involved in the ITLS solution for implementing calls from PeopleSoft EnterpriseOne: 1. Sales order information is entered through Sales Order Entry. The order is then created and completed on the AS/400 server. 2. Once the order is completed, the PeopleSoft EntepriseOne business function calls the Routing and Rating program on the server to create the shipment. In order to use the SMR9100 server, the data structure that holds the complementary products flag must be passed. This structure is defined in the I7300 copy module. 3. The Routing and Rating server (SMR9100) performs edits and passes the shipment information to the load building routine (SMR2200) on the server. 4. The load is released by the server. 5. Pick slips and pick requests are generated. 6. Orders that have gone through the generate pick slip or pick request process are automatically frozen by SMR9100. 7. For PeopleSoft EnterpriseOne applications, item and order and shipment confirmation are performed manually on the AS/400 server.

Programming Examples
This section contains specific code examples used to develop the ITLS interface. A brief description precedes each program.

Routing and Rating Program


The following header and corresponding program were written to call the RPG program which performs routing and rating for clients using the Shipper Management System (SMS).

B4201140.h Header
/***************************************************************************** * Header File: B4201140.h * Description: ITLS Interface Header File * History: * Date Programmer SAR# - Description * --------------------------------------------------------* Author 06/04/1997 SB5491937 1632368 - Created * * Copyright (c) J.D. Edwards World Source Company, 1996 * * This unpublished material is proprietary to J.D. Edwards World Source * Company. All rights reserved. The methods and techniques described * herein are considered trade secrets and/or confidential. Reproduction * or distribution, in whole or in part, is forbidden except by express * written permission of J.D. Edwards World Source Company. ****************************************************************************/

file://F:\Oracle\One World\Dev Tools\C Business Functions\Call CLP\calls to an rpg pro...

22/07/2011

ott-99-0063

Page 4 of 8

#ifndef __B4201140_H #define __B4201140_H /* This program is called by a CL program that passes */ /* */ /* */ /* */ /* RPG/400 is called to perform the Routing and Rating logic */ #include <stdio.h> #include <stdlib.h> #include <string.h> #ifdef JDENV_AS400 #include <decimal.h> #endif /* JDENV_AS400 */ /* The #pragma map directive maps a new program name to the existing program name so that the purpose of the program is clear.*/ #ifdef JDENV_AS400 #pragma map(rating_and_routing,"SMR9100") #endif /* JDENV_AS400 */ /* * Tell the compiler that there are dynamic program calls so arguments are passed by value-reference. */ #pragma linkage(rating_and_routing, OS) /***************************************************************************** * Table Header Inclusions ****************************************************************************/ /***************************************************************************** * External Business Function Header Inclusions ****************************************************************************/ #include <b0000083.h> /***************************************************************************** * Global Definitions ****************************************************************************/ /***************************************************************************** * Structure Definitions ****************************************************************************/ /*#ifdef JDENV_AS400 */ typedef struct { char sz_doco[8]; char sz_shan[8]; char sz_dcto[2]; char sz_kcoo[5]; char c_act; char c_src; char c_rtn; char sz_errn[4]; char sz_shpNo[12]; char sz_mcu[12]; char sz_d_chg[11]; /* #ifdef JDENV_AS400 decimal (11,2) d_chg; #endif*/ /* JDENV_AS400 */ char c_prov; char c_proc; char sz_misc[256]; char sz_mpid[10]; char sz_vers[10]; } DS_ITLS;

file://F:\Oracle\One World\Dev Tools\C Business Functions\Call CLP\calls to an rpg pro...

22/07/2011

ott-99-0063

Page 5 of 8

/*#endif*/ /* JDENV_AS400 */ /***************************************************************************** * DS Template Type Definitions ****************************************************************************/ /***************************************** * TYPEDEF for Data Structure * Template Name: ITLS Interface * Template ID: D4201140 * Generated: Wed Jun 04 13:48:57 1997 * * DO NOT EDIT THE FOLLOWING TYPEDEF * To make modifications, use the Everest Data Structure Tool to Generate a revised version, and paste from the clipboard. * **************************************/ #ifndef DATASTRUCTURE_D4201140 #define DATASTRUCTURE_D4201140 typedef struct tagDSD4201140 { MATH_NUMERIC mnDocumentOrderInvoiceE; MATH_NUMERIC mnAddressNumberShipTo; char szOrderType[3]; char szCompanyKeyOrderNo[6]; char szActionCodesNotAllowed[6]; char cEverestEventPoint01; MATH_NUMERIC mnRouteNumber; char szTypeofErrpr[5]; char szAlphaSpecData12[13]; char szCostCenter[13]; MATH_NUMERIC mnChangeFrequency; char cPriceOverrideCode; char cNoticeToProceed; MATH_NUMERIC mnMinServToCalculate; char szProgramId[11]; char szVersion[11]; } DSD4201140, *LPDSD4201140; #define IDERRmnDocumentOrderInvoiceE_1 1L #define IDERRmnAddressNumberShipTo_2 2L #define IDERRszOrderType_3 3L #define IDERRszCompanyKeyOrderNo_4 4L #define IDERRszActionCodesNotAllowed_5 5L #define IDERRcEverestEventPoint01_6 6L #define IDERRmnRouteNumber_7 7L #define IDERRszTypeofErrpr_8 8L #define IDERRszAlphaSpecData12_9 9L #define IDERRszCostCenter_10 10L #define IDERRmnChangeFrequency_11 11L #define IDERRcPriceOverrideCode_12 12L #define IDERRcNoticeToProceed_13 13L #define IDERRmnMinServToCalculate_14 14L #define IDERRszProgramId_15 15L #define IDERRszVersion_16 16L #endif /***************************************************************************** * Source Preprocessor Definitions ****************************************************************************/ #if defined (JDEBFRTN) #undef JDEBFRTN #endif #if defined (WIN32) #if defined (WIN32) #define JDEBFRTN(r) __declspec(dllexport) r #else #define JDEBFRTN(r) __declspec(dllimport) r #endif #else #define JDEBFRTN(r) r #endif /***************************************************************************** * Business Function Prototypes ****************************************************************************/ JDEBFRTN (ID) JDEBFWINAPI ITLSInterface (LPBHVRCOM lpBhvrCom,LPVOID lpVoid,LPDSD4201140 lpDS);

file://F:\Oracle\One World\Dev Tools\C Business Functions\Call CLP\calls to an rpg pro...

22/07/2011

ott-99-0063

Page 6 of 8

/***************************************************************************** * Internal Function Prototypes ****************************************************************************/ void rating_and_routing(char *); #endif /* __B4201140_H */

B4201140.c Program
#include <jde.h> #define b4201140_c /***************************************************************************** * Source File: b4201140 * Description: ITLS Interface Source File * History: * Date Programmer SAR# - Description * -------------------------------------------------------* Author 06/04/1997 SB5491937 1632368 - Created * * Copyright (c) J.D. Edwards World Source Company, 1996 * * This unpublished material is proprietary to J.D. Edwards World Source Company.* All rights reserved. The methods and techniques described herein are* considered trade secrets and/or confidential. Reproduction or* distribution, in whole or in part, is forbidden except by express* written permission of J.D. Edwards World Source Company. ****************************************************************************/ /************************************************************************** * Notes: * **************************************************************************/ #include <b4201140.h> /************************************************************************** * Business Function: ITLSInterface * Description: ITLS Interface * Parameters: * LPBHVRCOM lpBhvrCom Business Function Communications * LPVOID lpVoid Void Parameter - DO NOT USE! * LPDSD4201140 lpDS Parameter Data Structure Pointer * *************************************************************************/ #ifdef JDENV_AS400 JDEBFRTN (ID) JDEBFWINAPI ITLSInterface (LPBHVRCOM lpBhvrCom, LPVOID lpVoid,LPDSD4201140 lpDS) { /************************************************************************ * Variable declarations ************************************************************************/ DS_ITLS dsITLS; DSD0000083 dsD0000083; /************************************************************************ * Declare structures ************************************************************************/ /************************************************************************ * Declare pointers ************************************************************************/ /************************************************************************ * Check for NULL pointers ************************************************************************/

if ((lpBhvrCom == (LPBHVRCOM) NULL) || (lpVoid == (LPVOID) NULL) || (lpDS == (LPDSD4201140) NULL)) { jdeErrorSet (lpBhvrCom, lpVoid, (ID) 0, "4363", (LPVOID) NULL); return ER_ERROR; } /************************************************************************

file://F:\Oracle\One World\Dev Tools\C Business Functions\Call CLP\calls to an rpg pro...

22/07/2011

ott-99-0063

Page 7 of 8

* Set pointers ************************************************************************/ /************************************************************************ * Main Processing ************************************************************************/ /* clear the data structure to blanks */ memset ((void *)(&dsITLS), ' ', sizeof(DS_ITLS)); /************************************************************************ * ITLS needs both the Document Number (DOCO) and the AddressNumberShipTo (SHAN) both padded with zeroes to the left * * Format the Order Number to be a string with zeros padding ************************************************************************/ memset ((void *)(&dsD0000083), (int)('\0'), sizeof(DSD0000083)); MathCopy (&dsD0000083.mnMathNumeric, &lpDS->mnDocumentOrderInvoiceE); dsD0000083.nSizeOfString = 9; /* 8 chars */ jdeCallObject("MathNumericToStringZeroPad", NULL,lpBhvrCom, lpVoid,(LPVOID)&dsD0000083, (CALLMAP*)NULL, (int)0,(char*)NULL, (char*)NULL, (int)0); /* Assign the parameters */ memcpy ( dsITLS.sz_doco, dsD0000083.szString,strlen( dsD0000083.szString ) ); /* SHAN */ memset ((void *)(&dsD0000083), (int)('\0'), sizeof(DSD0000083)); MathCopy (&dsD0000083.mnMathNumeric, &lpDS->mnAddressNumberShipTo); dsD0000083.nSizeOfString = 9; /* 8 chars */ jdeCallObject("MathNumericToStringZeroPad", NULL,lpBhvrCom, lpVoid,(LPVOID)&dsD0000083, (CALLMAP*)NULL, (int)0,(char*)NULL, (char*)NULL, (int)0); memcpy ( dsITLS.sz_shan, dsD0000083.szString,strlen( dsD0000083.szString ) ); memcpy ( dsITLS.sz_dcto, lpDS->szOrderType,strlen(lpDS->szOrderType)); memcpy ( dsITLS.sz_kcoo,lpDS->szCompanyKeyOrderNo,strlen(lpDS->szCompanyKeyOrderNo) ); dsITLS.c_act = lpDS->szActionCodesNotAllowed[0]; dsITLS.c_src = lpDS->cEverestEventPoint01; /* assigning zeroes to the decimal item of data structure */ /*memcpy( dsITLS.d_chg,&lpDS->mnChangeFrequency ,strlen(lpDS->mnChangeFrequency) ); */ strcpy ((char *)(dsITLS.sz_d_chg),(const char *)("00000000000")); memcpy ( dsITLS.sz_mpid, lpDS->szProgramId,strlen(lpDS->szProgramId) ); memcpy ( dsITLS.sz_vers, lpDS->szVersion,strlen(lpDS->szVersion) ); system("ADDLIBLE TSMSCONST"); system("ADDLIBLE SM34RL73#"); system("ADDLIBLE SM34DV73PC"); system("ADDLIBLE SM34RL73O"); system("ADDLIBLE SM34RL73D"); system("ADDLIBLE SM34RL73L"); system("ADDLIBLE JDFOBJ73"); system("ADDLIBLE JDFCTL73Q"); system("ADDLIBLE JDFDTA73Q"); /* Call an RPG /400 program */ rating_and_routing( (char *) &dsITLS ); /************************************************************************ * Function Clean Up ************************************************************************/ return (ER_SUCCESS); } #endif /* JDENV_AS400 */ /* Internal function comment block */ /************************************************************************** * Function: Ixxxxxxx_a // Replace "xxxxxxx" with source file number * // and "a" with the function name * Notes: *

file://F:\Oracle\One World\Dev Tools\C Business Functions\Call CLP\calls to an rpg pro...

22/07/2011

ott-99-0063

Page 8 of 8

* Returns: * * Parameters: **************************************************************************/

file://F:\Oracle\One World\Dev Tools\C Business Functions\Call CLP\calls to an rpg pro...

22/07/2011

S-ar putea să vă placă și