天天看点

使用 SAP UI5 ABAP Repository 部署本地 SAP UI5 应用到 ABAP 服务器的单步调试

CL_GUI_FRONTEND_SERVICES 提供了 GET_SAPLOGON_ENCODING 方法,能返回 SAPGUI 环境下默认的系统 System Code page 值。

使用函数 ​

​SCP_CODEPAGE_FOR_LANGUAGE​

​ 获得系统当前的 Code Page:

输入参数为当前系统登录语言。

使用 SAP UI5 ABAP Repository 部署本地 SAP UI5 应用到 ABAP 服务器的单步调试

这里得知,语言 E 的 System Code page 为 4103:

TCP00 数据库表里,4103 是字符集 UTF16-LE 在 ABAP 系统的编号。

使用 SAP UI5 ABAP Repository 部署本地 SAP UI5 应用到 ABAP 服务器的单步调试

这个 FETYPE 是 Frontend Type 的意思吗?值为 MS,是指 Microsoft 操作系统吗?

使用 SAP UI5 ABAP Repository 部署本地 SAP UI5 应用到 ABAP 服务器的单步调试

frontend codepage 通过 CALL 调用之后,值变为 1160:

使用 SAP UI5 ABAP Repository 部署本地 SAP UI5 应用到 ABAP 服务器的单步调试

在 TCP00 数据库表里,1160 Code Page 对应的 CPCompany 为 MS,果然是 Microsoft 的意思。这里还有其他的 provider company,比如 IBM,SAP 等。

使用 SAP UI5 ABAP Repository 部署本地 SAP UI5 应用到 ABAP 服务器的单步调试

CPENCODING 的值 为 4:ISO/ASCII-base, 8 bits

使用 SAP UI5 ABAP Repository 部署本地 SAP UI5 应用到 ABAP 服务器的单步调试

01- one byte characters

使用 SAP UI5 ABAP Repository 部署本地 SAP UI5 应用到 ABAP 服务器的单步调试

SCP_GET_JAVA_NAME, 传入是 ABAP 格式的 code page 值 1160,输出一个字符串,Cp1252,这是 Java 世界里的 Code page 名称?

使用 SAP UI5 ABAP Repository 部署本地 SAP UI5 应用到 ABAP 服务器的单步调试

默认使用 Java Code Page:cp1252

使用 SAP UI5 ABAP Repository 部署本地 SAP UI5 应用到 ABAP 服务器的单步调试

根据 cp1252 和 J,进行逆运算,可以反得出 1160,这是 ABAP 和 Java Code page 的互相转换。

使用 SAP UI5 ABAP Repository 部署本地 SAP UI5 应用到 ABAP 服务器的单步调试

因此执行报表,打印出的默认 code page 为 Cp1252,就是这么来的。

使用 SAP UI5 ABAP Repository 部署本地 SAP UI5 应用到 ABAP 服务器的单步调试

在弹出框手动输入 external code page,比如 UTF-8:

使用 SAP UI5 ABAP Repository 部署本地 SAP UI5 应用到 ABAP 服务器的单步调试

​UTF-8​

​ 的 ABAP encoding 编号是 4110:

使用 SAP UI5 ABAP Repository 部署本地 SAP UI5 应用到 ABAP 服务器的单步调试

rv_upload_parameters-code_page_ui 变量维护的就是用户在弹出对话框里手动输入的 code page:

使用 SAP UI5 ABAP Repository 部署本地 SAP UI5 应用到 ABAP 服务器的单步调试

UTF-8 是 ABAP ENCODING 的编号,UTF8 是对应的 Java 编号:

使用 SAP UI5 ABAP Repository 部署本地 SAP UI5 应用到 ABAP 服务器的单步调试

只要是用 4110 就行:

使用 SAP UI5 ABAP Repository 部署本地 SAP UI5 应用到 ABAP 服务器的单步调试

这里的 CPCOMPANY 换成了 ISO,而不是之前的 MS - Microsoft

使用 SAP UI5 ABAP Repository 部署本地 SAP UI5 应用到 ABAP 服务器的单步调试

接下来就是我们熟悉的逻辑了,将 encoding 格式为 UTF-8 的 xstring 二进制内容,连同 UTF-8,一起传递到 CL_ABAP_CONV_IN_CE 的 create 方法里:

使用 SAP UI5 ABAP Repository 部署本地 SAP UI5 应用到 ABAP 服务器的单步调试

/ui5/cl_ui5_rep_utility 提供了很多有用的工具方法,比如在 xstring 和 string 之间互相转换的 convert_xstring_2_string 方法: