COBOL Challenge: Covid-19 Reports
Now that the COBOL community is growing, I would like to create some programming challenges that will help everyone in their learning.
It will be simple challenges that will allow you to practice what you have learned so far.
Our Goal
Since we are on a pandemic, the goal that I have set for this challenge is to create a COVID-19 Summary Report. The reports will come from the COVID19API website.
Pre-requisites:
- Get your Mainframe Credentials: https://www-01.ibm.com/events/wwe/ast/mtm/cobolvscode.nsf/enrollall?openform
- Use the COBOL Programming Course for reference: https://github.com/openmainframeproject/cobol-programming-course
Let’s Start
So here are the instructions:
- Extract the response from this API: https://api.covid19api.com/summary. You will receive a JSON file that is similar to the photo below:
2. Convert that file to CSV format. It should look like this. In my example, I only chose the “Countries” part.
Hint: If you are stuck in Step # 1 and Step # 2, I can provide the data for you.
3. Using Zowe, Upload the CSV file that you have created to mainframe.
Hint: you can use the command zowe files ul ftds “file location” “dataset name”
- Create a new member in your *.CBL Dataset to write your COBOL program
Hint: This step can be done using Zowe Explorer and Zowe CLI
4. Begin writing your COBOL program
Hint: You can use my COBOL Generator or you can copy an existing program and change it.
- In your COBOL program, you have to read the uploaded file from Step # 3 and re-format it to display the contents like this:
********************************************************************DATE: 2020-04-22TIME: T16:54:5COUNTRY: "Antigua and Barbuda"COUNTRY CODE: "AG"SLUG: "antigua-and-barbuda"NEW CONFIRMED CASES: 00000TOTAL CONFIRMED CASES: 00023NEW DEATHS: 00000TOTAL DEATHS: 00003NEW RECOVERIES: 00004TOTAL RECOVERIES: 00007********************************************************************
- Optional: A more advance approach is to reformat it into a Report Form like this:
5. Compile and Test your work
6. Optional: Automate. Using NPM and Zowe CLI, Run all these steps and create a “one click” COBOL build similar to this.
I hope this could be a good COBOL challenge to anybody who is willing to try.
If you want to check my solution, read all about it here. Happy Coding! 😉
If you want to know more, I have included below the links about Zowe and Open Mainframe Project.
- Zowe Articles: https://medium.com/zowe
- Zowe Learning Paths: https://broadcom.com/zowe
- Zowe Official Website: https://www.zowe.org/
- Zowe Github Repo: https://github.com/zowe
- Open Mainframe Project Official Website: https://www.openmainframeproject.org/
- Open Mainframe Youtube Channel: https://www.youtube.com/channel/UC-WTXQQtz2m5iTflJLK59aw
- Open Mainframe Project Slack Channel: https://openmainframeproject.slack.com
- Modern Mainframe Articles: https://medium.com/modern-mainframe
Also, here are the links for my Beginner’s Guide: COBOL Made Easy articles