RPG/400 – CL command to search a record like CHAIN opcode in RPG

140 pts.
Tags:
AS/400 Control Language
CHAIN
CL
RPG
RPG/400
Please advice we have any command there in CL to search or find a record like CHAIN opcode in RPG.
ASKED: January 19, 2009  6:43 AM
UPDATED: December 30, 2009  2:29 PM

Answer Wiki

Thanks. We'll let you know when a new response is added.

The <a href=”http://www.powercl.com/”>PowerCL: CL for Files (CLF)</a> product provides a CL <a href=”http://www.powercl.com/clf/clfcommands/chain”>CHAIN</a> command to search and find a record by key or relative record number. The product also has a <a href=”http://www.powercl.com/clf/clfcommands/readrcdclf”>ReadRcdCLF</a> command which provides quite a bit more function than the RPG CHAIN operation code.

Bruce Vining
(one of the authors of CLF)

==============================================

Hi,

There’s not really any command in CL to do this, however you may be able to use OPNQRYF to get a similar result.

Regards,

Martin Gilbert.

Discuss This Question: 6  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
  • Cwc
    Actually, you can use the OVRDBF command to position the file pointer to the desired record, so that when the RCVF command executes, it will read that record. Here's an example: OVRDBF FILE(MYFILE) POSITION(*KEY 1 MYFORMAT 'KEYVALUE'), where MYFORMAT is the record format name, and KEYVALUE is the value of the key being searched for. Note that random record access in CL isn't perfect, and isn't as straightfoward as RPG. I have found that it has some quirkiness when using a variable for the key value, and if the key value is a literal, you have to include the number of blanks on the end so that it will match up to the exact record. Otherwise, it will position the pointer just past it, and the RCVF will read that record instead. To get around that, the *KEYAE retrieve order could be used, and then you could check after the read to make sure you got the key value you're expecting. So you'll need to experiment with it and read the help text to get it to work the way you want.
    4,290 pointsBadges:
    report
  • Chandrababu
    how exact functioning of chain opcode in rpg and how it works?
    15 pointsBadges:
    report
  • Cwc
    Chandrababu, here is IBM's documentation for a comprehensive explanation of RPG's CHAIN operation: http://publib.boulder.ibm.com/infocenter/iseries/v6r1m0/index.jsp
    4,290 pointsBadges:
    report
  • Cwc
    I don't know why the posting of links sometimes doesn't work in this editor. Here's the URL that should have appeared above: http://publib.boulder.ibm.com/infocenter/iseries/v6r1m0/topic/rzasd/sc092508921.htm#zzchain
    4,290 pointsBadges:
    report
  • JennyMack
    Hi Cwc, Sorry to see you're having some trouble inserting a link. You need to use our in-editor link tool, since for security reasons we don't allow the standard HTML tags. You might have run into a problem by using a URL as the title as well as the link. Askt1, this link provided by Cwc should work. Jenny Community Manager
    4,280 pointsBadges:
    report
  • Cwc
    Thanks for the info, Jenny. I had used the link tool, but didn't realize that using the URL as the title as well as the link wouldn't work.
    4,290 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