Application Development 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: 

How to give message when files are transfered..Thank you

Former Member
0 Kudos

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

1 ACCEPTED SOLUTION

RichHeilman
Developer Advocate
Developer Advocate
0 Kudos

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

6 REPLIES 6

RichHeilman
Developer Advocate
Developer Advocate
0 Kudos

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

0 Kudos

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.

0 Kudos

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.

Former Member
0 Kudos

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.

sastry_gunturi
Active Participant
0 Kudos

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.

P561888
Active Contributor
0 Kudos

Hi,

GUI_DOWNLOAD will not work for background job ..Please check this once...

Regards,

Bharani