Is this possible..at all..?

Here is my question..
In my program, I am using an internal table which is based on a custom table. the table has 50 fields and 20000 records. For every record, I need to check if any of the fields are initial and if so, populate them with a certain value. I am using a logic similar to the one listed below.
loop at itab into wa.
if wa-field1 is initial.
wa-field1 = '1'
endif.
if wa-field2 is initial.
wa-field1 = '2'
endif.
........" until field 50 and modify the table
endloop.
Now instead of hard coding each field, is there a way, I can refer to the fields dynamically... I am not sure, if I can use Field symbols..I am currently researching that..
Any iputs will be appreciated... Thanks.

Yes, you can ..you can refer the code below for your use.
data:  lo_ddref       TYPE REF TO  cl_abap_datadescr,
         lo_table       TYPE REF TO  cl_abap_tabledescr.
  DATA : lo_struct TYPE REF TO cl_abap_structdescr,
         lo_type   TYPE REF TO cl_abap_typedescr.
DATA:   lt_target_tab_struc  TYPE dd_x031l_table,
         ls_target_tab_struc  TYPE x031l,
Find the table strcuture type
  CALL METHOD cl_abap_tabledescr=>describe_by_data
    EXPORTING
      p_data      = itab
    RECEIVING
      p_descr_ref = lo_type.
Cast it to generic type cl_abap_typedescr
  lo_table ?=  lo_type.
  CALL METHOD lo_table->get_table_line_type
    RECEIVING
      p_descr_ref = lo_ddref.
Get the source table DDIC structure information
  CALL METHOD lo_ddref->get_ddic_object
    RECEIVING
      p_object     = lt_target_tab_struc
    EXCEPTIONS
      not_found    = 1
      no_ddic_type = 2
      OTHERS       = 3.
  IF sy-subrc <> 0.
    MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
               WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
  ENDIF.
Read the first line of the table to find the
strcuture/table type name
  READ TABLE lt_target_tab_struc INTO ls_target_tab_struc
       INDEX 1.
Declare workareas dynamically based on the
structure of the tables eing passed.
  DATA: dref1 TYPE REF TO data,
        dref2 TYPE REF TO data.
  CREATE DATA : dref2 TYPE (ls_target_tab_struc-tabname).
Assign the work areas to field symbols
  ASSIGN: 
           dref2->* TO <wa_target>.
Loop at each record
  LOOP AT itab INTO <wa_target>.
  Loop at each field of the source work area
    LOOP AT lt_target_tab_struc INTO ls_target_tab_struc
      ASSIGN COMPONENT ls_target_tab_struc-fieldname
             OF STRUCTURE <wa_target> TO <wa_target_fld>.
      if <wa_target_fld> IS ASSIGNED and
           <wa_target_fld> IS INITIAL.
           sET THE VALUE
       ENDIF.
    ENDLOOP
ENDLOOP.

Similar Messages

Maybe you are looking for

  • I updated to iOS5 and it deleted some of my apps. Namely Things. And Things isn't in my iTunes, either. Help!

    I just updated my iPhone to the new OS. And it deleted a couple of my most-used apps, namely Twitter and Things. They are no longer on the phone or iTunes. And yes...I've searched for them. they are not on other screens. They are GONE. Help! I don't

  • A bizarre ORA-13349 case in 9i

    Hi all, We have just migrated from 8.17 to 9.2 and encountered a rather strange validation error on a particular polygon geometry. Subject Geometry: Parcel polygon composed of 4 polylines and 3 arcs. Validation SQL: SELECT SDO_GEOM.VALIDATE_GEOMETRY(

  • Java stack not working

    Hi!     I am using WebAS 6.40 using.The ABAP stack is working fine.But when I  am unable to connect to the web console.when I give the url for the webConsole   http://<ser-name>:port-no/me it is displaying as no page found error.. When I tried to log

  • Upgrading to Weblogic 9.2

    Hi I'm upgrading an 8.1 app to 9.2. I've managed to deploy it, but when I try to access a web service I have deployed there it returns a 401 error, because it's trying to do basic authentication. It worked fine under 8.1. I tried adding <enforce-vali

  • G4 floppy disk

    Hello , I have an old version of Cubase VST [4.1],and I would like to use it with my G4 ,just to have fun. Because this software has a protection system with a floppy disk ,I need to use a floppy disk drive with my G4, to authorise my hard disk for u