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: 

How to use field symbol for internal table

Former Member
0 Kudos

Hi all,

Can you explain about what is field symbol,

and how to use the field symbol for internal tables.

Need is:

I must use the single SubRoutine and pass the different internal tables to it like gt_header, gt_details.

The single subroutine should work for different internal tables which are having different structures.

Please provide valuble information.

5 REPLIES 5

Former Member
0 Kudos

Hi

Field-symbol is a variable has the chararcteristic assigned dynamically.

So for example:

DATA: ITAB_HEADER LIKE STANDARD TABLE OF BKPF,

ITAB_ITEM LIKE STANDARD TABLE OF BSEG.

FIELD-SYMBOLS: <TABLE> TYPE TABLE,

<WA> TYPE ANY.

ASSIGN ITAB_HEADER[] TO <TABLE>.

--> Here the field-symbols <TABLE> is ITAB_HEADER

ASSIGN ITAB_ITEM[] TO <TABLE>.

--> Here the field-symbols <TABLE> is ITAB_ITEM

LOOP AT <ITAB> ASSIGNING <WA>.

ENDLOOP.

Max

LeonardoAraujo
Active Contributor
0 Kudos

Good answer provided by Max.

I would add this piece of code example that might just be what you need...

Try this:

DATA:  it_vbak  TYPE TABLE OF vbak,
       it_likp  TYPE TABLE OF likp.
       

PERFORM write_lines USING it_vbak.

PERFORM write_lines USING it_likp.


*&---------------------------------------------------------------------*
*&      Form  write_lines
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
*      -->I_TABLE    text
*----------------------------------------------------------------------*
FORM write_lines USING i_table TYPE table.
  FIELD-SYMBOLS: <line> TYPE ANY.

  LOOP AT i_table ASSIGNING <line>.
    WRITE <line>.
  ENDLOOP.

ENDFORM.                    "write_lines

Hope this helps...

Leonardo De Araujo

0 Kudos

Need is like this.

FORM get_materials_data USING lt_table TYPE table.

  • Get the data from QALS(Inspection lot record) table.

SELECT prueflos " Inspection Lot Number

werk " Plant

matnr " Material Number

charg " Batch number

lgtyp " Storage Type

lgpla " Storage Bin

FROM qals

INTO TABLE gt_qals

FOR ALL ENTRIES IN lt_table

WHERE werk IN s_plant

AND matnr IN s_mat_n

AND prueflos EQ lt_table-yyqplos.

IF sy-subrc EQ 0.

  • Get Material Description and Material Group.

PERFORM get_mat_desc.

ENDIF. " IF SY-SUBRC EQ 0.

ENDFORM. " get_materials_data

0 Kudos

Hi,

Try something like this :

DATA: wt_ref_data  TYPE REF TO DATA.
FIELD-SYMBOLS: <ft_data>  TYE STANDARD TABLE.

CREATE DATA wt_ref_data TYPE TABLE OF qals.
ASSIGN wt_ref_data->* TO <ft_data>.

SELECT ... INTO TABLE <ft_data> FOR ALL ENTRIES ...

PERFORM get_mat_desc USING <ft_data>.

Best regards,

Guillaume

Message was edited by: Guillaume Garcia

Former Member
0 Kudos

Hi,

This statement declares a symbolic field called <fs>. At

runtime, you can assign a concrete field to the field symbol

using ASSIGN. All operations performed with the field symbol

then directly affect the field assigned to it.

FIELD-SYMBOLS <PT>.

TABLES SFLIGHT.

...

ASSIGN SFLIGHT-PLANETYPE TO <PT>.

WRITE <PT>.

Regards

amole