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

DFSORT USING PARSE command


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

New User


Joined: 31 Jul 2007
Posts: 47
Location: chennai

PostPosted: Wed Apr 10, 2013 5:26 pm
Reply with quote

Hi,

Input File:
-12.34
7
0.07
-1.2

Excepted Output File:
-000012 34
000007 00
000000 07
-000001 20

I have tried the below sort card:
Code:
INREC IFTHEN=(WHEN=INIT,                       
      PARSE=(     
              %01=(ENDBEFR=C'.',FIXLEN=06),     
             %02=(ENDBEFR=C',',FIXLEN=02)),     
BUILD=(             
                 
       %01,SFF,EDIT=(STTTTTT),SIGNS=(,-),X,     
       %02,UFF,M11,LENGTH=02,X))
OUTREC BUILD=(1,80)                 


My output:

Code:
-000012 34
 000007 00
 000000 07
-000001 02


In my Output last record are wrong.
Please provide me the correct sort card.

Thanks in Advance!
Regards,
Senthilnathan J
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 Apr 10, 2013 5:44 pm
Reply with quote

Your output is correct, even if it is not what you want.

Have you searched the forum for examples?
Back to top
View user's profile Send private message
senthilnathanj

New User


Joined: 31 Jul 2007
Posts: 47
Location: chennai

PostPosted: Wed Apr 10, 2013 8:10 pm
Reply with quote

Thanks Bill.

But I got the final solution. Below is my sort card:
Code:

OPTION COPY                                   
INREC IFTHEN=(WHEN=INIT,                     
      PARSE=(%01=(ENDBEFR=C'.',FIXLEN=06),   
             %02=(ENDBEFR=C',',FIXLEN=02)),   
                                             
BUILD=(%01,SFF,EDIT=(STTTTTT),SIGNS=(,-),X,   
       %02,ZD,M11,LENGTH=02))                 
                                             
     OUTREC BUILD=(1,10)                     


Excepted Output:
000001 20
Back to top
View user's profile Send private message
senthilnathanj

New User


Joined: 31 Jul 2007
Posts: 47
Location: chennai

PostPosted: Sat Apr 13, 2013 3:36 am
Reply with quote

Hi,

If I added one more column, this sort card is not working.

Input File:
Code:

123,-12.34
12,7     
34,0.3   
67,0.07   
98,-1.2   


Sort Card:
Code:

//SYSIN    DD *                               
   OPTION COPY                                 
   INREC IFTHEN=(WHEN=INIT,                   
         PARSE=(%01=(ENDBEFR=C'.',FIXLEN=05), 
                %02=(ENDBEFR=C'.',FIXLEN=06), 
                %03=(ENDBEFR=C',',FIXLEN=02)),
                                               
   BUILD=(%01,UFF,M11,LENGTH=06,X,             
          %02,SFF,EDIT=(STTTTTT),SIGNS=(,-),X,
          %03,ZD,M11,LENGTH=02))               
                                               
        OUTREC BUILD=(1,17)                   


My Out put:
Code:

00123  000034 00 
00127  000000 00 
00340  000003 00 
00670  000007 00 
00981  000002 00 

Excepted Output:
Code:

00123 -000012 34 
00127  000007 00 
00340  000000 30 
00670  000000 70 
00981 -000001 20 


Is there anyway to correct the sort card.
Please advise!
Back to top
View user's profile Send private message
Skolusu

Senior Member


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

PostPosted: Sat Apr 13, 2013 3:47 am
Reply with quote

senthilnathanj,

You should parse looking for comma for the first field. Use the following DFSORT JCL which will give you the desired results.

Code:

//STEP0100 EXEC PGM=SORT                                 
//SYSOUT   DD SYSOUT=*                                   
//SORTIN   DD *                                         
123,-12.34                                               
12,7                                                     
34,0.3                                                   
67,0.07                                                 
98,-1.2                                                 
//SORTOUT  DD SYSOUT=*                                   
//SYSIN    DD *                                         
  OPTION COPY                                           
  INREC PARSE=(%01=(ENDBEFR=C',',FIXLEN=6),             
               %02=(ENDBEFR=C'.',ENDBEFR=C',',FIXLEN=6),
               %03=(FIXLEN=2)),                         
        BUILD=(%01,UFF,M11,LENGTH=06,X,                 
               %02,SFF,EDIT=(STTTTTT),SIGNS=(,-),X,     
               %03,ZD,EDIT=(TT))                         
//*
Back to top
View user's profile Send private message
senthilnathanj

New User


Joined: 31 Jul 2007
Posts: 47
Location: chennai

PostPosted: Mon Apr 15, 2013 11:00 am
Reply with quote

Hi Skolusu,

Thanks for providing Solution.

Input File:
Code:

123,-12.34,345
323,4,345     
523,0.4,ABD   
623,-0.05,     
723,1.24,345   


My Sort card:
Code:

   OPTION COPY                                               
   INREC PARSE=(%01=(ENDBEFR=C',',FIXLEN=06),                 
                %02=(ENDBEFR=C'.',ENDBEFR=C',',FIXLEN=06),   
                %03=(FIXLEN=02,ENDBEFR=C','),                 
                %04=(FIXLEN=09)),                             
                                                             
   BUILD=(%01,UFF,M11,LENGTH=06,X,                           
          %02,SFF,EDIT=(STTTTTT),SIGNS=(,-),X,               
          %03,ZD,EDIT=(TT),X,                                 
          %04)                                               


output :
Code:

000123 -000012 34 345   
000323  000004 34       
000523  000000 40 ABD   
000623 -000000 05       
000723  000001 24 345   


Excepted Output:
Code:

000123 -000012 34 345   
000323  000004 00 345       
000523  000000 40 ABD   
000623 -000000 05       
000723  000001 24 345   


Only Integer in the amount field is not working.
In this example 2nd row is incorrect.
Please Advise!
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: Mon Apr 15, 2013 11:41 am
Reply with quote

This is the third time you have defined the problem. First, with one piece of data, then with two, then with three.

Is it finished now, or do you have more than three "columns" of data?

Are they the first columns?
Back to top
View user's profile Send private message
senthilnathanj

New User


Joined: 31 Jul 2007
Posts: 47
Location: chennai

PostPosted: Mon Apr 15, 2013 4:18 pm
Reply with quote

Yeah.This is the final one. No more format is required for me.
Quote:

Are they the first columns?

no.That one is different column.
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: Mon Apr 15, 2013 4:52 pm
Reply with quote

OK, assuming that you have a number of columns-of-data separated by commas, I would first PARSE everything on the commas.

I'd then locate the fields which need further attention (those which may or may not contain a ".") and PARSE those separately.

I'm assuming your data is fixed-length records:

Code:
//PRSTWICE EXEC PGM=SORT
//SYSOUT   DD SYSOUT=*
//SORTOUT  DD SYSOUT=*
//SYSIN    DD *
  OPTION COPY
                                                           
  INREC IFTHEN=(WHEN=INIT,
                 PARSE=(%01=(ENDBEFR=C',',
                             FIXLEN=06),
                        %02=(ENDBEFR=C',',
                             FIXLEN=09),
                        %03=(FIXLEN=09))),
                                                           
        IFTHEN=(WHEN=INIT,
                 OVERLAY=(81:%02)),
                                                           
        IFTHEN=(WHEN=INIT,
                 PARSE=(%04=(ABSPOS=81,
                             ENDBEFR=C'.',
                             FIXLEN=06),
                        %05=(FIXLEN=02))),
                                                           
        IFTHEN=(WHEN=INIT,
                 BUILD=(%01,UFF,M11,LENGTH=06,X,
                        %04,SFF,EDIT=(STTTTTT),SIGNS=(,-),X,
                        %05,ZD,EDIT=(TT),X,
                        %03))
                                                           
//SORTIN   DD *
123,-12.34,345
323,4,345
523,0.4,ABD
623,-0.05,
723,1.24,345
987,3.2,890


This gives:

Code:
000123 -000012 34 345
000323  000004 00 345
000523  000000 40 ABD
000623 -000000 05   
000723  000001 24 345
000987  000003 20 890


Note that %5 will contain blanks where no decimal places, and one blank when one decimal place, but that the EDIT will make the blanks into zeros.
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 RACF - Rebuild SETROPTS command which... All Other Mainframe Topics 3
No new posts PARSE Syntax for not fix length word ... JCL & VSAM 7
No new posts Modifying Date Format Using DFSORT DFSORT/ICETOOL 9
No new posts Routing command Address SDSF to other... TSO/ISPF 2
No new posts Replace Multiple Field values to Othe... DFSORT/ICETOOL 12
Search our Forums:

Back to Top