Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow changing the iASP from Code for IBM i #941

Closed
sebjulliand opened this issue Nov 3, 2022 · 7 comments
Closed

Allow changing the iASP from Code for IBM i #941

sebjulliand opened this issue Nov 3, 2022 · 7 comments
Labels
idea Feature suggestion

Comments

@sebjulliand
Copy link
Collaborator

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:

  1. Go to 'Object Browser'
  2. Create a new filter
  3. Use a library located on an iASP
  4. Save the filter
  5. Expand the filter
  6. 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
@worksofliam
Copy link
Contributor

Based on this comment: #885 (comment)

Try changing your JOBD to set the initial ASP and then restart your connection in Code for IBM i.

@worksofliam worksofliam added the discussion For questions label Nov 4, 2022
@sebjulliand
Copy link
Collaborator Author

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 😉

@worksofliam worksofliam added idea Feature suggestion and removed discussion For questions labels Nov 7, 2022
@worksofliam
Copy link
Contributor

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.

@worksofliam
Copy link
Contributor

worksofliam commented Feb 23, 2023

@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?

@chrjorgensen
Copy link
Collaborator

@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.

@worksofliam
Copy link
Contributor

@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.

@worksofliam worksofliam changed the title Object Browser does not support libraries located on iASP Object Browser does not support libraries located on iASP when not set on the user profile Aug 24, 2023
@worksofliam worksofliam changed the title Object Browser does not support libraries located on iASP when not set on the user profile Allow changing the iASP from Code for IBM i Nov 9, 2024
@worksofliam
Copy link
Contributor

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
idea Feature suggestion
Projects
None yet
Development

No branches or pull requests

3 participants