‎2007 Dec 28 9:00 AM
Hi Friends
I have a Performance Issue. That is, inside a loop...endloop a CALL FUNCTION has been used which gets data from another database table. Finally it's appended into another internal table. Please see this :
LOOP AT i_mdkp.
REFRESH lt_mdtbx.
CLEAR lt_mdtbx.
CALL FUNCTION 'READ_MRP_LIST'
EXPORTING
idtnum = i_mdkp-dtnum
icflag = 'X'
tables
mdtbx = lt_mdtbx
.
APPEND LINES OF lt_mdtbx TO i_mdtb.
ENDLOOP.
It happens for each record available in i_mdkp. Suppose, i_mdkp have around 50000 records, it needs to call the function module till that much time.
So, I want to split it. Can I?
Please give me your valueable suggestions.
Regards
Senthil
‎2007 Dec 28 9:04 AM
Hi
store the fm value results into the internal table and use that internal table instead of calling FM
Simply write the FM out side the loop store the result in one internal table and then
loop at that put read condition for that FM internal table
it will work fastly
‎2007 Dec 28 9:10 AM
> store the fm value results into the internal table and use that internal table instead of calling FM
that is exactly what this coding is doing!
There is no general answer, if the details of the function call are not known.
Try to change the function call so that it can work with the whole table i_mdkp and not only with one line!
Siegfried
‎2007 Dec 28 9:59 AM
Hi Siegfried
Thank you very much for your reply.
However, I couldn't get your answer.
Could you please explain me?
Senthil
‎2007 Dec 28 10:27 AM
Hi Senthil Vadivel,
He said to you change the usage, the calling of the FM.
With the currently usage, the FM return only one line. You need to get all values with only one call to get best performance. Try to do this, and post the results here.
Regards!
Try something like this:
CALL FUNCTION 'READ_MRP_LIST'
EXPORTING
idtnum = i_mdkp-dtnum
icflag = 'X'
tables
mdtbx = lt_mdtbx
.
LOOP AT i_mdkp.
REFRESH lt_mdtbx.
CLEAR lt_mdtbx.
APPEND LINES OF lt_mdtbx TO i_mdtb.
ENDLOOP.
I
Edited by: Rodrigo Paisante on Dec 28, 2007 8:29 AM
‎2007 Dec 28 10:55 AM
HI Rodrigo
The FM "'READ_MRP_LIST'" accepts the "dtnum" values one by one.
So, if I place the FM before the loop, it doesn't fetch any record and gives the runtime error.
could you please suggest me an alternative?
Senthil
‎2007 Dec 28 11:25 AM
Sorry friend but i haven't any sugestion. I dont know if exist other FM that you can use, to read all values.
Reading record by record, yes, you need to call the FM 50000 times. Thanks!
Rodrigo
‎2007 Dec 28 12:33 PM
if you can not change the function READ_MRP_LIST then you can not any better.
If you can change the function then you should program it in a way, that the function can take the whole table i_mdkp and not only lines of the table.
However, are you really sure that this is your performance issue?
Try the SE30, what is the total time of your program, how often is the function call and what is total time for the function and so on..
See how to use the SE30
/people/siegfried.boes/blog/2007/11/13/the-abap-runtime-trace-se30--quick-and-easy
Siegfried
‎2007 Dec 28 5:13 PM
I think you will have to debug FM READ_MRP_LIST and write some code yourself that does what the FM does, but for the entire internal table, not just one record of the table. For example, you may find that the FM does something like:
SELECT * FROM sometable
WHERE some_key = idtnum.You need it to do something like:
SELECT * FROM sometable
FOR ALL ENTRIES IN i_mdkp
WHERE some_key = i_mdkp-dtnum.Rob
‎2007 Dec 28 6:16 PM
If internal table i_mdkp has 50,000 records it does not mean that you need to run 50,000 iterations. You just need dtnum from internal table i_mdkp so you number of iterations should be eqaul to the unique number of dtnum in the internal table. Sort the internal table by dtnum and delete adjacent duplicates from the internal table comparing dtnum before looping. Look at the code below.
DATA i_mdkp_tmp LIKE TABLE OF i_mdkp.
IF NOT i_mdkp[] IS INITIAL.
i_mdkp_tmp[] = i_mdkp[].
SORT i_mdkp BY dtnum.
DELETE ADJACENT DUPLICATES FROM i_mdkp COMPARING dtnum.
REFRESH i_mdtb.
LOOP AT i_mdkp.
CALL FUNCTION 'READ_MRP_LIST'
EXPORTING
idtnum = i_mdkp-dtnum
icflag = 'X'
TABLES
mdtbx = lt_mdtbx.
APPEND LINES OF lt_mdtbx TO i_mdtb.
REFRESH lt_mdtbx.
ENDLOOP.
i_mdkp[] = i_mdkp_tmp[]
ENDIF.
‎2007 Dec 31 7:16 AM
Hi,
You can read datas from database table(mdkp,mdtb). don't use FM.
L.Velu
‎2009 Mar 03 11:12 AM
‎2009 Mar 03 11:48 AM
it can not be answered you did not distribute points!
I am always interested what people take as an answer, it is not always the correct one.
Siegfried