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.
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.
Joined: 23 Nov 2006 Posts: 19270 Location: Inside the Matrix
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.
Joined: 20 Jan 2007 Posts: 684 Location: Hollywood
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.
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.
DO i=1 to m.0
temp=N.(i-1) || N.I
where N. is the stem variable mentioned above.
Also expecting any alternate soln of the above problem.