Thursday 30 October 2014

Working with Field Symbols:

Field Symbols are similar to the reference variable available in most programming language.  The primary purpose of using field symbols is to facilitate dynamic access to variables and work areas during programming execution.

Though a lot has been discussed about the use of field symbols, not much has been discussed about the risk while working with them.

In this discussion I will focus on some of the statements which caused the program to dump even though these statements pass the syntax check of the compiler.

Field symbols are commonly used for referring work areas during internal table operations.  For example we need to modify the content of any internal table while looping through the same. Field symbol will reduce the number of operations carried out, as changes made to the values accessed using field symbol will help get rid of the MODIFY statement.

The syntax for the same is : LOOP AT  <ITAB> ASSIGINING <FS_WA>.
But the statement  LOOP AT <ITAB> INTO <FS_WA> is a valid statement , atleast syntactically. 

During the compile time the program does not indicate any error.
This statement leads to immediate dump at run time execution of the program.
The reason for this to be dumping is not basically due  to incorrect syntax but because the field symbol will be used (consumed) in the further lines of the code, and accessing a field-symbol without assigning the same to a memory location lead to the programming dumping at runtime.

Similar issue is again commonly encountered when using the popular
 ASSIGN COMPNENT <count> OF <STR> TO <field symbol>

The common mistake that occurs here is the count variable if not tracked correctly will lead to a situation where the field symbol is assigned to no field, and further down in the program logic we try to use this variable.


Will continue with similar challenges in further blog discussion.

Unisid technologies  www.unisidtechnologies.com is a leading online training provider offering extensive and indepth training for SAP-ABAP and SAP-FICO. The trainer's at Unisid have years of industry experience, which enables trainees to get exposed to the best in Online Training. 





No comments:

Post a Comment