Portal | Manuals | References | Downloads | Info | Programs | JCLs | Mainframe wiki | Quick Ref
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist Profile Log in to check your private messages Log in
 
How to write in a PS in comma separated form

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

New User


Joined: 16 Mar 2007
Posts: 6
Location: India

PostPosted: Fri Mar 16, 2007 10:35 am    Post subject: How to write in a PS in comma separated form
Reply with quote

Hi,

I'm new to REXX. I want to write a code which will write the content of one input file to a PS but the fields need to be comma separated. I've no idea how to read a copybook and accordingly separate different fields by comma.
Back to top
View user's profile Send private message

saiprasadh

Active User


Joined: 20 Sep 2006
Posts: 154
Location: US

PostPosted: Fri Mar 16, 2007 12:01 pm    Post subject:
Reply with quote

Hi

can you give an example how your input file look's like



Sai
Back to top
View user's profile Send private message
masterlock

New User


Joined: 16 Mar 2007
Posts: 6
Location: India

PostPosted: Fri Mar 16, 2007 6:12 pm    Post subject: Re: How to write in a PS in comma separated form
Reply with quote

Hi Sai,

Actually the input file will be a standard master input file where everyfield is mostly contiguous. For ex: AAAABBBBCCCC111112222. Suppose the 1st 4 bytes indicates name, the next 4 bytes location and so on. What I want to make the output look like:AAAA,BBBB,CCCC,1111,2222. Obviously the byte division will be as per the copybook.

Thanks,
Back to top
View user's profile Send private message
enrico-sorichetti

Global Moderator


Joined: 14 Mar 2007
Posts: 10308
Location: italy

PostPosted: Sat Mar 17, 2007 4:24 pm    Post subject: Re: How to write in a PS in comma separated form
Reply with quote

here is a quick and dirty sample,
the offsets and the lengths must be hand coded,
( they could be generated by analyzing the copybook, but the task is beyond the scope of this post)

the I/O statements work for a PC REXX environment *tested* on
regina rexx under MAC OS X 10.4.9,
regina rexx under FEDORA CORE 6

to make it running TSO You should substitute linein/lineout the corresponding "EXECIO" constructs

to make it production quality there should be some error and congruence checking

the script is meant to demonstrate the parsing capabilities of REXX

the source code

Code:
#! /usr/bin/rexx
/*REXX */
Trace "O"
parse arg in
parse var in fn "." ft
ou  = fn || ".csv" || "." || ft
data = ""
coun = 0
do while ( lines(in) > 0)
 data = linein(in)
 coun = coun + 1
 f1   =   substr(data,    1,   4 )
 f2   =   substr(data,    5,   4 )
 f3   =   substr(data,    9,   4 )
 f4   =   substr(data,   13,   5 )
 f5   =   substr(data,   18,   4 )
/*   the following construct is more performing but less intuitive
   parse var data f1 +4 f2 +4 f3 +4 f4 +5 f5 +4 .
*/
 csv =    f1 || "," || ,
 f2 || "," || ,
 f3 || "," || ,
 f4 || "," || ,
 f5
 call lineout ou, csv
end
say "Processed " coun " records"
exit

the input file
AAAABBBBCCCC111112222
EEEEFFFFGGGG333334444
HHHHIIIIJJJJ555556666
KKKKLLLLMMMM777778888
NNNNPPPPQQQQ999990000

the result
AAAA,BBBB,CCCC,11111,2222
EEEE,FFFF,GGGG,33333,4444
HHHH,IIII,JJJJ,55555,6666
KKKK,LLLL,MMMM,77777,8888
NNNN,PPPP,QQQQ,99999,0000
Back to top
View user's profile Send private message
dick scherrer

Site Director


Joined: 23 Nov 2006
Posts: 19270
Location: Inside the Matrix

PostPosted: Sat Mar 17, 2007 8:30 pm    Post subject:
Reply with quote

Hello,

If you have a copybook for the record format and there is no requirement that you must use REXX, you could write a simple program that reads the "plain" input and using STRING you could build a new comma-delimited output.

If this is for learning, great, but if you need to do this quickly, i'd recommend the COBOL code.
Back to top
View user's profile Send private message
Devzee

Active Member


Joined: 20 Jan 2007
Posts: 684
Location: Hollywood

PostPosted: Sat Mar 17, 2007 11:05 pm    Post subject:
Reply with quote

If you have copybook then it should be a standard fixed format for which you need CSV format. You can use JCL SORT in the outrec after the field positions put comma character.
This is the quickest method than writing COBOL program.

Input:AAAABBBBCCCC11112222.
Output:AAAA,BBBB,CCCC,1111,2222

Code:
outrec fields=(1,4,c',',5,4,c',',9,4,c',',12,4,c',',16,4)
Back to top
View user's profile Send private message
dick scherrer

Site Director


Joined: 23 Nov 2006
Posts: 19270
Location: Inside the Matrix

PostPosted: Sat Mar 17, 2007 11:16 pm    Post subject:
Reply with quote

Hello,

If you must hand key the length and displacement for each field and if the file has a few hundred fields, i believe it will be far faster and less error prone to use the copybook/cobol approach.

FWIW. . .
Back to top
View user's profile Send private message
masterlock

New User


Joined: 16 Mar 2007
Posts: 6
Location: India

PostPosted: Tue Mar 20, 2007 7:58 pm    Post subject:
Reply with quote

Hi all,

Sorry for the delayed reply. I've tried with the REXX code & the jcl, both have worked for a particular copybook which I can get beforehand. I haven't tried with the cobol code yet but will certainly do.

As of now I've been able to generate a REXX program which will store the different PIC values in a stem variable. Now if i become able to join these two codes then I'll get the soln. Now the problem arises in moving the said stem variable in a loop while concatenating. So pls anyone tell me whether the following simple pseudo code works at all.

N.0=","
DO i=1 to m.0
temp=N.(i-1) || N.I
END

where N. is the stem variable mentioned above.
Also expecting any alternate soln of the above problem.
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 Match two files using multiple keys a... santoshks1987 SYNCSORT 11 Fri Aug 18, 2017 10:50 am
No new posts Read two inputs and write into output... murali.andaluri DFSORT/ICETOOL 6 Wed Jul 26, 2017 7:35 pm
No new posts Write out NODUPS but just from one file Jay Villaverde DFSORT/ICETOOL 8 Fri Jul 14, 2017 12:44 am
No new posts How to write Specific Fields from Mul... Padhu SYNCSORT 6 Thu Jul 06, 2017 10:26 am
No new posts Need to write record of PS File in ex... Chandan1993 JCL & VSAM 1 Wed Jun 07, 2017 1:35 am

Facebook
Back to Top
 
Job Vacancies | Forum Rules | Bookmarks | Subscriptions | FAQ | Polls | Contact Us