2009 Mar 11 12:44 PM
Hi everybody,
I am wondering if somebody can help me with a problem I have using read report and insert report. I am going to try to explain the problem I have.
In the program I am doing I have to calculate a formula that is changing all the time so what I did was to create a program that is change the whole time with the new formula that must be calculated.
1) First I read the program with READ REPORT 'ZXXX' INTO itab.
2) Then I change the lines of itab writing what I want for example:
FUNCTION ZZCASHM_CALCULATE.
*"----
""Local interface:
*" CHANGING
*" REFERENCE(RES) TYPE ZZRESULT
*"----
res =
*START
10
/
5
*END
.
ENDFUNCTION.
3) Next step is to insert this report so I use INSERT REPORT 'ZXXX' from itab.
4) I call the function module and the calculation is done.
This process is in a loop so I change the formula all the time and I should receive different values but the error I am getting is the first time the calculation is ok, so in the example I would get 2 as a result. Next loop I change the formula so now can be something like 2 + 5, when I am debugging I see that read and insert are working fine because when I am in the Function Module the text change and I have the new formula but when the calculation is done I always get the result of the first operation (10 / 5), that is 2.
Does anybody know if I need to refresh memory or activate or something like that?
I have delete the program after reading and then created again but I always get the result of the first operation, I have also add to insert status 'A', to activate it but nothing change.
Thanks in advance,
Alejandro
2009 Mar 11 12:50 PM
2009 Mar 11 12:54 PM
READ REPORT 'LZZCASHMU30' INTO t.
LOOP AT t INTO st_aux.
* Search for start
IF start NE 'X'.
IF st_aux EQ '*START'.
start = 'X'.
APPEND st_aux TO t2.
CONTINUE.
ELSE.
APPEND st_aux TO t2.
CONTINUE.
ENDIF.
ENDIF.
* write new formula
IF start EQ 'X' AND insert NE 'X'.
LOOP AT it_calc INTO is_calc.
st_aux = is_calc-field.
APPEND st_aux TO t2.
ENDLOOP.
insert = 'X'.
CONTINUE.
ENDIF.
* delete everything till end.
IF end NE 'X'.
IF st_aux EQ '*END'.
end = 'X'.
APPEND st_aux TO t2.
CONTINUE.
ENDIF.
ENDIF.
* write the rest of the FM
IF end EQ 'X'.
APPEND st_aux TO t2.
ENDIF.
ENDLOOP.
INSERT REPORT 'LZZCASHMU30' FROM t2.
<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
CALL FUNCTION 'ZZCASHM_CALCULATE'
CHANGING
res = lv_res.
.
This is in a loop, so all the time I am changing this, but everytime I a trying to get lv_res is the same even the code inside 'ZZCASHM_CALCULATE' is different
Edited by: Matt on Mar 11, 2009 2:41 PM - added tags
2009 Mar 11 12:56 PM
After the Processing the first time....Clear the work area everytime from where you are making the changes.
Clear: <Work Area>.
Hope this resolves your problem.
LOOP AT it_calc INTO is_calc.
st_aux = is_calc-field.
APPEND st_aux TO t2.
ENDLOOP.
I thing the Issue is wit the above Loop...Its always reading the same records.
Just debug and check.
Regards,
Gurpreet
Edited by: Gurpreet Singh on Mar 11, 2009 2:12 PM
2009 Mar 11 12:56 PM
Hi,
Clear the field which is changing every time the loop executes.
Because after first time the same value is stored and you will get same result every time.
Regards
2009 Mar 11 1:06 PM
Hi thanks, I have already tried that. The problem is inside the function module, after the first time is run always give same result. For example the first time was:
FUNCTION ZZCASHM_CALCULATE.
*"----
""Local interface:
*" CHANGING
*" REFERENCE(RES) TYPE ZZRESULT
*"----
res =
*START
10
/
2
*END
.
res
ENDFUNCTION.
and the second time I debug the function module and now it is something like this:
FUNCTION ZZCASHM_CALCULATE.
*"----
""Local interface:
*" CHANGING
*" REFERENCE(RES) TYPE ZZRESULT
*"----
res =
*START
100
/
25
*END
.
res
break-point.
ENDFUNCTION.
I debug this part, and when I arrive to the breakpoint I expect 4 because of 100/25 but what I am getting in res inside the function module is the result of the first operation 5 (10/2). I tried to clear inside, outside but it doesn't work it is like the system is using the old function module even when you debug it is different
2009 Mar 11 1:13 PM
use this fm
REPS_OBJECT_ACTIVATE
to activate ur FM, try this after ur insert report statement
or even activate the entire function group and see if it works or not.
кu03B1ятu03B9к
Edited by: kartik tarla on Mar 11, 2009 6:44 PM
2009 Mar 11 1:35 PM
Thanks kartik,
it is weird but it doesn't work activating the function module or the function group. I have also tried to read deleta and then insert but the value it is still there, there is no change.
2009 Mar 11 1:45 PM
Have you tried GENERATE REPORT after the insert? You might also consider using the STATE extensions of READ/INSERT REPORT.
matt
2009 Mar 13 1:58 PM
Hi,
thanks for the reply. I have tried to generate it but it doesn't work, the function module is always different as I want but the calculation is always the same, the one that was obteined the first time the function module was processed
2009 Mar 30 12:35 PM
Hi,
thanks very much to all. I solved the problem but using an static function that was calculating the formulas I had to. It wasn't the best solution but it worked. The solution changing the code is very slow and due to performance issues I had to create a program just to calculate.
Thanks very much to all