MENU

Code for IBM i: IBM i Notebooks

Code for IBM i | Part 6: IBM i Notebooks
By Makoto Ogawa, T&Trust K.K.

 

When developing with VSCode+Code for IBM i, you may want to execute commands and SQL within VSCode, and the IBM i Notebooks extension makes this possible.

After installing the IBM i Notebooks extension, create a file with the extension inb (either remotely or locally). The following notebook is then created (Figure 59).

Figure 59   Immediately after opening the ibm i notebook (.inb)
Figure 59   Immediately after opening the ibm i notebook (.inb)

Now let’s look at the procedure for executing the command DSPFFD, which displays the field information of the table. First, click on the + code at the top of the created notebook, and a block with a blue border will be inserted into the notebook (Figure 60).

Figure 60   Adding code procs
Figure 60   Adding code procs

At the bottom right of the block is the word SQL, so this state can be executed by entering the SQL command, but this time we want to execute the command DSPFFD, so we click on the word SQL. Then the choices shown in Figure 61 will appear at the top.

Figure 61   Selecting the language to be executed in the block
Figure 61   Selecting the language to be executed in the block

If you select CL here, the lower right corner will also change to CL. Now, let’s enter a command. Clicking the play button on the left executes the command (Figure 62, Figure 63).

Figure 62   Execution of the CL command
Figure 62   Execution of the CL command
Figure 63   Execution result of the DSPFFD command
Figure 63   Execution result of the DSPFFD command

To clear the execution result, click on … to the left of the cell whose result is displayed. and select Clear cell output.

Next, let’s look at the contents of the data using an SQL SELECT statement. First, click on the + code in the upper left corner to insert another block. Next, change the lower right to SQL and enter and execute a SELECT statement (Figure 64).

Figure 64  Executing a SELECT statement in SQL
Figure 64   Executing a SELECT statement in SQL

The expected display was not achieved in this environment, as DBCS fields were concatenated internally when adjacent. Still, it could be used for simple data checking and maintenance purposes.

In addition, a block for writing Markdown can be added to this note (Figure 65).

Figure 65   Writing Markdown
Figure 65  Writing Markdown

Add a Markdown block like this, fill in the title and text in Markdown notation, and click the check mark with an arrow to display the formatted version (Figure 66).

Figure 66  After Markdown finalization
Figure 66   After Markdown finalization

Like the source code, this note can be saved remotely or locally, so it can be opened at any time to execute commands or SQL statements. If you register the ones you use frequently, you can work on them.

You can use it as a notepad for development using Markdown notation or share it with Git to create test procedures or store simple program specifications. This extension is handy, and we hope you will make use of it.

 

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/

新着