Pyrfc: RFCTable type TBL1024



将pdf二进制文件上传到SAP上,我可以使用RFC函数模块。此FM需要两个特定参数:

  • IC_ARC_OBJECT =文档类,以定义SAP中的MIME类型(OAC2
  • IN_CONTENT_LENGHT =导入数据类型,是文件的大小
  • IT_CONTENT =导入结构表TBL1024,带有文件的字节,切成1024尺寸的部分
  • ET_MESSAGES =只是一个BAPIRET2表,要检查错误(返回表)

该功能模块在Python程序中已成功执行,但是当我打破函数模块以检查IT_CONTENT的内容时,我可以看到表的行未正确填充:

提取FM的Python程序呼叫:

arc_object = "ZZ_PDF" 
content = Arc.get_arc_content(filename)
size = Arc.get_size(filename)
messages = []
result = connection.call("ZZ_UPLOAD_FILE", 
IC_ARC_OBJECT = arc_object,
IN_CONTENT_LENGTH = str(size),
IT_CONTENT = content,
ET_MESSAGES = messages)
messages = result['ET_MESSAGES']
for mes in messages:
     print mes['MESSAGE']

提取Python功能Arc.get_arc_content(filename)

def get_arc_content(filename="file.pdf"):
    maxLineLength = 1024
    structure = []
    if filename == '':
        filename = 'file.pdf'
    with open(filename, 'rb') as file1:
        f = file1.read()
        n = 1024
        fl = [f[i:i + n] for i in range(0, len(f), n)]
    content = []
    for line in fl:
        lineapp = {
            u"LINE": line
        }
        print len(line)
        content.append(lineapp)
    return content

SAP中的结果是参数的以下内容:

  • IN_CONTENT_LENGHT = 000000007945(7.8 kb)
  • IT_CONTENT = 8 x 1行:(4lines)
    LINE1
    255044462D312E3300000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
    LINE2
    B89B067867673EAB00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
    LINE3
    5BF4CB23B9A7513700000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
    LINE4
    61DB44B3B0AAB12500000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
    ...
    LINE8
    202020202020202000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
    

使用FM ARCHIVE_OBJECT_GET检查的IT_CONTENT的期望结果应该是:

LINE1
255044462D312E330D0A25E2E3CFD30D0A25525354585044463320506172616D65746572733A204452535458680D0A322030206F626A0D0A3C3C0D0A2F46696C7465722033203020520D0A2F4C656E67
LINE2
FA1D555450C8EF41AC263F14BC03C49BDD773CF22BC43FD21B3565DA2DFCCB83D8FFAC7BCBBBEBE6DED0AD68DEA29B349398511824DDDCFFAF41EA7FDADDF67EE61EF3FC303293F7E96351A911F8DE10
LINE3
FB4A559526CD6AED428976E80F8DD0B02517C4178D1EFB73C65792D09CFE5C717883BE38E61ED0AB3ADC0983C103E4338A1B210DA086DA73375E679C0A410F510FDC542BB686A1A4D601DD411A506504
...

所以问题是只传输了第一个字节,其余的是落后的。

这与我做错了以下事实有关,或者不可能将二进制文件正确切入1024的块并将其转移到SAP的表格中。如何在Python中使用字节类型?

非常感谢您的建议/支持。

pyrfc-1.9.4-py2.7-win-amd64.egg解决了问题。

似乎是Windows Pyrfc 1.9.3版本问题,1.9.4发行版正常,

非常感谢 srdjan boskovic 支持

相关内容

  • 没有找到相关文章

最新更新