‎2010 Sep 17 11:36 AM
Hi all,
..so its my fist post here, this is a bit strange problem for me and maybe someone knows whats happening.
So I have in SAP Solution Manager a function module 'Z', which calls a standard SAP class CL_SPROJECT_SOLAR_BASE_REPORT, which in turn calls the standard function module 'SPROJECT_GET_ADMIMP_SCREEN_BP'.
During development, things worked fine, but now I run my Z-Program for more than one instance and even I do all FREE for the Class, apperently the function module SPROJECT_GET_ADMIMP_SCREEN_BP, which is called by the class CL_SPROJECT_SOLAR_BASE_REPORT, does not get it's variables from the global data of the function pool re-initialized, when it is called for the second, 3rd, ... time.
This is a bit strane behavior for me, I would have expected that variables in a function module (or even in the global data of that function pool) get re-initialized each time that function module is called ?
Actually, this is the only function in that function pool.
Well, if not, does anyone has an idea how I can get the variables of this module pool re-initialized between the calls ? More concrete, the global data of function pool SAPLSPROJECT_SOLAR_ADMEVAL_BP define:
DATA: g_v_with_var TYPE char1.
In the function module line 36 (no reference to g_v_with_var, no module call, no changes to g_v_with_var before the IF-statement at all) it is querying:
IF g_v_with_var IS INITIAL.
So this is my problem, the second time I am calling the class (which is 'free'ed and re-created between the calls) which calls this function module the 'g_v_with_var' is not initial and there seems to be no way to have it set to initial again ?
So even thought this is in SolMan, I think the question & problem is a ABAP technical one ?
Any thoughts, help or support would be very much appreciated,
thank so much,
Frank
‎2010 Sep 17 11:46 AM
Look in the function pool if there is a function to initialize the variables. Alternatively, look if there is a form routine that does the initialization. If either one exist, execute if for each instance.
‎2010 Sep 17 11:46 AM
Look in the function pool if there is a function to initialize the variables. Alternatively, look if there is a form routine that does the initialization. If either one exist, execute if for each instance.
‎2010 Sep 17 11:59 AM
Hi Mae,
..thanks a lot for your fast reply, unfortunately there is only one function and no functions or forms at all for initializing. The variable I am fighting with is g_v_with_var and that is referenced only 4 times in the whole function pool:
Global Data: 101 DATA: g_v_with_var TYPE char1.
Function Module SPROJECT_GET_ADMIMP_SCREEN_BP (which is the only function module):
36 IF g_v_with_var IS INITIAL.
127 g_v_with_var = airep_true.
193 CLEAR g_v_with_var.
If in line 36 g_v_with_var is 'X', which it is always after the first call, the function will exit with an exception, so line 193 to clear it will actually never be executed...and it is not cleared the next time the function module is called, so you never get back to have the function run...
All the best,
Frank
‎2010 Sep 17 12:10 PM
Hi,
try to create a class and create attributes which are all the values need to carry in multiple call.
create a method with initialze and in import parameters import the data from FM to class and pass it to attributes.
and in the next call of FM call the attribute directly if the variable is initial fill it from class.
Prabhudas
‎2010 Sep 17 12:13 PM
Then possibly using memory manipulation you could initialize the value.
There's a trick using a field-symbol to point to that variable in the functionpool. If you assign that vairiable to the fidl-symbol you might be able to clear the variable.
it goes somewhat like: (if you search the forum there should be some examples)
data: gv_field(100) type c.
field-symbols: <fs_field> type any.
gv_field = '(FUNCTIONPOOLNAME)variablename'.
assign (gv_field) to <fs_field>.
if <fs_field> is assigned.
<fs_field> = space.
endif.
‎2010 Sep 17 12:15 PM
Hi Prabhu,
..thanks a lot for the reply, in a worst case I may have to do that, but it is a lot of code, classes and functions from SAP I would have to replicate and usually I would rather not do so...
Thanks again,
Frank
‎2010 Sep 17 12:16 PM
well you COULD do dirty assigns on the fields you need to refresh and then refresh the assigned field symbols, but somehow i´m feeilng quite awkward by just thinking of it...
‎2010 Sep 17 12:40 PM
> well you COULD do dirty assigns on the fields you need to refresh and then refresh the assigned field symbols, but somehow i´m feeilng quite awkward by just thinking of it...
Couldn't agree more. When i use this trick i only do it when i need to read out a value that normally would not be available.
‎2010 Sep 17 8:22 PM
Hello, Maen,
..well, I do certainly agree about the concerns and reservations for this method, but it seems the only technical possible way and I really appreciate your solution very much !
Thank you so much for your help and support,
best wishes,
Frank
‎2010 Sep 17 8:26 PM
Hello Florian,
thanks a lot for your feedback, yes I agree about the reservations, just the only other option seem to be to completely restructure the whole application, because one data field is not properly initialized in a standard SAP function module.
So agreeing about concerns and reservations, maybe this solution may be at least in the short run the best, maybe SAP will fix that problem one day...anyhow I still wonder why the function module variables don't get initialized again with every all...
Thanks again and best wishes,
Frank
‎2010 Sep 17 12:33 PM
Hi,
Is the FM remote-enabled? If so, you could try calling the FM with DESTINATION 'NONE'. I think treating it like an RFC should cause a fresh memory area.
If it's not remote-enabled then I think you'd need to go with one of the earlier suggestions in this thread.
Regards, Andy
‎2010 Sep 17 8:27 PM
Hello, abapandy
..thanks a lot for your comment, actually I am not calling that FM in my program, but I call a standard SAP class, which in turn calls tht FM, so I don't really have that much flexibility...
Thanks again,
best wishes,
Frank
‎2010 Sep 17 1:24 PM
I do not expect, when I'm using multiple calls to an FM or FMs within a function group, that global data will be executed more than once. Therefore, I utilize local variable within the FM or within a routine that calls the FM as often as possible, or I add an initialization routine before each new set of FM calls. As programmers we know that, upon first call of an FM, the entire group is loaded into memory. I believe you'll find that's the only time the global data declarations are processed.
‎2010 Sep 17 8:28 PM
>
> I do not expect, when I'm using multiple calls to an FM or FMs within a function group, that global data will be executed more than once. Therefore, I utilize local variable within the FM or within a routine that calls the FM as often as possible, or I add an initialization routine before each new set of FM calls. As programmers we know that, upon first call of an FM, the entire group is loaded into memory. I believe you'll find that's the only time the global data declarations are processed.
Hi breakpoint,
...I couldn't agree more, for some reasons SAP seems not to have that FM made callable multiple times from one report..
Thanks a lot,
best wishes,
Frank
‎2010 Sep 17 8:29 PM
So, you are using a Z FM, which calls a standard class, which calls a standard FM.
Can you change the Z FM? If yes, I can think of two possibilities. No guarantee that either of them will work.
1) In the Z FM, destroy the class object after the use and re-instantiate the object every subsequent time. That will hopefully initialize the function group every time.
2) Make your Z FM remote enabled and make a remote function call every time you call the FM.