3

From Java z/OS, using zfile I can create a mainframe dataset. Both flat file and GDG versions.

If the GDG base does not exist the java code abends. Do we have an option to create the mainframe GDG base dataset from Java?

2
  • What runtime are you executing Java ... Batch, TSO, OMVS ?
    – Hogstrom
    Commented Feb 15, 2022 at 16:34
  • Java Batch. Mainframe job is triggering the java code using COZBATCH utility
    – SSJ
    Commented Feb 15, 2022 at 17:57

2 Answers 2

4

Given below is the code snippet i used to create the GDG Base from java. We just add the IDCAMS SYSIN input to a string and execute the AccessMethodServices with that input. getoutputlines will give you the sysout from the IDCAMS command.

AccessMethodServices ams = new AccessMethodServices();

String gdgCreateString = "DEFINE GDG(NAME( " + dsName + " )  LIMIT(15)  NOEMPTY  SCRATCH)  " ;

ams.addInputLine(gdgCreateString );

int rc = ams.execute();

System.out.println(ams.getOutputLines());
1
  • easy peasy ... well done
    – Hogstrom
    Commented Feb 17, 2022 at 2:34
1

GDG base entries are created via the IDCAMS DEFINE GENERATIONDATAGROUP command.

There is a section in the documentation on invoking IDCAMS from within your program, but it seems to presume the invoking program is Assembler.

In my experience, job step failure due to a GDG base being undefined is not something recovered from programmatically. Implementation plans include define all required GDG base entries.

5
  • Thanks for the details. Ignoring the abend, in general do we have any option to create a GDG base from java code?
    – SSJ
    Commented Feb 15, 2022 at 18:54
  • @SSJ I don't know if there is a way to create a GDG base from Java code. If you can execute IDCAMS from your Java code (via system() maybe?), and get the right DDs allocated dynamically, and the SYSIN DD contains the requisite control cards, then I'd say "yes." But that "yes" is on the other side of several requirements that are outside my experience.
    – cschneid
    Commented Feb 15, 2022 at 19:04
  • 1
    Thanks for your input. I was able to create the GDG base from Java. AccessMethodServices in Java is used to run IDCAMS utility from Java.
    – SSJ
    Commented Feb 15, 2022 at 20:00
  • 1
    @SSJ It would be great if you could share your solution in an answer of your own.
    – piet.t
    Commented Feb 16, 2022 at 5:47
  • @piet.t Added the code snippet as the solution that worked for me.
    – SSJ
    Commented Feb 16, 2022 at 17:45

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.