Skip to Content
author's profile photo Former Member
Former Member

write to server help

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.

Add a comment
10|10000 characters needed characters exceeded

Assigned Tags

Related questions

2 Answers

  • Best Answer
    author's profile photo Former Member
    Former Member
    Posted on Jul 11, 2007 at 03: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

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Jul 11, 2007 at 03: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

    Add a comment
    10|10000 characters needed characters exceeded

Before answering

You should only submit an answer when you are proposing a solution to the poster's problem. If you want the poster to clarify the question or provide more information, please leave a comment instead, requesting additional details. When answering, please include specifics, such as step-by-step instructions, context for the solution, and links to useful resources. Also, please make sure that you answer complies with our Rules of Engagement.
You must be Logged in to submit an answer.

Up to 10 attachments (including images) can be used with a maximum of 1.0 MB each and 10.5 MB total.