Skip to Content
author's profile photo Former Member
Former Member

how to assign a whole internal table to field symbol

Can anyone explain me that , can we assign the whole internal table to a field symbol .If yes please explain with some simple example by assigning an internal tabl data to a field symbol and how to loop on to that field symbol to write the data from it.

Please don't paste the F1 help .

Thanks,

Rose.

Add a comment
10|10000 characters needed characters exceeded

Assigned Tags

Related questions

5 Answers

  • author's profile photo Former Member
    Former Member
    Posted on Jan 22, 2008 at 10:19 AM

    Hi,

    DATA wa1(512) TYPE table-type.

    FIELD-SYMBOLS STRUCTURE scarr DEFAULT wa1.

    -carrid = '...'.

    DATA wa2(512) TYPE c.

    FIELD-SYMBOLS TYPE scarr.

    ASSIGN wa2 TO CASTING.

    -carrid = '...'.

    PLzz reward points if it helps.

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Jan 22, 2008 at 10:20 AM

    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.

    or

    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.

    The field symbol <fs> is fully typed as a structure, and you can address its components in the program

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Jan 22, 2008 at 10:21 AM

    Hi Rose

    There are two ways of doing this,

    1) Assign entire internal table

    data : itab type standard table of mara.

    field-symbols : <fs_itab> type standard table,

    <wa_itab> type mara.

    assign <fs_itab> to itab.

    loop at <fs_itab> assigning <wa_itab>.

    write : / <wa_itab>-matnr.

    endlooop.

    2) Assign each record from internal table and print it,

    data : itab type standard table of mara.

    field-symbols : <wa_itab> type mara.

    loop at itab assigning <wa_itab>.

    write : / <wa_itab>-matnr.

    endlooop.

    Please check whatever is more relevant for your design.

    Regards

    Ranganath

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Jan 22, 2008 at 10:32 AM

    hi

    good

    check this code

    ) Defining the table records and the field symbol in a similar type.

    • just an ordinary standard table

    TYPES: BEGIN OF it_vbak_line,

    vbeln LIKE vbak-vbeln,

    vkorg LIKE vbak-vkorg,

    vtweg LIKE vbak-vtweg,

    spart LIKE vbak-spart,

    kunnr LIKE vbak-kunnr,

    END OF it_vbak_line.

    DATA: it_vbak TYPE TABLE OF it_vbak_line.

    FIELD-SYMBOLS: <it_vbak_line> TYPE it_vbak_line.

    • or as a screaming fast hash table for keyed reads

    TYPES: BEGIN OF it_vbpa_line,

    vbeln LIKE vbak-vbeln,

    kunnr LIKE vbak-kunnr,

    END OF it_vbpa_line.

    DATA: it_vbpa TYPE HASHED TABLE OF it_vbpa_line

    WITH UNIQUE KEY vbeln.

    FIELD-SYMBOLS: <it_vbpa_line> TYPE it_vbpa_line.

    2) In ITAB processing, utilize the ASSIGNING command.

    • loop example

    LOOP AT it_vbak ASSIGNING <it_vbak_line>.

    • look at records--populate it_zpartner

    • read example

    READ TABLE it_vbpa ASSIGNING <it_vbpa_line>

    WITH TABLE KEY vbeln = <it_vbak_line>-vbeln.

    3) Refer to the field symbol's fields in the loop or after the read.

    wa_zpartner-vkorg = <it_vbak_line>-vkorg.

    wa_zpartner-vtweg = <it_vbak_line>-vtweg.

    wa_zpartner-spart = <it_vbak_line>-spart.

    wa_zpartner-kunag = <it_vbak_line>-kunnr.

    wa_zpartner-kunwe = <it_vbpa_line>-kunnr.

    See the code example below for further detail. The code was written in R/3 4.6C and should work for all 4.x versions.

    thanks

    mrutyun^

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Jan 22, 2008 at 10:35 AM

    hi

    example code

    field-symbols: <fs>.

    data: begin of it_vbrp,

    vbeln like vbrp-vbeln,

    posnr like vbrp-posnr,

    brgew like vbrp-brgew,

    ntgew like vbrp-ntgew,

    end of it_vbrp.

    data: begin of it_vbrp2,

    vbeln like vbrp-vbeln,

    posnr like vbrp-posnr,

    brgew like vbrp-brgew,

    • ntgew like vbrp-ntgew,

    end of it_vbrp2.

    select vbeln

    posnr

    brgew

    ntgew

    from vbrp

    into corresponding fields of it_vbrp

    where vbeln between '0090059462' and '0090060327'.

    assign it_vbrp to <fs>.

    write:/ <fs>.

    move <fs> to it_vbrp2.

    clear <fs>.

    endselect.

    Add a comment
    10|10000 characters needed characters exceeded

Before answering

You should only submit an answer when you are proposing a solution to the poster's problem. If you want the poster to clarify the question or provide more information, please leave a comment instead, requesting additional details. When answering, please include specifics, such as step-by-step instructions, context for the solution, and links to useful resources. Also, please make sure that you answer complies with our Rules of Engagement.
You must be Logged in to submit an answer.

Up to 10 attachments (including images) can be used with a maximum of 1.0 MB each and 10.5 MB total.