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

How to reformat same field differently basing on a key value


IBM Mainframe Forums -> JCL & VSAM
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
Aruna Gutti

New User


Joined: 14 Mar 2009
Posts: 3
Location: Boston, MA, USA

PostPosted: Tue Mar 17, 2009 8:19 pm
Reply with quote

Hi,

This is my first post in this forum. So bear with me in case I missed anything. I checked the forum for a solution and couldn't come up with any hits.

I am trying to sort a VSAM file in to a CSV file using OUTREC feature. Some of the records have a field defined as characters and some have it as packed. So, how do I sort the file and reformat packed field properly.

Here is my basic sort control statement to create a CSV from VSAM:

SORT FIELDS=(5,5,CH,A)
RECORD TYPE=V
OUTREC FIELDS=(1,4,C'08,', (BEG RECORD)
5,2,C',', (GROUP NUM)
7,3,C',', (CODE )
10,1,C',', (AREA TYPE)
11,25,C',', (AREA1 )
26,25,C',') (AREA2 )

I am adding 08 as a starting field for the record.
If GROUP-NUM = 12 then the CODE field is coming as packed '9(5) Comp-3' otherwise it is coming as Char.

How to add that condition in the sort ?

Many Thanks,

Aruna.
Back to top
View user's profile Send private message
Arun Raj

Moderator


Joined: 17 Oct 2006
Posts: 2481
Location: @my desk

PostPosted: Tue Mar 17, 2009 8:37 pm
Reply with quote

Aruna,

Welcome to the forums. icon_smile.gif

Can you post here your input and output file attributes?
Back to top
View user's profile Send private message
Aruna Gutti

New User


Joined: 14 Mar 2009
Posts: 3
Location: Boston, MA, USA

PostPosted: Tue Mar 17, 2009 8:55 pm
Reply with quote

Hi Arun,

My Input is VSAM file with rec length 80and output file format is VB.

Here is JCL :

//SORTIN DD DSN=MC.VSAMLKUP,DISP=SHR
//SORTOUT DD DSN=LKUP.SEQ,
// DISP=(NEW,CATLG,DELETE),
// UNIT=DISK,
// SPACE=(0,(9,1),RLSE),
// DCB=(RECFM=VB,LRECL=70,BLKSIZE=0)


This is the Sysout listing :

SORTIN : RECFM=V ; LRECL= 80; CISIZE = 2048
OUTREC RECORD LENGTH = 68
SORTOUT : RECFM=VB ; LRECL= 70; BLKSIZE= 27998

Thanks,

Aruna.
Back to top
View user's profile Send private message
Arun Raj

Moderator


Joined: 17 Oct 2006
Posts: 2481
Location: @my desk

PostPosted: Tue Mar 17, 2009 11:26 pm
Reply with quote

Aruna Gutti,

I dont have access to mainframe and cant test this now. I'll show you a possible way of achieving the same. Try and post back in case of issues; somebody will be here to help. Good luck icon_smile.gif

Code:
 INREC FIELDS=(1,4,C'08,', (BEG RECORD)
               5,2,C',',   (GROUP NUM)
               7,3,C',',   (CODE )
              10,1,C',',   (AREA TYPE)
              11,25,C',',  (AREA1 )
              26,25,C',')  (AREA2 )
 SORT FIELDS=(5,5,CH,A) 
 RECORD TYPE=V
 OUTREC IFTHEN=(WHEN=(8,2,CH,EQ,C'12'),OVERLAY=(11:11,3,PD,EDIT=(TTT)))
Back to top
View user's profile Send private message
Aruna Gutti

New User


Joined: 14 Mar 2009
Posts: 3
Location: Boston, MA, USA

PostPosted: Wed Mar 18, 2009 12:08 am
Reply with quote

Hi Arun,

Wow! That is wonderful. It worked with a small change.

Instead of :

OUTREC IFTHEN=(WHEN=(8,2,CH,EQ,C'12'),OVERLAY=(11:11,3,PD,EDIT=(TTT)))

I Changed to :

OUTREC IFTHEN=(WHEN=(8,2,CH,EQ,C'12'),OVERLAY=(11:11,3,PD,EDIT=(TTTTT)))

as my out field is 5 bytes long.


Thanks a lot for your help,

Aruna.
Back to top
View user's profile Send private message
Arun Raj

Moderator


Joined: 17 Oct 2006
Posts: 2481
Location: @my desk

PostPosted: Wed Mar 18, 2009 1:52 am
Reply with quote

You're welcome. Glad that it's worked for you icon_smile.gif
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 -> JCL & VSAM

 


Similar Topics
Topic Forum Replies
No new posts Replace Multiple Field values to Othe... DFSORT/ICETOOL 12
No new posts Join 2 files according to one key field. JCL & VSAM 3
No new posts How to Reformat a file using File Man... All Other Mainframe Topics 14
No new posts How to move the first field of each r... DFSORT/ICETOOL 5
No new posts S0C7 - Field getting overlayed COBOL Programming 2
Search our Forums:

Back to Top