Skip to content

Commit

Permalink
Release 1.9.93
Browse files Browse the repository at this point in the history
  • Loading branch information
bsrdjan committed Aug 20, 2018
1 parent 5727c23 commit d61e601
Show file tree
Hide file tree
Showing 19 changed files with 104 additions and 79 deletions.
4 changes: 4 additions & 0 deletions CHANGES
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
Change log
==========

1.9.93 (2018-08-20)
-------------------
- Tables' processing memory consumption optimisation (#60)

1.9.92 (2018-07-31)
-------------------
- pyrfc.__version__ attribute added
Expand Down
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
1.9.92
1.9.93
Binary file added dist/pyrfc-1.9.93-cp27-cp27m-win_amd64.whl
Binary file not shown.
Binary file added dist/pyrfc-1.9.93-cp27-cp27mu-linux_x86_64.whl
Binary file not shown.
Binary file added dist/pyrfc-1.9.93-cp35-cp35m-linux_x86_64.whl
Binary file not shown.
Binary file added dist/pyrfc-1.9.93-cp35-cp35m-win_amd64.whl
Binary file not shown.
Binary file added dist/pyrfc-1.9.93-cp36-cp36m-linux_x86_64.whl
Binary file not shown.
Binary file added dist/pyrfc-1.9.93-cp36-cp36m-win_amd64.whl
Binary file not shown.
Binary file added dist/pyrfc-1.9.93-cp37-cp37m-linux_x86_64.whl
Binary file not shown.
Binary file added dist/pyrfc-1.9.93-cp37-cp37m-win_amd64.whl
Binary file not shown.
2 changes: 1 addition & 1 deletion src/pyrfc/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@

from pyrfc._pyrfc import get_nwrfclib_version, Connection, TypeDescription, FunctionDescription, Server

__version__ = "1.9.92"
__version__ = "1.9.93"

# TODO: define __all__ variable
#
26 changes: 17 additions & 9 deletions src/pyrfc/_pyrfc.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -1637,15 +1637,21 @@ cdef fillStructureField(RFC_TYPE_DESC_HANDLE typeDesc, RFC_STRUCTURE_HANDLE cont
cdef fillTable(RFC_TYPE_DESC_HANDLE typeDesc, RFC_TABLE_HANDLE container, lines):
cdef RFC_ERROR_INFO errorInfo
cdef RFC_STRUCTURE_HANDLE lineHandle
for line in lines:
lineHandle = RfcAppendNewRow(container, &errorInfo)
cdef unsigned int rowCount = len(lines)
cdef unsigned int i = 0
while i < rowCount:
lineHandle = RfcAppendNewRow(container, &errorInfo)
if not lineHandle:
raise wrapError(&errorInfo)
line = lines[i]
# line = lines[0]
if type(line) is dict:
for name, value in line.iteritems():
fillStructureField(typeDesc, lineHandle, name, value)
else:
fillStructureField(typeDesc, lineHandle, '', line)
# https://stackoverflow.com/questions/33626623/the-most-efficient-way-to-remove-first-n-elements-in-a-list
i += 1 # del lines[:1]

cdef fillVariable(RFCTYPE typ, RFC_FUNCTION_HANDLE container, SAP_UC* cName, value, RFC_TYPE_DESC_HANDLE typeDesc):
cdef RFC_RC rc
Expand Down Expand Up @@ -1978,18 +1984,20 @@ cdef wrapStructure(RFC_TYPE_DESC_HANDLE typeDesc, RFC_STRUCTURE_HANDLE container
cdef wrapTable(RFC_TYPE_DESC_HANDLE typeDesc, RFC_TABLE_HANDLE container, config):
cdef RFC_RC rc
cdef RFC_ERROR_INFO errorInfo
cdef unsigned lines
cdef unsigned rowCount
# # For debugging in tables (cf. class TableCursor)
# tc = TableCursor()
# tc.typeDesc = typeDesc
# tc.container = container
# return tc
RfcGetRowCount(container, &lines, &errorInfo)
result = []
for i in range(lines): #TODO: lazy?
RfcMoveTo(container, i, &errorInfo)
result.append(wrapStructure(typeDesc, container, config))
return result
RfcGetRowCount(container, &rowCount, &errorInfo)
table = [None] * rowCount
while rowCount > 0:
rowCount -= 1
RfcMoveTo(container, rowCount, &errorInfo)
table[rowCount] = wrapStructure(typeDesc, container, config)
RfcDeleteCurrentRow(container, &errorInfo)
return table

cdef wrapVariable(RFCTYPE typ, RFC_FUNCTION_HANDLE container, SAP_UC* cName, unsigned cLen, RFC_TYPE_DESC_HANDLE typeDesc, config):
cdef RFC_RC rc
Expand Down
1 change: 1 addition & 0 deletions src/pyrfc/csapnwrfc.pxd
Original file line number Diff line number Diff line change
Expand Up @@ -280,6 +280,7 @@ cdef extern from "sapnwrfc.h":

RFC_RC RfcGetRowCount(RFC_TABLE_HANDLE tableHandle, unsigned* rowCount, RFC_ERROR_INFO* errorInfo)
RFC_RC RfcMoveTo(RFC_TABLE_HANDLE tableHandle, unsigned index, RFC_ERROR_INFO* errorInfo)
RFC_RC RfcDeleteCurrentRow(RFC_TABLE_HANDLE tableHandle, RFC_ERROR_INFO* errorInfo)
RFC_RC RfcGetTable(DATA_CONTAINER_HANDLE dataHandle, SAP_UC* name, RFC_TABLE_HANDLE* tableHandle, RFC_ERROR_INFO* errorInfo)
RFC_STRUCTURE_HANDLE RfcAppendNewRow(RFC_TABLE_HANDLE tableHandle, RFC_ERROR_INFO* errorInfo)
RFC_RC RfcUTF8ToSAPUC(unsigned char *utf8, unsigned utf8Length, SAP_UC *sapuc, unsigned *sapucSize, unsigned *resultLength, RFC_ERROR_INFO *errorInfo)
Expand Down
2 changes: 1 addition & 1 deletion tests/pyrfc.cfg
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
[test]
[p7019s16]
user = demo
passwd = Welcome
ashost = 10.117.19.101
Expand Down
14 changes: 2 additions & 12 deletions tests/test_connection.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,18 +14,6 @@
class TestConnection():

def setup_method(self, test_method):
""" A connection to an SAP backend system
Instantiating an :class:`pyrfc.Connection` object will
automatically attempt to open a connection the SAP backend.
:param config: Configuration of the instance. Allowed keys are:
``dtime``
returns datetime types (accepts strings and datetimes), default is False
``rstrip``
right strips strings returned from RFC call (default is True)
``return_import_params``
importing parameters are returned by the RFC call (default is False)
:type config: dict or None (default)
"""
self.conn = pyrfc.Connection(**params)
assert self.conn.alive

Expand Down Expand Up @@ -255,3 +243,5 @@ def test_many_connections(self):
# self.assertEqual(s, out['EV_EXPORT_XSTRING'])
'''
if __name__ == '__main__':
unittest.main()
42 changes: 24 additions & 18 deletions tests/test_function_group_mrfc.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@

from tests.config import PARAMS as params, CONFIG_SECTIONS as config_sections, get_error


class TestMRFC():
"""
This test cases cover selected functions from the MRFC function group.
Expand Down Expand Up @@ -72,7 +73,8 @@ def test_RFC_RAISE_ERROR_AbapApplicationError(self):
assert error['msg_class'] == u'SR'
assert error['msg_type'] == 'E'
assert error['msg_number'] == '006'
self.conn.call('RFC_PING') # Assures that the connection handle is correctly synchronized
# Assures that the connection handle is correctly synchronized
self.conn.call('RFC_PING')

# '2_E': 'ABAPApplicationError-5-RAISE_EXCEPTION- Number:000-True',
# cf. ExceptionTest.c (l. 65ff)
Expand All @@ -85,7 +87,6 @@ def test_RFC_RAISE_ERROR_AbapApplicationError(self):
assert error['msg_number'] == '006'
self.conn.call('RFC_PING')


def test_RFC_RAISE_ERROR_AbapRuntimeError(self):
# RFC_RAISE_ERROR ARFC: Raise Different Type of Error Message
# Comment: cf. result_print of the error_test.py
Expand Down Expand Up @@ -165,20 +166,20 @@ def test_RFC_RAISE_ERROR_ExternalRuntimeError(self):
#assert error['key'] == 'RFC_NOT_FOUND'
#self.conn.call('RFC_PING')
'''
#def test_RFC_RAISE_ERROR_CommunicationError(self):
# Comment: cf. result_print of the error_test.py
# '32_E': 'CommunicationError-1-RFC_COMMUNICATION_FAILURE-connection closed without message (CM_NO_DATA_RECEIVED)-True',
##try:
## self.conn.call('RFC_RAISE_ERROR', METHOD='32', MESSAGETYPE='E')
#except (pyrfc.ABAPRuntimeError) as ex:
# error = get_error(ex)
# assert error['code'] == 4
# assert error['key'] == 'ON:N'
##except (pyrfc.CommunicationError) as ex:
## error = get_error(ex)
## assert error['code'] == 1
## assert error['key'] == 'RFC_COMMUNICATION_FAILURE'
## self.conn.call('RFC_PING')
# def test_RFC_RAISE_ERROR_CommunicationError(self):
# Comment: cf. result_print of the error_test.py
# '32_E': 'CommunicationError-1-RFC_COMMUNICATION_FAILURE-connection closed without message (CM_NO_DATA_RECEIVED)-True',
# try:
## self.conn.call('RFC_RAISE_ERROR', METHOD='32', MESSAGETYPE='E')
# except (pyrfc.ABAPRuntimeError) as ex:
# error = get_error(ex)
# assert error['code'] == 4
# assert error['key'] == 'ON:N'
# except (pyrfc.CommunicationError) as ex:
## error = get_error(ex)
## assert error['code'] == 1
## assert error['key'] == 'RFC_COMMUNICATION_FAILURE'
# self.conn.call('RFC_PING')
'''
@unittest.skip("not remote-enabled")
def test_RFC_RAISE_ERROR_VB(self):
Expand All @@ -200,11 +201,16 @@ def test_RFC_XML_TEST_1(self):
pass
'''

def test_STFC_CHANGING(self):
# STFC_CHANGING example with CHANGING parameters
start_value = 33
counter = 88
result = self.conn.call('STFC_CHANGING', START_VALUE=start_value, COUNTER=counter)
assert result['COUNTER'] ==counter + 1
result = self.conn.call(
'STFC_CHANGING', START_VALUE=start_value, COUNTER=counter)
assert result['COUNTER'] == counter + 1
assert result['RESULT'] == start_value + counter


if __name__ == '__main__':
unittest.main()
71 changes: 41 additions & 30 deletions tests/test_function_group_stfc.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,12 @@

from tests.config import PARAMS as params, CONFIG_SECTIONS as config_sections, get_error


class TestSTFC():
"""
This test cases cover selected functions from the STFC function group.
"""

def setup_method(self, test_method):
self.conn = pyrfc.Connection(**params)
assert self.conn.alive
Expand Down Expand Up @@ -49,15 +51,15 @@ def test_STFC_CALL_TRFC(self):
pass
# no remote-enabled module
#def test_STFC_CALL_TRFC_PLUS_UPDATE(self):
# def test_STFC_CALL_TRFC_PLUS_UPDATE(self):
# STFC_CALL_TRFC_PLUS_UPDATE TRFC in VB innerhalb der VB nochmal tRFC
# pass
'''

def test_STFC_CONNECTION(self):
# STFC_CONNECTION RFC-TEST: CONNECTION Test
# Test with rstrip:
hello = u'Hällo SAP!'# In case that rstip=False + u' ' * 245
hello = u'Hällo SAP!' # In case that rstip=False + u' ' * 245
result = self.conn.call('STFC_CONNECTION', REQUTEXT=hello)
assert result['RESPTEXT'].startswith('SAP')
assert result['ECHOTEXT'] == hello
Expand All @@ -82,10 +84,10 @@ def test_STFC_PERFORMANCE(self):
def test_STFC_PING_VB(self):
pass
# STFC_PING_VB RFC-Ping der in VB gerufen werden kann
#with self.assertRaises(pyrfc.ABAPRuntimeError) as run:
# with self.assertRaises(pyrfc.ABAPRuntimeError) as run:
# self.conn.call('STFC_PING_VB')
#self.assertEqual(run.exception.code, 3)
#self.assertEqual(run.exception.key, 'CALL_FUNCTION_NOT_REMOTE')
# self.assertEqual(run.exception.code, 3)
# self.assertEqual(run.exception.key, 'CALL_FUNCTION_NOT_REMOTE')
@unittest.skip("not supported yet (qrfc)")
def test_STFC_QRFC_TCPIC(self):
Expand Down Expand Up @@ -119,36 +121,45 @@ def test_STFC_START_CONNECT_REG_SERVER(self):
pass
'''


def test_STFC_STRUCTURE(self):
# STFC_STRUCTURE Inhomogene Struktur
imp = dict(RFCFLOAT=1.23456789,
RFCINT2=0x7ffe, RFCINT1=0x7f,
RFCCHAR4=u'bcde', RFCINT4=0x7ffffffe,
RFCHEX3=str.encode('fgh'),
RFCCHAR1=u'a', RFCCHAR2=u'ij',
RFCTIME='123456', #datetime.time(12,34,56),
RFCDATE='20161231', #datetime.date(2011,10,17),
RFCDATA1=u'k'*50, RFCDATA2=u'l'*50
)
RFCINT2=0x7ffe, RFCINT1=0x7f,
RFCCHAR4=u'bcde', RFCINT4=0x7ffffffe,
RFCHEX3=str.encode('fgh'),
RFCCHAR1=u'a', RFCCHAR2=u'ij',
RFCTIME='123456', # datetime.time(12,34,56),
RFCDATE='20161231', # datetime.date(2011,10,17),
RFCDATA1=u'k'*50, RFCDATA2=u'l'*50
)
out = dict(RFCFLOAT=imp['RFCFLOAT']+1,
RFCINT2=imp['RFCINT2']+1, RFCINT1=imp['RFCINT1']+1,
RFCINT4=imp['RFCINT4']+1,
RFCHEX3=b'\xf1\xf2\xf3',
RFCCHAR1=u'X', RFCCHAR2=u'YZ',
RFCDATE=str(datetime.date.today()).replace('-',''),
RFCDATA1=u'k'*50, RFCDATA2=u'l'*50
)
result = self.conn.call('STFC_STRUCTURE', IMPORTSTRUCT=imp, RFCTABLE=[imp])
RFCINT2=imp['RFCINT2']+1, RFCINT1=imp['RFCINT1']+1,
RFCINT4=imp['RFCINT4']+1,
RFCHEX3=b'\xf1\xf2\xf3',
RFCCHAR1=u'X', RFCCHAR2=u'YZ',
RFCDATE=str(datetime.date.today()).replace('-', ''),
RFCDATA1=u'k'*50, RFCDATA2=u'l'*50
)
table = []
xtable = []
records = ['1111', '2222', '3333', '4444', '5555']
for rid in records:
imp['RFCCHAR4'] = rid
table.append(imp)
xtable.append(imp)
# print 'table len', len(table), len(xtable)
result = self.conn.call(
'STFC_STRUCTURE', IMPORTSTRUCT=imp, RFCTABLE=xtable)
# print 'table len', len(table), len(xtable)
assert result['RESPTEXT'].startswith('SAP')
#assert result['ECHOSTRUCT'] == imp
assert len(result['RFCTABLE']) == 2
# assert result['ECHOSTRUCT'] == imp
assert len(result['RFCTABLE']) == 1+len(table)
for i in result['ECHOSTRUCT']:
assert result['ECHOSTRUCT'][i] == imp[i]
del result['RFCTABLE'][1]['RFCCHAR4'] # contains variable system id
del result['RFCTABLE'][1]['RFCTIME'] # contains variable server time
for i in result['RFCTABLE'][1]:
assert result['RFCTABLE'][1][i] == out[i]
del result['RFCTABLE'][5]['RFCCHAR4'] # contains variable system id
del result['RFCTABLE'][5]['RFCTIME'] # contains variable server time
for i in result['RFCTABLE'][5]:
assert result['RFCTABLE'][5][i] == out[i]

'''
def test_ZPYRFC_STFC_STRUCTURE(self):
Expand All @@ -175,7 +186,7 @@ def test_ZPYRFC_STFC_STRUCTURE(self):
RFCDEC17_8=Decimal('0')
)
result = self.conn.call('ZPYRFC_STFC_STRUCTURE', IMPORTSTRUCT=imp, RFCTABLE=[imp])
#print result
# print result
self.assertTrue(result['RESPTEXT'].startswith('SAP'))
assert result['ECHOSTRUCT'] == imp
assert len(result['RFCTABLE']) == 2
Expand Down Expand Up @@ -204,8 +215,8 @@ def test_STRFC_CHECK_USER_LANGUAGE(self):
def test_TRFC_RAISE_ERROR(self):
# TRFC_RAISE_ERROR ARFC: Raise different type of error messages
pass
'''


if __name__ == '__main__':
unittest.main()
'''
9 changes: 8 additions & 1 deletion tests/test_issues.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,11 @@

from tests.config import PARAMS as params, CONFIG_SECTIONS as config_sections, get_error


def utf8len(s):
return len(s.encode('utf-8'))


class TestIssues():

def setup_method(self, test_method):
Expand Down Expand Up @@ -81,7 +83,8 @@ def test_issue38(self):

for s in test:
is_input = {'ZSHLP_MAT1': s, 'ZFLTP': 123.45}
result = self.conn.call('/COE/RBP_FE_DATATYPES', IS_INPUT = is_input)['ES_OUTPUT']
result = self.conn.call(
'/COE/RBP_FE_DATATYPES', IS_INPUT=is_input)['ES_OUTPUT']
assert is_input['ZSHLP_MAT1'] == result['ZSHLP_MAT1']

def test_issue40(self):
Expand All @@ -104,3 +107,7 @@ def test_issue40(self):
assert error['code'] == 17
assert error['key'] == 'RFC_NOT_FOUND'
'''


if __name__ == '__main__':
unittest.main()
10 changes: 4 additions & 6 deletions tests/test_table_type.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,25 +7,23 @@

from tests.config import PARAMS as params, CONFIG_SECTIONS as config_sections, get_error


class TestTT():
"""
This test cases cover table types of variable and structure types
"""

def setup_method(self, test_method):
self.conn = pyrfc.Connection(**params)
assert self.conn.alive

def test_info(self):
connection_info = self.conn.get_connection_attributes()
assert connection_info['isoLanguage'] == u'EN'

def teardown_method(self, test_method):
self.conn.close()
assert not self.conn.alive


def test_TABLE_TYPE(self):
result = self.conn.call('/COE/RBP_PAM_SERVICE_ORD_CHANG', IV_ORDERID='4711', IT_NOTICE_NOTIFICATION=[{'': 'ABCD'}, {'': 'XYZ'}])
result = self.conn.call('/COE/RBP_PAM_SERVICE_ORD_CHANG', IV_ORDERID='4711',
IT_NOTICE_NOTIFICATION=[{'': 'ABCD'}, {'': 'XYZ'}])
assert len(result['ET_RETURN']) > 0
erl = result['ET_RETURN'][0]
assert erl['TYPE'] == 'E'
Expand Down

0 comments on commit d61e601

Please sign in to comment.