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
 

 

DFSORT USING PARSE command

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> DFSORT/ICETOOL
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    Post subject: DFSORT USING PARSE command
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

DFSORT Moderator


Joined: 09 Mar 2011
Posts: 7232

PostPosted: Wed Apr 10, 2013 5:44 pm    Post subject: Reply to: DFSORT USING PARSE command
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    Post subject: Reply to: DFSORT USING PARSE command
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    Post subject: Reply to: DFSORT USING PARSE command
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    Post subject: Reply to: DFSORT USING PARSE command
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    Post subject: Reply to: DFSORT USING PARSE command
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

DFSORT Moderator


Joined: 09 Mar 2011
Posts: 7232

PostPosted: Mon Apr 15, 2013 11:41 am    Post subject: Reply to: DFSORT USING PARSE command
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    Post subject: Reply to: DFSORT USING PARSE command
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

DFSORT Moderator


Joined: 09 Mar 2011
Posts: 7232

PostPosted: Mon Apr 15, 2013 4:52 pm    Post subject: Reply to: DFSORT USING PARSE command
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    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 What is the command to check MODE of ... rohanthengal CLIST & REXX 6 Fri Nov 18, 2016 1:48 pm
No new posts How to get the remainder and quotient... vnktrrd DFSORT/ICETOOL 2 Mon Oct 31, 2016 10:59 am
No new posts SDSF Command Avtrix CLIST & REXX 4 Fri Sep 30, 2016 11:13 am
No new posts How to find a CICS resource used in C... Arunkumar Chandrasekaran CICS 8 Thu Sep 29, 2016 1:45 pm
No new posts COMPARE command sivatechdrive TSO/ISPF 7 Fri Sep 16, 2016 4:31 pm


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