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

Converting spaces to zeroes


IBM Mainframe Forums -> DFSORT/ICETOOL
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
A_programmers

New User


Joined: 24 Mar 2010
Posts: 19
Location: USA

PostPosted: Tue Oct 01, 2019 12:41 am
Reply with quote

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
View user's profile Send private message
Rohit Umarjikar

Global Moderator


Joined: 21 Sep 2010
Posts: 3053
Location: NYC,USA

PostPosted: Tue Oct 01, 2019 3:34 am
Reply with quote

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
View user's profile Send private message
A_programmers

New User


Joined: 24 Mar 2010
Posts: 19
Location: USA

PostPosted: Tue Oct 01, 2019 6:01 pm
Reply with quote

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
View user's profile Send private message
Rohit Umarjikar

Global Moderator


Joined: 21 Sep 2010
Posts: 3053
Location: NYC,USA

PostPosted: Tue Oct 01, 2019 6:07 pm
Reply with quote

Frank is retired years back. Google is your friend , try to think thru.
Back to top
View user's profile Send private message
sergeyken

Senior Member


Joined: 29 Apr 2008
Posts: 2022
Location: USA

PostPosted: Tue Oct 01, 2019 11:49 pm
Reply with quote

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
View user's profile Send private message
Rohit Umarjikar

Global Moderator


Joined: 21 Sep 2010
Posts: 3053
Location: NYC,USA

PostPosted: Tue Oct 01, 2019 11:54 pm
Reply with quote

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
View user's profile Send private message
sergeyken

Senior Member


Joined: 29 Apr 2008
Posts: 2022
Location: USA

PostPosted: Wed Oct 02, 2019 12:01 am
Reply with quote

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
View user's profile Send private message
Rohit Umarjikar

Global Moderator


Joined: 21 Sep 2010
Posts: 3053
Location: NYC,USA

PostPosted: Wed Oct 02, 2019 12:05 am
Reply with quote

Instead of
Code:
BUILD=(001:C'Garbage!'))

OP wants
Code:
BUILD=(001:C'0.00'))

which I thought OP would think thru otherwise. 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 -> DFSORT/ICETOOL

 


Similar Topics
Topic Forum Replies
No new posts Issues Converting From ZD to Signed N... DFSORT/ICETOOL 4
No new posts Remove leading zeroes SYNCSORT 4
No new posts leading spaces can be removed in trai... DFSORT/ICETOOL 1
No new posts Cobol program with sequence number ra... COBOL Programming 5
No new posts Converting fixed length file to excel... IBM Tools 7
Search our Forums:

Back to Top