if (idJDBReturn == JDEDB_PASSED) { /* 1. Group the F41021 records by ITM and MCU */ jdeNIDcpy(dsF41021GroupBy[0].szDict, NID_ITM); jdeNIDcpy(dsF41021GroupBy[0].szTable, NID_F41021); dsF41021GroupBy[0].idInstance = 0;
/* 2. Set the F41021 Group By */ idJDBReturn = JDB_SetGroupBy(hRequest, dsF41021GroupBy, uGroupBy);
if (idJDBReturn == JDEDB_PASSED) { /* 3. Define F41021 Aggregate as SUM of PQOH */ jdeNIDcpy(dsF41021Aggregate[0].Item.szDict, NID_PQOH); jdeNIDcpy(dsF41021Aggregate[0].Item.szTable, NID_F41021); dsF41021Aggregate[0].Item.idInstance = 0; dsF41021Aggregate[0].nFunction = JDB_AGGRGFUNC_SUM;
/* 4. Set the F41021 Aggregate */ idJDBReturn = JDB_SetAggregate(hRequest, dsF41021Aggregate, 1, JDB_AGGRGFUNCTION_OPT_FUNC_COLUMNQUERY); if (idJDBReturn == JDEDB_PASSED) { MathCopy(&dsF41021Key1.liitm, &lpdsSUMDS->mnInputITM); jdeStrcpy((JCHAR *)dsF41021Key1.limcu, (const JCHAR *)lpdsSUMDS->szInputMCU);
/* 5. If the set aggregate worked, select the correct F41021 records to sum */ idJDBReturn = JDB_SelectKeyed(hRequest, 0, &dsF41021Key1, uKeys); if (idJDBReturn == JDEDB_PASSED) { /* 6. Continue Fetch Aggregate based on Key Selected */ idJDBReturn = JDB_FetchAggregate(hRequest, (void *)NULL, dsAggregateBuffer); if (idJDBReturn == JDEDB_PASSED) { /* 7. Return sum(itlqoh) */ MathCopy(&lpdsSUMDS->mnQtySum, &dsAggregateBuffer[0]); } } } } } if (hRequest != (HREQUEST)NULL) { JDB_CloseTable(hRequest); } return; }
Alternative Methods:
An alternative method is to create a Named Event Rule (NER) business function or event rules within a Report which may yield the same result.
mnQtySum = 0 mnQtySum_perLine = 0
F41021.SELECT ILMCU = szInputMCU ILITM = mnInputITM F41021.FETCH NEXT ILPQOH -> mnQtySum_perLine WHILE SV File IO is CO SUCESS mnQtySum = mnQtySum + mnQtySum_perLine F41021.FETCH NEXT ILPQOH -> mnQtySum_perLine END WHILE
Or, make use of Aggregation option through Report Design Aid within a Level Break Footer. Refer to <Document 636697.1> E1: RDA: Aggregate Function in Level Break Footer
Note:
Oracle is not responsible for any custom code and it's result.
Above example codes are sample only. Oracle does not provide any warranty on these samples and is not responsible for any bug or any issue resulting from these samples.
User should search in the source folder for "JDB_SetAggregate" to find all standard EnterpriseOne business functions that uses this API and study how this API is used. (E.g. XT4111Z1 uses this API)