JD Edwards

JD Edwards
Lokesh Reddy Blog

Thursday, October 20, 2016

C Business Function For Subsystem Job.



Header File:
/*****************************************************************************
 *    Header File:  B5642pic.h
 *
 *    Description:  Sub System C BSFN Source File
 *
 *        History:
 *          Date        Programmer  SAR# - Description
 *          ----------  ----------  -------------------------------------------
 *   Author 29/09/16    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.
 ****************************************************************************/

#ifndef __B5642PIC_H
#define __B5642PIC_H

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

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

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

/*****************************************************************************
 * DS Template Type Definitions
 ****************************************************************************/
/*****************************************
* TYPEDEF for Data Structure
*    Template Name: Sub System C BSFN
*    Template ID:   D5642PIC
*    Generated:     Mon Oct 10 13:33:09 2016
*
* 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_D5642PIC
#define DATASTRUCTURE_D5642PIC

typedef struct tagDSD5642PIC
{
    MATH_NUMERIC      mnUserReservedAmount;
    MATH_NUMERIC      mnUserReservedNumber;
    JDEDATE           jdUserReservedDate;
    JCHAR             szVersionR5642PIL[11];
    JCHAR             cSubsystemQue;
    JCHAR             cSuppressErrorMessage;
    JCHAR             szErrorMessage[57];
    MATH_NUMERIC      mnWaveID;
    JCHAR             cRegularorSpecialWaveType;
    MATH_NUMERIC      mnNumberOfCases;
    JCHAR             cAutoOrOnDemand;
    JDEDATE           jdDateUpdated;
    MATH_NUMERIC      mnTimeLastUpdated;
} DSD5642PIC, *LPDSD5642PIC;

#define IDERRmnUserReservedAmount_2               2L
#define IDERRmnUserReservedNumber_3               3L
#define IDERRjdUserReservedDate_5                 5L
#define IDERRszVersionR5642PIL_6                  6L
#define IDERRcSubsystemQue_7                      7L
#define IDERRcSuppressErrorMessage_8              8L
#define IDERRszErrorMessage_9                     9L
#define IDERRmnWaveID_12                          12L
#define IDERRcRegularorSpecialWaveType_13         13L
#define IDERRmnNumberOfCases_14                   14L
#define IDERRcAutoOrOnDemand_15                   15L
#define IDERRjdDateUpdated_16                     16L
#define IDERRmnTimeLastUpdated_17                 17L

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

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

#endif    /* __B5642PIC_H */

Source File:
#include <jde.h>

#define b5642pic_c


/*****************************************************************************
 *    Source File:  b5642pic
 *
 *    Description:  Sub System C BSFN Source File
 *
 *        History:
 *          Date        Programmer  SAR# - Description
 *          ----------  ----------  -------------------------------------------
 *   Author 05/10/16    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 <b5642pic.h>


/**************************************************************************
 *  Business Function:  SubSytemJobsCustom
 *
 *        Description:  Sub System Jobs Custom
 *
 *         Parameters:
 *           LPBHVRCOM           lpBhvrCom    Business Function Communications
 *           LPVOID              lpVoid       Void Parameter - DO NOT USE!
 *           LPDSD564            lpDS         Parameter Data Structure Pointer  
 *
 *************************************************************************/

JDEBFRTN (ID) JDEBFWINAPI SubSytemJobsCustom (LPBHVRCOM lpBhvrCom, LPVOID lpVoid, LPDSD5642PIC lpDS) 

{
   /************************************************************************
    *  Variable declarations
    ************************************************************************/
    ID          idReturnValue      = ER_SUCCESS;     /* Return Code  */
    ID          idJDEDBReturn      = JDEDB_PASSED;   /* DB API Return Code */
    ID            idReturnValue2       = ER_SUCCESS;     /* Return Code  */
    HUSER       hUser              = (HUSER) NULL;  
    JCHAR       szErrorID[11]      = _J(" ");                 /* Error Message ID */
   /************************************************************************
    * Declare structures
    ************************************************************************/
    DSRIR5642PIL ds5642pil = {0};  /* Location Selection DS */
   /************************************************************************
    * Declare pointers
    ************************************************************************/

   /************************************************************************
    * Check for NULL pointers
    ************************************************************************/
   if ((lpBhvrCom == (LPBHVRCOM) NULL) ||
       (lpVoid    == (LPVOID)    NULL) ||
       (lpDS      == (LPDSD5642PIC)    NULL))
   {
     jdeErrorSet (lpBhvrCom, lpVoid, (ID) 0, _J("4363"), (LPVOID) NULL);
     return ER_ERROR;
   }
    /************************************************************************
    *Intitialize Behavior Routine
    ************************************************************************/

   idJDEDBReturn = JDB_InitBhvr((void *)lpBhvrCom, &hUser, (JCHAR *) NULL, JDEDB_COMMIT_AUTO);

   if (idJDEDBReturn != JDEDB_PASSED)
   {
       jdeErrorSet(lpBhvrCom, lpVoid, (ID) 0, _J("3143"), (LPVOID) NULL);
       return ER_ERROR;
   }

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

   /************************************************************************
    * Main Processing
    ************************************************************************/
    /* Initialize Error ID to blank */

   jdeStrcpy((JCHAR *)(szErrorID), (const JCHAR *)(_J("    ")));

   if ( lpDS->cSubsystemQue  == _J('2') )
   {
      
      memset((void *)(&ds5642pil),(int)(_J('\0')), sizeof(DSRIR5642PIL));
      MathCopy (&ds5642pil.mnWaveID, &lpDS->mnWaveID);
      MathCopy (&ds5642pil.mnNumberOfCases, &lpDS->mnNumberOfCases);
      ds5642pil.cRegularorSpecialWaveType = lpDS->cRegularorSpecialWaveType;
      ds5642pil.cAutoOrOnDemand = lpDS->cAutoOrOnDemand;
      if ((MathZeroTest(&ds5642pil.mnUserReservedNumber)))
      {
        MathCopy (&ds5642pil.mnUserReservedNumber, &lpDS->mnUserReservedNumber);
      }
      if ((MathZeroTest(&ds5642pil.mnUserReservedAmount)))
      {
        MathCopy (&ds5642pil.mnUserReservedAmount, &lpDS->mnUserReservedAmount);
      }
      MathCopy (&ds5642pil.mnTimeLastUpdated, &lpDS->mnTimeLastUpdated);
      memcpy((void *)(&ds5642pil.jdUserReservedDate),
                (const void *)(&lpDS->jdUserReservedDate),
                sizeof(JDEDATE));
       memcpy((void *)(&ds5642pil.jdDateUpdated),
                (const void *)(&lpDS->jdDateUpdated),
                sizeof(JDEDATE));
       
   
       if (IsStringBlank(lpDS->szVersionR5642PIL))
       {
           jdeStrcpy((JCHAR *) (lpDS->szVersionR5642PIL), (const JCHAR *)(_J("PARSO00001")));
       }

       idReturnValue2 = ubeReport_AddSubsystemRecord (hUser,        /*User Handle*/
                       _J("R5642PIL"),                            /*Name of Subsyste*/
                       lpDS->szVersionR5642PIL,                     /*Subsystem Version (modified 4/17/98)*/
                       NULL,                                /*Name of the Override Envir.  Not used */
                       NULL,                                /*Name of the Server*/
                       &ds5642pil);                            /*Subsystem Connect DS*/
                      
   }

   if(idReturnValue2 == 0)
   {
       idReturnValue = ER_ERROR;
       if (lpDS->cSuppressErrorMessage != _J('1'))
       {
         
           jdeErrorSet(lpBhvrCom, lpVoid, (ID) 0, _J("099R"), (LPVOID) NULL);
           jdeStrcpy((JCHAR *)(lpDS->szErrorMessage), (const JCHAR *)(_J("099R")));
       }
   }

  

   /************************************************************************
    * Function Clean Up
    ************************************************************************/

   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:
 **************************************************************************/


Saturday, October 1, 2016

Business Function For Get Column Value From F03012 By Passing Alias

Description: Get Column Value From F03012 By Passing Alias

Header&Source File:

/*****************************************************************************
 *    Header File:  B5603012.h
 *
 *    Description:  GetColumnValuefromF03012 Header File
 *
 *        History:
 *          Date        Programmer  SAR# - Description
 *          ----------  ----------  -------------------------------------------
 *   Author 26/09/16    Lokesh Vedium      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 __B5603012_H
#define __B5603012_H

/*****************************************************************************
 * Table Header Inclusions
 ****************************************************************************/
 #include <f03012.h>
/*****************************************************************************
 * External Business Function Header Inclusions
 ****************************************************************************/
 #include<b4700220.h>
/*****************************************************************************
 * Global Definitions
 ****************************************************************************/

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

/*****************************************************************************
 * DS Template Type Definitions
 ****************************************************************************/
 /*****************************************
 * TYPEDEF for Data Structure
 *    Template Name: GetColumnValuefromF03012                                   
 *    Template ID:   D5603012
 *    Generated:     Mon Sep 26 20:32:27 2016
 *
 * 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_D5603012
#define DATASTRUCTURE_D5603012

typedef struct tagDSD5603012
{
  JCHAR             szColumnName[11];                   
  MATH_NUMERIC      mnAddressNumber;                    
  JCHAR             szCompany[6];                       
  JCHAR             szColumnValue[37];                  
} DSD5603012, *LPDSD5603012;

#define IDERRszColumnName_1                       1L
#define IDERRmnAddressNumber_2                    2L
#define IDERRszCompany_3                          3L
#define IDERRszColumnValue_4                      4L

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


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

#endif    /* __B5603012_H */

 #include <jde.h>

#define b5603012_c


/*****************************************************************************
 *    Source File:  b5603012
 *
 *    Description:  GetColumnValuefromF03012 Source File
 *
 *        History:
 *          Date        Programmer  SAR# - Description
 *          ----------  ----------  -------------------------------------------
 *   Author 26/09/16    Lokesh Vedium      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 <b5603012.h>


/**************************************************************************
 *  Business Function:  GetColumnValuefromF03012
 *
 *        Description:  Get ColumnValue from F03012
 *
 *         Parameters:
 *           LPBHVRCOM           lpBhvrCom    Business Function Communications
 *           LPVOID              lpVoid       Void Parameter - DO NOT USE!
 *           LPDSD560            lpDS         Parameter Data Structure Pointer  
 *
 *************************************************************************/

JDEBFRTN (ID) JDEBFWINAPI GetColumnValuefromF03012 (LPBHVRCOM lpBhvrCom, LPVOID lpVoid, LPDSD5603012 lpDS) 

{
   /************************************************************************
    *  Variable declarations
    ************************************************************************/
    ID                idReturnCode            = ER_SUCCESS;   
    ID                idJDBReturn             = JDEDB_PASSED;
    ID                  idSelectSuccess          = ER_SUCCESS; 
     HUSER              hUser                = NULL;

    NID                  szTable              =  {0};   
    int               nNumSelect              =  0; 
    ID                idJDEDBResult        = JDEDB_PASSED;
    ID                   idJDEDBReturn = JDEDB_PASSED;
    HREQUEST               hRequestF03012=(HREQUEST)NULL;
   
    ID                idFetchResult        = JDEDB_PASSED;

    JCHAR            cValue            = _J('0');/*Temporary Character Value for Character Format */
    JCHAR            szTempCharValue[2];        /*Temporary Character Value for Character Format */
    JCHAR            szTemporaryValue[100];    /*Temporary Variable for String Format */
    MATH_NUMERIC    mnValue;                /*Temporary Variable for Math Numeric Value */
    JDEDATE            jdValue;                /*Temporary Variable for Date Format*/   
    JCHAR            szFormatMask[]    = _J("OSASR"); /* Format Mask for JDEDATE to string conversion*/
    MATH_NUMERIC    mnTempValue;            /*Temporary Math Numeric Value for Integer Format*/
    int                iValue            = 0;    /*Temporary Integer Value for Integer Format*/   
    ID                idValue            = (ID)NULL;/*Temporary Variable for Long Integer Format */
    long int        iDataItemSize    = 0;
    int                iDataType        = 0;
    int                iValueSize        = 36;/*Size of szAlphaValue */
    short           sNumberOfKeysF4101 = 6;

   /************************************************************************
    * Declare structures
    ************************************************************************/
    DBREF zDbRef = { 0 };
   

    KEY1_F03012        dsF03012Key;
    F03012            dsF03012;
    DSD4700220A        dsGetDataDictionaryInfo;

   /************************************************************************
    * Declare pointers
    ************************************************************************/
    LPVOID            pVoid = (LPVOID)NULL;
    LPCOLINFO        lpCol;
   /************************************************************************
    * Check for NULL pointers
    ************************************************************************/
   if ((lpBhvrCom == (LPBHVRCOM) NULL) ||
       (lpVoid    == (LPVOID)    NULL) ||
       (lpDS      == (LPDSD5603012)    NULL))
   {
     jdeErrorSet (lpBhvrCom, lpVoid, (ID) 0, _J("4363"), (LPVOID) NULL);
     return ER_ERROR;
   }

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

   /************************************************************************
    * Main Processing
    ************************************************************************/
    idJDBReturn = JDB_InitBhvr(lpBhvrCom, &hUser, (JCHAR *)NULL, JDEDB_COMMIT_AUTO);
            if (idJDBReturn != JDEDB_PASSED)
            {
                jdeSetGBRError(lpBhvrCom, lpVoid, (ID) 0, _J("078S"));
                idReturnCode = ER_ERROR;
            }

            memset ((void *) &dsGetDataDictionaryInfo,(int) (_J('\0')), sizeof(DSD4700220A));   
        memset((void *)&zDbRef, (int)_J('\0'), sizeof(zDbRef));
        memset((void *)szTemporaryValue, (int)_J('\0'), sizeof(szTemporaryValue));
        memset((void *)&mnValue, (int)_J('\0'), sizeof(MATH_NUMERIC));
        memset((void *)(&jdValue),(int)(_J('\0')), sizeof(JDEDATE));
        ZeroMathNumeric(&mnTempValue);
           
             idJDEDBResult = JDB_OpenTable (hUser, NID_F03012,
                    ID_F03012_ADDRESS_COMPANY, NULL,
                    (ushort) 0, (JCHAR *) NULL, &hRequestF03012); 

           
              if (idJDBReturn != JDEDB_PASSED)
   {
       idReturnCode = ER_ERROR;
   }
   else
   {
       memset ((void *) &dsF03012Key,(int) (_J('\0')), sizeof(KEY1_F03012));
                /* Load Keys */
        MathCopy (&dsF03012Key.aian8, &lpDS->mnAddressNumber);
        jdeStrcpy((JCHAR *)(dsF03012Key.aico),
             (const JCHAR *)(lpDS->szCompany));

      idFetchResult = JDB_FetchKeyed(hRequestF03012,ID_F03012_ADDRESS_COMPANY,
                                   (void *)(&dsF03012Key),(short)2,
                                   (void *)(&dsF03012), (int)(FALSE));
      jdeNIDcpy( zDbRef.szDict , lpDS->szColumnName);
                        jdeNIDcpy( zDbRef.szTable , _J("F03012") );
                        zDbRef.idInstance = 0L;
                        pVoid = JDB_GetTableColValue( hRequestF03012, zDbRef );
                         if ( pVoid == (LPVOID)NULL )
                        {
                            idJDEDBReturn = JDEDB_FAILED;
                            idReturnCode = ER_ERROR;
                            goto FunctionCleanUp;
                        }
                          else
                 {
                /*Get Data Type information about the DD Item representing the Column passed in*/
            jdeStrcpy ((JCHAR *) dsGetDataDictionaryInfo.szDataItem,
                        (const JCHAR *) (lpDS->szColumnName));
       
            idJDEDBReturn = jdeCallObject(_J("GetDataDictionaryInformation"),
                                         NULL, lpBhvrCom, lpVoid,
                                         &dsGetDataDictionaryInfo,
                                         (CALLMAP *) NULL,(int) 0,
                                         (JCHAR *) NULL, (JCHAR *) NULL,
                                         (int) 0);
            /* Convert Data Item Size to long integer */
            MathNumericToInt(&dsGetDataDictionaryInfo.mnLength,
                             (LPINT)&iDataItemSize);
            iDataItemSize = iDataItemSize * sizeof(JCHAR);
   
            /* Get Data Type Values for correponding fields */
            jdeSscanf(dsGetDataDictionaryInfo.szDataType,_J("%d"),&iDataType);
   
            switch (iDataType)
            {
                case 1 : /* Character Value */
                memcpy((void *)(&cValue), (const void *)pVoid,
                sizeof (JCHAR));
                /* Convert character to string */
                szTempCharValue[0] = cValue;
                szTempCharValue[1] = _J('\0');
                jdeStrncpy((JCHAR *)lpDS->szColumnValue, (const JCHAR *)szTempCharValue,
                iValueSize - 1);
                break;
           
                case 2 :
                case 20 : /* String Value */
                memcpy((void *)szTemporaryValue,
                   (const void *)pVoid, iDataItemSize);
                jdeStrncpy((JCHAR *)lpDS->szColumnValue, (const JCHAR *)szTemporaryValue,
                    iValueSize - 1);
                break;

                case 7 : /* ID */
                memcpy((void*)&idValue,
                   (const void *)pVoid, sizeof (ID));
                /* Convert ID (a long integer) to math numeric and
                * math numeric to string */
                LongToMathNumeric(idValue, &mnTempValue);
                FormatMathNumeric(lpDS->szColumnValue, &mnTempValue);
                break;

                case 9 : /* Math Numeric Value */
                memcpy((void*)&mnValue,
                   (const void *)pVoid, sizeof(MATH_NUMERIC));
       
                /* Convert Math Numeric value to string */
                FormatMathNumeric((PJSTR)lpDS->szColumnValue,
                                (LPMATH_NUMERIC)&mnValue);
                break;

                case 11 : /* JDEDATE */
                memcpy((void*)&jdValue,
                   (const void *)pVoid, sizeof(JDEDATE));
                /* Convert JDEDATE to string */
                FormatDate(lpDS->szColumnValue, &jdValue, szFormatMask);
                break;

                case 15 : /* Integer Value */
                memcpy((void*)&iValue,
                   (const void *)pVoid, sizeof (int));
           
                /* Convert integer to math numeric and
                 * math numeric to string */
                IntToMathNumeric(iValue, &mnTempValue);
                FormatMathNumeric(lpDS->szColumnValue, &mnTempValue);
                break;

            } /* End of the switch construct to get values */
        } /* End if pVoid is not NULL */
    }

    FunctionCleanUp:
   /************************************************************************
    * Function Clean Up
    ************************************************************************/

    JDB_FreeBhvr(hUser);
     if (hRequestF03012 != (HREQUEST)NULL)
    {
        JDB_CloseTable(hRequestF03012);
    }
  
   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:
 **************************************************************************/