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

How do i empty a temporary table?

Former Member
0 Likes
880
  • SAP Managed Tags

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.

1 ACCEPTED SOLUTION
Read only

former_member201275
Active Contributor
0 Likes
824
  • SAP Managed Tags

Have you tried REFRESH IOUT?

2 REPLIES 2
Read only

former_member201275
Active Contributor
0 Likes
825
  • SAP Managed Tags

Have you tried REFRESH IOUT?

Read only

0 Likes
824
  • SAP Managed Tags

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

Very much appreciated.