"De-Override" an UBE Version (playing with TAM Files in Xe)

amwalshjde

Well Known Member
\"De-Override\" an UBE Version (playing with TAM Files in Xe)

I have a ube, the R43500, for which there are many versions. Many of those versions have version level overrides, both in layout and in ER Code. I want to take one of those versions, "ABC" (and it's overrides), and use it to create a new Object the R554500. With the end result being that the R5543500 (default template) is a exact copy of the R43500 version ABC

At a high level the process should be (assuming I have already created a shell R554300 so the F9860/F9861/etc all exist):
1) Delete All RDA Specs for R5543500, version "+"
2) Copy all RDA specs for R43500, Version ABC to R5543500, version "+" excluding where spec type = 16. (those are EV overides at version level
3) Delete all RDA Text Specs for R5543500, version "+"
4) Copy all RDA Text specs for R43500, Version ABC to R5543500, version "+"
5) Delete all GBRLink Specs for R5543500, version "+"
6) Copy all GBRLink specs for R43500, Version ABC to R5543500, version "+" where nProductType = 2 (those are only UBE ER)
For each GBRLINK spec copy all GBRSpec records

This of course makes some assumptions about the datastructues be the same, etc. In this example, the specs can be copied to a different spec folder, then brought back in

Before I go to far this this, am I missing anything obvious?

__________________________________________
Code Below (just so that searching the forums will find it)
__________________________________________

I have a C Function where I pass in the following:
char szVersionFrom[11]; /* From Version */
char szTargetDirectory[257]; /* To SpecFolder */
char szNameObjectFrom[12]; /* From Object */
char szFromPath[257]; /* From SpecFolder */
char szVersionTo[11]; /* To Version */
char szDDObjectNameTo[12]; /* To Object */

My Code is as follows:
/************************************************************************
* Variable declarations
************************************************************************/
LPTAM lpTamS = NULL;
LPTAM lpTamT = NULL;
LPTAM lpTamS_2 = NULL;
LPTAM lpTamT_2 = NULL;

REPORT_SPEC * pRDAHFrom = (REPORT_SPEC * ) NULL;
XRDASPEC_3 RDAHFrom;

REPORT_SPEC * pRDAHTo = (REPORT_SPEC * ) NULL;
XRDASPEC_4 RDAHTo;

RDATEXT * pRDAText = (RDATEXT * ) NULL;
XRDATEXT_2 RDAText;

RDATEXT * pRDATextTo = (RDATEXT * ) NULL;
XRDATEXT_2 RDATextTo;

RDATEXT * pRDATextFrom = (RDATEXT * ) NULL;
XRDATEXT_2 RDATextFrom;

GBRLINK * pGBRLTo = (GBRLINK * ) NULL;
XGBRLINK_2 GBRLTo;

GBRLINK * pGBRLFrom = (GBRLINK * ) NULL;
XGBRLINK_2 GBRLFrom;

GBRCRIT * pGBRS = (GBRCRIT * ) NULL;
XGBRSPEC_2 GBRS;

TAMERRORCODE iTamReturn;
char szXDBPath[127];
char szDDBPath[127];
char szPathFrom[127];
char szPathTo[127];
char szPathCode[11];

ID idJDBReturn = JDEDB_PASSED;
HUSER hUser = NULL;
HREQUEST hRequest = NULL;
HREQUEST hRequest_2 = NULL;



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

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

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

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


strcpy(szPathCode,"DV7333");
strcpy(szPathFrom,lpDS->szFromPath);
strcpy(szPathTo ,lpDS->szTargetDirectory);


/************************************************************************
* Main Processing
************************************************************************/
idJDBReturn = JDB_InitBhvr(lpBhvrCom, &hUser, (char *)NULL, JDEDB_COMMIT_AUTO);

/** RDASPEC **/
if ((lpDS->szVersionFrom == NULL)||(strcmp(lpDS->szVersionFrom," ")==0)) {
strcpy(lpDS->szVersionFrom,"+");
};
if ((lpDS->szVersionTo == NULL)||(strcmp(lpDS->szVersionTo," ")==0)) {
strcpy(lpDS->szVersionTo,"+");
};

/*Set and Delete Existing RDASPEC for "TO" Obect*/
strcpy(RDAHTo.szReport,lpDS->szDDObjectNameTo);
strcpy(RDAHTo.szVersion,lpDS->szVersionTo);
strcpy(szXDBPath, szPathTo);strcat(szXDBPath, "rdaspec.xdb");
strcpy(szDDBPath, szPathTo);strcat(szDDBPath, "rdaspec.ddb");
lpTamT = TAMInit (szXDBPath, szDDBPath);
TAMKeepFileOpen(lpTamT);
TAMDeleteByKey(lpTamT,INDEX3_RDASPEC,&RDAHTo, 2);

/*Set RDASPEC for "FROM" Obect */
strcpy(RDAHFrom.szReport,lpDS->szNameObjectFrom);
strcpy(RDAHFrom.szVersion,lpDS->szVersionFrom);
strcpy(szXDBPath, szPathFrom);strcat(szXDBPath, "rdaspec.xdb");
strcpy(szDDBPath, szPathFrom);strcat(szDDBPath, "rdaspec.ddb");
/* INIT FROM TAM*/
lpTamS = TAMInit (szXDBPath, szDDBPath);
TAMKeepFileOpen(lpTamS);
TAMSetBeforeKey(lpTamS,INDEX3_RDASPEC,&RDAHFrom,2);
pRDAHFrom = TAMAllocFetchNextMatchingKey(lpTamS,INDEX3_RDASPEC,&RDAHFrom,2);
while (pRDAHFrom){
/* Need to change the Program and Version from Source to Dest*/
strcpy(RDAHFrom.szReport,lpDS->szDDObjectNameTo);
strcpy(RDAHFrom.szVersion,lpDS->szVersionTo);
/* For each TAM read from source add to destintation*/

/* Definitio of nRecord Type
1 = Base Record
2 = Sections (will have one type 2 record for each section of a report)
3 = Report objects (one record for each report variable and constant on the report)
4 = Column calculation defined on tabular sections
5 = Subsection join (defines join information between sections)
6 = Data Sequencing (will have one record for each data item included in data sequencing)
7 = Data Selection (will have one record for each data item included in data selection)
8 = Database output (one record indicating destination for output -filename)
9 = Database output (one record for each mapping in database output)
10 = Row on tabular section (one record for each row)
11 = Cell on tabular section (one record for each cell)
13 = Row calculation defined on tabular section
16 = Event rule overrides performed at version level
17 = Row on tabular section (record for defined row criteria
18 = Cell on tabular section (record for defined cell criteria)
19 = Column data selection on tabular section
20 = Column and row overrides (tabular section only)
*/

/*
Notes:
If going from version to +, then dont copy Types = 16
*/
if (pRDAHFrom->nRecordType != 16 )
{
TAMAdd(lpTamT,pRDAHFrom);
}
TAMFree(pRDAHFrom);
pRDAHFrom = TAMAllocFetchNextMatchingKey(lpTamS,INDEX3_RDASPEC,&RDAHFrom,2);
};
TAMFree(pRDAHFrom);
TAMKeepFileClosed(lpTamS);TAMTerminate(lpTamS);
TAMKeepFileClosed(lpTamT);TAMTerminate(lpTamT);

/** RDATEXT **/
/* Delete "TO" records */
strcpy(RDATextTo.szReport,lpDS->szDDObjectNameTo);
strcpy(RDATextTo.szVersion,lpDS->szVersionTo);
strcpy(szXDBPath, szPathTo);strcat(szXDBPath, "rdatext.xdb");
strcpy(szDDBPath, szPathTo);strcat(szDDBPath, "rdatext.ddb");
lpTamT = TAMInit (szXDBPath, szDDBPath);
TAMKeepFileOpen(lpTamT);
TAMDeleteByKey(lpTamT,INDEX2_RDATEXT,&RDATextTo, 2);

/*Set RDATEXT for "FROM" Obect */
strcpy(RDATextFrom.szReport,lpDS->szNameObjectFrom);
strcpy(RDATextFrom.szVersion,lpDS->szVersionFrom);
strcpy(szXDBPath, szPathFrom);strcat(szXDBPath, "rdatext.xdb");
strcpy(szDDBPath, szPathFrom);strcat(szDDBPath, "rdatext.ddb");
lpTamS = TAMInit (szXDBPath, szDDBPath);
TAMKeepFileOpen(lpTamS);
TAMSetBeforeKey(lpTamS,INDEX2_RDATEXT,&RDATextFrom,2);
pRDATextFrom = TAMAllocFetchNextMatchingKey(lpTamS,INDEX2_RDATEXT,&RDATextFrom,2);
while (pRDATextFrom){
/* Need to change the Program and Version from Source to Dest*/
strcpy(RDATextFrom.szReport,lpDS->szDDObjectNameTo);
strcpy(RDATextFrom.szVersion,lpDS->szVersionTo);
/* For each TAM read from source add to destintation*/
TAMAdd(lpTamT,pRDATextFrom);
TAMFree(pRDATextFrom);
pRDATextFrom = TAMAllocFetchNextMatchingKey(lpTamS,INDEX2_RDATEXT,&RDATextFrom,2);
};
TAMFree(pRDATextFrom);
TAMKeepFileClosed(lpTamS);TAMTerminate(lpTamS);
TAMKeepFileClosed(lpTamT);TAMTerminate(lpTamT);


/** GBRLINK **/
/* Definition of nProducttype
#define GBRPT_FDA 1 Application Event Rule
#define GBRPT_RDA 2 UBE Event Rule
#define GBRPT_NER 3 Named Event Rule
#define GBRPT_TER 4 Table Event Rule
#define GBRPT_TC 5 Table Conversion ER
#define GBRPT_WF 6 WorkFlow ER

*/
GBRL.nProductType = 2;

/* Delete "TO" records */
strcpy(GBRLTo.szApplication,lpDS->szDDObjectNameTo);
strcpy(GBRLTo.szVersion,lpDS->szVersionTo);
strcpy(szXDBPath, szPathTo);strcat(szXDBPath, "gbrlink.xdb");
strcpy(szDDBPath, szPathTo);strcat(szDDBPath, "gbrlink.ddb");
lpTamT = TAMInit (szXDBPath, szDDBPath);
TAMKeepFileOpen(lpTamT);
TAMDeleteByKey(lpTamT,INDEX2_GBRLINK,&GBRLTo, 3);


/*Set GBRLINK for "FROM" Obect */
strcpy(GBRLFrom.szApplication,lpDS->szNameObjectFrom);
strcpy(GBRLFrom.szVersion,lpDS->szVersionFrom);
strcpy(szXDBPath, szPathFrom);strcat(szXDBPath, "gbrlink.xdb");
strcpy(szDDBPath, szPathFrom);strcat(szDDBPath, "gbrlink.ddb");
lpTamS = TAMInit (szXDBPath, szDDBPath);
TAMKeepFileOpen(lpTamS);
TAMSetBeforeKey(lpTamS,INDEX2_GBRLINK,&GBRLFrom,3);
pGBRLFrom = TAMAllocFetchNextMatchingKey(lpTamS,INDEX2_GBRLINK,&GBRLFrom,3);
while (pGBRLFrom){
/* Need to change the Program and Version from Source to Dest*/
strcpy(GBRLFrom.szApplication,lpDS->szDDObjectNameTo);
strcpy(GBRLFrom.szVersion,lpDS->szVersionTo);

/* For each TAM read from source add to destintation*/
TAMAdd(lpTamT,pGBRLFrom);


/** GBRSPEC **/

strcpy(GBRS.szEventSpecKey,pGBRLFrom->szEventSpecKey);
strcpy(szXDBPath, szPathTo);strcat(szXDBPath, "gbrspec.xdb");
strcpy(szDDBPath, szPathTo);strcat(szDDBPath, "gbrspec.ddb");
lpTamT_2 = TAMInit (szXDBPath, szDDBPath);
TAMKeepFileOpen(lpTamT_2);
TAMDeleteByKey(lpTamT_2,INDEX2_GBRSPEC,&GBRS, 1);

strcpy(szXDBPath, szPathFrom);strcat(szXDBPath, "gbrspec.xdb");
strcpy(szDDBPath, szPathFrom);strcat(szDDBPath, "gbrspec.ddb");
lpTamS_2 = TAMInit (szXDBPath, szDDBPath);
TAMKeepFileOpen(lpTamS_2);
TAMSetBeforeKey(lpTamS_2,INDEX2_GBRSPEC,&GBRS,1);
pGBRS = TAMAllocFetchNextMatchingKey(lpTamS_2,INDEX2_GBRSPEC,&GBRS,1);
while (pGBRS){
TAMAdd(lpTamT_2,pGBRS);
TAMFree(pGBRS);
pGBRS = TAMAllocFetchNextMatchingKey(lpTamS_2,INDEX2_GBRSPEC,&GBRS,1);
};
TAMFree(pGBRS);
TAMKeepFileClosed(lpTamS_2);TAMTerminate(lpTamS_2);
TAMKeepFileClosed(lpTamT_2);TAMTerminate(lpTamT_2);

TAMFree(pGBRLFrom);
pGBRLFrom = TAMAllocFetchNextMatchingKey(lpTamS,INDEX2_GBRLINK,&GBRLFrom,3);
};
TAMFree(pGBRLFrom);
TAMKeepFileClosed(lpTamS);TAMTerminate(lpTamS);
TAMKeepFileClosed(lpTamT);TAMTerminate(lpTamT);
};
 
Re: \"De-Override\" an UBE Version (playing with TAM Files in Xe)

Have you looked at our Code CopyCat tool? - one of its functions is to do exactly that. Can save you a lot of coding...
 
Re: \"De-Override\" an UBE Version (playing with TAM Files in Xe)

Sell a man a fish, he eats for a day...
Teach a man to fish, he eats for life.

My advice is to keep doing what your doing. The answers are out there. You're on a good path.
 
Back
Top