Look for the condition for the error
*** Break In Code of B0900049 - F0911FSBeginDoc ***
if ((MathZeroTest(&lpDS->mnDocNumber)) &&
(lpDS->cDocAction == _J('A')))
{
/************************************************************************
* Validate Document Number
************************************************************************/
jdeStrncpy(dsD0900049F.szDocumentType, (const JCHAR *)(lpDS->szDocumentType), DIM(dsD0900049F.szDocumentType));
MathCopy(&dsD0900049F.mnDocumentNumber, &lpDS->mnDocNumber);
jdeStrncpy(dsD0900049F.szKeyCompany, (const JCHAR *)(lpDS->szCompanyKey), DIM(dsD0900049F.szKeyCompany));
memcpy((void *)(&dsD0900049F.jdGLDate), (const void *)(&lpDS->jdGLDate),
sizeof (dsD0900049F.jdGLDate));
jdeStrncpy(dsD0900049F.szLedgerType, (const JCHAR *)(lpDS->szLedgerType),
DIM(dsD0900049F.szLedgerType));
dsD0900049F.cModelFlag = lpDS->cModelFlag;
jdeCallObject(_J("F0911FSValidateDocNumber"), NULL, lpBhvrCom,
lpVoid, (void *)&dsD0900049F, (CALLMAP *)NULL, (int)0, (JCHAR *)NULL,
(JCHAR *)NULL, (int)0);
if (dsD0900049F.cRecordExistsFlag == _J('1'))
{
jdeSetGBRError(lpBhvrCom, lpVoid, (ID)IDERRmnDocNumber_11, _J("0002"));
lpDS->cErrorFlag = _J('2');
}
} /* end if document number isn't zero and action is 'A' */
*** Break In Code ***
Notes:
- Error routine: dsD0900049F.cRecordExistsFlag is '1'
- Data Structure dsD0900049F is data structure for BSFN F0911FSValidateDocNumber
- Error Code '0002' is hard coded
- cErrorFlag will be set to '2'
- lpDS is long pointer data structure for the first level BSFN B0900049 - F0911FSBeginDoc
- So, for this example, refer to source of B0900049 - F0911FSValidateDocumentNumber
For this example, the called report R0911Z1 exit from routine as xxxBeginDoc ends in error. Keep in mind the Master Business Function flow as below:
- xxxBeginDoc: Validate header/initialize variables and store header cache (if any)
- xxxEditLine: Validate Detail and create cache for detail
- xxxEditDoc: Compare header cache with detail cache (e.g., summary of detail has to be header)
- xxxEndDoc: Commit cache to DB and clear cache used
*** Break In Code of B0900049 - F0911FSValidateDocNumber ***
jdeStrncpy(dsF0911Key15.glkco, (const JCHAR *)(lpDS->szKeyCompany),DIM(dsF0911Key15.glkco));
jdeStrncpy(dsF0911Key15.gldct, (const JCHAR *)(lpDS->szDocumentType),DIM(dsF0911Key15.gldct));
MathCopy(&dsF0911Key15.gldoc, &lpDS->mnDocumentNumber);
memcpy((void *)(&dsF0911Key15.gldgj), (const void *)(&lpDS->jdGLDate), sizeof (dsF0911Key15.gldgj));
MathCopy(&dsF0911Key15.gljeln, &lpDS->mnJELineNumber);
jdeStrncpy(dsF0911Key15.glextl, (const JCHAR *)(lpDS->szLineExtension),DIM(dsF0911Key15.glextl));
jdeStrncpy(dsF0911Key15.gllt, (const JCHAR *)(lpDS->szLedgerType),DIM(dsF0911Key15.gllt));
nNumKeysF0911 = 7;
lpDS->cRecordExistsFlag = _J('0'); /* Note: cRecordExistFlag is initialized */
/************************************************************************
* Do a fetch keyed for account ledger record
************************************************************************/
idJDBReturn = JDB_FetchKeyed(hRequestF0911, ID_F0911_DOC_TYPE__NUMBER___B,
(void *)&dsF0911Key15, nNumKeysF0911,
(void *)&dsColF0911, FALSE);
if(idJDBReturn == JDEDB_PASSED) /* If a record is found then set cRecordExistsFlag to '1' */
{
lpDS->cRecordExistsFlag = _J('1'); /* cRecordExistFlag is set 1 */
}
*** Break In Code ***
Notes:
- Based on input parameters in calling F0911FSBeginDoc, it assigns/copies data or pointer into dsF0911Key15
- It is looking for specific index file so JDB_FetchKeyed() API is issued
- As long as it fetches a record, the function sets cRecordExistFlag to '1' to stop Database(or JDBC) from issuing a Duplicate Key error