Application Development Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 

right way to declare field symbols

Former Member
0 Kudos

i am new to field symbols, pls help

i want to know which is the right way of declaration ?


types: begin of typ_tab,
           vbeln  type vbap-vbeln,
           posnr type vbap-posnr,
           matnr  type vbap-matnr,
           - - - - -
          end of typ_tab.
 
data:  itab type standard table of typ_tab,
          wa  type typ_tab.
 
field-symbols: <f_t> type standard table,  
                       <f_w> type any,                or      <f_w>  like  line of typ_tab,  ??
                        <f_s> type any.
 
select  vbeln posnr  ....... into itab......
 
assign  itab to <f_t>.
assign wa  to <f_w>.
 
loop at <f_t> assigning <f_w>.
assign component 'vbeln' of structure <f_w>  to <f_s>.
write : / <f_s>.
endloop.

OR

loop at itab assigning <f_w>.  
write: / <f_w>-vbeln.
endloop.  

r these 2 statements correctt ? if so then which one  to use,  pls show with an example. wats the diff btwn above 2  types of  looping statements ?   how to use read statement on this ?


1 REPLY 1

asik_shameem
Active Contributor
0 Kudos

Hello Saurajit,

Both the way are correct. And it depends on the requirement, which one to use.

<f_w> TYPE ty_tab - is TYPED field symbol - if you know TYPE before runtime you can use this. It will just work like a static work area.

<f_w> TYPE any - is not TYPED and structure of this field symbol is defined during runtime using ASSIGN statement. And fields of the structure is read by ASSIGN COMPONENT <<field name>> statement.