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: 

clarification on move

Former Member
0 Kudos

tables : lfa1 .

data itab like lfa1 occurs 2 with header line.

select * from lfa1 into table itab.

loop at itab.

<b>move itab to lfa1.</b> ...

...

endloop.

Could you explain how this move statement works? Are we moving the data into lfa1 database table? This is from working example.

We all know the move staement works like this:

move <source> to <destination>

1 ACCEPTED SOLUTION

RichHeilman
Developer Advocate
Developer Advocate
0 Kudos

In this example, you are moving data from itab to a work area which has a structure like LFA1. It is not modifying the database yet. If you would have an INSERT, MODIFY, DELETE, or UPDATE statement afterwards, then it would be modified.

REgards,

Rich Heilman

8 REPLIES 8

Manohar2u
Active Contributor
0 Kudos

<b>Move</b> can also move entire internal table headers in a single shot. Than moving individual fields.

<b>Move</b> is advised to use than <b>Move-correspnding</b> clause.

Also refer to helplink..fyi

http://help.sap.com/saphelp_nw2004s/helpdata/en/fc/eb3260358411d1829f0000e829fbfe/content.htm

Regds

Manohar

RichHeilman
Developer Advocate
Developer Advocate
0 Kudos

In this example, you are moving data from itab to a work area which has a structure like LFA1. It is not modifying the database yet. If you would have an INSERT, MODIFY, DELETE, or UPDATE statement afterwards, then it would be modified.

REgards,

Rich Heilman

0 Kudos

Hi Rich,

This is a print program (Driver program) in Sapscript.

Could you explain the role of 'move' in this program? Why are we moving the data to a structure? (I ran this program it is working)

REPORT ZRIP_SCRIPT .

TABLES LFA1 .

DATA ITAB LIKE LFA1 OCCURS 2 WITH HEADER LINE .

SELECT * FROM LFA1 INTO TABLE ITAB.

CALL FUNCTION 'OPEN_FORM'

EXPORTING

APPLICATION = 'TX'

  • ARCHIVE_INDEX =

  • ARCHIVE_PARAMS =

DEVICE = 'PRINTER'

DIALOG = 'X'

FORM = 'ZSAPSCRIPT'

LANGUAGE = SY-LANGU

.

IF SY-SUBRC <> 0.

  • MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO

  • WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.

ENDIF.

LOOP AT ITAB .

<b>MOVE ITAB TO LFA1 .</b>

CALL FUNCTION 'WRITE_FORM'

EXPORTING

ELEMENT = 'ELELFA1'

FUNCTION = 'SET'

TYPE = 'BODY'

WINDOW = 'MAIN'

.

IF SY-SUBRC <> 0.

  • MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO

  • WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.

ENDIF.

ENDLOOP.

CALL FUNCTION 'CLOSE_FORM'

.

IF SY-SUBRC <> 0.

  • MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO

  • WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.

ENDIF.

0 Kudos

Hi Sreenath,

Its moving the work area of the itab to the workarea of LFA1 created by the TABLES statement.

Each pass of the loop will move the ITAB record into LFA1 work area for further use.

Cheers

VJ

0 Kudos

With this statement, in each loop pass of ITAB, the contents in the record of the internal tables are passed to the structure LFA1. This structure LFA1 is probably used in the Text element ELELFA1. You can verify his by opening the form ZSAPSCRIPT in SE71.

~Suresh

0 Kudos

In this case, the structure LFA1 is being used in the sapscript itself. Probably something like....

AS  &LFA1-LIFNR& &LFA1-NAME1&

The tables statement in the driver program provides a work area in which you are moving data to. Once the data is in the structure LFA1, it then can be displayed on the output.

It is practically the same as if you would define a structure in the print program yourself, something like,

data: begin of xoutput,
      lifnr type lfa1-lifnr,
      name1 type lfa1-name1,
      end of xoutput.

Then move the values from the itab to these fields.



LOOP AT ITAB .

<b>xoutput-lifnr = itab-lifnr.
xoutput-name1 = itab-name1.</b>
 


CALL FUNCTION 'WRITE_FORM'
EXPORTING
ELEMENT = 'ELELFA1'
FUNCTION = 'SET'
TYPE = 'BODY'
WINDOW = 'MAIN'
.
IF SY-SUBRC <> 0.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
* WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
ENDLOOP.



Then in the sapscript.....

AS  &XOUTOUT-LIFNR& &XOUTPUT-NAME1&

Does this help clarify a little?

Regards,

Rich Heilman

0 Kudos

Thank you Rich and every one.

0 Kudos

You are quite welcome.

Regards,

Rich Heilman