Read line + field symbol

Hi expets.
I have some doubt related to Read Line, iknow it's use but it fails when i m using field symbol.
1->
Do w_lines times.
Read line sy-index field value <fs_customer>-name1.
enddo
Here it makes dump because i m using fied symbol. Its type is correct .
But when i use int. table or structure it's wrks fine
2-> when i try to hide a field sybmol it shows dump. what can i do?
  actually in a loop i_customer assigning <fs_customer>
  write: /<fs_customer>-name1..etc...
hide : <fs_customer>-kunnr.
here it makes dump when i hide
3-> Problem is-
I have two reports on same screen.1 for Customer and another for Vendor.
both have check boxes.
I want to read them from Screen output and for Customer name i have to get the Customer no. for the selected check box.
Same is with the venodr report n same screen.
wen slect Vendor name check box get vendor no.
My issue is that how i should read two reports on same screen for check boxes.
I mean i will make a DO ...ENDDO . and on it i will read for sy-line-1 times.
then hw i will separate that whetehr this read is for Customer or Vendor.
Do i need to set  some flag and then hide that flag.
and supoose if Flag eq C at read then its custoer and as it will be V then its Vendor,
All teh Vendor report is Below thw Customer.
Please tell me the advantage of Field symbol over heaer lines of table./
thanks in Advance.

Loop to get the unselected checkbox
  DO l_line_lockbx TIMES.
  Read the lines on Screen -for LOCK BOX
    READ LINE sy-index FIELD VALUE g_check
                                                     <fs_lockbx>-name1 .
    IF  sy-subrc EQ 0 .
  If Check Box is not selected-Store in a separate table
    if g_check eq c_x.
    clear l_name_lockbx.
    move <fs_lockbx>-name1 to l_name_lockbx.
  Read table to get the Detail when ceck box not selected
    read table i_lockbx with key name1 = l_name_lockbx
                                binary search
                                assigning <fs_lockbx>.
      IF  sy-subrc EQ 0.
      MOVE : <fs_lockbx>-serial     TO <fs_rcvlad>-serial ,
                   <fs_lockbx>-rcvlad    TO <fs_rcvlad>-rcvlad ,
                   <fs_lockbx>-docnum TO <fs_rcvlad>-docnum .
      APPEND <fs_rcvlad> TO i_rcvlad.
      CLEAR :<fs_rcvlad>  ,
                   <fs_lockbx> ,
                     g_check     .
     endif.            " IF  sy-subrc EQ 0
    ENDIF.             " if g_check ne c_x.
  ENDDO.               " DO l_line_lockbx TIMES.

Similar Messages

  • Reading a field symbol whose structure is dynamic

    Hi Experts,
    I have used the concept of dynamic internal tables to select data from COSS/COSP for e.g.database tables.Field symbol of type " ANY TABLE" has been used to select data , as the dynamic structure is assigned directly to the field symbol.
    To calculate the values of various fields I need to read the this field symbol for diferent line items , but I get a compilation error saying " Key not Found ". I understand that I am not able to read the field symbol because its structure is of type 'ANY TABLE' .How do I read this field symbol ?
    The field symbol gets the structure of dynamic internal table as formed initially by using class concept.Is their any way in which I could get the structure of this field symbol or any other way to read it?
    Thanks in advance.
    Regards
    Reetwika

    Hi Ritwika,
    Even if u use the concept if dynamic internal table, u can read the each of the field of ur structure,
    if u know the name of the field.
    for example:
    MATNR being one of the field of internal table
    field-symbols : <fs> type any.
    loop at <fs_it> into <fs_wa>.
    ASSIGN COMPONENT 'MATNR' OF STRUCTURE <fs_wa> to <fs_matnr>.
    " in this case matnr field value will be assigned to the field symbol <fs_matnr>, so it can be used further.
    endloop.
    " do reply if still confused.
    Rohit G
    Edited by: Rohit Gaharwar on Aug 12, 2009 11:51 AM

  • Read Dynamic Field Symbol

    Hello ,
    I have a field symbol where i am not aware of fields (Column Name) , i mean column names are Dynamic.
    Problem is i need to read this field symbol value , how can i do it . It will always have 1 record
    Example
    Field Symbol looks something like this
    <FS> Column Name dynamic -
    >
    A B C
    Record
    1 2 3
    So now i have to refer to Second Column (i.e. is B in this case) , how should i do
    What i tried .
    1. <FS>-(Column Name in variable in brackets) - It doesnt work , Error Message unable to interpret the number B
    2. <FS>[1] - Error out.

    For a structured data object <s>, you can use the statement
    <b>
    ASSIGN COMPONENT <comp> OF STRUCTURE <s> TO <FS>.
    </b>
    to assign one of its components <comp> to the field symbol <FS>. You can specify the
    component <comp> either as a literal or a variable. If <comp> is of type C or a structure which
    has no internal tables as components, it specifies the name of the component. If <comp> has any
    other elementary data type, it is converted to type I and specifies the number of the component.
    In the assignment is successful, SY-SUBRC is set to 0. Otherwise, it returns 4.

  • How to read dynamic field symbol

    hi all,
       ASSIGN (tabname) TO <fs_tab>.
       in above code i am passing dynamic table to fs_tab
      can anyone tell me how can i read this field symbol........
      in other words i want to read dynamic field symbols

    Hi,
    you could do without the field-symbols:
    select from variable table
    grtz,
    Koen

  • Read dynamic field symbol Work Area before append to dynamic table

    Hi experts:
    I have a dynamic work area but before doing an append to the dynamic table, I need to do some validation on some fields of the work area in order to decide to append it or not, but I don't know how...
    More or less this is the example
    loop at so_kschl.
        field = so_kschl-low.
        if <t_dyntable>-field = 0. "if the value of this field in dinamic table is 0.
    don't append
        else.
           APPEND <fs_dyntable> TO <t_dyntable>.  
        endif.
    endloop.
    Thank you very much for your help.
    Miriam

    Check this example, you read the component of the dynamic work area and assign it to a field-symbols. In this case, I validate that the entry is always 'a'.
    DATA: i_lvc TYPE lvc_t_fcat WITH HEADER LINE,
          i_table TYPE REF TO data,
          l_style TYPE lvc_fname,
          l_warea TYPE REF TO data,
          l_name(7) VALUE 'VARCHAR'..
    FIELD-SYMBOLS: <fs> TYPE table,
                  <fs2> TYPE ANY,
                  <fs3> TYPE ANY.
    PARAMETERS p_char TYPE c LOWER CASE.
    START-OF-SELECTION.
      i_lvc-fieldname = 'Varchar'.
      i_lvc-inttype = 'C'.
      i_lvc-intlen = 1.
      APPEND i_lvc.
      CALL METHOD cl_alv_table_create=>create_dynamic_table
      EXPORTING
      it_fieldcatalog = i_lvc[]
      IMPORTING
      ep_table = i_table
      e_style_fname = l_style.
      ASSIGN i_table->* TO <fs>.
      CREATE DATA l_warea LIKE LINE OF <fs>.
      ASSIGN l_warea->* TO <fs2>.
      <fs2> = p_char.
      ASSIGN COMPONENT l_name OF STRUCTURE <fs2> TO <fs3>.
      IF <fs3> = 'a'.
        WRITE: 'Component VARCHAR is a'.
    *  APPEND <fs2> TO <fs>.
      ELSE.
        WRITE: 'Component VARCHAR is not a'.
      ENDIF.

  • Regarding reading a field symbols with a key

    Hi
    i have a scenario where i need to delete some duplicates from previous selection
    i' m selecting some 1000 records from one table. now in my second selection i' m reading records from 1001 to 2000.
    now i need to compare the last record(1000th) and compare the record with this second selection(1001 to 2000). in this scenario i' m using all feild symbols. here is the code
            SELECT * FROM (pa_tab)
                   INTO TABLE <lt_dyntable>
                   UP TO pa_ind ROWS
                   WHERE (lt_conditions_temp).
    initially <lt_dyntable> contains 1000 records
    if lv_dbcnt GT 1000.
    read table <lt_dyntable> assigning <ls_dyntable> with key
    <ls_dyntable> = <ls_check>.-----ERROR
    endif.
    this i have written to get the last record.
          LOOP AT <lt_dyntable> assigning <ls_dyntable>.
          ENDLOOP.
    i have stored the last record in this check. as the table <lt_dyntable> should be refreshed.
    move <ls_dyntable> to <LS_CHECK>.
    the code which i mentioned is giving me an error.
      <ls_dyntable> TYPE ANY,
      <ls_check> type any.
    let me know where i' m doing the error.
    Thanks & Regards,
    T.Subhashini.

    Hi,
    I think it is looking for a field <ls_dyntable> in your internal table <lt_dyntable>
    read table <lt_dyntable> assigning <ls_dyntable> with key
    <b><ls_dyntable> = <ls_check>.-----</b>ERROR
    Try this..
    READ TABLE <lt_dyntable> assigning <ls_dyntable> INDEX 1.
    IF <ls_dyntable> = <ls_check>.
    ENDIF.
    Thanks,
    Naren

  • Read Data from the dynamic Field Symbol with key ?

    Dear All,
    I've  2 dynamic internal tables in the form of field symbols.
    Now,I want to loop the item field symbol, read the header field symbol content and then move the corresponding into a final field symbol.
    How to read the field symbol with key ?
    When I'm trying to give the key clause in the paranthesis it's giving a syntax error.
    Any clues ?
    FYI .....
    * Get the Dynamic Field and Value for the Date/Year and convert it into Year value
      LOOP AT <fs_t_son> ASSIGNING <wa_son>.
        ASSIGN COMPONENT gwa_znrows_def-fieldname OF STRUCTURE <wa_son> TO <fs_year>.
        IF sy-subrc = 0.
          CLEAR gv_string.
          MOVE <fs_year> TO gv_string.
          CLEAR gv_year.
          gv_year = gv_string.
          <fs_year> = gv_year.
        ELSE.
    * When the Date/year Field is not in the Table then -->
    * Get the Dynamic Field and Value
          ASSIGN COMPONENT gwa_znrows_def-kfldname OF STRUCTURE <wa_rson> TO <fs_value>.
    * Populate field for Dynamic Where condition
          CLEAR gv_value.
          CONCATENATE '''' <fs_value> '''' INTO gv_value.
          CONCATENATE gwa_znrows_def-kfldname '=' gv_value INTO gt_where SEPARATED BY space.
          APPEND gt_where.
          CLEAR gt_where.
          READ TABLE <fs_t_rson> ASSIGNING <wa_rson> ( gt_where ).  "Key clause
        ENDIF.  " if sy-subrc = 0.  "Assign
      ENDLOOP.
    Thanks & regards,
    Deepu.K

    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 from a syntax point of view.

  • BADI Implementation field symbol error in code...

    Hi,
    My requirement is to provide barcode for a particular equipment in trasaction IE06. I've implemented badi for that too.
    But the problem is when pressing the print barcode button its gives barcode for all equipments rather than giving for particular one.
    I think issue is in the code ..here in code field symbol is used for processing the selected equipment buut its not working..
    the code is as follows..
    METHOD if_ex_badi_eam_list_fcode~execute_function_code.
      BREAK-POINT.
      CONSTANTS: lc_formname TYPE fpname VALUE 'Z_BARCODE_PRINT_FORM',
                 lc_cat TYPE char2 VALUE 'EQ'.
      CONSTANTS: lc_formname1 TYPE fpname VALUE 'Z_BARCODE_PRINT_FUNCTIONAL_LOC',
               lc_cat1 TYPE char2 VALUE 'FL'.
      DATA: lv_fname TYPE funcname,
            lv_equip TYPE string,
            lv_outparamas TYPE sfpoutputparams,
            lw_objects TYPE rihequi_list,
            LW_OBJECTS1 TYPE  RIHIFLO_LIST.
    *  DATA: ls_objects type REF TO ANY." TABLE."RIHEQUI_LIST.
      FIELD-SYMBOLS <ls_objects> TYPE ANY.
      IF sy-tcode EQ 'IE06'.
    *    lc_formname = 'Z_BARCODE_PRINT_FORM'.
        CALL FUNCTION 'FP_FUNCTION_MODULE_NAME'
          EXPORTING
            i_name     = lc_formname
          IMPORTING
            e_funcname = lv_fname.
        CALL FUNCTION 'FP_JOB_OPEN'
          CHANGING
            ie_outputparams = lv_outparamas
          EXCEPTIONS
            cancel          = 1
            usage_error     = 2
            system_error    = 3
            internal_error  = 4
            OTHERS          = 5.
        IF sy-subrc <> 0.
          MESSAGE 'An error occured in processing the background job' TYPE 'E'.
          EXIT.
        ENDIF.
        LOOP AT it_selected_objects INTO lw_objects.
          lv_equip = lw_objects-equnr.
          CALL FUNCTION lv_fname
            EXPORTING
    *   /1BCDWB/DOCPARAMS        =
              item_no                  = lv_equip
              item_cat                 = lc_cat
    * IMPORTING
    *   /1BCDWB/FORMOUTPUT       =
    * EXCEPTIONS
    *   USAGE_ERROR              = 1
    *   SYSTEM_ERROR             = 2
    *   INTERNAL_ERROR           = 3
    *   OTHERS                   = 4
          IF sy-subrc <> 0.
    * MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
    *         WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
          ENDIF.
    *      ENDIF.
          CLEAR: lv_equip,lw_objects.
          UNASSIGN <ls_objects>.
        ENDLOOP.
        CALL FUNCTION 'FP_JOB_CLOSE'
    * IMPORTING
    *   E_RESULT             =
    * EXCEPTIONS
    *   USAGE_ERROR          = 1
    *   SYSTEM_ERROR         = 2
    *   INTERNAL_ERROR       = 3
    *   OTHERS               = 4
        IF sy-subrc <> 0.
    * MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
    *         WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
        ENDIF.
    Please Help....

    Hi Akshay,
    1. It is not a standard program, it is a custom one.
    2. Try to fix the bug such that field symbol gets assigned.
    3. Place the necessary checks before trying to read the field-symbol, i.e. IF <FIELD> IS ASSIGNED. ... ENDIF.
    Cheers,
    Aabhas

  • Field Symbol error in program SAPMZF01

    Hi All,
    I am doing upgrade from R/3 Enterprise to ECC 6.0. When i do the EPC for the standard program SAPMZF01, in the section "Field Attributes" i get following error:
    *Program: SAPMZF01   Include: MZF01TOP     Row:  468
    Fieldsymbol <FIELD> is not assigned to a field
    (This message can be hidden with "#EC  )
    Is it ok to comment the field symbol, or is there any other way to solve this error.
    Thanking you in advance
    Best Regards
    Akshay

    Hi Akshay,
    1. It is not a standard program, it is a custom one.
    2. Try to fix the bug such that field symbol gets assigned.
    3. Place the necessary checks before trying to read the field-symbol, i.e. IF <FIELD> IS ASSIGNED. ... ENDIF.
    Cheers,
    Aabhas

  • How to assign values to a work area which is a Field Symbol?

    Hello Experts!
    I really need your help! this is the problem:
    I need to assign values to fields into a work area which is a field symbol. The values come from a flat file I uploaded and as I can't know the length I had to build the structure dynamically ( That's why I'm using FS). Each field comes from the file separated by ';', I tried using the SPLIT sentence:
    "SPLIT text AT ';' INTO TABLE <dyn_table>." but the values are assigned vertically into the same field instead of horizontally into each field of the table(field-symbol table).
    I know the name of the field dynamically
    (a TEXT + number) and I know I can't do this
    <dyn_wa>-TEXT1 or field_name = 'TEXT1' <dyn_wa>-(field_name).... ohhh I'm blocked, I don't seem to find the answer, please help!
    Thanks in advance!!
    Frinee

    Now that you have a table with the values, you can move them to the work area.
    data: begin of wa,
          fld1(20) type c,
          fld2(20) type c,
          fld3(20) type c,
    *     and so on
          end of wa.
    data: istr type table of string with header line.
    field-symbols: <fs>.
    split text at ';' into table istr.
    loop at istr.
    assign component sy-tabix of structure wa to <fs>.
    if sy-subrc <> 0.
    exit.
    endif.
    <fs> = istr.
    endloop.
    write:/ wa-fld1, wa-fld2, wa-fld3.
    Now, WA has the values in a horizontal fashion.
    Regards,
    Rich Heilman

  • Field symbols and READ TABLE with system code 4

    Hi,
    I have a hashed table and I am using field symbols to point to it to retrieve the field content. I then use it in the READ TABLE statement in the following way:
    Loop at x_data assign <fs>.
    ASSIGN COMPONENT 'xxx' OF STRUCTURE <fs> TO <c1>.
    ASSIGN COMPONENT 'xxx' OF STRUCTURE <fs> TO <c2>.
    READ TABLE ZZZZ assign <fs> with table key a1 = <c1>
                                               a2 = <c2>.
    If sy-subrc = 0.
    endif.
    I ran the debugger and I keep getting a 4. I am not able to get the value from a1 and a2 to see what it is and why it is causing a 4 sy-subrc. I know the value from the hashed table and the values c1 and c2 are the same, so the sy-subrc should be 0.
    How would I read a hashed table using field symbols? I know that usig a standard table, I have to sort the table on the key fields() before I actually can do the READ TABLE using the binary search.
    Please advise. Thanks
    RT

    Hai Rob
    Go  through the following Code
    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
    Sreenivasulu P

  • Better alternative to header lines, use of logical database, field-symbols

    Hello experts,
    I am wondering if theres a better and faster alternative than declaring a header line for an itab. are work areas faster?
    What is the use of logical database? can you please give me an example on how to use it in reports.
    how do I use field-symbols? I am confused on how it works.
    P.S. I recently installed SAP netweaver preview abap edition
    in my home PC and I am wondering if I could practice BDC, user exits, etc. If so, how?
    Again, thanks for all your help since I'm kinda new to ABAP.

    I always use this...It uses header lines, but at least is smaller -:)
    <b>DATA: BEGIN OF MY_TAB TYPE STANDARD TABLE OF BKPF WITH HEADER LINE.</b>
    For logical databases, you can check my blog...I always use LDB for HR programs -:)
    <a href="/people/alvaro.tejadagalindo/blog/2006/02/19/how-to-deal-with-hr-payroll-reports:///people/alvaro.tejadagalindo/blog/2006/02/19/how-to-deal-with-hr-payroll-reports
    LDB's provides a lot of information, because they gather it from a lot of different tables...
    A Field-Symbols is like a pointer in C++, like an alias for a variable...Here's a small example...
    REPORT Z_ATG_DUMMY.
    FIELD-SYMBOLS: <F1>, <F2> TYPE I.
    DATA: TEXT(20) TYPE C VALUE 'Hello, how are you?',
          NUM TYPE I VALUE 5,
          BEGIN OF LINE1,
          COL1 TYPE F VALUE '1.1e+10',
          COL2 TYPE I VALUE '1234',
          END OF LINE1,
          LINE2 LIKE LINE1.
    ASSIGN TEXT TO <F1>.
    ASSIGN NUM TO <F2>.
    DESCRIBE FIELD <F1> LENGTH <F2>.
    TEXT = 'CHAU'.
    WRITE: / <F1>, 'has length', NUM.
    WRITE: / TEXT, 'has length', NUM.
    ASSIGN LINE1 TO <F1>.
    ASSIGN LINE2-COL2 TO <F2>.
    MOVE <F1> TO LINE2.
    ASSIGN 'LINE2-COL2 =' TO <F1>.
    I just can't install SAPNWSP...I only got MiniSap...But I got all the development enviorment...Don't know about the User-Exits...Actually I don't think so...Because those "mini" systems doesn't come with any functional module.
    Greetings,
    Blag.

  • Problem after assigning  field-symbol in read statement...

    Hello Experts,
    I want to use a universal field-symbol in reading my internal tables so
    I can avoid declaring multiple work areas. Here is my code:
    FIELD-SYMBOLS: <fs_any> type any.
    READ TABLE lt_orderadm_h INDEX 1 ASSIGNING <fs_any>.
    Now when I try to insert this code:
    IF NOT <fs_any>-object_id IS INITIAL.
    ENDIF.
    It says that <fs_any> has no structure and therefore no component called object_id.
    I think that I need to use assign component for this but I don't know the code.
    Thank you guys and take care!

    Hi
    DATA : WA_ITORDERADM_H LIKE LINE OF IT_ORDERADM_H.
    **Try to assign the work area rather type any**
    FIELD-SYMBOLS: <fs_any> type WA_ITORDERADM_H.
    READ TABLE lt_orderadm_h INDEX 1 ASSIGNING <fs_any>.
    Now when I try to insert this code:
    IF NOT <fs_any>-object_id IS INITIAL.
    ENDIF.
    Check this program
    This works for me
    Simple program.
    TYPES: BEGIN OF NAME,
    NEXTNAME(10),
    FIRSTNAME(10),
    LASTNAME(10),
    END OF NAME.
    FIELD-SYMBOLS <F> TYPE NAME.
    DATA: LINE(30).
    LINE = 'JOHN SMITH SHRI'.
    ASSIGN LINE TO <F> CASTING.
    WRITE: / 'Lastname:', <F>-LASTNAME,
    'Firstname:', <F>-FIRSTNAME,
    'Nextname :', <F>-NEXTNAME
    Award points if helpful
    Thanks
    VENKI

  • How to move field symbol internal table to internal table with header line?

    Dear all,
    hi...hereby i would like to ask how i can move field symbol internal table to a internal table?
    as i know field symbol internal table is without header line..
    so, may i know how to do this....to move field symbol internal table to internal table which consist of header line and field and record will same as field symbol internal table...in additional, my field symbol internal table is dynamic table mean everytime will have flexible columns..?
    Please advise...
    Thanks
    Regard,
    ToToRo.
    Edited by: @ToToRo@ on Aug 20, 2009 6:16 AM

    Hello,
    Try this way:
    If both the type of internal tables are same then you can directly assign dynamic internal table to static internal table.
    itab = <itab>.
    Suppose you have field symbol internal table <itab> which is different in structure from ITAB.
    Now, you can create <wa> as follow:
    FIELD-SYMBOLS <wa>.
    DATA wa TYPE REF TO DATA.
    CREATE DATA wa TYPE LINE OF <itab>.
    ASSIGN wa->* to <wa>.
    This way your work area is read.
    Using [ASSIGN COMPONENT|http://help.sap.com/saphelp_nw04/helpdata/EN/fc/eb3923358411d1829f0000e829fbfe/content.htm] syntax you can read required component of <wa>.
    Finally you can use that value to load static internal table.
    You can also refer to my thread on [Dynamic table|Re: Creating Dynamic table].
    Hope this helps!
    Thanks,
    Augustin.
    Edited by: Augustarian on Aug 20, 2009 10:06 AM

  • Dynamically table read / write with field symbols

    Hi,
    I like to read dynamically from a table via field symbols. The reading part is working.
    But now I like to do some changes on the entry and then write it to another table with a similar structure.
    I use SAP 4.6c
    There I have two problems:
    1. At the statement I get a dump:
    <l_sysid> = sy-sysid.
    --> Field symbol has not yet been assigned.
    I think that the problem is somewhere around
    assign <table_to> to <wa_to>.
    2. the data change inside the loop. There I like to add the sysid to the target-wa and then copy the source-wa it to the new target-wa to append it to the target table.
    But this does not work. What kind of code do I need? The "move-correspondig" is not correct.
    --> see code around
    loop at <table_from> assigning <wa_from>.
    Below you can find my code. The problem is within the last loop-statement.
    FUNCTION Z_MIG_COPY_TABLE.
    *"*"Lokale Schnittstelle:
    *"  IMPORTING
    *"     REFERENCE(I_TABNAME_FROM) TYPE  TABNAME
    *"     REFERENCE(I_TABNAME_TO) TYPE  TABNAME
    *"     REFERENCE(I_KOMP_TRANS) LIKE  ZS_KOMP_TRANS STRUCTURE
    *"        ZS_KOMP_TRANS OPTIONAL
    *"  TABLES
    *"      I_SELCON STRUCTURE  ZS_SELCON
    *"  EXCEPTIONS
    *"      NOT_FOUND
    *"      OTHERS
    * zeilenweiser Aufbau Tabelle I_SELCON z.B.:
    * bukrs = 3011
    * AND
    * bstyp = 'F'
    * I_KOMP_TRANS
    * dient zur Uebersetzung von alt/neu, z.B. bei LIFNR
    * der angegebene Funktionsbaustein wird genutzt,
    * um den neuen Wert der übergebenen Komponente zu ermitteln
    * Angabe z.B.:
    * LIFNR
      DATA: dref       TYPE REF TO data,
            dref_to    TYPE REF TO data,
            i_alv_cat  TYPE TABLE OF lvc_s_fcat,
            ls_alv_cat LIKE LINE OF i_alv_cat,
            i_alv_cat_to  TYPE TABLE OF lvc_s_fcat,
            ls_alv_cat_to LIKE LINE OF i_alv_cat.
      DATA: BEGIN OF itab OCCURS 0.
    *        INCLUDE STRUCTURE dntab.
              INCLUDE structure DFIES.
      DATA: END OF itab.
      DATA: BEGIN OF itab_to OCCURS 0.
    *        INCLUDE STRUCTURE dntab.
              INCLUDE structure DFIES.
      DATA: END OF itab_to.
      FIELD-SYMBOLS: <table_from>   TYPE ANY TABLE.
      FIELD-SYMBOLS: <table_to>     TYPE Standard TABLE.
      FIELD-SYMBOLS: <wa_from>      TYPE ANY.
      FIELD-SYMBOLS: <wa_to>        TYPE ANY.
      FIELD-SYMBOLS: <l_komp>       TYPE ANY.
      FIELD-SYMBOLS: <l_sysid>      TYPE ANY.
      Data: l_alt type ELIFN.
      Data: l_neu type ELIFN.
      CALL FUNCTION 'DDIF_NAMETAB_GET'
           EXPORTING
                TABNAME   = i_tabname_from
           TABLES
                DFIES_TAB = itab
           EXCEPTIONS
                NOT_FOUND = 1
                OTHERS    = 2.
      IF SY-SUBRC = 1.
        raise not_found.
      elseif sy-subrc = 2.
        raise others.
      ENDIF.
      LOOP AT itab .
        ls_alv_cat-fieldname = itab-fieldname.
        ls_alv_cat-ref_table = i_tabname_from.
        ls_alv_cat-ref_field = itab-fieldname.
        APPEND ls_alv_cat TO i_alv_cat.
      ENDLOOP.
    * build internal table
      CALL METHOD cl_alv_table_create=>create_dynamic_table
          EXPORTING
            it_fieldcatalog = i_alv_cat
          IMPORTING
            ep_table = dref.
      ASSIGN dref->* TO <table_from>.
      CALL FUNCTION 'DDIF_NAMETAB_GET'
           EXPORTING
                TABNAME   = i_tabname_to
           TABLES
                DFIES_TAB = itab_to
           EXCEPTIONS
                NOT_FOUND = 1
                OTHERS    = 2.
      IF SY-SUBRC = 1.
        raise not_found.
      elseif sy-subrc = 2.
        raise others.
      ENDIF.
      LOOP AT itab_to.
        ls_alv_cat_to-fieldname = itab_to-fieldname.
        ls_alv_cat_to-ref_table = i_tabname_to.
        ls_alv_cat_to-ref_field = itab_to-fieldname.
        APPEND ls_alv_cat_to TO i_alv_cat_to.
      ENDLOOP.
    *  break-point.
    * build internal table
      CALL METHOD cl_alv_table_create=>create_dynamic_table
          EXPORTING
            it_fieldcatalog = i_alv_cat_to
          IMPORTING
            ep_table = dref_to.
      ASSIGN dref_to->* TO <table_to>.
    *Select Ursprungstabelle mit Selektionsbedingungen
      SELECT * FROM (i_tabname_from) up to 5 rows
        INTO CORRESPONDING FIELDS OF TABLE <table_from>
        where (i_selcon).
    *  break-point.
    *Aufbau interne Tabelle mit eventuell geänderten Feldern
      assign <table_to> to <wa_to>.
      if not I_KOMP_TRANS is initial.
        loop at <table_from> assigning <wa_from>.
          assign component I_KOMP_TRANS-KOMP
            of structure <wa_from> to <l_komp>.
          CALL FUNCTION I_KOMP_TRANS-FUBA
               EXPORTING
                    I_KOMP = I_KOMP_TRANS-KOMP
                    I_ALT  = <l_komp>
               IMPORTING
                    E_NEU  = <l_komp>.
          break-point.
          assign component 'SYSID' of structure <wa_to> to <l_sysid>.
          <l_sysid> = sy-sysid.
    *      move-corresponding <wa_from> to <wa_to>.
          append <wa_to> to <table_to>.
        endloop.
    *    break-point.
    *Speichern der ausgelesenen Daten in Zieltabelle
        MODIFY (i_tabname_to) FROM TABLE <table_to>.
        if sy-subrc <> 0.
          MESSAGE E001(ZMESSAGES) WITH i_tabname_to.
    *   Fehler beim Modify von Tabelle '&'.
        endif.
      else.
    *Speichern der ausgelesenen Daten in Zieltabelle
        MODIFY (i_tabname_to) FROM TABLE <table_from>.
        if sy-subrc <> 0.
          MESSAGE E001(ZMESSAGES) WITH i_tabname_to.
    *   Fehler beim Modify von Tabelle '&'.
        endif.
      endif.
      commit work.
      if sy-subrc <> 0.
        MESSAGE E002(ZMESSAGES) WITH i_tabname_to.
    *   Fehler beim Commit von Tabelle '&'.
      endif.
    *  break-point.
    ENDFUNCTION.
    Thanks a lot for any hints.
    Regards
    Tom

    Hi,
    Answers below.
    1) For this...you assigning an internal table to a work area...
    assign <table_to> to <wa_to>.
    This should solve the problem..
    * Create the target work area..
    DATA: new_line  TYPE REF TO data.
    CREATE DATA new_line LIKE LINE OF <table_to>.
    ASSIGN new_line->* TO <wa_to>.
    Now the target work area is created..
    2) For the second one...
    ************New code
       FIELD-SYMBOLS: <FS>,<FS1>.
    ************New code End.
       loop at <table_from> assigning <wa_from>.
          assign component I_KOMP_TRANS-KOMP
            of structure <wa_from> to <l_komp>.
          CALL FUNCTION I_KOMP_TRANS-FUBA
               EXPORTING
                    I_KOMP = I_KOMP_TRANS-KOMP
                    I_ALT  = <l_komp>
               IMPORTING
                    E_NEU  = <l_komp>.
          break-point.
          assign component 'SYSID' of structure <wa_to> to <l_sysid>.
          <l_sysid> = sy-sysid.
    ************New code
          LOOP AT itab .
             ASSIGN COMPONENT itab-fieldname of structure <WA_FROM> TO <FS>.
             CHECK SY-SUBRC = 0.
             ASSIGN COMPONENT itab-fieldname of structure <WA_TO> TO <FS1>.
             CHECK SY-SUBRC = 0.
    * Move from source to target.
             <FS1> = <FS>.
          ENDLOOP.
    ************New code End
          append <wa_to> to <table_to>.
        endloop.
    Thanks
    Naren

Maybe you are looking for