Skip to Content
avatar image
Former Member

How do i empty a temporary table?

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
Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

1 Answer

  • Best Answer
    Nov 13, 2017 at 09:01 AM

    Have you tried REFRESH IOUT?

    Add comment
    10|10000 characters needed characters exceeded