07-02-2008 4:17 AM
Hello,
I have textfile in appserver. I want to change some lines in it. Using dataset, how to do this?
Thanks,
Sid
07-02-2008 4:20 AM
using open dataset get the file into the internal table modify it and re write to the same path.
to read the file into internal table.
OPEN DATASET p_ufile FOR INPUT IN TEXT MODE.
IF sy-subrc <> 0.
EXIT.
ENDIF.
DO.
READ DATASET p_ufile INTO wa_file.
IF sy-subrc <> 0.
EXIT.
ENDIF.
ASSIGN wa_file TO <wa_table>.
APPEND <wa_table> TO p_table.
CLEAR wa_file.
ENDDO.
CLOSE DATASET p_ufile.
ENDIF.
modify ur p_table as per ur requirement..
to re-write file back to the same path.
OPEN DATASET p_ufile FOR OUTPUT IN TEXT MODE.
IF sy-subrc <> 0.
EXIT.
ENDIF.
LOOP AT p_output INTO wa_file.
TRANSFER wa_file TO p_ufile.
CLEAR wa_file.
ENDLOOP.
CLOSE DATASET p_ufile.
07-02-2008 4:20 AM
using open dataset get the file into the internal table modify it and re write to the same path.
to read the file into internal table.
OPEN DATASET p_ufile FOR INPUT IN TEXT MODE.
IF sy-subrc <> 0.
EXIT.
ENDIF.
DO.
READ DATASET p_ufile INTO wa_file.
IF sy-subrc <> 0.
EXIT.
ENDIF.
ASSIGN wa_file TO <wa_table>.
APPEND <wa_table> TO p_table.
CLEAR wa_file.
ENDDO.
CLOSE DATASET p_ufile.
ENDIF.
modify ur p_table as per ur requirement..
to re-write file back to the same path.
OPEN DATASET p_ufile FOR OUTPUT IN TEXT MODE.
IF sy-subrc <> 0.
EXIT.
ENDIF.
LOOP AT p_output INTO wa_file.
TRANSFER wa_file TO p_ufile.
CLEAR wa_file.
ENDLOOP.
CLOSE DATASET p_ufile.
07-02-2008 4:37 AM
Thanks Jay. How do you declare wa_file and p_output. pls.write some example. thanks.
07-02-2008 4:42 AM
Hi there...
data: wa_field type string.
data: p_output type standard table of string.
or
data: begin of p_output,
data(1000) type c,
end of p_output.
assign points for all useful answers.