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 to identify the field name at run time.

soumya_jose3
Active Contributor
0 Kudos

Hi All,

i have a structure p0041. It has some fields like dar01, dat01, dar02, dat02, dar03, dat03 etc etc...

i have to insert new values like '99' to darXX and '20081220' to datXX.

The problem is some records have dar01 and dat01 filled, some have dar01, dat01 , dar02 , dat02 filled like that.

In the first case i have to insert the new values to dar02 and dat02 respectively as (dar01, dat01 is filled) and for the second case i have to insert new values

to dar03 and dat03 respectively as upto dar02 dat 02 are filled here.

I know that i have to use field-symbols here to identify the field names to which the new values are to be inserted.

Please let me know how to achieve this.

Thanks & Regards,

Soumya.

3 REPLIES 3

former_member598013
Active Contributor
0 Kudos

Hi Soumya,

Check out the Below sample code.


        CONCATENATE 'IT_FINAL-DMBTR' l_tabix INTO l_field_qty.
        ASSIGN: COMPONENT 'DMBTR' OF STRUCTURE it1_mseg TO <fs>.
        ASSIGN:  l_field_qty TO <fs1>.

Thanks,

Chidanand

ThomasZloch
Active Contributor
0 Kudos

maybe like this


  do.
    lf_index = sy-index.
    assign component lf_index of structure p0041 to <fs>.
    if subrc >< 0.
      exit.
    endif.
    if <fs> is initial.
      <fs> = '99'.
      add 1 to lf_index.
      assign component lf_index of structure p0041 to <fs>.
      <fs> = '20081220'.
      exit.
    endif.
  enddo.

Thomas

Former Member
0 Kudos

Hi,

u can code like this...


DATA: F1(5) TYPE C VALUE 'DAR',
      F2(10) TYPE C,
      COUNT TYPE I.
FIELD-SYMBOLS: <FS>.

DO.
COUNT = COUNT + 1.
CONCATENATE F1 COUNT INTO F2.
CONDENSE F2.

ASSIGN COMPONENT F2 OF STRUCTURE P0041 TO <FS>.
IF <FS> IS ASSIGNED.
   IF <FS> IS NOT INITIAL.
      CONTINUE.
   ELSE.
      <FS> = NEW CODE.
   ENDIF.
ELSE.
   EXIT.
ENDIF.
ENDDO.

I think this code may help u....

Edited by: Sukriti Saha on Oct 14, 2008 10:44 AM