IBM Mainframe Forum Index
 
Log In
 
IBM Mainframe Forum Index Mainframe: Search IBM Mainframe Forum: FAQ Register
 

REXX - Dynamic file Creation


IBM Mainframe Forums -> CLIST & REXX
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
d_sarlie

New User


Joined: 22 Apr 2008
Posts: 42
Location: coimbatore

PostPosted: Tue Jun 27, 2017 7:30 pm
Reply with quote

/***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
View user's profile Send private message
Nic Clouston

Global Moderator


Joined: 10 May 2007
Posts: 2455
Location: Hampshire, UK

PostPosted: Tue Jun 27, 2017 8:08 pm
Reply with quote

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
View user's profile Send private message
d_sarlie

New User


Joined: 22 Apr 2008
Posts: 42
Location: coimbatore

PostPosted: Tue Jun 27, 2017 8:14 pm
Reply with quote

[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
View user's profile Send private message
d_sarlie

New User


Joined: 22 Apr 2008
Posts: 42
Location: coimbatore

PostPosted: Tue Jun 27, 2017 8:16 pm
Reply with quote

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
View user's profile Send private message
d_sarlie

New User


Joined: 22 Apr 2008
Posts: 42
Location: coimbatore

PostPosted: Tue Jun 27, 2017 8:18 pm
Reply with quote

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
View user's profile Send private message
Nic Clouston

Global Moderator


Joined: 10 May 2007
Posts: 2455
Location: Hampshire, UK

PostPosted: Tue Jun 27, 2017 8:21 pm
Reply with quote

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
View user's profile Send private message
Nic Clouston

Global Moderator


Joined: 10 May 2007
Posts: 2455
Location: Hampshire, UK

PostPosted: Wed Jun 28, 2017 4:21 pm
Reply with quote

[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
View user's profile Send private message
sergeyken

Senior Member


Joined: 29 Apr 2008
Posts: 2012
Location: USA

PostPosted: Thu Jun 29, 2017 12:37 am
Reply with quote

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
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   Reply to topic View Bookmarks
All times are GMT + 6 Hours
Forum Index -> CLIST & REXX

 


Similar Topics
Topic Forum Replies
No new posts How to split large record length file... DFSORT/ICETOOL 10
No new posts Running REXX through JOB CLIST & REXX 13
No new posts Error to read log with rexx CLIST & REXX 11
No new posts Extracting Variable decimal numbers f... DFSORT/ICETOOL 17
No new posts SFTP Issue - destination file record ... All Other Mainframe Topics 2
Search our Forums:

Back to Top