12
Wed, Jun
4 New Articles

IBM i Coding Using VS Code

RPG
Typography
  • Smaller Small Medium Big Bigger
  • Default Helvetica Segoe Georgia Times

Can VS Code—the free, popular, extensible editor—replace the venerable SEU, which hasn't been updated since 2008? Check out the Code for IBM i extension.

Nearly all IBM i users are familiar with SEU, the Source Entry Utility. It has been around "forever," but it hasn't been updated since 2008 and remains frozen at the V6R1 level. RPG has had significant enhancements since then, and SEU doesn't understand the new syntax.

IBM's replacement for SEU is Rational Developer for i (RDi). It has context-sensitive help, content assist, an outline, a verify option, and lots more. As far as I am concerned, RDi is the gold standard for IBM i development, but unfortunately it is priced similarly to gold and is out of the reach of some developers.

Virtual Studio Code (VS Code) is a free, open-source, GUI editor first released in 2015. It’s very popular, and it's extensible. This article focuses on the Code for IBM i extension, which I think is the extension that integrates best with the IBM i. I'll give you a feel for what it can do and then conclude with some wrap-up thoughts.

Code for IBM i: Overview

Code for IBM i is not easy to describe. It is a bit like green-screen PDM, SEU, WRKLNK, and EDTF combined, with elements of RDi thrown in, all in a GUI interface. It allows you to browse, edit, and compile both traditional source files and source files in the IFS. It highlights compilation errors and shows them in the source, a super productivity feature that RDi also provides. You can have connections to multiple machines and multiple named connections to each machine. And more.

This article is not intended to be a tutorial on Code for IBM i but rather to introduce you to some of the capabilities a typical IBM i developer would use. When you install the Code for IBM i extension, a Quick Start Guide is included, and it has a link to more detailed documentation on using and customizing the extension.

Probably the best way to describe Code for IBM i is to show some screen shots of what it looks like for an IBM i coder.

Code for IBM i: Browsers

When you first connect to an IBM i, the Code for IBM i screen will look something like Figure 1 below. Note that, at the bottom of the screen, you can see the IBM i host (here it's ipublic.online). At the left is the sidebar showing the available browsers and the library list from your user profile. (If you have tweaked your VS Code layout, you may see something a little different.)

IBM i Coding Using VS Code - Figure 1 

Figure 1: First-time Code for IBM i display

You can easily close or expand a browser by clicking on it, and you can add or remove items from it. Figure 2 below shows my adjusted browsers, where I have added several source physical files to the Member Browser and have expanded QPRGLESRC.

IBM i Coding Using VS Code - Figure 2 

Figure 2: Member browser expanded

In Figure 3 below, I have closed the Library List, expanded the IFS Browser, and drilled down a couple of folders to see the contents of the DATE_UDF folder. If I hover over DATECRTFN.SQL I can see the complete path, showing I'm several directories down.

IBM i Coding Using VS Code - Figure 3 

Figure 3: IFS browser expanded

The browser is the standard VS Code approach and is like RDi and other GUI code editors.

Code for IBM i: Editing and Compiling

Back in the member browser, I have expanded the DATE_UDF source file and clicked several members to open them. Figure 4 shows the results.

IBM i Coding Using VS Code - Figure 4 

Figure 4: Multiple members in the DATE_UDF source file open for editing

The leftmost tab is the one with the focus and is a /FREE RPG module that is nicely colored. The multiple tabs feature for open files is a standard VS Code feature.

Ctrl+E is the shortcut that compiles the code in the tab with the focus. Since this is an RPGLE member, there can be several compile options, as shown in Figure 5.

IBM i Coding Using VS Code - Figure 5 

Figure 5: Compile prompt for RPGLE source

This source is going to be made into a service program, and I want to create an RPG module, so I cursor down to, or click on, Create RPG Module and press Enter. Figure 6 shows the results.

IBM i Coding Using VS Code - Figure 6 

Figure 6: Prompt for additional compile changes

I could change CRTRPGMOD here to add or remove parameters.

Compile commands, or "Actions" (discussed later), can execute immediately or prompt you for additional input, as in this case. (This is analogous to the "?command" syntax you can use in interactive CLP programs or in PDM User-Defined Options.) In this case, the default is what I want, so I just press Enter.

The code is compiled, and the success or failure is listed in the bottom right corner of my screen, as in Figure 7.

IBM i Coding Using VS Code - Figure 7 

Figure 7: Compile results reported

If you look again at Figure 7, you will notice 9 problems reported and listed in the Problems tab. If I click one of the problem lines, the cursor is positioned to the source line in question, line 103 in Figure 8 below.

IBM i Coding Using VS Code - Figure 8 

Figure 8: Positioning the cursor to the line in error

This feature makes finding and fixing errors a whole lot easier than in SEU.

Alternatively, you can just scroll through the source, looking for the squiggly lines underneath the errors. If I hover, the error message is shown. In Figure 9 below, the cursor is hovering over line 107.

IBM i Coding Using VS Code - Figure 9 

Figure 9: Hovering over a squiggly, annotated line

Astute readers may notice that this compile was successful and may wonder why VS Code is reporting problems. I can control which problems are reported in the Problems tab by clicking the little "filter" icon and choosing what level of problems I want to see, as in Figure 10, where I have filtered out the Info messages. (It still has a problem count of 9, but that's the way VS Code works.)

IBM i Coding Using VS Code - Figure 10 

Figure 10: Info messages filtered out

Want to see the compile listing? I can find that by clicking on the Output tab. I have to make sure I have IBM i Output selected in the dropdown on the right. See Figure 11.

IBM i Coding Using VS Code - Figure 11 

Figure 11: Compile listing

Code for IBM i: Actions

An action is something that is applied to the tab that has the focus. Ctrl+E to compile, as shown earlier, invoked the CRTRPGMOD action. An action can also be applied to an object in a browser by right-clicking it.

Code for IBM i comes with a set of standard actions. Clicking on Actions down at the bottom brings up the Work with Actions tab. Figure 12 show the currently supplied standard actions.

IBM i Coding Using VS Code - Figure 12 

Figure 12: Work with Actions tab

You can add a new action by clicking on New Action. You can change an existing action by clicking on it. Figure 13 shows the CRTRPGMOD action used earlier.

IBM i Coding Using VS Code - Figure 13 

Figure 13: The CRTRPGMOD action

Code for IBM i: Conclusion

I've given you a feel for some of what VS Code with Code for IBM i can do. There are other capabilities, but I don't have space here to show them.

Is this a viable option for IBM i developers? Definitely.

Honestly, Code for IBM i is not RDi, but RDi is currently in a class and price point of its own.

Code for IBM i is free, it is open source, and it offers much that SEU does not provide and never will provide. Code for IBM i is also being improved and enhanced.

VS Code loads quickly, is also regularly improved, and is an all-around extremely competent editor for all kinds of files.

I Recommend That You Give It a Try

If you are already using VS Code, you'll quickly come up to speed with Code for IBM i. It you haven't used VS Code, it is easy to install and comes with a number of tutorials. You will need a little time to become familiar with it, but once you do, you may find you use it for editing lots of file types.

Plaudits and Acknowledgements

Code for IBM i is largely the work of Liam Allan, who is well-known in the IBM i world and recognized as an IBM Champion. He is committed to extending and improving Code for IBM i and keeping it open source. So far, 13 others have contributed to the project, and the functionality is increasing. You can follow the development, raise issues, ask questions, or contribute on GitHub.

 

Sam Lennon

Sam Lennon is an analyst, developer, consultant and IBM i geek. He started his programming career in 360 assembly language on IBM mainframes, but moved to the AS400 platform in 1991 and has been an AS400/iSeries/i5/IBM i advocate ever since.

BLOG COMMENTS POWERED BY DISQUS

LATEST COMMENTS

Support MC Press Online

$0.00 Raised:
$

Book Reviews

Resource Center

  • SB Profound WC 5536 Have you been wondering about Node.js? Our free Node.js Webinar Series takes you from total beginner to creating a fully-functional IBM i Node.js business application. You can find Part 1 here. In Part 2 of our free Node.js Webinar Series, Brian May teaches you the different tooling options available for writing code, debugging, and using Git for version control. Brian will briefly discuss the different tools available, and demonstrate his preferred setup for Node development on IBM i or any platform. Attend this webinar to learn:

  • SB Profound WP 5539More than ever, there is a demand for IT to deliver innovation. Your IBM i has been an essential part of your business operations for years. However, your organization may struggle to maintain the current system and implement new projects. The thousands of customers we've worked with and surveyed state that expectations regarding the digital footprint and vision of the company are not aligned with the current IT environment.

  • SB HelpSystems ROBOT Generic IBM announced the E1080 servers using the latest Power10 processor in September 2021. The most powerful processor from IBM to date, Power10 is designed to handle the demands of doing business in today’s high-tech atmosphere, including running cloud applications, supporting big data, and managing AI workloads. But what does Power10 mean for your data center? In this recorded webinar, IBMers Dan Sundt and Dylan Boday join IBM Power Champion Tom Huntington for a discussion on why Power10 technology is the right strategic investment if you run IBM i, AIX, or Linux. In this action-packed hour, Tom will share trends from the IBM i and AIX user communities while Dan and Dylan dive into the tech specs for key hardware, including:

  • Magic MarkTRY the one package that solves all your document design and printing challenges on all your platforms. Produce bar code labels, electronic forms, ad hoc reports, and RFID tags – without programming! MarkMagic is the only document design and print solution that combines report writing, WYSIWYG label and forms design, and conditional printing in one integrated product. Make sure your data survives when catastrophe hits. Request your trial now!  Request Now.

  • SB HelpSystems ROBOT GenericForms of ransomware has been around for over 30 years, and with more and more organizations suffering attacks each year, it continues to endure. What has made ransomware such a durable threat and what is the best way to combat it? In order to prevent ransomware, organizations must first understand how it works.

  • SB HelpSystems ROBOT GenericIT security is a top priority for businesses around the world, but most IBM i pros don’t know where to begin—and most cybersecurity experts don’t know IBM i. In this session, Robin Tatam explores the business impact of lax IBM i security, the top vulnerabilities putting IBM i at risk, and the steps you can take to protect your organization. If you’re looking to avoid unexpected downtime or corrupted data, you don’t want to miss this session.

  • SB HelpSystems ROBOT GenericCan you trust all of your users all of the time? A typical end user receives 16 malicious emails each month, but only 17 percent of these phishing campaigns are reported to IT. Once an attack is underway, most organizations won’t discover the breach until six months later. A staggering amount of damage can occur in that time. Despite these risks, 93 percent of organizations are leaving their IBM i systems vulnerable to cybercrime. In this on-demand webinar, IBM i security experts Robin Tatam and Sandi Moore will reveal:

  • FORTRA Disaster protection is vital to every business. Yet, it often consists of patched together procedures that are prone to error. From automatic backups to data encryption to media management, Robot automates the routine (yet often complex) tasks of iSeries backup and recovery, saving you time and money and making the process safer and more reliable. Automate your backups with the Robot Backup and Recovery Solution. Key features include:

  • FORTRAManaging messages on your IBM i can be more than a full-time job if you have to do it manually. Messages need a response and resources must be monitored—often over multiple systems and across platforms. How can you be sure you won’t miss important system events? Automate your message center with the Robot Message Management Solution. Key features include:

  • FORTRAThe thought of printing, distributing, and storing iSeries reports manually may reduce you to tears. Paper and labor costs associated with report generation can spiral out of control. Mountains of paper threaten to swamp your files. Robot automates report bursting, distribution, bundling, and archiving, and offers secure, selective online report viewing. Manage your reports with the Robot Report Management Solution. Key features include:

  • FORTRAFor over 30 years, Robot has been a leader in systems management for IBM i. With batch job creation and scheduling at its core, the Robot Job Scheduling Solution reduces the opportunity for human error and helps you maintain service levels, automating even the biggest, most complex runbooks. Manage your job schedule with the Robot Job Scheduling Solution. Key features include:

  • LANSA Business users want new applications now. Market and regulatory pressures require faster application updates and delivery into production. Your IBM i developers may be approaching retirement, and you see no sure way to fill their positions with experienced developers. In addition, you may be caught between maintaining your existing applications and the uncertainty of moving to something new.

  • LANSAWhen it comes to creating your business applications, there are hundreds of coding platforms and programming languages to choose from. These options range from very complex traditional programming languages to Low-Code platforms where sometimes no traditional coding experience is needed. Download our whitepaper, The Power of Writing Code in a Low-Code Solution, and:

  • LANSASupply Chain is becoming increasingly complex and unpredictable. From raw materials for manufacturing to food supply chains, the journey from source to production to delivery to consumers is marred with inefficiencies, manual processes, shortages, recalls, counterfeits, and scandals. In this webinar, we discuss how:

  • The MC Resource Centers bring you the widest selection of white papers, trial software, and on-demand webcasts for you to choose from. >> Review the list of White Papers, Trial Software or On-Demand Webcast at the MC Press Resource Center. >> Add the items to yru Cart and complet he checkout process and submit

  • Profound Logic Have you been wondering about Node.js? Our free Node.js Webinar Series takes you from total beginner to creating a fully-functional IBM i Node.js business application.

  • SB Profound WC 5536Join us for this hour-long webcast that will explore:

  • Fortra IT managers hoping to find new IBM i talent are discovering that the pool of experienced RPG programmers and operators or administrators with intimate knowledge of the operating system and the applications that run on it is small. This begs the question: How will you manage the platform that supports such a big part of your business? This guide offers strategies and software suggestions to help you plan IT staffing and resources and smooth the transition after your AS/400 talent retires. Read on to learn: