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

*OMIT not supported #343

Closed
GajenderI opened this issue Jul 7, 2022 · 28 comments · Fixed by #346
Closed

*OMIT not supported #343

GajenderI opened this issue Jul 7, 2022 · 28 comments · Fixed by #346
Labels
enhancement New feature or request

Comments

@GajenderI
Copy link
Contributor

What if the RPG program has a *omit param and I want to specify that in the addParm and also not pass any value to it.

Describe the solution you'd like
omit should be supported

Describe alternatives you've considered
None

Additional context
In the XMLSERVICE documentation we can see that a param option io can have values 'in|out|both|omit' but the itoolkit document says io (string()) – Valid values are in, out, or both.
https://nodejs-itoolkit.readthedocs.io/en/latest/ProgramCall.html#parameterConfig
https://xmlservice.readthedocs.io/en/latest/functions.html#pgm

@GajenderI GajenderI added the enhancement New feature or request label Jul 7, 2022
@alanseiden
Copy link
Contributor

We will look into *OMIT since XMLSERVICE supports it.

@abmusse
Copy link
Member

abmusse commented Oct 13, 2022

Yes the documentation needs to be updated to include *OMIT as a valid option.
As the code is written passing *omit as io should still get passed through though.

if (parameter.io) { this.xml += ` io='${parameter.io}'`; }

@GajenderI
Copy link
Contributor Author

GajenderI commented Oct 14, 2022

@alanseiden Thank you for considering this.
@abmusse Thank you for the pointing that out, I did try this but was getting some unexpected error. It was months ago so dont remember that exactly but I was not able to make this work.

@alanseiden
Copy link
Contributor

@GajenderI Please try omit again, if you still have your program available, and let us know how it goes. If you get an error, please tell us the specific error. We may still change the documentation to allow the omit option.

@alanseiden
Copy link
Contributor

We have created a PR to update the documentation after testing 'omit' in XMLSERVICE: #346

@GajenderI
Copy link
Contributor Author

GajenderI commented Nov 3, 2022

@alanseiden please have a look at the xml going in, what should I send in place of data if I want the parameter to be omitted?
the program to be called has PR

dcl-pi mypgm;                           
 input          Char(15) options(*omit); 
 output         Char(16);                    
end-pi;                                      
<?xml version='1.0'?><xmlservice><pgm name="simpleomit" lib="mylib"><parm name="input" io="omit"><data type="15A">?</data></parm><parm name="output"><data type="16A"></data></parm></pgm></xmlservice>
`

@alanseiden
Copy link
Contributor

@GajenderI here is what we found so far:

  • the ZZOMIT unit test works correctly.
  • Your program test does not fully work (we replicated your results). The parameter comes in blank (good), but is not equal to a null pointer (bad).

The difference may be that ZZOMIT is a service program. We are looking at why this may matter. XMLSERVICE has a different code path for service program procedures.

@GajenderI If you have time, try making your program into a service program with a procedure having the *OMIT and let us know if that makes a difference.

@alanseiden
Copy link
Contributor

We should create a new issue about your specific test rather than adding to this closed issue that was about documentation.

@sagartyagi121
Copy link

Thank you very much @alanseiden for taking the effort. I will test it by making it a service program and let me know how else I can help in this.

@sagartyagi121
Copy link

@amagid please have a look at this issue.

@JonFP
Copy link

JonFP commented Nov 5, 2022

The difference may be that ZZOMIT is a service program. We are looking at why this may matter. XMLSERVICE has a different code path for service program procedures.

The mechanism the system uses for program parameters and procedure parameters is radically different Alan so this is hardly surprising. Parms for procedures (regardless of whether local/bound/or service program) are pushed on the stack. So to get the effect of *Omit a null pointer has to be pushed on the stack. For program calls the parm pointers are passed to the system and retrieved basically by calling an internal API. So radically different code paths.

@kadler
Copy link
Member

kadler commented Nov 7, 2022

We should create a new issue about your specific test rather than adding to this closed issue that was about documentation.

If this can be replicated outside of nodejs-itoolkit using raw XML to XMLSERVICE, then it's likely an XMLSERVICE issue and an issue should be opened there.

@brandonp42
Copy link

@kadler It is a XMLSERVICE issue and I'm hoping to submit a PR for it later this week, but it might only be for the mode="opm" path. The mode="ile" code path that does PASE stuff is quite a bit more complicated at first glance.

@brandonp42
Copy link

I just realized that I'm not seeing a way with the nodejs-itoolkit to specify that a program call should be mode="opm" vs mode="ile". So if I only fix the mode="opm" path in XMLSERVICE then there's still going to be a problem because it seems to default to the mode="ile" handling. If I'm correct would @sagartyagi121 or @amagid be willing to submit a PR adding that ability here?

@JonFP
Copy link

JonFP commented Nov 7, 2022 via email

@brandonp42
Copy link

@JonFP I'm not in the debugger right now but here's my recollection from Friday. It is pretty challenging to follow the code path through and ultimately I had to just walk through the debugger to see it.

<pgm mode="ile"> *PGM - https://github.com/IBM/xmlservice/blob/master/src/plugpase.rpgle#L1526
<pgm mode="opm"> *PGM - https://github.com/IBM/xmlservice/blob/master/src/plugile.rpgle#L4293
<pgm mode="ile"> *SRVPGM - https://github.com/IBM/xmlservice/blob/master/src/plugpase.rpgle#L1634
<pgm mode="opm> *SRVPGM - https://github.com/IBM/xmlservice/blob/master/src/plugile.rpgle#L4366

You can see that for the mode="ile" path via PASE it's using Qp2CallPase for both *PGM and *SRVPGM objects, but mode="opm" is using _CALLPGMV for *PGM objects and a semi-generic prototype with procedure pointer for *SRVPGM function calls. I suspect the prototype might not work correctly for parameters passed by value but I haven't tried to test that yet.

Also from the XMLSERVICE documentation at https://xmlservice.readthedocs.io/en/latest/functions.html#xmlservice-call-pgm note that the ILE vs OPM doesn't seem to be what you might think at face value (it wasn't what I thought):

*  mode
*     ile     - ILE and PASE memory (default)
*     opm     - ILE only memory (PASE can not view)

@JonFP
Copy link

JonFP commented Nov 7, 2022 via email

@brandonp42
Copy link

Honestly I don't understand why there's the two code paths either. There seems to be reasons based on internal operating system architecture that I'm not sure if anybody outside of IBM really knows well.

At the end of the day though, fixing the PLUGILE ilePGM() & ileSRV() for *OMIT parameters seems somewhat straightforward since it just needs to go through argv backwards instead of forwards. I'm trying to confirm if you can count on all of those pointers having been reliably initialized since it isn't being done in the PLUGILE module. If the memory is only allocated one by one then going backwards through argv in a simplistic fashion won't work. Or maybe there's a count of parameters somewhere that can be grabbed instead of walking through argv.

Fixing *OMIT for PLUGPASE *PGM objects might be possible for me, not sure if I'm going to try yet. It does seem to work for *SRVPGM objects already. I'm almost certainly not going to try to fix the %PARMS issue in the PLUGPASE code though. I strongly think IBM needs to address that part.

@alanseiden
Copy link
Contributor

Tony meant OPM mode to mean using the pre-6.1 memory model. We called it the "v5r4" flag in the PHP toolkit :)

@alanseiden
Copy link
Contributor

I found an old email discussion with Tony about *OMIT and OPM / "v5r4" mode. I'll forward it to Kevin, Brandon, Jon, and anyone else interested. It refers to a discussion on the old Zend forum that Zend later deleted, but you can get the main idea from the emails.

@brandonp42
Copy link

Oh cool, I will look for that.

FWIW there's also the newer JSON based iService (https://github.com/IBM/iService-ibmi) but I don't think it supports all the features yet.

@alanseiden
Copy link
Contributor

And "Technically, mode='opm' uses non-teraspace memory compatible both ILE and OPM calls (theory)." I'll forward that one as well.

@brandonp42
Copy link

I've submitted my PR for mode="opm" at IBM/xmlservice#64

@kadler
Copy link
Member

kadler commented Nov 10, 2022

Yeah, XMLSERVICE code and options are very obtuse and confusing with overloaded meanings. I did not realize there was this split in opm/ile behavior. We consciously do not make visible all the XMLSERVICE options because of this problem. I do recall having discussions with @abmusse about mode=opm/ile and deciding not to allow it. Because of this issue, we might need to do something about it, though I'd prefer to make it somewhat sensibly instead of just passing through the XMLSERVICE option to the user.

@alanseiden
Copy link
Contributor

I'll search my notes for one or two other situations where OPM mode is useful.

@kadler
Copy link
Member

kadler commented Nov 10, 2022

I have no idea why Tony made the decision to call through PASE for program calls when CALLPGMV works great from ILE. In fact, _PGMCALL is deficient in that it requires a null-terminated list of arguments, meaning you cannot pass null pointer arguments in the middle of the list (*OMIT parameters won't work!).

Calling in to PASE to call ILE service programs does make sense, because there is no generic way to dynamically call all types of ILE service program functions from within ILE. There is QZRUCLSP but it only supports up to 248 arguments and those arguments can only be a pointer or a 32-bit integer by value. There's no support for passing floats, decfloats, or any other size integers. However, basically any function can be called using _ILECALLX in PASE.

@brandonp42
Copy link

@kadler is there any way to get _ILECALLX to generate the operational descriptor that RPG needs for %PARMS? See the issue I opened for more details at IBM/xmlservice#62

I'd be happy to add more commentary there if it would help, I've learned a lot more about the XMLSERVICE code this week since creating that.

@kadler
Copy link
Member

kadler commented Nov 16, 2022

@kadler is there any way to get _ILECALLX to generate the operational descriptor that RPG needs for %PARMS?

No, this is not supported in PASE. There's an Idea to add support, though: https://ibm-power-systems.ideas.ibm.com/ideas/IBMI-I-3080

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

7 participants