Rexx as400 – IO utility (or how to read more than one file)

0 pts.
Tags:
Development
I need to read more than one file in As400 Rexx. can someone provide IO utility or sample code thanks
ASKED: January 6, 2005  1:59 AM
UPDATED: January 6, 2011  7:53 PM

Answer Wiki

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

This was published in a Club Tech iSeries Programming Tips Newsletter:

4. READING TWO FILES IN A REXX PROGRAM
Q: Is it possible to read more than one file in a REXX program? According to the documentation I have read so far, I can specify something such as LineIn(MyFile). I’m working on the iSeries, and overriding the StdIn works well for a single file, but I want to read two files to compare options.

A: You’ve discovered a limitation of REXX on the iSeries. A program can read only one database file when you override StdIn before the first Parse LineIn or Parse Pull instruction. To read two files, you can use the StrREXPrc (Start REXX Procedure) command from inside a REXX program to start a child invocation of the REXX interpreter, read a file there, and pass back records via the REXX external data queue. Both the parent and child invocations of the REXX interpreter will share the same external data queue, but each invocation can open a different file.

The Parse LineIn instruction reads a record from StdIn or its override. The Parse Pull instruction reads a record from the REXX external data queue. If the external data queue is empty, then Parse Pull behaves like Parse LineIn.

For example, program Compare works with two input files:

/*——————————————————*/
/* Program: Compare */
/* Language: REXX */
/* Purpose: Compare two database files */
/*——————————————————*/
“StrREXPrc QueueFile Parm(‘MYLIB2 MYFILE2 MYMBR2′)”
“OvrDbF StdIn MyLib1/MyFile1 MyMbr1″
Do Queued()
Parse LineIn Record1 /* read MyLib1/MyFile1/MyMbr1 */
Parse Pull Record2 /* read MyLib2/MyFile2/MyMbr2 */
/* compare Record1 and Record2 here */
End
The Parse LineIn instruction reads records from MyLib1/MyFile1/MyMbr1, and the Parse Pull instruction reads copies of MyLib2/MyFile2/MyMbr2 records from the REXX external data queue. Program Compare calls the QueueFile program through the StrREXPrc command:

/*——————————————————*/
/* Program: QueueFile */
/* Language: REXX */
/* Purpose: Copy database file into REXX data queue */
/*——————————————————*/
Arg Library File Member
“OvrDbF StdIn” Library”/”File Member
Do Forever
Parse LineIn Record
If Record = ” Then Return
Queue Record
End
The QueueFile program copies records from MyLib2/MyFile2/MyMbr2 into the external data queue.

The above tip was from Gene Gaunt and was published in iSeries NEWS.

Discuss This Question: 3  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
  • GonenSho
    thanks for reply ! Works very nice. thanks again
    0 pointsBadges:
    report
  • REXXguy
    I've found a way to access and manipulate as many tables/files as you'd like in a REXX program on the iSeries. You use SQL. If interested, let me know and I'll provide examples of how.
    10 pointsBadges:
    report
  • TomLiotta
    You use SQL. REXX and SQL get along very well on all AS/400s and later systems, without requiring the SQL Dev Kit product. Anyone familiar with REXX can pick up the concepts easily. I can also post various samples if needed. I'm pretty sure we can cover most scenarios. Tom
    125,585 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