Topic
  • No replies
LuisA.
LuisA.
5 Posts

Pinned topic Knowing the Data Set Name in a Cobol Program

‏2010-10-04T17:33:28Z |
Is possible to know the DSN "name" written in the JCL that is executing a program that manage a QSAM file for reading or writing that file ?.

Is there some Language environment Callable Service, or some special function to get it?.

If not, is possible to arrive to some Z/os Data Area through the CVT ?. If it is possible, where can i get some information about this data areas to navigate and find what i'm looking for ?

Thanks in advance for your replies.
Updated on 2011-10-18T15:12:39Z at 2011-10-18T15:12:39Z by Ismael_Batista
  • wmklein
    wmklein
    79 Posts

    Re: Knowing the Data Set Name in a Cobol Program

    ‏2010-10-04T18:04:27Z  
    To the best of my knowledge, there is no LE callable service to do this.

    I am NOT good at z/OS control blocks, but there is a COBOL program (on the web) to get to MVS control blocks. Check out

    http://gsf-soft.com/Freeware/COB2JOB.shtml

    and see if that gets you to some control block that you think will let you find this information.

    You may also want to look at the "thread" of information (with COBOL examples) at:

    http://ibmmainframes.com/about6604.html
  • PRH
    PRH
    2 Posts

    Re: Knowing the Data Set Name in a Cobol Program

    ‏2010-10-05T01:45:26Z  
    Try the following :
    
    DD2DSN   TITLE 
    '- RETRIEVE DSN GIVEN A DD NAME' *********************************************************************** * * * *       THIS PROGRAM ACCEPTS THREE PARAMETERS AS FOLLOWS * *             CALL 
    'DD2DSN' USING DD-NAME DS-NAME MEMBER * *       WHERE * *             01  DD-NAME   PIC X(8).     (INPUT) *             01  DS-NAME   PIC X(44).    (OUTPUT) *             01  MEMBER    PIC X(8).     (OUTPUT) * *        THE MEMBER NAME MAY ALSO CONTAIN A RELATIVE GDG NUMBER. * *       THE RETURN CODE IS PASSED UP FROM THE RDJFCB MACRO. * *  ATTRIBUTES: REENTRANT * *********************************************************************** * DD2DSN   RMODE 31 DD2DSN   AMODE 31 DD2DSN   CSECT * *********************************************************************** *              LINKAGE *********************************************************************** * STM   R14,R12,12(R13)            SAVE REGISTERS IN CALLER AREA LR    R11,R15 USING DD2DSN,R11                 USE ENTRY POINT AS BASE L     R2,0(R1)                   GET DDNAME ADDRESS L     R3,4(R1)                   GET DSNAME ADDRESS L     R4,8(R1)                   GET MEMBER ADDRESS GETMAIN RU,LV=DATALEN,LOC=BELOW  GET SOME STORAGE FOR WORKAREA LR    R10,R1                     SAVE ADDR OF RETURNED STORAGE USING WORKAREA,R10               AND USE IT FOR OUR WORKAREA * *********************************************************************** *              PROCESS REQUEST *********************************************************************** * LA    R12,DCB                 ADDRESS DCB USING IHADCB,R12              ESTABLISH BASE FOR DCB * MVC   0(DCBLEN,R12),DCBMODEL  INITIALISE DCB MVC   DCBDDNAM,0(R2)          SET DDNAME IN DCB LA    R5,JFCBXLST             GET EXITLIST ADDRESS STCM  R5,7,DCBEXLSA           STORE IT IN DCB MVI   JFCBCODE,X
    '87'          SET EXIT CODE LA    R5,JFCBAREA             GET JFCB AREA ADDRS STCM  R5,7,JFCBADDR           AND STORE IT IN EXIT LIST USING INFMJFCB,R5             ESTABLISH  ADRESSABILITY OF AREA MVC   XRDJFCB,LRDJFCB         INITIALISE RDJFCB PARAM LIST RDJFCB ((R12)),MF=(E,XRDJFCB) GET JFCB LTR   R15,R15                 OK? BNZ   RETURN                  NOPE MVC   0(44,R3),JFCBDSNM       RETURN DSN MVC   0(8,R4),JFCBELNM        RETURN MEMBER OR RELATIVE GDG *********************************************************************** *              RETURN TO CALLER *********************************************************************** * RETURN   LR    R5,R15 FREEMAIN RU,LV=DATALEN,A=(R10) FREE OUR STORAGE LR    R15,R5                   SET RETURN CODE LM    R0,R12,20(R13)           RESTORE REGISTERS  0-12 L     R14,12(R13)              RESTORE LINK REGISTER BSM   R0,R14                   GO BACK * *********************************************************************** *              WORK AREA *********************************************************************** * DS    0D DCBSTART EQU   * * TEMPLATE DCB USED TO INITIALISE DCB BELOW THE LINE DCBMODEL DCB   DDNAME=TEMPLTE,DSORG=PS,MACRF=(R,W) DCBEND   EQU   * DCBLEN   EQU   (DCBEND-DCBSTART) * RDJFSTRT EQU   * * TEMPLATE RDJFCB LIST LRDJFCB  RDJFCB DCBMODEL,MF=L RDJFEND  EQU   * RDJFLEN  EQU   (RDJFEND-RDJFSTRT) WTOL     WTO   TEXT=,ROUTCDE=11,MF=L * WORKAREA DSECT * THIS AREA IS MAPPED TO THE GETMAINED STORAGE DATA     EQU   * * JFCBXLST DS    0F                            THE RDJFCB MACRO EXIT LIST JFCBCODE DS    X JFCBADDR DS XL3 JFCBAREA DS    0D * MACRO TO MAP JFCB SO WE CAN READ IT IEFJFCBN * DS    0D DCB      DS    (DCBLEN)C DS    0D XRDJFCB  DS    (RDJFLEN)C ENDDATA  EQU   * DATALEN  EQU   (ENDDATA-DATA) * DSECT MACRO TO MAP DCB SO WE CAN ALTER IT DCBD * *********************************************************************** *              DEFINE SYMBOLS *********************************************************************** * R0       EQU   0 R1       EQU   1 R2       EQU   2 R3       EQU   3 R4       EQU   4 R5       EQU   5 R6       EQU   6 R7       EQU   7 R8       EQU   8 R9       EQU   9 R10      EQU   10 R11      EQU   11 R12      EQU   12 R13      EQU   13 R14      EQU   14 R15      EQU   15 * END   DD2DSN
    
  • LuisA.
    LuisA.
    5 Posts

    Re: Knowing the Data Set Name in a Cobol Program

    ‏2010-10-05T11:57:21Z  
    • wmklein
    • ‏2010-10-04T18:04:27Z
    To the best of my knowledge, there is no LE callable service to do this.

    I am NOT good at z/OS control blocks, but there is a COBOL program (on the web) to get to MVS control blocks. Check out

    http://gsf-soft.com/Freeware/COB2JOB.shtml

    and see if that gets you to some control block that you think will let you find this information.

    You may also want to look at the "thread" of information (with COBOL examples) at:

    http://ibmmainframes.com/about6604.html
    Thank you a lot !! I have tried the COBOL program found in the forum http://ibmmainframes.com/about6604.html, and it runs ok in Z/OS 1.10. I think i will use it form my purpose.
  • LuisA.
    LuisA.
    5 Posts

    Re: Knowing the Data Set Name in a Cobol Program

    ‏2010-10-05T11:59:24Z  
    • PRH
    • ‏2010-10-05T01:45:26Z
    Try the following :
    <pre class="jive-pre"> DD2DSN TITLE '- RETRIEVE DSN GIVEN A DD NAME' *********************************************************************** * * * * THIS PROGRAM ACCEPTS THREE PARAMETERS AS FOLLOWS * * CALL 'DD2DSN' USING DD-NAME DS-NAME MEMBER * * WHERE * * 01 DD-NAME PIC X(8). (INPUT) * 01 DS-NAME PIC X(44). (OUTPUT) * 01 MEMBER PIC X(8). (OUTPUT) * * THE MEMBER NAME MAY ALSO CONTAIN A RELATIVE GDG NUMBER. * * THE RETURN CODE IS PASSED UP FROM THE RDJFCB MACRO. * * ATTRIBUTES: REENTRANT * *********************************************************************** * DD2DSN RMODE 31 DD2DSN AMODE 31 DD2DSN CSECT * *********************************************************************** * LINKAGE *********************************************************************** * STM R14,R12,12(R13) SAVE REGISTERS IN CALLER AREA LR R11,R15 USING DD2DSN,R11 USE ENTRY POINT AS BASE L R2,0(R1) GET DDNAME ADDRESS L R3,4(R1) GET DSNAME ADDRESS L R4,8(R1) GET MEMBER ADDRESS GETMAIN RU,LV=DATALEN,LOC=BELOW GET SOME STORAGE FOR WORKAREA LR R10,R1 SAVE ADDR OF RETURNED STORAGE USING WORKAREA,R10 AND USE IT FOR OUR WORKAREA * *********************************************************************** * PROCESS REQUEST *********************************************************************** * LA R12,DCB ADDRESS DCB USING IHADCB,R12 ESTABLISH BASE FOR DCB * MVC 0(DCBLEN,R12),DCBMODEL INITIALISE DCB MVC DCBDDNAM,0(R2) SET DDNAME IN DCB LA R5,JFCBXLST GET EXITLIST ADDRESS STCM R5,7,DCBEXLSA STORE IT IN DCB MVI JFCBCODE,X '87' SET EXIT CODE LA R5,JFCBAREA GET JFCB AREA ADDRS STCM R5,7,JFCBADDR AND STORE IT IN EXIT LIST USING INFMJFCB,R5 ESTABLISH ADRESSABILITY OF AREA MVC XRDJFCB,LRDJFCB INITIALISE RDJFCB PARAM LIST RDJFCB ((R12)),MF=(E,XRDJFCB) GET JFCB LTR R15,R15 OK? BNZ RETURN NOPE MVC 0(44,R3),JFCBDSNM RETURN DSN MVC 0(8,R4),JFCBELNM RETURN MEMBER OR RELATIVE GDG *********************************************************************** * RETURN TO CALLER *********************************************************************** * RETURN LR R5,R15 FREEMAIN RU,LV=DATALEN,A=(R10) FREE OUR STORAGE LR R15,R5 SET RETURN CODE LM R0,R12,20(R13) RESTORE REGISTERS 0-12 L R14,12(R13) RESTORE LINK REGISTER BSM R0,R14 GO BACK * *********************************************************************** * WORK AREA *********************************************************************** * DS 0D DCBSTART EQU * * TEMPLATE DCB USED TO INITIALISE DCB BELOW THE LINE DCBMODEL DCB DDNAME=TEMPLTE,DSORG=PS,MACRF=(R,W) DCBEND EQU * DCBLEN EQU (DCBEND-DCBSTART) * RDJFSTRT EQU * * TEMPLATE RDJFCB LIST LRDJFCB RDJFCB DCBMODEL,MF=L RDJFEND EQU * RDJFLEN EQU (RDJFEND-RDJFSTRT) WTOL WTO TEXT=,ROUTCDE=11,MF=L * WORKAREA DSECT * THIS AREA IS MAPPED TO THE GETMAINED STORAGE DATA EQU * * JFCBXLST DS 0F THE RDJFCB MACRO EXIT LIST JFCBCODE DS X JFCBADDR DS XL3 JFCBAREA DS 0D * MACRO TO MAP JFCB SO WE CAN READ IT IEFJFCBN * DS 0D DCB DS (DCBLEN)C DS 0D XRDJFCB DS (RDJFLEN)C ENDDATA EQU * DATALEN EQU (ENDDATA-DATA) * DSECT MACRO TO MAP DCB SO WE CAN ALTER IT DCBD * *********************************************************************** * DEFINE SYMBOLS *********************************************************************** * R0 EQU 0 R1 EQU 1 R2 EQU 2 R3 EQU 3 R4 EQU 4 R5 EQU 5 R6 EQU 6 R7 EQU 7 R8 EQU 8 R9 EQU 9 R10 EQU 10 R11 EQU 11 R12 EQU 12 R13 EQU 13 R14 EQU 14 R15 EQU 15 * END DD2DSN </pre>
    thank you a lot !!, i prefer to use the cobol programm (my knowledge in assembler is very very basic) , but thank for your interest anf for the code. I will try it too.

    Thanks to everybody !!
  • frbock
    frbock
    1 Post

    Re: Knowing the Data Set Name in a Cobol Program

    ‏2010-10-09T01:50:07Z  
    I did have to make a couple of tweaks to meet shop standards, and scary enough, I was just trying to do the same thing as of yesterday, so the thread was timely.
    For those going into this, the DSN will carry a .G000V00 as the last piece. If you need the version, you need to back off 7 from the 1st non-space. If you need the basic DSN, you need to chop off the G000V00.

    My error in coding it (I'll admit it, being from a VSE backgound) was to assume you had to open the DCB before you could access the info. I had no end of grief on that one. The default DCB, popping the requested DD name into it was also brilliant.

    Damn... I really hate someone beating me to a solution.
    But, I do have to admit, yours is a more general and usable solution.

    SALUTE!!!
  • Ismael_Batista
    Ismael_Batista
    1 Post

    Re: Knowing the Data Set Name in a Cobol Program

    ‏2011-10-18T15:12:39Z  
    I load the Dr. Phillip assemby pgm alternative.
    The pgm assembly went all right the very first time.
    I made a CALL to the assembly subpgm from an EASYTRIEVE,
    and it works fine the very first time too.
    Thanks Dr Phillip, very good.
  • larvelo
    larvelo
    1 Post

    Re: Knowing the Data Set Name in a Cobol Program

    ‏2013-09-04T17:55:06Z  
    • PRH
    • ‏2010-10-05T01:45:26Z
    Try the following :
    <pre class="jive-pre"> DD2DSN TITLE '- RETRIEVE DSN GIVEN A DD NAME' *********************************************************************** * * * * THIS PROGRAM ACCEPTS THREE PARAMETERS AS FOLLOWS * * CALL 'DD2DSN' USING DD-NAME DS-NAME MEMBER * * WHERE * * 01 DD-NAME PIC X(8). (INPUT) * 01 DS-NAME PIC X(44). (OUTPUT) * 01 MEMBER PIC X(8). (OUTPUT) * * THE MEMBER NAME MAY ALSO CONTAIN A RELATIVE GDG NUMBER. * * THE RETURN CODE IS PASSED UP FROM THE RDJFCB MACRO. * * ATTRIBUTES: REENTRANT * *********************************************************************** * DD2DSN RMODE 31 DD2DSN AMODE 31 DD2DSN CSECT * *********************************************************************** * LINKAGE *********************************************************************** * STM R14,R12,12(R13) SAVE REGISTERS IN CALLER AREA LR R11,R15 USING DD2DSN,R11 USE ENTRY POINT AS BASE L R2,0(R1) GET DDNAME ADDRESS L R3,4(R1) GET DSNAME ADDRESS L R4,8(R1) GET MEMBER ADDRESS GETMAIN RU,LV=DATALEN,LOC=BELOW GET SOME STORAGE FOR WORKAREA LR R10,R1 SAVE ADDR OF RETURNED STORAGE USING WORKAREA,R10 AND USE IT FOR OUR WORKAREA * *********************************************************************** * PROCESS REQUEST *********************************************************************** * LA R12,DCB ADDRESS DCB USING IHADCB,R12 ESTABLISH BASE FOR DCB * MVC 0(DCBLEN,R12),DCBMODEL INITIALISE DCB MVC DCBDDNAM,0(R2) SET DDNAME IN DCB LA R5,JFCBXLST GET EXITLIST ADDRESS STCM R5,7,DCBEXLSA STORE IT IN DCB MVI JFCBCODE,X '87' SET EXIT CODE LA R5,JFCBAREA GET JFCB AREA ADDRS STCM R5,7,JFCBADDR AND STORE IT IN EXIT LIST USING INFMJFCB,R5 ESTABLISH ADRESSABILITY OF AREA MVC XRDJFCB,LRDJFCB INITIALISE RDJFCB PARAM LIST RDJFCB ((R12)),MF=(E,XRDJFCB) GET JFCB LTR R15,R15 OK? BNZ RETURN NOPE MVC 0(44,R3),JFCBDSNM RETURN DSN MVC 0(8,R4),JFCBELNM RETURN MEMBER OR RELATIVE GDG *********************************************************************** * RETURN TO CALLER *********************************************************************** * RETURN LR R5,R15 FREEMAIN RU,LV=DATALEN,A=(R10) FREE OUR STORAGE LR R15,R5 SET RETURN CODE LM R0,R12,20(R13) RESTORE REGISTERS 0-12 L R14,12(R13) RESTORE LINK REGISTER BSM R0,R14 GO BACK * *********************************************************************** * WORK AREA *********************************************************************** * DS 0D DCBSTART EQU * * TEMPLATE DCB USED TO INITIALISE DCB BELOW THE LINE DCBMODEL DCB DDNAME=TEMPLTE,DSORG=PS,MACRF=(R,W) DCBEND EQU * DCBLEN EQU (DCBEND-DCBSTART) * RDJFSTRT EQU * * TEMPLATE RDJFCB LIST LRDJFCB RDJFCB DCBMODEL,MF=L RDJFEND EQU * RDJFLEN EQU (RDJFEND-RDJFSTRT) WTOL WTO TEXT=,ROUTCDE=11,MF=L * WORKAREA DSECT * THIS AREA IS MAPPED TO THE GETMAINED STORAGE DATA EQU * * JFCBXLST DS 0F THE RDJFCB MACRO EXIT LIST JFCBCODE DS X JFCBADDR DS XL3 JFCBAREA DS 0D * MACRO TO MAP JFCB SO WE CAN READ IT IEFJFCBN * DS 0D DCB DS (DCBLEN)C DS 0D XRDJFCB DS (RDJFLEN)C ENDDATA EQU * DATALEN EQU (ENDDATA-DATA) * DSECT MACRO TO MAP DCB SO WE CAN ALTER IT DCBD * *********************************************************************** * DEFINE SYMBOLS *********************************************************************** * R0 EQU 0 R1 EQU 1 R2 EQU 2 R3 EQU 3 R4 EQU 4 R5 EQU 5 R6 EQU 6 R7 EQU 7 R8 EQU 8 R9 EQU 9 R10 EQU 10 R11 EQU 11 R12 EQU 12 R13 EQU 13 R14 EQU 14 R15 EQU 15 * END DD2DSN </pre>

    Do you have this Assembler routine in a more readable format, with its carriage control and line feed characters?

  • PRH
    PRH
    2 Posts

    Re: Knowing the Data Set Name in a Cobol Program

    ‏2013-09-06T05:48:58Z  
    • larvelo
    • ‏2013-09-04T17:55:06Z

    Do you have this Assembler routine in a more readable format, with its carriage control and line feed characters?

    Try the attached file.

    Attachments