View previous topic :: View next topic
|
Author |
Message |
mandyaharsha
New User
Joined: 16 May 2009 Posts: 12 Location: Bangalore
|
|
|
|
Hi All,
I have a requirement where the business will be sending an INPUT file and I need to create a formatted OUTPUT file based on the copybook.
Generic Input file:
ABC|XY|DEF|.................. This record will be of length 4096.
AB|XYZ|DE|P|..................
A|XY|D|PQR|......
Output file should be generated in the below manner:
ABC............XY............DEF............
AB..............XYZ..........DE..............P..............
A................XY............D................PQR..........
Note: Both INPUT and OUTPUT files are mix of CHAR, NUM and DECIMAL values.
To be precise on the output file format, if the first data before '|' is of length 3 and in the COPYBOOK if its variable length is 10 then we have to add 7 spaces along with data i.e., ( ABC ……….) Same is applicable for all the remaining data and here we have to remove '|' in the output record in all the places(we should allow extra space for ‘|’ to occupy).
I am trying to implement this with REXX or JCL (using ICETOOL) but not really able to get into conclusion to start up with.
But was thinking will have to make use of INDEXING here.
Could you please throw some light on this?
Thank you.
Harsha
|
|
Back to top |
|
|
enrico-sorichetti
Superior Member
Joined: 14 Mar 2007 Posts: 10873 Location: italy
|
|
|
|
search the forum about converting CSV datasets to fixed format datasets
( the fact that the separator is the | still makes the records CSV records ) |
|
Back to top |
|
|
dick scherrer
Moderator Emeritus
Joined: 23 Nov 2006 Posts: 19244 Location: Inside the Matrix
|
|
|
|
Hello,
If you are not already experienced in REXX, suggest you use your sort product.
As Enrico mentioned, there are examples in the forum of reformatting delimited files. |
|
Back to top |
|
|
dbzTHEdinosauer
Global Moderator
Joined: 20 Oct 2006 Posts: 6966 Location: porcelain throne
|
|
|
|
Quote: |
But was thinking will have to make use of INDEXING here. |
meaning that you were also thinking of a COBOL solution?
Quote: |
Note: Both INPUT and OUTPUT files are mix of CHAR, NUM and DECIMAL values.
|
NOTE BIEN: bytes are bytes.
the way that you datatype them is how they are treated
by instructions.
REXX treats everything as alphanumeric.
if you have valid characters within a variable that conform to a datatype,
instructions will treat them
according to the datatype rules associated with those instructions.
as has been said before in this thread, other threads, and conversations/writings
a 4096 record with an unknown number of records
is not a good REXX target.
Sort products do this kind of stuff very easily
and there are many examples in the forum
as well as documented as CSV conversions within the DFSORT SORTTRCKS PDF. |
|
Back to top |
|
|
PANIGRAHI,DEVA
New User
Joined: 20 Aug 2012 Posts: 3 Location: India
|
|
|
|
Hi Harsha,
You can use this SORT Card to format your file.
Code: |
OPTION COPY
INREC PARSE=(%00=(ENDBEFR=C'|',FIXLEN=10),
%01=(ENDBEFR=C'|',FIXLEN=10),
%02=(ENDBEFR=C'|',FIXLEN=10),
%03=(ENDBEFR=C'|',FIXLEN=10)),
BUILD=(%00,C'.',%01,C'.',%02,C'.',%03)
OUTREC FINDREP=(IN=C' ',OUT=C'.') |
|
|
Back to top |
|
|
enrico-sorichetti
Superior Member
Joined: 14 Mar 2007 Posts: 10873 Location: italy
|
|
|
|
the dots were fillers ...
the ts lazily forgot to enclose the data within the code tags
( the code tags preserve the spacing ) |
|
Back to top |
|
|
mandyaharsha
New User
Joined: 16 May 2009 Posts: 12 Location: Bangalore
|
|
|
|
Hi Deva,
Thanks for that.But last week I followed below points
In the STEP01 modified the INPUT rec using ICEMAN
OPTION COPY
OUTREC FINDREP=(IN=C'| ',OUT=C' |')
and then treated the OUTPUT of STEP01 as INPUT to STEP02 where I used a COBOL program and did a UNSTRING of the INPUT file for all the input records with COPYBOOK as reference.
I was sucessfull in getting the desired output.
But my INPUT file as so many VARIABLES that I have to mention all the VARIABLES in the UNSTRING syntax which looks little messy. Even I'm wondering how UNSTRING works for a VARIABLE which is defined with OCCURS clause.
So I'm interested in knowing about other options for this,If any??
Thank you.
Harsha |
|
Back to top |
|
|
dick scherrer
Moderator Emeritus
Joined: 23 Nov 2006 Posts: 19244 Location: Inside the Matrix
|
|
|
|
Hello,
UNSTRING works the same for both. . .
If you post a bit of the data definition and the question about how to use it, someone should be able to clarify.
As this would be a COBOL question, you should start a new topic in the COBOL part of the forum. |
|
Back to top |
|
|
Nic Clouston
Global Moderator
Joined: 10 May 2007 Posts: 2455 Location: Hampshire, UK
|
|
|
|
Easy-peasy PARSEing with Rexx - just a lot of R's and RR's in the editor. However I was not allowed to use Rexx (Philistines!) so used DFSORT. Look in that forum for the last topic started by me. Note: you can only parse 100 fields at a time with DFSORT so the last parse would be the remainder of the record and then repeat the process. (I think that is the way but there was a topic a few months ago that met this limitation so you could search for that as well.) |
|
Back to top |
|
|
Bill Woodger
Moderator Emeritus
Joined: 09 Mar 2011 Posts: 7309 Location: Inside the Matrix
|
|
|
|
If you tell us which Sort product you use, we'll get it shifted to the correct place to at least stop people telling you to use Sort to do it.
Plus, I hope you don't have any "unsigned packed-decimal" or "binary" fields in your records... |
|
Back to top |
|
|
|