Skip to end of metadata
Go to start of metadata

You are viewing an old version of this page. View the current version.

Compare with Current View Page History

Version 1 Next »

Prerequisites:

Process Parameters:

Parameter

Type

Prompt

Value

pLogOutput

String

Record in process log

1

pMaxThreads

String

Optional: Maximum number of threads for parallel processing: default =1

1

pDimPar

String

Optional: Parallelization dimension: default =blank (FIN Company)

pThreadID

String

Private: Thread ID (don't override, leave 0 as default)

0

Prolog (declarations):

cDimPar = 'FIN Company';

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 );
      RunProcess( cThisProcName,
        'pLogOutput', pLogOutput,
        'pVersion', pVersion,
        'pYear', pYear,
        'pCompany', pCompany,
        'pBSEG1', pBSEG1,
        'pBSEG2', pBSEG2,
        'pBSEG3', pBSEG3,
        'pBSEG4', pBSEG4,
        'pThreadID', sThreadID,
        'pDimPar', pDimPar,
        'pMonthFrom', pMonthFrom,
        'pMonthTo', pMonthTo,
        'pMaxThreads', pMaxThreads,
        'pReattachRule', '0'
      );
      nThread = nThread + 1;
    End;
  Else;
    CellPutN( 1, cCubThreadCtrl, cUserName, cThisProcName, pThreadID, 'running' );
    CellPutN( 0, cCubThreadCtrl, cUserName, cThisProcName, pThreadID, 'completed' );
  EndIf;
EndIf;

  • No labels