Prerequisites:
Process Parameters:
Parameter | Type | Prompt | Value |
---|---|---|---|
|
|
|
|
|
|
|
|
|
|
| |
|
|
|
|
Prolog (before Initialize Logging region)
pLogOutput = TRIM( pLogOutput ); nLogOutput = StringToNumber( If( pLogOutput @= '', '0', pLogOutput ));
Prolog (declarations):
cCubParam = '}APQ Settings'; cDimPar = 'FIN Company'; cCubThreadCtrl = '}APQ C3 Thread Control'; cDimensionDelim = CellGetS( cCubParam, 'pDimDelim', 'String' ); cElementStartDelim = CellGetS( cCubParam, 'pEleStartDelim', 'String' ); cElementDelim = CellGetS( cCubParam, 'pEleDelim', 'String' );
Prolog (after declarations):
nMaxThreads = StringToNumber( If( pMaxThreads @= '', '0', pMaxThreads )); nThreadID = StringToNumber( If( pThreadID @= '', '0', pThreadID ));
Prolog (parameter testing region):
If( pDimPar @= '' ); pDimPar = cDimPar; sMessage = Expand( 'Parallelization will run on default dimension [%pDimPar%].' ); sSequenceID = NumberToString( nMultiMsgJSON ); sMessageJSON = INSRT(' "message":"', sMessage | '"', 1); sMultiMsg = Expand( '%sMultiMsg%' | If(LONG(sMultiMsg)=0, '', ', ') | '"' | NumberToString( nMultiMsgJSON ) | '":{%sMessageJSON%}' ); nMultiMsgJSON = nMultiMsgJSON + 1; LogOutput( 'WARN', Expand( sMessage ) ); EndIf;
Prolog (after parameter testing region):
If( nThreadId = 0 ); CubeSetLogChanges( cCubTgt, 0 ); EndIf;
Prolog:
If ( nMaxThreads > 1 & nThreadID >= 0 ); # Parallel processing nThreads = nMaxThreads; If ( nThreadID = 0 ); # This is master - spawn worker threads. Master will be also processing data. sThreads = NumberToString( nThreads ); sMessage = Expand( 'Data processing will run on %sThreads% thread' | If( nThreads > 1, 's', '') | '.' ); sSequenceID = NumberToString( nMultiMsgJSON ); sMessageJSON = INSRT(' "message":"', sMessage | '"', 1); sMultiMsg = Expand( '%sMultiMsg%' | If(LONG(sMultiMsg)=0, '', ', ') | '"' | NumberToString( nMultiMsgJSON ) | '":{%sMessageJSON%}' ); nMultiMsgJSON = nMultiMsgJSON + 1; LogOutput( 'Info', sMessage ); sFilter = '}Clients' | cElementStartDelim | cUserName; sFilter = sFilter | cDimensionDelim | '}Processes' | cElementStartDelim | cThisProcName; sProc = '}bedrock.cube.view.create'; nRet = ExecuteProcess( sProc, 'pLogOutput', nLogOutput, 'pCube', cCubThreadCtrl, 'pView', cViewClr, 'pFilter', sFilter, 'pSuppressConsol', 1, 'pSuppressRules', 0, 'pDimDelim', cDimensionDelim, 'pEleStartDelim', cElementStartDelim, 'pEleDelim', cElementDelim, 'pTemp', 1 ); IF( nRet <> ProcessExitNormal ); nErrors = nErrors + 1; sRet = NumberToString( nRet ); sMessage = Expand( 'Call to %sProc% has finished with errors (code = %sRet%).' ); sSequenceID = NumberToString( nMultiMsgJSON ); sMessageJSON = INSRT(' "message":"', sMessage | '"', 1); sMultiMsg = Expand( '%sMultiMsg%' | If(LONG(sMultiMsg)=0, '', ', ') | '"' | NumberToString( nMultiMsgJSON ) | '":{%sMessageJSON%}' ); nMultiMsgJSON = nMultiMsgJSON + 1; LogOutput( cMsgErrorLevel, Expand( cMsgErrorContent ) ); ProcessBreak; EndIF; ViewZeroOut( cCubThreadCtrl, cViewClr ); CellPutN( 1, cCubThreadCtrl, cUserName, cThisProcName, pThreadID, 'scheduled' ); CellPutN( 1, cCubThreadCtrl, cUserName, cThisProcName, pThreadID, 'running' ); CellPutN( 0, cCubThreadCtrl, cUserName, cThisProcName, pThreadID, 'completed' ); nThread = 1; While ( nThread < nThreads ); sThreadID = NumberToString( nThread ); CellPutN( 1, cCubThreadCtrl, cUserName, cThisProcName, sThreadID, 'scheduled' ); nThread = nThread + 1; End; CubeSaveData( cCubThreadCtrl ); nThread = 1; While ( nThread < nThreads ); sThreadID = NumberToString( nThread ); # TODO: Add proper parameters - all are passed through RunProcess( cThisProcName, 'pLogOutput', pLogOutput, 'pThreadID', sThreadID, 'pDimPar', pDimPar, 'pMaxThreads', pMaxThreads ); nThread = nThread + 1; End; Else; CellPutN( 1, cCubThreadCtrl, cUserName, cThisProcName, pThreadID, 'running' ); CellPutN( 0, cCubThreadCtrl, cUserName, cThisProcName, pThreadID, 'completed' ); EndIf; EndIf;