IBM MTM 2019: Part Three – Challenge #06

Okay, another Java challenge! I like that, more coding problems! I have those daily at my j… No I don’t… heheh (awkward smile).

JZOS Toolkit API for Java

IBM Master the Mainframe Part Three – Challenge #06

Copy Java source to your Unix directory

Let’s get started by making sure we have the needed resources. From ISPF I enter the primary command =6 and enter oput ‘zos.mtm2019.public.p3.source(zjava)’ ‘zjava.java’ as primary again shortly after.
The text should then jump to the other line. That’s okay!

View the Java source in your Unix subdirectory

From the same screen we enter oedit.

We now see a file explorer that looks like it was built in one of the matrix movies. We need to edit zjava.java, we can do so by entering the line command next to the file name.

Press enter. You might have to press it twice as another screen pops up. Ignore that one.

I now get to see the file, IBM explains what the code does. We also see that scary warning. But I’m not scared, are you?

Submit JCL to compile and execute Java source program

Let’s run… not away, but the script. Let’s enter tso sub ‘zos.public.jcl(zjava)’ ; =sd ;st as primary command and try to identify the error.

If you can’t see your jobs, try entering prefix * ; owner z#####; as primary command. Thank you Georges! Enter line command v next to STDERR and let’s see..

It looks like there’s an undefined variable? Let’s fix that!

Identify and correct Java compile error

Let’s go back to the ISPF Primary Option Menu and enter the primary command tso oedit. Let’s edit zjava.java and correct the syntax error.

THINK WELL, IBM SAYS: “What was the name of integer value declared early in the Java program?”; You can use the primary command f int to highlight the text ‘int’. That should help!

If you think you’ve fixed it, enter the primary command tso sub ‘zos.public.jcl(zjava)’ ; =sd ; st and check the output to see if the error is gone. If it’s gone, congratulations!

Verify the completion of challenge #06

I have this output in my P3.OUTPUT data set. This means I got it right! On to challenge #07!

IBM MTM 2019: Part Three – Challenge #05

Java! 3 billion devices their best friend! Java is one of the biggest programming languages out there and now we have the chance to work with it on a mainframe.

Note: there might be some encoding issues if you copy and paste the copy commands from my blog into the mainframe. It’s best you copy the paths from the mybluemix website. My quotes are saved differently somehow (angry emoji).

Java – A popular programming language

IBM Master the Mainframe Part Three – Challenge #05

Copy Java program to MVS partitioned data set member and Unix file

Let’s navigate to our Z#####.SOURCE and create a new member using the primary command s pgmjava. Inthere we copy ‘ZOS.MTM2019.PUBLIC.P3.SOURCE(PGMJAVA)’.

Let’s return to the dslist by pressing F3. As primary command we enter TSO OMVS and enter oedit pgmjava.java

Once in edit mode we copy source(pgmjava) and return using F3.

Compile and execute Java program using Unix shell prompt

From the OMVS shell I enter javac pgmjava.java as command. There might be a message, but we can ignore that one.

So, we now have to connect to the workstation via SSH. Good lord, yeah, let me try.

Ok…

Oof, (sweaty palms emoji thingy). I got in. RIGHTCLICK to paste something in the command prompt, I used CTRL+V and felt stupid.

Now it compiled correctly! Does it suddenly have java because it’s accessed via CMD? WHAT.

YES I PRESSED CTRL+V AGAIN. OOPSIE. Let’s execute using java pgmjava. And I saw the hello world message! YESS! Enter the command exit to safely terminate the SSH connection.

Execute the Java program using JCL

Now in Z#####.JCL we create a new member pgmjava and copy ‘ZOS.MTM2019.PUBLIC.P3.JCL(PGMJAVA)’ into it. After that, let’s submit ; =sd ; st and check the output.

Last task to get full credit for the challenge

We need to change STDOUT in jcl member pgmjava and redirect output to member #05 in to our P3.OUTPUT partitioned data set.

I honestly don’t know what I need to do here, so I’ll just copy and paste the code after //SORTOUT in Z50087.JCL(SORTCITY) and change it to P3.OUTPUT(#05). I’ll take my chances! If you’re unsure if you have the correct thing, just compare our things’ length. If you’re as long as mine, you’ve got it.

Let’s execute! No errors so far. Let me check P3.OUTPUT(#05).

Done! All good! Let’s continue to challenge #06!

IBM MTM 2019: Part Three – Challenge #04

COBOL! This is probably going to be one of my most favorite challenges in this years’ master the mainframe. I actually have explained COBOL a bit in one of my other blogsposts MOM Pt. 003: Getting to know COBOL – Compiling. It explains how COBOL works and what the code looks like. The fourth part also shows me coding a FIZZBUZZ in COBOL on MVS 3.8 TK4-.

Note: there might be some encoding issues if you copy and paste the copy commands from my blog into the mainframe. It’s best you copy the paths from the mybluemix website.

Application Development – Procedural Programming Languages

IBM Master the Mainframe Part Three – Challenge #04

Practice Preparation

So from the ISPF Primary Option Menu I enter =3.4 and navigate to my Z#####.SOURCE. For this part we need to make new empty members and copy some data into them.

I create a new member using the primary command s. Then I will edit that member using the line command and copy ‘zos.mtm2019.public.p3.source(cblhello)’ and copy ‘zos.mtm2019.public.p3.source(chello)’ into them.

This is what it looks like after copying a member. Next do this in your Z#####.JCL and make a new member hello. copy ‘zos.mtm2019.public.p3.jcl(hello)’ into it. Execute the JCL using sub ; =sd ; st primary command.

After execution, execute the following primary commands: tso call load(cblhello) and tso call load(chello). These commands just execute the scripts we have just copied.

Get and review COBOL program source code.

We’ll create a new member called zcobol in Z#####.SOURCE and copy ‘zos.mtm2019.public.p3.source(zcobol)’ into it. Find the RECIN and RECOUT file names in the source code and take note. We can easily search a file using the f primary command.

Get and review C program source code

Same as last time. We create a new member called zc in Z#####.SOURCE and copy ‘zos.mtm2019.public.p3.source(zc)’ into it. Find the recin and recout.

Get and review program compile and execution JCL

Same as last time but other data set. In Z#####.JCL we create a new member rwrecord and copy ‘zos.mtm2019.public.p3.jcl(rwrecord)’ into it. Find the recin and recout.

It’s possible to have mutliple RECIN and RECOUT.

Execute C and COBOL programs

Don’t worry, I did not skip a paragraph. It’s just nothing I can write about. Let’s compile and execute the recently created jcl using primary command tso submit jcl(rwrecord). Now in P3.OUTPUT(#04) we should see the following text.

The message needs a correction to complete the challenge

We get to code? We get to code! Let’s quickly visit ZCOBOL in Z#####.SOURCE and see what can be done.

Somewhere in the code it replaces characters with other characters. I wonder what it can be! Let’s edit and run primary command tso submit jcl(rwrecord) again.

I did it! Woot! Now we need to copy source(zcobol) after at line 000003.

And we should have the source code under it.

That’s it for challenge #04!

Further challenges

I’m a bit behind on schedule sorry for that. I have had very little free time the last few weeks but I plan on doing a blogging day next saturday the 9th of november. That should get me to at least challenge 10 of part 3.

Goodluck everybody!