|
View previous topic :: View next topic
|
| Author |
Message |
A_programmers
New User
Joined: 24 Mar 2010 Posts: 19 Location: USA
|
|
|
|
I am working on writing SORT job to convert input packed decimal fields to output display format fields.
In my input file I have field : S9(13)V9(2) COMP-3 which is unload of a DB2 table.
At many records this field in input file contains spaces i.e. X'4040404040404040' which when converted into output using
edit fields viz. 1:1,08,PD,EDIT=(STTTTTTTTTTTTT.TT),SIGNS=(,-)
is shown as : 4040404040404.04
Whereas I want output in this case as zeroes and if it is not spaces in input; input should be converted into output display format as per the edit field shown above.
How can I do this in the single pass of the input file ?
Current sort card :
| Code: |
//SYSIN DD *
SORT FIELDS=COPY
OUTFILE FNAMES=SORTOUT,REMOVECC,VTOF
BUILD=(001:001,08,PD,EDIT=(STTTTTTTTTTTTT.TT),SIGNS=(,-)) |
|
|
| Back to top |
|
 |
Rohit Umarjikar
Global Moderator

Joined: 21 Sep 2010 Posts: 3109 Location: NYC,USA
|
|
|
|
Why someone allow spaces to be stored in Db2 decimal column ?Is it legitimate?
Btw, there are many ways to replace spaces by zeros and if you google it you will get many choices. |
|
| Back to top |
|
 |
A_programmers
New User
Joined: 24 Mar 2010 Posts: 19 Location: USA
|
|
|
|
I am looking for this to be done in 1 pass. May be using change / altseq.
Regarding why originally data is spaces in this field; I have no idea.
Frank would you able to comment on this ?
Regards,
Sandip |
|
| Back to top |
|
 |
Rohit Umarjikar
Global Moderator

Joined: 21 Sep 2010 Posts: 3109 Location: NYC,USA
|
|
|
|
| Frank is retired years back. Google is your friend , try to think thru. |
|
| Back to top |
|
 |
sergeyken
Senior Member

Joined: 29 Apr 2008 Posts: 2276 Location: USA
|
|
|
|
| A_programmers wrote: |
I am working on writing SORT job to convert input packed decimal fields to output display format fields.
In my input file I have field : S9(13)V9(2) COMP-3 which is unload of a DB2 table.
At many records this field in input file contains spaces i.e. X'4040404040404040' which when converted into output using
edit fields viz. 1:1,08,PD,EDIT=(STTTTTTTTTTTTT.TT),SIGNS=(,-)
is shown as : 4040404040404.04
Whereas I want output in this case as zeroes and if it is not spaces in input; input should be converted into output display format as per the edit field shown above.
How can I do this in the single pass of the input file ?
Current sort card :
| Code: |
//SYSIN DD *
SORT FIELDS=COPY
OUTFILE FNAMES=SORTOUT,REMOVECC,VTOF
BUILD=(001:001,08,PD,EDIT=(STTTTTTTTTTTTT.TT),SIGNS=(,-)) |
|
Fields defined with COMP-3 attributes cannot contain spaces. It's a sort of bullshit.
S9(13)V9(2) COMP-3 fields may look like this:
| Code: |
X'012345678901C' - for +123456789.01
X'000000000001D' - for -.01
etc. |
Find out accurately: what you really have on input?
Before that try to understand the difference between packed decimals (PIC COMP-3), and character/numerics (PIC 999999, or PIC XXXXX ) |
|
| Back to top |
|
 |
Rohit Umarjikar
Global Moderator

Joined: 21 Sep 2010 Posts: 3109 Location: NYC,USA
|
|
|
|
| Quote: |
| Regarding why originally data is spaces in this field; I have no idea. |
Then thats the idea to start with to know what you say is true and find out is it even possible to have one like this case , because it doesn't make sense what you describe.
Run this yourself and check what happens to spaces.
| Code: |
//S2 EXEC PGM=SORT
//SYSOUT DD SYSOUT=*
//SORTLIST DD SYSOUT=*
//SORTIN DD *
123.23
//SORTOUT DD DSN="Your DSN"
//SYSIN DD *
OPTION COPY
INREC OVERLAY=(10:1,6,UFF,TO=PD,LENGTH=6) |
|
|
| Back to top |
|
 |
sergeyken
Senior Member

Joined: 29 Apr 2008 Posts: 2276 Location: USA
|
|
|
|
Non-decimal data in packed decimal field would cause program error, in most cases the well-known ABEND S0C7.
If you are not sure about your input, SORT utility can check the data field before trying to convert it:
| Code: |
OUTFILE FNAMES=SORTOUT,REMOVECC,VTOF,
IFTHEN=(WHEN=(001,08,PD,EQ,NUM),
BUILD=(001:001,08,PD,EDIT=(STTTTTTTTTTTTT.TT),SIGNS=(,-))),
IFTHEN=(WHEN=NONE,
BUILD=(001:C'Garbage!'))
|
|
|
| Back to top |
|
 |
Rohit Umarjikar
Global Moderator

Joined: 21 Sep 2010 Posts: 3109 Location: NYC,USA
|
|
|
|
Instead of
| Code: |
| BUILD=(001:C'Garbage!')) |
OP wants
| Code: |
| BUILD=(001:C'0.00')) |
which I thought OP would think thru otherwise.  |
|
| Back to top |
|
 |
|
|
 |
All times are GMT + 6 Hours |
|