‎2007 Jul 11 4:21 PM
Hallow
hallow i send this table to server but the problem that after the second perform
delete the data that write in first perform and so on ,how can i write to the same file all the table like append?
Regards
PERFORM write_2_server TABLES hire_emp_tab.
PERFORM write_2_server TABLES entrance_tab.
PERFORM write_2_server TABLES integration_tab.
PERFORM write_2_server TABLES duty_tab .
FIELD-SYMBOLS: <wa> TYPE ANY.
" MOVE 'D:_pa_test_mmsk_pa1.txt' TO adress.
OPEN DATASET adress IN TEXT MODE
ENCODING DEFAULT FOR OUTPUT.
IF sy-subrc = 0.
no_file = ' '.
LOOP AT p_tab_data ASSIGNING <wa>.
TRANSFER <wa> TO adress.
ENDLOOP.
CLOSE DATASET adress.
ELSE.
no_file = 'X'.
ENDIF.
‎2007 Jul 11 4:32 PM
if you use open dataset for output,it deletes the previous data and it will insert new data.
in your case you have 4 perform statement,first perform it puts the data and second perform it delete the old data
and inserting new data.
so use append statement
Opening a File for Appending Data
To open a file so that you can append data to the end of it, use the FOR APPENDING addition in the OPEN DATASET statement:
Syntax
OPEN DATASET <dsn> FOR APPENDING.
This statement opens a file to which you can append data. If the file does not already exist, it is created automatically. If it does exist, but is closed, the system opens it, and sets the position to the end of the file. If the file exists and is already open (for read or write access, or for appending), the position is set to the end of the file. SY-SUBRC is always 0.
OPEN DATASET FNAME FOR APPENDING.
check the below help :
It is good programming style to close files that are already open before you reopen them for a different operation (for further information about closing files, refer to Closing a File).
DATA FNAME(60) VALUE 'myfile'.
DATA NUM TYPE I.
OPEN DATASET FNAME FOR OUTPUT.
DO 5 TIMES.
NUM = NUM + 1.
TRANSFER NUM TO FNAME.
ENDDO.
OPEN DATASET FNAME FOR INPUT.
OPEN DATASET FNAME FOR APPENDING.
NUM = 0.
DO 5 TIMES.
NUM = NUM + 10.
TRANSFER NUM TO FNAME.
ENDDO.
OPEN DATASET FNAME FOR INPUT.
DO.
READ DATASET FNAME INTO NUM.
IF SY-SUBRC <> 0.
EXIT.
ENDIF.
WRITE / NUM.
ENDDO.
Thanks
Seshu
‎2007 Jul 11 4:24 PM
Well, you'll have to open a different dataset each time you perform the form write_2_server. You can pass the dataset name each time you call it.
rob
‎2007 Jul 11 4:29 PM
‎2007 Jul 11 4:32 PM
if you use open dataset for output,it deletes the previous data and it will insert new data.
in your case you have 4 perform statement,first perform it puts the data and second perform it delete the old data
and inserting new data.
so use append statement
Opening a File for Appending Data
To open a file so that you can append data to the end of it, use the FOR APPENDING addition in the OPEN DATASET statement:
Syntax
OPEN DATASET <dsn> FOR APPENDING.
This statement opens a file to which you can append data. If the file does not already exist, it is created automatically. If it does exist, but is closed, the system opens it, and sets the position to the end of the file. If the file exists and is already open (for read or write access, or for appending), the position is set to the end of the file. SY-SUBRC is always 0.
OPEN DATASET FNAME FOR APPENDING.
check the below help :
It is good programming style to close files that are already open before you reopen them for a different operation (for further information about closing files, refer to Closing a File).
DATA FNAME(60) VALUE 'myfile'.
DATA NUM TYPE I.
OPEN DATASET FNAME FOR OUTPUT.
DO 5 TIMES.
NUM = NUM + 1.
TRANSFER NUM TO FNAME.
ENDDO.
OPEN DATASET FNAME FOR INPUT.
OPEN DATASET FNAME FOR APPENDING.
NUM = 0.
DO 5 TIMES.
NUM = NUM + 10.
TRANSFER NUM TO FNAME.
ENDDO.
OPEN DATASET FNAME FOR INPUT.
DO.
READ DATASET FNAME INTO NUM.
IF SY-SUBRC <> 0.
EXIT.
ENDIF.
WRITE / NUM.
ENDDO.
Thanks
Seshu
‎2007 Jul 11 4:44 PM