Application Development and Automation 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: 
Read only

Assign field symbol to table line?

Former Member
0 Kudos
3,712

Hello experts,

is it possible to point a table line to a variable?

I have an itab it_mara type mara with 10 entry´s.

If i type it_mara[1] in debugger the programm points perfectly to the structure of line 1.

If i type it_mara[2] in debugger the programm points perfectly to the structure of line 2.

This function i need in my code but:

assgin ('it_mara[1]') to <fs_mara>        doesn´t work

Anyone an idea?

5 REPLIES 5
Read only

Former Member
0 Kudos
1,354

Hi

Why don't use READ statament?

ASSIGN ('IT_MARA[]') TO <FS_MARA_T>.

READ TABLE <FS_MARA_T> ASSIGNING <FS_MARA> INDEX 1.

Max

Read only

RaymondGiuseppi
Active Contributor
0 Kudos
1,354

Yes assign line thru statements READ or equivalent with ASSIGNING option

/or/

Upgrade your SAP to a recent version

Regards,

Raymond

Read only

0 Kudos
1,354

i can´t use read statement because in my application i build a path through a deep structure:

it_mara[1]-texts[2]-long

U know what i mean?

Yes i can capsule it, but i thought there is a easier way... The debugger can do this

Read only

0 Kudos
1,354

The delights of scuba diving in the deep structures

  • LOOP AT/READ TABLE itab1 ... ASSIGNING <fs1>,
  • ASSIGN COMPONENT fieldname  OF STRUCTURE <fs1> to <fs2>
  • LOOP AT/READ TABLE <fs2> ...  ASSIGNING <fs3>
  • etc.

The debugger can do this, but is everybody able and has time and opportunity to rewrite the debugger...


Regards,

Raymond

Read only

0 Kudos
1,354

Hi

If you know the defination of source structure, you can define your field symbol like that:


TYPES: BEGIN OF TY_01,

          FIELD1,

        END   OF TY_01.

TYPESTTY_01 TYPE STANDARD TABLE OF TY_01.

*

DATA: BEGIN OF ITAB OCCURS 0,

          FIELD,

          FIELD_TAB TYPE TTY_01,

       END   OF ITAB.

DATA: WA TYPE TY_01.

*

FIELD-SYMBOLS: <FS_ITAB>      TYPE TABLE.

FIELD-SYMBOLS: <FS_WA_ITAB>   LIKE ITAB.

FIELD-SYMBOLS: <FS_WA>        TYPE ANY.

DO 4 TIMES.

   MOVE SY-INDEX TO ITAB-FIELD.

   DO 6 TIMES.

     MOVE SY-INDEX TO WA-FIELD1.

     APPEND WA TO ITAB-FIELD_TAB.

   ENDDO.

   APPEND ITAB.

   FREE ITAB-FIELD_TAB.

ENDDO.

ASSIGN ('ITAB[]') TO <FS_ITAB>.

READ TABLE <FS_ITAB> ASSIGNING <FS_WA_ITAB> INDEX 1.

READ TABLE <FS_WA_ITAB>-FIELD_TAB ASSIGNING <FS_WA> INDEX 2.

WRITE <FS_WA>.