vscode-ibmi
vscode-ibmi copied to clipboard
Object Browser does not support libraries located on iASP when not set on the user profile
Describe the bug Trying to browse a library location on an iASP does not work. After the filter is created, expanding it crashes with CPF3064. This is due to CL commands (i.e. DSPOBJD) being run in QSHELL where every command runs in a new job...meaning that running SETASPGRP beforehand won't help π Setting the iASP in the connection's settings doesn't help either.
To Reproduce Steps to reproduce the behavior:
- Go to 'Object Browser'
- Create a new filter
- Use a library located on an iASP
- Save the filter
- Expand the filter
- Kaboom π₯
Expected behavior Being able to browse a library on an iASP.
Environment
- Extension version : master branch π
- IBM i OS version : 7.3 and 7.4
Based on this comment: https://github.com/halcyon-tech/vscode-ibmi/issues/885#issuecomment-1263399051
Try changing your JOBD to set the initial ASP and then restart your connection in Code for IBM i.
Of course, changing the JOBD does the trick. It's just that sometimes, it's not an option (from my personal experience) and users rely entirely on the product/client configuration. I have to deal with IASPs issues on a...regular basis...so I know where it hurts π It's a very powerful feature but man, supporting it is an ordeal sometimes.
Now, since everything in Code for IBM i goes through SSH, you're not left with many options either. But here's an idea: since you already upload and a program (GENCMDXML), you could upload a little command as well that would go like this:
CMD
CMD PROMPT('Execute command on IASP')
PARM KWD(CMD) TYPE(*CHAR) LEN(10000) VARY(*YES *INT2) +
PROMPT('Command') MIN(1)
PARM KWD(IASP) TYPE(*CHAR) LEN(10) PROMPT('IASP (optional)')
CL
PGM PARM(&in_COMMAND &in_IASP)
DCL VAR(&in_COMMAND) TYPE(*CHAR) LEN(10002)
DCL VAR(&in_IASP) TYPE(*CHAR) LEN(10)
DCL VAR(&w_COMMAND) TYPE(*CHAR) LEN(10000)
DCL VAR(&w_LENGTHA) TYPE(*CHAR) LEN(2)
DCL VAR(&w_LENGTH) TYPE(*DEC) LEN(15 5)
IF COND(&in_IASP *NE ' ') THEN(SETASPGRP ASPGRP(&in_IASP))
CHGVAR VAR(&w_LENGTHA) VALUE(%SST(&in_COMMAND 1 2))
CHGVAR VAR(&w_LENGTH) VALUE(%BIN(&w_LENGTHA))
CHGVAR VAR(&w_COMMAND) VALUE(%SST(&in_COMMAND 3 10000))
CALL QCMDEXC PARM(&w_COMMAND &w_LENGTH)
ENDPGM
I know it's not ideal, but it might do the trick.
My two cents π
While this is a good idea, I am scared to add this additional dependancy to Code for IBM i (e.g. the additional program which would have to be installed during the connection stage).
@chrjorgensen It's likely important you see this idea from @sebjulliand since you're pretty familiar with the ASP stuff going on.
I personally would be more interested in changing the user job description automatically when the user changes ASP inside of Code for IBM i, which would then take immediate affect on the commands executed after that. It's the least impactful (in terms of system requirements)
SΓ©bastien, please also review these ideas from Christian. It's likely we will need to merge ideas to get this to work correctly.
@sebjulliand @chrjorgensen
Trying to browse a library location on an iASP does not work.
Can we get around this if we start to use SQL instead of the CL commands in IBMiContent#getObjectList?
@worksofliam @sebjulliand
Can we get around this if we start to use SQL instead of the CL commands in
IBMiContent#getObjectList?
No, sorry - SQL can not get around the iASP issue, it's merely another way for retrieving the same data. It can't see schemas or objects in schemas residing on iASP if the ASP group is not set for the job.
One way to overcome the problem is to go with the original idea from @sebjulliand about a program to run the command for the iASP. It should be more refined, of course, with more error detection and forwarding. And by the way, the max length for a CMD *CHAR is 5000 bytes, but a *CMDSTR can be 20000 bytes. π
We could also use a SQL stored procedure for this - but the same applies, it must be build on the system. It is however more flexible than a CL program, IMHO.
A third solution could be to make use of bash and the fact, that IBM has provided new bash builtins, including a cl function which is modeled after the PASE system command, but can run the CL command in the same thread. So using bash we can set the ASP group and run a CL command from the SSH job.
@chrjorgensen you should also know, the program we use to run SQL statements can also accept an ASP name (or number? One of them), so that statements run using that ASP group.
Based on #2339, we won't allow the user to change the ASP in Code for IBM i, and will inherit it based on the job. Closing this now.