Portal | Manuals | References | Downloads | Info | Programs | JCLs | Mainframe wiki | Quick Ref
IBM Mainframe Forum Index
 
Register
 
IBM Mainframe Forum Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist Profile Log in to check your private messages Log in
 
Converting spaces to zeroes

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> DFSORT/ICETOOL
View previous topic :: :: View next topic  
Author Message
A_programmers

New User


Joined: 24 Mar 2010
Posts: 10
Location: USA

PostPosted: Tue Oct 01, 2019 12:41 am    Post subject: Converting spaces to zeroes
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

Senior Member


Joined: 21 Sep 2010
Posts: 2262
Location: NY,USA

PostPosted: Tue Oct 01, 2019 3:34 am    Post subject:
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: 10
Location: USA

PostPosted: Tue Oct 01, 2019 6:01 pm    Post subject: Reply to: Converting spaces to zeroes
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

Senior Member


Joined: 21 Sep 2010
Posts: 2262
Location: NY,USA

PostPosted: Tue Oct 01, 2019 6:07 pm    Post subject:
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

Active Member


Joined: 29 Apr 2008
Posts: 552
Location: Maryland

PostPosted: Tue Oct 01, 2019 11:49 pm    Post subject: Re: Converting spaces to zeroes
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

Senior Member


Joined: 21 Sep 2010
Posts: 2262
Location: NY,USA

PostPosted: Tue Oct 01, 2019 11:54 pm    Post subject:
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

Active Member


Joined: 29 Apr 2008
Posts: 552
Location: Maryland

PostPosted: Wed Oct 02, 2019 12:01 am    Post subject:
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

Senior Member


Joined: 21 Sep 2010
Posts: 2262
Location: NY,USA

PostPosted: Wed Oct 02, 2019 12:05 am    Post subject:
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    IBMMAINFRAMES.com Support Forums -> DFSORT/ICETOOL All times are GMT + 6 Hours
Page 1 of 1

 

Search our Forum:

Similar Topics
Topic Author Forum Replies Posted
No new posts Converting a copybook value into Json... srikant314 COBOL Programming 1 Mon Jun 03, 2019 11:17 am
No new posts To remove the spaces using SORT Card dharmaraok DFSORT/ICETOOL 1 Tue Apr 30, 2019 3:42 pm
No new posts Abends using up address spaces? John Poulakos ABENDS & Debugging 6 Tue Apr 23, 2019 8:34 pm
No new posts converting bytes and megabytes to kil... knobi SYNCSORT 4 Fri Apr 12, 2019 8:05 pm
No new posts how to use RDZ for converting cobol c... balajiChid CICS 1 Tue Oct 09, 2018 8:40 pm

Facebook
Back to Top
 
Job Vacancies | Forum Rules | Bookmarks | Subscriptions | FAQ | Polls | Contact Us