2012 Oct 12 6:47 PM
I'm working on a program someone else wrote. The program takes delivery information, goes through a template, and saves a "label template" into an internal table. The internal table, BUF2, only has that one line that contains all the control characters and such. Now after this is done, the program uses WS_DOWNLOAD to send to either COM1 or LPT1. Here is the code it uses.
MOVE: zshp_printers-local_port TO out_port.
CALL FUNCTION 'WS_DOWNLOAD'
EXPORTING
filename = out_port
filetype = 'ASC'
mode = 'S'
TABLES
data_tab = buf2
EXCEPTIONS
file_open_error = 01
file_write_error = 02
invalid_filesize = 03
invalid_table_width = 04
invalid_type = 05
no_batch = 06
unknown_error = 07.
the variable out_port is either 'COM1' or 'LPT1'. Now this works with our Windows XP machines, however, I'm trying to setup a Windows 7 PC to run this and I get the UNKNOWN_ERROR exception. I've tried looking this up and I haven't found anything that has to do with sending a file to a port. Does anyone have any ideas?
Thanks,
Curtis
2012 Oct 12 6:56 PM
WS_DOWNLOAD is marked as obsolete in my system. What Basis version are you on? If it's available in your system, have you tried using CL_GUI_FRONTEND_SERVICES=>GUI_DOWNLOAD instead?
Having said that, i'm not sure whether specifying the port in place of the filename was functionality provided by WindowsXP or SAPGui. If it was provided by WindowsXP I wouldn't be surprised if it was dropped for Windows Vista/7. If I remember correctly, for Vista/7 Microsoft made some fundamental changes to the way peripherals, printing, and networking work. You might want to look into whether a new version of SAPGui will get the functionality back.
I'm working on a program someone else wrote. The program takes delivery information, goes through a template, and saves a "label template" into an internal table. The internal table, BUF2, only has that one line that contains all the control characters and such. Now after this is done, the program uses WS_DOWNLOAD to send to either COM1 or LPT1. Here is the code it uses.
MOVE: zshp_printers-local_port TO out_port.
CALL FUNCTION 'WS_DOWNLOAD'
EXPORTING
filename = out_port
filetype = 'ASC'
mode = 'S'
TABLES
data_tab = buf2
EXCEPTIONS
file_open_error = 01
file_write_error = 02
invalid_filesize = 03
invalid_table_width = 04
invalid_type = 05
no_batch = 06
unknown_error = 07.
the variable out_port is either 'COM1' or 'LPT1'. Now this works with our Windows XP machines, however, I'm trying to setup a Windows 7 PC to run this and I get the UNKNOWN_ERROR exception. I've tried looking this up and I haven't found anything that has to do with sending a file to a port. Does anyone have any ideas?
Thanks,
Curtis
2012 Oct 12 6:56 PM
WS_DOWNLOAD is marked as obsolete in my system. What Basis version are you on? If it's available in your system, have you tried using CL_GUI_FRONTEND_SERVICES=>GUI_DOWNLOAD instead?
Having said that, i'm not sure whether specifying the port in place of the filename was functionality provided by WindowsXP or SAPGui. If it was provided by WindowsXP I wouldn't be surprised if it was dropped for Windows Vista/7. If I remember correctly, for Vista/7 Microsoft made some fundamental changes to the way peripherals, printing, and networking work. You might want to look into whether a new version of SAPGui will get the functionality back.
2012 Oct 12 7:58 PM
Alex,
I changed the code to...
MOVE: zshp_printers-local_port TO str_port.
CALL METHOD cl_gui_frontend_services=>gui_download
EXPORTING
filename = str_port
filetype = 'ASC'
CHANGING
data_tab = buf2
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
separator_not_allowed = 8
filesize_not_allowed = 9
header_too_long = 10
dp_error_create = 11
dp_error_send = 12
dp_error_write = 13
unknown_dp_error = 14
access_denied = 15
dp_out_of_memory = 16
disk_full = 17
dp_timeout = 18
file_not_found = 19
dataprovider_exception = 20
control_flush_error = 21
not_supported_by_gui = 22
error_no_gui = 23
OTHERS = 24.
What I got was a SY-SUBRC of 15, ACCESS_DENIED, so yeah, something must have changed with permissions to the printer. Do you have any clue how to get around that? I'll keep looking too.
Thanks,
Curtis
2012 Oct 15 3:59 PM
I found out the issue. I used the following to help figure it out.
http://scn.sap.com/thread/3204528
After disabling the security module in the GUI it worked.
Thanks all,
Curtis
2012 Oct 15 4:17 PM
A few thoughts:
- Take a look at the SY message variables after the ACCESS_DENIED exception has been raised (sy-msgid, sy-msgno, etc.). The message they refer to might give additional details about the nature of teh exception.
- After a quick google, it sounds like Win7 should still allow you to write to a port as if it were a file, at least in the command prompt. Have you checked in Device Manager to make sure that the COM1 & LPT1 ports are available, and named the same? Have you tried writing a file to these ports within the Command Prompt, just as a test?
- Have you tried running the SAP Gui as an administrator?
| User | Count |
|---|---|
| 4 | |
| 2 | |
| 2 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 |