View previous topic :: View next topic
|
Author |
Message |
d_sarlie
New User
Joined: 22 Apr 2008 Posts: 42 Location: coimbatore
|
|
|
|
/***REXX****/
INPDSET = 'X.CLIENT'
OUTDSET = 'MMMMMM.OUTPUT.FILE'
COUNT=1
TEMP=1
OUTSET=1
"ALLOC DDN(INFILE) DSN('"INPDSET"') SHR REUSE"
"EXECIO * DISKR INFILE(STEM RECD. FINIS)"
"FREE DDN(INFILE)"
DO RX=1 TO RECD.0
LREC=RECD.0
SAY 'LREC' LREC
CURREC=RECD.RX
SAY 'CURREC' CURREC
OUT.TEMP=RECD.RX
SAY 'OUT.TEMP' OUT.TEMP
RNEXT=RX+1
SAY 'RNEXT' RNEXT
NEXREC=RECD.RNEXT
SAY 'NEXREC' NEXREC
NEXREC=STRIP(CURREC)
LEV=SUBSTR(CURREC,7,3)
LEV=STRIP(LEV)
IF (LEV='511' | RX=LREC) & OUTSET=1 THEN
SAY 'I AM INTO LOOP1'
SAY 'LEV' LEV
SAY 'RX' RX
SAY 'OUTSET' OUTSET
OUTDS=OUTDSET|| '.F' ||LEV
OUTDS=STRIP(OUTDS)
SAY 'OUTDS' OUTDS
SAY 'INPDSET' INPDSET
"ALLOC DDN(OFILE) DSN('"OUTDS"')NEW ",
"LIKE('"INPDSET"')"
"FREE DDN(OFILE)"
"ALLOC DDN(OFILE) DSN('"OUTDS"') SHR REUSE"
"EXECIO * DISKW OFILE(STEM RECD. FINIS)"
"FREE DDN(OFILE)"
DROP OUT.
TEMP=0
COUNT=COUNT+1
OUTSET=OUTSET+1
SAY 'TEMP' TEMP
SAY 'COUNT' COUNT
SAY 'OUTSET' OUTSET
END
EXIT
This is my rexx code
The output file to be created is as follows
MMMMMM.OUTPUT.FILE.FMOH --> this should have 1 MOH record
MMMMMM.OUTPUT.FILE.FDOH --> This should have 2 DOH record
MMMMMM.OUTPUT.FILE.FFOH --> this should have 4 FOH record
The content in X.CLIENT is
000001MOH
000002FOH
000003DOH
000004FOH
000005FOH
000006DOH
000007FOH
I am not getting the desired output
I am new to rexx. Can somebody help me |
|
Back to top |
|
|
Nic Clouston
Global Moderator
Joined: 10 May 2007 Posts: 2455 Location: Hampshire, UK
|
|
|
|
Run with a Rexx trace set and diagnose your problem.
When posting code and data use the code tags - you should know that after 9 years. |
|
Back to top |
|
|
d_sarlie
New User
Joined: 22 Apr 2008 Posts: 42 Location: coimbatore
|
|
|
|
[quote="Nic Clouston"]Run with a Rexx trace set and diagnose your problem.
NIC if I was able to identify the issue I might not have seek for help. |
|
Back to top |
|
|
d_sarlie
New User
Joined: 22 Apr 2008 Posts: 42 Location: coimbatore
|
|
|
|
NIC I never had a chance to work on Rexx.
I would be grateful to you if you could help me with this one |
|
Back to top |
|
|
d_sarlie
New User
Joined: 22 Apr 2008 Posts: 42 Location: coimbatore
|
|
|
|
000001 /***REXX****/
000002 INPDSET = 'X.CLIENT'
000003 OUTDSET = 'MMMMMM.OUTPUT.FILE'
000004 COUNT=1
000005 TEMP=1
000006 OUTSET=1
000007 "ALLOC DDN(INFILE) DSN('"INPDSET"') SHR REUSE"
000008 "EXECIO * DISKR INFILE(STEM RECD. FINIS)"
000009 "FREE DDN(INFILE)"
000010 DO RX=1 TO RECD.0
000011 LREC=RECD.0
000012 SAY 'LREC' LREC
000013 CURREC=RECD.RX
000014 SAY 'CURREC' CURREC
000015 OUT.TEMP=RECD.RX
000016 SAY 'OUT.TEMP' OUT.TEMP
000017 RNEXT=RX+1
000018 SAY 'RNEXT' RNEXT
000019 NEXREC=RECD.RNEXT
000020 SAY 'NEXREC' NEXREC
000021 NEXREC=STRIP(CURREC)
000022 LEV=SUBSTR(CURREC,7,3)
000023 LEV=STRIP(LEV)
000024 IF (LEV='511' | RX=LREC) & OUTSET=1 THEN
000025 SAY 'I AM INTO LOOP1'
000026 SAY 'LEV' LEV
000027 SAY 'RX' RX
000028 SAY 'OUTSET' OUTSET
000029 OUTDS=OUTDSET|| '.F' ||LEV
000030 OUTDS=STRIP(OUTDS)
000031 SAY 'OUTDS' OUTDS
000032 SAY 'INPDSET' INPDSET
000033 "ALLOC DDN(OFILE) DSN('"OUTDS"')NEW ",
000034 "LIKE('"INPDSET"')"
000035 "FREE DDN(OFILE)"
000036 "ALLOC DDN(OFILE) DSN('"OUTDS"') SHR REUSE"
000037 "EXECIO * DISKW OFILE(STEM RECD. FINIS)"
000038 "FREE DDN(OFILE)"
000039 DROP OUT.
000040 TEMP=0
000041 COUNT=COUNT+1
000042 OUTSET=OUTSET+1
000043 SAY 'TEMP' TEMP
000044 SAY 'COUNT' COUNT
000045 SAY 'OUTSET' OUTSET
000046 END
000047 EXIT |
|
Back to top |
|
|
Nic Clouston
Global Moderator
Joined: 10 May 2007 Posts: 2455 Location: Hampshire, UK
|
|
|
|
Still no code tags and you have been asked to use them on previous posts. If you want help you have to help the helpers by presenting your code properly.
All the information that you need is in the manuals.
[locked] |
|
Back to top |
|
|
Nic Clouston
Global Moderator
Joined: 10 May 2007 Posts: 2455 Location: Hampshire, UK
|
|
|
|
[Unlocked]
What you have is bad design.
Your requirement is to write records to various output datasets depending on the last 3 bytes in the record.
What you are doing is:
read a record
determine dataset name
allocate the dataset
write ALL the input records to the dataset
read next record
So you are writing all the records to each dataset each time you read a record. Plus the overhead of allocating and de-allocating the datset each time.
What you should do is:
read a record
allocate to a stem depending on its identifier
read next record
set the record count in each output stem.0
Allocate the datasets
write the records from each stem to the appropriate dataset
free
exit |
|
Back to top |
|
|
sergeyken
Senior Member
Joined: 29 Apr 2008 Posts: 2012 Location: USA
|
|
|
|
d_sarlie wrote: |
I am not getting the desired output
I am new to rexx. Can somebody help me |
The problem is not that you are new to REXX.
It looks like you are new to the whole Information Technology...
Did you ever hear about an "algorithm"?
This thing must be ready in your mind BEFORE you start any coding, either in REXX, or in whatever else.
Your question demonstrated that you have no idea about this stuff.
Start from understanding (at least) algorithms. Otherwise no "modern gadget" would help you to do your own task unless someone else has made it for you (as free of charge "help"). |
|
Back to top |
|
|
|