User:Rogueai

From Try-AS/400
Jump to navigation Jump to search

This page currently serves as my "braindump" to keep track of various findings while I explore the AS/400 world.

All the information available here is tested on the machine available to me: AS/400 9406-170 V4R2

Screenshot script for tn5250j

While researching and trying out new things, I often find myself taking screenshots or saving the screen content as text. To ease this process I wrote a simple jython script that can be used with tn5250j.

The script saves the current screen as both a txt and a png file.

The script must be placed inside $HOME/.tn5250j/scripts as a python source file, e.g.: myScript.py. It can then be referenced from the "Macros" menu. A keybind can also be assigned to further ease the process.

Currently, output files are stored in $HOME/Documents/as400/screens, with the file names being in the format screen-<yyyyMMdd-HHmmss>.[txt|png]. I'd suggest reviewing the script and customizing it to your liking before running it for the first time.

from org.tn5250j.tools.encoder import EncodeComponent

from java.text import SimpleDateFormat
from java.util import Date
from java.lang import String
from java.lang import StringBuffer
from java.lang import System
from java.io import File

def fillBuffer(screen, sb):
    chars = screen.getScreenAsChars()
    c = screen.getColumns()
    l = screen.getRows() * c

    x = 0
    y = 0
    while x < l:
        sb.append(chars[x])
        if y == c - 1:
            sb.append('\n')
            y = 0
        else :
            y += 1
        x += 1

print "--------------- tn5250j printScreen script start ------------"

home = System.getProperty("user.home")
filename = 'screen-' + SimpleDateFormat("yyyyMMdd-HHmmss").format(Date())
filepath = home + '/Documents/as400/screens/' + filename

screen = _session.getScreen()
sb = StringBuffer()

fillBuffer(screen, sb)

screen_txt = open(filepath + '.txt','w')
screen_txt.write(sb.toString())
screen_txt.close()

screen_png = open(filepath + '.png','w')
EncodeComponent.encode(EncodeComponent.PNG, _session, screen_png)
screen_png.close()

print "---------------- tn5250j printScreen script end -------------"

JTOpen/jt400

This is a short list of notes about IBM' open source project JTOpen aka jt400.

JTOpen is the open source software product known as the "IBM Toolbox for Java." It is also commonly referred to "jt400" or simply "the toolbox." In short, this package provides a set of Java classes that enable applications to integrate with IBM i

The project's readme reports compatibility between different version of OS/400 as follows:

Toolbox                         Installs on     Connects to
release         LPP release     OS/400 version  OS/400 version
-------         --------------  --------------  --------------
V4R2            5763JC1 V3R2M0  V3R2 and up     V3R2 and up
V4R3            5763JC1 V3R2M1  V3R2 and up     V3R2 and up
V4R4            5769JC1 V4R2M0  V4R2 and up     V4R2 and up
V4R5            5769JC1 V4R5M0  V4R3 and up     V4R2 and up
V5R1            5722JC1 V5R1M0  V4R4 and up     V4R3 and up
V5R2            5722JC1 V5R2M0  V4R5 and up     V4R5 and up
V5R3(*)         5722JC1 V5R3M0  V5R1 and up     V5R1 and up
V5R4(**)        5722JC1 V5R4M0  V5R2 and up     V5R2 and up
JTOpen 1.x      Not applicable  Not applicable  V4R3 and up
JTOpen 2.x      Not applicable  Not applicable  V4R4 and up
JTOpen 3.x      Not applicable  Not applicable  V4R5 and up
JTOpen 4.0-4.2  Not applicable  Not applicable  V4R5 and up
JTOpen 4.3-4.7  5722JC1 V5R3M0  V5R1 and up     V5R1 and up
JTOpen 4.8+     5722JC1 V5R4M0  V5R2 and up     V5R2 and up
JTOpen 6.1+     5761JC1 V6R1M0  V5R3 and up     V5R3 and up
JTOpen 7.0+     5770SS1 V7R1M0  V5R4 and up     V5R4 and up

(*)  Note: Toolbox release V5R3 is equivalent to JTOpen 4.3.
(**) Note: Toolbox release V5R4 is equivalent to JTOpen 4.8.

The project was originally named "Java Toolbox", and later open sourced and rebranded as JTOpen 1.x. The readme seems to imply that JTOpen (the open source version) has never been compatible with V4R2, however tn5250j is currently using JTOpen 10.5 and it seems to be working.

The reason could be that jt400 is actually a collection of modules, and tn5250j might be using only part of them. As a counter example, the latest ACS uses JTOpen 11.5 and doesn't work on V4R2, attempting to connect would fail. Tests on that side have pointed out to a possible change in the way JDBC connections are established.

The latest known version of JTOpen that's able to establish a JDBC connection is 5.3, as verified by running this simple JUnit test:

public class JDBCTest {

    @Test
    public void test() throws SQLException {
        AS400JDBCDriver driver = new AS400JDBCDriver();
        DriverManager.registerDriver(driver);
        Connection connection = DriverManager.getConnection("jdbc:as400://hostname", "user", "pass");
    }

}

Running this test using JTOpen 5.4 against V4R2 will result in a "General security error", which is the same error you'd get when trying to start a 5250 session on ACS.

Specifically, the AS/400 returns a: SQL state 08004: The application server rejected establishment of the connection.[1]

Cannot perform CHGNETA due to active APPC

I got this error when trying to change my system's name from CHGNETA.

According to: QILANM3601 Controller Description (archive: [2])

QILANM3601 controller description can cause some problems with the system. QILANM3601 is no longer supported and should be deleted.

For my use case I decided to just disable it for the time being:

  • WRKCTLD
  • Locate QILANM3601 *APPC
  • 8, 2

Footnotes