|
View previous topic :: View next topic
|
| Author |
Message |
devmisra
New User
Joined: 29 Jan 2009 Posts: 39 Location: India
|
|
|
|
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 |
|
 |
Garry Carroll
Senior Member
Joined: 08 May 2006 Posts: 1216 Location: Dublin, Ireland
|
|
| Back to top |
|
 |
devmisra
New User
Joined: 29 Jan 2009 Posts: 39 Location: India
|
|
|
|
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 |
|
 |
Garry Carroll
Senior Member
Joined: 08 May 2006 Posts: 1216 Location: Dublin, Ireland
|
|
|
|
Line 5 of your JCL has SYSNAMES - the DD should read SYMNAMES
Garry. |
|
| Back to top |
|
 |
Bill Woodger
Moderator Emeritus
Joined: 09 Mar 2011 Posts: 7309 Location: Inside the Matrix
|
|
|
|
WER message as SYNCSORT.
Should have been posted to the JCL forum where the SYNCSORT queries live. |
|
| Back to top |
|
 |
devmisra
New User
Joined: 29 Jan 2009 Posts: 39 Location: India
|
|
|
|
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 |
|
 |
Bill Woodger
Moderator Emeritus
Joined: 09 Mar 2011 Posts: 7309 Location: Inside the Matrix
|
|
|
|
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 |
|
 |
devmisra
New User
Joined: 29 Jan 2009 Posts: 39 Location: India
|
|
|
|
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 |
|
 |
Garry Carroll
Senior Member
Joined: 08 May 2006 Posts: 1216 Location: Dublin, Ireland
|
|
|
|
Have you specified LRECL for SORTOUT in JCL?
| Code: |
| WER462I OUTPUT LRECL DIFFERS FROM SORTOUT LRECL |
Garry. |
|
| Back to top |
|
 |
devmisra
New User
Joined: 29 Jan 2009 Posts: 39 Location: India
|
|
|
|
| yes. and both are having same LRECL=219 and RECFM=VB |
|
| Back to top |
|
 |
Bill Woodger
Moderator Emeritus
Joined: 09 Mar 2011 Posts: 7309 Location: Inside the Matrix
|
|
|
|
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 |
|
 |
Bill Woodger
Moderator Emeritus
Joined: 09 Mar 2011 Posts: 7309 Location: Inside the Matrix
|
|
|
|
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 |
|
 |
Ed Goodman
Active Member
Joined: 08 Jun 2011 Posts: 556 Location: USA
|
|
|
|
| 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 |
|
 |
devmisra
New User
Joined: 29 Jan 2009 Posts: 39 Location: India
|
|
|
|
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 |
|
 |
Bill Woodger
Moderator Emeritus
Joined: 09 Mar 2011 Posts: 7309 Location: Inside the Matrix
|
|
|
|
| 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 |
|
 |
devmisra
New User
Joined: 29 Jan 2009 Posts: 39 Location: India
|
|
|
|
| yes, all the output records will be off same length as each other. They can be recfm FB. |
|
| Back to top |
|
 |
Arun Raj
Moderator
Joined: 17 Oct 2006 Posts: 2482 Location: @my desk
|
|
|
|
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 |
|
 |
Ed Goodman
Active Member
Joined: 08 Jun 2011 Posts: 556 Location: USA
|
|
|
|
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 |
|
 |
devmisra
New User
Joined: 29 Jan 2009 Posts: 39 Location: India
|
|
|
|
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 |
|
 |
dick scherrer
Moderator Emeritus

Joined: 23 Nov 2006 Posts: 19243 Location: Inside the Matrix
|
|
|
|
Hello,
Why was it decided that this exercise is even needed
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 |
|
 |
devmisra
New User
Joined: 29 Jan 2009 Posts: 39 Location: India
|
|
|
|
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 |
|
 |
dick scherrer
Moderator Emeritus

Joined: 23 Nov 2006 Posts: 19243 Location: Inside the Matrix
|
|
|
|
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  |
|
| Back to top |
|
 |
|
|
 |
All times are GMT + 6 Hours |
|