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 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: 10256
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 Write R1 and R2 to OP1 and R1 to OP2 bhaskar_kanteti DFSORT/ICETOOL 10 Fri Mar 03, 2017 11:18 am
No new posts Can you write 2 recs on SORTOUT when ... Sysaron DFSORT/ICETOOL 6 Thu Feb 23, 2017 12:07 am
No new posts Error IEC161I 052(009,XXXRS00)-084 wh... amitc23 JCL & VSAM 10 Wed Oct 12, 2016 5:00 pm
No new posts Removing Extra Spaces in a comma sepa... Puspojit DFSORT/ICETOOL 3 Tue Sep 13, 2016 7:46 am
No new posts how to DYNAMICALLY write sort cond to... mohamedmubee COBOL Programming 13 Fri Aug 26, 2016 11:46 pm


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