I tried node-jt400 (Programs)

Programs Let's call the program.

CLLE (no parameters)

Try CALL a simple CL program with no parameters.

MYLIB/SMPL010C.CLLE


             PGM                                                     
             SNDMSG MSG('SMPL010C was called') TOMSGQ(*SYSOPR)  
             ENDPGM                                                  

Programs.JS


app.get("/smpl010c", function (req, res, next) {
  var SMPL010C = pool.pgm('SMPL010C', []); 
  SMPL010C({}).then(
    function (result) {
      res.send(result);
    });
});

There is one restriction on calling a program. That is, ** there is always a program to execute in the library list **. The following were all NG.

var SMPL010C = pool.pgm('MYLIB/SMPL010C', []); 
var SMPL010C = pool.pgm('MYLIB.SMPL010C', []); 
var SMPL010C = pool.pgm('/QSYS.LIB/MYLIB.LIB/SMPL010C.PGM', []); 

nodejt16.png

nodejt17.png

RPGLE (with parameters)

Try to CALL RPGLE with parameters.

MYLIB/SMPL011R.SQLRPGLE


      *                                                                            
      * CRTSQLRPGI OBJ(MYLIB/SMPL011R) SRCFILE(MYLIB/QRPGLESRC) DBGVIEW(*SOURCE)
      *                                                                            
     H DFTACTGRP(*NO)                                                              
     D main            PR                  EXTPGM('SMPL011R')                      
     D                                3P 0                                         
     D                               12A                                           
     D                               12A                                           
     D                               40A                                           
     D                                7P 3                                         
     D main            PI                                                          
     D id                             3P 0                                         
     D lname                         12A                                           
     D fname                         12A                                           
     D prof                          40A                                           
     D tokuten                        7P 3                                         
                                                                                   
     D stmt            S            512A                                           
     /free                                                 
                                                           
         stmt = 'insert into member' +                     
                ' values(?, ?, ?, ?, ?)';                  
         exec sql prepare s1 from :stmt;                   
                                                           
         exec sql execute s1                               
               using :id, :lname, :fname, :prof, :tokuten; 
                                                           
         tokuten = tokuten + 100;                          
                                                           
         *inlr = *on;                                      
                                                           
         return ;                                          
                                                           
     /end-free                                             

Programs.JS


app.get("/smpl011r", function (req, res, next) {
    var SMPL011R = pool.pgm('smpl011r', [
        { type: 'DECIMAL', precision:  3, scale: 0, name: 'id' },
        { type: 'CHAR',    precision: 12, scale: 0, name: 'lname' },
        { type: 'CHAR',    precision: 12, scale: 0, name: 'fname' },
        { type: 'CHAR',    precision: 40, scale: 0, name: 'prof' },
        { type: 'DECIMAL', precision:  7, scale: 3, name: 'tokuten' }
    ]);
    SMPL011R({
        id: 120,
        lname: 'Date',
        fname: 'Masamune',
        prof : 'Appeared in white costume.',
        tokuten: 10
    }).then(function (result) { 
      res.send(result); 
    });
});

However, this program does not work properly. When I debugged SMPL011R to investigate the cause, I found that the Japanese parameters were not passed correctly. nodejt18.png

nodejt19.png

Java source modification of node-jt400

So, I will try to fix the Java source of node-jt400. Get the source from github.

git clone [email protected]:tryggingamidstodin/node-jt400.git mynode-jt400

nodejt20.png

The source to be modified is \ java \ src \ nodejt400 \ Pgm.java.

Pgm.java


  public TextPgmParam(String name, Props paramDef)
  {
    super(name, paramDef);
    parser = new AS400Text(paramDef.getFirstInt("size", "precision"), "Cp871");
  }

Cp871 seems to be doing something wrong, so I did the following:

Pgm.java


  public TextPgmParam(String name, Props paramDef)
  {
    super(name, paramDef);
    parser = new AS400Text(paramDef.getFirstInt("size", "precision"));
  }

After modifying the source, create a new jt400wrap.jar and replace jt400wrap.jar in \ myfolder \ node_modules \ node-jt400 \ java \ lib.

I ran it again and debugged it in the same place. This time the parameters are passed correctly.

nodejt22.png

The parameter "tokuten" has been added 100. It seems that the return value is also taken.

nodejt23.png

nodejt24.png

The poster does not take any responsibility for the source modification. Please do so at your own risk.

Added on December 28, 2017 I put the pre-built jt400wrap.jar in here.

Recommended Posts

I tried node-jt400 (Programs)
I tried node-jt400 (execute)
I tried node-jt400 (Transactions)
I tried node-jt400 (Environment construction)
I tried node-jt400 (IFS write)
I tried node-jt400 (SQL Update)
I tried node-jt400 (SQL query)
I tried node-jt400 (SQL stream)
I tried node-jt400 (IFS read)
I tried Spring.
I tried tomcat
I tried youtubeDataApi.
I tried refactoring ①
I tried FizzBuzz.
I tried JHipster 5.1
[I tried] Spring tutorial
I tried running Autoware
I tried QUARKUS immediately
I tried using TestNG
I tried Spring Batch
I tried using Galasa
I tried DI with Ruby
I tried using azure cloud-init
I tried Spring State machine
I tried Drools (Java, InputStream)
I tried Rails beginner [Chapter 1]
I tried the Docker tutorial!
I tried using Apache Wicket
I tried the VueJS tutorial!
I tried using Java REPL
I tried source code analysis
I tried the FizzBuzz problem
I tried putting XcodeGen + SwiftPM
I tried Rails beginner [Chapter 2]
I tried UPSERT with PostgreSQL.
I tried BIND with Docker
I tried to verify yum-cron
I tried Jets (ruby serverless)
I tried metaprogramming in Java
I tried using anakia + Jing now
I tried to chew C # (indexer)
I tried something called recursive search
I tried using Spring + Mybatis + DbUnit
I tried using JOOQ with Gradle
[K8s] I tried communication between pods!
I tried morphological analysis with MeCab
I tried a little digdag docker.run_options
I tried to summarize iOS 14 support
I tried to interact with Java
I tried UDP communication with Java
I tried to explain the method
I tried putting Domino11 in CentOS7
I tried using Java8 Stream API
I tried Java's micro-benchmark tool JMH
I tried using JWT in Java
I tried GraphQL with Spring Boot
I tried to summarize Java learning (1)
Collatz number, Fibonacci number, triangular number I tried to make various sequence programs
I tried to understand nil guard
[Android] I tried using Coordinator Layout.
I tried installing CentOS 8 on ESXi 6.7