IBM Mainframe Forum Index
 
Log In
 
IBM Mainframe Forum Index Mainframe: Search IBM Mainframe Forum: FAQ Register
 

Read the INPUT flat file and get the formatted OUTPUT file.


IBM Mainframe Forums -> CLIST & REXX
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
mandyaharsha

New User


Joined: 16 May 2009
Posts: 12
Location: Bangalore

PostPosted: Thu Aug 23, 2012 1:05 pm
Reply with quote

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
View user's profile Send private message
enrico-sorichetti

Superior Member


Joined: 14 Mar 2007
Posts: 10873
Location: italy

PostPosted: Thu Aug 23, 2012 1:21 pm
Reply with quote

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
View user's profile Send private message
dick scherrer

Moderator Emeritus


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

PostPosted: Thu Aug 23, 2012 6:47 pm
Reply with quote

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
View user's profile Send private message
dbzTHEdinosauer

Global Moderator


Joined: 20 Oct 2006
Posts: 6966
Location: porcelain throne

PostPosted: Thu Aug 23, 2012 7:03 pm
Reply with quote

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
View user's profile Send private message
PANIGRAHI,DEVA

New User


Joined: 20 Aug 2012
Posts: 3
Location: India

PostPosted: Mon Aug 27, 2012 6:07 pm
Reply with quote

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
View user's profile Send private message
enrico-sorichetti

Superior Member


Joined: 14 Mar 2007
Posts: 10873
Location: italy

PostPosted: Mon Aug 27, 2012 6:14 pm
Reply with quote

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
View user's profile Send private message
mandyaharsha

New User


Joined: 16 May 2009
Posts: 12
Location: Bangalore

PostPosted: Wed Aug 29, 2012 6:23 pm
Reply with quote

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
View user's profile Send private message
dick scherrer

Moderator Emeritus


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

PostPosted: Wed Aug 29, 2012 6:30 pm
Reply with quote

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
View user's profile Send private message
Nic Clouston

Global Moderator


Joined: 10 May 2007
Posts: 2455
Location: Hampshire, UK

PostPosted: Wed Aug 29, 2012 7:50 pm
Reply with quote

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
View user's profile Send private message
Bill Woodger

Moderator Emeritus


Joined: 09 Mar 2011
Posts: 7309
Location: Inside the Matrix

PostPosted: Wed Aug 29, 2012 8:07 pm
Reply with quote

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
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   Reply to topic View Bookmarks
All times are GMT + 6 Hours
Forum Index -> CLIST & REXX

 


Similar Topics
Topic Forum Replies
No new posts TRIM everything from input, output co... DFSORT/ICETOOL 1
No new posts FTP VB File from Mainframe retaining ... JCL & VSAM 8
No new posts Extract the file name from another fi... DFSORT/ICETOOL 6
No new posts How to split large record length file... DFSORT/ICETOOL 10
No new posts Error to read log with rexx CLIST & REXX 11
Search our Forums:

Back to Top