Home > SAP software/management Tips > SAP ABAP/Java developer tips > Use field symbols for better performance in internal tables
SAP Tips:
EMAIL THIS
 TIPS & NEWSLETTERS TOPICS 

SAP ABAP/JAVA DEVELOPER TIPS

Use field symbols for better performance in internal tables


James Vander Heyden
08.20.2003
Rating: -4.15- (out of 5) Hall of fame tip of the month winner


Digg This!    StumbleUpon Toolbar StumbleUpon    Bookmark with Delicious Del.icio.us   


Do you want to squeeze more performance out of your Internal Table processing?The new ABAP object extensions in SAP require internal table definitions to look a little different. With this new style of definition comes many options for better performance like hash tables and sorted tables. The use of field symbols takes this performance concept one step further.

The new style of definition of internal tables usually doesn't include a header area for the internal table. Furthermore, ABAP Objects will not allow internal tables with header lines. For added performance, instead of declaring a work area--use a field symbol. The work area concept and header line format both require data to be moved from the internal table to the work area or header area. A field symbol is just a pointer that will point to the proper line of the itab. With field symbols, no data needs to be moved. The field symbol just stores the proper memory address to point at the right line. The field symbol can have structure and be made up of fields similar to a work area or header line. Because no data needs to be copied, processing is much faster.

The keys to the usage are:
1) Defining the table records and the field symbol in a similar type.
* just an ordinary standard table
TYPES: BEGIN OF it_vbak_line,
vbeln LIKE vbak-vbeln,
vkorg LIKE vbak-vkorg,
vtweg LIKE vbak-vtweg...

Digg This!    StumbleUpon Toolbar StumbleUpon    Bookmark with Delicious Del.icio.us   



RELATED CONTENT
SAP ABAP/Java developer tips
How to do additional dialog processing after SAP COMMIT WORK statement
How to find a piece of SAP ABAP code without debugging
How to read an SAP transaction in an ABAP code
How to provide an SAP R/3 4.5B application server with a Web service interface
How to find owners and transports of deleted ABAP programs
Fixing a common OPEN_FORM and START_FORM error in SAPscript
Select Text fields: Case-insensitive
Is this the quickest way to find a BADI?
Easily debug error messages in SAP processes
Accessing private attributes in ABAP Objects

RELATED RESOURCES
2020software.com, trial software downloads for accounting software, ERP software, CRM software and business software systems
Search Bitpipe.com for the latest white papers and business webcasts
Whatis.com, the online computer dictionary


,
spart LIKE vbak-spart,
kunnr LIKE vbak-kunnr,
END OF it_vbak_line.

DATA: it_vbak TYPE TABLE OF it_vbak_line.
FIELD-SYMBOLS: <it_vbak_line> TYPE it_vbak_line.

* or as a screaming fast hash table for keyed reads
TYPES: BEGIN OF it_vbpa_line,
vbeln LIKE vbak-vbeln,
kunnr LIKE vbak-kunnr,
END OF it_vbpa_line.

DATA: it_vbpa TYPE HASHED TABLE OF it_vbpa_line
WITH UNIQUE KEY vbeln.
FIELD-SYMBOLS: <it_vbpa_line> TYPE it_vbpa_line.

2) In ITAB processing, utilize the ASSIGNING command.
* loop example
LOOP AT it_vbak ASSIGNING <it_vbak_line>.
* look at records--populate it_zpartner
* read example
READ TABLE it_vbpa ASSIGNING <it_vbpa_line>
WITH TABLE KEY vbeln = <it_vbak_line>-vbeln.

3) Refer to the field symbol's fields in the loop or after the read.
wa_zpartner-vkorg = <it_vbak_line>-vkorg.
wa_zpartner-vtweg = <it_vbak_line>-vtweg.
wa_zpartner-spart = <it_vbak_line>-spart.
wa_zpartner-kunag = <it_vbak_line>-kunnr.
wa_zpartner-kunwe = <it_vbpa_line>-kunnr.

See the code example below for further detail. The code was written in R/3 4.6C and should work for all 4.x versions.

Code


Rate this Tip
To rate tips, you must be a member of SearchSAP.com.
Register now to start rating these tips. Log in if you are already a member.


Submit a Tip




DISCLAIMER: Our Tips Exchange is a forum for you to share technical advice and expertise with your peers and to learn from other enterprise IT professionals. TechTarget provides the infrastructure to facilitate this sharing of information. However, we cannot guarantee the accuracy or validity of the material submitted. You agree that your use of the Ask The Expert services and your reliance on any questions, answers, information or other materials received through this Web site is at your own risk.



NetWeaver SAP White Papers
About Us  |  Contact Us  |  For Advertisers  |  For Business Partners  |  Site Index  |  RSS
SEARCH 
TechTarget provides technology professionals with the information they need to perform their jobs - from developing strategy, to making cost-effective purchase decisions and managing their organizations' technology projects - with its network of technology-specific websites, events and online magazines.

TechTarget Corporate Web Site  |  Media Kits  |  Site Map




All Rights Reserved, Copyright 2000 - 2009, TechTarget | Read our Privacy Policy
SearchSAP.com is a search service provided by TechTarget and is completely
independent of and not affiliated with SAP AG.
  TechTarget - The IT Media ROI Experts