MENU

Code for IBM i: Special Contribution 2

Code for IBM i | Part 9: Special Contribution 2

ushiday’s Code for IBM i Application Case
By Yoshiki Ushida, President and CEO,  Chubu System Company (CSC)

 

Server-side open source software technology on IBM i reached a turning point in 2019. It is a shift in how OSS is provided from the licensing program 5733-OPS to yum. This has allowed for speedy application of OSS on the IBM i.

However, what about the development environment for the client? In many cases, RPG and CL are developed using SEU (no longer under development), while open systems are developed using various editors (RDi, VSCode, Eclipse, IDEA, Atom, etc.).

I am one of them. Especially for RPG and CL development, I mostly use SEU, which I have been accustomed to using for many years. For a craftsman (engineer), tools are essential business tools, so there is nothing better than ease of use. However, rather than sticking with old tools forever, it is important to try out new tools and use them skillfully.

In this situation, client-side development environments for IBM i, such as IBM i Merlin and Code for IBM i, have been gaining popularity. Even the author, who usually uses SEU, is using Code for IBM i more and more. In this article, I would like to introduce some practical usage of Code for IBM i.

Here are some of the advantages of Code for IBM i from a personal point of view.

Enables local work (source editing/reading) 

You can work in a local environment by importing sources on IBM i to Code for IBM i on a local PC even when you are not connected to IBM i. The author often downloads program sources to a local PC in advance when going out or traveling and uses Code for IBM i when the network environment is weak and it isn’t easy to refer to the sources on IBM i. While traveling on the bullet train or waiting at a café, I conduct source code analysis and preliminary research on Code for IBM i. In the author’s case, he rarely modifies the source code on his local PC but uses it to embed comments on the analyzed contents into the source code.

Procedure
(1) “Download” the source code using “Code for i – Object Browser” (Figure 1)
(2) Save the source code in an appropriate folder on the local PC (Figure 2)

Figure 1
Figure 1
Figure 2
Figure 2

Easy Git management of source code 

Since Git management is bundled with VSCode itself, it is easy to put the source code on Git management as it is.

Procedure (installation of Git in the local environment is required)
(1) put the source folder of the local PC under git management “git init (in the source folder)” (Figure 3)
(2) management by various git commands
(3)easier management with VSCode’s GitLens extension, etc. (Figure 4)

Figure 3
Figure 3
Figure 4
Figure 4

Timeline function can be used

In addition to Git management, local history (change history) can be managed using VSCode’s timeline function. VSCode also saves changes worked on locally at any time, so even in cases where small changes are made and no history is kept on Git, the timeline function can be used to check the changes. Even if you make an editing mistake, you can easily roll back. With SEU, I have often seen the vice of copying members and increasing the number of garbage members.

Procedure
(1) From “Explorer” on the left pane , right-click on the file and select [ Open Timeline ] (Figure 5)

Figure 5
Figure 5

The outline function can be used

VSCode’s outline function lets you see the overall structure of variables, Data Structure, and subroutines, and jump to the corresponding source code. This is useful when jumping to a subroutine when analyzing a source code with many steps.

Procedure
(1)Select the file from “Explorer” in the left pane and expand “Outline” (Figure 6).

Figure 6
Figure 6

Advanced search functions are available 

Code for IBM i allows source searching using regular expressions, which is impossible with SEU. In the case of SEU, searches using wildcards and common expression patterns are not possible, so unintended search results are also picked up. Still, regular expressions can be used for flexible searches. Furthermore, in the case of search results within a project, the results can be output via copy and paste for subsequent work.

Procedure
(1) source code search: In the source code, press “Ctrl + F” to display the search window and enter the search value (Figure 7).
(2) Member (project) search: Click the “magnifying glass” mark on the left, and then press “Ctrl + F” to display the search window and enter the search value (Figure 8, Figure 9)

Figure 7
Figure 7
 
Figure 8
Figure 8
Figure 9
Figure 9

Output of source differences can be used

Extract the differences between the pre-and post-change source code, which the developer uses to review the code after the change. For example, in the author’s team, the responsible person is supposed to review the source code after the developer has developed it. Still, when changes are made, the conversation is often based on source diffs. In such cases, the source diff output function of Code for IBM i and VSCode can be used to facilitate review.

Procedure
(1) git history comparison: Right-click the file in question and select [ Commit Changes ]…. (Figure 10).
(2) optional comparison: Right-click the corresponding file and select source (Select for Compare) and destination (Compare with Selected).

Figure 10
Figure 10

Local editing (Remote compilation becomes possible)

Even if edited on a local PC, its contents can be saved to IFS on the IBM i for successive compilation. Moreover, these sequences can be performed by the actions function of Code for IBM i, which allows remote command behavior linked to file extensions. For example, in the case of *.rpgle”, CRTBNDRPG can be followed by an IFS upload.

Procedure
(1) select [View] → [Command Palette] at the top
(2) Select “IBM i Launch Action Setup” (Figure 11)
(3) Select the type of file to define the Action (Figure 12)
(4) Connect to IBM i with [IBM i] in the left pane
(5) Set the library list (USER LIBRARY LIST) and the current library (where to compile)
(6) Specify the source upload destination in IFS BROWSER, right-click and click [Change working directory].
(7) Select the files to be uploaded and compiled to IFS and press [Ctrl + E]. Select the execution command (Figure 13) and the file to be uploaded (Figure 14)
(8) check the compilation result by clicking [Output] -> [Output] in the lower pane (Figure 15)

Figure 11
Figure 11
Figure 12
Figure 12
Figure 13
Figure 13

 

Figure 14
Figure 14
Figure 15
Figure 15

Finally

In the author’s case, SEU is more for supplementary development use than full-scale development or scratch. However, Code for IBM i is useful for improving development efficiency by utilizing functions not available in SEU. Therefore, Code for IBM i is the best bridge between VSCode and IBM i. Rather than thinking “all development should be done with Code for IBM i,” why not start by trying out where you can use it efficiently? 

Author
Yoshiki Ushida

President 
Chubu System Company (CSC)
https://www.cscweb.jp/

Yoshiki Ushida joined Chubu System Company(CSC) in 2001 and has been in charge of many contracted development projects as an RPG engineer. He is also an expert in PHP, JavaScript, Node.js, etc. He is active on Twitter and Qiita, etc. He has been in his current position since 2021.

[i Magazine・IS magazine]    https://www.imagazine.co.jp/

新着