JD Edwards

JD Edwards
Lokesh Reddy Blog

Friday, May 15, 2015

Launch UBE For SynchronousAsynchronous

 Business Function : Launch R5942004 With Report Interconnects Header File
  This business function is used to run the specified UBE by either Synchronous or Asynchronous.
/*****************************************************************************
 *    Header File:  B5942004.h
 *
 *    Description:  Launch R5942004 With Report Interconnects Header File
 *
 *        History:
 *          Date        Programmer  SAR# - Description
 *          ----------  ----------  -------------------------------------------
 *   Author 2/2/2015      Lokesh      Unknown  - 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.
 ****************************************************************************/

#ifndef __B5942004_H
#define __B5942004_H

/*****************************************************************************
 * Table Header Inclusions
 ****************************************************************************/
 #include <R5942004.h>
/*****************************************************************************
 * External Business Function Header Inclusions
 ****************************************************************************/

/*****************************************************************************
 * Global Definitions
 ****************************************************************************/

/*****************************************************************************
 * Structure Definitions
 ****************************************************************************/

/*****************************************************************************
 * DS Template Type Definitions
 ****************************************************************************/
 /*****************************************
 * TYPEDEF for Data Structure
 *    Template Name: Data Structure for B5942004                                
 *    Template ID:   D5942004A
 *    Generated:     Tue Feb 2 09:59:58 2015
 *
 * 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_D5942004A
#define DATASTRUCTURE_D5942004A

typedef struct tagDSD5942004A
{
  MATH_NUMERIC      mnLoadNumber_LDNM;                  
  JCHAR             szLoadDepot_VMCU[13];               
  JCHAR             szVersion[11];                      
  JCHAR             cSyncFlag01_EV01;                   
  JCHAR             cErrorCode_ERRC;                    
} DSD5942004A, *LPDSD5942004A;

#define IDERRmnLoadNumber_LDNM_1                  1L
#define IDERRszLoadDepot_VMCU_2                   2L
#define IDERRszVersion_3                          3L
#define IDERRcSyncFlag01_EV01_4                   4L
#define IDERRcErrorCode_ERRC_5                    5L

#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 LaunchR5942004WithReportIntercon (LPBHVRCOM lpBhvrCom, LPVOID lpVoid, LPDSD5942004A lpDS);


/*****************************************************************************
 * Internal Function Prototypes
 ****************************************************************************/

#endif    /* __B5942004_H */


#include <jde.h>

#define b5942004_c


/*****************************************************************************
 *    Source File:  b5942004
 *
 *    Description:  Launch R5942004 With Report Interconnects Source File
 *
 *        History:
 *          Date        Programmer  SAR# - Description
 *          ----------  ----------  -------------------------------------------
 *   Author 2/2/2015   Unkno       Unknown  - 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 <b5942004.h>


/**************************************************************************
 *  Business Function:  LaunchR5942004WithReportIntercon
 *
 *        Description:  Launch R5942004 With Report Interconnects
 *
 *         Parameters:
 *           LPBHVRCOM           lpBhvrCom    Business Function Communications
 *           LPVOID              lpVoid       Void Parameter - DO NOT USE!
 *           LPDSD5842           lpDS         Parameter Data Structure Pointer  
 *
 *************************************************************************/

JDEBFRTN (ID) JDEBFWINAPI LaunchR5942004WithReportIntercon (LPBHVRCOM lpBhvrCom, LPVOID lpVoid, LPDSD5942004A lpDS) 

{
   /************************************************************************
    *  Variable declarations
    ************************************************************************/
      JCHAR                   szEnvironmentName[11];
    JCHAR                   szLocalComputerName[16];
    HUSER                    hUser                        = (HUSER)   NULL;
    PUBEVAR                    pUBEVar                       = (PUBEVAR) NULL;
    ID                        idJDBReturn                    = JDEDB_PASSED;
    BOOL                    bReportSuccess                = FALSE;
    ID                        idReturnValue                = ER_SUCCESS;
   /************************************************************************
    * Declare structures
    ************************************************************************/
     DSRIR5942004                ds5942004;  
   /************************************************************************
    * Declare pointers
    ************************************************************************/

   /************************************************************************
    * Check for NULL pointers
    ************************************************************************/
   if ((lpBhvrCom == (LPBHVRCOM) NULL) ||
       (lpVoid    == (LPVOID)    NULL) ||
       (lpDS      == (LPDSD5942004A)    NULL))
   {
     jdeErrorSet (lpBhvrCom, lpVoid, (ID) 0, _J("4363"), (LPVOID) NULL);
     return ER_ERROR;
   }
    
   idJDBReturn = JDB_InitBhvr(lpBhvrCom, &hUser, (JCHAR *)NULL,
                              JDEDB_COMMIT_AUTO);  

   if (idJDBReturn == JDEDB_FAILED)
   {
      jdeSetGBRError(lpBhvrCom, lpVoid, (ID)0, _J("3143"));
      return ER_ERROR;
   }

   /************************************************************************
    * Set pointers
    ************************************************************************/

   /************************************************************************
    * Main Processing
    ************************************************************************/

    /* Retrieve Computer Information */
    jdeGetHostName(szLocalComputerName, DIM(szLocalComputerName), (int) 0);
    GetLocalEnvironmentName(szEnvironmentName, sizeof(szEnvironmentName));
   
    /* Allocate memory */
    pUBEVar = jdeAlloc(COMMON_POOL, sizeof(struct tagUBEVAR),MEM_ZEROINIT);

    if (pUBEVar != (PUBEVAR)NULL)
    {
        memset((void *)pUBEVar, (int)_J('\0'), sizeof(pUBEVar));

        /* Load UBE Structure */

        pUBEVar->bPreview = TRUE;
        jdeNIDcpy((JCHAR *)pUBEVar->szReport,(const JCHAR *)_J("R5942004"));

        if (IsStringBlank(lpDS->szVersion))
        {
            memcpy((void *)(pUBEVar->szVersion), (const JCHAR *) _J("TEST0001"),
                    sizeof(pUBEVar->szVersion));
        }
        else
        {
            memcpy((void *)(&pUBEVar->szVersion), (const JCHAR *) &lpDS->szVersion,
                    sizeof(pUBEVar->szVersion));
        }

        memcpy((void *)(&pUBEVar->szMachineKey), (const JCHAR *) &szLocalComputerName,
                    sizeof(pUBEVar->szMachineKey));
        memcpy((void *)(&pUBEVar->szEnhv), (const JCHAR *) &szEnvironmentName,
                    sizeof(pUBEVar->szEnhv));
       

       
      /* If cXMLFlag is equal to 1, run Asynch, otherwise run Synch  */
          if (lpDS->cSyncFlag01_EV01 == _J('1'))
          {   
            /* Run the UBE Synchronously */
              pUBEVar->bSynchFlag    = TRUE;
          }
          else
          {
                /* Run the UBE Asynchronously */
                pUBEVar->bSynchFlag    = FALSE; 
          }   
        /* Run the UBE Asynchronously */
        //pUBEVar->bSynchFlag = FALSE;  

        /* Run the UBE in Batch Mode */
        pUBEVar->bBatchFlag = TRUE;

        /* Load R5942004 Structure */
        memset((void *)&ds5942004, (int)_J('\0'), sizeof(ds5942004));

        MathCopy(&ds5942004.mnLoadNumber1_LDNM, &lpDS->mnLoadNumber_LDNM);
        memcpy((void *)(&ds5942004.szCostCenterTrip1_VMCU), (const JCHAR *) &lpDS->szLoadDepot_VMCU,
                    sizeof(ds5942004.szCostCenterTrip1_VMCU));
       
        /* Launch the UBE */
        bReportSuccess = jdeLaunchUBEEx((HUSER)hUser, (PUBEVAR)pUBEVar, (LPVOID)&ds5942004, lpBhvrCom);

        if (!bReportSuccess)
        {
         jdeSetGBRError(lpBhvrCom, lpVoid, (ID)0, _J("017H"));
         idReturnValue = ER_ERROR;
         lpDS->cErrorCode_ERRC = _J('1');
        }
    }


   /************************************************************************
    * Function Clean Up
    ************************************************************************/
    if (pUBEVar != (PUBEVAR)NULL)
    {
        jdeFree((LPVOID)pUBEVar);
    }

    if (hUser)
    {
        JDB_FreeBhvr(hUser);
    }
    return (idReturnValue); 
}

/* Internal function comment block */
/**************************************************************************
 *   Function:  Ixxxxxxx_a   // Replace "xxxxxxx" with source file number
 *                           // and "a" with the function name
 *      Notes:
 *
 *    Returns:
 *
 * Parameters:
 **************************************************************************/

No comments:

Post a Comment