Skip to Content
0

How do i empty a temporary table?

Nov 13, 2017 at 08:42 AM

16

avatar image
Former Member

Hi,

I am exporting information from Z-table about employee work hours to separate files on the server. The first file it creates is perfect. The second contains both the first lines i exported + the new lines, the 3rd file contains export 1+2+the new.

The problem seams to be that the temp file is not empty when it starts each export - it add up the lines all the time.

How can i empty the file ("iout") between each export?

(i have checked the "iout" and can see that it adds up the lines for each loop)

In short the code is like this:

Data: i_emplo type standard table of zemplo with header line,

i_hours type standard table of zhours with header line,

iout type table of string WITH HEADER LINE,
xout type string,
xhea type string,
zfil type string.

*

SELECT * FROM ZEMPL INTO TABLE I_EMPLO*

LOOP AT I_EMPLO

FIELD-SYMBOLS: <fs>.

CLEAR IOUT.

SELECT * FROM ZHOURS INTO TABLE I_HOURS

WHERE EMPNO = I_EMPLO-EMPNO.

LOOP AT I_HOURS.

CLEAR xout.

DO.ASSIGN COMPONENT sy-index OF STRUCTURE I_HOURS TO <fs>.

IF sy-subrc <> 0.

EXIT.

ENDIF.

IF sy-index = 1.
xout = <fs>.

ELSE.

xout = I_HOURS-TEKST.

ENDIF.

ENDDO.

APPEND xout TO iout.

ENDLOOP.

CONCATENATE '\\server-name\' I_EMPLO-EMPNO '.txt' INTO ZFIL.

OPEN DATASET ZFIL FOR OUTPUT IN TEXT MODE encoding default.

LOOP AT IOUT.

TRANSFER iout TO ZFIL.

ENDLOOP.

CLOSE DATASET ZFIL.

ENDLOOP.

SQL
10 |10000 characters needed characters left characters exceeded
* Please Login or Register to Answer, Follow or Comment.

1 Answer

Best Answer
Glen Anthony Nov 13, 2017 at 09:01 AM
0

Have you tried REFRESH IOUT?

Show 1 Share
10 |10000 characters needed characters left characters exceeded
Former Member

THANK YOU VERY MUCH:-) I knew it was just a detail;-)

Very much appreciated.

0