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

Reformat the variable pipe delimited fields to fixed field


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

New User


Joined: 29 Jan 2009
Posts: 39
Location: India

PostPosted: Mon Aug 15, 2011 11:32 am
Reply with quote

Hi All,

I have a variable block input file and data are like,
Code:

HEADER|000000000004                                     
TPS1|GEDMUI|244709102|ERS-37164-2177914|Y|2011-06-02|24.310|657.000|632.690|N|TS1|A
TPS1|GEDMUI|104275101|ERS-1015167-2153890|Y|2011-05-25|117.810|3465.000|3347.190|N|TS2|A
TPS1|GEDMUI|104275101|ERS-1015168-2153891|Y|2011-05-25|7.850|231.000|223.150|N|TS3|A
TPS1|GEDMUI|502151104|ERS-112783-2166898|Y|2011-05-31|121.100|6054.780|5933.680|N|TS4|C



Please help me to reformat the above fields.Expected outputs will be,
Code:

HEADER|000000000004                                       
TPS1|GEDMUI|244709102|ERS-37164-2177914  |Y|2011-06-02| 24.310| 657.000| 632.690|N|TS1|A
TPS1|GEDMUI|104275101|ERS-1015167-2153890|Y|2011-05-25|117.810|3465.000|3347.190|Y|TS2|A
TPS1|GEDMUI|104275101|ERS-1015168-2153891|Y|2011-05-25|  7.850| 231.000| 223.150|N|TS3|A
TPS1|GEDMUI|502151104|ERS-112783-2166898 |Y|2011-05-31|121.100|6054.780|5933.680|Y|TS4|C




Thanks a lot in advance,
Back to top
View user's profile Send private message
Garry Carroll

Senior Member


Joined: 08 May 2006
Posts: 1205
Location: Dublin, Ireland

PostPosted: Mon Aug 15, 2011 11:56 am
Reply with quote

Look at ftp.software.ibm.com/storage/dfsort/mvs/sorttrck.pdf for the PARSE function.


Garry.
Back to top
View user's profile Send private message
devmisra

New User


Joined: 29 Jan 2009
Posts: 39
Location: India

PostPosted: Mon Aug 15, 2011 12:56 pm
Reply with quote

I coded below sort card
Code:

//SORT1     EXEC PGM=ICEMAN                                             
//SORTIN    DD DSN=G1KL00AT.DEBA.PORTFOL,DISP=SHR                       
//SORTOUT   DD DSN=G1KL00AT.DEBA.PORTFOL.SORT,DISP=SHR                 
//SYSOUT    DD SYSOUT=*                                                 
//SYSNAMES  DD *                                                       
FLD1,1,26                                                               
FLD2,%00                                                               
FLD3,%01                                                               
PIPE,'|'                                                               
BLANK,' '                                                               
//SYSIN     DD *                                                       
   OPTION COPY                                                         
   INREC PARSE=(FLD2=(ABSPOS=27,FIXLEN=35,ENDBEFR=PIPE),               
                FLD3=(FIXLEN=1,ENDBEFR=PIPE),                           
   BUILD=(FLD1,FLD2,JFY=(SHIFT=RIGHT))                                 
/*                                                   

and got the syntax error,
Code:

SYSIN :                                                 
   OPTION COPY                                           
   INREC PARSE=(FLD2=(ABSPOS=27,FIXLEN=35,ENDBEFR=PIPE),
                *                                       
                FLD3=(FIXLEN=1,ENDBEFR=PIPE),           
   BUILD=(FLD1,FLD2,JFY=(SHIFT=RIGHT))                   
WER268A  INREC STATEMENT   : SYNTAX ERROR               
WER211B  SYNCSMF  CALLED BY SYNCSORT; RC=0000           
Back to top
View user's profile Send private message
Garry Carroll

Senior Member


Joined: 08 May 2006
Posts: 1205
Location: Dublin, Ireland

PostPosted: Mon Aug 15, 2011 1:02 pm
Reply with quote

Line 5 of your JCL has SYSNAMES - the DD should read SYMNAMES

Garry.
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: Mon Aug 15, 2011 1:06 pm
Reply with quote

WER message as SYNCSORT.

Should have been posted to the JCL forum where the SYNCSORT queries live.
Back to top
View user's profile Send private message
devmisra

New User


Joined: 29 Jan 2009
Posts: 39
Location: India

PostPosted: Mon Aug 15, 2011 1:07 pm
Reply with quote

Oh sorry,, yes Garry, after posting the code into this formun ,I noticed that one and changed to //SYMNAMES and ran it but still getting the syntax error.

Code:

SYSIN :                                                                       
   OPTION COPY                                                                 
   INREC PARSE=(FLD2=(ABSPOS=27,FIXLEN=35,ENDBEFR=PIPE),                       
                FLD3=(FIXLEN=1,ENDBEFR=PIPE),                                 
   BUILD=(FLD1,FLD2,JFY=(SHIFT=RIGHT))                                         
DATA DICTIONARY SYMBOLS SUBSTITUTED :                                         
OPTION COPY                                                                   
INREC PARSE=(FLD2=(ABSPOS=27,FIXLEN=35,ENDBEFR=PIPE),FLD3=(FIXLEN=1,ENDBEFR=PIP
             *                                                                 
),BUILD=(FLD1,FLD2,JFY=(SHIFT=RIGHT))                                         
WER268A  INREC STATEMENT   : SYNTAX ERROR                                     
WER211B  SYNCSMF  CALLED BY SYNCSORT; RC=0000                                 
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: Mon Aug 15, 2011 1:13 pm
Reply with quote

Hi misra,

I would if I could :-) I was just highlighting it for a moderator (who can) and for you for next time, and for you to know where it is gone if you can't find it in DFSORT later.
Back to top
View user's profile Send private message
devmisra

New User


Joined: 29 Jan 2009
Posts: 39
Location: India

PostPosted: Mon Aug 15, 2011 1:50 pm
Reply with quote

Thanks Bill,

Hi Garry,

i corrected the syntax and ran the sort card and it seems sort card is fine now. but still its throwing error because both the files are VB.

Code:


 SYSIN :                                                                       
    SORT FIELDS=COPY                                                           
    INREC PARSE=(Fld2=(ABSPOS=27,FIXLEN=35,ENDBEFR=Pipe),                       
                 Fld3=(FIXLEN=1,ENDBEFR=Pipe)),                                 
    BUILD=(1,4,Fld1,Pipe,Fld2,Pipe)                                             
 DATA DICTIONARY SYMBOLS SUBSTITUTED :                                         
 SORT FIELDS=COPY                                                               
 INREC PARSE=(%00=(ABSPOS=27,FIXLEN=35,ENDBEFR=C'|'),%01=(FIXLEN=1,ENDBEFR=C'|')
 ,BUILD=(1,4,1,26,C'|',%00,C'|')                                               
 WER276B  SYSDIAG= 50062, 465587, 465587, 2017950                               
 WER164B  5,664K BYTES OF VIRTUAL STORAGE AVAILABLE, MAX REQUESTED,             
 WER164B     0 BYTES RESERVE REQUESTED, 2,256K BYTES USED                       
 WER146B  24K BYTES OF EMERGENCY SPACE ALLOCATED                               
 WER108I  SORTIN   : RECFM=VB   ; LRECL=   219; BLKSIZE= 27998                 
 WER257I  INREC RECORD LENGTH =    67                                           
 WER110I  SORTOUT  : RECFM=VB   ; LRECL=   219; BLKSIZE= 27998                 
 WER462I  OUTPUT LRECL DIFFERS FROM SORTOUT LRECL                               
 WER410B  4,636K BYTES OF VIRTUAL STORAGE AVAILABLE ABOVE THE 16MEG LINE,       
 WER410B     0 BYTES RESERVE REQUESTED, 2,112K BYTES USED                       
 WER244A  INREC  - SHORT RECORD                                                 
 WER211B  SYNCSMF  CALLED BY SYNCSORT; RC=0000
Back to top
View user's profile Send private message
Garry Carroll

Senior Member


Joined: 08 May 2006
Posts: 1205
Location: Dublin, Ireland

PostPosted: Mon Aug 15, 2011 1:57 pm
Reply with quote

Have you specified LRECL for SORTOUT in JCL?
Code:
WER462I  OUTPUT LRECL DIFFERS FROM SORTOUT LRECL                               


Garry.
Back to top
View user's profile Send private message
devmisra

New User


Joined: 29 Jan 2009
Posts: 39
Location: India

PostPosted: Mon Aug 15, 2011 2:19 pm
Reply with quote

yes. and both are having same LRECL=219 and RECFM=VB
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: Mon Aug 15, 2011 2:22 pm
Reply with quote

You have a "short" record on your input file, which means that the record finishes before the end of one of the parts you are using for your output record.

If you try to copy 20 bytes to some position in the output but the input record is only 10 bytes long, you'll get this message.
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: Mon Aug 15, 2011 2:35 pm
Reply with quote

Misra,

Nice to see you using SYMNAMES, by the way.

Fld1 could be more meaningful.

It also, for a VB, should start at 5, not 1, which is in the start of the RDW, or you should not include the 1,4 for the RDW (which you didn't give a SYMNAME).

This is in addition to your short record problem.
Back to top
View user's profile Send private message
Ed Goodman

Active Member


Joined: 08 Jun 2011
Posts: 556
Location: USA

PostPosted: Mon Aug 15, 2011 7:30 pm
Reply with quote

Isn't the output going to be the same length for each record now? The sort product is going to write it as variable because the input is variable, but is that what you really want?
Back to top
View user's profile Send private message
devmisra

New User


Joined: 29 Jan 2009
Posts: 39
Location: India

PostPosted: Tue Aug 16, 2011 10:22 am
Reply with quote

Hi Ed,

The output record length will not be same as input reccord. After reformatting, the output field will have greater length than the input field.

for e,g Field-4 is Invoice-No and value is 'ERS-37164-2177914' which is 17 char length and after reformatting it will be fixed one with 35 char length.rest will be be spaces.

But input file will always have shorter record than 219(VB) which is file lengfth.
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: Tue Aug 16, 2011 11:21 am
Reply with quote

Ed means, "aren't all output records going to be the same length as each other" - with the implied question, "so can they be recfm fb"?
Back to top
View user's profile Send private message
devmisra

New User


Joined: 29 Jan 2009
Posts: 39
Location: India

PostPosted: Tue Aug 16, 2011 12:03 pm
Reply with quote

yes, all the output records will be off same length as each other. They can be recfm FB.
Back to top
View user's profile Send private message
Arun Raj

Moderator


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

PostPosted: Tue Aug 16, 2011 5:48 pm
Reply with quote

devmisra,

Your header record itself is in fact a "short record" since your parse starts at ABSPOS=27.
If you don't have any more short records other than the header record, you can have a condition check like this.
Code:
//SYSIN   DD *                                               
  SORT FIELDS=COPY                                           
  INREC IFTHEN=(WHEN=(5,6,CH,NE,C'HEADER'),                   
               PARSE=(%00=(ABSPOS=27,FIXLEN=35,ENDBEFR=C'|'),
                      %01=(FIXLEN=1,ENDBEFR=C'|')),           
        BUILD=(1,30,C'|',%00,C'|'))                           
/*                                                           
Back to top
View user's profile Send private message
Ed Goodman

Active Member


Joined: 08 Jun 2011
Posts: 556
Location: USA

PostPosted: Tue Aug 16, 2011 8:56 pm
Reply with quote

exactly...

Is your goal to have a fixed length file? Will the receiving program/utility be expecting it as fixed length?

It's the type of thing that will sneak up on you later, when you think you've got it figured out. Then you have to come back to this step and try to fix it.
Back to top
View user's profile Send private message
devmisra

New User


Joined: 29 Jan 2009
Posts: 39
Location: India

PostPosted: Wed Aug 17, 2011 11:27 am
Reply with quote

Thanks to Everyone to help me on this.

For the time being, I am copying that VB file into FB file. Then using FB file, i am Skipping the Header record and reformatting the other records.

And its working fine but here i need your help.I reformat the amount fields like below
Code:

//SYMNAMES  DD *   
...         
Fld9,%07           
Fld10,%08           
Fld11,%09   
...
//SYSIN     DD *
SORT FIELDS=COPY                                       
OPTION SKIPREC=1                                       
INREC PARSE=(
...
Fld9=(FIXLEN=18,ENDBEFR=Pipe), 
Fld10=(FIXLEN=18,ENDBEFR=Pipe),
Fld11=(FIXLEN=18,ENDBEFR=Pipe),
...
BUILD=
...
Fld9,JFY=(SHIFT=RIGHT),Pipe,     
Fld10,JFY=(SHIFT=RIGHT),Pipe,   
Fld11,JFY=(SHIFT=RIGHT),Pipe,   
...

output is
Code:

fields |            24.310|           657.000|           632.690|fields


Amount field positions are 113-130, 132-149 and 151-168. Length is 18.
Please suggest how to Left Pad the amount fields with zeros in the same BUILD part of the SORT card .

Expected output is
Code:

fields |00000000000024.310|00000000000657.000|00000000000632.690|fields




Thanks a lot in advance.
Back to top
View user's profile Send private message
dick scherrer

Moderator Emeritus


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

PostPosted: Wed Aug 17, 2011 2:24 pm
Reply with quote

Hello,

Why was it decided that this exercise is even needed icon_confused.gif

The data shown in the first post is perfectly usable as is (unless this is to accommodate unqualified programmers). If this is the case, i suggest the programmers be brought up to speed rather than waste machine resources "forever".

If there is some real business requirement it would be nteresting to know what it is.

Keep in mind this could be done in a very simple COBOL program using UNSTRING. . . A very simple program.
read the record
if the header - whatever
if not the header unstring and write the new record

Assuming this is even needed. . . .
Back to top
View user's profile Send private message
devmisra

New User


Joined: 29 Jan 2009
Posts: 39
Location: India

PostPosted: Wed Aug 17, 2011 2:34 pm
Reply with quote

Hi d.sch,

You are absolutely correct on this approach.

Actually, I am generating a VB file which will contain around 200k records. To review the file data with table data, i need to know the Sum of the amount fields. I thought SORT will be an easier way to achieve the Total amounts. The whole process is not for production, only to review Test/QA data.

When i went thru the SORT cards I learnt PARSE function, so it got more interesting when i tested and got the result.... :-)
Back to top
View user's profile Send private message
dick scherrer

Moderator Emeritus


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

PostPosted: Wed Aug 17, 2011 2:38 pm
Reply with quote

Hello,

When PARSEing you might be able to sum the amount fields by using UFF if they will always be positive or SFF if they are allowed to be negative also.

I'm not able to try this just now, but thought i'd at least pass it along.

Good luck 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 Help required to reset decimal points... DFSORT/ICETOOL 8
No new posts REXX/CMS How to place command console... CLIST & REXX 4
No new posts Sorting Date Field DFSORT/ICETOOL 4
No new posts Pull data using date difference betwe... DB2 6
No new posts CA7 count with DATE variable CA Products 0
Search our Forums:

Back to Top