PDA

View Full Version : Getting a procedure pointer problem - Help



B.Morris
03-14-2002, 12:25 PM
I glanced at your code, and I noticed that you're passing a 2A by value for the rslvsp _OBJ_TYPE_T parameter. That parameter is actually an integer type. When a function expects an integer/float/pointer by value, you can't pass a character type even if it's the same length. Try defining all those 2A parameters as 10i 0. You can use still use x'nnn' values to set the 10i parameters, or pass the x'nnn' values directly. Even if those parameters are defined as short (2-byte) integers, you must pass them from RPG as 4-byte integers. This is because of a C concept called "parameter widening" where all integer types shorter than 4 bytes get passed (and expected) as 4 bytes, and all float types shorter than 8 bytes get passed/expected as 8 bytes. If you are on V5R1, you can get RPG to handle the widening for you by coding EXTPROC(*CWIDEN : 'name'). Look here for a working example of using those or similar functions to get a procedure pointer from a service program: http://www.iseriesnetwork.com/Resources/ClubTech/TNT400/bo400ng/ilerpgmodule.htm

Guest.Visitor
03-15-2002, 04:52 AM
This will basically do everything that I need all in one Proc right? Basically what I want to do is to activate the service program and get the proc pointer so I can call it will out having to recompile all the programs thar use the proc. I think this is exactly what I am after isn't it? Trev

Guest.Visitor
03-15-2002, 05:34 AM
Hello, I used the code example that you gave me, and I am still getting an error that the pointer is not set on my call. Do you have any other thoughts as to what I might be doing wrong? I can't wait to get this all working, I think it makes maint. SOOO much easier this way. Thanks again for all the help, Trev

B.Morris
03-15-2002, 09:55 AM
Trevor, I just tried that code again and it worked ok for me. Have you stepped through it in the source debugger? Are you sure the service program is exporting that procedure? ===> DSPSRVPGM DETAIL(*PROCEXP))

B.Morris
03-15-2002, 10:01 AM
Trev, I'm just curious what you're doing here. Are you avoiding signature errors, or have you changed which service program a procedure is in? Normally this technique is used to dynamically select which of several service programs a procedure will come from. (Say you have one service program for each division with division-specific routines.) Trevor Price wrote: > > This will basically do everything that I need all in one Proc right? Basically what I want to do is to activate the service program and get the proc pointer so I can call it will out having to recompile all the programs thar use the proc. I think this is exactly what I am after isn't it? > > Trev

Guest.Visitor
03-15-2002, 11:01 AM
Basically what I am after is to make maint. easier on myself. I want to be able to change a procedure within a service program, and then put it out there and envoke it w/o having to recompile all of the apps that use the procedure that was changed. Isn't this the way I would accomplish this? I want to specify the service program that holds the proc, activate it and then return the proc pointer and call it. Does this make sense?

Guest.Visitor
03-15-2002, 11:04 AM
Hello all, I am currently dinking around with the activation of a service program then returning a specific proc's pointer. I am having a bit of trouble everything that I can see looks ok, but I always come back the a *null value in which I initialized it to. Here is the code I used, and was wondering if anyone could help me figure this out. http://home.xtra.co.nz/hosts/eggyolk/qrpglesrc/index.html It seems to be activating the service program, at least I think it is anyway, I don't know much about this stuff yet. Maybe I just don't know what I need to be looking for as far as values passed back and forth between. Any help would be greatly appreciated.

Guest.Visitor
03-15-2002, 11:04 AM
As far as debugger goes, the code that you gave me I don't understand all that well to be prefectly honest. All of this stuff is fairly new to me so I am still trying to learn.

B.Morris
03-15-2002, 12:40 PM
If you change a service program procedure in a way that doesn't require a recompile (if you just change the logic) then you don't have to do anything to the calling programs anyway. You just update the service program and you're done.

B.Morris
03-15-2002, 12:52 PM
Just step (F10) through the procedure. After any call to a function called RSLVSP2 or RSLVSP4, do an EVAL of the first parameter; it should be set to some value that looks reasonable. For example, after one RSLVSP2, I EVAL LibPtr and see this: > EVAL libptr LIBPTR = SYP:BMORRIS :0401: :000000000 0000000 The final Procptr should look something like this: > EVAL procptr PROCPTR = PRP:D01EB2E8DB001D80 I'm just thinking that if you see where it's failing (the library, the srvpgm, the procedure), you may be able to guess what's going wrong. If everything up to the GetExport looks good, and the service program is exporting the exact name you are specifying as the procedure, then ... well, I have no idea what's going wrong. Ohhhh ... maybe you're specifying the procedure name with the wrong case. If you coded your D spec like this, without any EXTPROC D myproc PR then the name of the procedure is 'MYPROC', not 'myproc'. Hmm, another problem could maybe be that you have trailing blanks in your procedure name. I suppose it should do a %TRIM on the procedure name: C CALLP GetExport(ActMark : 0 : C %len(%trim(Procedure)) : %trim(Procedure) : C ProcPtr : ExportType : C ErrCode)