Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
329 views
in Technique[技术] by (71.8m points)

python - Change encoding, downloading file from SAP

I'm trying to download some documents via SAP GUI using Python, but I get them with a wrong encoding.

When I tried UTF8 manually - i got the wrong encoding. Changed Codepage settings in connection options to ANSI encoding and was glad to see fine results working manually.

But with the same SAP connection SAP GUI Scripting proceeds getting same wrong results, as it was with UTF8. Encoding errors come only when icon "SAP GUI Scripting: Script is running" is on. As I understand, on Windows server SAP GUI always uses utf8 with Scripting, ignoring my connection settings.

In SAP GUI Scripting API I found SaveAsUnicode session property, which is True by default: session.saveAsUnicode = 0 makes it False, but it does not help. All other methods, connected with code-page are read-only.

So how can I force SAP GUI use different encoding, use my settings downloading files?


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

Solved with the use of a SAP Logon Shortcut. If we connect with it, but not with a call of SAPGui.exe, the coding is perfect. We even have written a self-made decoder for windows 1251 for this problem, but did not need it, because of the use of shortcut.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...