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
 

 

Field expansion Tool in REXX

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> CLIST & REXX
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    Post subject: Field expansion Tool in REXX
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

Global Moderator


Joined: 14 Mar 2007
Posts: 10256
Location: italy

PostPosted: Tue Jun 10, 2008 11:31 am    Post subject: Reply to: FIELD EXPANSION TOOL IN REXX
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

Senior Member


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

PostPosted: Tue Jun 10, 2008 9:30 pm    Post subject: Reply to: Field expansion Tool in REXX
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

Global Moderator


Joined: 14 Mar 2007
Posts: 10256
Location: italy

PostPosted: Wed Jun 11, 2008 12:07 am    Post subject: Reply to: Field expansion Tool in REXX
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    Post subject:
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    Post subject: Re: Reply to: FIELD EXPANSION TOOL IN REXX
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

Global Moderator


Joined: 14 Mar 2007
Posts: 10256
Location: italy

PostPosted: Tue Jun 17, 2008 3:08 pm    Post subject: Reply to: Field expansion Tool in REXX
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    Post subject: Re: Reply to: Field expansion Tool in REXX
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

Global Moderator


Joined: 14 Mar 2007
Posts: 10256
Location: italy

PostPosted: Tue Jun 17, 2008 5:19 pm    Post subject: Reply to: Field expansion Tool in REXX
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    Post subject: Re: Reply to: Field expansion Tool in REXX
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

Global Moderator


Joined: 14 Mar 2007
Posts: 10256
Location: italy

PostPosted: Tue Jun 17, 2008 5:51 pm    Post subject: Reply to: Field expansion Tool in REXX
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

Active Member


Joined: 08 May 2006
Posts: 995
Location: Dublin, Ireland / Edinburgh, Scotland

PostPosted: Wed Jun 18, 2008 1:25 pm    Post subject:
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
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
This topic is locked: you cannot edit posts or make replies. Need help on If condition continuatio... ashok_uddaraju CLIST & REXX 4 Fri May 19, 2017 8:55 am
No new posts READ A PACKED "NEGATIVE" FI... jdesouza CA Products 3 Tue May 02, 2017 11:43 pm
No new posts Alter &DATENS field in HEADER1 Angad DFSORT/ICETOOL 4 Mon Apr 24, 2017 11:49 am
No new posts Running an REXX EXEC implicitly sho7hills CLIST & REXX 3 Thu Apr 20, 2017 8:14 am
No new posts Need help in REXX CALL program Raje1002 CLIST & REXX 5 Wed Apr 19, 2017 11:18 pm


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