Media Object convert string to binary blob

clmates

Reputable Poster
Hi To all

We are upgrading from XE to 9.1, just have finished the retrofit and I'm validating the custom developments

I have a customization of R42565 that calls a NER bsfn that adds a new line to the SO with an fixed item and then add an small text attachment

on XE we handled this with a direct insert in F00165 giving the kely to the new SO line, the text and the text lenght

Now in 9.1 I see that the string that holds the text has changed form an string to a binary blob

the problem is that i build the attached text with the use of several concat functions and now I find that the concat function do not work on the TXFT data type as it is a binary blob

I also tried to make all the string and then convert it to a binary blob, but I cant find how

and now here are the questions.

1. Is there any way or any standard function that I can use to conver an string to a binary blob valid for direct insertion in F00165 as a standard text without any kind of format

2 or is there any standard function to concatenate strings directly in a binary blob?

PS: I also tried to build my own bsfn , but jdestrcat dont work also on binary blob, should I use jdememcat for this? or is there any easier way?

Many Thanks
 
Writing directly to F00165 is not really the correct way to handle inserting attachments. Actually, I would argue that it really wasn't correct to do this in Xe either. Instead of trying to figure out the BLOB format and doing table I/O use the ER system functions for attachments or the myriad of C API calls to work with attachments.
 
This function is used to clear GT objects, but it could be changed to insert new text. Note that 'update' is actually update/add.


<font class="small">Code:</font><hr /><pre> JDEBFRTN (ID) JDEBFWINAPI ClearGTText (LPBHVRCOM lpBhvrCom, LPVOID lpVoid, LPDSD5700020C lpDS)

{
/************************************************************************
* Variable declarations
************************************************************************/

/************************************************************************
* Declare structures
************************************************************************/

/************************************************************************
* Declare pointers
************************************************************************/
JDEDB_RESULT eJDEDBResult = JDEDB_PASSED;
MOKEYDATA pMOKeyData = {0};
MOF00165 pMOData = {0};
JCHAR szLang[] = _J(" ");

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

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

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


/** Fetch the Code Page Text **/
pMOKeyData.pszDataSource = NULL;
pMOKeyData.pszObjectName = (JCHAR*)lpDS->szFromNameObject;
pMOKeyData.nMOType = OBJ_RTFTEXT;
pMOKeyData.pszLanguage = szLang;
pMOKeyData.nSeq = lpDS->nFromSequenceNumber;

pMOData.nSeq = lpDS->nFromSequenceNumber;
pMOData.nMOType = OBJ_RTFTEXT;


pMOData.bRTFData = 0;
jdeStrncpyTerminate( pMOData.szItemName , lpDS->szGenericTextItemName ,DIM( pMOData.szItemName ) );

pMOData.pData = (void*)szLang;


eJDEDBResult = JDEGTUpdateF00165WithKeyStr( &pMOKeyData,
(JCHAR*)lpDS->szFromGenericTextKey,
&pMOData,
1);



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

return (ER_SUCCESS);
} </pre><hr />
 
Use B90CA892 to write Media attachments in F00165.
This will make appropriate entries.
No need to Re engineer.
 
Use BSFN B90CA892 to insert records in media attachment file F00165.
No need to re engineer.
 
Hi WhippingBoy

Thanks for the info

At last I used the api, but not at low level like you, I followed the example on Doc ID 639974.1 and also on bsfn B3101930 - GT4311 Insert Generic Text

and created my own insert on GT4211A

here it is, maybe it is useful for others




***************** start of .c *********************

#include <jde.h>

#define b5600001


/*****************************************************************************
* Source File: B5600002
*
* Description: Funciones de Fundamentos Comunes
*
* History:
* Date Programmer SAR# - Description
* ---------- ---------- -------------------------------------------
* 18/09/2013 C. Lorenzo TRID-2161 Retrofit 9.1
*
* Copyright (c) SUMTEC, S.L. 2013
*
* This unpublished material is proprietary to SUMTEC, S.L.
* 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 SUMTEC, S.L.
****************************************************************************/
/**************************************************************************
* Notes:
*
**************************************************************************/

#include <b5600001.h>


/**************************************************************************
* Business Function: InsertaTextoenGT4211A
*
* Description: Inserta Texto en Media Object GT4211A
*
* Parameters:
* LPBHVRCOM lpBhvrCom Business Function Communications
* LPVOID lpVoid Void Parameter - DO NOT USE!
* LPDSD5600002 lpDS Parameter Data Structure Pointer
*
*************************************************************************/

JDEBFRTN (ID) JDEBFWINAPI InsertaTextoenGT4211A (
LPBHVRCOM lpBhvrCom,
LPVOID lpVoid,
LPDSD5600002 lpDS
)

{
/************************************************************************
* Variable declarations
************************************************************************/
ID idJDEDBReturn = JDEDB_PASSED; /* DB API Return Code */
HUSER hUser = (HUSER)NULL;


/************************************************************************
* Declare structures
************************************************************************/

DSGT4211A ClaveMediaObject = {0};


/************************************************************************
* Declare pointers
************************************************************************/


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

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

/************************************************************************
* Initialize Behavior Routine
************************************************************************/
idJDEDBReturn = JDB_InitBhvr(
(void *)lpBhvrCom,
&hUser,
(JCHAR *) NULL,
JDEDB_COMMIT_AUTO
);

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

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

// Preparo la clave en la estructura

MathCopy(&ClaveMediaObject.mnLinenumber, &lpDS->Linea_LNID);
MathCopy(&ClaveMediaObject.mnSalesOrderNumber, &lpDS->NumeroPedido_DOCO);
jdeStrncpy(ClaveMediaObject.szSalesOrderkeyCompany, lpDS->Compania_KCOO, DIM(ClaveMediaObject.szSalesOrderkeyCompany)-1);
jdeStrncpy(ClaveMediaObject.szSalesOrdertype, lpDS->TipoPedido_DCTO, DIM(ClaveMediaObject.szSalesOrdertype)-1);

// Inserto el media Object

ModifyGenericText(_J("GT4211A"), 0, &ClaveMediaObject, lpDS->Texto_LNGTEXT);


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

return (ER_SUCCESS);
}

************************* END of .c **************************



****************** start of .h ******************

/*****************************************************************************
* Header File: B5600001.h
*
* Description: Funciones de Fundamentos Comunes
*
* History:
* Date Programmer SAR# - Description
* ---------- ---------- -------------------------------------------
* 18/09/2013 C. Lorenzo TRID-2161 Retrofit 9.1
*
*
* Copyright (c) SUMTEC, S.L. 2013
*
* This unpublished material is proprietary to SUMTEC, S.L.
* 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 SUMTEC, S.L.
****************************************************************************/

#ifndef __B5600001_H
#define __B5600001_H


/**
* TYPEDEF for Data Structure
* D5600002 : Inserta Texto en media Object GT4211A
*
* Copyright Oracle USA
*
* This is a JDEdwards EnterpriseOne generated file.
* Do not modify this file.
* Only re-generate with the appropriate tool.
* Generation Date : 19/09/2013
*/

#ifndef DATASTRUCTURE_D5600002
#define DATASTRUCTURE_D5600002

typedef struct tagDSD5600002
{
JCHAR Compania_KCOO[6];
JCHAR TipoPedido_DCTO[3];
MATH_NUMERIC NumeroPedido_DOCO;
MATH_NUMERIC Linea_LNID;
JCHAR Texto_LNGTEXT[50001];
} DSD5600002 , *LPDSD5600002;

#define IDERRCompania_KCOO_4 4L
#define IDERRTipoPedido_DCTO_5 5L
#define IDERRNumeroPedido_DOCO_6 6L
#define IDERRLinea_LNID_7 7L
#define IDERRTexto_LNGTEXT_9 9L

#endif /* DATASTRUCTURE_D5600002 */


/**
* TYPEDEF for Data Structure
* GT4211A :
*
* Copyright Oracle USA
*
* This is a JDEdwards EnterpriseOne generated file.
* Do not modify this file.
* Only re-generate with the appropriate tool.
* Generation Date : 19/09/2013
*/

#ifndef DATASTRUCTURE_GT4211A
#define DATASTRUCTURE_GT4211A

typedef struct tagDSGT4211A
{
MATH_NUMERIC mnSalesOrderNumber;
JCHAR szSalesOrdertype[3];
JCHAR szSalesOrderkeyCompany[6];
MATH_NUMERIC mnLinenumber;
} DSGT4211A , *LPDSGT4211A;

#define IDERRmnSalesOrderNumber_1 1L
#define IDERRszSalesOrdertype_2 2L
#define IDERRszSalesOrderkeyCompany_3 3L
#define IDERRmnLinenumber_4 4L

#endif /* DATASTRUCTURE_GT4211A */



/*****************************************************************************
* 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 InsertaTextoenGT4211A (LPBHVRCOM lpBhvrCom, LPVOID lpVoid, LPDSD5600002 lpDS);

#endif /* B5600002.h */


********************** end of .h ********************


Best Regards
 
ModifyGenericText doesn't let you deal with sequence numbers, or note names directly. My project had that requirement for add/update/delete against F00165.
 
Hi WhippingBoy

yes, your solution is by far more complete, could also work vs any media object , mine is fixed for F4211, but was what I needed.

I had a development in XE that on R42565 we call a custom bsfn to apply transportation charges, and this creates a new invoice with the costs, so I need to create a new SO and add a line with an attached text in order to specify there the VR01 included in the invoice, so I needed this in order to retrofit this customization

Really, yours was a bit complicated for my JD Edwards api knowledge
laugh.gif


but thanks anyway
 
Use B90CA892 to write Media attachments in F00165.
This will make appropriate entries.
No need to Re engineer.
Hi @Abhishek Chhajer ,

can you share something about B90CA892 BSFN , as my BSFN fails at attachment ID parameter , can you please share what parameter should i pass there , or else you explain about this BSFN , Thanks in advanced.
 
Back
Top