0

Describe the bug

I am using PyRFC to pull data from SAP BW InfoCubes using BAPI_MDDATASET_CREATE_OBJECT, BAPI_MDDATASET_SELECT_DATA, and BAPI_MDDATASET_GET_FLAT_DATA. I pass in my MDX query, and the results are close to what I see in MDXTEST, but a few columns are always missing. I have also tried with RSR_MDX_CREATE_OBJECT and RSR_MDX_GET_FS_DATA with the same results.

To Reproduce

query = wrap(query, 75)

result = self.connection.call('RSR_MDX_CREATE_OBJECT', COMMAND_TEXT=query)
datasetid = result['DATASETID']
if numrows:
    result = self.connection.call('RSR_MDX_GET_FS_DATA', DATASETID=datasetid, END_ROW=numrows - 1)
else:
    result = self.connection.call('RSR_MDX_GET_FS_DATA', DATASETID=datasetid)

rows = {}
if 'DATA' in result:
    result = result['DATA']
    for cell in result:
        if cell['ROW'] not in rows:
            rows[cell['ROW']] = {}
        if '].[' not in cell['DATA']:
            rows[cell['ROW']][cell['COLUMN']] = cell['DATA']

rows = [rows[row] for row in rows]

df = pd.DataFrame(rows)
print(df)

Here is an example:

SELECT 
   { } ON COLUMNS, 
   NON EMPTY 
   { { [0CUSTOMER].[LEVEL01].MEMBERS } } 
   DIMENSION PROPERTIES 
    [0CUSTOMER].[20CUSTOMER],
    [0CUSTOMER].[2ZPRNTSITE],
    [0CUSTOMER].[2ZDELFLAG],
    [0CUSTOMER].[2ZDELDATE] ON ROWS 
FROM [PDCAM07/ZPDCAM07_Q0001] 
 SAP VARIABLES [!V000003] INCLUDING [ZCUSGRTYP].[GRP]

I expect five columns but only get four.

enter image description here

enter image description here

whytheq
  • 34,466
  • 65
  • 172
  • 267
C. Holt
  • 101
  • 1
  • I realized that the missing fields were dimension properties that could be added to the MDX. Theobald's Xtract Universal includes a Member Caption for all dimensions as a field, while calling the MDX from BAPI only includes a Member Caption if no dimension property was specifically called from that dimension even though it's included before the DIMENSION PROPERTIES clause. – C. Holt Oct 20 '22 at 17:14

0 Answers0