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

Insert <fs>

Former Member
0 Likes
676

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

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
644

*&---------------------------------------------------------------------*
*& 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.

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

4 REPLIES 4
Read only

Former Member
0 Likes
644

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.

Read only

Former Member
0 Likes
645

*&---------------------------------------------------------------------*
*& 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.
Read only

Former Member
0 Likes
644

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

Read only

Former Member
0 Likes
644

thankx