Troubleshooting
Problem
An
RPG program using SETLL *LOVAL to position to the start of an overridden file that was opened using OPNQRYF with the KEYFLD parameter may result in incorrect output.SETLL *HIVAL can have similar issues.Symptom
Example source code:
OVRDBF FILE(RPGOPN1) TOFILE(RPGOPN1) SHARE(*YES)OPNQRYF FILE(RPGOPN1) KEYFLD((KEY3) (KEY4))CALL RPGPGMThe
OVRDBF is used to share the access path opened with the OPNQRYF with the RPGPGM.The
OPNQRYF is specifying KEYFLDs that do not match the keys defined for RPGOPN1. (KEY1 and KEY2)In this scenario it's possible that incorrect output would result if using
SETLL *LOVAL.Not all OVRDBF/RPG scenarios will have incorrect output.
Diagnosing The Problem
APAR SE62752 has additional details for a tool that can be used to find OPNQRYF/RPG scenarios that need to be changed.
Only IBM i 7.2 has a PTF SI57839.
IBM i 7.3 and later releases do not need a PTF.
Example output message:
CPF9898Message . . . . : A KEY MISMATCH HAS BEEN DETECTED WHILE PERFORMING A
POSITIONING OPERATION FOR FILE yourfile IN LIBRARY *LIBL (FOR
EXAMPLE, RPG SETLL USING *LOVAL). INCORRECT POSITIONING IS POSSIBLE. CORRECT
THE KEY SPECIFICATION IN YOUR PROGRAM TO MATCH THE KEY SPECIFIED ON THE
OPNQRYF KEYFLD PARAMETER.
Use QOPNQRYFKY set to 3 for SBMJOB.
Resolving The Problem
The
RPG record format should match the KEYFLD of the OPNQRYF.Use
SETLL *START instead of SETLL *LOVAL to position the cursor at the beginning of the file.Use
SETLL *END instead of SETLL *HIVAL to position the cursor at the end of the file.Create the physical file with the same record format name and the same keys as the
OPNQRYF.For the file definition in
RPG use the EXTDESC keyword to specify the physical file to be used at compile time.Related Information
Document Location
Worldwide
[{"Type":"SW","Line of Business":{"code":"LOB57","label":"Power"},"Business Unit":{"code":"BU058","label":"IBM Infrastructure w\/TPS"},"Product":{"code":"SWG60","label":"IBM i"},"ARM Category":[{"code":"a8m0z0000000CHeAAM","label":"IBM i Db2"},{"code":"a8m0z0000001i6BAAQ","label":"IBM i Db2->OPNQRYF - Open Query File"}],"ARM Case Number":"","Platform":[{"code":"PF012","label":"IBM i"}],"Version":"All Version(s)"}]
Was this topic helpful?
Document Information
Modified date:
22 April 2021
UID
ibm10870826