Skip to Content

Archived discussions are read-only. Learn more about SAP Q&A

Dinamically choose field of internal table

Hello

Lets assume internal table has fields F1, F2, F3 of the same length and type.

Is it posible to dynamically assign choose a field of the table like

Field = 'Field1'

Loop at itab assigning <FS>.

<FS>-FIELD = 100.

Endloop.

Former Member
Former Member replied

Hi,

With slight modification to your code it is possible.check below sample code.

TABLES vbak.

PARAMETERS: po_1(10) TYPE c .

DATA: l_ref TYPE REF TO DATA.

FIELD-SYMBOLS: <vbak> TYPE ANY,
               <temp> TYPE ANY.

CREATE DATA l_ref LIKE vbak.
ASSIGN l_ref->* TO <vbak>.
<vbak> = '10012345'.
"po_1 has value VBELN
ASSIGN COMPONENT po_1 OF STRUCTURE <vbak> TO <temp>.
WRITE: /1 <temp>.
<temp> = '54321'.

WRITE:/1  <temp>. "At this point <vbak>-vbeln  also has the same value(54321) 

Thanks,

Vinod.

0 View this answer in context
Not what you were looking for? View more on this topic or Ask a question