Skip to content

Commit ffaa08d

Browse files
lbrowncubewiselotsaram
authored andcommitted
New B4 process to utilise the ExecuteCommand function (#112)
* Updated B4 calling processes to include the * wildcard function, following testing on client site. * Updated Bedrock Sub MDX process to include a parameter to set the subset alias on run * Adding new B4 process to utilise the ExecuteCommand function from any source, including TM1RunTI or RushTI etc. Also to remove the requirement of creating a new process for the purposes of using this function * Updated ExecuteCommand B4 process with check for quote characters * bedrock executecommand b4 process epilog success message updated following peer review.
1 parent 5ac78cd commit ffaa08d

1 file changed

Lines changed: 181 additions & 0 deletions

File tree

Lines changed: 181 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,181 @@
1+
601,100
2+
602,"}bedrock.server.executecommand"
3+
562,"NULL"
4+
586,
5+
585,
6+
564,
7+
565,"c6ra[C[7?MRZGEd4Vj8iW<bLezX3G;syGaB:Sf0R1gMIzkNX0>6jhYCZzGu=F6_VXaS3geIQPIpyx6J:V[jfDQgSFAG8iQts]3x9DVFqhJu4emK64:eRYT@aakRBkVloBi;bGY11r_B>gze>foyX0_bp>^DJ69mEKS<0aCEznZ>SIE0<Am=UX]XUlOw4p6mBD@XElDmH"
8+
559,1
9+
928,0
10+
593,
11+
594,
12+
595,
13+
597,
14+
598,
15+
596,
16+
800,
17+
801,
18+
566,0
19+
567,","
20+
588,"."
21+
589,","
22+
568,""""
23+
570,
24+
571,
25+
569,0
26+
592,0
27+
599,1000
28+
560,3
29+
pLogOutput
30+
pCommand
31+
pWait
32+
561,3
33+
1
34+
2
35+
2
36+
590,3
37+
pLogOutput,0
38+
pCommand,""
39+
pWait,"0"
40+
637,3
41+
pLogOutput,"Optional: write parameters and action summary to server message log (Boolean True = 1)"
42+
pCommand,"The full command line string to execute"
43+
pWait,"Wait for command to finish 0=false 1=true"
44+
577,0
45+
578,0
46+
579,0
47+
580,0
48+
581,0
49+
582,0
50+
603,0
51+
572,47
52+
#****Begin: Generated Statements***
53+
#****End: Generated Statements****
54+
55+
#################################################################################################
56+
##~~Join the bedrock TM1 community on GitHub https://github.com/cubewise-code/bedrock Ver 4.0~~##
57+
#################################################################################################
58+
59+
#Region @DOC
60+
# Description:
61+
# This process will run the TI ExecuteCommand function.
62+
63+
# Use case: Intended for production.
64+
# 1/ To run an executeCommand function from any part of the model, including RushTI or third party system without direct access to TI Editor.
65+
# 2/ To remove the requirement of creating a one off process to use this function
66+
67+
#EndRegion @DOC
68+
69+
### Global Variables
70+
StringGlobalVariable('sProcessReturnCode');
71+
NumericGlobalVariable('nProcessReturnCode');
72+
nProcessReturnCode= 0;
73+
74+
### Constants ###
75+
cThisProcName = GetProcessName();
76+
cUserName = TM1User();
77+
cMsgErrorLevel = 'ERROR';
78+
cMsgErrorContent = 'User:%cUserName% Process:%cThisProcName% ErrorMsg:%sMessage%';
79+
80+
## LogOutput parameters
81+
If( pLogOutput = 1 );
82+
sLogInfo = Expand('Process:%cThisProcName% run with parameters: pCommand: %pCommand%, pWait: %pWait%');
83+
LogOutput ( 'INFO', sLogInfo );
84+
nStart = Now();
85+
EndIf;
86+
87+
### Validate Parameters ###
88+
nErrors = 0;
89+
If ( pCommand @= '' );
90+
sMessage = 'parameter pCommand is blank';
91+
LogOutput ( 'ERROR', sMessage );
92+
ProcessQuit;
93+
EndIf;
94+
95+
### ExecuteCommand ###
96+
nWait = StringToNumber ( pWait );
97+
98+
# Check if the pCommand parameter is enclosed in quotes and add if not
99+
sSubst = Subst ( pCommand, 1, 1 );
100+
If ( Subst ( pCommand, 1, 1 ) @<> '"' );
101+
sCommand = Expand ( '"%pCommand%"' );
102+
Else;
103+
sCommand = pCommand;
104+
EndIf;
105+
106+
ExecuteCommand ( pCommand, nWait );
107+
108+
573,2
109+
#****Begin: Generated Statements***
110+
#****End: Generated Statements****
111+
574,2
112+
#****Begin: Generated Statements***
113+
#****End: Generated Statements****
114+
575,27
115+
#****Begin: Generated Statements***
116+
#****End: Generated Statements****
117+
118+
### LogOutput ###
119+
120+
If( pLogOutput = 1 );
121+
sSec = NumberToStringEx( 86400*(Now() - nStart),'#,##0.0', '.', ',' );
122+
sLogInfo = Expand('Process:%cThisProcName% completed. Elapsed time %sSec% seconds.');
123+
LogOutput( 'INFO', sLogInfo );
124+
EndIf;
125+
126+
### Return code & final error message handling
127+
If( nErrors > 0 );
128+
sMessage = 'the process incurred at least 1 error. Please see above lines in this file for more details.';
129+
nProcessReturnCode = 0;
130+
LogOutput( cMsgErrorLevel, Expand( cMsgErrorContent ) );
131+
sProcessReturnCode = Expand( '%sProcessReturnCode% Process:%cThisProcName% completed with errors. Check tm1server.log for details.' );
132+
Else;
133+
sProcessAction = Expand( 'Process:%cThisProcName% completed successfully.' );
134+
sProcessReturnCode = Expand( '%sProcessReturnCode% %sProcessAction%' );
135+
nProcessReturnCode = 1;
136+
If( pLogoutput = 1 );
137+
LogOutput('INFO', Expand( sProcessAction ) );
138+
EndIf;
139+
EndIf;
140+
141+
### End Epilog ###
142+
576,
143+
930,0
144+
638,1
145+
804,0
146+
1217,0
147+
900,
148+
901,
149+
902,
150+
938,0
151+
937,
152+
936,
153+
935,
154+
934,
155+
932,0
156+
933,0
157+
903,
158+
906,
159+
929,
160+
907,
161+
908,
162+
904,0
163+
905,0
164+
909,0
165+
911,
166+
912,
167+
913,
168+
914,
169+
915,
170+
916,
171+
917,0
172+
918,1
173+
919,0
174+
920,50000
175+
921,""
176+
922,""
177+
923,0
178+
924,""
179+
925,""
180+
926,""
181+
927,""

0 commit comments

Comments
 (0)