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

format the data using syncsort


IBM Mainframe Forums -> JCL & VSAM
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
venugopal404

New User


Joined: 14 Dec 2010
Posts: 13
Location: hyderabad

PostPosted: Thu Apr 26, 2012 7:22 pm
Reply with quote

Hi All..
We have a small requirement to add the amount field.position 86-100(15 bytes).but the problem is the amount fileds are not in a proper order and they are separated by commas.Sample data shown below.

Input file: FB, LRECL = 100..Declared as below..position 86-100

01 WS-AA.
05 FILLER PIC X(85).
05 TOTAL PIC ----,---,--9.99.

sample-data:

-1,280.00
-21,548.53
51,146.92
-3,165.24
-8,096.52
-193.41

Output File : FB,LRECL = 100..position 86-100

-00000001280.00
-00000021548.53
00000051146.92
-00000003165.24
-00000008096.52
-00000000193.41

after arranging in this way.we need to add these amounts and should display the sum at the bottom of the file under the same amount field.
Could some1 please help me out.
i have goggled and found a similar topic with the subject "Reformatting numeric data using sync sort" but this is working only when the field starts from 1st position if the file..in my input file the amount filed is at 86-100 position.

please help me out.
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: Thu Apr 26, 2012 7:38 pm
Reply with quote

Why don't you try with the code that starts at position 1, and change it to your start and length?
Back to top
View user's profile Send private message
venugopal404

New User


Joined: 14 Dec 2010
Posts: 13
Location: hyderabad

PostPosted: Thu Apr 26, 2012 7:58 pm
Reply with quote

Hi Bill.

We Need 3 steps in the JCL to Accomplish this task where in the first step,
i need to pull out the data from the input file (pos 86-100) to a temporary file..
in the second i need to do my reformatting and the third i need to put back the same in the main-file again.

Want to accomplish this in a single step using sort.
Back to top
View user's profile Send private message
dick scherrer

Moderator Emeritus


Joined: 23 Nov 2006
Posts: 19244
Location: Inside the Matrix

PostPosted: Thu Apr 26, 2012 8:03 pm
Reply with quote

Hello,

Why do you believe you need to do this in 3 steps?

Why not try as Bill suggested and simply refer to the proper data positions instead of pos 1?

Maybe posting better sample input and desired output data would help.
Back to top
View user's profile Send private message
venugopal404

New User


Joined: 14 Dec 2010
Posts: 13
Location: hyderabad

PostPosted: Thu Apr 26, 2012 8:14 pm
Reply with quote

Hi Dick/Bill..

Below is the piece of code which is working fine for the amounts in position 1-10.. and its working fine..

Code:
//STEP01   EXEC  PGM=SORT                                             
//SORTIN   DD  *                                                       
   -213.45                                                             
   9865.56                                                             
  65654.98                                                             
 -55455.65                                                             
 -45545.56                                                             
//SORTOUT  DD  SYSOUT=*                                               
//SYSOUT DD SYSOUT=*                                                   
//SYSIN DD *                                                           
  OPTION COPY                                                         
    INREC IFTHEN=(WHEN=(1,10,SS,NE,C'.'),                             
            OVERLAY=(8:C'.00',20X),HIT=NEXT),                         
          IFTHEN=(WHEN=(1,10,SS,EQ,C'.'),                             
            BUILD=(1:1,10,SQZ=(SHIFT=RIGHT)),HIT=NEXT),               
          IFTHEN=(WHEN=(25,1,CH,EQ,C' '),                             
            FINDREP=(STARTPOS=1,ENDPOS=10,IN=C' ',OUT=C'0'),HIT=NEXT),
          IFTHEN=(WHEN=(1,10,SS,EQ,C'-'),
  OVERLAY=(1:C'-'),HIT=NEXT),                             
IFTHEN=(WHEN=(2,9,SS,EQ,C'-'),                           
 FINDREP=(STARTPOS=2,ENDPOS=9,IN=C'-',OUT=C'0'),HIT=NEXT),
IFTHEN=(WHEN=(1,1,CH,NE,C'-'),                           
  OVERLAY=(1:C' '))

output:
Code:
-000213.45
 009865.56
 065654.98
-055455.65
-045545.56

below is my sort card after changing according to my requirement.
Code:
OPTION COPY                                                           
  INREC IFTHEN=(WHEN=(86,15,SS,NE,C'.'),                             
          OVERLAY=(98:C'.00',20X),HIT=NEXT),                         
        IFTHEN=(WHEN=(86,15,SS,EQ,C'.'),                             
          BUILD=(86:1,15,SQZ=(SHIFT=RIGHT)),HIT=NEXT),               
        IFTHEN=(WHEN=(105,1,CH,EQ,C' '),                             
          FINDREP=(STARTPOS=86,ENDPOS=100,IN=C' ',OUT=C'0'),HIT=NEXT),
        IFTHEN=(WHEN=(86,15,SS,EQ,C'-'),                             
          OVERLAY=(86:C'-'),HIT=NEXT),                               
        IFTHEN=(WHEN=(87,14,SS,EQ,C'-'),                             
         FINDREP=(STARTPOS=87,ENDPOS=99,IN=C'-',OUT=C'0'),HIT=NEXT), 
        IFTHEN=(WHEN=(86,1,CH,NE,C'-'),                               
          OVERLAY=(86:C' '))             


output error Message:
WER268A INREC STATEMENT : SYNTAX ERROR
WER211B SYNCSMF CALLED BY SYNCSORT; RC=0000
WER449I SYNCSORT GLOBAL DSM SUBSYSTEM ACTIVE

Code:
OPTION COPY                                                         
  INREC IFTHEN=(WHEN=(86,15,SS,NE,C'.'),                             
          OVERLAY=(98:C'.00',20X),HIT=NEXT),                         
        IFTHEN=(WHEN=(86,15,SS,EQ,C'.'),                             
          BUILD=(86:1,15,SQZ=(SHIFT=RIGHT)),HIT=NEXT),               
        IFTHEN=(WHEN=(105,1,CH,EQ,C' '),                             
          FINDREP=(STARTPOS=86,ENDPOS=100,IN=C' ',OUT=C'0'),HIT=NEXT)
        IFTHEN=(WHEN=(86,15,SS,EQ,C'-'),                             
        *     -------> showing syntax error here                                                       
          OVERLAY=(86:C'-'),HIT=NEXT),                               
        IFTHEN=(WHEN=(87,14,SS,EQ,C'-'),                             
         FINDREP=(STARTPOS=87,ENDPOS=99,IN=C'-',OUT=C'0'),HIT=NEXT),
        IFTHEN=(WHEN=(86,1,CH,NE,C'-'),                             
          OVERLAY=(86:C' '))

could you please help me.
Back to top
View user's profile Send private message
dbzTHEdinosauer

Global Moderator


Joined: 20 Oct 2006
Posts: 6966
Location: porcelain throne

PostPosted: Thu Apr 26, 2012 8:38 pm
Reply with quote

how about the missing comma on the line above?
Back to top
View user's profile Send private message
venugopal404

New User


Joined: 14 Dec 2010
Posts: 13
Location: hyderabad

PostPosted: Thu Apr 26, 2012 8:41 pm
Reply with quote

Dick,

My Aplogies..

there was a comma when i ran it..but while pasting here in the FORUM..i missed it in copy n paste.

below is the sort-card
Code:
  OPTION COPY                                                             
    INREC IFTHEN=(WHEN=(86,15,SS,NE,C'.'),                               
            OVERLAY=(98:C'.00',20X),HIT=NEXT),                           
          IFTHEN=(WHEN=(86,15,SS,EQ,C'.'),                               
            BUILD=(86:1,15,SQZ=(SHIFT=RIGHT)),HIT=NEXT),                 
          IFTHEN=(WHEN=(105,1,CH,EQ,C' '),                               
            FINDREP=(STARTPOS=86,ENDPOS=100,IN=C' ',OUT=C'0'),HIT=NEXT), 
          IFTHEN=(WHEN=(86,15,SS,EQ,C'-'),                               
          *                                                               
            OVERLAY=(86:C'-'),HIT=NEXT),                                 
          IFTHEN=(WHEN=(87,14,SS,EQ,C'-'),                               
           FINDREP=(STARTPOS=87,ENDPOS=99,IN=C'-',OUT=C'0'),HIT=NEXT),   
          IFTHEN=(WHEN=(86,1,CH,NE,C'-'),                                 
            OVERLAY=(86:C' '))   


WER268A INREC STATEMENT : SYNTAX ERROR
WER211B SYNCSMF CALLED BY SYNCSORT; RC=0000
WER449I SYNCSORT GLOBAL DSM SUBSYSTEM ACTIVE
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: Thu Apr 26, 2012 9:01 pm
Reply with quote

You have a Signed Free Format field, in DFSORT terms. I don't know if Syncsort has them, maybe that is the reason for the weirdness.

Code:
86,14,SFF


You "arrange in that way" with an appropriate EDIT mask.

If you want to then add them, and have the total at the end of the file, you should be able to do that with TRAILER1 and again using SFF.

I can't try this with Syncsort, and haven't tried it with DFSORT.

If the commas or decimal point give you problems despite SFF, you could try to FINDREP them to C''.
Back to top
View user's profile Send private message
gcicchet

Senior Member


Joined: 28 Jul 2006
Posts: 1702
Location: Australia

PostPosted: Fri Apr 27, 2012 4:28 am
Reply with quote

Hi,

what column does the last byte in this statement occupy ?
Code:
            FINDREP=(STARTPOS=86,ENDPOS=100,IN=C' ',OUT=C'0'),HIT=NEXT),



Gerry
Back to top
View user's profile Send private message
dbzTHEdinosauer

Global Moderator


Joined: 20 Oct 2006
Posts: 6966
Location: porcelain throne

PostPosted: Fri Apr 27, 2012 5:15 am
Reply with quote

hence the missing comma..........
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: Fri Apr 27, 2012 5:16 am
Reply with quote

See if this gets you somewhere:

Code:
//STEP0100 EXEC PGM=SORT
//CHKOUT DD DUMMY
//SYSOUT   DD SYSOUT=*
//SORTOUT  DD SYSOUT=*
//SYSIN    DD *
  OPTION COPY
  INREC IFTHEN=(WHEN=INIT,
                 OVERLAY=(20:1,14,SFF,
                           EDIT=(STTTTTTTTT.TT),SIGNS=(,-)))
  OUTFIL REMOVECC,TRAILER1=(20:TOT=(20,13,SFF,
                           EDIT=(STTTTTTTTT.TT),SIGNS=(,-)))
//SORTIN DD *
       -213.45
      9,865.56
     65,654.98
    -55,455.65
    -45,545.56


Gives:
Code:

       -213.45     -000000213.45
      9,865.56      000009865.56
     65,654.98      000065654.98
    -55,455.65     -000055455.65
    -45,545.56     -000045545.56
                   -000025694.12


If you are just after the total, you don't even have to reformat the number, just go with the TRAILER1 with your original data.
Back to top
View user's profile Send private message
venugopal404

New User


Joined: 14 Dec 2010
Posts: 13
Location: hyderabad

PostPosted: Fri Apr 27, 2012 9:52 am
Reply with quote

Hi Bill..

The Above Piece of sort-card is working fine when the amount field is in first 15 bytes of the input file.In my case the amount field is present in 86-100 position.

could you please help me in modifying the above sort-card..

In the sort-card, where can i specify the starting position of the amount field in my case..
Back to top
View user's profile Send private message
venugopal404

New User


Joined: 14 Dec 2010
Posts: 13
Location: hyderabad

PostPosted: Fri Apr 27, 2012 10:46 am
Reply with quote

hello All..

below code is working fine for my requirement..

OPTION COPY
INREC IFTHEN=(WHEN=INIT,
OVERLAY=(86:86,14,SFF,
EDIT=(STTTTTTTTT.TT),SIGNS=(,-)))
OUTFIL REMOVECC,TRAILER1=(86:TOT=(86,13,SFF,
EDIT=(STTTTTTTTT.TT),SIGNS=(,-)))

Thanks All for ur support and help...
Back to top
View user's profile Send private message
dick scherrer

Moderator Emeritus


Joined: 23 Nov 2006
Posts: 19244
Location: Inside the Matrix

PostPosted: Fri Apr 27, 2012 8:03 pm
Reply with quote

Good to hear it is working - thank you for letting us know icon_smile.gif

d
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 -> JCL & VSAM

 


Similar Topics
Topic Forum Replies
No new posts Store the data for fixed length COBOL Programming 1
No new posts Populate last day of the Month in MMD... SYNCSORT 2
No new posts Modifying Date Format Using DFSORT DFSORT/ICETOOL 9
No new posts Compare only first records of the fil... SYNCSORT 7
No new posts Data set Rec-Cnt and Byte-Cnt Testing & Performance 2
Search our Forums:

Back to Top