Unable to write value in a cube with active drill through

Post Reply
Emixam
Posts: 149
Joined: Tue May 21, 2019 3:33 pm
OLAP Product: TM1
Version: PA 2.0.x
Excel Version: 2016
Location: The Internet

Unable to write value in a cube with active drill through

Post by Emixam »

Hello

I have a tm1py script to query log delta and load the result into a target cube. I got inspired by this sample

Code: Select all

TM1_MEASURE_LOG = ['User','TimeStamp','OldValue','NewValue']
with TM1Service(**config) as tm1:
    cube_source = 'My Cube'
    cube_target = '}Log_My Cube'
    tm1.server.initialize_transaction_log_delta_requests(cube_source)
    def get_transaction_log():
        entries = tm1.server.execute_transaction_log_delta_request()
        if len(entries) > 0:
            cellset = dict()
            for entry in entries:
                if entry["StatusMessage"] is None:
                    for measure in TM1_MEASURE_LOG:
                        tuple_cellset = tuple(entry["Tuple"] + ["1"] + [measure])
                        cellset[tuple_cellset] = entry[measure]
                    cellset[tuple(entry["Tuple"] + ["Current Index"] + ["Current Index"])] = "1"
            tm1.cubes.cells.write_values(cube_target, cellset)

    i = 1
    while True:
        get_transaction_log()
        time.sleep(4)
        i = i + 1
        if( i > 5):
            break
Everything works perfectly. When the script is running and I'm updating value in 'My Cube', I can see the OldValue and NewValue in '}Log_My Cube'. However, when I right-click->Drill in 'My Cube', it opens a view in '}Log_My Cube' but my tm1py script crash with a weird error message:

Code: Select all

  File ".../tm1transactionlog copy.py", line 48, in <module>
    get_transaction_log()
  File ".../tm1transactionlog copy.py", line 43, in get_transaction_log
    [b]tm1.cubes.cells.write_values(cube_target, cellset)[/b]
  File "...\TM1py\1.8.0\lib\TM1py\Services\CellService.py", line 109, in wrapper
    return func(self, *args, **kwargs)
  File "...\TM1py\1.8.0\lib\TM1py\Services\CellService.py", line 84, in wrapper
    return func(self, *args, **kwargs)
  File "...\TM1py\1.8.0\lib\TM1py\Services\CellService.py", line 749, in write_values
    self._rest.POST(url=url, data=updates, **kwargs)
  File "...\TM1py\1.8.0\lib\TM1py\Services\RestService.py", line 80, in wrapper
    self.verify_response(response=response)
  File "...\TM1py\1.8.0\lib\TM1py\Services\RestService.py", line 457, in verify_response
    headers=response.headers)
[b]TM1py.Exceptions.Exceptions.TM1pyRestException: Text: '{"error":{"code":"278","message":"'}Views_}Log_My Cube' can not be found in collection of type 'Element'."}}' - Status Code: 404 - Reason: 'Not Found' - Headers: {'Content-Length': '124', 'Connection': 'keep-alive', 'Content-Encoding': 'gzip', 'Cache-Control': 'no-cache', 'Content-Type': 'application/json; charset=utf-8', 'OData-Version': '4.0'}, 'Content-Encoding': 'gzip', 'Cache-Control': 'no-cache', 'Content-Type': 'application/json; charset=utf-8', 'OData-Version': '4.0'}[/b]
Note that the tm1py script crash ONLY when I right-click -> Drill Through. The drill through always work fine. The same issue happen in both Workspace and Architect. Anybody knows what happening ? What exactly happen when ReturnViewHandle is executed ? Is there any kind of weird lock ?
Last edited by Emixam on Tue Oct 25, 2022 4:44 pm, edited 2 times in total.
Emixam
Posts: 149
Joined: Tue May 21, 2019 3:33 pm
OLAP Product: TM1
Version: PA 2.0.x
Excel Version: 2016
Location: The Internet

Re: Unable to write value in a cube with active drill through

Post by Emixam »

Update: The script also crash when I try to get_value in 'My Cube' and there is a view open using the drill through functionality

Code: Select all

TM1py.Exceptions.Exceptions.TM1pyRestException: Text: '{"error":{"code":"501","message":"\"Current Index\" : member not found (rte 81)"}}' - Status Code: 400 - Reason: 'Bad Request' - Headers: {'Content-Length': '87', 'Connection': 'keep-alive', 'Content-Encoding': 'gzip', 'Cache-Control': 
'no-cache', 'Content-Type': 'application/json; charset=utf-8', 'OData-Version': '4.0'}       
(myenv)
Again, everything work fine when there is no drill through involved.
Emixam
Posts: 149
Joined: Tue May 21, 2019 3:33 pm
OLAP Product: TM1
Version: PA 2.0.x
Excel Version: 2016
Location: The Internet

Re: Unable to write value in a cube with active drill through

Post by Emixam »

For those who are interested, the issue was with the subset creation. In my drill process, I changed the subsets creation from MDX to manually loop on elements and SubsetElementInsert. Everything works perfectly now !

Out of curiosity, anybody knows what could be the reason ?
User avatar
gtonkin
MVP
Posts: 1233
Joined: Thu May 06, 2010 3:03 pm
OLAP Product: TM1
Version: Latest and greatest
Excel Version: Office 365 64-bit
Location: JHB, South Africa
Contact:

Re: Unable to write value in a cube with active drill through

Post by gtonkin »

Could you share the MDX? May give us insights.
BR, George.

Learn something new: MDX Views
Post Reply