View previous topic :: View next topic
|
Author |
Message |
Unshriven
New User
Joined: 04 Jan 2010 Posts: 7 Location: Dallas
|
|
|
|
I'm been tasked to write a Rexx program to check a file. I've never used Rexx and am a bit lost but I had this foisted on my because I expressed interest in learning Rexx. My task is this:
Read 4 sequential datasets
check the value in a certain column of each
if the value is not 0000 then copy that record to a temp dataset (and add each exception to that dataset)
when all 4 datasets have been read write the file if the program has found exceptions, otherwise exit and do nothing.
I've been given access to a list of existing Rexx programs as an example. To me, it's like saying "Here's War and Peace" by the end of the week you should be reading Russian. Yes, I'm reading the tutorials and it's very slow going. I don't have any other programming experience.
Any samples, guidance or suggestions (examples) would be greatly appreciated. |
|
Back to top |
|
|
expat
Global Moderator
Joined: 14 Mar 2007 Posts: 8796 Location: Welsh Wales
|
|
|
|
Yes, tell them that your sort product would be far more efficient than using REXX |
|
Back to top |
|
|
PeterHolland
Global Moderator
Joined: 27 Oct 2009 Posts: 2481 Location: Netherlands, Amstelveen
|
|
|
|
If im right there is another forum for students like you. |
|
Back to top |
|
|
Akatsukami
Global Moderator
Joined: 03 Oct 2009 Posts: 1787 Location: Bloomington, IL
|
|
|
|
Depending on the size of the input data sets, performance may range from adequate to execrable; you have been warned.
I don't entirely understand
Quote: |
if the value is not 0000 then copy that record to a temp dataset (and add each exception to that dataset)
when all 4 datasets have been read write the file if the program has found exceptions, otherwise exit and do nothing. |
As you may already know, Rexx has no facility for allocating data sets and files. Assuming that you are running this in the background (i.e., in batch), you can either allocate them statically in the JCL, or dynamically by means of the TSO ALLOCATE command, if you're executing the TMP (IKJEFT*) or have established a TSO environment.
I/O is done with the EXECIO command. Use the SUBSTR function, the INDEX function, and/or the POS function to select and search the proper positions in each record. Remember that all Rexx variables are character strings, and there are therefore no true Boolean variables; IMNSHO, it is better to code
Code: |
flag = val
if (flag=1) then do |
than
Code: |
flag = val
if (flag) then do |
since flag cannot be restricted to having either zero or one as valuers. |
|
Back to top |
|
|
Unshriven
New User
Joined: 04 Jan 2010 Posts: 7 Location: Dallas
|
|
|
|
No, I didn't know Rexx can't write datasets. Also, remember, I'm relaying what I was told by my boss so if I describe it inaccurately, I apologize.
The situation is that I've been given a batch job that does 4 queries against a dataset then it produces 4 datasets. In one of the columns of the dataset, there is a flag that should be set to 0000 (this shows that one of the aspects of the facilities we're looking at has been reset). If the value has not been reset, it retains it's last value (not 0). If that is the case, then I need that record written out to another dataset (my boss told me Rexx can write it to a temp file then at the end 'writeall' to allocate the dataset). Then this dataset will be emailed out to be checked. If there are no exceptions, nothing is sent.
I don't know if this is the easiest way to do it. Some others at work have suggested sort but I've been told to do it in Rexx. |
|
Back to top |
|
|
enrico-sorichetti
Superior Member
Joined: 14 Mar 2007 Posts: 10888 Location: italy
|
|
|
|
Quote: |
Some others at work have suggested sort but I've been told to do it in Rexx. |
You were not told.... You asked to be told...
being unskilled in REXX means that just helping You with the logic will just lead nowhere
You will need full spoonfeeding for each rexx statement to be used, and this is not help... is something completely different
also , repeating for the zillionth time, REXX is not the proper choice for processing large amounts of records.
use Your sort product... |
|
Back to top |
|
|
Unshriven
New User
Joined: 04 Jan 2010 Posts: 7 Location: Dallas
|
|
|
|
I agree but my shop loves the whole "let's throw them to the wolves" mentality in training. I particularly think it's the most horrid, in efficient means to train anyone but they really don't want my opinion.
As for being told, yes I said sort may be a better choice and the response was "yeah, maybe, but you're going to do it in Rexx". so yes, I was 'told'.
I hate having to be spoon fed, I hate the fact that I was given a production job to learn on that has a strict time limit. Good choice but that's what I have to live with. |
|
Back to top |
|
|
Akatsukami
Global Moderator
Joined: 03 Oct 2009 Posts: 1787 Location: Bloomington, IL
|
|
|
|
Unshriven wrote: |
No, I didn't know Rexx can't write datasets. |
It can write data sets (if we consider the EXECIO command part of Rexx), it can't allocate them.
If you were writing a COBOL program, you would probably write something like:
Code: |
ENVIRONMENT DIVISION.
CONFIGURATION SECTION.
INPUT-OUTPUT SECTION.
FILE-CONTROL.
*
SELECT A-FILE ASSIGN TO UT-S-FOO.
|
and
Code: |
READ FOO AT END
some stuff. |
When you executed it, your JCL would look like
Code: |
//STEPNN EXEC PGM=RORA
//FOO DD DSN=BAR,DISP=SHR |
The file FOO is associated withe data set BAR by the JCL (that's what JCL does, not sort records, copy one PDS to another, or any of the myriad misconceptions that too many querents have). In Rexx, you would write:
Code: |
EXECIO 1 DISKR FOO
pull record |
and the JCL would be
Code: |
//STEPNN EXEC PGM=IRXJCL,PARM='RORA'
//FOO DD DSN=BAR,DISP=SHR |
Alternatively, as I've said, if you're established a TSO environment, you could code
Code: |
"ALLOC FI(FOO) DA('BAR') SHR"
"EXECIO 1 DISKR FOO"
pull record |
|
|
Back to top |
|
|
Pedro
Global Moderator
Joined: 01 Sep 2006 Posts: 2594 Location: Silicon Valley
|
|
|
|
Quote: |
Rexx can write it to a temp file then at the end 'writeall' to allocate the dataset |
I suggest that you save any records you want to write to a rexx stem variable and then when you are done to use EXECIO to write the entire stem to your file.
So, find the rexx reference manual and read up on rexx stem variables and EXECIO syntax. |
|
Back to top |
|
|
Unshriven
New User
Joined: 04 Jan 2010 Posts: 7 Location: Dallas
|
|
|
|
I appreciate everyone's help. I'm going back to him and saying this is not working. The first time I should at least be shown. I'll let everyone know how it works out. |
|
Back to top |
|
|
Pedro
Global Moderator
Joined: 01 Sep 2006 Posts: 2594 Location: Silicon Valley
|
|
|
|
Start with this program, then add to it:
Code: |
/* rexx */
Say 'Hello World!' |
|
|
Back to top |
|
|
expat
Global Moderator
Joined: 14 Mar 2007 Posts: 8796 Location: Welsh Wales
|
|
|
|
I suppose that you could really show them, and use REXX to invoke SORT to do the processing |
|
Back to top |
|
|
chaoj
Active User
Joined: 03 Jun 2010 Posts: 103 Location: Dalian
|
|
|
|
Unshriven wrote: |
I've been given access to a list of existing Rexx programs as an example. |
You're so lucky and could read sample rexx code, I learn rexx from its name : rexx , rexx what ? who knows , like the TSO's ready , ready for what ? |
|
Back to top |
|
|
Anuj Dhawan
Superior Member
Joined: 22 Apr 2006 Posts: 6248 Location: Mumbai, India
|
|
|
|
Quote: |
I don't have any other programming experience. |
If that's the case - possibly start by writing a pseudo code, irrespective of which language to use - and then try to use the language of your choice. Logics are universal, most of the times. |
|
Back to top |
|
|
|