Wrong sequence in Table IO

Xe_na_thanks

Active Member
Dear List,

I am trying to read a custom file by three fields.

MCU
ITM
TRDJ

However when I run my business function it uses the primary key, i.e.

ORDER BY SCKCOO ASC,SCDOCO ASC,SCDCTO ASC,SCLNID ASC

From the debug log.

I have selected the right key in the ER on both the select and fetch next. The ER compiles to;

/* F5500100(VA evt_idF5500100Handle_F55100).Select */
if ( RTK_CER_FIOGetHandleInfo( evt_idF5500100Handle_F55100HN , &zHndlInfo ) )
{
pAppVars->iTableRetCode = ER_ERROR;
if ( JDB_ClearSelection( zHndlInfo.hReqest ) == JDEDB_PASSED )
{
RTK_CER_FIOSelectInitH( zSelect45 , 2 , zHndlInfo.nType ,
zHndlInfo.szFileName , 0L );
jdeNIDcpy( zSelect45[0].Item1.szDict , "MCU" );
if ( zHndlInfo.nType == FILEIO_TYPE_VIEW )
{
jdeNIDcpy( zSelect45[0].Item1.szTable , "F5500100" );
zSelect45[0].Item1.idInstance = 0L;
}
zSelect45[0].lpValue = (LPVOID)lpDS->szCostCenter;
jdeNIDcpy( zSelect45[1].Item1.szDict , "ITM" );
if ( zHndlInfo.nType == FILEIO_TYPE_VIEW )
{
jdeNIDcpy( zSelect45[1].Item1.szTable , "F5500100" );
zSelect45[1].Item1.idInstance = 0L;
}
zSelect45[1].lpValue = (LPVOID)&lpDS->mnIdentifierShortItem;
RTK_CER_FIOSelect( zHndlInfo.hReqest , 4L , 2 , zSelect45 ,
&pAppVars->iTableRetCode );

/* F5500100(VA evt_idF5500100Handle_F55100).Fetch Next */
if ( RTK_CER_FIOGetHandleInfo( evt_idF5500100Handle_F55100HN , &zHndlInfo ) )
{
if ( JDB_Fetch( zHndlInfo.hReqest , &zF5500100_47 , 0 ) != JDEDB_PASSED )
{
JDB_ClearSelection( zHndlInfo.hReqest );
JDB_ClearSequencing( zHndlInfo.hReqest );
pAppVars->iTableRetCode = ER_ERROR;
}
else
{
jdeStrcpy( evt_szCompanyKeyOrderNo_KCOO , zF5500100_47.sckcoo ,
sizeof( evt_szCompanyKeyOrderNo_KCOO ) );
MathCopy( &evt_mnDocumentOrderInv_DOCO , &zF5500100_47.scdoco );
jdeStrcpy( evt_szOrderType_DCTO , zF5500100_47.scdcto ,
sizeof( evt_szOrderType_DCTO ) );
MathCopy( &evt_mnLineNumber_LNID , &zF5500100_47.sclnid );
jdeStrcpy( evt_szCostCenter_MCU , zF5500100_47.scmcu ,
sizeof( evt_szCostCenter_MCU ) );
MathCopy( &evt_mnUnitsTransactionQty_UORG , &zF5500100_47.scuorg );
pAppVars->iTableRetCode = ER_SUCCESS;
}

Anyone got any ideas? I really need it in that sequence! Do triggers have anything to do with it? Is the sequencing done in the select or the fetch next? Has;

RTK_CER_FIOSelect( zHndlInfo.hReqest , 4L , 2 , zSelect45 ,
&pAppVars->iTableRetCode );

replaced the JDB_SelectKeyed function?

And how do you without re writing this in C force it to use the key selected not the primary keys. All encouragement and words of wisdom (and just plain old chat) will be very welcome. It has been a rough couple of weeks.

Adrian.

Xe SP15 Update1 applied AS400 V4R4 DB2, World A73 Cum 11 00X2
 

vbojan

Well Known Member
Hi Adrian,

On B733.2, NT 4.0, SQL 7.0 you have to select same key for select and for fetch next. If they are not the same it won’t work. Don’t use another table IO for same table between select and fetch next unless you using file handle. Do you maybe Inserting or Deleting record(s) or Updating selected key from your table? In that case record pointer can be damaged and you need to reselect record(s). Also you can try to regenerate table, log off and on JDE and recompile your NER.

Hope this helps,

Bojan.
 

Xe_na_thanks

Active Member
Well list if you can't solve it I can ;->

I first moved the offending section of code to a seperate business function. That didn't change anything!

I then stopped using a handle and did the read directly from the table ,and ping, it suddenly works!!!!!!!

Any explination will be not be believed as I am convinced it is all magic and tricks with mirrors!

Yours in confusion.

A.



Xe SP15 Update1 applied AS400 V4R4 DB2, World A73 Cum 11 00X2
 
Top