当前位置:  开发笔记 > 编程语言 > 正文

与DDNAME相关的PDS成员列表

如何解决《与DDNAME相关的PDS成员列表》经验,为你挑选了1个好方法。

如何使用COBOL获取PDS的成员列表(使用批处理作业中指定的DD名称)?可以动态处理使用DDNAME指定的PDS.因此,使用TCB可以获得给定DDNAME的PDS列表并处理指定的成员名称.

但是如何使用COBOL获取PDS的成员列表?我知道这可以使用REXX轻松实现.但我需要它在COBOL中或直接从COBOL调用.



1> Bill Woodger..:

如果你指定这个,用一个简单的SELECT(当然包括FILE STATUS),你就可以读取一个PDS目录.

   FD  INPUT-FILE 
       RECORDING MODE IS U 
       LABEL RECORDS ARE STANDARD. 
   01  INPUT-RECORD. 
       05  FILLER PIC X(256). 

在JCL中,您可以像这样指定DDName:

//ffffffff DD DISP=OLD,DSN=yourpdsname,
//            RECFM=U,LRECL=256

您也可以在COBOL程序中将RECORDING MODE更改为F,在JCL中将RECFM更改为F. 两者都可以工作(U(ndefined)或F(ixed)).

然后,您只需将该目录视为普通文件.

但是,每个目录块有多个条目,您需要了解能够使用这些数据的条目.

这是一个最初来自1982年左右的程序.在某些时候,我将最初的GO TO循环改为内联PERFORM,并根据IBM的VS COBOL II对1985年的COBOL Standard进行了其他更改.

EXPANDED-DIRECTORY是我为你粘贴的一本字帖.

使用上面定义的输入记录和EXPANDED-DIRECTORY调用程序.

然后,在每次CALL之后,您可以访问当前块中的成员(如果有的话).

   ID DIVISION. 
   PROGRAM-ID. OCDIRBLK. 
   DATA DIVISION. 
   WORKING-STORAGE SECTION. 
   01  LENGTH-UP-DIRECTORY          BINARY PIC 9(4). 
   01  LENGTH-OF-USER-DATA          BINARY PIC 9(4). 
   01  DIRECTORY-DATA-LENGTH        BINARY PIC 9(4). 
   01  HIGH-ORDER-BIT-VALUE         BINARY PIC 9(4) VALUE 128.
   01  BIT-ONE-VALUE                BINARY PIC 9(4) VALUE 64. 
   01  BIT-TWO-VALUE                BINARY PIC 9(4) VALUE 32. 
   01  USER-DATA-LENGTH             BINARY PIC 9(4). 
       88  NO-USER-HALFWORDS               VALUE ZERO. 
       88  SOME-USER-HALFWORDS             VALUE 1 THRU 31. 
       88  MEMBER-HAS-ONE-POINTER          VALUE 32 THRU 63. 
       88  MEMBER-HAS-TWO-POINTERS         VALUE 64 THRU 127. 
       88  MEMBER-IS-AN-ALIAS              VALUE 128 THRU 255.
   01  FILLER REDEFINES USER-DATA-LENGTH. 
       05  FILLER                          PIC X. 
       05  USER-DATA-BYTE                  PIC X. 
   LINKAGE SECTION. 
   01  INPUT-DIRECTORY. 
       05  I-D-LENGTH               BINARY PIC 9(4). 
           88  I-D-NO-MEMBERS              VALUE ZERO. 
       05  FILLER OCCURS 0 TO 252 TIMES 
           DEPENDING ON LENGTH-UP-DIRECTORY 
                                           PIC X. 
       05  I-D-MEMBER-NAME                 PIC X(8). 
           88 I-D-END-OF-BLOCK             VALUE HIGH-VALUES. 
       05  I-D-TRACK-ADDRESS               PIC XXX. 
       05  I-D-INDICATOR                   PIC X. 
       05  I-D-USER-DATA. 
           10  FILLER 
               OCCURS 0 TO 62 TIMES 
               DEPENDING ON 
               LENGTH-OF-USER-DATA. 
               15  FILLER                  PIC X. 
   01  EXPANDED-DIRECTORY. 
       05  E-D-NUMBER-OF-ENTRIES    BINARY PIC 9(4). 
       05  FILLER OCCURS 22 TIMES. 
           10  E-D-MEMBER-NAME             PIC X(8). 
           10  E-D-TRACK-ADDRESS           PIC X(3). 
           10  E-D-INDICATOR               PIC X(1). 
           10  E-D-ALIAS-FLAG              PIC X. 
               88  E-D-ALIAS               VALUE "Y". 
               88  E-D-ALIAS-NOT           VALUE "N". 
           10  E-D-NO-OF-POINTERS          PIC 9. 
           10  E-D-USER-DATA               PIC X(62). 
   PROCEDURE DIVISION               USING 
                                          INPUT-DIRECTORY 
                                          EXPANDED-DIRECTORY 
                                          . 

       IF I-D-NO-MEMBERS 
           MOVE ZERO                TO DIRECTORY-DATA-LENGTH 
       ELSE 
           SUBTRACT +2              FROM I-D-LENGTH 
             GIVING                 DIRECTORY-DATA-LENGTH 
       END-IF 

       MOVE ZERO                    TO E-D-NUMBER-OF-ENTRIES 
                                       LENGTH-UP-DIRECTORY 
       PERFORM UNTIL ( LENGTH-UP-DIRECTORY 
             NOT LESS THAN DIRECTORY-DATA-LENGTH ) 
                 OR ( I-D-END-OF-BLOCK ) 
           ADD 1                    TO E-D-NUMBER-OF-ENTRIES 
           MOVE I-D-MEMBER-NAME     TO E-D-MEMBER-NAME 
                                        ( E-D-NUMBER-OF-ENTRIES ) 
           MOVE I-D-TRACK-ADDRESS   TO E-D-TRACK-ADDRESS 
                                        ( E-D-NUMBER-OF-ENTRIES ) 
           MOVE I-D-INDICATOR       TO E-D-INDICATOR 
                                        ( E-D-NUMBER-OF-ENTRIES ) 
                                           USER-DATA-BYTE 
           MOVE ZERO                TO E-D-NO-OF-POINTERS 
                                        ( E-D-NUMBER-OF-ENTRIES ) 
           IF MEMBER-IS-AN-ALIAS 
               SET E-D-ALIAS ( E-D-NUMBER-OF-ENTRIES ) 
                                    TO TRUE 
               SUBTRACT HIGH-ORDER-BIT-VALUE 
                                    FROM USER-DATA-LENGTH 
           ELSE 
               SET E-D-ALIAS-NOT ( E-D-NUMBER-OF-ENTRIES ) 
                                    TO TRUE 
           END-IF 
           IF MEMBER-HAS-TWO-POINTERS 
               MOVE 2               TO E-D-NO-OF-POINTERS 
                                        ( E-D-NUMBER-OF-ENTRIES )
               SUBTRACT BIT-ONE-VALUE 
                                    FROM USER-DATA-LENGTH 
           END-IF 
           IF MEMBER-HAS-ONE-POINTER 
               ADD 1                TO E-D-NO-OF-POINTERS 
                                        ( E-D-NUMBER-OF-ENTRIES )
               SUBTRACT BIT-TWO-VALUE 
                                    FROM USER-DATA-LENGTH 
           END-IF 
           IF SOME-USER-HALFWORDS 
               MULTIPLY USER-DATA-LENGTH BY 2 
                GIVING              LENGTH-OF-USER-DATA 
               MOVE I-D-USER-DATA   TO E-D-USER-DATA 
                                        ( E-D-NUMBER-OF-ENTRIES )
               ADD LENGTH-OF-USER-DATA TO LENGTH-UP-DIRECTORY 
           ELSE 
               MOVE SPACE           TO E-D-USER-DATA 
                                        ( E-D-NUMBER-OF-ENTRIES )
               MOVE ZERO            TO LENGTH-OF-USER-DATA 
           END-IF 
           ADD 12                   TO LENGTH-UP-DIRECTORY 
       END-PERFORM 
       GOBACK 
       . 

这是一个程序读取PDS/PDSE目录,并使用OCDIRBLK作为包含/嵌套/嵌入程序的示例.

   IDENTIFICATION DIVISION. 
   PROGRAM-ID. STOB30. 
   ENVIRONMENT DIVISION. 
   INPUT-OUTPUT SECTION. 
   FILE-CONTROL. 

        SELECT INPUT-FILE ASSIGN TO PDSIND 
           FILE STATUS IS W-PDSIND-FILE-STATUS. 

   DATA DIVISION. 
   FILE SECTION. 
   FD         INPUT-FILE 
       RECORDING MODE IS U 
       RECORD IS VARYING FROM 1 TO 256 DEPENDING ON 
       W-RECORD-LENGTH 
       LABEL RECORDS ARE STANDARD. 
   01  INPUT-RECORD. 
       05  FILLER PIC X(252). 
   WORKING-STORAGE SECTION. 
   01  W-THIS-PROGRAM                      PIC X(9) VALUE 
                                                     "STOB30".
   01  W-WHEN-COMPILED                     PIC X(8)BX(8). 
   01  W-RECORD-LENGTH              BINARY PIC 9(8). 
   01  W-PDSIND-FILE-STATUS                PIC XX. 
       88  W-PDSIND-FILE-STATUS-OK         VALUE ZERO "10". 
       88  W-END-OF-INPUT-PDSIND           VALUE "10". 
   01  EXPANDED-DIRECTORY. 
       05  E-D-NUMBER-OF-ENTRIES    BINARY PIC 9(4). 
       05  FILLER 
           OCCURS 22 TIMES 
           INDEXED BY E-D-IND. 
           10  E-D-MEMBER-NAME             PIC X(8). 
           10  E-D-TRACK-ADDRESS           PIC X(3). 
           10  E-D-INDICATOR               PIC X(1). 
           10  E-D-ALIAS-FLAG              PIC X. 
               88  E-D-ALIAS               VALUE "Y". 
               88  E-D-ALIAS-NOT           VALUE "N". 
           10  E-D-NO-OF-POINTERS          PIC 9. 
           10  E-D-USER-DATA               PIC X(62). 
   PROCEDURE DIVISION. 
       PERFORM                      00-START-UP 
       PERFORM                      10-INTIAL-FILE-PROCESSING 
       PERFORM UNTIL W-END-OF-INPUT-PDSIND 
           CALL "OCDIRBLK"          USING INPUT-RECORD 
                                          EXPANDED-DIRECTORY 
           SET E-D-IND              TO 1 
           PERFORM E-D-NUMBER-OF-ENTRIES TIMES 
              DISPLAY 
                      E-D-MEMBER-NAME ( E-D-IND ) 
              SET E-D-IND           UP BY 1 
           END-PERFORM 
           PERFORM                  99A-READ-INPUT-FILE 
       END-PERFORM 
       PERFORM                      30-FINALISE-INPUT-PROCESSING
       GOBACK 
       . 
   00-START-UP. 
       MOVE WHEN-COMPILED           TO W-WHEN-COMPILED 
       DISPLAY 
               W-THIS-PROGRAM 
               " COMPILED ON " 
               W-WHEN-COMPILED 
       . 
   10-INTIAL-FILE-PROCESSING. 
       OPEN INPUT INPUT-FILE 
       IF NOT W-PDSIND-FILE-STATUS-OK 
           DISPLAY W-THIS-PROGRAM " DODGY PDSIND OPEN STATUS " 
                   ">" W-PDSIND-FILE-STATUS "<" 
           CALL "BBDUMP" 
       END-IF 

       PERFORM                      10A-PRIMING-READ 
       . 
   10A-PRIMING-READ. 
       PERFORM                      99A-READ-INPUT-FILE 
       . 
   30-FINALISE-INPUT-PROCESSING. 
       CLOSE INPUT-FILE 
       IF NOT W-PDSIND-FILE-STATUS-OK 
           DISPLAY W-THIS-PROGRAM " DODGY PDSIND CLOSE STATUS "
                   ">" W-PDSIND-FILE-STATUS "<" 
           CALL "BBDUMP" 
       END-IF 
       . 
   99A-READ-INPUT-FILE. 
       IF  W-END-OF-INPUT-PDSIND 
            DISPLAY "YOIKS" 
       END-IF 
       READ INPUT-FILE 
       IF NOT W-PDSIND-FILE-STATUS-OK 
           DISPLAY W-THIS-PROGRAM " DODGY PDSIND READ " 
                   ">" W-PDSIND-FILE-STATUS "<" 
           CALL "BBDUMP" 
       END-IF 
       . 
   IDENTIFICATION DIVISION. 
   PROGRAM-ID. OCDIRBLK. 
   DATA DIVISION. 
   WORKING-STORAGE SECTION. 
   01  LENGTH-UP-DIRECTORY          BINARY PIC 9(4). 
   01  LENGTH-OF-USER-DATA          BINARY PIC 9(4). 
   01  DIRECTORY-DATA-LENGTH        BINARY PIC 9(4). 
   01  HIGH-ORDER-BIT-VALUE         BINARY PIC 9(4) VALUE 128. 
   01  BIT-ONE-VALUE                BINARY PIC 9(4) VALUE 64. 
   01  BIT-TWO-VALUE                BINARY PIC 9(4) VALUE 32. 
   01  USER-DATA-LENGTH             BINARY PIC 9(4). 
       88  NO-USER-HALFWORDS               VALUE ZERO. 
       88  SOME-USER-HALFWORDS             VALUE 1 THRU 31. 
       88  MEMBER-HAS-ONE-POINTER          VALUE 32 THRU 63. 
       88  MEMBER-HAS-TWO-POINTERS         VALUE 64 THRU 127. 
       88  MEMBER-IS-AN-ALIAS              VALUE 128 THRU 255. 
   01  FILLER REDEFINES USER-DATA-LENGTH. 
       05  FILLER                          PIC X. 
       05  USER-DATA-BYTE                  PIC X. 
   LINKAGE SECTION. 
   01  INPUT-DIRECTORY. 
       05  I-D-LENGTH               BINARY PIC 9(4). 
           88  I-D-NO-MEMBERS              VALUE ZERO. 
       05  FILLER OCCURS 0 TO 252 TIMES 
           DEPENDING ON LENGTH-UP-DIRECTORY 
                                           PIC X. 
       05  I-D-MEMBER-NAME                 PIC X(8). 
           88 I-D-END-OF-BLOCK             VALUE HIGH-VALUES.
       05  I-D-TRACK-ADDRESS               PIC XXX. 
       05  I-D-INDICATOR                   PIC X. 
       05  I-D-USER-DATA. 
           10  FILLER 
               OCCURS 0 TO 62 TIMES 
               DEPENDING ON 
               LENGTH-OF-USER-DATA. 
               15  FILLER                  PIC X. 
   01  EXPANDED-DIRECTORY. 
       05  E-D-NUMBER-OF-ENTRIES    BINARY PIC 9(4). 
       05  FILLER OCCURS 22 TIMES. 
           10  E-D-MEMBER-NAME             PIC X(8). 
           10  E-D-TRACK-ADDRESS           PIC X(3). 
           10  E-D-INDICATOR               PIC X(1). 
           10  E-D-ALIAS-FLAG              PIC X. 
               88  E-D-ALIAS               VALUE "Y". 
               88  E-D-ALIAS-NOT           VALUE "N". 
           10  E-D-NO-OF-POINTERS          PIC 9. 
           10  E-D-USER-DATA               PIC X(62). 
   PROCEDURE DIVISION               USING 
                                          INPUT-DIRECTORY 
                                          EXPANDED-DIRECTORY 
                                          . 

       IF I-D-NO-MEMBERS 
           MOVE ZERO                TO DIRECTORY-DATA-LENGTH 
       ELSE 
           SUBTRACT +2              FROM I-D-LENGTH 
             GIVING                 DIRECTORY-DATA-LENGTH 
       END-IF 

       MOVE ZERO                    TO E-D-NUMBER-OF-ENTRIES 
                                       LENGTH-UP-DIRECTORY 
       PERFORM UNTIL ( LENGTH-UP-DIRECTORY 
             NOT LESS THAN DIRECTORY-DATA-LENGTH ) 
                 OR ( I-D-END-OF-BLOCK ) 
           ADD 1                    TO E-D-NUMBER-OF-ENTRIES 
           MOVE I-D-MEMBER-NAME     TO E-D-MEMBER-NAME 
                                        ( E-D-NUMBER-OF-ENTRIES )
           MOVE I-D-TRACK-ADDRESS   TO E-D-TRACK-ADDRESS 
                                        ( E-D-NUMBER-OF-ENTRIES )
           MOVE I-D-INDICATOR       TO E-D-INDICATOR 
                                        ( E-D-NUMBER-OF-ENTRIES )
                                           USER-DATA-BYTE 
           MOVE ZERO                TO E-D-NO-OF-POINTERS 
                                        ( E-D-NUMBER-OF-ENTRIES )
           IF MEMBER-IS-AN-ALIAS 
               SET E-D-ALIAS ( E-D-NUMBER-OF-ENTRIES ) 
                                    TO TRUE 
               SUBTRACT HIGH-ORDER-BIT-VALUE 
                                    FROM USER-DATA-LENGTH 
           ELSE 
               SET E-D-ALIAS-NOT ( E-D-NUMBER-OF-ENTRIES ) 
                                    TO TRUE 
           END-IF 
           IF MEMBER-HAS-TWO-POINTERS 
               MOVE 2               TO E-D-NO-OF-POINTERS 
                                        ( E-D-NUMBER-OF-ENTRIES )
               SUBTRACT BIT-ONE-VALUE 
                                    FROM USER-DATA-LENGTH 
           END-IF 
           IF MEMBER-HAS-ONE-POINTER 
               ADD 1                TO E-D-NO-OF-POINTERS 
                                        ( E-D-NUMBER-OF-ENTRIES )
               SUBTRACT BIT-TWO-VALUE 
                                    FROM USER-DATA-LENGTH 
           END-IF 
           IF SOME-USER-HALFWORDS 
               MULTIPLY USER-DATA-LENGTH BY 2 
                GIVING              LENGTH-OF-USER-DATA 
               MOVE I-D-USER-DATA   TO E-D-USER-DATA 
                                        ( E-D-NUMBER-OF-ENTRIES )
               ADD LENGTH-OF-USER-DATA TO LENGTH-UP-DIRECTORY 
           ELSE 
               MOVE SPACE           TO E-D-USER-DATA 
                                        ( E-D-NUMBER-OF-ENTRIES )
               MOVE ZERO            TO LENGTH-OF-USER-DATA 
           END-IF 
           ADD 12                   TO LENGTH-UP-DIRECTORY 
       END-PERFORM 
       GOBACK 
       . 
   END PROGRAM OCDIRBLK. 
   END PROGRAM STOB30. 

这是JCL的一个例子:

//LISTDIR EXEC PGM=STOB30,TIME=(,2)
//STEPLIB DD DSN=yours as necessary
//SYSOUT DD SYSOUT=* for the DISPLAY output 
//PDSIND DD DSN=your pds/pdse,
// DISP=SHR,LRECL=256,RECFM=U

注意,在设置JCL时我没有包括RECFM = U(意外).使用RECFM = FB,LRECL = 80 PDS和RECFM = U PDSE进行清洁以产生正确的结果.

这让我感到惊讶.你的旅费可能会改变.

推荐阅读
郑谊099_448
这个屌丝很懒,什么也没留下!
DevBox开发工具箱 | 专业的在线开发工具网站    京公网安备 11010802040832号  |  京ICP备19059560号-6
Copyright © 1998 - 2020 DevBox.CN. All Rights Reserved devBox.cn 开发工具箱 版权所有