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: 

Field Symbol

Former Member
0 Kudos

Hi, i'm facing some problems with my coding..... I'm trying to use field-symbols to replace the process below.... but i still didnt get the way.... Please help... thanks....

what i plan to do is.... for every lgart for ex 1000

then CONCETENATE 'tab_rt-z' rt-lgart INTO STR then ASSIGN STR to <fs>.....after that how to passing the rt-betrg value into tab_rt-z1000.....and using the <fs> passing back the betrg into tab_rt-z1000.

LOOP AT rt.

CASE rt-lgart.

WHEN '1000'.

ADD rt-betrg TO tab_rt-z1000.

*****************************************

  • A D D I T I O N *

*****************************************

  • Legal (THR/AWS) Bonus

WHEN '2001'.

ADD rt-betrg TO tab_rt-z2001.

ADD rt-betrg TO tab_rt-total_add.

  • Operational Incentives

WHEN '2020'.

ADD rt-betrg TO tab_rt-z2020.

ADD rt-betrg TO tab_rt-total_add.

  • Balanced Scorecard Bonus

WHEN '2023'.

ADD rt-betrg TO tab_rt-z2023.

ADD rt-betrg TO tab_rt-total_add.

  • Productivity Incentives

WHEN '2037'.

ADD rt-betrg TO tab_rt-z2037.

ADD rt-betrg TO tab_rt-total_add.

ENDCASE.

ENDLOOP.

Thanks

4 REPLIES 4

Former Member
0 Kudos

data : fname(15) type c.

field-symbols : <fs> type any.

Loop at RT.

fname = 'TAB_RT-Z'.

concatenate fname rt_lgart into fname.

assign (fname) tp <fs>.

<fs> = rt-betrg

endloop.

Regards,

Ravi

Note : Pleae mark the helpful answers

0 Kudos

Hi, Ravi

I ever try the code before... but how am i going to pass the value of rt-betrg into tab_rt-z1000 ?

Thanks

Former Member
0 Kudos

one approach can be.

Field-symbols: <fs1> type any.

LOOP AT rt.

*C-- (Field names in Capital letters)

concatenate 'Z' rt-lgart into l_string.

assign component l_string of tab_rt to <fs>.

Add rt-betrg to <FS>.

endloop.

Former Member
0 Kudos

Hai Check the following

Go through the following Link

This documentation should answer your question. I use field symbols when using dynamic programming.

Just go through these links.

http://help.sap.com/saphelp_nw04/helpdata/en/fc/eb3860358411d1829f0000e829fbfe/frameset.htm

http://help.sap.com/saphelp_nw04/helpdata/en/16/0dce0a0cf711d3b9360000e8353423/content.htm

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

Field-Symbols are place holders for existing fields.

A Field-Symbol does not physically reserve space for a field but points to a field, which is not known until run time of the program.

Field-Symbols are like Pointers in Programming language ‘ C ‘.

Syntax check is not effective.

Syntax :

Data : v1(4) value ‘abcd’.

Field-symbols <fs>.

Assign v1 to <fs>.

Write:/ <fs>.

DATA: BEGIN OF LINE,

COL1 TYPE I,

COL2 TYPE I,

END OF LINE.

DATA ITAB LIKE SORTED TABLE OF LINE WITH UNIQUE KEY COL1.

FIELD-SYMBOLS <FS> LIKE LINE OF ITAB.

DO 4 TIMES.

LINE-COL1 = SY-INDEX.

LINE-COL2 = SY-INDEX ** 2.

APPEND LINE TO ITAB.

ENDDO.

READ TABLE ITAB WITH TABLE KEY COL1 = 2 ASSIGNING <FS>.

<FS>-COL2 = 100.

READ TABLE ITAB WITH TABLE KEY COL1 = 3 ASSIGNING <FS>.

DELETE ITAB INDEX 3.

IF <FS> IS ASSIGNED.

WRITE '<FS> is assigned!'.

ENDIF.

LOOP AT ITAB ASSIGNING <FS>.

WRITE: / <FS>-COL1, <FS>-COL2.

ENDLOOP.

The output is:

1 1

2 100

4 16

Thanks & regards

Sreeni