MVSFORUMS.com Forum Index MVSFORUMS.com
A Community of and for MVS Professionals
 
 FAQFAQ   SearchSearch   Quick Manuals   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Need help in formatting output

 
Post new topic   Reply to topic   printer-friendly view    MVSFORUMS.com Forum Index -> Utilities
View previous topic :: View next topic  
Author Message
shekar123
Advanced


Joined: 22 Jul 2005
Posts: 528
Topics: 90
Location: Bangalore India

PostPosted: Mon May 27, 2024 2:36 am    Post subject: Need help in formatting output Reply with quote

I have a dataset with data as below FB 80 bytes 800 BLKSIZE
Code:
----+----1----+----2----+----3----+----4----+----5----+----6----+----7----+----8
********************************* Top of Data **********************************
SYSDSNAME=TEST.DBDSRC                                                     
SYSADIRBLK=1848                                                                 
SYSALLOC=210                                                                   
SYSUDIRBLK=1752                                                                 
SYSUSED=104                                                                     
SYSMEMBERS=12259                                                               
SYSEXTENTS=16                                                                   
SYSCREATE=1995/071                                                             
SYSPRIMARY=135                                                                 
SYSUNITS=CYLINDER               

I need desired output as below
Code:

----+----1----+----2----+----3----+----4----+----5----+----6----+----7----+----8
********************************* Top of Data **********************************
                    TEST.DBDSRC                                       2024-05-27
                                                                               
ALLOCATED DIRECTORY BLOCKS: 1848                                               
USED      DIRECTORY BLOCKS: 1752                                               
LEFT OUT  DIRECTORY BLOCKS:   96                                                     

CURRENT NUMBER OF MEMBERS : 12259            
YOU CAN ACCMODATE MEMBERS :   576 ( 96 * 6 = 576 )       

ALLOCATED SPACE           :  210            
USED SPACE                :  104            
LEFT OUT SPACE            :  106 CYLINDERS - this should pick up from the variable output SYSUNITS          

EXTENTS                   :    1            

I have not used SORT for a long time and I would need help. I started with the below code and I got
Code:
----+----1----+----2----+----3----+----4----+----5----+----6----+----7----+----8
********************************* Top of Data **********************************
                    TEST.DBDSRC                                       2024-05-27
                                                                               
ALLOCATED DIRECTORY BLOCKS: 1848                                               
USED      DIRECTORY BLOCKS: 1752                                               
LEFT OUT  DIRECTORY BLOCKS:                                                     



My SORT code
Code:
//STEP030  EXEC PGM=SORT                                     
//SORTIN   DD *                                               
                                                             
/*                                                           
//SORTOUT  DD DSN=&&T1,                                       
//            UNIT=SYSDA,DISP=(NEW,PASS),                     
//            DCB=(LRECL=80,BLKSIZE=800,RECFM=FB),           
//            SPACE=(CYL,(1,1))                               
//SYSOUT   DD SYSOUT=*                                       
//SYSPRINT DD SYSOUT=*                                       
//SYSIN    DD *                                               
  SORT FIELDS=COPY                                           
  OUTREC FIELDS=(80X)                                         
/*                                                           
//************************************************************
//STEP040  EXEC PGM=SORT                                     
//SORTIN   DD DSN=TEST.DBDSRC,DISP=SHR
//SORTOUT  DD DSN=&&T2,                                       
//            UNIT=SYSDA,DISP=(NEW,PASS),                     
//            DCB=(LRECL=80,BLKSIZE=800,RECFM=FB),                     
//            SPACE=(CYL,(1,1))                                         
//SYSOUT   DD SYSOUT=*                                                 
//SYSPRINT DD SYSOUT=*                                                 
//SYSIN    DD *                                                         
  INCLUDE COND=(01,10,CH,EQ,C'SYSDSNAME=')                             
  SORT FIELDS=COPY                                                     
  OUTREC FIELDS=(21:11,45,5X,DATE1(-))                                 
/*                                                                     
//**********************************************************************
//STEP050  EXEC PGM=SORT                                               
//SORTIN   DD DSN=TEST.DBDSRC,DISP=SHR           
//SORTOUT  DD DSN=&&T3,                                                 
//            UNIT=SYSDA,DISP=(NEW,PASS),                               
//            DCB=(LRECL=80,BLKSIZE=800,RECFM=FB),                     
//            SPACE=(CYL,(1,1))                                         
//SYSOUT   DD SYSOUT=*                                                 
//SYSPRINT DD SYSOUT=*                                                 
//SYSIN    DD *                                                         
  INCLUDE COND=(01,11,CH,EQ,C'SYSADIRBLK=')                             
  SORT FIELDS=COPY                                                     
  OUTREC FIELDS=(01:C'ALLOCATED DIRECTORY BLOCKS: ',29:12,5,80:X)       
/*                                                                     
//**********************************************************************
//STEP060  EXEC PGM=SORT                                               
//SORTIN   DD DSN=TEST.DBDSRC,DISP=SHR           
//SORTOUT  DD DSN=&&T4,                                                 
//            UNIT=SYSDA,DISP=(NEW,PASS),                               
//            DCB=(LRECL=80,BLKSIZE=800,RECFM=FB),                     
//            SPACE=(CYL,(1,1))                                         
//SYSOUT   DD SYSOUT=*                                                 
//SYSPRINT DD SYSOUT=*                                                 
//SYSIN    DD *                                                         
  INCLUDE COND=(01,11,CH,EQ,C'SYSUDIRBLK=')                             
  SORT FIELDS=COPY                                                     
  OUTREC FIELDS=(01:C'USED      DIRECTORY BLOCKS: ',29:12,5,80:X)       
/*                                                                     
//**********************************************************************
//STEP070  EXEC PGM=SORT                                               
//SORTIN   DD DSN=TEST.DBDSRC,DISP=SHR           
//SORTOUT  DD DSN=&&T5,                                                 
//            UNIT=SYSDA,DISP=(NEW,PASS),                               
//            DCB=(LRECL=80,BLKSIZE=800,RECFM=FB),                     
//            SPACE=(CYL,(1,1))                                         
//SYSOUT   DD SYSOUT=*                                                 
//SYSPRINT DD SYSOUT=*                                                 
//SYSIN    DD *                                                         
  INCLUDE COND=(01,11,CH,EQ,C'SYSUDIRBLK=')                             
  SORT FIELDS=COPY                                                     
  OUTREC FIELDS=(01:C'LEFT OUT  DIRECTORY BLOCKS: ',80:X)               
/*                                                                     
//**********************************************************************
//FINAL    EXEC PGM=SORT                                               
//SORTIN   DD DSN=&&T2,DISP=(OLD,DELETE)                               
//         DD DSN=&&T1,DISP=(OLD,PASS)                                 
//         DD DSN=&&T3,DISP=(OLD,DELETE)                               
//         DD DSN=&&T4,DISP=(OLD,DELETE)                               
//         DD DSN=&&T5,DISP=(OLD,DELETE)                           
//SORTOUT  DD DSN=TEST.DBDSRC.REPORT,           
//            UNIT=SYSDA,DISP=(NEW,CATLG,DELETE),                   
//            DCB=(LRECL=80,BLKSIZE=800,RECFM=FB),                 
//            SPACE=(CYL,(1,1))                                     
//SYSOUT   DD SYSOUT=*                                             
//SYSPRINT DD SYSOUT=*                                             
//SYSIN    DD *                                                     
  SORT FIELDS=COPY                                                 
/*                                                                 
//

_________________
Shekar
Grow Technically
Back to top
View user's profile Send private message
kolusu
Site Admin
Site Admin


Joined: 26 Nov 2002
Posts: 12369
Topics: 75
Location: San Jose

PostPosted: Mon May 27, 2024 9:46 am    Post subject: Reply with quote

shekar123,

What a waste of time and resources. bonk bonk A simple 10 line report can be generated much faster by hand rather than running 6 passes of data for getting only partial data bonk

You have been a member for a long time, but post questions which lack BASIC information like what is the LRECL and RECFM of the input file? I had to find out from your sample coded JCL. On top of it you post incorrect output.

in your input you have
Code:
SYSEXTENTS=16       


but your output you have
Code:

EXTENTS                   :    1     


Where did you get the extents of 1 when the value is 16?

Any way here is a UNTESTED 1 step solution that would give you the desired results.

Code:

//STEP0100 EXEC PGM=SORT                                 
//SYSOUT   DD SYSOUT=*                                   
//SORTIN   DD *                                           
SYSDSNAME=TEST.DBDSRC                                     
SYSADIRBLK=1848                                           
SYSALLOC=210                                             
SYSUDIRBLK=1752                                           
SYSUSED=104                                               
SYSMEMBERS=12259                                         
SYSEXTENTS=16                                             
SYSCREATE=1995/071                                       
SYSPRIMARY=135                                           
SYSUNITS=CYLINDER                                         
//SORTOUT  DD SYSOUT=*   
//SYSIN    DD *                                 
  INCLUDE COND=(01,10,CH,EQ,C'SYSDSNAME=',OR,                       
                01,11,CH,EQ,C'SYSADIRBLK=',OR,                       
                01,11,CH,EQ,C'SYSUDIRBLK=',OR,                       
                01,11,CH,EQ,C'SYSMEMBERS=',OR,                       
                01,09,CH,EQ,C'SYSALLOC=',OR,                         
                01,08,CH,EQ,C'SYSUSED=',OR,                         
                01,08,CH,EQ,C'SYSUNITS=',OR,                         
                01,11,CH,EQ,C'SYSEXTENTS=')                         
                                                                     
  INREC IFTHEN=(WHEN=INIT,                                           
               PARSE=(%01=(STARTAFT=C'=',                           
                            ENDBEFR=C' ',                           
                             FIXLEN=44)),                           
             OVERLAY=(81:C'Z',%01)),                                 
                                                                     
        IFTHEN=(WHEN=INIT,                                           
             OVERLAY=(81:01,08,CHANGE=(1,C'SYSUSED=',C'C'),         
                              NOMATCH=(81,1),                       
                                                                     
                      81:01,09,CHANGE=(1,C'SYSUNITS=',C'B',         
                                         C'SYSALLOC=',C'C'),         
                              NOMATCH=(81,1),                       
                                                                     
                      81:01,10,CHANGE=(1,C'SYSDSNAME=',C'A'),       
                              NOMATCH=(81,1),                       
                                                                     
                      81:01,11,CHANGE=(1,C'SYSADIRBLK=',C'A',       
                                         C'SYSUDIRBLK=',C'A',       
                                         C'SYSMEMBERS=',C'B'),       
                              NOMATCH=(81,1)))                       
                                                                     
  SORT FIELDS=(81,1,CH,A),EQUALS                                     
                                                                     
  OUTREC IFTHEN=(WHEN=GROUP,BEGIN=(01,10,CH,EQ,C'SYSDSNAME='),     
                PUSH=(126:82,44)),                                 
                                                                   
         IFTHEN=(WHEN=GROUP,BEGIN=(01,11,CH,EQ,C'SYSADIRBLK='),   
                PUSH=(171:82,44)),                                 
                                                                   
         IFTHEN=(WHEN=GROUP,BEGIN=(01,11,CH,EQ,C'SYSUDIRBLK='),   
                PUSH=(216:82,44)),                                 
                                                                   
        IFTHEN=(WHEN=GROUP,BEGIN=(01,09,CH,EQ,C'SYSUNITS='),       
                PUSH=(261:82,44)),                                 
                                                                   
        IFTHEN=(WHEN=GROUP,BEGIN=(01,09,CH,EQ,C'SYSALLOC='),       
                PUSH=(306:82,44)),                                 
                                                                   
        IFTHEN=(WHEN=(01,11,CH,EQ,C'SYSUDIRBLK='),                 
             OVERLAY=(352:170,16,UFF,SUB,                         
                          215,16,UFF,M10,LENGTH=6)),               
                                                                   
        IFTHEN=(WHEN=(01,11,CH,EQ,C'SYSMEMBERS='),                 
             OVERLAY=(360:(170,16,UFF,SUB,                         
                           215,16,UFF),MUL,+6,M10,LENGTH=6)),     
                                                                   
        IFTHEN=(WHEN=(01,08,CH,EQ,C'SYSUSED='),                   
             OVERLAY=(370:306,16,UFF,SUB,                         
                          082,16,UFF,M10,LENGTH=6,X,               
                          261,44,                                 
                      370:370,50,SQZ=(SHIFT=LEFT,MID=C' ')))       
                                                                   
  OUTFIL REMOVECC,                                           
  OMIT=(01,09,CH,EQ,C'SYSUNITS=',OR,                         
        01,09,CH,EQ,C'SYSALLOC=',OR,                         
        01,10,CH,EQ,C'SYSDSNAME=',OR,                         
        01,11,CH,EQ,C'SYSADIRBLK='),                         
                                                             
  HEADER1=(22:126,44,70:&DATE=(4MD-),/),                     
  IFOUTLEN=80,                                               
    IFTHEN=(WHEN=(01,11,CH,EQ,C'SYSUDIRBLK='),               
      BUILD=(C'ALLOCATED DIRECTORY BLOCKS :   ',171,44,/,     
             C'USED      DIRECTORY BLOCKS :   ',082,44,/,     
             C'LEFT OUT  DIRECTORY BLOCKS : ',352,6,/)),     
                                                             
    IFTHEN=(WHEN=(01,11,CH,EQ,C'SYSMEMBERS='),               
      BUILD=(C'CURRENT NUMBER OF MEMBERS  :  ',082,44,/,     
             C'YOU CAN ACCMODATE MEMBERS  : ',360,06,/)),     
                                                             
    IFTHEN=(WHEN=(01,08,CH,EQ,C'SYSUSED='),                   
      BUILD=(C'ALLOCATED SPACE            :  ',306,44,/,     
             C'USED SPACE                 :  ',082,44,/,     
             C'LEFT OUT SPACE             :  ',370,50,/)),   
                                                             
    IFTHEN=(WHEN=(01,11,CH,EQ,C'SYSEXTENTS='),               
      BUILD=(C'EXTENTS                    :  ',082,44))       
/*                                                           

_________________
Kolusu
www.linkedin.com/in/kolusu
Back to top
View user's profile Send private message Send e-mail Visit poster's website
shekar123
Advanced


Joined: 22 Jul 2005
Posts: 528
Topics: 90
Location: Bangalore India

PostPosted: Mon May 27, 2024 11:11 am    Post subject: Reply with quote

Kolusu

Thank you so much for your help. I lost DFSORT usage to some extent. I completely agree whatever I coded is just waste of time and resources.But I have completely understand the code syntax and the way you have achieved the output.

Code:

                     TEST.DBDSRC                                     2024-05-27
                                                                               
ALLOCATED DIRECTORY BLOCKS :   1848                                             
USED      DIRECTORY BLOCKS :   1752                                             
LEFT OUT  DIRECTORY BLOCKS :     96                                             
                                                                               
CURRENT NUMBER OF MEMBERS  :  12259                                             
YOU CAN ACCMODATE MEMBERS  :    576                                             
                                                                               
ALLOCATED SPACE            :  210                                               
USED SPACE                 :  104                                               
LEFT OUT SPACE             :  106 CYLINDER                                     
                                                                               
EXTENTS                    :  16                                               
   
           

Thank you once again.
_________________
Shekar
Grow Technically
Back to top
View user's profile Send private message
kolusu
Site Admin
Site Admin


Joined: 26 Nov 2002
Posts: 12369
Topics: 75
Location: San Jose

PostPosted: Mon May 27, 2024 6:45 pm    Post subject: Reply with quote

shekar123 wrote:
I lost DFSORT usage to some extent.


shekar123,


Any programming language/utility is like riding a bike. You learn once and never forget. I haven't coded COBOL programs since 2006 as I primarily deal with HLASM, but even to this date, I can code an entire COBOL program on the fly. Same with Db2. So pay attention to what you learn and that helps in the long run.

shekar123 wrote:
But I have completely understand the code syntax and the way you have achieved the output.


The job is quite simple.

1. The INCLUDE COND will only bring in the desired records.
2. We parse the contents of each record looking "=" and pick the contents after that. Since the dataset name can be a maximum of 44 bytes, we used FIXLEN=44
3. We also need to re-arrange the records as the output you want is NOT following the same order as the input. So we tag every record as "Z" and then change it based it on fields

4. Now sort the records so that they are in the order that you seek.

5. On outrec using when=GROUP, you just need to push the values on to each record, so that all the records have information you require.

6. Now since you needed the calculation allocated - used and primary - secondary we do that calculation

7. Once we have we the necessary information, it is just about building the final output. The "/" is used to create a new record.

If you do want to understand how each of the statements work, you can run the job with 1 statement at a time

for example:

Pass 1: See how the INCLUDE COND works.
Code:

//SYSIN    DD *
  INCLUDE COND=(01,10,CH,EQ,C'SYSDSNAME=',OR,                       
                01,11,CH,EQ,C'SYSADIRBLK=',OR,                       
                01,11,CH,EQ,C'SYSUDIRBLK=',OR,                       
                01,11,CH,EQ,C'SYSMEMBERS=',OR,                       
                01,09,CH,EQ,C'SYSALLOC=',OR,                         
                01,08,CH,EQ,C'SYSUSED=',OR,                         
                01,08,CH,EQ,C'SYSUNITS=',OR,                         
                01,11,CH,EQ,C'SYSEXTENTS=')     
 
 SORT FIELDS=COPY
/*


Pass2 : See how the parse and records are tagged with Z ( see position 81 onwards). Notice that COMMA is missing as you don't have other statements.
Code:

//SYSIN    DD *
  INCLUDE COND=(01,10,CH,EQ,C'SYSDSNAME=',OR,                       
                01,11,CH,EQ,C'SYSADIRBLK=',OR,                       
                01,11,CH,EQ,C'SYSUDIRBLK=',OR,                       
                01,11,CH,EQ,C'SYSMEMBERS=',OR,                       
                01,09,CH,EQ,C'SYSALLOC=',OR,                         
                01,08,CH,EQ,C'SYSUSED=',OR,                         
                01,08,CH,EQ,C'SYSUNITS=',OR,                         
                01,11,CH,EQ,C'SYSEXTENTS=')     

  INREC IFTHEN=(WHEN=INIT,                                           
               PARSE=(%01=(STARTAFT=C'=',                           
                            ENDBEFR=C' ',                           
                             FIXLEN=44)),                           
             OVERLAY=(81:C'Z',%01))                                 
                                     
 
 SORT FIELDS=COPY
/*


Pass3 : see how the records are tagged with A,B,C

Code:

//SYSIN    DD *

  INCLUDE COND=(01,10,CH,EQ,C'SYSDSNAME=',OR,                       
                01,11,CH,EQ,C'SYSADIRBLK=',OR,                       
                01,11,CH,EQ,C'SYSUDIRBLK=',OR,                       
                01,11,CH,EQ,C'SYSMEMBERS=',OR,                       
                01,09,CH,EQ,C'SYSALLOC=',OR,                         
                01,08,CH,EQ,C'SYSUSED=',OR,                         
                01,08,CH,EQ,C'SYSUNITS=',OR,                         
                01,11,CH,EQ,C'SYSEXTENTS=')                         
                                                                     
  INREC IFTHEN=(WHEN=INIT,                                           
               PARSE=(%01=(STARTAFT=C'=',                           
                            ENDBEFR=C' ',                           
                             FIXLEN=44)),                           
             OVERLAY=(81:C'Z',%01)),                                 
                                                                     
        IFTHEN=(WHEN=INIT,                                           
             OVERLAY=(81:01,08,CHANGE=(1,C'SYSUSED=',C'C'),         
                              NOMATCH=(81,1),                       
                                                                     
                      81:01,09,CHANGE=(1,C'SYSUNITS=',C'B',         
                                         C'SYSALLOC=',C'C'),         
                              NOMATCH=(81,1),                       
                                                                     
                      81:01,10,CHANGE=(1,C'SYSDSNAME=',C'A'),       
                              NOMATCH=(81,1),                       
                                                                     
                      81:01,11,CHANGE=(1,C'SYSADIRBLK=',C'A',       
                                         C'SYSUDIRBLK=',C'A',       
                                         C'SYSMEMBERS=',C'B'),       
                              NOMATCH=(81,1)))   

 SORT FIELDS=COPY
/*



Pass4 : same as pass 3 but you would change SORT FIELDS=COPY to SORT FIELDS=(81,1,CH,A),EQUALS so that you can see how the records are sorted.


You can follow the same procedure till the end to understand how each statement is processed.
_________________
Kolusu
www.linkedin.com/in/kolusu
Back to top
View user's profile Send private message Send e-mail Visit poster's website
shekar123
Advanced


Joined: 22 Jul 2005
Posts: 528
Topics: 90
Location: Bangalore India

PostPosted: Tue May 28, 2024 12:08 am    Post subject: Reply with quote

Kolusu

Thanks a lot a lot and a lot. Again you have taken a lot of time in explaining each step in so detail. Great of you. This helps a lot.
_________________
Shekar
Grow Technically
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic   printer-friendly view    MVSFORUMS.com Forum Index -> Utilities All times are GMT - 5 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


MVSFORUMS
Powered by phpBB © 2001, 2005 phpBB Group