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

SFF problems with decimal data


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

New User


Joined: 06 Nov 2008
Posts: 46
Location: Manila, Philippines

PostPosted: Wed Dec 19, 2012 7:28 am
Reply with quote

Hi,

I have the following data that I want to reformat.

input
Code:
ARCA,ARCA,C,,0.00085
ARCA,ARCA,F,,0.003
ARCA,ARCA,G,,0.0005
ARCA,ARCA,L,,0.003
ARCA,ARCA,M,,-0.0015


desired output
Code:

ARCAARCAC  00008500
ARCAARCAF  00030000
ARCAARCAG  00005000
ARCAARCAL  00030000
ARCAARCAM  00015000-


I am using the following sort card
Code:
 OPTION COPY
 INREC PARSE=(%01=(ENDBEFR=C',',FIXLEN=4),
              %02=(ENDBEFR=C',',FIXLEN=4),
              %03=(ENDBEFR=C',',FIXLEN=2),
              %04=(ENDBEFR=C',',FIXLEN=1),
              %05=(ENDBEFR=C',',FIXLEN=8)),
       BUILD=(%01,%02,%03,%04,%05,SFF,TO=ZD,LENGTH=8)
 OUTREC FIELDS=(1,11,
               (12,08,ZD,MUL,+1000),
                EDIT=(TTTTTTTTS),SIGNS=(,,,-))


but I am ending up with the following:
Code:
ARCAARCAC  00085000
ARCAARCAF  00003000
ARCAARCAG  00005000
ARCAARCAL  00003000
ARCAARCAM  00015000-


It seems like since SFF does not retain decimal place, my data is getting messed up because my input file is not padded with zeroes. Is there a way to fix this?

Thanks.
Back to top
View user's profile Send private message
hailashwin

New User


Joined: 16 Oct 2008
Posts: 74
Location: Boston

PostPosted: Wed Dec 19, 2012 1:54 pm
Reply with quote

Please check if this works for you..

Code:

//SYSIN    DD  *                                                   
  OPTION COPY                                                     
  INREC FINDREP=(STARTPOS=14,ENDPOS=21,IN=C' ',OUT=C'0')           
  OUTREC PARSE=(%01=(ENDBEFR=C',',FIXLEN=4),                       
                %02=(ENDBEFR=C',',FIXLEN=4),                       
                %03=(ENDBEFR=C',',FIXLEN=2),                       
                %04=(ENDBEFR=C',',FIXLEN=1),                       
                %05=(ENDBEFR=C' ',FIXLEN=8)),                     
         BUILD=(%01,%02,%03,%04,%05,SFF,TO=ZD,LENGTH=8)           
  OUTFIL BUILD=(1,11,12,8,ZD,MUL,+10,EDIT=(TTTTTTTTS),SIGNS=(,,,-))
//*                                                               



Output:
Code:

ARCAARCAC  00008500
ARCAARCAF  00030000
ARCAARCAG  00005000
ARCAARCAL  00030000
ARCAARCAM  00001500-


Thanks,
Ashwin.
Back to top
View user's profile Send private message
Bill Woodger

Moderator Emeritus


Joined: 09 Mar 2011
Posts: 7309
Location: Inside the Matrix

PostPosted: Wed Dec 19, 2012 2:00 pm
Reply with quote

hailashwin, did you check that final figure?

darkstar13,

Having identified what is happening, it is only a small step to a resolution. If it can't be done one way, look for another.

Although the leading minus sign complicates, you can get rid of the "." with a simple rearrangement of data, and change trailing spaces to zero with FINDREP or by multiple IFTHENs, with perhaps other possibilities.
Back to top
View user's profile Send private message
bodatrinadh

Active User


Joined: 05 Jan 2007
Posts: 101
Location: chennai (India)

PostPosted: Wed Dec 19, 2012 3:51 pm
Reply with quote

Hi darkstar13,

You can try this -

Code:

//STEP1   EXEC PGM=SORT                                               
//SYSPRINT DD SYSOUT=*                                                 
//SYSOUT DD SYSOUT=*                                                   
//SORTIN   DD *                                                       
ARCA,ARCA,C,,0.00085                                                   
ARCA,ARCA,F,,0.003                                                     
ARCA,ARCA,G,,0.0005                                                   
ARCA,ARCA,L,,0.003                                                     
ARCA,ARCA,M,,-0.0015                                                   
//SORTOUT  DD SYSOUT=*                                                 
//SYSIN    DD *                                                       
 OPTION COPY                                                           
  INREC PARSE=(%01=(ENDBEFR=C',',FIXLEN=4),                           
               %02=(ENDBEFR=C',',FIXLEN=4),                           
               %03=(ENDBEFR=C',',FIXLEN=2),                           
               %04=(ENDBEFR=C',',FIXLEN=1),                           
               %05=(ENDBEFR=C'.',FIXLEN=2),                           
               %06=(FIXLEN=5)),                                       
 OVERLAY=(%01,%02,%03,%04,%05,JFY=(SHIFT=RIGHT),                       
       14:%06,ZD,EDIT=(TTTTT),10X,                                     
       12:12,08,JFY=(SHIFT=RIGHT),                                     
       12:12,08,SFF,TO=ZD,LENGTH=08)                                   
 OUTREC OVERLAY=(12:13,7,ZD,MUL,+100,EDIT=(TTTTTTTTS),SIGNS=(,,,-),10X)


And Output :-

Code:

ARCAARCAC  00008500 
ARCAARCAF  00030000 
ARCAARCAG  00005000 
ARCAARCAL  00030000 
ARCAARCAM  00015000-


Thanks
-3nadh
Back to top
View user's profile Send private message
Skolusu

Senior Member


Joined: 07 Dec 2007
Posts: 2205
Location: San Jose

PostPosted: Wed Dec 19, 2012 11:59 pm
Reply with quote

darkstar13,

Use the following DFSORT JCL which will give you the desired results. I assumed that your final number has S9V9(7) with trailing sign.

Code:

//STEP0100 EXEC PGM=SORT                       
//SYSOUT   DD SYSOUT=*                         
//SORTIN   DD *                                 
ARCA,ARCA,C,,0.00085                           
ARCA,ARCA,F,,0.003                             
ARCA,ARCA,G,,0.0005                             
ARCA,ARCA,L,,0.003                             
ARCA,ARCA,M,,-0.0015                           
//SORTOUT  DD SYSOUT=*                         
//SYSIN    DD *                                 
  OPTION COPY                                   
  INREC PARSE=(%01=(ENDBEFR=C',',FIXLEN=4),     
               %02=(ENDBEFR=C',',FIXLEN=4),     
               %03=(ENDBEFR=C',',FIXLEN=2),     
               %04=(ENDBEFR=C',',FIXLEN=1),     
               %05=(ENDBEFR=C'.',FIXLEN=2),     
               %06=(FIXLEN=7)),                 
        BUILD=(%01,%02,%03,%04,                 
               %05,SFF,EDIT=(T),%06,TRAN=ALTSEQ,
               %05,SFF,EDIT=(S),SIGNS=(,-))     
  ALTSEQ CODE=(40F0)                           
//*


The output from this is
Code:

ARCAARCAC  00008500
ARCAARCAF  00030000
ARCAARCAG  00005000
ARCAARCAL  00030000
ARCAARCAM  00015000-
Back to top
View user's profile Send private message
darkstar13

New User


Joined: 06 Nov 2008
Posts: 46
Location: Manila, Philippines

PostPosted: Thu Dec 20, 2012 5:45 am
Reply with quote

Hi Bodatrinadh, Skolusu,

Thanks a lot. It was a brilliant idea to parse using the decimal point ;)

I got the result that I wanted.

To Hailashwin and Bill, thanks for your reply. Your input is very much appreciated too. ;)
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 How to save SYSLOG as text data via P... All Other Mainframe Topics 2
No new posts Store the data for fixed length COBOL Programming 1
No new posts Extracting Variable decimal numbers f... DFSORT/ICETOOL 17
No new posts Data set Rec-Cnt and Byte-Cnt Testing & Performance 2
No new posts SCOPE PENDING option -check data DB2 2
Search our Forums:

Back to Top