OVRDBF -POSITION

515 pts.
Tags:
CL Commands
CL Program
CL/400
OVRDBF
Hi,
    How to position the record in CL based on the key value?
I have tried this.my CL program is as follows...
***************************
 PGM                                                  
 DCLF       FILE(PMS90/EMPMST90)                      
 OVRDBF     FILE(EMPMST90) POSITION(*KEY 1 EMPREC 101)
 RCVF                                                 
 SNDUSRMSG  MSG(&EMPNAM)                              
 DLTOVR     FILE(EMPMST90)                            
 ENDPGM       
****************************
Position(*key  1  emprec  101)
Starting position in file:               
  Retrieve order . . . . . . . . > *KEY  
  *RRN-rcd nbr *KEY-nbr key flds > 1     
  *KEY-rec format having key . . > EMPREC
  *KEY-key value . . . . . . . . > 101   
i am getting error in this statement...
*key-key equal records will be retrieved
*key nbr key flds-here what i have to specify.i specified as '1'.Is this right.In my physical file "EMPMST",i had one key field-'EMPCDE'...
"EMPREC"-rec format name...
101 is one of the records in my file EMPMST...
Please correct my mistake in my program displayed above and explain about the parameters in POSITION...
                                        


Software/Hardware used:
AS400

Answer Wiki

Thanks. We'll let you know when a new response is added.
Send me notifications when members answer or reply to this question.

REGISTER or login:

Forgot Password?
By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy

Discuss This Question: 13  Replies

 
There was an error processing your information. Please try again later.
Thanks. We'll let you know when a new response is added.
Send me notifications when members answer or reply to this question.

REGISTER or login:

Forgot Password?
By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy
  • TomLiotta
    i am getting error in this statement... What is the message identifier of the error? The text isn't helpful to us, but the message identifier will let us look at the same message. However, you are requesting to position by key and you specify that a single key field exists and that you want to retrieve a record with a key value of "101". But we have no way of knowing if that's correct because you haven't shown us the file key description. Tom
    125,585 pointsBadges:
    report
  • 22917
    My error msg and its description is as follows.. CPF4137 received by OVRDBF11 at 301. Position option for member EMPMST90 not valid... EMPMST90:- MY PF R EMPREC A EMPCDE 5S0 A EMPNAM 30A K EMPCDE RECORDS; 101 ARUN 102 BALA 103 DEVA OVRDBF COMMAND -IN POSITION I AM GETTING ERROR...I HAVE SHOWN MY FILE AND DATA...NOW HELP ME TO GET 101 th RECORD...
    515 pointsBadges:
    report
  • 22917
    MY CL PROGRAM: PGM DCLF FILE(PMS90/EMPMST90) OVRDBF FILE(EMPMST90) POSITION(*KEY 1 EMPREC 101) RCVF SNDUSRMSG MSG(&EMPNAM) DLTOVR FILE(EMPMST90) ENDPGM
    515 pointsBadges:
    report
  • TomLiotta
    A EMPCDE 5S0 According to that, you have a key that is five bytes long. However, you are only passing three bytes into your positioning value: POSITION(*KEY 1 EMPREC 101) Try this: POSITION(*KEY 1 EMPREC '00101') The key-value element is a character parameter. When you pass in (101), it becomes '101bb' as the key value -- two blanks will essentially be assumed in the last two positions. As long as you always treat the key-value element as a series of bytes, you should always be able to determine what values will work. Tom
    125,585 pointsBadges:
    report
  • TomLiotta
    For some investigation, look at the output from this command:
    DSPPFM  PMS90/EMPMST90
    You should see that the actual key value is '00101'. Keys may be 'compound keys'. The indexes will hold effectively character data structures. Even packed-decimal and binary values will appear to be represented as bytes in memory rather than values formatted for external viewing. CL is not a database language, so it doesn't have a full set of features like those provided in HLLs such as ILE RPG or COBOL. You need to use the limited capabilities if you use a language that isn't full-featured. Tom
    125,585 pointsBadges:
    report
  • 22917
    OVRDBF FILE(EMPMST90) POSITION(*KEY 1 EMPREC '00101') Thanks Tom Sir its working... But how to retrieve by RRN... OVRDBF FILE(EMPMST90) POSITION(*RRN 1) I cant able to get the first record
    515 pointsBadges:
    report
  • TomLiotta
    Thanks Tom Sir its working… You're welcome. Note that the <help> text for POSITION() parameter says this:
    • The key value is specified as a character string enclosed in apostrophes for character or positive zoned decimal formats, or is specified in hexadecimal form (x'value').
    The information was available by using the F1=Help key. But how to retrieve by RRN… The OVRDBF looks fine, but the rest of the CL is needed in order to know if it's correct. For example, if the file was previously opened and not closed, the override will not be effective. Also, what is OS version/release? Current releases of i5/OS have some capabilities that earlier releases didn't have. Tom
    125,585 pointsBadges:
    report
  • jching

    Hello...

    In this example: OVRDBF FILE(MYFILE) POSITION(*KEY 1 MYKEY  'ABC'),  can the value 'ABC'  be replaced with a variable?  If so, how do I code it on my CL program? Please advise how to do the same for a numeric key. 

    Thanks. Any help on this is greatly appreciated.

    30 pointsBadges:
    report
  • Vsevilod
    Yes it can.

    DCLF VAR(&NUM) TYPE(*DEC) LEN(2) VALUE(1)
    DCLF VAR(&VALUE) TYPE(*CHAR) LEN(20) VALUE('ABC')

    OVRDBF FILE(MYFILE) POSITION(*KEY &NUM MYKEY  &VALUE)

    Hope this helps.
    135 pointsBadges:
    report
  • jching

    Thanks Vsevilod.

    However, I tried the same before but it did not work. 

    It seems that the key value in parameter POSITION is expected to be a quoted charcter string.  I also tried adding the quotes in the variable and also resulted with an error message

    30 pointsBadges:
    report
  • Vsevilod
    Hi jching,

    Sorry. I missed the quotes in the &VALUE field. It should be:

    DCLF VAR(&VALUE) TYPE(*CHAR) LEN(20) VALUE('''ABC''')
    135 pointsBadges:
    report
  • Vsevilod
    Kindly disregard my post above. Can you post your codes you used and what error message appeared when you ran the program?
    135 pointsBadges:
    report
  • jching

    PGM        PARM(&#VALUE)                          
    DCL        VAR(&#VALUE) TYPE(*CHAR) LEN(4)        
    DCL        VAR(&#VAR)   TYPE(*CHAR) LEN(10)   

    DCLF       FILE(FILEA) OPNID(A)       

    CHGVAR     VAR(&#VAR) VALUE('''' || &#VALUE || '''')  

    OVRDBF     FILE(FILEA) TOFILE(FILEA) +          
                 POSITION(*KEY 1 RECORDA &#VAR) SECURE(*YES)
    RCVF       OPNID(A)                                   

    The above codes return the messeage ID CPF4137.  The same error message is returned  if &#VALUE instead of &#VAR.  If I use a quoted char string then the record is found.   I need the &#VALUE to be a variable to make my program as generic as it can be.  Thanks.

     

     

                        

     

     

     

                  

     

    30 pointsBadges:
    report

Forgot Password

No problem! Submit your e-mail address below. We'll send you an e-mail containing your password.

Your password has been sent to:

To follow this tag...

There was an error processing your information. Please try again later.

REGISTER or login:

Forgot Password?
By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy

Thanks! We'll email you when relevant content is added and updated.

Following