0

Hy all,

this is my first question on stackoverflow, so let me know if something is wrong. Howerver, I need to know if is it possible to read a dataset, defined with a DD name declared in a COBOL program, from a Java Stored Procedure under DB2.

The program flow is: - a JCL invoke a STORED PROCEDURE - the STORED PROCEDURE invoke the jar - the jar try to open the data set through the DD name

I tried to use ZFile class from jZos library but the Java code can't see neither the DD name and the relative file on z/OS. My doubt is: There is no way to accomplish this task because the JVM on DB2 runs in an isolated environment or there is a specific class/procedure to reach the data set?

Thanks in advance!

Fedox
  • 11
  • 1
  • Welcome @Stackoverflow. As you've asked about questions - please [take the tour](https://stackoverflow.com/tour) - people will also see this (you'll get your second badge) and assume you know the contents. In general: You've already tried something, it normally is best to show the code of what you've tried so far, this will help people see what you did and how to possibly help you better. – Simon Sobisch Oct 23 '18 at 16:19

1 Answers1

5

There is a significant difference between "is it possible," "is it allowed," and "is it a good idea."

Because you know the file name I believe it may be possible to achieve your goal via dynamic allocation of the file associated with the DD. The javadoc for ZFile indicates it "includes an interface to BPXWDYN (text based interface to MVS dynamic allocation)."

Whether this is allowed in your IT shop is a question for your architecture staff and DB2 Systems Programmers (the people responsible for installing, configuring, and performance of DB2). Just because something is possible does not mean it is allowed - there may be performance or security or audit considerations.

Even if it turns out this architecture is possible and allowed, it may be that there are better solutions. Talk to your architecture staff and z/OS and DB2 Systems Programmers about your requirements and why you wish to pursue this particular solution. Ask them for suggestions on improvements which still implement your requirements.

For example, if you intend to execute this stored procedure one million times in a batch job, and to dynamically allocate the file, open it, read its contents, close it, and then deallocate it for each execution - that is unlikely to perform well and is likely to have an adverse impact on the other applications which make use of DB2 stored procedures. Perhaps storing the contents of the file in a DB2 table is a better solution - I cannot say because I do not know your business requirements or the context of the rest of your application, I merely bring it up as an example.

cschneid
  • 10,237
  • 1
  • 28
  • 39
  • very well said. – SaggingRufus Oct 23 '18 at 15:46
  • First of all thanks for your detailed answer. I know you have absolutely right about specific architecture-policy, systems and so on. I "simply" tried to abstract the problem and explain that in a pure theoretical way. Howerver I'll try with BPXWDYN and I'll let you know. Thanks a lot! – Fedox Oct 24 '18 at 09:28