I am trying to get data by using python connect SAP system. Here I have question about how to filter one specific field IS NOT EMPTY?
For example below, how to filter the field QNAME is not empty. In SAP, we can easily set. Thanks a lot!
table = 'LTAP'
options = [{ 'TEXT': "LGNUM = '586'" and "VLTYP = 'GPA'" and "NLTYP = 'PD2'"}]
fields = ['TANUM','VLTYP','VLPLA','NLTYP','NLPLA','QDATU','QNAME']
pp = PrettyPrinter(indent=4)
rowskips = 0
print("----Begin of Batch---")
result = conn.call("RFC_READ_TABLE",
QUERY_TABLE = table,
DELIMITER='|',
FIELDS = fields,\
OPTIONS = options,
ROWSKIPS = rowskips,
ROWCOUNT = 50 )
pp.pprint(result['DATA'])
In ABAP SQL (A.K.A. Open SQL), "not equal" corresponds to the operator
<>. With pyrfc, it will be:Note that there are two lines because
TEXTis only 72 characters inRFC_READ_TABLE. If you have more than 72 characters, split the condition into several lines, like explained here, i.e.RFC_READ_TABLEwill pad each line with spaces to obtain exactly 72 characters, and will collate all the lines without any transformation to form the WHERE clause.