How to use the DDNAME passed from JCL in a COBOL program?

Hi,

We have a requirement where whe have to invoke a COBOL program from JCL , where we are passing a file to the program from JCL. Could you please provide some examples on how we can get this done.

Regards,

Sunil

  • Hello Sunil,
    There is an example in the Samples Browser; Mainframe Samples > JCL > Classic JCL Demo, that shows a COBOL program, JCLCREAT.cbl, opening and writing to a dataset identified by the DDNAME OUTFILE in the ESJCL.jcl job.
    If you open the sample project in your IDE you will be able to see the compiler options for the program (mainframe dialect).
    Hope this helps.
    Regards,
    Andrew
  • Sunil, can you provide some more details in order to correctly assess what you try to achieve?

    • ED Eclipse? Visual Studio?  version?
      Target ES environment : Linux? UNIX? Windows?
    • Small piece of JCL as an exemple
    • What task is expected to be done in the COBOL program?
      Providing the relevant piece of COBOL code may be helpful

    Thanks,

    Daniel

  • In reply to Andrew Fendick:

    hi,
    Could you please provide the link of the samples, i could not navigate to the program you mentioned.
    Many thanks for replying
  • In reply to DanielP:

    Hi,

    We are using Visual studio 2015 and out target environment is Windows
    Its not about the Task the COBOL program is doing, actually we are not able to reference the DD statement of the JCL file in the COBOL program.
    For example:-
    file-control.
    select out-file assign to OUTFILE
    organization is sequential
    access mode is sequential
    FILE STATUS IS WS-FS1.

    in the above file control MF cobol is seeing OUTFILE as variable and thus failing to do any operation. is there any way it to represent the DDNAME in JCL say for example:-

    //STEP01 EXEC PGM=JCLCRT
    //OUTFILE DD DSN=TEMP.INTRDR,RECFM=FB,LRECL=80,
    // DISP=(NEW,CATLG,DELETE),SPACE=(CYL,(100,50),RLSE)
    //SYSOUT DD SYSOUT=*
  • In reply to Sunilmh:

    Hi Sunil,
    The Samples Browser is installed with your Enterprise Developer product. Start > All Programs > Micro Focus Enterprise Developer > Samples > Mainframe Samples
    Regards
    Andrew
  • In reply to Andrew Fendick:

    Yep, found the program, its running fine in ENT COBOL, but not in MF COBOL dialect
  • found the solution after lot of searching. Couldn't believe it was so simple. putting it here , so that some may find it helpful.

    This can be done easily by using the compiler directive :-
    $set FCDCAT ASSIGN(EXTERNAL)