Performance enhancement for parallel loops
Hi,
I have performance problem for the following parallel loops.Please help me solve this to improve performance of report,urgently.
LOOP AT xt_git_ekpo INTO lv_wa_ekpo.
lv_wa_final-afnam = lv_wa_ekpo-afnam.
LOOP at xt_git_ekkn into lv_wa_ekkn where ebeln = lv_wa_ekpo-ebeln
and ebelp = lv_wa_ekpo-ebelp.
lv_wa_final-meins = lv_wa_ekpo-meins.
READ TABLE xt_git_ekko INTO lv_wa_ekko
WITH KEY ebeln = lv_wa_ekpo-ebeln
BINARY SEARCH.
IF sy-subrc IS INITIAL.
lv_wa_final-ebeln = lv_wa_ekko-ebeln.
lv_wa_final-ebelp = lv_wa_ekpo-ebelp.
lv_wa_final-txz01 = lv_wa_ekpo-txz01.
lv_wa_final-aedat = lv_wa_ekko-aedat.
READ TABLE xt_git_lfa1 INTO lv_wa_lfa1
WITH KEY lifnr = lv_wa_ekko-lifnr
BINARY SEARCH.
IF sy-subrc IS INITIAL.
lv_wa_final-lifnr = lv_wa_lfa1-lifnr.
lv_wa_final-name1 = lv_wa_lfa1-name1.
ENDIF.
LOOP AT xt_git_ekbe INTO lv_wa_ekbe WHERE ebeln = lv_wa_ekpo-ebeln
AND ebelp = lv_wa_ekpo-ebelp.
waiting for quick reply.
Hi
U can use SORTED TABLE instead of STANDARD TABLE:
DATA: xt_git_ekkn TYPE SORTED TABLE OF EKKN WITH NON-UNIQUE KEY EBELN EBELP,
xt_git_ekbe TYPE SORTED TABLE OF EKBE WITH NON-UNIQUE KEY EBELN EBELP.
LOOP AT xt_git_ekpo INTO lv_wa_ekpo.
lv_wa_final-afnam = lv_wa_ekpo-afnam.
LOOP at xt_git_ekkn into lv_wa_ekkn where ebeln = lv_wa_ekpo-ebeln
and ebelp = lv_wa_ekpo-ebelp.
lv_wa_final-meins = lv_wa_ekpo-meins.
READ TABLE xt_git_ekko INTO lv_wa_ekko WITH KEY ebeln = lv_wa_ekpo-ebeln
BINARY SEARCH.
IF sy-subrc IS INITIAL.
lv_wa_final-ebeln = lv_wa_ekko-ebeln.
lv_wa_final-ebelp = lv_wa_ekpo-ebelp.
lv_wa_final-txz01 = lv_wa_ekpo-txz01.
lv_wa_final-aedat = lv_wa_ekko-aedat.
READ TABLE xt_git_lfa1 INTO lv_wa_lfa1 WITH KEY lifnr = lv_wa_ekko-lifnr
BINARY SEARCH.
IF sy-subrc IS INITIAL.
lv_wa_final-lifnr = lv_wa_lfa1-lifnr.
lv_wa_final-name1 = lv_wa_lfa1-name1.
ENDIF.
LOOP AT xt_git_ekbe INTO lv_wa_ekbe WHERE ebeln = lv_wa_ekpo-ebeln
AND ebelp = lv_wa_ekpo-ebelp.
Anyway u should considere to upload in the internal table only the record of the current document, in this case u need to insert the SELECT into the loop:
SORT xt_git_ekpo by EBELN EBELP.
LOOP AT xt_git_ekpo INTO lv_wa_ekpo.
lv_wa_final-afnam = lv_wa_ekpo-afnam.
IF lv_wa_ekkn-EBELN <> lv_wa_ekpo-EBELN.
SELECT * FROM EKKN INTO TABLE xt_git_ekkn WHERE EBELN = lv_wa_ekpo-EBELN.
SELECT * FROM EKBE INTO TABLE xt_git_ekbe WHERE EBELN = lv_wa_ekpo-EBELN.
ENDIF.
LOOP at xt_git_ekkn into lv_wa_ekkn where ebelp = lv_wa_ekpo-ebelp.
lv_wa_final-meins = lv_wa_ekpo-meins.
READ TABLE xt_git_ekko INTO lv_wa_ekko WITH KEY ebeln = lv_wa_ekpo-ebeln
BINARY SEARCH.
IF sy-subrc IS INITIAL.
lv_wa_final-ebeln = lv_wa_ekko-ebeln.
lv_wa_final-ebelp = lv_wa_ekpo-ebelp.
lv_wa_final-txz01 = lv_wa_ekpo-txz01.
lv_wa_final-aedat = lv_wa_ekko-aedat.
READ TABLE xt_git_lfa1 INTO lv_wa_lfa1 WITH KEY lifnr = lv_wa_ekko-lifnr
BINARY SEARCH.
IF sy-subrc IS INITIAL.
lv_wa_final-lifnr = lv_wa_lfa1-lifnr.
lv_wa_final-name1 = lv_wa_lfa1-name1.
ENDIF.
LOOP AT xt_git_ekbe INTO lv_wa_ekbe WHERE ebelp = lv_wa_ekpo-ebelp.
In my experience (for a very large number of records) this second solution was faster than the first one:
- Using the first solution (upload all data in internal table and use sorted table): my job takes 2/3 days
- Using the second solution: my job takes 1 hour.
Max
Similar Messages
-
Question about "Enhanced for loop"
public class NewLoopTest{
public NewLoopTest(){
int result=0;
int[] a=new int[20];
for(int i=0;i<a.length;i++){
a=i++;
for(int i:a){
System.out.println("i="+i+";"+"a["+i+"]="+a[i]+";result="+result+"+"+i+"="+(result+i));
result+=i;
System.out.println("-------------");
result=0;
for(int i=0;i<a.length;i++){
System.out.println("i="+i+";"+"a["+i+"]="+a[i]+";result="+result+"+"+i+"="+(result+i));
result+=i;
This code counts sum of the elements of a array.
At first I use the enhanced for loop and at second I use the traditional for.
Enhanced for loop in sdk1.5 returns only even elements of array, am I right?Enhanced for loop in sdk1.5 returns only even
elements of array, am I right?No. It covers them all.
The i in the enhanced for loop is not the index. It's the element at the current index. You don't have access to the index in the new loop because you don't need it.
for (int item : arr) {
System.out.println(item);
// is equivalent to
for (int ix = 0; ix < arr.length; ix++) {
int item = aa[ix];
System.out.println(item);
}The i in your new loop is the same as a [ i ] in the old loop. -
Enhanced for-loop by java5 needs to be more enhanced?
Hi, all of you,
I often need to iterate a collection. Sometimes I need to iterate a subset of a collection. Then I have found the enhanced for-loop is not enough.
Before Java 5, you did the following:
for(int i=0;i<collection.size();i++) {
Object object = collection.get(i);
doSomething(object);
}Thanks to Java 5, you can do the following:
for(Object object:collection) {
doSomething(object);
}However, before Java 5, I have the flexibility to skip the first two lines by purpose, as follows
for(int i=2;i<collection.size();i++) {
Object object = collection.get(i);
doSomething(object);
}What should I do the same thing with Java 5?
Kind regards.
Pengyoupengyou wrote:
JoachimSauer wrote:
masijade. wrote:
uncle_alice wrote:
Or, if the collection is a List: for (Object obj : theList.subList(2, theList.size())) {
doSomething(obj);
Ah, yeah, I keep forgetting about that. ;-)
Actually, I just never think about it. ;-)I think you're not alone. I find that subList() is severly under-used. It simplifies a lot of operations (ever tried someList.subList(0, someIndex).clear()? Try it).The solution is nice except it might throw IndexOutOfBoundsException.Which probably means a bug somewhere else. The way to avoid runtime exceptions is to write code that doesn't put you into situations where they'll arise, not to avoid them being thrown -
How to get count from new enhanced for loop
Is there a better way to determine the count when new enhanced for loop is used as follows:
String[] test = new String[]{"1","2","3"};
int count = 0;
for(String i: test)
count++;
system.out.println("count: "+count);
}There are cases where I need to use the count inside
the for loop. I can keep track of the count by using
the increment. But, then I would rather using the old
for loop. Go ahead and use it. Are you under the assumption that the old form should be avoided?
There is no saving in term of efficiency and readability.If there is any added efficiency in the "for each" form of the loop, it is on the micro level, and you would never notice it.
As far as readability, look at some of the crazy solutions you've been given to avoid the general for loop, then reconsider which is more readable. -
I get the following compiler error when using the Java 5 SE enhanced for loop with a generic collection.
Code:
public static void main(String[] args)
List<Integer> l = new ArrayList<Integer>();
l.add(new Integer(1));
printCollection(l);
private static void printCollection(Collection<?> c)
for (Object e : c)
System.out.println(e);
Error on attempting to build:
"Error: Internal compilation error, terminated with a fatal exception"
And the following from ojcInternalError.log:
java.lang.NullPointerException
at oracle.ojc.compiler.EnhancedForStatement.resolveAndCheck(Statement.java:2204)
at oracle.ojc.compiler.StatementList.resolveAndCheck(Statement.java:4476)
at oracle.ojc.compiler.MethodSymbol.resolveMethod(Symbol.java:10822)
at oracle.ojc.compiler.RawClassSymbol.resolveMethodBodies(Symbol.java:6648)
at oracle.ojc.compiler.Parser.resolveMethodBodies(Parser.java:8316)
at oracle.ojc.compiler.Parser.parse(Parser.java:7823)
at oracle.ojc.compiler.Compiler.main_internal(Compiler.java:978)
at oracle.ojc.compiler.Compiler.main(Compiler.java:745)
at oracle.jdeveloper.compiler.Ojc.translate(Ojc.java:1486)
at oracle.jdeveloper.compiler.UnifiedBuildSystem$CompileThread.buildGraph(UnifiedBuildSystem.java:300)
at oracle.jdeveloper.compiler.UnifiedBuildSystem$CompileThread.buildProjectFiles(UnifiedBuildSystem.java:515)
at oracle.jdeveloper.compiler.UnifiedBuildSystem$CompileThread.buildAll(UnifiedBuildSystem.java:715)
at oracle.jdeveloper.compiler.UnifiedBuildSystem$CompileThread.run(UnifiedBuildSystem.java:893)Install the Service Update 1 patch for JDeveloper (using the help->check for updates), and let us know if this didn't solve the problem.
-
Inconsiste​nt Parallel Loop Performanc​e
My original question was can traditional DAQ devices run in parallel loops? I have some extensive data processing and additional automation that would be a lot easier to do in parallel with an acquisition loop rather than cram it all into the acquisition's while loop. As I was building an example VI, I discovered the answer seems to be "sometimes".
I am working on a calibration rig for hot wire anemometers. It requires pressure values to be read into a PCI-4351 (traditional DAQ) for the duration of the calibration and record wire voltages to a PCI-6110 (DAQmx device) only when the pressure values have settled (i.e. the stream velocity is constant). Inevitably, both devices will be polling data simultaneously at some point.
It seems that the 4351 would transfer its data to a parallel loop, but not when 6110 was running and vice versa - and sometimes the buttons to stop the loops wouldn't work. Will traditional DAQ and DAQmx devices not perform parallel tasks simultaneously?
The attached VI might clear up the parallel structures I'm talking about.
Andrew
Andrew
Attachments:
ParallelLoopsExample.vi 32 KBAltenbach,
You pointed me a good direction - I wasn't familiar with action engines until you mentioned them, but after some reading (namely Ben's AE nugget), you have me convinced (although not entirely sure on how to proceed) so here come the questions!
1. I tried to use Ben's running average example as a template - what should the cases inside my AE be? Right now they're "initialize", "acquire", and "close". However, I have to pass a value from initialize to acquire to close - so as is, the VI won't run.
2. Ben had his AE in a loop to add data to the array and in another loop to perform the running average calculation. Since you end up with two of the same thing in your BD, how is this better than creating a local variable?
3. Best practice? I'm pulling values from several channels - should I isolate each channel an put it into its own SR within the AE or keep the data together and have a single SR for the 2D array?
I don't expect anybody to have the 4351 drivers installed - so the what you're probably seeing as three "?" VIs in the "Initialize" panel are the VIs needed to initialize the device (sampling rate, number of scans, etc.), the single "?" in "Acquire" reads the data and the two in "Close" end the acquisition.
Brad,
Thanks for the tip - I'll keep that in mind when I'm implementing the 6110 acquisition into my code
Andrew
Attachments:
InputAE.vi 20 KB -
TOO MANY Parallel Loops in Main VI
Hi,
I have heard that all vi should fit on one screen. I have a main vi that have multiple parallel loops. The first loop is to detect the user request, the second loop is to perform the request, the third loop is to control my samples with digital out and analog out, the forth loop is to display analog in data on the screen, the fifth loop is to empty the daq buffer continuously, and the sixth loop is to log data into a file. If I have 6 loops in parallel, it is impossible for this vi to fit on one screen. Is there a better way to organize this? BTW, this is a multiple producers and multiple consumers architecture. Thanks!
Kudos and Accepted as Solution are welcome!"jyang72211" <[email protected]> wrote in message
news:[email protected]...
> Hi, I have heard that all vi should fit on one screen. I have a
main vi that have multiple parallel loops. The first loop is to detect
the user request, the second loop is to perform the request, the third loop
is to control my samples with digital out and analog out, the forth loop is
to display analog in data on the screen, the fifth loop is to empty the daq
buffer continuously, and the sixth loop is to log data into a
file. If I have 6 loops in parallel, it is impossible for this vi
to fit on one screen. Is there a better way to organize this?
BTW, this is a multiple producers and multiple consumers architecture.
Thanks!
An ideal Vi should fit on screen, because it provides more overview.
One way to "hide" the parallel loops, is but putting them in sub VI's. This
is only useful if only one loop deals with UI stuff. If one loop does one
type of DAQ, it's easy to put this in a sub VI. I'd start this sub VI
dynamically in the UI loop, but you might as well keep it as a normal VI
running parallel of the UI loops.
But I wouldn't force this. There is absolutely nothing wrong with a few
parallel loops, where each loop takes the full width, and 60% of the height
of the screen! The reason this became a rule, is to avoid diagrams with: one
big sequence. In it, four steps. In each step, a nested case, while loop,
two parallel for loops and in there again two or three sequence structures
with 8 steps, and 40 nodes kludged together. But shrinking something like
this (with a few more sequence structures) is not helpful.
I think there is nothing wrong with a few (perhaps un to 5 or 6) parallel
loops, as long as there is a logic behind there existence. I often make a
DAQ VI. In it, there are perhaps 10 loops that read data from serial, tcp/ip
and fieldpoint devices. So, would it be helpful if I put them in subVI's? I
think, in this case, not. The reason for the rule is it provides a better
overview, and this solution would give *less* overview, so, not a good
idea...
I'd say: if there is a good reason, and you keep it structured, it is just
as good as hiding the same stuff behind (dynamic) sub vi's...
There are some benefits in keeping your diagrams small. It forces you to
separate your code, and those peaces are more likely to be simpler (thus
less errors), and more reusable. In the above example of the DAQ loop,
putting the loops in seperate subVI's, would result in reusable DAQ VI's. So
it's a delicate issue, don't follow the rules blindly, try to see why they
are there.
Regards,
Wiebe. -
Adding parallel loops programatically
Hi!
I'm building a system with some instruments and I want to use the same instrument-VI for all instruments.
One way is to do it set it up as 'Possible solution..' (see image).
Is there some way where I can loop through the 'hardware settings'-array and create as many as necessary? Like the 'More what I want...' (see image)?
Attachments:
parallel loops.PNG 15 KBHello again thread!
So I'm back on the same problem...
Summary:
What I want to do is something like in the new picture 'parallel loops2.png'. Start X parallel loops that each handle the communication with a specific instrument. At the moment I have 9 instruments connected.
If I use 'Configure Iteration Parallelism' I can set the 'Number of generated parallel loop instances' to the max number (=64 for me) and then use the P terminal with the 'array size' VI to get my 9 instrumentloops running.
When reading this white paper
http://www.ni.com/white-paper/9393/en/ ('Improving Performance with Parallel For Loops')
I'm getting the feeling that the way I solved it is not the way right way. Since the P-terminal should equal the number of cores in the computer.
The Run! VI does not have any outputs wired to its connector pane. It is reentrant (Preallocate clones - No debugging allowed).
I havn't looked at Asyncchronous calls yet. Is that the way to go?
Attachments:
parallel loops2.PNG 3 KB -
No difference between using a local variable and a notifier in timed parallel loops?
The example code "Pass Data With Notifiers.vi" that came with LV 7.1 illustrates using notifiers with parallel loops. Just looking at two of the loops, the one that generates the sine wave and the one for "User 1", you can change the timing of the two loops and you can change the condition of the "Ignore Previous" status on the "Wait on Notification". I have a special case of this to consider, where I'm wondering if there's any reason not to use a local variable instead of the notifier:
Set the delay on the generator portion (which contains the Send Notification) to something very short, say 5 ms. Set the delay on the User 1 (which contains the Wait on Notification) to something relatively longer, say 200 ms. Set the Wait on Notification to False. Now you have a situation where the User 1 loop action is contingent only upon the loop delay time, since each time the loop timer runs the loop there will always be a value in the notifier. In this case it seems to behave just like the case where you update a local variable in the fast loop and read it in the slow one.
Is my understanding correct? Would there be a performance difference between the two methods? What do you prefer in this situation and why?
Thanks,
HoseheadHi H.,
I think your idea is to write to a Global Variable in the data-producer VI, and read it in the data-consumer VI(?)
One reason this might be less efficient than using Notifiers is if you want to graph every new value in the "consumer" - or make sure the value read in the consumer has changed at least once since the last loop.
> since each time the [consumer] loop timer runs the loop there will always be a value in the notifier...
> Would there be a performance difference between the two methods?
If you don't use the Notification "event" to synchronize the producer and consumer, then to be sure the consumer gets a new vaue, you've made the producer loop faster - every 5 ms - a waste of cpu-cycles. More often the situation is reversed, that is, there's a consumer that needs to see every single new value, and (without events) the consumer must loop faster than the producer (to catch every new value) - this is called polling and it wastes cpu-cycles.
Just about anytime one's tempted to make a loop execute "fast" to check on some value (or to make sure there's a fresh value,) there's an opportunity to improve performance through synchronization with events (including notifiers, queues, occurrances, semaphores, and rendezvous')
tbd
Message Edited by tbd on 07-09-2006 03:51 AM
"Inside every large program is a small program struggling to get out." (attributed to Tony Hoare) -
Pass error references to parallel loops
I have a program with two parallel loops, each of which are contained within subvis for compactness. One of the loops acquires data and writes it to a queue and the other reads the queue and performs calculations. The problem is that I would like to stop both loops if an error occurs in either loop but I get Error 1055 (Object reference is invalid) when trying to write the error to the reference. I know of several ways to get around this (i.e., depend on the timeout, write only the error status, etc.) but was wondering if anyone else has had a similar problem.
Thanks,
JohnI have attached jpegs of the code for the main vi and for the data acquisition vi which is giving the problem. I tried to recreate this problem in a scaled down program, but it worked properly. I'll continue taking a closer look at this while I also consider other options.
Thanks
Attachments:
MainProgram.jpg 124 KB
Acquire_subvi.jpg 94 KB -
Highest speed for a loop in the microprocessor of my CRIO?
Hello:
Im trying to develop a control system for an inverter with with my CRIO 9022, the speed of my system is 10 kHz(the switching frequency for the inverter is 10 kHz).
Im trying to develop the controller using the microprocesor, but I was reading that the highest speed achievable for a loop in the microprocessor is around 1 Khz, is this true?
If is it, how can I develop a control with a loop of 10 Khz? this speed is only achievable using the FPGA?
Thanks a lot!
RegardsSorry for dont attach the subVI, but the calculation that I perform inside are not diffcult, the first one is only aritmetic calculations and the second one is a PID (I attach them).
Maybe I can try to move them to the FPGA, but would be very tedious because I need huge times for compile and if I want to make any change will be very more difficult.
Do you think that the processor can not carry out these loop a higher speed than 400 Hz?
Thanks
Attachments:
SubVI1.PNG 50 KB
SubVI2(PID).PNG 81 KB -
What is the best way to stop parallel loops at the same time, from any loop?
If there is a vi with two or more parallel while loops, what would be a good method to simultaneously stop parallel loop execution, from any of the parallel loops? My intent was to try and do this without local variables, so I used notifiers. This seems like an ok method for two loops, but how about for n loops?
In addition, my code has a flaw. I use an OR block to compare the stop status of each of the loops. This works fine most of the time, but if both loops are triggered to stop at the same time,the boolean result will be false, causing the loops to never stop. How can this be avoided?
Thanks,
Curt
Attachments:
parallel_loop_w-stop.vi 54 KBI think you have the right idea, notifiers are one of the better ways to stop parallel loops. You can simplify things by using 1 notifier for everything. I modified your VI to use 1 notifier, it will set the notifier to True ONLY if the loop is stopping, then it stops. The other loop will read the notifier status, and stop based on it the next time it executes.
I also changed the second loop to stop and notify if it has an error (that is usually a good idea, especally if you have I/O or other things that can cause problems)
I also changed the switch mechanical action, that will eliminate the problems for your second question.
The VI's attached are written in Labview 7.0
P.S. If you have 7.1, the Queues are polymorphic, meaning that the typecast operat
ions are NOT needed!
Attachments:
parallel_loop_w-stop7_0.vi 45 KB -
Possible strange bug with parallel loops in LV2010
I have a specific code which does not execute correctly in parallel, but making almost any small change to the code causes it to work. Even more bizarre, I can change it so that it sometimes works correctly, and somtimes doesn't. Interested? Read on...
I have a relatively simple VI (to compute 2D Wavelet Denoising on planes of a 3D array) with the following block diagram (debugging not allowed):
The parallel loop is set to 8 automatically-partitioned instances, and I've tested this on 2-core and 8-core machines. When the #cores wired into the loop is not one, several of the iterations do not compute (for example 4 out of 24). I can check this by putting a break in the VI called inside the loop and counting how many times it is called.
I can do a number of things to make all iterations run:
- put an indicator inside the loop on the iteration number, or anything else (except the P node)
- wire the iteration number outside the loop to an indicator
- remove the case structure
- remove the loop in the other case (it's at the moment identical except for a call to a different VI which uses Discrete WT instead of Undecimated WT -- if I change the other case to match this one, the other case runs fine but this one still fails)
- change code outside the loop
- turn on debugging!
- change the loop setup to another number of instances other than 8
- change the loop setup to set the number of partitions
I can also do a number of things that do not solve the problem:
- rewriting the loop from scratch
- copying the loop from the other case
- saving for LV2009 (in which everything runs as expected) and then reloading (and presumably recompiling) in 2010
Stranger still, if I replace the called VI with a dummy VI (which simply adds one to the input 2D array so I can tell if it executes), then as long as the other wires are still wired in, it sometimes executes all iterations, and sometimes doesn't (roughly 50% split)!!! Any other changes and it always works fine.
I've managed to replace as much as possible with dummy code and still keep the results the same (i.e. sometimes executing all iterations and sometimes not).
If you want to check it out (on a multicore machine with LV2010), run LoopTest.vi, and the results at the index shown should sometimes be 13 and sometimes 14. Changing #cores to 1 will always give a result of 14, changing WT to DWT always gives 14, even though the code inside both cases is identical!
Hope it's not just me, otherwise I'll be sure that LV hates me!
Attachments:
LoopTest.zip 355 KBOK, here's a new version that exhibits the same behaviour, but is hopefully simpler to understand.
The expected result is to add one to the whole array, however sometimes not all of the parallel iterations are executed. Run ParallelLoopTest.vi from the attached ZIP file on a multi-core machine to verify. This screenshot shows that sometimes it works correctly, and sometimes not:
The code in the other case is identical (created by duplicating the case) but always works correctly.
Attachments:
ParallelLoopTest.zip 63 KB -
hi,
Can u please specify the particular enhancement which triggers between payment proposal and payment run.
Requirement:
I need to capture the username who performs the payment proposal and check with the same whether the same user is running the payment run....
Rgds.,
subashFDTAX001 Enhancement to Transaction FDTA (event after the downlo
FEDI0002 Function exits for EDI DOCS in FI - Incoming pyt adv.no
FEDI0003 Function exits for EDI docs in FI - Save PEXR segments
FEDI0004 Function exits for EDI docs in FI - particular events
FEDI0006 Function Exits for EDI-docs in FI: Save IDCR Segments
RFFOX003 Frame for user exit RFFOX003 (in program RFFOM100)
RFFOX041 Framework for user exit RFFOX041 (in program RFFOBE_I)
RFFOX042 Framework for user exit RFFOX042 (in program RFFOBE_E)
RFFOX043 Framework for user exit RFFOX043 (in program RFFOBE_D)
RFFOX061 Frame for user exit RFFOX061 (in program RFFOCH_P)
RFFOX062 Frame for user exit RFFOX062 (in program RFFOCH_P)
RFFOX063 Frame for user exit RFFOX063 (in program RFFOCH_P)
RFFOX064 Frame for user exit RFFOX064 (in program RFFOCH_P)
RFFOX065 Frame for user exit RFFOX065 (in program RFFOCH_P)
RFFOX066 Frame for user exit RFFOX066 (in program RFFOCH_P)
RFFOX071 Frame for user exit RFFOX071 (in program RFFOCH_U)
RFFOX072 Frame for user exit RFFOX072 (in program RFFOCH_U)
RFFOX073 Frame for user exit RFFOX073 (in program RFFOCH_U)
RFFOX074 Frame for user exit RFFOX074 (in program RFFOCH_U)
RFFOX075 Frame for user exit RFFOX075 (in program RFFOCH_U)
RFFOX081 Frame for user exit RFFOX081 (in program RFFOF__T)
RFFOX082 Frame for user exit RFFOX082 (in program RFFOF__T)
RFFOX100 Frame for user exit RFFOX100 (in program RFFOUS_T)
RFFOX101 Frame for user exit RFFOX101 (in program RFFOUS_T)
RFFOX102 Frame for user exit RFFOX102 (in program RFFOUS_T)
RFFOX103 Frame for user exit RFFOX103 (in program RFFOUS_T)
RFFOX104 user exit
RFFOX105 Frame for user exit RFFOX105 (in program RFFOUS_T)
RFFOX200 Frame for user exit RFFOX200 (in program RFFONZ_T)
RFFOX210 Frame for user exit RFFOX210 (in program RFFOAU_T)
RFFOX211 Frame for user exit RFFOX211 (in program RFFONZ_T)
RFFOX230 General program for user exit RFFOX230 (in program RFFO
RFFOX240 Enhancement for User Exit 240 (RFFOAT_P)
RFFOX250 Enhancement for User Exit 250 (RFFODK_E)
RFFOX901 Framework for user exit RFFOX901 (in program RFFOM100)
RFFOX902 Framework for user exit RFFOX902 (in program RFFOM100) -
Performance Tuning for a report
Hi,
We have developed a program which updates 2 fields namely Reorder Point and Rounding Value on the MRP1 tab in TCode MM03.
To update the fields, we are using the BAPI BAPI_MATERIAL_SAVEDATA.
The problem is that when we upload the data using a txt file, the program takes a very long time. Recently when we uploaded a file containing 2,00,000 records, it took 27 hours. Below is the main portion of the code (have ommitted the open data set etc). Please help us fine tune this, so that we can upload these 2,00,000 records in 2-3 hours.
select matnr from mara into table t_mara.
select werks from t001w into corresponding fields of table t_t001w .
select matnr werks from marc into corresponding fields of table t_marc.
loop at str_table into wa_table.
if not wa_table-partnumber is initial.
CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT'
EXPORTING
INPUT = wa_table-partnumber
IMPORTING
OUTPUT = wa_table-partnumber
endif.
clear wa_message.
read table t_mara into wa_mara with key matnr = wa_table-partnumber.
if sy-subrc is not initial.
concatenate 'material ' wa_table-partnumber ' doesnot exists'
into wa_message.
append wa_message to t_message.
endif.
read table t_t001w into wa_t001w with key werks = wa_table-HostLocID.
if sy-subrc is not initial.
concatenate 'plant ' wa_table-HostLocID ' doesnot exists' into
wa_message.
append wa_message to t_message.
else.
case wa_t001w-werks.
when 'DE40'
or 'DE42'
or 'DE44'
or 'CN61'
or 'US62'
or 'SG70'
or 'FI40'
read table t_marc into wa_marc with key matnr = wa_table-partnumber
werks = wa_table-HostLocID.
if sy-subrc is not initial.
concatenate 'material' wa_table-partnumber ' not extended to plant'
wa_table-HostLocID into wa_message.
append wa_message to t_message.
endif.
when others.
concatenate 'plant ' wa_table-HostLocID ' not allowed'
into wa_message.
append wa_message to t_message.
endcase.
endif.
if wa_message is initial.
data: wa_headdata type BAPIMATHEAD,
wa_PLANTDATA type BAPI_MARC,
wa_PLANTDATAx type BAPI_MARCX.
wa_headdata-MATERIAL = wa_table-PartNumber.
wa_PLANTDATA-plant = wa_table-HostLocID.
wa_PLANTDATAX-plant = wa_table-HostLocID.
wa_PLANTDATA-REORDER_PT = wa_table-ROP.
wa_PLANTDATAX-REORDER_PT = 'X'.
wa_plantdata-ROUND_VAL = wa_table-EOQ.
wa_plantdatax-round_val = 'X'.
CALL FUNCTION 'BAPI_MATERIAL_SAVEDATA'
EXPORTING
HEADDATA = wa_headdata
PLANTDATA = wa_PLANTDATA
PLANTDATAX = wa_PLANTDATAX
IMPORTING
RETURN = t_bapiret
CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'
write t_bapiret-message.
endif.
clear: wa_mara, wa_t001w, wa_marc.
endloop.
loop at t_message into wa_message.
write wa_message.
endloop.
Thanks in advance.
Peter
Edited by: kishan P on Sep 17, 2010 4:50 PMHi Peter,
I would suggest few changes in your code. Please refer below procedure to optimize the code.
Steps:
Please run SE30 run time analysis and find out if ABAP code or Database fetch is taking time.
Please run extended program check or code inspector to remove any errors and warnings.
Few code changes that i would suggest in your code
For select query from t001w & marc remove the corresponding clause as this also reduces the performance. ( For this you can define an Internal table with only the required fields in the order they are specified in the table and execute a select query to fetch these fields)
Also put an initial check if str_table[] is not initial before you execute the loop.
where ever you have used read table. Please sort these tables and use binary search.
Please clear the work areas after every append statment.
As i dont have a sap system handy. i would also check if my importing parameters for the bapi structure is a table. Incase its a table i would directly pass all the records to this table and then pass it to the bapi. Rather than looping every records and updating it.
Hope this helps to resolve your problem.
Have a nice day
Thanks
Maybe you are looking for
-
Hello, users shall have the possibility to make comments in a pdf which is displayed in a WD application. But when the user save the pdf it will be saved as a copy local on client site. Is there a possibility that the original pdf can be changed? Oth
-
Error when trying to upgrade to iOS6 ipod touch
It is my daughters iPod touch that i am having an issue with. Each time I try to upgrade to version 6.0.1 via itunes I get the error: There was a problem downloading the software for the iPod "Daughters iPod". The service is temporarily unavailable.
-
WRT54G v6, Weird Problem
My new WRT54G router was working fine for a couple weeks, both wired and wireless performance, on one desktop(wired) and two laptops(wireless). Recently I've been having a strange problem with the wireless; it connects with an excellent signal, and I
-
Calling Stored Procedure outside of ADF BC 'impl' classes
Hello What is the best way to execute a Stored Procedure outside of the ADF BC 'impl' classes? I have a java class that performs batch inserts (using view objects). I am looking for a way to call a Stored Proc from here (How can I get a handle to the
-
Transfer 1 asset to multiple assets
I'm looking for the functionality to transfer 1 asset to multiple assets in one in one transaction. In transaction code ABUMN, there is a "multiple asset" functionality but it cannot be used to transfer 1 asset to multiple assets. SAP will give an