View previous topic :: View next topic
|
Author |
Message |
for1ranjith
New User
Joined: 15 Jun 2017 Posts: 4 Location: Florida
|
|
|
|
Hi Team,
I have a requirement to create a input file, by taking a production file as a reference. File records will have common layout, but 3 fields should have unique values. can you advice me a approach to achieve this.
e.g:
header
AAAAAA BBBBB CCCCC DDDDD 11111
AAAAAA BBBB1 CCCC1 DDDDD 11111
AAAAAA BBBB2 CCCC2 DDDDD 11111
AAAAAA BBBB3 CCCC3 DDDDD 11111
AAAAAA BBBB4 CCCC4 DDDDD 11111
AAAAAA BBBB5 CCCC5 DDDDD 11111
trailer
above file has fixed values in few columns, and should have unique values in few columns. how to generate a randomized values by referring a production file. |
|
Back to top |
|
|
Willy Jensen
Active Member
Joined: 01 Sep 2015 Posts: 724 Location: Denmark
|
|
|
|
You talk about unique and random, which do you really want?
Unique numbers can be created in a number of ways.
- Just increase a number in each iteration.
- Using the TIME('L') function.
Unique random numbers can be generated by using the RANDOM() function in combination with a stem or a list to check for duplicate numbers. |
|
Back to top |
|
|
Robert Sample
Global Moderator
Joined: 06 Jun 2008 Posts: 8700 Location: Dubuque, Iowa, USA
|
|
|
|
Make up your mind, first. If you want random values, then you MUST accept the possibility that the values will NOT be unique -- period. Random means random, and random values can occur more than once in a sequence. If you want unique values, the sequence is not random. |
|
Back to top |
|
|
for1ranjith
New User
Joined: 15 Jun 2017 Posts: 4 Location: Florida
|
|
|
|
Thanks for your responses, however to be very clear, I'm looking for unique values(in sequence). As suggested, will use the time function for generating the feed file. |
|
Back to top |
|
|
for1ranjith
New User
Joined: 15 Jun 2017 Posts: 4 Location: Florida
|
|
|
|
Can you let me know how to overlay data for specific column positions. and keep the rest of the data as it is available in the file.
for e.g., Below is my reference file for creating another file in the similar layout by overlaying few fields.
$$HEADERASN20170616ITRON METER
06739553EITSP20170614319717483 00010000000500001NF240240131 2003000 00000201706140.12.58 2017042412 900
06739554EITSP20170614319717484 00010000000500001NF240240132 2003000 00000201706140.12.59 2017042412 900
06739555EITSP20170614319717485 00010000000500001NF240240133 2003000 00000201706580.12.60 2017042412 900
$$TRAILERASN00000000500000000000000003
i want to create another similar file like above by replacing the colored data records with unique values. I tried below logic, but it is erasing the whole records except the first 8 characters.
DS.METERS.INPUT.FILE - this is my input file having below records, I want to overlay this 8 bytes in my output file. and unique values in the colored columns.
10000001
10000002
10000003
DS.REFEREN.FILE- This is my reference file.
Code: |
"ALLOC F(INFILE) DSN('DS.METERS.INPUT.FILE') SHR REU"
"EXECIO * DISKR INFILE (FINIS STEM MYFILE."
"FREE F(INFILE)"
"ALLOC F(OUTFL) DSN('DS.REFEREN.FILE') SHR REU"
I=0
C=1
DO WHILE I <= MYFILE.0
I = I + 1
X = SUBSTR(MYFILE.I,1,8)
D = SUBSTR(X,1,8)
OUTFL.C=D
"EXECIO * DISKW OUTFL(FINIS STEM OUTFL."
C = C +1
END
D = DS.REFEREN.FILE
X = DS.METERS.INPUT.FILE
Exit |
Please advice
Coded for you - do it yourself next time |
|
Back to top |
|
|
prino
Senior Member
Joined: 07 Feb 2009 Posts: 1310 Location: Vilnius, Lithuania
|
|
|
|
Your profile tells us you have the following skills:
jcl,cobol,db2,rexx,cics
In that light, this post warrants only one answer: Sigh...
You really haven't got a clue as to what you are doing, don't you? |
|
Back to top |
|
|
Nic Clouston
Global Moderator
Joined: 10 May 2007 Posts: 2454 Location: Hampshire, UK
|
|
|
|
If you look at your last post you will see that the code has been coded. This helps in presentation and maintains the indentation. You appear to have no indentation which makes your coded even harder to read. Please structure your code properly and use the code tags to preserve that structure and the structure of any data.
Next point - you are not dealing with "files" but with "data sets". They are different things in the mainframe world.
Next point - do not use colours. Add a 'ruler', use the code tags and refer by column.
Finally, you almost answered your own question when you used the word 'overlaying'. Now go to the Rexx manual and look in the index. |
|
Back to top |
|
|
mistah kurtz
Active User
Joined: 28 Jan 2012 Posts: 316 Location: Room: TREE(3). Hilbert's Hotel
|
|
Back to top |
|
|
enrico-sorichetti
Superior Member
Joined: 14 Mar 2007 Posts: 10879 Location: italy
|
|
|
|
Probably what You want is more along the lines of ...
Code: |
/*
Allocate Your input and output datasets
- not needed if run as a job,
datasets will be handled by the proper JCL satatements
*/
Address TSO "EXECIO * DISKR <input ddname> (FINIS STEM idata."
do i = 1 to idata.0
idata.i = overlay( <value>, idata.i, <position> )
end
Address TSO "EXECIO" idata.0 "DISKW <output ddname> (FINIS STEM idata."
/*
Free Your input and output datasets
- not needed if run as a job,
datasets will be handled by the proper JCL satatements
*/ |
up to You to build the proper <value> |
|
Back to top |
|
|
sergeyken
Senior Member
Joined: 29 Apr 2008 Posts: 2115 Location: USA
|
|
|
|
for1ranjith wrote: |
Code: |
"ALLOC F(INFILE) DSN('DS.METERS.INPUT.FILE') SHR REU"
"EXECIO * DISKR INFILE (FINIS STEM MYFILE."
"FREE F(INFILE)"
"ALLOC F(OUTFL) DSN('DS.REFEREN.FILE') SHR REU"
I=0
C=1
DO WHILE I <= MYFILE.0
I = I + 1
X = SUBSTR(MYFILE.I,1,8)
D = SUBSTR(X,1,8)
OUTFL.C=D
"EXECIO * DISKW OUTFL(FINIS STEM OUTFL."
C = C +1
END
D = DS.REFEREN.FILE
X = DS.METERS.INPUT.FILE
Exit |
|
My note.
I have an impression that this is not only the first REXX in your life, but the first program you've had ever written at all (or copy-pasted?), isn't it?
90% of the lines of your code prove it for sure. |
|
Back to top |
|
|
for1ranjith
New User
Joined: 15 Jun 2017 Posts: 4 Location: Florida
|
|
|
|
Thank Nic & Enrico. |
|
Back to top |
|
|
sergeyken
Senior Member
Joined: 29 Apr 2008 Posts: 2115 Location: USA
|
|
|
|
sergeyken wrote: |
My note.
I have an impression that this is not only the first REXX in your life, but the first program you've had ever written at all (or copy-pasted?), isn't it?
90% of the lines of your code prove it for sure. |
There was no reaction; so I will clarify the idea a little bit.
1. While working with files (data sets in zOS), you must either to use a pair of ALLOCATE/FREE fro each of used DSNAMEs, or (when running in batch only) use NONE of ALLOCATE/FREE at all; in batch there are 100500 reasons to use normal DD allocation vs. dynamic allocation.
It is considered as serious bug when using ALLOCATE without FREE, or FREE without ALLOCATE (the last one just physically deletes DD allocation from job step, making the DDNAME not available for the rest of code in the same job step).
2. Loops are easily organized with DO I=A to B with no extra coding
3. It makes no sense at all to reassign the same values of SUBSTR function many times
4. When preparing output file, you need EITHER to create a stem step by step inside the loop, then use EXECIO after the loop, OR create single line and immediately write it using single EXICIO per line inside the loop as well. In your case there is unclear mixture of both approaches.
5. When assigning character string to a REXX variable, the string must be quoted; otherwise its value depends on some other conditions.
6. It makes no sense to assign any value to any variable just before operator EXIT; all results are just lost
7. Other notes might be added (more notes than the number of lines in your "code")
Keeping in mind the above said 1-7, your code might look like this
Code: |
"EXECIO * DISKR INFILE (FINIS STEM MYFILE."
DO I = 1 to MYFILE.0
OUTFL.I = Left( MyFile.I, 8 )
END I
"EXECIO * DISKW OUTFL (FINIS STEM OUTFL."
Exit |
Or like this (using program stack instead of stem - since all "processing" is done in sequential order)
Code: |
"EXECIO * DISKR INFILE (FINIS"
Size = Queued()
DO (Size)
Parse Pull NewRecord +8 .
Queue NewRecord
END
"EXECIO * DISKW OUTFL (FINIS"
Exit |
|
|
Back to top |
|
|
|