JD Edwards Business Service Integration (Part 2-5)

Overview

First of all, we would like to thank everyone for such a wonderful response on our Part-1 for JD Edwards Business Service Integration series, if you haven’t seen it yet Click here to read Part-1. In this part we will continue from where we left off and develop & build our business function. We will be specifically looking at the JD Edwards XRCS API for the manipulation of XML communication packet and then finally use the jdeCallBusinessService() API call to invoke our business service. In the final step we are going to build our business function to ensure that there are no anomalies.

 

What is covered  in Part-2

In Part-2 of this series, we will talk about

Designing our Business Function

We will use the P9862 application to design our Business Function.

JDE Business Function Design P9862
JDE Business Function Design P9862

Business Function Source Code using Visual Studio 2005

Next we will take a detailed walk through of the entire source code inside Visual Studio 2005.

JD Edwards Business Function Visual Studio 2005
JD Edwards Business Function Visual Studio 2005

Building our Business Function

Then we will take a look at how to build our business function using the busbuild utility.

JDE Build Business Function BusBuild
JDE Build Business Function BusBuild

Download Source Code to Presentation

Download the Source Code here (C File) (H File).

C-File

#include <jde.h>#define b55v002_c/*****************************************************************************
* Source File: b55v002
*
* Description: UK Address Verification Business Service Source File
*
* History:
* Date Programmer SAR# – Description
* ———- ———- ——————————————-
* Author 6/7/2013 Saad Faisal Unknown – Created by Ephlux Pvt Ltd. (c) 2013 (http://blog.ephlux.com)
*
* 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 <b55v002.h>//#define MODE_LIVE 1
#define MODE_TEST 1/**************************************************************************
* Business Function: VerifyUKAddressService
*
* Description: Verify UK Address
*
* Parameters:
* LPBHVRCOM lpBhvrCom Business Function Communications
* LPVOID lpVoid Void Parameter – DO NOT USE!
* LPDSD55V lpDS Parameter Data Structure Pointer
*
*************************************************************************/
JDEBFRTN (ID) JDEBFWINAPI VerifyUKAddressService (LPBHVRCOM lpBhvrCom, LPVOID lpVoid, LPDSD55V002 lpDS)
{
#ifdef SOA_ENABLED
/************************************************************************
* Variable declarations
************************************************************************/
XRCS_hParser hParser = NULL;
XRCS_Status XRCSStatus = XRCS_SUCCESS;
XRCS_hDocument hDoc = NULL;
XRCS_hDocument hBSSVDoc = NULL;
XRCS_hElement hRootElm = NULL; XRCS_hElement *hElm = NULL;
unsigned int nElmCount = 0;
XRCS_hElement *hChildElms = NULL;
unsigned int nChildCount = 0;
JCHAR *elmName = NULL;
JCHAR *elmValue = NULL;
unsigned int i = 0;
ID idReturnValue = ER_SUCCESS;
JCHAR *bssvPayloadReturn = NULL;
JCHAR *newXMLString = NULL;
JCHAR *errorText = NULL;
JCHAR *xmlString =
_J(“<?xml version=\”1.0\”?>”)
_J(“<validate-address-vO>”)
_J(“<sz-county></sz-county>”)
_J(“<sz-post-code></sz-post-code>”)
_J(“<sz-town-name></sz-town-name>”)
_J(“<sz-response></sz-response>”)
_J(“</validate-address-vO>”);
//<?xml version=”1.0″ encoding=”UTF-8″?>
//<validate-address-vO><sz-county></sz-county><sz-town-name></sz-town-name><sz-post-code></sz-post-code><sz-response></sz-response></validate-address-vO>
/************************************************************************
* Declare structures
************************************************************************/
DSDE954000 dsDE954000 = {0};
/************************************************************************
* Declare pointers
************************************************************************/
/************************************************************************
* Check for NULL pointers
************************************************************************/
if ((lpBhvrCom == (LPBHVRCOM) NULL) ||
(lpVoid == (LPVOID) NULL) ||
(lpDS == (LPDSD55V002) NULL))
{
jdeErrorSet (lpBhvrCom, lpVoid, (ID) 0, _J(“4363”), (LPVOID) NULL);
return ER_ERROR;
}
/************************************************************************
* Set pointers
************************************************************************/
/************************************************************************
* Main Processing
************************************************************************/
/* Initialize Xerces Engine */
XRCSStatus = XRCS_initEngine();
if(XRCSStatus != XRCS_SUCCESS) {
jdeVWriteLogEntry(_J(“B55V0001”), __FILE__, __LINE__, 0, _J(“XRCS_initEngine failed”));
return ER_ERROR;
}
/* Get the Xerces Parser */
XRCSStatus = XRCS_getParser(&hParser);
if(XRCSStatus != XRCS_SUCCESS)
{
jdeVWriteLogEntry(_J(“B55V002”), __FILE__, __LINE__, 0, _J(“XRCS_getParser failed”));
XRCS_terminateEngine();
return ER_ERROR;
}
/* Parse the XML String */
XRCSStatus = XRCS_parseXMLString(hParser, xmlString, &hDoc);
if(XRCSStatus != XRCS_SUCCESS)
{
jdeVWriteLogEntry(_J(“B55V002”), __FILE__, __LINE__, 0, _J(“XRCS_parseXMLString failed”));
XRCS_freeParser(hParser);
XRCS_terminateEngine();
return ER_ERROR;
}
/* Get Root Element */
XRCSStatus = XRCS_getDocumentElement(hDoc,&hRootElm);
if(XRCSStatus != XRCS_SUCCESS)
{
jdeVWriteLogEntry(_J(“B55V002”), __FILE__, __LINE__, 0, _J(“XRCS_getDocumentElement failed”));
XRCS_freeParser(hParser);
XRCS_freeDocument(hDoc);
XRCS_terminateEngine();
return ER_ERROR;
}
/* Set the Town Name to as it is passed by user */
XRCSStatus = XRCS_getElementsByTagName(hRootElm, _J(“sz-town-name”), &hElm,&nElmCount);
if(XRCSStatus != XRCS_SUCCESS)
{
jdeVWriteLogEntry(_J(“B55V002”), __FILE__, __LINE__, 0, _J(“XRCS_getElementsByTagName failed”));
XRCS_freeParser(hParser);
XRCS_freeDocument(hDoc);
XRCS_freeElement(hRootElm);
XRCS_terminateEngine();
return ER_ERROR;
}
XRCSStatus = XRCS_setElementText(hElm[0], lpDS->szTownName);
if(XRCSStatus != XRCS_SUCCESS)
{
jdeVWriteLogEntry(_J(“B55V002”), __FILE__, __LINE__, 0, _J(“XRCS_setElementText failed”));
XRCS_freeParser(hParser);
XRCS_freeDocument(hDoc);
XRCS_freeElement(hRootElm);
XRCS_freeElementArray(hElm,nElmCount);
XRCS_terminateEngine();
return ER_ERROR;
}
/* Serialize the XML DOC to XML String */
XRCSStatus = XRCS_serializeDocumentToXMLStringNoEncoding(hDoc, &newXMLString);
if(XRCSStatus != XRCS_SUCCESS)
{
jdeVWriteLogEntry(_J(“B55V002”), __FILE__, __LINE__, 0, _J(“XRCS_serializeDocumentToXMLStringNoEncoding failed”));
XRCS_freeParser(hParser);
XRCS_freeDocument(hDoc);
XRCS_freeElement(hRootElm);
XRCS_freeElementArray(hElm,nElmCount);
XRCS_terminateEngine();
return ER_ERROR;
}
#ifdef MODE_LIVE
/* call the Business Service */
idReturnValue = jdeCallBusinessService(lpBhvrCom,
lpVoid,
_J(“oracle.e1.bssv.J55V002.ValidateUKAddress”),
_J(“getValidateAddress”),
TRUE,
newXMLString,
&bssvPayloadReturn);
if ( idReturnValue == CallBSSVNoError || idReturnValue == CallBSSVNoErrorWithMessages)
{
XRCSStatus = XRCS_parseXMLStringRemoveEncoding(hParser, bssvPayloadReturn, &hBSSVDoc);
if(XRCSStatus != XRCS_SUCCESS) {
jdeVWriteLogEntry(_J(“B55V002”), __FILE__, __LINE__, 0, _J(“XRCS_parseXMLStringRemoveEncoding failed”));
XRCS_freeParser(hParser);
XRCS_freeDocument(hDoc);
XRCS_freeElement(hRootElm);
XRCS_freeElementArray(hElm,nElmCount);
XRCS_terminateEngine();
jdeFree(newXMLString);
jdeFreeBSSVPayloadReturn (&bssvPayloadReturn);
return ER_ERROR;
}
XRCSStatus = XRCS_getDocumentElement(hBSSVDoc,&hRootElm);
if(XRCSStatus != XRCS_SUCCESS)
{
jdeVWriteLogEntry(_J(“B55V002”), __FILE__, __LINE__, 0, _J(“XRCS_getDocumentElement failed”));
XRCS_freeParser(hParser);
XRCS_freeDocument(hDoc);
XRCS_freeElementArray(hElm,nElmCount);
XRCS_freeDocument(hBSSVDoc);
XRCS_terminateEngine();
jdeFree(newXMLString);
jdeFreeBSSVPayloadReturn (&bssvPayloadReturn);
return ER_ERROR;
}
XRCSStatus = XRCS_getElementChildren(hRootElm,&hChildElms,&nChildCount);
if(XRCSStatus != XRCS_SUCCESS)
{
jdeVWriteLogEntry(_J(“B55V002”), __FILE__, __LINE__, 0, _J(“XRCS_getElementChildren failed”));
XRCS_freeParser(hParser);
XRCS_freeDocument(hDoc);
XRCS_freeElementArray(hElm,nElmCount);
XRCS_freeDocument(hBSSVDoc);
XRCS_freeElement(hRootElm);
XRCS_terminateEngine();
jdeFree(newXMLString);
jdeFreeBSSVPayloadReturn (&bssvPayloadReturn);
return ER_ERROR;
}
for ( i=0;i<nChildCount;i++)
{
XRCSStatus = XRCS_getElementName(hChildElms[i],&elmName);
if(XRCSStatus != XRCS_SUCCESS)
{
jdeVWriteLogEntry(_J(“B55V002”), __FILE__, __LINE__, 0, _J(“XRCS_getElementName failed”));
XRCS_freeParser(hParser);
XRCS_freeDocument(hDoc);
XRCS_freeElementArray(hElm,nElmCount);
XRCS_freeDocument(hBSSVDoc);
XRCS_freeElement(hRootElm);
XRCS_freeElementArray(hChildElms,nChildCount);
XRCS_terminateEngine();
jdeFree(newXMLString);
jdeFreeBSSVPayloadReturn (&bssvPayloadReturn);
return ER_ERROR;
}
XRCSStatus = XRCS_getElementText(hChildElms[i],&elmValue);
if(XRCSStatus != XRCS_SUCCESS)
{
jdeVWriteLogEntry(_J(“B55V002”), __FILE__, __LINE__, 0, _J(“XRCS_getElementText failed”));
XRCS_freeParser(hParser);
XRCS_freeDocument(hDoc);
XRCS_freeElementArray(hElm,nElmCount);
XRCS_freeDocument(hBSSVDoc);
XRCS_freeElement(hRootElm);
XRCS_freeElementArray(hChildElms,nChildCount);
XRCS_terminateEngine();
XRCS_freeString(elmName);
jdeFree(newXMLString);
jdeFreeBSSVPayloadReturn (&bssvPayloadReturn);
return ER_ERROR;
}
if ( (JCHAR*)NULL != elmValue)
{
if (jdeStricmp(elmName,_J(“sz-response”))==0) {
jdeStrncpyTerminate(lpDS->szResponse, elmValue, DIM(lpDS->szResponse));
}
else if (jdeStricmp(elmName,_J(“sz-county-name”))==0) {
jdeStrncpyTerminate((JCHAR *)lpDS->szCounty, elmValue, DIM(lpDS->szCounty));
}
else if (jdeStricmp(elmName,_J(“sz-post-code”))==0) {
jdeStrncpyTerminate((JCHAR *)lpDS->szPostCode, elmValue, DIM(lpDS->szPostCode));
}
XRCS_freeString(elmName);
XRCS_freeString(elmValue);
elmName = (JCHAR*)NULL;
elmValue = (JCHAR*)NULL;
}
} /*end of for loop*/
}
else
{
memset((void *)(&dsDE954000), (int)(_J(”)), sizeof(dsDE954000));
errorText = jdeGetBusinessServiceErrorText(idReturnValue);
jdeVWriteLogEntry(_J(“B55V002”), __FILE__, __LINE__, 0,errorText);
jdeStrncpy(dsDE954000.szWSCallExceptionInfo, errorText , DIM(dsDE954000.szWSCallExceptionInfo));
jdeSetGBRErrorSubText(lpBhvrCom, lpVoid, (ID) 0, _J(“007FIS”), &dsDE954000);
XRCS_freeParser(hParser);
XRCS_freeDocument(hDoc);
XRCS_freeElement(hRootElm);
XRCS_freeElementArray(hElm,nElmCount);
XRCS_terminateEngine();
jdeFree(newXMLString); jdeFreeBSSVPayloadReturn (&bssvPayloadReturn);
return ER_ERROR;
}
#endif
#ifdef MODE_TEST
jdeStrncpyTerminate(lpDS->szResponse, _J(“TEST_SUCCESS!!”), DIM(lpDS->szResponse));
jdeStrncpyTerminate(lpDS->szCounty, _J(“TEST_COUNTY”), DIM(lpDS->szCounty));
jdeStrncpyTerminate(lpDS->szPostCode, _J(“TEST_POSTCODE”), DIM(lpDS->szPostCode));
#endif
/************************************************************************
* Function Clean Up
************************************************************************/
XRCS_freeParser(hParser);
XRCS_freeDocument(hDoc);
XRCS_freeElementArray(hElm,nElmCount);
XRCS_freeDocument(hBSSVDoc);
XRCS_freeElement(hRootElm);
XRCS_freeElementArray(hChildElms,nChildCount);
XRCS_terminateEngine();
jdeFree(newXMLString);
jdeFreeBSSVPayloadReturn (&bssvPayloadReturn);
#else
jdeTraceSz(NULL, _J(“B55V002 – VerifyUKAddress() called but system does not have SOA_ENABLED defined.”));
#endif
return (ER_SUCCESS);
}
/* Internal function comment block */
/**************************************************************************
* Function: Ixxxxxxx_a // Replace “xxxxxxx” with source file number
* // and “a” with the function name
* Notes:
*
* Returns:
*
* Parameters:
**************************************************************************/

 

H-File

/*****************************************************************************
* Header File: B55V002.h
*
* Description: UK Address Verification Business Service Header File
*
* History:
* Date Programmer SAR# – Description
* ———- ———- ——————————————-
* Author 6/7/2013 Saad Faisal Unknown – Created by Ephlux Pvt Ltd. (c) 2013 (http://blog.ephlux.com)
*
*
* 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.
****************************************************************************/
#ifndef __B55V002_H
#define __B55V002_H
/*****************************************************************************
* Table Header Inclusions
****************************************************************************/
/*****************************************************************************
* External Business Function Header Inclusions
****************************************************************************/
#include <xerceswrapper.h>
/*****************************************************************************
* Global Definitions
****************************************************************************/
/*****************************************************************************
* Structure Definitions
****************************************************************************/
/*****************************************************************************
* DS Template Type Definitions
****************************************************************************/
/*****************************************
* TYPEDEF for Data Structure
* Template Name: UK Address Verification DS
* Template ID: D55V002
* Generated: Fri Jun 07 22:19:39 2013
*
* DO NOT EDIT THE FOLLOWING TYPEDEF
* To make modifications, use the OneWorld Data Structure
* Tool to Generate a revised version, and paste from
* the clipboard.
*
**************************************/
#ifndef DATASTRUCTURE_D55V002
#define DATASTRUCTURE_D55V002
typedef struct tagDSD55V002
{
JCHAR szTownName[101];
JCHAR szResponse[101];
JCHAR szCounty[101];
JCHAR szPostCode[101];
} DSD55V002, *LPDSD55V002;
#define IDERRszTownName_1 1L
#define IDERRszResponse_2 2L
#define IDERRszCounty_3 3L
#define IDERRszPostCode_4 4L
#endif
/*****************************************
* TYPEDEF for Data Structure
* Template Name: Error Text For WS Reference Implementation
* Template ID: DE954000
* Generated: Thu May 24 13:16:20 2007
*
* DO NOT EDIT THE FOLLOWING TYPEDEF
* To make modifications, use the OneWorld Data Structure
* Tool to Generate a revised version, and paste from
* the clipboard.
*
**************************************/
#ifndef DATASTRUCTURE_DE954000
#define DATASTRUCTURE_DE954000
typedef struct tagDSDE954000
{
JCHAR szWSCallExceptionInfo[1025];
} DSDE954000, *LPDSDE954000;
#define IDERRszWSCallExceptionInfo_2 2L
#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 VerifyUKAddressService (LPBHVRCOM lpBhvrCom, LPVOID lpVoid, LPDSD55V002 lpDS);
/*****************************************************************************
* Internal Function Prototypes
****************************************************************************/
#endif /* __B55V002_H */

If you would like to discuss some specific needs for JD Edwards Integration OR would like to schedule a LIVE JD Edwards BSSV training online, feel free to reach out our lead consultant by filling the form below:
[contact-form-7 404 "Not Found"]


In Part-3 of this training series we will continue from where we left off and begin our development for our Business Service so stay tuned and I will see you in the next video.


Update: JD Edwards E1 BSSV Integration Training finally launched

Over the past 2 years we have been constantly approached by many seasoned, mid-level and fresh JD Edwards consultants alike to provide BSSV Training to help them integrate JD Edwards E1 to 3rd party applications, enterprise cloud apps, mobile apps and social channels.
We are glad to finally announce the launch of “JD Edwards Business Services (BSSV) Integration Training”. Find more details and register here: JD Edwards E1 BSSV Integration Training Registration
 



1 Comment

  • You guys are doing a good job with this. It’s a great start for someone like me who’s had many years of JDE experience but is totally new in to XML and Webservices world.

Leave a Reply to Andy Cancel reply