08-13-2006 9:10 PM
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>
08-13-2006 11:04 PM
08-13-2006 9:29 PM
<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
08-13-2006 11:04 PM
08-14-2006 1:38 AM
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.
08-14-2006 1:40 AM
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
08-14-2006 1:45 AM
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
08-14-2006 2:19 AM
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
08-14-2006 2:40 AM
08-14-2006 2:42 AM