Skip to main content

JFCB in SEP - how do I get a filename(DSN=) from the JCL to a variable within a Cobol program

  • November 29, 2016
  • 4 replies
  • 0 views

I have a need to obtain the physical name of a dataset (DSN=my.flat.file), for processing by a Cobol program.  In zOS, assembler code could be used to access the JFCB control block.  Is there some similar method within MFES?


#CobolDSNJFCB
#EnterpriseServer

4 replies

  • Author
  • Rocketeer
  • 19312 replies
  • November 30, 2016

I have a need to obtain the physical name of a dataset (DSN=my.flat.file), for processing by a Cobol program.  In zOS, assembler code could be used to access the JFCB control block.  Is there some similar method within MFES?


#CobolDSNJFCB
#EnterpriseServer

ES supports the IEFJFCBN, according to the docs:

documentation.microfocus.com/.../HCOMCMCBLKS001.html

Does that meet your needs? (This isn't something I've used myself.) If not, I can dig into this further - it seems like something we would support one way or another.

Another alternative is to use the %PCDSN extension to force a particular physical file for the DD. I don't know whether that's relative to your situation.


  • Author
  • Rocketeer
  • 19312 replies
  • November 30, 2016

I have a need to obtain the physical name of a dataset (DSN=my.flat.file), for processing by a Cobol program.  In zOS, assembler code could be used to access the JFCB control block.  Is there some similar method within MFES?


#CobolDSNJFCB
#EnterpriseServer

Thanks Michael.  I assume that the TIOT points to the JFCB.  This would be a great way to solve an existing issue for us.  Do you have an example program that access data from the IEFJFCBN?


  • Author
  • Rocketeer
  • 19312 replies
  • November 30, 2016

I have a need to obtain the physical name of a dataset (DSN=my.flat.file), for processing by a Cobol program.  In zOS, assembler code could be used to access the JFCB control block.  Is there some similar method within MFES?


#CobolDSNJFCB
#EnterpriseServer

in W-S

copy MFJCTLBC.CPY

----------------------------------------------------------------

    OBTAIN JobName

----------------------------------------------------------------

OBTAIN-JOB-NAME.

   INITIALIZE                       WS-JCL-DD-AREA

                                    WS-JCL-RETCODE.

   SET  WS-JCL-FUNC-GET-EXEC     TO  TRUE.

   SET  WS-JCL-EXEC-VERS-CUR     TO  TRUE.

   CALL  'MFJCTLBP'           USING  WS-JCL-FUNCTION

                                     WS-JCL-RETCODE

                                     WS-JCL-EXEC-AREA.

   DISPLAY ':We run under JobName    = '  WS-JCL-job-jobname .

=============================

OBTAIN DDName related to DD

    SET WS-JCL-DD-VERS-CUR      TO TRUE.

    SET WS-JCL-FUNC-GET-DD      TO TRUE.

    MOVE 'BPFJESO' TO WS-JCL-DDNAME.

    CALL 'MFJCTLBP' USING       WS-JCL-FUNCTION

                                WS-JCL-RETCODE

                                WS-JCL-DD-AREA.

    perform varying JCL-FILENAME-Len from 256 by -1

    until WS-JCL-FILENAME(JCL-FILENAME-Len:1)

       not = space

        continue

    end-perform

    MOVE WS-JCL-FILENAME(1:JCL-FILENAME-Len)

        to JCL-FILENAME-text


  • Author
  • Rocketeer
  • 19312 replies
  • November 30, 2016

I have a need to obtain the physical name of a dataset (DSN=my.flat.file), for processing by a Cobol program.  In zOS, assembler code could be used to access the JFCB control block.  Is there some similar method within MFES?


#CobolDSNJFCB
#EnterpriseServer

A0100-GET-DD-INFO SECTION.

   SET WS-JCL-DD-VERS-CUR      TO TRUE.

   IF  WS-LK-SUB = 1

       SET WS-JCL-FUNC-GET-DD-FIRST

                               TO TRUE

   ELSE

       SET WS-JCL-FUNC-GET-DD-NEXT

                               TO TRUE

   END-IF.

   CALL 'MFJCTLBP' USING       WS-JCL-FUNCTION

                               WS-JCL-RETCODE

                               WS-JCL-DD-AREA.

   IF  WS-JCL-RETCODE = 500

       GO TO A0100-EXIT

   END-IF.

   IF  WS-JCL-RETCODE NOT = ZERO

       DISPLAY '*********************************************

           UPON CONSOLE

       DISPLAY '* MFJCLINF-BAD RETURN CODE ON CALL TO MFJCTLB

           WS-JCL-RETCODE UPON CONSOLE

       DISPLAY '*********************************************

           UPON CONSOLE

       STOP RUN

   END-IF.

   MOVE WS-JCL-DDNAME          TO LK-MFJCLINF-DDN

                                  (WS-LK-SUB).

   MOVE WS-JCL-DSNAME-DSN      TO LK-MFJCLINF-DSN

                                  (WS-LK-SUB).

   MOVE WS-JCL-DSNAME-MBR      TO LK-MFJCLINF-MBR

                                  (WS-LK-SUB).

   MOVE WS-JCL-FILENAME        TO LK-MFJCLINF-PC-FILE

                                  (WS-LK-SUB).

   MOVE WS-JCL-DSORG           TO LK-MFJCLINF-DSORG

                                  (WS-LK-SUB).

   MOVE WS-JCL-RECFM           TO LK-MFJCLINF-RECFM

                                  (WS-LK-SUB).

   MOVE WS-JCL-TRTCH           TO LK-MFJCLINF-TRTCH

                                  (WS-LK-SUB).

   MOVE WS-JCL-LRECL-MIN       TO LK-MFJCLINF-LRECL-MIN

                                  (WS-LK-SUB).

   MOVE WS-JCL-LRECL-MAX       TO LK-MFJCLINF-LRECL-MAX

                                  (WS-LK-SUB).

   ADD 1                       TO WS-LK-SUB.