Parallel Cursor Method
Parallel Cursor Method
the client requirements. Business programs usually handle huge amounts of data. ABAP programs in SAP implementations are not an exception to this, and they need to give the user acceptable response times before they can be delivered to the client. Therefore, every developer should pay special attention to performance when building programs. Although too many times the development environment will not have an adequate data volume (and nearly always not as in real productive systems), there is always a lot that can be done to deliver good programs from a performance standpoint. Database accesses are probably the first focus point; wrong sentences searching records in tables may lead to extremely poor response times, and this needs to be taken care of. However, there is another important area to bear in mind, which is forgotten more often that it could be thought: data processing within the program. This white paper, oriented to developers and technical designers, will explain an amazing alternative way of processing data (applicable when handling together header and position records) that will give great response times, making it possible to build complex programs that need to process big amounts of data in an acceptable time and achieving customer satisfaction.
technical instructions to apply the method in the special case when the tables have a different key.
Sequential Method
Get the starting Run time. Loop the header internal table. Inside the master loop, item data will be looped and if any item data found, both the header and item data will be moved to another internal table. Get the Ending Run Time. The difference in End and Start run time is the actual time taken for sequential search.
SORT <Header Internal Table> BY <Key Field> ASCENDING. SORT <Item Internal Table> BY <Key Field> <Key Field> ASCENDING. CLEAR: <Header Work Area>. GET RUN TIME FIELD <Begin Time> LOOP AT <Header Internal Table> INTO <Header Work Area>. CLEAR: <Item Work Area>. LOOP AT <Item Internal Table> INTO <Item Work Area>. WHERE <Key Field> EQ <Header KEY Field>. PROCESS the Header AND Item DATA. ENDLOOP. ENDLOOP. GET RUN TIME FIELD <End Time> Total TIME = End TIME Begin TIME.
Parallel Method
Sort the header and item internal table. Get the starting Run time. Loop the header internal table. Inside the master loop, Item data will be looped by checking the index. If the key field of item data is greater than the key field of header data, then there is no item data is found and exit from the detail loop. If item data is equal to the key field of header data, move the header and item data to another internal table. Store the index of the item data. And continue the process. Get the Ending Run Time. The difference in End and Start run time is the actual time taken for Parallel Cursor.
SORT <Header Internal Table> BY <Key Field> ASCENDING. SORT <Item Internal Table> BY <Key Field> <Key Field> ASCENDING. CLEAR: <Header Work Area>. INITIALIZE INDEX Variable GET RUN TIME FIELD <Begin Time> LOOP AT <Item Internal Table> INTO <Item Work Area>. CLEAR: <Header Work Area>. LOOP AT <Header Internal Table> INTO <Item Work Area>. FROM <Index Number> IF <Item KEY Field> Greater Than <Header KEY Field> NO DATA found IN the item INTERNAL TABLE. EXIT. ELSE <Item KEY Field> Equal TO <Header KEY Field>
variable.
PROCESS the Header AND Item DATA. ENDIF. ENDLOOP. ENDLOOP. GET RUN TIME FIELD <End Time> Total TIME = End TIME Begin TIME.