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: 

Insert <fs>

Former Member
0 Kudos

How to move the values in a field symbol to an table.?

1 ACCEPTED SOLUTION

former_member212653
Active Contributor
0 Kudos

*&---------------------------------------------------------------------*
*& Report  ZTEST112
*&
*&---------------------------------------------------------------------*
*&
*&
*&---------------------------------------------------------------------*

REPORT  ztest112.

TYPES:
BEGIN OF x_mara,
  matnr TYPE matnr,
END OF x_mara,
x_t_mara TYPE STANDARD TABLE OF x_mara.

FIELD-SYMBOLS: <f1> TYPE x_t_mara,
               <f2> TYPE x_mara.

DATA: i_mara TYPE STANDARD TABLE OF x_mara INITIAL SIZE 0.

ASSIGN i_mara TO <f1>.
SELECT matnr FROM mara
  UP TO 50 ROWS
INTO TABLE <f1>.
IF sy-subrc = 0.
  i_mara = <f1>.  " <---- move from FS to itab
 UNASSIGN <f1>.
ENDIF.
FORMAT COLOR 5 ON INVERSE ON.
LOOP AT i_mara ASSIGNING <f2>.

  WRITE: /10 <f2>-matnr.

ENDLOOP.
FORMAT COLOR 5 OFF.
4 REPLIES 4

Former Member
0 Kudos

if you have the data in <fs> then you need to do this way...

mara-matnr = <fs>-matnr.

mara-maktx = <fs>-maktx.

other fields folow...........

insert mara.

former_member212653
Active Contributor
0 Kudos

*&---------------------------------------------------------------------*
*& Report  ZTEST112
*&
*&---------------------------------------------------------------------*
*&
*&
*&---------------------------------------------------------------------*

REPORT  ztest112.

TYPES:
BEGIN OF x_mara,
  matnr TYPE matnr,
END OF x_mara,
x_t_mara TYPE STANDARD TABLE OF x_mara.

FIELD-SYMBOLS: <f1> TYPE x_t_mara,
               <f2> TYPE x_mara.

DATA: i_mara TYPE STANDARD TABLE OF x_mara INITIAL SIZE 0.

ASSIGN i_mara TO <f1>.
SELECT matnr FROM mara
  UP TO 50 ROWS
INTO TABLE <f1>.
IF sy-subrc = 0.
  i_mara = <f1>.  " <---- move from FS to itab
 UNASSIGN <f1>.
ENDIF.
FORMAT COLOR 5 ON INVERSE ON.
LOOP AT i_mara ASSIGNING <f2>.

  WRITE: /10 <f2>-matnr.

ENDLOOP.
FORMAT COLOR 5 OFF.

Former Member
0 Kudos

Say you want to move lt_itab to lt_itab1. Below code will move data from lt_itab to lt_itab1 using a field symbol .

FIELD-SYMBOLS <FS> TYPE ANY.

DATA LV_STR TYPE STRING.

LV_STR = 'LT_ITAB1'.

ASSIGN (LV_STR) TO <FS>.

<FS> = LT_ITAB.

thats it...

~Piyush Patil

Former Member
0 Kudos

thankx