E9.2 Copy SDB Media Object attachments

JohnDanter2

JohnDanter2

VIP Member
Hi folks

I have a requirement whereby I am cloning ITMs and all their anciliary linked tables to a new ITM and data clone. This process works super well and has been extended to SDB data too.
One of the new requirements is now to also clone any media object attachments that the original F00092 records may have

I have seen various BSFNs in 9.2 already that I think do this, B4100120 to copy F4101 MOs, B1700450 to copy case MOs etc. I can't seem to see a F00092 one. So is there a generic way?

I see older posts referencing API JDEGTCopyF00165WithKeyStr and there are no references in the Source64 folder. I think it may have been replaced with JDEGTCopyF00165FromDataSource??

Does anyone know of a way to clone MO data and attachments and is there a one already written for F00092
b9840g maybe????

Thanks

John
 
I have had to copy or clone media objects in several cases and have used the API you referenced. I use the GT DS version but its basically the same as the "WithKeyStr" version. I am still on 32bit but looking at the header file where this is defined it looks like JDEGTCopyF00165 is still valid in 64bit, but of course I guess they could have changed the header file since my TR version.

Example:
Code:
DSGT4201A        dsHdrFrom={0}, dsHdrTo={0};

 jdeStrncpy(dsHdrFrom.szCompanykeyorderno, lpDS->szFromCompany, DIM(dsHdrFrom.szCompanykeyorderno)-1);
MathCopy(&dsHdrFrom.mnDocumentorderinvoicee, &lpDS->mnFromOrderNo);
 jdeStrncpy(dsHdrFrom.szOrdertype, lpDS->szFromOrderType, DIM(dsHdrFrom.szOrdertype)-1);

 jdeStrncpy(dsHdrTo.szCompanykeyorderno, lpDS->szToCompany, DIM(dsHdrTo.szCompanykeyorderno)-1);
MathCopy(&dsHdrTo.mnDocumentorderinvoicee, &lpDS->mnToOrderno);
 jdeStrncpy(dsHdrTo.szOrdertype, lpDS->szToOrderType, DIM(dsHdrTo.szOrdertype)-1);

 if(JDEGTCopyF00165(B5642024_GT_DS_NAME_SO_HEADER, &dsHdrFrom, 0, OBJ_JDEALL,
                                   B5642024_GT_DS_NAME_SO_HEADER, &dsHdrTo) != JDEDB_PASSED)
{
    jdeErrorSet(lpBhvrCom, lpVoid, (ID)0, _J("500SOMOAA"), (LPVOID)NULL);
    idReturn = ER_ERROR;
}


TR9.2.4.3 header file - JDEGTCopyF00165 and JDEGTCopyF00165WithKeyStr appear to be defined for both 32 and 64 bit.
Code:
#if defined(JDENV_64BIT)
#define JDEGTCopyF00165FromDataSource     JDEGTCopyF00165FromDataSourceEx
#else
KRNL_RTN(BOOL) JDEWINAPI JDEGTCopyF00165FromDataSource(
                                                PJSTR          szObjectName,
                                                PJSTR          szGTKey,
                                                PJSTR          szFromDatasource,
                                                PJSTR          szToDatasource,
                                                long          *nTotRecRead,
                                                long          *nTotRecUpdt,
                                                long          *nTotFailRead,
                                                long          *nTotFailUpdt);
#endif

KRNL_RTN(BOOL) JDEWINAPI JDEGTCopyF00165FromDataSourceEx(
                                                PJSTR          szObjectName,
                                                PJSTR          szGTKey,
                                                PJSTR          szFromDatasource,
                                                PJSTR          szToDatasource,
                                                int           *nTotRecRead,
                                                int           *nTotRecUpdt,
                                                int           *nTotFailRead,
                                                int           *nTotFailUpdt);

KRNL_RTN(JDEDB_RESULT) JDEWINAPI JDEGTCopyF00165(
                                                PJSTR          szFromObjName,
                                                LPVOID         pFromMODSKey,
                                                int            nFromSeq,
                                                MOTYPE         nMOType,
                                                PJSTR          szToObjName,
                                                LPVOID         pToMODSKey);

KRNL_RTN(JDEDB_RESULT) JDEWINAPI JDEGTCopyF00165WithKeyStr(
                                                PJSTR          szFromObjName,
                                                PJSTR          pszFromGTKey,
                                                int            nFromSeq,
                                                MOTYPE         nMOType,
                                                PJSTR          szToObjName,
                                                PJSTR          pszToGTKey);
 
Love you Brian

Out of interest, where do you go to find these header files?

I think the one I found is more of a setup thing that CNC may run at start up or environment cloning example.
This one looks great JDEGTCopyF00165WithKeyStr
 
All the JDE BSFN C APIs are found under \[JDE Install Folder]\System\include and subfolders. On my TR and install these are the folders that contain the majority of what you will see and use in BSFNs.

C:\e920\system\include
C:\e920\system\include\xml

I have posted in the past (long time ago) about how I do C BSFN development which includes setting up Visual Studio for BSFN development so that IntelliSense works (code completion, etc.). With IntelliSense working it allows several methods to browse, inspect and discover all the various APIs available using Visual Studio. Often when you find one there are a "family" of APIs defined in the same section of the header file.
 
Thanks Brian

I'll take a closer look at the other BSFNs I listed too, as they seem to copy MO attachments but are just hardcoded so speak to certain GT DSTRs. Mine will just be GT00092 or the 92A I suppose
 
Back
Top