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: 

Reg:Field-symbols

Former Member
0 Kudos

Hi,

I have the following code..

Types: begin of ty_line,

col1(1) type C,

col2(1) type C,

End of ty_line.

Types : gt_line type standard table of ty_line.

Data : it_line type gt_line,

wa_line like line of it_line.

Now by using field symbols I want to insert data into it_line and display the data in it_line with field symbols reffering to wa.

Normally we will do like...

wa_line-col1 = 'A'.

wa_line-col2 = 'B'.

append wa_line to it_line.

loop at it_line into wa_line.

write : wa_line-col1 , wa_line-col2.

endloop.

I dont want like this...I want to know how to use field symbols in this scenario.

3 REPLIES 3

kesavadas_thekkillath
Active Contributor
0 Kudos

Types: begin of ty_line,
col1(1) type C,
col2(1) type C,
End of ty_line.

data:gt_line type standard table of ty_line.
data:wa_line type ty_line.

field-symbols:<fs> type  table.
field-symbols:<fs1> type ty_line .

assign wa_line to <fs1>.
assign gt_line to <fs>.

<fs1>-col1 = 'A'.
<fs1>-col2 = 'B'.
append <fs1> to <fs>.
<fs1>-col1 = 'C'.
<fs1>-col2 = 'D'.
append <fs1> to <fs>.

loop at <fs> ASSIGNING <fs1>.
  write :<fs1>-col1,<fs1>-col2.
  skip 1.
endloop.

Former Member
0 Kudos

hi,

Try using like this

field-SYMBOLS : <wa_mara> TYPE mara,

<it_mara> TYPE ANY TABLE.

<wa_mara>-matnr = 'a'.

APPEND <wa_mara> to <it_mara>.

loop at <it_mara> ASSIGNING <wa_mara>.

WRITE <wa_mara>-matnr.

ENDLOOP.

deepak_dhamat
Active Contributor
0 Kudos

HI, bACHI ,

LIKE THIS

TYPES: BEGIN OF ty_line,

col1(1) TYPE c,

col2(1) TYPE c,

END OF ty_line.

FIELD-SYMBOLS <pt> TYPE ANY.

DATA : gt_line TYPE STANDARD TABLE OF ty_line WITH HEADER LINE.

**

*DATA : it_line TYPE gt_line,

GT_line-col1 = 'A'.

GT_line-col2 = 'B'.

*APPEND GT_line.

ASSIGN GT_line TO <pt> .

WRITE : <pt> .

rEGARDS

dEEPAK