MENU

Code for IBM i: Can it replace SEU/PDM?

Code for IBM i | Part 4: Can it replace SEU/PDM?
By Makoto Ogawa, T&Trust K.K.

 

As mentioned in “About Code for IBM i,” the RPG III compiler cannot directly reference source code on the IFS (there is no SRCSTMF parameter in the CRTRPGPGM command). And Code for IBM i cannot push local code directly to members of source files on IBM i. In other words, as it is, you can’t save RPG III source code to a folder on your development PC for coding, and if you do, you can’t version control it with Git either.

This will be addressed in the following three ways.

#1   develop and maintain RPG III code with traditional SEU/PDM
#2   use RDi
#3   consider other methods

Regarding #1, we would like to avoid this option because we cannot version control with Git. As for #2, RDi, we explained in “Introduction to Git for IBM i Users” in the i Magazine 2022 Autumn issue that you can use Git to manage your iProjects, so RDi Users of RDi should refer to that article.

Since this article is about VSCode+Code for IBM i, let’s see if we can do it in this environment, preferably as a third solution.

Since it is enough if we can finally push the compiler CRTRPGPGM command to a member of the source file that can be referenced, we can work with the following steps.

(1) Use VSCode to store source code in a local folder
(2) Deploy (push) the source code to a pre-defined IFS directory using the Code for IBM i function
(3) Copy IFS stream files to source members using the CPY command
(4) Execute the CRTRPGPGM command

Since we have confirmed that (1) and (2) are possible with the explanation so far, how to realize (3) and (4) there is an open source command (CRTFRMSTMF) to execute these commands.

      https://GitHub.com/BrianGarland/CRTFRMSTMF

The above README.md on GitHub says the following.

     “CRTFRMSTMF is a wrapper over the IBM i CRTxxx compile commands that do not allow a stream file.”

Wrapper means “wrapper” or “wrapping paper,” and this command provides the functionality to perform (3) and (4) above.

In addition, the installation procedure in README.md states

1.   clone the repository
2.   run gmake

Although gmake is also a yum command to install, we will introduce the steps to create an object on IBM i without using it this time.

First, clone the repository by clicking the Code button on the above GitHub site and copying the https URL with the Copy button (Figure 45).

Figure 45    Copying the clone source address
Figure 45    Copying the clone source address

Next, create the clone destination folder on the development PC and start VSCode. If the previous folder is displayed, click “File” – “New Window.”

On the Start Working tab, click the “Clone Git Repository…” Next, click on the link, paste the repository URL you copied, and press enter. A folder selection window will appear, select the folder you just created. After the clone is executed, you will be asked if you want to open the repository, click “Open” (trust the creator of the folder).

When the clone is complete, a QSOURCE folder is created in the folder, and if you expand it, you will see that the following four source files have been downloaded. Let’s push these to the IFS directory of the IBM i using the Code for IBM i functionality.

cl_dltf.clle
crtfrmstmf.cmd
crtfrmstmf.pnlgrp
crtfrmstmf.rpgle

Connect to IBM i with Code for IBM i, set the Deploy (push) destination to /home/IMAG23WINT, click Deploy on the status bar, and click “All Every file in the local Click “All Every file in the local workspace” to push all files (Figure 46).

Figure 46   Deploying all files related to CRTFRMSTMF
Figure 46   Deploying all files related to CRTFRMSTMF

In this case, we need to create a *MODULE object and then create a *PGM object from multiple modules. This command is not registered in .vscode/actions. json, so I executed the following command using the system command in the PASE terminal (of course, you can also execute it in the 5250 emulator).

MODULE 
CRTCLMOD MODULE(IMAG2023/CL_DLTF) SRCSTMF(‘/home/IMAG23WINT/QSOURCE/cl_dltf.clle’)
CRTRPGMOD MODULE(IMAG2023/CRTFRMSTMF) SRCSTMF(‘/home/IMAG23WINT/QSOURCE/crtfrmstmf.rpgle’) TGTCCSID(*JOB)

Program 
CRTPGM PGM(IMAG2023/CRTFRMSTMF) MODULE(IMAG2023/CRTFRMSTMF IMAG2023/CL_DLTF)

Command 
CRTCMD CMD(IMAG2023/CRTFRMSTMF) PGM(IMAG2023/CRTFRMSTMF) SRCSTMF(‘/home/IMAG23WINT/QSOURCE/crtfrmstmf.cmd’) HLPPNLGRP(IMAG2023/ CRTFRMSTMF) HLPID(*CMD)

Please refer to Figure 47 for the relationship between each object.

Figure 47   Relationship between each object
Figure 47   Relationship between each object

The parameters of the CRTFRMSTMF command are as follows.

◎Keyword: Description: Selection item
・OBJ: Program object name and library name: Qualified object name
・CMD: Compile command: CRTCMD, CRTDSPF, CRTPRTF, CRTRPGPGM, CRTPNLGRP, CRTPF, CRTPF, etc.
・SRCSTMF: Source stream file: path name

Addition to .vscode/actions.json

Next, add the above commands to .vscode/actions.json so that the local RPG III source code can be compiled using the CRTFRMSTMF command (Figure 48).

Figure 48 Adding CRTFRMSTMF to actions.json
Figure 48 Adding CRTFRMSTMF to actions.json

The panel group object provides help information for the command. This also has a create command CRTPNLGRP, but the SRCSTMF parameter is not provided for this command either. Like RPG III, I added an action to this to be compiled in the VSCode+Code for IBM i environment.

Now let’s create a panel group.

In VSCode, open crtfrmstmf.pnlgrp in the QSOURCE folder and select Create Panel Group, which was registered earlier, using Ctrl + E. You should see a message that the action was successful, so click Output on the status bar and check the compilation list as well, just to be sure.

RPG III can also be managed with Git

Now, Deploy + Compile with Ctrl + E is possible while saving the RPG III code in a local folder. As I have repeatedly noted, RPG III does not provide a prompt function, so coding from scratch may be difficult. Still, in most cases, the code of a similar program should be copied and created, so I think this command makes a lot of sense, considering that it will allow version control with Git.

Author
Makoto Ogawa

President and CTO,CIO
T&Trust K.K.
https://www.tat.co.jp/

Since 1989, he has been responsible for system development and programming training on AS/400. He learned how IFS works on OS/400 V3R1 through Linux, and since then, he has been deeply interested in open source in IBM i. His theory is that developer needs knowledge of Linux to understand IBM i. He has also written many articles for i Magazine.

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

新着