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

Get system related infos in PL/I


IBM Mainframe Forums -> PL/I & Assembler
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
dick scherrer

Moderator Emeritus


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

PostPosted: Tue Mar 10, 2009 6:01 am
Reply with quote

Hello and welcome to this forum,

Thank you for the code icon_smile.gif

d
Back to top
View user's profile Send private message
bauer

New User


Joined: 03 Mar 2009
Posts: 28
Location: germany

PostPosted: Tue Mar 10, 2009 12:47 pm
Reply with quote

Try this:


Code:


 TEST:                                                                         
 PROC  OPTIONS(MAIN) REORDER  ;                                                 
                                                                               
                                                                               
    /* Some information in this structure is only avialable if                 
       the jcl provides the DCB parameter or the associated                     
       dataset is open                                                         
    */                                                                         
    DEFINE STRUCTURE                                                           
       1 tDSInfo                                                               
         ,  2 DD          CHAR(8)        /* DD Name from JCL */                 
         ,  2 DSN         CHAR(44)       /* Datasetname */                     
         ,  2 MEMBER      CHAR(8)        /* Membername */                       
         ,  2 DISP        CHAR(3)        /* Disposition */                     
         ,  2 DSORG       CHAR(2)        /* Datasetorganisation */             
         ,  2 RECFM       CHAR(3)        /* Recordformat */                     
         ,  2 LRECL       BIN FIXED(15)  /* Logical Recordlength */             
         ,  2 RESERVED    CHAR(442)      /* For future use */                   
         ;                                                                     
                                                                               
                                                                               
                                                                               
 MyCallback:                                                                   
    PROC(pDSInfo,pUserData) RETURNS(BIT(1));                                   
    DCL pDSInfo   PTR ;                                                         
    DCL pUSerData PTR ;                                                         
    DCL 1 DSInfo TYPE tDSInfo BASED(pDSInfo) ;                                 
    PUT SKIP EDIT('DSInfo.DD     = ' ||      DSInfo.DD     ) (A);               
    PUT SKIP EDIT('DSInfo.DSN    = ' ||      DSInfo.DSN   ) (A);               
    PUT SKIP EDIT('DSInfo.Member = ' ||      DSInfo.Member ) (A);               
    PUT SKIP EDIT('DSInfo.Disp   = ' ||      DSInfo.Disp   ) (A);               
    PUT SKIP EDIT('DSInfo.DSORG  = ' ||      DSInfo.DSORG  ) (A);               
    PUT SKIP EDIT('DSInfo.RECFM  = ' ||      DSInfo.RECFM  ) (A);               
    PUT SKIP EDIT('DSInfo.LRECL  = ' || CHAR(DSInfo.LRECL )) (A);               
    PUT SKIP EDIT('')(A);                                                       
    PUT SKIP EDIT('')(A);                                                       
    RETURN('1'B) ;    /* Continue Processing */                                 
    END;                                                                       
                                                                               
                                                                               
 CALL DSInfo(MyCallback,NULL());   
                                                                               
                                                                               
                                                                               
 DSInfo:                                                                       
    /* Loops over the MVS Control blocks to get information                     
       for all DD names associated with the current job.                       
       For each DD Name the filenames and some other                           
       data is fetched from then JFCB (Job File                                 
       Control Block).                                                         
                                                                               
       A callback function is invoked for each file.                           
       The callbackfunction is passed from the calling module.                 
       */                                                                       
                                                                               
    PROC(pEntry,pUserdata);                                                     
                                                                               
    DCL pEntry  ENTRY                                                           
          (  PTR    /* Data for each DDName / Dataset */                       
           , PTR    /* Userdata  */                                             
          ) RETURNS(BIT(1)) VARIABLE ;                                         
                                                                               
    DCL pUserData  PTR ; /* any data passed from the calling modul             
                            an routed to the callback function */               
                                                                               
    DCL 1 DSInfo TYPE tDSInfo AUTO;                                             
                                                                               
    DCL pPSA            PTR  AUTO INIT(SYSNULL());                             
    DCL 1 PSA           BASED(pPSA)  /* Prefixed Save Area */                   
          , 2 FILLER1   CHAR(540)                                               
          , 2 pTCB      PTR                                                     
          ;                                                                     
    DCL 1 TCB           BASED(pTCB)  /* Task Control Block */                   
          , 2 FILLER1   CHAR(12)                                               
          , 2 pTIOT     PTR                                                     
          ;                                                                     
                                                                               
   DCL pTIOTSEG PTR ;                                                           
   DCL 1 TIOTSEG      BASED (pTIOTSEG)   /* Task Input/Output Table */         
        ,2 TIOELNGH   BIN FIXED(7)       /* Length of this entry */             
        ,2 FILLER2    CHAR(3)                                                   
        ,2 TIOEDDNM   CHAR(8)            /* DD Name of Dateset */               
        ,2 TIOEJFCB   CHAR(3)            /* JFCB per SWAREQ MACRO */           
        ;                                                                       
                                                                               
    DCL pJFCB PTR;                                                             
    DCL 1 JFCB        BASED(pJFCB)       /* Job File Control Block */           
          ,2 JFCBDSNM CHAR(44)           /* DSN Name */                         
          ,2 JFCBELNM CHAR(8)            /* Member */                           
          ,2 FILLER1  CHAR(35)                                                 
          ,2 JFCBIND2 CHAR(1)            /* Indicator2 */                       
          ,2 FILLER2  CHAR(10)                                                 
          ,2 JFCDSRG1 CHAR(1)            /* DSORG, Byte 1*/                     
          ,2 FILLER3  CHAR(1)                                                   
          ,2 JFCRECFM CHAR(1)            /* RECFM */                           
          ,2 FILLER4  CHAR(3)                                                   
          ,2 JFCLRECL BIN FIXED(15)      /* LRECL */                           
          ;                                                                     
                                                                               
    DCL Continue BIT(1) AUTO INIT('1'B) ;                                       
                                                                               
   /* Build address of first TIOT Segement by skipping */                       
   /* bytes for jobname, stepname */                                           
   pTIOTSEG = TCB.PTIOT + 24 ;                                                 
                                                                               
   /* Loop over all TIOT Segments */                                           
   DO WHILE ((TIOTSEG.TIOELNGH ^= 0) & (CONTINUE));                             
                                                                               
      /* Convert SWA virtual address token to JFCB address */                   
      pJFCB = SWAREQ(TIOEJFCB) ;                                               
                                                                               
      /* extract/prepare data from controlblocks to pass                       
         to the callback function for the calling modul */                     
      CALL PLIFILL(ADDR(DSInfo),'00'X,CSTG(DSInfo));/* Fill with '0'x */       
      DSInfo.DD      = TIOTSEG.TIOEDDNM ;                                       
      DSInfo.DSN     = JFCB.JFCBDSNM    ;                                       
      DSInfo.Member  = JFCB.JFCBELNM    ;                                       
      SELECT (JFCB.JFCBIND2) ;                                                 
         WHEN('40'x, '41'x) DSInfo.DISP = 'OLD' ;                               
         WHEN('C0'x, 'C1'x) DSInfo.DISP = 'NEW' ;                               
         WHEN('80'x, '81'x) DSInfo.DISP = 'MOD' ;                               
         WHEN('48'x, '49'x) DSInfo.DISP = 'SHR' ;                               
         OTHER              DSInfo.DISP = ''    ;                               
      END;                                                                     
      SELECT (JFCB.JFCDSRG1) ;                                                 
         WHEN('80'x, '81'x) DSInfo.DSORG = 'IS' ;                               
         WHEN('40'x, '41'x) DSInfo.DSORG = 'PS' ;                               
         WHEN('20'x, '21'x) DSInfo.DSORG = 'DA' ;                               
         WHEN('02'x, '03'x) DSInfo.DSORG = 'PO' ;                               
         OTHER              DSInfo.DSORG = ''   ;                               
      END;                                                                     
      SELECT (JFCB.JFCRECFM) ;                                                 
         WHEN('C0'x) DSInfo.RECFM = 'U'  ;                                     
         WHEN('80'x) DSInfo.RECFM = 'F'  ;                                     
         WHEN('40'x) DSInfo.RECFM = 'V'  ;                                     
         WHEN('90'x) DSInfo.RECFM = 'FB' ;                                     
         WHEN('50'x) DSInfo.RECFM = 'VB' ;                                     
         OTHER       DSInfo.RECFM = ''   ;                                     
      END;                                                                     
      DSInfo.LRECL   = JFCB.JFCLRECL  ;                                         
                                                                               
      /* Pass data to callback function in calling module */                   
      Continue = pEntry(ADDR(DSInfo),pUserdata);                               
                                                                               
      /* Get next TIOTSEG */                                                   
      pTIOTSEG = pTIOTSEG + TIOTSEG.TIOELNGH ;                                 
                                                                               
   END ;                                                                       
                                                                               
                                                                               
 SWAREQ:                                                                       
    /* Convert SWA virtual address token to 31 Bit address */                   
    /* This submodule replaces assembler macro SWAREQ */                       
    PROC(SWA) RETURNS(PTR);                                                     
                                                                               
    DCL SWA CHAR(3) ;  /* parameter SWA Virtual address token */               
                                                                               
    DCL 1 SVAS AUTO                                                             
          ,2 SVA1  CHAR(1) INIT(LOW(1))                                         
          ,2 SVA2  CHAR(3) INIT(SWA)                                           
          ;                                                                     
    DCL SVAP PTR BASED(ADDR(SVAS)) ;                                           
    DCL SVAB BIN FIXED(31) BASED(ADDR(SVAS));                                   
                                                                               
    DCL pPSA            PTR  AUTO INIT(SYSNULL());                             
    DCL 1 PSA           BASED(pPSA)  /* Prefixed Save Area */                   
          , 2 FILLER1   CHAR(540)                                               
          , 2 pTCB      PTR                                                     
          ;                                                                     
    DCL 1 TCB           BASED(pTCB) /* Task Control Block */                   
          , 2 FILLER1   CHAR(180)                                               
          , 2 pJSCB     PTR                                                     
          ;                                                                     
    DCL 1 JSCB          BASED(pJSCB) /* Job / Step Control Block */             
          ,2 FILLER1    CHAR(244)                                               
          ,2 pJSCBQMPI  PTR                                                     
          ;                                                                     
    DCL 1 QMPA          BASED(pJSCBQMPI) /* Queue Manager                       
                                            Parameter Area */                   
          ,2 Filler     CHAR(24)                                               
          ,2 QMAT       BIN FIXED(31)                                           
          ;                                                                     
                                                                               
    DCL l_QMAT BIN FIXED(31) AUTO NOINIT;                                       
                                                                               
                                                                               
    IF MOD(SVAB,2) = 1 THEN DO; /* 24 or 31 Bit address */                     
       l_QMAT = QMPA.QMAT ;                                                     
       DO WHILE(SVAB > 65536) ;                                                 
          l_QMAT = l_QMAT + 12 ;                                               
          SVAB = SVAB - 65536;                                                 
       END;                                                                     
       SVAB = SVAB + 1 + 16 + l_QMAT ;                                         
    END;                                                                       
    ELSE DO;                                                                   
       SVAB = SVAB + 16 ;                                                       
    END ;                                                                       
                                                                               
    RETURN(SVAP);    /* return 31 Bit address */                               
                                                                               
    END ; /* SWAREQ procedure */                                               
                                                                               
    END ; /* DSInfo */                                                         
                                                                               
                                                                               
                                                                               
 END;                                                                           

Back to top
View user's profile Send private message
PeD

Active User


Joined: 26 Nov 2005
Posts: 459
Location: Belgium

PostPosted: Tue Mar 10, 2009 1:48 pm
Reply with quote

Brillant!

For my coding here , Ein Sonnenschein zwischen den Wolken !!

Thanks

Pierre
Back to top
View user's profile Send private message
bauer

New User


Joined: 03 Mar 2009
Posts: 28
Location: germany

PostPosted: Wed Mar 11, 2009 12:53 pm
Reply with quote

Thank you. icon_biggrin.gif icon_biggrin.gif
Back to top
View user's profile Send private message
parsesource

New User


Joined: 06 Feb 2006
Posts: 97

PostPosted: Wed Mar 11, 2009 1:52 pm
Reply with quote

great stuff, i´ll try. thank you!


icon_biggrin.gif
Back to top
View user's profile Send private message
parsesource

New User


Joined: 06 Feb 2006
Posts: 97

PostPosted: Wed Mar 11, 2009 10:33 pm
Reply with quote

your program works great

i´ve added the following statement to a job-step

//STDERR DD PATH='/tmp/ASDFASDFASDFASDF.STDERR',
// PATHOPTS=(OWRONLY,OCREAT,OTRUNC),
// PATHMODE=SIRWXU

the program returns

DSInfo.DD = STDERR
DSInfo.DSN = ...PATH=.SPECIFIED...

so as an exercise to the reader, enhance the program to return unix paths too. i´ll try to get a working solution using bpxwdyn icon_biggrin.gif
Back to top
View user's profile Send private message
bauer

New User


Joined: 03 Mar 2009
Posts: 28
Location: germany

PostPosted: Wed Mar 11, 2009 10:46 pm
Reply with quote

Quote:
so as an exercise to the reader, enhance the program to return unix paths too


Just do it ! icon_biggrin.gif icon_biggrin.gif
Back to top
View user's profile Send private message
PeD

Active User


Joined: 26 Nov 2005
Posts: 459
Location: Belgium

PostPosted: Sun Mar 15, 2009 2:28 pm
Reply with quote

Aie, Eine Kleine Wolk
Bauer,

When I executed this program in a jobclass SWA=BELOW, it is fine.
When I ran the program in a jobclass SWA=ABOVE, the program did not give me back the correct SVAB.

As an example

Before starting the SAWREQ routine, display of SVAB is ‘00006F’x for the first file, “0000EF”x for the second, ‘00011F’x for the third, etc With this value the loop
Code:
DO WHILE(SVAB > 65536);
is never activated and the value of SVAB returned is
Code:
SVAB = SVAB +1 +16 +l_QMAT
which is decimal 2136813696 ( 111 + 1 + 16 + 2136813568 ) which seems to be not correct because they are junk characters and not the DSN, the DD name, etc.
Code:
DSN = '5CE2E8000000B01D00007F0000007F5CE3A8000000B02900008F....'x

I spent a part of the night on that. So maybe I need some rest icon_confused.gif icon_confused.gif …..

An idea? Did I missed somethning?

Thanks

Pierre
Back to top
View user's profile Send private message
bauer

New User


Joined: 03 Mar 2009
Posts: 28
Location: germany

PostPosted: Tue Mar 17, 2009 12:44 pm
Reply with quote

Pierre,

the conversion of the three byte address token TIOEJFCB using routine SWAREQ seems to be wrong in case of 31 bit address. I have to check this.

bauer
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 -> PL/I & Assembler Goto page 1, 2  Next

 


Similar Topics
Topic Forum Replies
No new posts Sysplex System won't IPL at DR site I... All Other Mainframe Topics 2
No new posts How to delete a user's alias from the... JCL & VSAM 11
No new posts Insert system time/date (timestamp) u... DFSORT/ICETOOL 5
No new posts JCL Dynamic System Symbols JCL & VSAM 3
No new posts the system or user abend SF0F R=NULL COBOL Programming 0
Search our Forums:

Back to Top