agoyal
Guest
"I want to do a fetch next loop on a table (F4211) using an “order by” that is not in any of the available indexes. In SQL I would just do a select statement with an ORDER BY clause. I do not want to add index as this table already has many indexes.
I read something in Post # 73468 which seems a cool solution. And on that basis I created a business function as follows:
JDEBFRTN (ID) JDEBFWINAPI B55AddSort (LPBHVRCOM lpBhvrCom, LPVOID lpVoid, LPDSD55UTIL01 lpDS)
{
/************************************************************************
* Variable declarations
************************************************************************/
ID idReturn;
/************************************************************************
* Declare structures
************************************************************************/
FILEIO_HANDLE_INFO dsHandleInfo = { 0 };
/************************************************************************
* Declare pointers
************************************************************************/
SORTSTRUCT Sort[3] = {0};
/************************************************************************
* Check for NULL pointers
************************************************************************/
if ((lpBhvrCom == (LPBHVRCOM) NULL) ||
(lpVoid == (LPVOID) NULL) ||
(lpDS == (LPDSD55UTIL01) NULL))
{
jdeErrorSet (lpBhvrCom, lpVoid, (ID) 0, "4363", (LPVOID) NULL);
return ER_ERROR;
}
/************************************************************************
* Set pointers
************************************************************************/
/************************************************************************
* Main Processing
************************************************************************/
if(!RTK_CER_FIOGetHandleInfo( lpDS->idTableHandle , &dsHandleInfo ))
{
return ER_ERROR;
}
jdeNIDcpy(Sort[0].Item.szDict, "UPRC");
jdeNIDcpy(Sort[0].Item.szTable, "F4211");
Sort[0].Item.idInstance = 0;
Sort[0].nSort = JDEDB_SORT_ASC;
jdeNIDcpy(Sort[1].Item.szDict, "DCTO");
jdeNIDcpy(Sort[1].Item.szTable, "F4211");
Sort[1].Item.idInstance = 0;
Sort[1].nSort = JDEDB_SORT_ASC;
jdeNIDcpy(Sort[2].Item.szDict, "DOCO");
jdeNIDcpy(Sort[2].Item.szTable, "F4211");
Sort[2].Item.idInstance = 0;
Sort[2].nSort = JDEDB_SORT_ASC;
JDB_ClearSequencing(dsHandleInfo.hReqest);
idReturn = JDB_SetSequencing (dsHandleInfo.hReqest, Sort, 3, JDEDB_SET_REPLACE);
if (idReturn != JDEDB_PASSED )
{
jdeSetGBRError(lpBhvrCom, lpVoid, (ID) 0, "3143");
JDB_CloseView(dsHandleInfo.hReqest);
return FALSE;
}
/************************************************************************
* Function Clean Up
************************************************************************/
return (ER_SUCCESS);
}
--------------------------------------
"The DS Template Type Definition for the above is as follows:
#ifndef DATASTRUCTURE_D55UTIL01
#define DATASTRUCTURE_D55UTIL01
typedef struct tagDSD55UTIL01
{
ID idTableHandle;
} DSD55UTIL01, *LPDSD55UTIL01;
#define IDERRidTableHandle_4 4L
#endif
----------------------------
"I used F4211 Handle (HF4211) to open the table in the application. Then I did Select using the same handle. The I passed this handle to the above business function expecting it to change the data sequencing. But it is not working.
I wonder if any one of you have done something like this. Please comment.
I read something in Post # 73468 which seems a cool solution. And on that basis I created a business function as follows:
JDEBFRTN (ID) JDEBFWINAPI B55AddSort (LPBHVRCOM lpBhvrCom, LPVOID lpVoid, LPDSD55UTIL01 lpDS)
{
/************************************************************************
* Variable declarations
************************************************************************/
ID idReturn;
/************************************************************************
* Declare structures
************************************************************************/
FILEIO_HANDLE_INFO dsHandleInfo = { 0 };
/************************************************************************
* Declare pointers
************************************************************************/
SORTSTRUCT Sort[3] = {0};
/************************************************************************
* Check for NULL pointers
************************************************************************/
if ((lpBhvrCom == (LPBHVRCOM) NULL) ||
(lpVoid == (LPVOID) NULL) ||
(lpDS == (LPDSD55UTIL01) NULL))
{
jdeErrorSet (lpBhvrCom, lpVoid, (ID) 0, "4363", (LPVOID) NULL);
return ER_ERROR;
}
/************************************************************************
* Set pointers
************************************************************************/
/************************************************************************
* Main Processing
************************************************************************/
if(!RTK_CER_FIOGetHandleInfo( lpDS->idTableHandle , &dsHandleInfo ))
{
return ER_ERROR;
}
jdeNIDcpy(Sort[0].Item.szDict, "UPRC");
jdeNIDcpy(Sort[0].Item.szTable, "F4211");
Sort[0].Item.idInstance = 0;
Sort[0].nSort = JDEDB_SORT_ASC;
jdeNIDcpy(Sort[1].Item.szDict, "DCTO");
jdeNIDcpy(Sort[1].Item.szTable, "F4211");
Sort[1].Item.idInstance = 0;
Sort[1].nSort = JDEDB_SORT_ASC;
jdeNIDcpy(Sort[2].Item.szDict, "DOCO");
jdeNIDcpy(Sort[2].Item.szTable, "F4211");
Sort[2].Item.idInstance = 0;
Sort[2].nSort = JDEDB_SORT_ASC;
JDB_ClearSequencing(dsHandleInfo.hReqest);
idReturn = JDB_SetSequencing (dsHandleInfo.hReqest, Sort, 3, JDEDB_SET_REPLACE);
if (idReturn != JDEDB_PASSED )
{
jdeSetGBRError(lpBhvrCom, lpVoid, (ID) 0, "3143");
JDB_CloseView(dsHandleInfo.hReqest);
return FALSE;
}
/************************************************************************
* Function Clean Up
************************************************************************/
return (ER_SUCCESS);
}
--------------------------------------
"The DS Template Type Definition for the above is as follows:
#ifndef DATASTRUCTURE_D55UTIL01
#define DATASTRUCTURE_D55UTIL01
typedef struct tagDSD55UTIL01
{
ID idTableHandle;
} DSD55UTIL01, *LPDSD55UTIL01;
#define IDERRidTableHandle_4 4L
#endif
----------------------------
"I used F4211 Handle (HF4211) to open the table in the application. Then I did Select using the same handle. The I passed this handle to the above business function expecting it to change the data sequencing. But it is not working.
I wonder if any one of you have done something like this. Please comment.