|
1 | 1 | # -*- coding: utf-8 -*- |
2 | 2 | from pyrfc import * |
3 | 3 | from decimal import Decimal |
4 | | - |
5 | | -connection_info = { |
6 | | - 'user': 'demo', |
7 | | - 'passwd': 'welcome', |
8 | | - 'ashost': '10.68.110.51', |
9 | | - 'sysnr': '00', |
10 | | - 'lang': 'EN', |
11 | | - 'client': '620', |
12 | | - 'sysid': 'MME' |
13 | | -} |
14 | | - |
15 | | -conn = Connection(**connection_info) |
16 | | - |
17 | | -is_input = dict( |
18 | | - |
19 | | - # Character |
20 | | - ZCHAR=u'Hällö SÄP!', |
21 | | - ZCLNT='510', |
22 | | - ZUNIT_DTEL='KGM', |
23 | | - ZCUKY_DTEL='USD', |
24 | | - ZLANG='e', |
25 | | - |
26 | | - # Date, time |
27 | | - ZDATS='20161231', # datetime.date(2011,10,17), |
28 | | - ZTIMS='123456', # datetime.time(12,34,56), |
29 | | - |
30 | | - # Integer |
31 | | - ZINT1=2 ** 8 - 1, # 255 |
32 | | - ZINT2=2 ** 15 - 1, # 32767 |
33 | | - ZINT4=2 ** 31 - 1, # 2147483647 |
34 | | - |
35 | | - # Numeric |
36 | | - ZACCP='201805', |
37 | | - ZNUMC='123456', |
38 | | - |
39 | | - ZPREC=2, |
40 | | - |
41 | | - # String |
42 | | - ZRAW=bytes('abc\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00'), |
43 | | - ZRAWSTRING=bytes('四周远处都能望见'), |
44 | | - ZSTRING=u'\u0001\uf4aa', |
45 | | - ZSSTRING=u'四周远处都能望见' |
| 4 | +import datetime |
| 5 | +from config import CONNECTION_INFO, RFC_MATH |
| 6 | + |
| 7 | + |
| 8 | +conn_strip = Connection({"rstrip": True}, **CONNECTION_INFO) |
| 9 | +hello = u"Hällo SAP! " |
| 10 | +result = conn_strip.call("STFC_CONNECTION", REQUTEXT=hello) |
| 11 | +# assert len(result["RESPTEXT"]) == len(result["ECHOTEXT"]) |
| 12 | +# self.conn_strip.close() |
| 13 | + |
| 14 | +""" |
| 15 | +
|
| 16 | +client = Connection(**CONNECTION_INFO) |
| 17 | +
|
| 18 | +
|
| 19 | +uc = u"四周远处都" |
| 20 | +uc = u"ÄÜ" |
| 21 | +uc = u"fgh" |
| 22 | +buc = uc.encode("utf-8") |
| 23 | +print(len(uc), uc) |
| 24 | +print(len(buc), buc) |
| 25 | +
|
| 26 | +ZRAW = buc |
| 27 | +IS_INPUT = {"ZRAW": ZRAW, "ZRAWSTRING": ZRAW} |
| 28 | +output = client.call("/COE/RBP_FE_DATATYPES", IS_INPUT=IS_INPUT, IV_COUNT=0)[ |
| 29 | + "ES_OUTPUT" |
| 30 | +] |
| 31 | +print(len(ZRAW), ZRAW) |
| 32 | +print(len(output["ZRAW"]), output["ZRAW"]) |
| 33 | +
|
| 34 | +
|
| 35 | +imp = dict( |
| 36 | + RFCFLOAT=1.23456789, |
| 37 | + RFCINT2=0x7FFE, |
| 38 | + RFCINT1=0x7F, |
| 39 | + RFCCHAR4=u"bcde", |
| 40 | + RFCINT4=0x7FFFFFFE, |
| 41 | + RFCHEX3=buc, |
| 42 | + RFCCHAR1=u"a", |
| 43 | + RFCCHAR2=u"ij", |
| 44 | + RFCTIME="123456", # datetime.time(12,34,56), |
| 45 | + RFCDATE="20161231", # datetime.date(2011,10,17), |
| 46 | + RFCDATA1=u"k" * 50, |
| 47 | + RFCDATA2=u"l" * 50, |
46 | 48 | ) |
| 49 | +result = client.call("STFC_STRUCTURE", IMPORTSTRUCT=imp)["ECHOSTRUCT"] |
47 | 50 |
|
48 | | -result = conn.call('/COE/RBP_FE_DATATYPES', IS_INPUT=is_input)['ES_OUTPUT'] |
49 | | -for k in is_input: |
50 | | - if is_input[k] != result[k]: |
51 | | - print k, type(result[k]) |
52 | | - if str(is_input[k]) != str(result[k]): |
53 | | - print '!', k, is_input[k], result[k] |
54 | | - |
55 | | - |
56 | | -is_input = dict( |
57 | | - # Float |
58 | | - ZFLTP='0.123456789', |
59 | | - |
60 | | - # Decimal |
61 | | - ZDEC='12345.67', |
62 | | - |
63 | | - # Currency, Quantity |
64 | | - ZCURR='1234.56', |
65 | | - ZQUAN='12.3456', |
66 | | - ZQUAN_SIGN='-12.345', |
67 | | -) |
68 | | - |
69 | | -result = conn.call('/COE/RBP_FE_DATATYPES', IS_INPUT=is_input)['ES_OUTPUT'] |
70 | | -for key, in_val in is_input.iteritems(): |
71 | | - out_val = result[key] |
72 | | - if type(in_val) != type(out_val): |
73 | | - if str(in_val) != str(out_val): |
74 | | - print 'str:', k, in_val, out_val |
75 | | - else: |
76 | | - if in_val != result[key]: |
77 | | - print key, in_val, out_val |
78 | | - |
79 | | -is_input = dict( |
80 | | - # Float |
81 | | - ZFLTP=0.123456789, |
82 | | - |
83 | | - # Decimal |
84 | | - ZDEC=12345.67, |
85 | | - |
86 | | - # Currency, Quantity |
87 | | - ZCURR=1234.56, |
88 | | - ZQUAN=12.3456, |
89 | | - ZQUAN_SIGN=-12.345, |
90 | | -) |
91 | | - |
92 | | - |
93 | | -result = conn.call('/COE/RBP_FE_DATATYPES['ES_OUTPUT'] |
94 | | -for key, in_value in is_input.iteritems(): |
95 | | - out_value = result[key] |
96 | | - if type(in_value) != type(out_value): |
97 | | - if str(in_value) != str(out_value): |
98 | | - print 'str:', k, in_value, out_value |
99 | | - else: |
100 | | - if in_value != result[key]: |
101 | | - print key, in_value, out_value |
102 | | - |
103 | | -is_input = dict( |
104 | | - # Float |
105 | | - ZFLTP=Decimal('0.123456789'), |
106 | | - |
107 | | - # Decimal |
108 | | - ZDEC=Decimal('12345.67'), |
109 | | - |
110 | | - # Currency, Quantity |
111 | | - ZCURR=Decimal('1234.56'), |
112 | | - ZQUAN=Decimal('12.3456'), |
113 | | - ZQUAN_SIGN=Decimal('-12.345'), |
114 | | -) |
115 | | - |
116 | | - |
117 | | -result = conn.call('/COE/RBP_FE_DATATYPES', IS_INPUT=is_input)['ES_OUTPUT'] |
118 | | -for key, in_value in is_input.iteritems(): |
119 | | - out_value = result[key] |
120 | | - if type(in_value) != type(out_value): |
121 | | - if str(in_value) != str(out_value): |
122 | | - print 'str:', k, in_value, out_value |
123 | | - else: |
124 | | - if in_value != result[key]: |
125 | | - print key, in_value, out_value |
126 | | - |
127 | | -INPUTS = { |
128 | | - 'dec': dict( |
129 | | - # Float |
130 | | - ZFLTP=Decimal('0.123456789'), |
131 | | - |
132 | | - # Decimal |
133 | | - ZDEC=Decimal('12345.67'), |
134 | | - |
135 | | - # Currency, Quantity |
136 | | - ZCURR=Decimal('1234.56'), |
137 | | - ZQUAN=Decimal('12.3456'), |
138 | | - ZQUAN_SIGN=Decimal('-12.345'), |
139 | | - ), |
140 | | - |
141 | | - 'numbers': dict( |
142 | | - # Float |
143 | | - ZFLTP=0.123456789, |
144 | | - |
145 | | - # Decimal |
146 | | - ZDEC=12345.67, |
147 | | - |
148 | | - # Currency, Quantity |
149 | | - ZCURR=1234.56, |
150 | | - ZQUAN=12.3456, |
151 | | - ZQUAN_SIGN=-12.345 |
152 | | - ), |
153 | | - |
154 | | - 'strings': dict( |
155 | | - # Float |
156 | | - ZFLTP='0.123456789', |
157 | | - |
158 | | - # Decimal |
159 | | - ZDEC='12345.67', |
160 | | - |
161 | | - # Currency, Quantity |
162 | | - ZCURR='1234.56', |
163 | | - ZQUAN='12.3456', |
164 | | - ZQUAN_SIGN='-12.345', |
165 | | - ) |
166 | | -} |
167 | | - |
168 | | -for in_type in INPUTS: |
169 | | - result = conn.call('/COE/RBP_FE_DATATYPES', |
170 | | - IS_INPUT=INPUTS[in_type])['ES_OUTPUT'] |
171 | | - print |
172 | | - print in_type |
173 | | - for k in is_input: |
174 | | - in_val = is_input[k] |
175 | | - out_val = result[k] |
176 | | - print k, type(in_val), type(out_val), in_val, out_val |
177 | | - if type(in_val) != type(out_val): |
178 | | - assert(str(in_val) == str(out_val)) |
179 | | - else: |
180 | | - assert(in_val == out_val) |
| 51 | +print(len(result["RFCHEX3"]), result["RFCHEX3"]) |
| 52 | +""" |
0 commit comments