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

Field expansion Tool in REXX


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

New User


Joined: 22 Aug 2007
Posts: 66
Location: bangalore

PostPosted: Tue Jun 10, 2008 10:39 am
Reply with quote

Hi All,

I need to develop a tool in REXX. The desc is as below:

Generally when a field is expanded in a file, other fields have to be shifted towards right to accommodate the new field (expanded). This utility should expand the field and as well as reformat the file to accommodate the new field.

For Example : ID X(5),Name X(20),PH X(10),CITY X(10), COUNTRY(10)
If City field is expanded to X(20), the already existing data in the COUNTRY field has to be moved towards right to accommodate the 10 characters newly added.

Can anybody help on this as i am new to rexx

Thanks in advance!
Back to top
View user's profile Send private message
enrico-sorichetti

Superior Member


Joined: 14 Mar 2007
Posts: 10873
Location: italy

PostPosted: Tue Jun 10, 2008 11:31 am
Reply with quote

Here is a snippet...

Code:
/* inp contains the old data
ID X(5),Name X(20),PH X(10),CITY X(10), COUNTRY(10)
*/
id     = substr(inp, 1, 5)
Name   = substr(inp, 6,20)
Ph     = substr(inp,26,10)
City   = substr(inp,36,10)
Coutry = substr(inp,46,10)

/* reformat each field to the proper length */
City   = left(City,20," ")

/* out contains the reformatted record
ID X(5),Name X(20),PH X(10),CITY X(20), COUNTRY(10)
*/
out = Id || Name || || Ph || City || Country
Back to top
View user's profile Send private message
Pedro

Global Moderator


Joined: 01 Sep 2006
Posts: 2547
Location: Silicon Valley

PostPosted: Tue Jun 10, 2008 9:30 pm
Reply with quote

You also have to worry about the record lengths. The new record might not fit in the old file. Be prepared to reallocate the dataset to a new size.
Back to top
View user's profile Send private message
enrico-sorichetti

Superior Member


Joined: 14 Mar 2007
Posts: 10873
Location: italy

PostPosted: Wed Jun 11, 2008 12:07 am
Reply with quote

but for huge amount of data I would investigate the dfsort/icetools capabiliies,
it will outperform rexx by a factor of five
it is not that difficult to move things around
Back to top
View user's profile Send private message
anirudh1985
Currently Banned

New User


Joined: 22 Aug 2007
Posts: 66
Location: bangalore

PostPosted: Wed Jun 11, 2008 10:47 am
Reply with quote

thanx a lot!...icon_smile.gif
Back to top
View user's profile Send private message
anirudh1985
Currently Banned

New User


Joined: 22 Aug 2007
Posts: 66
Location: bangalore

PostPosted: Tue Jun 17, 2008 2:43 pm
Reply with quote

enrico-sorichetti wrote:
Here is a snippet...

Code:
/* inp contains the old data
ID X(5),Name X(20),PH X(10),CITY X(10), COUNTRY(10)
*/
id     = substr(inp, 1, 5)
Name   = substr(inp, 6,20)
Ph     = substr(inp,26,10)
City   = substr(inp,36,10)
Coutry = substr(inp,46,10)

/* reformat each field to the proper length */
City   = left(City,20," ")



/* out contains the reformatted record
ID X(5),Name X(20),PH X(10),CITY X(20), COUNTRY(10)
*/
out = Id || Name || || Ph || City || Country



How can this be generalised so that for any given record structure and for any given field it has to be expanded by desired length and reformatted?
Back to top
View user's profile Send private message
enrico-sorichetti

Superior Member


Joined: 14 Mar 2007
Posts: 10873
Location: italy

PostPosted: Tue Jun 17, 2008 3:08 pm
Reply with quote

If You' d explain what You are trying to achieve
You might get better answers

Your last requirement was a bit unclear...

are You asking about data reformatting ?

in this case as I already said rexx will not give top performance
and most of the transformations ( like the one explained before )
can be carried out by sort/icetool
Back to top
View user's profile Send private message
anirudh1985
Currently Banned

New User


Joined: 22 Aug 2007
Posts: 66
Location: bangalore

PostPosted: Tue Jun 17, 2008 4:33 pm
Reply with quote

[quote="enrico-sorichetti"]If You' d explain what You are trying to achieve
You might get better answers


I need to develop a tool which will take any file say VSAM and expand any of its filed to the specified length. The file can have 10 fields or 20 etc... it has to work for files with varied fields.. i hope i am clear....
Back to top
View user's profile Send private message
enrico-sorichetti

Superior Member


Joined: 14 Mar 2007
Posts: 10873
Location: italy

PostPosted: Tue Jun 17, 2008 5:19 pm
Reply with quote

in what format are You planning to give the description of the input and output layouts ?
Back to top
View user's profile Send private message
anirudh1985
Currently Banned

New User


Joined: 22 Aug 2007
Posts: 66
Location: bangalore

PostPosted: Tue Jun 17, 2008 5:31 pm
Reply with quote

enrico-sorichetti wrote:
in what format are You planning to give the description of the input and output layouts ?


my input will be a copybook with the record format of the file for which a field has to be expanded and a VSAM file whose fild has to be expanded and output has to be a reformatted VSAM file....
Back to top
View user's profile Send private message
enrico-sorichetti

Superior Member


Joined: 14 Mar 2007
Posts: 10873
Location: italy

PostPosted: Tue Jun 17, 2008 5:51 pm
Reply with quote

Hi Anirudh!

two copybooks I would suggest...
the format of the copybook would be cobol I guess

also remember that REXX does not have any VSAM access facility
( unless You use external packages , not free )

so You must repro the vsam to a sequential file
carry on the reformatting
repro to the reformatted file

i am still of the opinion that rexx is not the best suited tool for the task

do You realize that You have to build a small cobol parser scanner to achieve the mapping You want,
You must decode all the possible variable layouts and definitions

...take my word for it, I do know about compiler and interpreter writing
that' not a simple task, especially if, no offense meant, You must rely on forum replies to implement it

I just looked at the IBM file manager specs and here is a quote of the
copy feature
Quote:
You can use the Copy Utility to:
* Copy data from any partitioned, sequential, or VSAM data set to any other partitioned, sequential, or VSAM data set.
* Select the records to be copied using the start key (VSAM only), skip and copy count fields, or a conditional expression defined in an input template.
* Change file attributes. You can copy records where the input and output data sets have differing record formats, record lengths or block sizes. The copy process truncates or pads records appropriately. To specify a pad character to be used, use the PAD processing option on the Set Processing Options (option 0) panel.
* Copy selected fields, change the size of fields, and create new fields in the output file by using a "From" template with a "To" template.
* Allocate a non-VSAM data set, or define a VSAM data set.
* Copy sequential data sets or PDS or PDSE members, converting the data to or from ISPF PACK data format.


I guess that fileaid if present in Your shop should have the same capabilities

did You look at the rlcl sample I pointed You to
Back to top
View user's profile Send private message
Garry Carroll

Senior Member


Joined: 08 May 2006
Posts: 1193
Location: Dublin, Ireland

PostPosted: Wed Jun 18, 2008 1:25 pm
Reply with quote

Quote:
also remember that REXX does not have any VSAM access facility
( unless You use external packages , not free )


There is cbt268 which gives REXX access to VSAM.

Quote:
do You realize that You have to build a small cobol parser scanner to achieve the mapping You want,
You must decode all the possible variable layouts and definitions


The cobol copybook parser (cobdfsym) in DFSORT's Sort Tricks document (sorttrck.pdf) would probably be useful for this.

I agree that REXX is probably not the best way to achieve the object. It may be that something clever using DFSORT with generated SYMNAMES for the 'before' and 'after' copybooks could be used to provide a solution.

Garry.
Back to top
View user's profile Send private message
mbizzle

New User


Joined: 06 May 2020
Posts: 7
Location: United States

PostPosted: Wed May 06, 2020 6:55 pm
Reply with quote

I registered just so I could share this fix to COBDFSYM.

I had been using it for a few years now, and loved it and was sad when our upgrade from cobol compiler V4 to V6 bricked this program. Luckily, it was a fairly simple fix to update it.
Here are the fixes you need to make to allow it to be compatible with the V6 (and i assume V5) compilers.
I am posting this on a few forums so that others may find it that have the same issue.

change this line
parse var line 92 asmdef datatyp .
to
parse var line 87 asmdef datatyp .

and add this line

do until left(line,1) = '1'
call Put_line
parse pull line
if pos('End of Data Division Map',line)<> 0 then leave
end
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 Compile Several JCL JOB Through one r... CLIST & REXX 4
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 isfline didnt work in rexx at z/OS ve... CLIST & REXX 7
No new posts run rexx code with jcl CLIST & REXX 15
Search our Forums:

Back to Top