Portal | Manuals | References | Downloads | Info | Programs | JCLs | Master the Mainframes
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist Usergroups Profile Log in to check your private messages Log in
 

 

Reformat the variable pipe delimited fields to fixed field
Goto page 1, 2  Next
 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> JCL & VSAM
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    Post subject: Reformat the variable pipe delimited fields to fixed field
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

Active Member


Joined: 08 May 2006
Posts: 988
Location: Dublin, Ireland / Edinburgh, Scotland

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

Look at ftp://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    Post subject:
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

Active Member


Joined: 08 May 2006
Posts: 988
Location: Dublin, Ireland / Edinburgh, Scotland

PostPosted: Mon Aug 15, 2011 1:02 pm    Post subject:
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

DFSORT Moderator


Joined: 09 Mar 2011
Posts: 7223

PostPosted: Mon Aug 15, 2011 1:06 pm    Post subject:
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    Post subject:
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

DFSORT Moderator


Joined: 09 Mar 2011
Posts: 7223

PostPosted: Mon Aug 15, 2011 1:13 pm    Post subject: Reply to: Reformat the variable pipe delimited fields to fix
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    Post subject:
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

Active Member


Joined: 08 May 2006
Posts: 988
Location: Dublin, Ireland / Edinburgh, Scotland

PostPosted: Mon Aug 15, 2011 1:57 pm    Post subject:
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    Post subject:
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

DFSORT Moderator


Joined: 09 Mar 2011
Posts: 7223

PostPosted: Mon Aug 15, 2011 2:22 pm    Post subject: Reply to: Reformat the variable pipe delimited fields to fix
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

DFSORT Moderator


Joined: 09 Mar 2011
Posts: 7223

PostPosted: Mon Aug 15, 2011 2:35 pm    Post subject: Reply to: Reformat the variable pipe delimited fields to fix
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    Post subject:
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    Post subject:
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

DFSORT Moderator


Joined: 09 Mar 2011
Posts: 7223

PostPosted: Tue Aug 16, 2011 11:21 am    Post subject: Reply to: Reformat the variable pipe delimited fields to fix
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    Post subject:
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: 2158
Location: @my desk

PostPosted: Tue Aug 16, 2011 5:48 pm    Post subject:
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    Post subject:
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    Post subject:
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

Site Director


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

PostPosted: Wed Aug 17, 2011 2:24 pm    Post subject:
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
View previous topic :: :: View next topic  
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> JCL & VSAM All times are GMT + 6 Hours
Goto page 1, 2  Next
Page 1 of 2

 

Search our Forum:

Similar Topics
Topic Author Forum Replies Posted
No new posts Add PD field from 2nd file to PD in 1st Sushant Garje DFSORT/ICETOOL 6 Thu Dec 01, 2016 4:32 pm
No new posts SQZ pipe delimited file with 1 column... Rick Silvers DFSORT/ICETOOL 2 Sun Nov 06, 2016 8:11 pm
No new posts How to split the records using the am... vnktrrd DFSORT/ICETOOL 24 Fri Oct 28, 2016 7:33 pm
No new posts Access SQLCA fields inside a stored p... gangapd DB2 4 Thu Oct 27, 2016 10:20 am
No new posts Sort records based on numeric field. Alks SYNCSORT 2 Wed Oct 19, 2016 10:14 pm


Facebook
Back to Top
 
Mainframe Wiki | Forum Rules | Bookmarks | Subscriptions | FAQ | Tutorials | Contact Us