Portal | Manuals | References | Downloads | Info | Programs | JCLs | Master the Mainframes
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist Usergroups Profile Log in to check your private messages Log in
 

 

format the data using syncsort

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> JCL & VSAM
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    Post subject: format the data using syncsort
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

DFSORT Moderator


Joined: 09 Mar 2011
Posts: 7223

PostPosted: Thu Apr 26, 2012 7:38 pm    Post subject: Reply to: format the data using syncsort
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    Post subject:
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

Site Director


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

PostPosted: Thu Apr 26, 2012 8:03 pm    Post subject:
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    Post subject:
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    Post subject:
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    Post subject:
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

DFSORT Moderator


Joined: 09 Mar 2011
Posts: 7223

PostPosted: Thu Apr 26, 2012 9:01 pm    Post subject: Reply to: format the data using syncsort
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: 1703
Location: Australia

PostPosted: Fri Apr 27, 2012 4:28 am    Post subject:
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    Post subject:
Reply with quote

hence the missing comma..........
Back to top
View user's profile Send private message
Bill Woodger

DFSORT Moderator


Joined: 09 Mar 2011
Posts: 7223

PostPosted: Fri Apr 27, 2012 5:16 am    Post subject: Reply to: format the data using syncsort
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    Post subject:
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    Post subject:
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

Site Director


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

PostPosted: Fri Apr 27, 2012 8:03 pm    Post subject: Reply to: format the data using syncsort
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    IBMMAINFRAMES.com Support Forums -> JCL & VSAM All times are GMT + 6 Hours
Page 1 of 1

 

Search our Forum:

Similar Topics
Topic Author Forum Replies Posted
No new posts syncsort: copy lines after the keyword shreya19 SYNCSORT 1 Fri Dec 02, 2016 9:47 am
No new posts ODPP(Optim Data privacy Provider) Iss... Rama kishore IBM Tools 1 Mon Nov 07, 2016 5:46 pm
No new posts Match or compare two files in VB Format anatol DFSORT/ICETOOL 14 Thu Nov 03, 2016 7:41 pm
No new posts Syncsort - Hard coded Value in output PORYES SYNCSORT 1 Thu Nov 03, 2016 9:23 am
No new posts Low values Results from VARCHAR FORMAT balaji81_k DB2 10 Thu Oct 20, 2016 1:18 am


Facebook
Back to Top
 
Mainframe Wiki | Forum Rules | Bookmarks | Subscriptions | FAQ | Tutorials | Contact Us