Portal | Manuals | References | Downloads | Info | Programs | JCLs | Master the Mainframes
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist Usergroups Profile Log in to check your private messages Log in
 
How to generate a new unique Input file with a reference fil

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> CLIST & REXX
View previous topic :: :: View next topic  
Author Message
for1ranjith

New User


Joined: 15 Jun 2017
Posts: 4
Location: Florida

PostPosted: Sat Jul 01, 2017 12:09 pm    Post subject: How to generate a new unique Input file with a reference fil
Reply with quote

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

Willy Jensen

Active User


Joined: 01 Sep 2015
Posts: 155
Location: Switzerland

PostPosted: Sat Jul 01, 2017 2:08 pm    Post subject:
Reply with quote

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

Global Moderator


Joined: 06 Jun 2008
Posts: 8132
Location: East Dubuque, Illinois, USA

PostPosted: Sat Jul 01, 2017 4:36 pm    Post subject:
Reply with quote

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

New User


Joined: 15 Jun 2017
Posts: 4
Location: Florida

PostPosted: Sun Jul 02, 2017 4:32 am    Post subject: Reply to: How to generate a new unique Input file with a reference fil
Reply with quote

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

New User


Joined: 15 Jun 2017
Posts: 4
Location: Florida

PostPosted: Sun Jul 02, 2017 12:22 pm    Post subject:
Reply with quote

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

Senior Member


Joined: 07 Feb 2009
Posts: 1032
Location: Oostende, Belgium

PostPosted: Sun Jul 02, 2017 1:29 pm    Post subject:
Reply with quote

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

Global Moderator


Joined: 10 May 2007
Posts: 1848
Location: UK

PostPosted: Sun Jul 02, 2017 2:57 pm    Post subject:
Reply with quote

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

Active User


Joined: 28 Jan 2012
Posts: 287
Location: Room: TREE(3). Hilbert's Hotel

PostPosted: Mon Jul 03, 2017 1:21 pm    Post subject:
Reply with quote

You might want to check the IEBDG utility: Generate test data
Back to top
View user's profile Send private message
enrico-sorichetti

Global Moderator


Joined: 14 Mar 2007
Posts: 10293
Location: italy

PostPosted: Mon Jul 03, 2017 2:55 pm    Post subject:
Reply with quote

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

Active User


Joined: 29 Apr 2008
Posts: 128
Location: Maryland

PostPosted: Mon Jul 03, 2017 9:20 pm    Post subject:
Reply with quote

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

New User


Joined: 15 Jun 2017
Posts: 4
Location: Florida

PostPosted: Mon Jul 03, 2017 11:42 pm    Post subject:
Reply with quote

Thank Nic & Enrico.
Back to top
View user's profile Send private message
sergeyken

Active User


Joined: 29 Apr 2008
Posts: 128
Location: Maryland

PostPosted: Thu Jul 06, 2017 7:04 pm    Post subject:
Reply with quote

sergeyken wrote:
for1ranjith wrote:
Code:
 . . .


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
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> CLIST & REXX All times are GMT + 6 Hours
Page 1 of 1

 

Search our Forum:

Similar Topics
Topic Author Forum Replies Posted
No new posts editting the file by inserting zeros ... pramodrsingh DFSORT/ICETOOL 9 Mon Aug 21, 2017 5:58 pm
No new posts Match two files using multiple keys a... santoshks1987 SYNCSORT 11 Fri Aug 18, 2017 10:50 am
No new posts Getting Mutiple input from Panels vidyaa CLIST & REXX 12 Mon Aug 14, 2017 1:28 pm
No new posts Multiple VSAM files single output fil... Mohan Kothakota DFSORT/ICETOOL 11 Wed Aug 09, 2017 7:57 pm
This topic is locked: you cannot edit posts or make replies. rexx code to create a ps file Bharath Vikraman CLIST & REXX 4 Mon Aug 07, 2017 10:30 am


Facebook
Back to Top
 
Mainframe Wiki | Forum Rules | Bookmarks | Subscriptions | FAQ | Tutorials | Contact Us