Page 1 of 1

Reading concatenated PDSE using QSAM

PostPosted: Sat Mar 05, 2016 7:05 am
by pintu1228
Hi everyone, was wondering if someone can help me figure out a better than the way I already did to do the following:

1. Read a block, use XSNAP to print it, all 256 bytes.
2. Skip two bytes to find the first name
3. After the name, skip 3 bytes (the TTR value) and read the C value (1 byte).
4. The last 5 bits of the C byte gives us the length of the user data field in halfwords. Use this to advance in the block to the next name: the start of the first name + 4 bytes for TTR and C + the length of the user data field.

I have done this a different way (which works) but I would like to know how I can make it better if possible.



//STEP1 EXEC PROC=ASMACLG                                              
//C.SYSLIB DD DSN=SYS1.MACLIB,DISP=SHR                                    
//         DD DSN=KC02293.SYS2.MACLIB,DISP=SHR                            
//C.SYSIN DD *                                                            
MAIN     CSECT                                                            
         PRINT NOGEN                              
         STM   14,12,12(13)                          
         LR    12,15                              
         USING MAIN,12                                
         LA    14,MAINSAVE                          
         ST    13,4(0,14)                              
         ST    14,8(0,13)                                  
         LR    13,14                                
*                                                                          
         OPEN  (PDDCB,(INPUT))                              
         LTR   15,15                              
         BZ    OPEN10K                      
         ABEND 333,DUMP                    
*                                                                          
OPEN10K  OPEN  (OUTDCB,(OUTPUT))                          
         LTR   15,15                              
         BZ    OPEN20K                      
         ABEND 444,DUMP                    
*                                                                          
OPEN20K  DS    0H                                                          
*                                                                          
OUTLOOP  GET   PDDCB,PDSBUF                                                
         CLI   EOFFLAG2,C'Y'                              
*                                                                          
         BE    ENDLOOP                            
         PUT   OUTDCB,OUTHDR                                              
         XSNAP STORAGE=(PDSBUF,PDSBUF+256),T=NOREGS                        
         LA    2,PDSBUF                                                    
         LA    2,2(0,2)                                                    
INLOOP   DS    0H                                                          
         CLC   0(8,2),=8X'FF'                                              
         BZ    DONE                                                        
         MVC   RECORD(8),0(2)                                              
         PUT   OUTDCB,PRINTLN                                              
         IC    4,11(2)                                                    
         SLA   4,27(0)                                                    
         SRA   4,26(0)                                                    
         LA    2,12(4,2)                                                  
         B     INLOOP                                                      
DONE     PUT   OUTDCB,EMPTY                                                
         B     OUTLOOP                                                    
ENDLOOP  DC    0H                                                          
*                                                                          
         CLOSE (PDDCB)                                                    
         LTR   15,15                                                      
         BZ    CLOSE10K                                                    
         ABEND 666,DUMP                                                    
*                                                                          
CLOSE10K CLOSE (OUTDCB)                                                    
         LTR   15,15                                                      
         BZ    CLOSE20K                                                    
         ABEND 777,DUMP                                                    
*                                                                          
CLOSE20K DS    0H                                                          
         SR    15,15                                                      
*                                                                          
         L     13,4(0,13)                            
         LM    14,12,12(13)                              
         BR    14                                                          
         LTORG                                                            
*                                                                          
***************************************************************            
MAINSAVE DS    18F'-1'                 MAINSAVE AREA                      
PRINTLN  DC    C' '                    RECORD TITLE                        
RECORD   DS    CL79' '                                                    
OUTHDR   DC    CL80' DATA MEMBERS STORED IN PDSE'                          
EMPTY    DC    80C' '                                                      
*                                                                          
PDSBUF   DS    CL256                                                      
*                                                                          
PDDCB    DCB   DDNAME=INLIB,                                           X  
               DEVD=DA,                                                X  
               DSORG=PS,                                               X  
               MACRF=GM,                                               X  
               RECFM=F,                                                X  
               LRECL=256,                                              X  
               BLKSIZE=256,                                            X  
               EODAD=PDSEOF                                                
*                                                                          
EOFFLAG2 DC    C'N'                                                        
*                                                                          
PDSEOF   MVI   EOFFLAG2,C'Y'                                              
         BR    14                                                          
*                                                                          
OUTDCB  DCB    DDNAME=OUTPUT,                                          X  
               DEVD=DA,                                                X  
               DSORG=PS,                                               X  
               MACRF=PM,                                               X  
               LRECL=80,                                               X  
               RECFM=FB                                                    
*                                                                          
        END    MAIN                                                        
/*                                                                        
//L.SYSLIB DD DSN=KC02293.SYS2.CALLIB,DISP=SHR                            
//G.OUTPUT DD SYSOUT=*                                                    
//G.XSNAPOUT DD SYSOUT=*                                                  
//G.XPRNT DD SYSOUT=*                                                      
//*                                                                        
//*                                                                        
//G.INDATA DD DSN=KC02314.SPRING16.CSCI641.HW3DATA,DISP=SHR                
//G.INLIB  DD DSN=KC02314.SPRING16.CSCI641.HW3LIBA,DISP=SHR                
//         DD DSN=KC02314.SPRING16.CSCI641.HW3LIBB,DISP=SHR                

 



The code in question I want modify if possible is:


OUTLOOP  GET   PDDCB,PDSBUF                                                
         CLI   EOFFLAG2,C'Y'                              
*                                                                          
         BE    ENDLOOP                            
         PUT   OUTDCB,OUTHDR                                              
         XSNAP STORAGE=(PDSBUF,PDSBUF+256),T=NOREGS                        
         LA    2,PDSBUF                                                    
         LA    2,2(0,2)                                                    
INLOOP   DS    0H                                                          
         CLC   0(8,2),=8X'FF'                                              
         BZ    DONE                                                        
         MVC   RECORD(8),0(2)                                              
         PUT   OUTDCB,PRINTLN                                              
         IC    4,11(2)                                                    
         SLA   4,27(0)                                                    
         SRA   4,26(0)                                                    
         LA    2,12(4,2)                                                  
         B     INLOOP                                                      
DONE     PUT   OUTDCB,EMPTY                                                
         B     OUTLOOP  
 



Any help would be great.

Re: Reading concatenated PDSE using QSAM

PostPosted: Sat Mar 05, 2016 8:52 am
by steve-myers
Your code to space through a directory block is clumsy, but it should work.

Your title implied you want to skip to the next data set in the concatenation after you have read through a directory. I wrote this up to test. I strongly suggest you understand the code to process a directory block. I've used this code or minor variation for more than 40 years. After you get the logical EOF you use FEOV to start the next data set in the concatenation.
         OPEN  (DIRDCB,INPUT)      Open the directory
DIR0100  GET   DIRDCB              Read a directory block
         LH    5,0(,1)             Load used bytes in the block
         AR    5,1                 Compute address of end of data
         BCTR  5,0                 Compute address of last used byte
         LA    3,2(,1)             Compute address of first entry
DIR0200  CLC   =FL8'-1',0(3)       Logical EOF?
         BE    DIR0400             Yes
         ...                       Process the directory entry
DIR0300  IC    4,11(,3)            Load PDS2INDC
         N     4,=A(X'1F')         Isolate half words in user data
         LA    4,12(4,4)           Compute length of the entry
         BXLE  3,4,DIR0200         Compute address of next entry
         B     DIR0100             Go read the next directory block
DIR0400  FEOV  DIRDCB              Skip to next data set
         B     DIR0100             Go read its directory
DIR0500  CLOSE DIRDCB
         ...
DIRDCB   DCB   DSORG=PS,MACRF=GL,DDNAME=PDS,EODAD=DIR0500,             >
               RECFM=F,LRECL=256,BLKSIZE=256
FL8'-1' assembles as X'FFFFFFFF'

Re: Reading concatenated PDSE using QSAM

PostPosted: Sat Mar 05, 2016 10:22 am
by pintu1228
Thanks, I'm trying to implement a variation of the above code into my code, but I don't get any print out.

Whats going on with my code, did I mess something up in my understanding?


//STEP1 EXEC PROC=ASMACLG                                              
//C.SYSLIB DD DSN=SYS1.MACLIB,DISP=SHR                                    
//         DD DSN=KC02293.SYS2.MACLIB,DISP=SHR                            
//C.SYSIN DD *                                                            
MAIN     CSECT                                                            
         PRINT NOGEN                              
         STM   14,12,12(13)                          
         LR    12,15                              
         USING MAIN,12                                
         LA    14,MAINSAVE                          
         ST    13,4(0,14)                              
         ST    14,8(0,13)                                  
         LR    13,14                                
*                                                                          
         OPEN  (PDDCB,(INPUT))                              
         LTR   15,15                              
         BZ    OPEN10K                      
         ABEND 333,DUMP                    
*                                                                          
OPEN10K  OPEN  (OUTDCB,(OUTPUT))                          
         LTR   15,15                              
         BZ    OPEN20K                      
         ABEND 444,DUMP                    
*                                                                          
OPEN20K  DS    0H                                                          
*                                                                          
OUTLOOP  GET   PDDCB,PDSBUF                  
         CLI   EOFFLAG2,C'Y'                          
*                                                                      
         BE    ENDLOOP                        
         PUT   OUTDCB,OUTHDR                    
*                                                                      
         XSNAP STORAGE=(PDSBUF,PDSBUF+256),T=NOREGS                    
*                                                                      
         LH    5,0(,1)                                                  
         AR    5,1                                                      
         BCTR  5,0                                                      
         LA    3,2(,1)                                                  
INLOOP   DS    0H                                                      
         CLC   =FL8'-1',0(3)                                            
         BZ    DIR0400                                                  
*                                                                      
*        LA    2,PDSBUF                                                
*        LA    2,2(0,2)                                                
*        CLC   0(8,2),=8X'FF'                                          
*        BZ    DONE                                                    
         MVC   RECORD(8),0(2)                                          
         PUT   OUTDCB,PRINTLN                                          
         IC    4,11(,3)                                                
         N     4,=A(X'1F')                                              
         LA    4,12(4,4)                                                
         BXLE  3,4,INLOOP                                              
*        IC    4,11(2)                                                  
*        SLA   4,27(0)                                                  
*        SRA   4,26(0)                                                  
*        LA    2,12(4,2)                                                
         B     INLOOP                                                  
DONE     PUT   OUTDCB,EMPTY                                            
         B     OUTLOOP                                                  
DIR0400  FEOV  PDDCB                                                    
ENDLOOP  DC    0H                                                                                                  
*                                                                          
         CLOSE (PDDCB)                                                    
         LTR   15,15                                                      
         BZ    CLOSE10K                                                    
         ABEND 666,DUMP                                                    
*                                                                          
CLOSE10K CLOSE (OUTDCB)                                                    
         LTR   15,15                                                      
         BZ    CLOSE20K                                                    
         ABEND 777,DUMP                                                    
*                                                                          
CLOSE20K DS    0H                                                          
         SR    15,15                                                      
*                                                                          
         L     13,4(0,13)                            
         LM    14,12,12(13)                              
         BR    14                                                          
         LTORG                                                            
*                                                                          
***************************************************************            
MAINSAVE DS    18F'-1'                 MAINSAVE AREA                      
PRINTLN  DC    C' '                    RECORD TITLE                        
RECORD   DS    CL79' '                                                    
OUTHDR   DC    CL80' DATA MEMBERS STORED IN PDSE'                          
EMPTY    DC    80C' '                                                      
*                                                                          
PDSBUF   DS    CL256                                                      
*                                                                          
PDDCB    DCB   DDNAME=INLIB,                                           X  
               DEVD=DA,                                                X  
               DSORG=PS,                                               X  
               MACRF=GM,                                               X  
               RECFM=F,                                                X  
               LRECL=256,                                              X  
               BLKSIZE=256,                                            X  
               EODAD=PDSEOF                                                
*                                                                          
EOFFLAG2 DC    C'N'                                                        
*                                                                          
PDSEOF   MVI   EOFFLAG2,C'Y'                                              
         BR    14                                                          
*                                                                          
OUTDCB  DCB    DDNAME=OUTPUT,                                          X  
               DEVD=DA,                                                X  
               DSORG=PS,                                               X  
               MACRF=PM,                                               X  
               LRECL=80,                                               X  
               RECFM=FB                                                    
*                                                                          
        END    MAIN                                                        
/*                                                                        
//L.SYSLIB DD DSN=KC02293.SYS2.CALLIB,DISP=SHR                            
//G.OUTPUT DD SYSOUT=*                                                    
//G.XSNAPOUT DD SYSOUT=*                                                  
//G.XPRNT DD SYSOUT=*                                                      
//*                                                                        
//*                                                                        
//G.INDATA DD DSN=KC02314.SPRING16.CSCI641.HW3DATA,DISP=SHR                
//G.INLIB  DD DSN=KC02314.SPRING16.CSCI641.HW3LIBA,DISP=SHR                
//         DD DSN=KC02314.SPRING16.CSCI641.HW3LIBB,DISP=SHR                

 

Re: Reading concatenated PDSE using QSAM

PostPosted: Sat Mar 05, 2016 10:34 am
by pintu1228
The only thing it prints int ALPHA repeating itself and not the rest of the output, seems like it doesn't print other members in the PDSEs.

Re: Reading concatenated PDSE using QSAM

PostPosted: Sat Mar 05, 2016 11:07 am
by steve-myers
Look at what PDSEOF does. It is not always correct. Where did you get that idea? The B after the BXLE is incorrect.

Re: Reading concatenated PDSE using QSAM

PostPosted: Sat Mar 05, 2016 11:43 am
by pintu1228
Thanks for your help, figured out a simple mistake on my part.

Re: Reading concatenated PDSE using QSAM

PostPosted: Sat Mar 05, 2016 5:08 pm
by steve-myers
You have two mistakes. Did you correct both of them? After I wrote my last post I went to the manuals. "DFSMS Using Data Sets" clearly states your PDSEOF code will not work if FEOV detects an attempt to switch after the last data set in the concatenation.