10-02-2008 3:15 PM
Hi members,
Need some help in completing this code. Thank you.
I have program which writes files on application server, Please let me know how can I give messages on sucefull completion or failure of data transfer.
IF p_Unix = X.
open dataset w_fname for output in text mode encoding default.
loop at itab into wa.
transfer wa to w_fname.
endloop.
Elseif p_desktop = X.
CALL FUNCTION 'GUI_DOWNLOAD'
EXPORTING
filename = local_file
filetype = 'ASC'
TABLES
data_tab = itab
EXCEPTIONS
file_write_error = 1
no_batch = 2
gui_refuse_filetransfer = 3
invalid_type = 4
no_authority = 5
unknown_error = 6
header_not_allowed = 7.
endif.
Please help me creating messages, eg : X number of records are transfered / No files were transfered.
Also please note that, BY default it is unix and will be running as back ground job.
Thank You
10-02-2008 3:19 PM
Something like this?
IF p_Unix = X.
open dataset w_fname for output in text mode encoding default.
loop at itab into wa.
transfer wa to w_fname.
endloop.
close dataset w_fname.
Elseif p_desktop = X.
CALL FUNCTION 'GUI_DOWNLOAD'
EXPORTING
filename = local_file
filetype = 'ASC'
TABLES
data_tab = itab
EXCEPTIONS
file_write_error = 1
no_batch = 2
gui_refuse_filetransfer = 3
invalid_type = 4
no_authority = 5
unknown_error = 6
header_not_allowed = 7.
endif.
if sy-subrc <> 0.
message e001(00) with "File was not transfered successfully".
else.
data: lines(5) type c.
data: message type char40.
lines = lines( itab ).
concatenate lines ' rows were transferred successsfully' into message.
message e001(00) with message.
endif.
Regards,
Rich Heilman
10-02-2008 3:19 PM
Something like this?
IF p_Unix = X.
open dataset w_fname for output in text mode encoding default.
loop at itab into wa.
transfer wa to w_fname.
endloop.
close dataset w_fname.
Elseif p_desktop = X.
CALL FUNCTION 'GUI_DOWNLOAD'
EXPORTING
filename = local_file
filetype = 'ASC'
TABLES
data_tab = itab
EXCEPTIONS
file_write_error = 1
no_batch = 2
gui_refuse_filetransfer = 3
invalid_type = 4
no_authority = 5
unknown_error = 6
header_not_allowed = 7.
endif.
if sy-subrc <> 0.
message e001(00) with "File was not transfered successfully".
else.
data: lines(5) type c.
data: message type char40.
lines = lines( itab ).
concatenate lines ' rows were transferred successsfully' into message.
message e001(00) with message.
endif.
Regards,
Rich Heilman
10-02-2008 3:46 PM
Rich / Aparna,
Thanks for your reply. I wonder, if I can use message statement in jobs running in background.
Please let me know.
Thank you.
10-02-2008 4:41 PM
You can use the Message statement for jobs running in background.
IF it is a success message you will see the text in the job log. If it encounters a message statement of type E(Error) then the job will cancel.
10-02-2008 3:20 PM
You can just check the value of sy-subrc. If sy-subrc is 0 then the transfer of file was successfull and the no of records transfered is equal to the no of records in the internal table.
10-02-2008 3:22 PM
try the below code....
describe table itab lines v_lines. " declare a variable v_lines.
IF p_Unix = X.
open dataset w_fname for output in text mode encoding default.
loop at itab into wa.
transfer wa to w_fname.
lines = lines + 1. " counter to read number of line transferred
endloop.
close dataset w_fname.
write : / ' number of line written to application server is' lines.
Elseif p_desktop = X.
CALL FUNCTION 'GUI_DOWNLOAD'
EXPORTING
filename = local_file
filetype = 'ASC'
TABLES
data_tab = itab
EXCEPTIONS
file_write_error = 1
no_batch = 2
gui_refuse_filetransfer = 3
invalid_type = 4
no_authority = 5
unknown_error = 6
header_not_allowed = 7.
endif.
10-02-2008 4:57 PM
Hi,
GUI_DOWNLOAD will not work for background job ..Please check this once...
Regards,
Bharani