Application Development and Automation 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: 
Read only

sample program for field symbol

Former Member
0 Likes
4,028

hi,

I am fresher. I want sample program(code) for field symbol.

5 REPLIES 5
Read only

Former Member
0 Likes
1,074

Hi,

Check the following code :


DATA NAME(4) VALUE 'JOHN'. 
FIELD-SYMBOLS <F> TYPE ANY. 
ASSIGN NAME TO <F>. 
WRITE <F>. 

Erwan

Read only

0 Likes
1,074

REPORT ZGILL_FS line-size 250

line-count 65 .

data: name like p0002-vorna.

*

parameter pernr like pernr-pernr.

*

field-symbols <fs_name> type any.

*

start-of-selection .

*

assign name to <fs_name>.

*

select single vorna into name from pa0002

where pernr = pernr.

*

write: 'Name: ' ,<fs_name> .

Read only

Former Member
0 Likes
1,074

http://www.sts.tu-harburg.de/teaching/sap_r3/ABAP4/field_sy.htm

TYPES: BEGIN OF line,
         col1 TYPE c,
         col2 TYPE c,
       END OF line.

DATA: wa TYPE line,
      itab TYPE HASHED TABLE OF line WITH UNIQUE KEY col1,
      key(4) TYPE c VALUE 'COL1'.

FIELD-SYMBOLS <fs> TYPE ANY TABLE.

ASSIGN itab TO <fs>.

READ TABLE <fs> WITH TABLE KEY (key) = 'X' INTO wa.

The internal table ITAB is assigned to the generic field symbol <FS>, after which it is possible to address the table key of the field symbol dynamically. However, the static address

READ TABLE <fs> WITH TABLE KEY col1 = 'X' INTO wa.

is not possible syntactically, since the field symbol does not adopt the key of table ITAB until runtime. In the program, the type specification ANY TABLE only indicates that <FS> is a table. If the type had been ANY (or no type had been specified at all), even the specific internal table statement READ TABLE <FS> would not have been possible.

http://help.sap.com/saphelp_nw04/helpdata/en/fc/eb387a358411d1829f0000e829fbfe/content.htm

http://help.sap.com/saphelp_nw2004s/helpdata/en/fc/eb387a358411d1829f0000e829fbfe/content.htm

Read only

Former Member
0 Likes
1,074

Hi Poonam,

Please check the below code:

field-symbols: <mgv_poitemx> type bapimepoitemx.

loop at poitemx assigning <mgv_poitemx>

where not ( material_external is initial and

material_version is initial and

material_guid is initial ).

<mgv_poitemx>-material = 'X'.

endloop.

loop at poitemx assigning <mgv_poitemx>

where not ( ematerial_external is initial and

ematerial_version is initial and

ematerial_guid is initial ).

<mgv_poitemx>-ematerial = 'X'.

endloop.

Regards

Kannaiah

Read only

p291102
Active Contributor
0 Likes
1,074

HI,

REPORT demo_field_symbols_type.

DATA: BEGIN OF line,

col1(1) TYPE c,

col2(1) TYPE c VALUE 'X',

END OF line.

FIELD-SYMBOLS <fs> LIKE line.

ASSIGN line TO <fs>.

MOVE <fs>-col2 TO <fs>-col1.

Thanks,

Shankar