DMCM Developers Ref
DMCM Developers Ref
DIMENSIONS CM 12.2.1
Developer’s Reference
Serena Proprietary and Confidential Information
Copyright © 1988–2012 Serena Software, Inc. All rights reserved.
This document, as well as the software described in it, is furnished under license and may
be used or copied only in accordance with the terms of such license. Except as permitted
by such license, no part of this publication may be reproduced, photocopied, stored in a
retrieval system, or transmitted, in any form or by any means, electronic, mechanical,
recording, or otherwise, without the prior written permission of Serena. Any reproduction
of such software product user documentation, regardless of whether the documentation
is reproduced in whole or in part, must be accompanied by this copyright statement in its
entirety, without modification.
This document contains proprietary and confidential information, and no reproduction or
dissemination of any information contained herein is allowed without the express
permission of Serena Software.
The content of this document is furnished for informational use only, is subject to change
without notice, and should not be construed as a commitment by Serena. Serena
assumes no responsibility or liability for any errors or inaccuracies that may appear in this
document.
Third party programs included with the Dimensions product are subject to a restricted
use license and can only be used in conjunction with Dimensions.
Trademarks
Serena, TeamTrack, StarTool, PVCS, Collage, Comparex, Dimensions, Serena Dimensions,
Mashup Composer, Mashup Exchange, Prototype Composer, Mariner and ChangeMan are
registered trademarks of Serena Software, Inc. The Serena logo, Version Manager,
Meritage and Mover are trademarks of Serena Software, Inc. All other products or
company names are used for identification purposes only, and may be trademarks of their
respective owners.
Developer's Reference 3
Table of Contents
Developer's Reference 5
Table of Contents
Purpose . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 76
Prototype . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 76
Parameters. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 76
Return Codes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 76
Comments . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 76
Related Functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 76
PcmsGetBaseDbOptions - Retrieve Base Database Options . . . . . . . . . . . . 77
Purpose . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 77
Prototype . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 77
Parameters. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 77
Return Codes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 77
Comments . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 77
Related Functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 77
PcmsGetCandidates - Retrieve Candidates for Delegation . . . . . . . . . . . . . 78
Purpose . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 78
Prototype . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 78
Parameters. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 78
Return Codes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 78
PcmsGetCommandLine – Get the Dimensions CM Command . . . . . . . . . . . 79
Purpose . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 79
Prototype . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 79
Parameters. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 79
PcmsGetConnectDesc - Get Input File Descriptor . . . . . . . . . . . . . . . . . . . 80
Purpose . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 80
Prototype . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 80
Parameters. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 80
Return Codes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 80
Comments . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 80
Related Functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 80
PcmsGetDimensionsVersions - Obtain List of Loaded DLLs and Dates and Times for
Each. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 81
Purpose . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 81
Prototype . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 81
Parameters. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 81
Return Codes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 81
Comments . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 81
Related Functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 81
PcmsGetPendingUsers - Obtain Inbox User Structures . . . . . . . . . . . . . . . 82
Purpose . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 82
Prototype . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 82
Parameters. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 82
Return Codes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 83
Related Functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 83
PcmsGetRSAttrs - Retrieve Attribute Numbers in a Role Section . . . . . . . . 84
Purpose . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 84
Prototype . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 84
Parameters. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 84
Return Codes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 85
Comments . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 85
Related Functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 85
PcmsGetRSNames - Obtain Role Section Names for a Product . . . . . . . . . . 86
Purpose . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 86
Prototype . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 86
Parameters. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 86
Return Codes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 86
Related Functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 87
PcmsGetStringSymbolValue - Obtain Values Associated with a Symbol. . . . 88
Purpose . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 88
Prototype . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 88
Parameters. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 88
Return Codes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 88
Comments . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 88
Related Functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 88
PcmsGetSymbolInfo - Look Up Symbol in Structured Information Return Table89
Purpose . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 89
Prototype . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 89
Parameters. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 89
Return Codes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 89
Comments . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 90
Related Functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 90
PcmsGetUserRelTypes - Obtain User Relationship Subtypes . . . . . . . . . . . 91
Purpose . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 91
Prototype . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 91
Parameters. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 91
Return Codes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 91
Comments . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 92
PcmsGetUserRoles - Obtain User Role Structures. . . . . . . . . . . . . . . . . . . 93
Purpose . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 93
Prototype . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 93
Parameters. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 93
Return Codes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 94
Comments . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 94
Related Functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 94
PcmsGetWsetObj - Get User's Current Project . . . . . . . . . . . . . . . . . . . . . 95
Purpose . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 95
Prototype . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 95
Parameters. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 95
Return Codes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 95
Sample . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 95
PcmsInitSpec - Get Dimensions CM Object Details by Specification . . . . . . 96
Purpose . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 96
Prototype . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 96
Parameters. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 96
Return Codes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 96
Comments . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 96
Related Functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 96
Developer's Reference 7
Table of Contents
Developer's Reference 9
Table of Contents
Parameters. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 135
PcmsClntApiGetLastError - Get the Last Dimensions CM Message . . . . . . . 136
Purpose . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 136
Prototype . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 136
Parameters. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 136
Return Codes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 136
Related Function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 136
PcmsClntApiGetLastErrorEx - Get the Last Dimensions CM Message (Dynamic
Buffer) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 137
Purpose . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 137
Prototype . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 137
Parameters. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 137
Return Codes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 137
Related Function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 137
PcmsClntApiModeBinary - Set File Transfer Mode to Binary . . . . . . . . . . . . 138
Purpose . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 138
Prototype . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 138
Parameters. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 138
Return Codes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 138
Comments . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 138
PcmsClntApiModeText - Set File Transfer Mode to ASCII. . . . . . . . . . . . . . 139
Purpose . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 139
Prototype . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 139
Parameters. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 139
Return Codes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 139
Comments . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 139
PcmsClntApiSilentConnect - Connect Silently to a Dimensions CM Database 140
Purpose . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 140
Prototype . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 140
Parameters. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 140
Return Codes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 140
Related Functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 141
Additional Supported DTK Functions. . . . . . . . . . . . . . . . . . . . . . . . . . . . 142
Developer's Reference 11
Table of Contents
)CM . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 181
)DUMP . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 181
)ELSE . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 182
)ENDIF. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 182
)ENDEXPAND . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 183
)ENDR . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 184
)ENDSCRIPT . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 184
)EXPAND . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 184
)IF. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 185
)IFDEF . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 185
)IFNDEF . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 185
)IM . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 185
)LOGON . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 186
)REP . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 186
)SCRIPT . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 188
)SET . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 188
)SETL. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 188
)SET_PATH . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 189
)SET_PATH_MVS . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 189
)SET_PATH_NT . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 189
)SET_PATH_UNIX . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 190
)SETU . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 190
)SLICE . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 190
)VECTOR . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 191
Special Directives . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 191
General Predefined Symbols . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 191
%DMCOMBINEOUTERR. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 192
%DMCURRENTDIRECTORY. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 192
%DMCYGWIN. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 192
%DMDAY. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 192
%DMFOLDERSEPARATOR. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 192
%DMHOUR. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 192
%DMMICROSEC. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 193
%DMMINUTE. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 193
%DMMONTH. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 193
%DMOSTDERR.. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 193
%DMOSTDOUT. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 193
%DMOSTYPE. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 193
%DMOXTMPLT. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 194
%DMPASSWORD. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 194
%DMPATHSEPARATOR. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 194
%DMSAVESTDERR. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 194
%DMSAVESTDOUT. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 194
%DMSECOND. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 195
%DMUNIQUE. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 195
%DMUSER.. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 195
%DMUSERU.. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 195
%DMYEAR. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 195
Developer's Reference 13
Table of Contents
Developer's Reference 15
Table of Contents
Index. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 291
Purpose of this This manual describes the various application programming interfaces (APIs) and other
manual programming interfaces that enable you to programmatically extend the functionality of
Dimensions CM. The intended audience for this manual is users who are well versed in
both Dimensions CM concepts and in the C, C++, and Java programming languages.
NOTE Unless definitive Linux information is required in a particular context, Linux will be
regarded as simply another "flavor" of UNIX for the purposes of this guide.
Demonstrations
Demonstrations for Dimensions CM can be accessed at the following public Web site:
http://www.serena.com/serenacourseware/dimensions
Developer's Reference 17
Welcome to Serena Dimensions CM
Typographical Conventions
The following typographical conventions are used in the online manuals and online help.
These typographical conventions are used to assist you when using the documentation;
they are not meant to contradict or change any standard use of typographical conventions
in the various product components or the host operating system.
italics Introduces new terms that you may not be familiar with and
occasionally indicates emphasis.
bold Emphasizes important information and field names.
UPPERCASE Indicates keys or key combinations that you can use. For example,
press the Enter key.
monospace Indicates syntax examples, values that you specify, or results that
you receive.
monospaced Indicates names that are placeholders for values you specify; for
italics example, filename.
monospace Indicates the results of an executed command.
bold
vertical rule | Separates menus and their associated commands. For example,
select File | Copy means to select Copy from the File menu.
Also, indicates mutually exclusive choices in a command syntax line.
brackets [] Indicates optional items. For example, in the following statement:
SELECT [DISTINCT], DISTINCT is an optional keyword.
... Indicates command arguments that can have more than one value.
Language-specific technical support is available during local business hours. For all other
hours, technical support is provided in English.
Developer's Reference 19
Part 1 C/C++ API DTK
Overview 22
Positioning Your Solutions within the DTK 22
Scope of the DTK Architecture 23
Developer's Reference 21
Chapter 1 What is the Dimensions CM Toolkit Interface?
Overview
The Serena® Dimensions® CM Developer's Toolkit Interface (DTK) is a powerful C and
C++ Applications Programming Interface (API) that allows you to access data held within
a Dimensions CM repository.
This chapter takes you through the architecture of the DTK and how you can use it to
expand on the functionality offered by Dimensions CM.
1 As a separate client application that uses the DTK to access and manipulate objects
held within a Dimensions CM repository
2 As a rich event callout interface that allows you to perform your own customized
operations when certain Dimensions CM commands are run.
When you are looking at your requirements keep in mind where within the DTK
architecture you wish to position your solution. If, for example, you have a requirement
where you need to assess the impact to one of your projects of implementing a number of
application changes, then you would use the format for Client Architecture as stated in the
following subsection.
Client Architecture
This scheme enables you to use the DTK as an input/output interface into the
Dimensions CM repository. If, however, you wanted a specific operation or action to be
performed when certain Dimensions CM commands are run, then you would use the Event
Architecture described below.
Event Architecture
Using the Event Architecture you can design a set of customizations that are applied
explicitly when a user issues a certain Dimensions CM command. A public interface is
provided that allows you to pass information back and forth between the event and the
Dimensions CM server. The result of this is that you can manipulate the outcome of the
command in certain ways.
Dimensions
Event Data
For more details on how events operate, please refer to Chapter 5, "Dimensions CM
Events Callout Interface" on page 145.
Developer's Reference 23
Chapter 1 What is the Dimensions CM Toolkit Interface?
Introduction 26
DTK Return Codes 27
DTK Data Structures 28
DTK System Attribute Definitions 35
DTK Constant Definitions 40
Memory Allocation within the DTK 41
Developer's Reference 25
Chapter 2 Writing Dimensions CM DTK Applications
Introduction
This chapter outlines the data structures, manifest constants, and return codes that are
used by the DTK. These structures and constants are defined in the provided include file
pcms_api.h in the directory:
$DM_ROOT%/pcms_api for UNIX.
%DM_ROOT%\pcms_api for Windows.
Any source file that references DTK functions or constants must include this file.
NOTES
2 The Dimensions CM 10.1.2 or later API supports MBCS (Multi-Byte Character Set). As
part of this support, the legacy primitive type char has been replaced by _TCHAR. If
you do not intend to utilize any MBCS or DBCS (Double-Byte Character Set)
functionality, you can continue to use char as in previous releases of Dimensions.
Note, UTF-8 is supported on non-Windows platforms.
3 The API library files are versioned to the number of the Dimensions CM release. For
example, in Dimensions CM 10.1.3 the API libraries are named pcms_api10m.lib
(Windows) and pcms_api10.so (UNIX).
4 The Dimensions CM 2009 R1 or later API has added support for large files (4GBytes
or greater)—so, for example, you will now be able to check in and fetch back a DVD
ISO image. Consequently, the length of the corresponding item library file in such
circumstances will need to exceed 4Gbytes.
To provide support for such item library files, internally Dimensions CM 2009 R1 or
later uses 64-bit integers to represent library file lengths. Those 64-bit library
lengths are stored as pairs of low-order 32-bits and high-order 32-bits.
The PCMS_ITEM_DATA published view (see the Reports Guide) has been enhanced to
reflect this by providing a new column, LIB_FILE_LENGTH_HI, containing the high-
order 32-bits of the file length. The low-order 32-bits of the file length continue to be
stored in the LIB_FILE_LENGTH column as in releases of Dimensions CM prior to
2009 R1.
[continued on next page]
NOTES [continued]
This also means that the LIB_FILE_LENGTH and FILE_LENGTH item attributes can
potentially refer to 64-bit values. If you store files larger than 4Gbytes in
Dimensions CM, and use DTK applications or event callouts, then you need to ensure
that your code uses correct C functions for converting attribute values into 64-bit
integers and vice versa. Please refer to your compiler/C library vendor reference for
information on how to convert 64-bit integers into null-terminated strings and vice
versa.
PCMS_OK indicates that the function call succeeded, and objects were
processed (for example, a query returned some information).
PCMS_FAIL indicates that while the function call succeeded, no objects were
actually processed (for example, a query returned no objects).
PCMS_ERROR indicates that an error occurred trying to process the function call. If
an error is encountered, the reason for the error can be assessed by
examining the following variables.
int PcmsErrorNo If the error occurred due to a
char *PcmsErrorStr programming error, for example, invalid
parameters were specified to a DTK
function, these variables will be set
detailing the reason for the error.
int PcmsDbErrorNo If the error occurred due to a database
char *PcmsDbErrorStr error, for example, the database is full,
these variables will be set detailing the
reason for the error.
NOTE ErrorNo variables and ErrorStr variables will be set only when an error occurs.
Developer's Reference 27
Chapter 2 Writing Dimensions CM DTK Applications
PcmsCallbackStruct
Definition
typedef struct PcmsCallbackStruct
{
PcmsCallbackProc callback;
void *clientData;
} PcmsCallbackStruct;
Description
This structure is used to hold information regarding registered callbacks. For more
information please refer to PcmsSetCallback().
PcmsChdAttachmentStruct
Definition
typedef struct PcmsChdAttachmentStruct
{
int uid;
_TCHAR opt;
_TCHAR filename[(PCMS_L_FILENAME + 1)*CHARSIZEMAX];
_TCHAR *userFile;
_TCHAR dateTime[(PCMS_L_DATE_TIME + 1)*CHARSIZEMAX];
_TCHAR userId[(PCMS_L_USER + 1)*CHARSIZEMAX];
_TCHAR description[(PCMS_L_REMARK + 1)*CHARSIZEMAX];
}
PcmsChdAttachmentStruct;
Description
To support integration with the Application Lifecycle Framework (ALF), this structure is
used to provide Dimensions CM event level access to Dimensions CM request
attachments.
PcmsEventStruct
Definition
typedef struct
{
char *database;/* Dimensions RDBMS database */
/* identification */
char *baseDb;/* Base Database */
int eventId;/* PCMS_EVENT_XXX */
/* See userSuppliedFunction */
int objType;/* PCMS_ITEM, PCMS_PART, */
/* PCMS_CHDOC */
int noAttrsChanged; /*The number of attributes */
/* that changed */
PcmsObjAttrStruct *attrsChanged;
/* Attribute number of field that changed */
int whenCalled;/* PCMS_EVENT_VALIDATE_OP, */
/* PCMS_EVENT_PRE_OP or PCMS_EVENT_POST_OP */
} PcmsEventStruct;
Description
This structure is used exclusively for events and defines which event is being fired and
with what parameters.
PcmsLcStruct
Definition
typedef struct
{
char normalPath;
int phase;
char status [PCMS_L_STATUS + 1];
char role [PCMS_L_ROLE + 1];
} PcmsLcStruct;
Description
This structure holds lifecycle definition information.
Developer's Reference 29
Chapter 2 Writing Dimensions CM DTK Applications
PcmsObjAttrDefStruct
Definition
typedef struct
{
int attr;/* Attribute number */
int valueMaxLen;/* The maximum length of the */
/* attribute */
char variable [PCMS_L_ATTR_VARIABLE + 1];
/*The attribute name */
char prompt [PCMS_L_ATTR_PROMPT + 1];
/* The screen prompt*/
char attrType;/* PCMS_ATTR_DATE = 'D' */
/* PCMS_ATTR_UNDEFINED = 'U' */
/* PCMS_ATTR_INTEGER = 'I' */
/* PCMS_ATTR_NUMBER = 'N' */
/* PCMS_ATTR_CHAR = 'C' */
char scope;/* PCMS_ATTR_ITEM='I' */
/* PCMS_ATTR_PART='P'*/
char display;/* Y or N */
char allRevisions;/* Y or N */
char manOpt;/* MANDATORY = 'Y' */
/* OPTIONAL = 'N' */
char fldUpd;/* 'Y' or 'N' */
char roleCheck [PCMS_L_ROLE + 1];
char uniqueVal;/* 'Y' *or 'N' /
char defaultVal[PCMS_L_ATTR_DEFAULT_VAL + 1];
char helpMess [PCMS_L_ATTR_HELP_MESS + 1];
char validationOn;/* Is validation enabled, */
/* Y or N */
int definedBy;/* PCMS_ATTR_PCMS/PROG/USER */
char hasLov;/* 'Y' or 'N'. List of Values */
/* must be used to set */
void **pp;/* Reserved */
char mva;/* 'Y' or 'N'.Multi-Valued */
/* use PcmsMva... macros to */
/* interpret. * /
char mvaType;/* not used currently */
char blockName [PCMS_L_ID + 1];
/* attr may belong to a */
/* display Block */
int blockColNo;/* Column number in the */
/* display block */
int displayWidth;/* Recommended display width */
int displayHeight;/* Recommended display height */
char multiLine;
/* 'Y' - use displayHeight ie. */
/* displayHeight > 0 */
/* 'N' - displayHeight not used */
char valueCase; /* 'L' - Lower 'U' - Upper, */
/* or 'M' - Mixed */
char catalogDisplay;/* 'Y' or 'N' */
} PcmsObjAttrDefStruct;
Description
This structure is used to hold information relating to the attribute definition. Some of the
fields for requests are currently hard-wired to the following values.
allRevisions 'N'
manOpt' 'N'
fldUpd 'Y'
roleCheck '\0'
uniqueVal 'N'
PcmsObjAttrStruct
Definition
typedef struct
{
int attr;/* Attribute number */
void *value;/* The value of the attribute. */
/* See section on Attribute Macros */
PcmsObjAttrDefStruct *attrDef;
/* Pointer to the definition */
/* of the attribute */
} PcmsObjAttrStruct;
Description
This structure is used to hold information regarding the attributes that an object has. The
attr member details the attribute number, while the *attrDef pointer contains details
on the attribute definition. The value of the attribute is accessed through the
PcmsMvaGetVal() and PcmsSvaGetVal() attribute macros. For more information about
these macros, please refer to the "Attribute Macros" on page 126.
Developer's Reference 31
Chapter 2 Writing Dimensions CM DTK Applications
PcmsObjStruct
Definition
typedef struct PcmsObjStruct
{
int uid;
int specUid;
int objType; /* PCMS_ITEM, PCMS_PART, PCMS_CHDOC, etc */
int typeUid;
_TCHAR typeName[(PCMS_L_TYPE_NAME + 1)*CHARSIZEMAX];
_TCHAR productId[(PCMS_L_PRODUCT_ID + 1)*CHARSIZEMAX];
_TCHAR objId[(PCMS_MAX_L_ID + 1)*CHARSIZEMAX];
_TCHAR variant[(PCMS_L_VARIANT + 1)*CHARSIZEMAX];
_TCHAR revision[(PCMS_L_REVISION + 1)*CHARSIZEMAX];
_TCHAR description[(PCMS_L_DESCRIPTION + 1)*CHARSIZEMAX];
_TCHAR userName[(PCMS_L_USER + 1)*CHARSIZEMAX];
_TCHAR status[(PCMS_L_STATUS + 1)*CHARSIZEMAX];
_TCHAR dateTime[(PCMS_L_DATE_TIME + 1)*CHARSIZEMAX];
_TCHAR isExtracted;
int noAttrs; /* The number of attributes for this object. */
PcmsObjAttrStruct *attrs; /* Pointer to the array of attributes. */
int specUid;
} PcmsObjStruct;
Description
This is the generic structure used for Dimensions CM objects such as items, parts,
requests, and baselines. The type of object is defined by the member field objType being
set to a specific constant (for example, PCMS_ITEM). The *attrs pointer can be used to
access attribute information if it is defined. The specUid field contains the object's
specification uid, where applicable, or -1.
PcmsPendingUserStruct
Definition
typedef struct
{
char user [PCMS_L_USER+ 1];/* User */
char role [PCMS_L_ROLE + 1];/* Role */
char capability;/* The user's capability in */
/* role, either */
/* 'P' - Primary or */
/* 'S' - Secondary or */
/* 'L' – Leader */
char nextStatus [PCMS_L_STATUS + 1];
/* next possible status */
int nextPhase;/* next phase */
char actionable;
/* PCMS_ACT_NOT_LEADER = '1' */
/* (Can't action not leader) */
/* PCMS_ACT_OK = '2' */
/* (Can action no leaders) */
/* PCMS_ACT_LEADER = '3' */
/* (Can action I am a leader) */
} PcmsPendingUserStruct;
Description
This structure holds information relating to who can action an object and to what states.
PcmsPendStruct
Definition
typedef struct
{
int objUid;
int objType;
char capability;/* 'P' - Primary, */
/* 'S'- Secondary, */
/* 'L' - Leader*/
char actionable;/* PCMS_ACT_NOT_LEADER = '1'*/
/* (can't action not leader), */
/* PCMS_ACT_OK = '2' */
/* (Can action no leaders), */
/* PCMS_ACT_LEADER = '3' */
/* (Can action I am a leader) */
} PcmsPendStruct;
Description
This structure holds object inbox information.
PcmsRelStruct
Definition
typedef struct
{
int uid;
int objType;
int relType;
int relSubTypeUid;
/* Refers to the uid field of a */
/* PcmsRelTypeStruct. For requests, users */
/* may setup up specialization's of the basic */
/* relTypes to add attributes, etc. See */
/* section on PcmsGetUserRels */
} PcmsRelStruct;
Description
This structure is used in conjunction with PcmsRelTypeStruct and stores the
relationships that an object has.
Developer's Reference 33
Chapter 2 Writing Dimensions CM DTK Applications
PcmsRelTypeStruct
Definition
typedef struct
{
int uid;/* of this relationship subType */
char name [ PCMS_L_ID + 1];
/* Name for this rel subtype*/
int relType;
/* The parent relationship type */
/* for, example, PCMS_REL_INFO */
char productId [ PCMS_L_PRODUCT_ID + 1];
/* Product name */
} PcmsRelTypeStruct;
Description
This structure is used to hold information relating to the user-defined types used in
Dimensions CM. For example, 'request to request' relationships.
PcmsRoleStruct
Definition
typedef struct PcmsRoleStruct
{
char role [PCMS_L_ROLE + 1];/* Role */
int uid;/* uid of the part */
char leader;/* 'Y' = Leader only role */
} PcmsRoleStruct;
Description
This structure holds information of the roles defined on a Dimensions CM product.
PcmsTypeStruct
Definition
typedef struct
{
int uid;
char productId [PCMS_L_PRODUCT_ID + 1];
char typeName [PCMS_L_TYPE_NAME + 1];
int objType;/* PCMS_PART, PCMS_ITEM, */
/* PCMS_CHDOC etc*/
char lifecycle [PCMS_L_ID + 1];
char typeDescription [PCMS_L_DESCRIPTION + 1];
char superType;/* '1', '2', '3', or '4'*/
/* for requests only */
} PcmsTypeStruct;
Description
This structure holds object type definition information.
PcmsUserRoleStruct
Definition
typedef struct
{
char user [PCMS_L_USER + 1];/* User */
char role [PCMS_L_ROLE + 1];/* Role */
char capability;/* The users capability in */
/* this role, either */
/* 'P' - Primary or */
/* 'S' - Secondary or */
/* 'L' - Leader */
char applyDeny;/* applyDeny flag not */
/* currently used */
char treeWalk;/* treeWalk flag not */
/* currently used */
char actionable;
/* PCMS_ACT_NOT_LEADER = '1' */
/* (Can't action not leader) */
/* PCMS_ACT_OK = '2' */
/* (Can action no leaders) */
/* PCMS_ACT_LEADER = '3' */
/* (Can action I am a leader) */
char fromTree;/* 'Y' This role was found */
/* from the Part Structure */
/* 'N' This role was delegated */
/* using the DLGC command */
} PcmsUserRoleStruct;
Description
This structure is used to hold information relating to role assignments.
Developer's Reference 35
Chapter 2 Writing Dimensions CM DTK Applications
The table below details the system attributes that are available for each object type.
Number of
Reference
Attributes
Definition
Attribute
System
Object
Type
Number of
Reference
Attributes
Definition
Attribute
System
Object
Type
PCMS_ : PCMS_NUM_ : PCMS_ATTR_ :
OWNER_SITE Issue replication attribute:
current owner site.
PHASE Current phase of the
request.
SUPER_TYPE Super type of the request.
UPDATE_DATE Update date of the request.
Developer's Reference 37
Chapter 2 Writing Dimensions CM DTK Applications
Number of
Reference
Attributes
Definition
Attribute
System
Object
Type
PCMS_ : PCMS_NUM_ : PCMS_ATTR_ :
LIB_FILENAME_HI Length of the item file in the
library (high-order 32-bits).
See Step 4 of "Introduction"
on page 26 for a discussion
of support for files greater
than 4Gbytes.
LIFECYCLE Lifecycle id that is followed
by the item.
LOCKED_USER The user who last locked/
unlocked this file.
LOCKED_DATETIME The date that the file was
last locked/unlocked.
LOCKED_FILE Indicates if the file is
currently locked.
ORIGINATOR Who created the item.
PHASE The item's current phase.
REVISED_DATE The item's last revised date
in Julian date format (this is
the equivalent of Oracle's
date format: 'J.SSSSS').
Number of
Reference
Attributes
Definition
Attribute
System
Object
Type
PCMS_ : PCMS_NUM_ : PCMS_ATTR_ :
Developer's Reference 39
Chapter 2 Writing Dimensions CM DTK Applications
Number of
Reference
Attributes
Definition
Attribute
System
Object
Type
PCMS_ : PCMS_NUM_ : PCMS_ATTR_ :
PRIVILEGE_LEVEL The user’s privilege.
SITE The user’s site name.
Relationships (relType)
Relationship types are constants used in the DTK to indicate relationships between
objects (for example, usage).
Phases
Phases are generic indicators that are used to show where a particular object is in its
lifecycle. Please refer to the related document Introduction to Dimensions CM for more
information.
PcmsEvntFree() free()
PcmsEvntMalloc() malloc()
PcmsEvntCalloc() calloc()
PcmsEvntRealloc() realloc()
Developer's Reference 41
Chapter 2 Writing Dimensions CM DTK Applications
int *uids = 0;
int noUids = 0;
if (PcmsQuery(conId, &queryObj,0,&noUIds,&uids)!=PCMS_OK)
PcmsEvntFree(uids);
then you would use PcmsEvntFree() function to free this memory. You do not need
to use these functions if you are allocating memory that is not used by the DTK.
However, to be consistent in the memory functions that you do use, it is strongly
recommended that you use these functions for all memory allocation and de-
allocation.
Within DTK events these functions must always be used to allocate or de-allocate
memory. This includes both memory usage with events and with reference to DTK
function calls, for example:
To minimize the impact of any code changes, it is suggested that you redefine the
standard C functions to use the new functions through the use of #define(s), for
example:
and then recompile the event code. Please note, however, that the prototype of the
function PcmsEventCalloc() is not the same as calloc(). Please consult Chapter 3,
"DTK API Functions for C/C++" for more information.
NOTE These functions must always be used when freeing memory that has been
allocated by DTK function calls (such as PcmsQuery()) both within events and within
DTK client programs.
The table below is provided as a guideline to help you identify which functions and
pointers are dynamically assigned memory by the DTK, and what functions you should
use to free that memory. Ensure that you refer to the DTK function description for more
information on when this memory may be assigned.
Developer's Reference 43
Chapter 2 Writing Dimensions CM DTK Applications
Introduction 47
Memory Allocation by DTK Functions 47
Access Security in DTK Functions 47
PcmsAttrDefInit - Get Attribute Definition 49
PcmsAttrGetLov - Get Attribute's List of Values 50
PcmsAttrValidate - Validate an Attribute Value 53
PcmsCheckMessages - Check Results of Dimensions CM Command 54
PcmsCntrlPlanGet - Get Dimensions CM Process Model Information 56
PcmsConnect - Connect to Dimensions CM Database 59
PcmsDisconnect - Disconnect from a Dimensions CM Database 61
PcmsEvntCalloc – Allocate Zero Initialized Memory 62
PcmsEvntFree – Free Memory 63
PcmsEvntMalloc – Allocate Memory 64
PcmsEvntRealloc – Re-Allocate Memory 65
PcmsExecCommand - Execute Dimensions CM Command Synchronously 66
PcmsFullQuery - Find Dimensions CM Objects, Returning Complete Objects 68
PcmsGetAttachments - Obtain Request Attachment Structures 72
PcmsGetAttrDefNum - Get Attribute Definition Number 73
PcmsGetAttrFile - Get Request Descriptions 74
PcmsGetAttrs - Get Dimensions CM Object Attributes 76
PcmsGetBaseDbOptions - Retrieve Base Database Options 77
PcmsGetCandidates - Retrieve Candidates for Delegation 78
PcmsGetCommandLine – Get the Dimensions CM Command 79
PcmsGetConnectDesc - Get Input File Descriptor 80
PcmsGetDimensionsVersions - Obtain List of Loaded DLLs and Dates and Times for Each
81
PcmsGetPendingUsers - Obtain Inbox User Structures 82
PcmsGetRSAttrs - Retrieve Attribute Numbers in a Role Section 84
PcmsGetRSNames - Obtain Role Section Names for a Product 86
PcmsGetStringSymbolValue - Obtain Values Associated with a Symbol 88
PcmsGetSymbolInfo - Look Up Symbol in Structured Information Return Table 89
PcmsGetUserRelTypes - Obtain User Relationship Subtypes 91
PcmsGetUserRoles - Obtain User Role Structures 93
PcmsGetWsetObj - Get User's Current Project 95
PcmsInitSpec - Get Dimensions CM Object Details by Specification 96
Developer's Reference 45
Chapter 3 DTK API Functions for C/C++
Introduction
This chapter describes each of the functions that are available in the Serena®
Dimensions® CM DTK for C/C++ programs. The description of each function has the
following components.
Before reading this chapter, ensure that you have familiarized yourself with the contents
of Chapter 2, "Writing Dimensions CM DTK Applications" because it contains important
information relating to data structures, return codes, and manifest constants that are
referenced in this chapter.
PcmsAttrDefNum()
PcmsAttrGetLov()
PcmsAttrValidate()
PcmsCntrlPlanGet()
PcmsFullQuery()
PcmsGetAttachments()
Developer's Reference 47
Chapter 3 DTK API Functions for C/C++
PcmsGetAttrFile()
PcmsGetAttrs()
PcmsGetCandidates()
PcmsGetPendingUsers()
PcmsGetRSAttrs()
PcmsGetRSNames()
PcmsGetUserRelTypes()
PcmsGetUserRoles()
PcmsInitSpec()
PcmsInitUid()
PcmsObjGetBackRels()
PcmsObjGetRels()
PcmsPendWhoGet()
PcmsPopulate()
PcmsQuery()
PcmsSetAttrs()
PcmsWriteAttachments()
Purpose
This function retrieves an attribute definition for a specified typeUid, object type, and
attribute number.
Prototype
int
PcmsAttrDefInit (
int connectId,
int typeUid,
int objType,
int attrNum,
PcmsObjAttrDefStruct **ptrDefStruct
);
Parameters
connectId is the database connection identifier.
typeUid is the type (the typeUid field of the PcmsObjStruct) to which the
attribute applies.
objType is the type of the object. You can use PCMS_PART, PCMS_ITEM,
PCMS_BASELINE, PCMS_USER, PCMS_CHDOC, or PCMS_WORKSET.
attrNum is the attribute number for which the definition is to be retrieved.
ptrDefStruct is the address of a pointer to a PcmsObjAttrDefStruct in which the
attribute definition will be stored.
Return Codes
PcmsAttrDefInit() returns:
PCMS_OK on success.
PCMS_FAIL on failure to find the specified attribute number for the given type
and object type.
PCMS_ERROR on failure and sets PcmsErrorNo and PcmsErrorStr.
Related Functions
PcmsCntrlPlanGet().
Developer's Reference 49
Chapter 3 DTK API Functions for C/C++
Purpose
This function retrieves the list of valid set values that are allowed for a specified object
and attribute. The list of values is returned as an array of char *(s).
The PcmsObjStruct that is used in this function must have at least the following member
fields defined.
The typeUid set to the Dimensions CM type against which the attribute has been
assigned.
The noAttrs field set to at least 1.
The *attrs pointer set to a PcmsObjAttrStruct structure, which must have the
member fields set as follows:
• attr: attribute number you are querying
• value: a " " string through PcmsSvaSetVal()
• attrDef: the corresponding PcmsObjAttrDefStruct.
Prototype
int
PcmsAttrGetLov
(
int connectId,
PcmsObjStruct *objPtr,
int attrNum,
char **message,
int *noStrings,
char ***ptrArrayOfStrings
);
Parameters
connectId is the database connection identifier.
objPtr is the object containing the type and attribute details.
attrNum is the attribute number.
message is the error message returned if the status is not PCMS_OK. It is
the caller's responsibility to free this allocated memory if not
NULL.
noStrings is the address of an integer variable to contain the number of
strings in the array.
ptrArrayOfStrings is the address of a pointer to the array of returned strings. This
array must be freed through PcmsLovFree().
Return Codes
PcmsAttrGetLov() returns:
PCMS_OK on success.
PCMS_FAIL on failure to find the specified attribute number for the given type
and object type.
PCMS_ERROR on failure and sets PcmsErrorNo, PcmsErrorStr, PcmsDbErrorNo,
and PcmsDbErrorStr.
Sample
/*
*--------------------------------------------------------------
* FUNCTION SPECIFICATION
* Name:
* GetLovs
* Description:
* Get LOVs for a specified attribute and typeUid
* Parameters:
* int conId
* int objType
* int typeUid
* int attr
* Return:
* int
* Notes:
*------------------------------------------------------
*/
int GetLovs(int conId, int objType, int typeUid, int attr)
{
PcmsobjStruct obj = { 0 };
PcmsObjAttrDefStruct *attrDef = 0;
char **vals = 0;
int noVals = 0;
int x = 0;
char *ptrError = 0;
int status = 0;
obj.typeUid = typeUid;
obj.noAttrs = 1;
/* Get the details on the specified attribute */
if ((status = PcmsAttrDefInit(conId,typeUid
objType,attr,&attrDef))!=PCMS_OK)
return status;
/* Put together a dummy object structure */
obj.attrs =
(PcmsObjAttrStruct*)PcmsEvntMalloc(sizeof(PcmsObjAttrStruct)*1);
obj.attrs[0].attr = attr;
PcmsSvaSetVal(obj.attrs[0].value,NULL,0);
obj.attrs[0].attrDef = attrDef;
/* Get the LOV values */
if ((status = PcmsAttrGetLov(conId,&obj,
attr,&ptrError,
&noVals,&vals))==PCMS_OK)
Developer's Reference 51
Chapter 3 DTK API Functions for C/C++
{
int i = 0;
/**
** Scan list of LOVs and report
**/
for(i=O;i<noVals;i++)
(void)fprintf(stdout,
"\nLov[%d/%d] - %s",
i,noVals,vals[i]);
PcmsLovFree(noVals,vals);
}
void)PcmsObjFree(&obj);
return(status);
}
Related Functions
PcmsAttrDefInit(), PcmsAttrValidate().
Purpose
This function verifies that any attribute values specified on a given object structure do not
conflict with any valid sets that may have been defined.
Prototype
int
PcmsAttrValidate (
int connectId,
PcmsObjStruct *objPtr,
int attrNum,
char **message
);
Parameters
connectId is the database connection identifier.
objPtr is the object containing the attribute values to be validated.
attrNum is the attribute number against which the object attributes will be
validated.
message is the error message returned if the status is not PCMS_OK. It is the
caller's responsibility to free this allocated memory if not NULL.
Return Codes
PcmsAttrValidate() returns:
PCMS_OK on success.
PCMS_FAIL on failure.
PCMS_ERROR on failure and sets PcmsErrorNo, PcmsErrorStr, PcmsDbErrorNo,
and PcmsDbErrorStr.
Related Functions
PcmsAttrGetLov(), PcmsLovFree().
Developer's Reference 53
Chapter 3 DTK API Functions for C/C++
Purpose
This function may be used to check whether the results from Dimensions CM commands
previously submitted, using PcmsSendCommand(), are available.
Prototype
int
PcmsCheckMessages (
int connectId,
int flag
);
Parameters
connectId is the database connection identifier.
flag is used to determine whether the operation is to be blocking
(PCMS_MSG_WAIT) or non-blocking (PCMS_MSG_NOWAIT).
Return Codes
PcmsCheckMessages() returns:
PCMS_OK results of a command are available and the callback function has
been invoked.
PCMS_FAIL results of a command are not available (non-blocking operation).
PCMS_ERROR on failure and sets PcmsErrorNo and PcmsErrorStr.
Comments
If there are no commands being processed on this connection, PCMS_FAIL will be
returned. If there are outstanding commands, the operation of this function will depend
on the value of flag.
If flag is equal to PCMS_MSG_WAIT, the function will block (by calling the function set
with PcmsSetIdleChecker()) until the results of the next command are available.
The function will then invoke the callback function (see PcmsSetCallback() on page
118) and return PCMS_OK.
Related Functions
PcmsSendCommand(), PcmsSetCallback(), PcmsSetIdleChecker(),
PcmsExecCommand().
Developer's Reference 55
Chapter 3 DTK API Functions for C/C++
Purpose
This function queries the Dimensions CM process model and returns the data in various
different structures.
Prototype
int
PcmsCntrlPlanGet (
int connectId,
int reserved,
int options,
char *fromId,
int objUid,
char *startContext,
int *noStructs,
void **ptrStructs
);
Parameters
When options = PCMS_CHD_TYPE:
It is the responsibility of the calling application to free the ptrStructs pointer when it is
no longer required.
Developer's Reference 57
Chapter 3 DTK API Functions for C/C++
Return Codes
PcmsCntrlPlanGet() returns:
PCMS_OK on success.
PCMS_FAIL when no objects were found.
PCMS_ERROR on failure and sets PcmsErrorNo, PcmsErrorStr, PcmsDbErrorNo,
and PcmsDbErrorStr.
Purpose
This function provides you with a connection to the Dimensions CM database (for
example, intermediate) specified by the input parameters. You can use this function to
open multiple connections on the same or different Dimensions CM databases. This
function will return a connectId (integer) that represents your database connection. The
database parameters reflect the same values as you would specify for a DMDB symbol.
Prototype
int
PcmsConnect (
char *database,
char *password,
char *node
);
Parameters
database is the name of the Dimensions CM database to connect to.
password is the password of the database. Use NULL if the user is secure.
node is the RDBMS Service Name assigned to the node where the RDBMS
database is located.
Return Codes
PcmsConnect() returns:
Comments
This function will not return until a successful connection has been made, or an error is
encountered while attempting the connection.
If you wish to use the default Dimensions CM database for this user (DMDB), then invoke
PcmsConnect() with NULL parameters for database, password, and node.
This function will apply all the same pre-login user-verification checks as if the user had
typed dmcli at the command prompt.
Developer's Reference 59
Chapter 3 DTK API Functions for C/C++
Sample
/*
* connect to Dimensions
*
*/
int connect()
{
int conId = PCMS_ERROR
/* CONNECT to DMDB */
conId = PcmsConnect(NULL, NULL, NULL);
return conId;
}
Related Function
PcmsDisconnect().
Purpose
This function disconnects from the Dimensions CM database as specified by the
connectId. This connectId must be a valid connectId returned by PcmsConnect().
Prototype
int
PcmsDisconnect (
int connectId
);
Parameters
connectId is the database connection identifier.
Return Codes
PcmsDisconnect() returns:
PCMS_OK on success.
PCMS_ERROR on failure, and sets PcmsErrorNo, PcmsErrorStr,
PcmsDbErrorNo, and PcmsDbErrorStr.
Sample
/* Disconnect and exit with success… */
(void) PcmsDisconnect(conID);
return (EXIT_SUCCESS);
Comments
On some operating systems if you do not call this function before the application exits, the
connection to the repository may never terminate.
Related Function
PcmsConnect().
Developer's Reference 61
Chapter 3 DTK API Functions for C/C++
Purpose
This function is a wrapper to the C function calloc(). It must be used to allocated zero
initialized memory within a DTK application. The reason for this is that on some platforms,
like Windows, the memory that is allocated within a shared library must be freed in the
same shared library. If this is not done, then memory errors begin to occur. This function
is thus provided as a convenience to ensure that all the memory is allocated within the
context of the same shared library.
Prototype
void* PcmsEvntCalloc (int size);
Parameters
size is the size of the memory to allocate.
Purpose
This function is a wrapper to the C function free(). It must be used to free memory
allocated by DTK functions, such as PcmsQuery(). The reason for this is that on some
platforms, like Windows, the memory that is allocated within a shared library must be
freed by the same shared library. If this is not done, then memory errors begin to occur.
Prototype
void PcmsEvntFree (void *ptr);
Parameters
ptr is a pointer to the memory block that will be freed.
Developer's Reference 63
Chapter 3 DTK API Functions for C/C++
Purpose
This function is a wrapper to the C function malloc. It must be used to allocate memory
within a DTK application. The reason for this is that on some platforms, like Windows, the
memory that is allocated within a shared library must be freed by the same shared library.
If this is not done, then memory errors begin to occur. This function is thus provided as a
convenience to ensure that all the memory is allocated within the context of the same
shared library.
Prototype
void* PcmsEvntMalloc (int size);
Parameters
size is the size of the memory to allocate.
Purpose
This function is a wrapper to the C function realloc(). It must be used to re-allocate
memory within a DTK application. The reason for this is that on some platforms, like
Windows, the memory that is allocated within a shared library must be re-allocated by the
same shared library. If this is not done, then memory errors begin to occur. This function
is thus provided as a convenience to ensure that all the memory is maintained within the
context of the same shared library.
Prototype
void* PcmsEvntRealloc (void *ptr, int size);
Parameters
ptr is a pointer to the block of memory that will be resized.
size is the size of the new memory.
Developer's Reference 65
Chapter 3 DTK API Functions for C/C++
Purpose
This function sends a command to Dimensions CM and waits for it to complete. See the
Command-Line Reference for information on legal syntax for command mode
applications.
Prototype
int
PcmsExecCommand (
int connectId,
char *command,
char **response
);
Parameters
connectId is the database connection identifier.
command is the command to be executed.
response is the address of a char* variable that will be set to point to a
dynamically allocated buffer containing the diagnostic messages
generated during the execution of the command. It is the
responsibility of the calling application to free this buffer when it is
no longer required.
Return Codes
PcmsExecCommand () returns:
PCMS_OK on success.
PCMS_FAIL on the Dimensions CM command failing and sets the response
parameter.
PCMS_ERROR on other failures and sets PcmsErrorNo and PcmsErrorStr.
Sample
See the examples on the release media.
Comments
All commands that have been queued previously to Dimensions CM using
PcmsSendCommand() will be processed first. When the results from all those commands
have been received, the current command will be executed by Dimensions CM. Therefore
the time taken for PcmsExecCommand() to process a single simple command may depend
on the number of commands previously queued to Dimensions CM using
PcmsSendCommand().
Related Function
PcmsSendCommand().
Developer's Reference 67
Chapter 3 DTK API Functions for C/C++
Purpose
This function, like PcmsQuery(), will return a set of Dimensions CM objects based on a
user-specified filter. However, unlike PcmsQuery(), this function returns fully populated
PcmsObjStructs with both object and attribute details loaded. This function is faster
than PcmsQuery() for returning large amounts of data.
Prototype
int
PcmsFullQuery (
int connectId,
PcmsObjStruct *ptrPcmsObjStruct,
int options,
int *noObjs,
PcmsObjStruct **ptrObjs
);
Parameters
connectId is the database connection identifier.
ptrPcmsObjStruct is a pointer to a PcmsObjStruct that contains the fields to
query for. The objType field in the PcmsObjStruct can
currently only be PCMS_CHDOC.
options if this is set to PCMS_OPT_SECONDARY_CATALOGUE, then the
function will process requests in the secondary catalog. By
default this function processes requests in the primary
catalog.
noObjs is a pointer to an PcmsObjStruct variable in which to store
the objects returned in ptrObjs.
ptrObjs is a pointer to a contiguous block of allocated memory that
contains the structures that the query returned. If no objects
are found noObjs is set to zero and ptrObjs is set to
(PcmsObjStruct *) zero.
Return Codes
PcmsFullQuery() returns:
PCMS_OK on success.
PCMS_FAIL when no objects were found.
PCMS_ERROR on failure and sets PcmsErrorNo, PcmsErrorStr, PcmsDbErrorNo,
and PcmsDbErrorStr.
Sample
/*
*-------------------------------------------------------------
* FUNCTION SPECIFICATION
* Name:
* CountPcmsChdocs
* Description:
* Count chdocs
* Return:
* Return no of chdocs
*-------------------------------------------------------------
*/
static int
CountPcmsChdocs(int conId, char *chdoc)
{
/*
* Query the database for chdocs with the chdoc passed in...
*/
int *uids = 0;
int noUids = 0;
int noAttrs = 5;
int i = 0;
int xx = PCMS_OK;
PcmsObjStruct obj = { 0 };
PcmsObjStruct *ptrObjs = 0;
#define SET_ATTR(_attr,_value,p) \
{\
register int x = p;\
x--;\
obj.attrs[x].attr = _attr;\
PcmsSvaSetVal(obj.attrs[x].value,_value,0);\
p++;\
}
obj.objType = PCMS_CHDOC;
obj.noAttrs = noAttrs;
obj.attrs = 0;
obj.attrs =
(PcmsObjAttrStruct *)
PcmsEvntCalloc(sizeof(PcmsObjAttrStruct)
* obj.noAttrs);
(void)strcpy(obj.objId,chdoc);
i=1;
Developer's Reference 69
Chapter 3 DTK API Functions for C/C++
Comments
By manipulating the *attrs pointer and associated noAttrs members of the
PcmsObjStruct structure it is possible to use system and user attributes as additional
components within the query. If you wish to make use of this functionality, then you only
need to specify values in the attr and value members of the PcmsObjAttrStruct
structure. All other member fields are ignored.
Both the members of the PcmsObjStruct structure and the value field member of the
PcmsObjAttrStruct support the use of wildcard characters. There are two different
kinds of wildcard that you can use:
' % ' (per cent) that allows pattern matching on many characters
' _ ' (underscore) that allows pattern matching against one character.
If you use a multi-valued attribute as a filter, then only the first element of the attribute
list will be used, the other elements will be ignored.
Related Functions
PcmsQuery().
Developer's Reference 71
Chapter 3 DTK API Functions for C/C++
Purpose
This function allows users to retrieve the list of attachments for a specified request object.
Each of the structures that are returned detail an individual attachment for that request.
The "userFile" member of each returned structures is NULL.
Prototype
int
PcmsGetAttachments (
int connectId,
PcmsObjStruct object,
int *noAttachments,
PcmsChdAttachmentStruct **ptrAttachments
);
Parameters
connectId is the database connection identifier.
object is the request - PcmsObjStruct that has been initialized
through PcmsInitSpec() or PcmsInitUid().
noAttachments is the address of an integer variable to contain the number of
attachment structures returned.
ptrAttachments is a pointer to a contiguous block of allocated memory that
lists the structures of type PcmsChdAttachmentStruct. If no
attachments are found noAttachments is set to zero and
ptrAttachments is set to
(PcmsChdAttachmentStruct *)zero.
It is the responsibility of the called application to free this
pointer when it is no longer required.
Return Codes
PcmsGetAttachments() returns:
PCMS_OK on success.
PCMS_ERROR on failure or when no attachments are found.
Purpose
This function returns the attribute number for a specified attribute definition.
Prototype
int
PcmsGetAttrDefNum (
int connectId,
char *productId,
int objType,
char *attrName,
int *attrNum
);
Parameters
connectId is the database connection identifier.
productId is the product name.
objtype is the type of the object. You can use PCMS_PART, PCMS_ITEM,
PCMS_BASELINE, PCMS_USER, PCMS_CHDOC, or PCMS_WORKSET.
attrName is the name of the attribute (the variable field in the
PcmsObjAttrDefStruct).
attrNum is the returned attribute number.
Return Codes
PcmsGetAttrDefNum() returns:
PCMS_OK on success.
PCMS_FAIL on failure to find the specified attribute name for the given product
and object type.
PCMS_ERROR on failure and sets PcmsErrorNo and PcmsErrorStr.
Developer's Reference 73
Chapter 3 DTK API Functions for C/C++
Purpose
This function enables you to obtain either the detailed description, the current action
description, or full action for a specified Dimensions CM request.
Prototype
int
PcmsGetAttrFile (
int connectId,
PcmsObjStruct *objPtr,
int options,
int attrNo,
char **toFile,
int *size
);
Parameters
connectId is the database connection identifier.
objPtr is the pointer to the request that the function will use.
options Options 0 to 2 and 4 are used as follows:
0 Copies the selected description into a file specified by the variable
toFile
1 Copies the selected description into the variable toFile and
populates the size of the description file into the variable size.
2 Places only the size of the description into the variable size.
4 Do not convert the file to the local character set of the client.
attrNo specifies the type of description requested, the following values are valid.
PCMS_ATTR_ACTION_DESC Returns the full action
description of the
request.
PCMS_ATTR_THIS_ACTION_DESC Returns the current
action description for
the request.
PCMS_ATTR_DETAIL_DESC Returns the detailed
description of the
request.
toFile is a pointer to where the description is to be copied. If *toFile is a NULL
pointer, this function will allocate memory to hold the description. It is the
responsibility of the caller to free this memory after use.
size is a pointer to an integer into which the description size is returned.
Return Codes
PcmsGetAttrFile() returns:
PCMS_OK on success.
PCMS_FAIL on failure to find any data.
PCMS_ERROR on failure and sets PcmsErrorNo, PcmsErrorStr, PcmsDbErrorNo,
and PcmsDbErrorStr.
Developer's Reference 75
Chapter 3 DTK API Functions for C/C++
Purpose
This function populates a specific PcmsObjStruct with the attribute details for that
object. Calling this function will result in the noAttrs and *attrs member elements
being populated with the full attribute details and attribute definitions. If you wish to
access the information on the attribute definitions, use the PcmsObjAttrDefStruct
pointer (attrDef) from the PcmsObjAttrStruct (attrs) pointer.
Prototype
int
PcmsGetAttrs (
int connectId,
PcmsObjStruct *ptrPcmsObjStruct
);
Parameters
connectId is the database connection identifier.
ptrPcmsObjStruct is a pointer to a structure of type PcmsObjStruct into which the
attribute information will be populated.
Return Codes
PcmsGetAttrs() returns:
PCMS_OK on success.
PCMS_FAIL on not finding the object.
PCMS_ERROR on failure and sets PcmsErrorStr, PcmsDbErrorNo, and
PcmsDbErrorStr.
Comments
Before calling this function ensure that you have populated a valid PcmsObjStruct
through the PcmsInitUid() or PcmsInitSpec() functions.
When you have populated an object structure using this function, remember to free the
memory associated with it through PcmsObjFree() when that object is no longer
required.
Related Functions
PcmsInitUid(), PcmsInitSpec(), PcmsObjFree()
Purpose
This function populates a specific PcmsObjStruct with the details of the defined base
database options. Calling this function will result in the noAttrs and *attrs member
elements being populated with the full option details and option definitions. If you wish to
access the information on the database option definitions, use the
PcmsObjAttrDefStruct pointer (attrDef) from the PcmsObjAttrStruct (attrs)
pointer.
Prototype
int
PcmsGetBaseDbOptions(
int connectId,
PcmsObjStruct *ptrPcmsObjStruct
);
Parameters
connectId is the database connection identifier.
ptrPcmsObjStruct is a pointer to a structure of type PcmsObjStruct into which
the base database options will be populated.
Return Codes
PcmsGetBaseDbOptions() returns:
PCMS_OK on success.
PCMS_ERROR on failure and sets PcmsErrorStr.
Comments
This function requires that the objType member element of the supplied PcmsObjStruct
pointer be initialized to PCMS_BASEDB_OPTIONS.
When you have populated an object structure using this function, remember to free the
memory associated with it via PcmsObjFree() when that object is no longer required.
Related Functions
PcmsObjFree()
Developer's Reference 77
Chapter 3 DTK API Functions for C/C++
Purpose
This function returns a list of those users who are valid candidates for the object, role, and
capability supplied. Currently this function supports only objects of the type PCMS_CHDOC.
Prototype
int
PcmsGetCandidates (
int connectId,
int options,
PcmsObjStruct *objPtr,
char *role,
char capability,
char *noCandidates,
char ***candidates
);
Parameters
connectId is the database connection identifier.
options is reserved for future use.
objPtr is pointer to a PcmsObjStruct that contains an object that has been
initialized with PcmsInitSpec() or PcmsInitUid().
role is the role for which to retrieve candidates, for example,
DEVELOPER.
capability is the capability that the candidate has – 'L' (Leader),'P' (Primary) or
'S' (Secondary).
noCandidates is a pointer to an integer in which to store the number of returned
values.
candidates is the address of a pointer in which the returned list of users will be
returned. The function will allocate the associated memory.
It is the responsibility of the calling application to free this pointer
when it is no longer required.
Return Codes
PcmsGetCandidates() returns:
PCMS_OK on success.
PCMS_FAIL on failure to find any data.
PCMS_ERROR on failure and sets PcmsErrorNo, PcmsErrorStr,
PcmsDbErrorNo, and PcmsDbErrorStr.
Purpose
This function will return a constant string pointer to a copy of the command that was
submitted to Dimensions CM. This is intended to allow you, from within a DTK event, to
determine what Dimensions CM command was actually run.
Prototype
const char* PcmsGetCommandLine (void);
Parameters
None.
Developer's Reference 79
Chapter 3 DTK API Functions for C/C++
Purpose
This function returns the input file descriptor for the specified connection identifier. The
purpose of this function is for an X based application to add the file descriptor as an input
for the X application using XtAddInput(). When the X application receives notification
that there is input available on the file descriptor, the application should call
PcmsCheckMessages(). This will then activate any callback functions that have been
setup by PcmsSetCallback(). Using this method of processing Dimensions CM
messages, the need for PcmsSetIdleChecker() is eliminated.
Prototype
int
PcmsGetConnectDesc (
int connectId
);
Parameters
connectId is the database connection identifier.
Return Codes
PcmsGetConnectDesc () returns:
int fd on success.
PCMS_ERROR on failure and sets PcmsErrno and PcmsErrorStr.
Comments
This function is applicable only to UNIX.
Related Functions
PcmsExecCommand(),PcmsCheckMessages(), PcmsSetCallback().
Purpose
To provide a means of determining exactly which DLLs have been loaded to support this
DTK program.
Prototype
int
PcmsGetDimensionsVersions(
_TCHAR **ppszResult
)
Parameters
Pointer to a string pointer that will return a single string of text describing the DLLs
loaded. This string should be copied and freed using the usual mechanisms for freeing
resources allocated by the DTK.
Return Codes
PcmsGetDimensionsVersions() returns NULL if the call fails.
Comments
None.
Related Functions
None.
Developer's Reference 81
Chapter 3 DTK API Functions for C/C++
Purpose
This function allows users with the above privilege to retrieve the list of inbox users (with
their roles and capabilities) for a specified request object.
Each of the structures that are returned detail the next status and phase possible for a
user on that request.
Prototype
int
PcmsGetPendingUsers (
int connectId,
int options,
int reserved,
PcmsObjStruct *objPtr,
int *noPendingUsers,
PcmsPendingUserStruct **ptrPendingUsers
);
Parameters
connectId is the database connection identifier.
options is reserved for future use.
reserved is reserved for future use.
objPtr is a pointer to a request - PcmsObjStruct that has been
initialized through PcmsInitSpec() or PcmsInitUid().
noPendingUsers is the address of an integer variable to contain the number of
connectId structures returned.
ptrPendingUsers is a pointer to a contiguous block of allocated memory that
lists the structures of type PcmsPendingUser. If no objects
are found noPendingUsers is set to zero and
ptrPendingUsers is set to (PcmsPendingUser *) zero.
Return Codes
PcmsGetPendingUsers() returns:
PCMS_OK on success.
PCMS_FAIL on failure to find any data.
PCMS_ERROR on failure and sets PcmsErrorNo, PcmsErrorStr, PcmsDbErrorNo,
and PcmsDbErrorStr.
Related Functions
PcmsInitSpec(), PcmsInitUid(), PcmsGetUserRoles().
Developer's Reference 83
Chapter 3 DTK API Functions for C/C++
Purpose
This function returns the attribute numbers that are used by a given role section object/
type uid combination. The order in at these attribute numbers are returned is in the
display order described in the process model. If you specify an object uid, then only those
roles section attributes applicable to that object are returned. If you specify a type uid,
then all the role section attributes associated with that type's lifecycle are returned.
Object and type uids are mutually exclusive. If you specify object uid (objUid), this will
cause the function to ignore any type uids that you may additionally specify.
This function currently supports items, requests, baselines, parts, and projects.
Prototype
int
PcmsGetRSAttrs (
int connectId,
int reserved,
int options,
int objUid,
int typeUid,
char *roleName,
char *userName,
int *noAttrs,
int **attrs,
char **defaultRole
);
Parameters
connectId is the database connection identifier.
reserved is reserved for future use.
options is reserved for future use.
objUid is the uid of the object that the function will use.
typeUid is the uid of the type name that the function will use.
roleName is the role name to request the attribute numbers for. If a NULL string
is used, the default role section name will be calculated and returned
through the parameter defaultRole.
userName is reserved for future use.
noAttrs is the total number of attribute numbers returned.
Return Codes
PcmsGetRSAttrs() returns:
PCMS_OK on success.
PCMS_FAIL on failure to find any data.
PCMS_ERROR on failure and sets PcmsErrorNo, PcmsErrorStr, PcmsDbErrorNo,
and PcmsDbErrorStr.
Comments
You can use the roleName parameter to filter on those attributes that apply to a certain
role section name. In addition, two special filters can also be used.
1 $ALL returns all the attributes that are associated with that
object or type uid's lifecycle.
2 $ALL_ROLE_SECTIONS returns all the attributes used by any role sections for
this object or type uid's lifecycle.
If you specify the roleName parameter as a NULL string, the function will calculate the
default role section name and populate this into the defaultRole parameter.
Related Functions
PcmsGetRSNames()
Developer's Reference 85
Chapter 3 DTK API Functions for C/C++
Purpose
This function retrieves the list of role section names corresponding to a given object uid.
This uid can be for a request, an item, a part, a baseline, a workset, or a type name. If
you specify an object uid, then only those role sections applicable to that object are
returned. If you specify a type uid, then all role sections associated with that type's
lifecycle are returned.
Prototype
int
PcmsGetRSNames (
int connectId,
int reserved,
int options,
int uid,
char **message,
int *noValues,
char **values
);
Parameters
connectId is the database connection identifier.
reserved is reserved for future use.
options is reserved for future use.
uid is the object uid or type uid that will be used.
message is the error message returned if the status is not PCMS_OK. It is the
caller's responsibility to free this allocated memory if not NULL.
noValues is the address of an integer corresponding to the number of role section
names returned.
values is a char * array of role section names returned.
Return Codes
PcmsGetRSNames() returns:
PCMS_OK on success.
Related Functions
PcmsGetRSAttrs().
Developer's Reference 87
Chapter 3 DTK API Functions for C/C++
Purpose
Obtain a value for a symbol from the symbol table.
Prototype
int
PcmsGetStringSymbolValue(
int Pcms_connection,
const _TCHAR *pszTable,
const _TCHAR *pszSymbol,
int iIndex,
_TCHAR **ppszResult)
Parameters
Pcms_connection This is the integer identifying the connection the command was
sent on.
pszTable A string that defines the tables to search. P denotes search the
persistent table, and T the temporary table. The order is
observed, and the first match returned.
pszSymbol The symbol to search for.
iIndex The occurrence of the symbol for which a value is to be
returned.
ppszResult The string value requested, or NULL if no match. This string is
a copy of that from the symbol table, and must be freed using
the usual DTK mechanism once consumed.
Return Codes
PcmsGetStringSymbolValue() returns:
PCMS_OK on success.
PCMS_FAIL on failure to locate a symbol of the specified name.
PCMS_ERROR on failure.
Comments
None.
Related Functions
PcmsGetSymbolInfo()
Purpose
To provide a means of checking for a symbol in the Structured Information Return (SIR)
symbol tables.
Prototype
int
PcmsGetSymbolInfo(
int Pcms_connection,
const _TCHAR *pszTable,
const _TCHAR *pszSymbol,
int *pcMaxOccurs,
int *pType)
Parameters
Pcms_connection This is the integer identifying the connection the command was
sent on.
pszTable A string that defines the tables to search. P denotes search the
persistent table, and T the temporary table. The order is
observed, and the first match returned.
pszSymbol The symbol to search for.
pcMaxOccurs A pointer to the integer to hold the maximum number of times
this field occurs. NULL is valid, and will result in this parameter
not being returned.
ptype A pointer to the type of this field. NULL is valid, and will result
in this parameter not being returned.
Return Codes
PcmsGetSymbolInfo() returns:
PCMS_OK on success.
PCMS_FAIL on failure to locate a symbol of the specified name.
PCMS_ERROR on failure.
Developer's Reference 89
Chapter 3 DTK API Functions for C/C++
Comments
None.
Related Functions
PcmsGetStringsSymbolValue()
Purpose
This function returns all the user-relationship sub-types for a specified product. These
relationship types include affected, information, dependent, and user-defined item-to-
item relationships.
Prototype
int
PcmsGetUserRelTypes (
int connectId,
int reserved,
int options,
char *productId,
int *noRelTypes,
PcmsRelTypeStruct **relTypes
);
Parameters
connectId is the database connection identifier.
reserved is reserved for future use.
options is reserved for future use.
productId is the product Id that the function will use.
noRelTypes is pointer to an integer variable in which to store in relTypes.
relTypes is a pointer to a contiguous block of allocated memory that lists the an
array of PcmsRelTypeStructs returned. If no objects are found as a
result of the function call, then noRelTypes is set to zero and relTypes
is set to (PcmsRelTypeStruct *) zero.
Return Codes
PcmsGetUserRelTypes() returns:
PCMS_OK on success.
PCMS_FAIL on failure to find any data.
PCMS_ERROR on failure and sets PcmsErrorNo, PcmsErrorStr, PcmsDbErrorNo,
and PcmsDbErrorStr.
Developer's Reference 91
Chapter 3 DTK API Functions for C/C++
Comments
For completeness, definitions of the standard Dimensions CM defined relationships are
also given.
Purpose
This function returns those users who are found to have certain roles for this object. The
returned structures indicate whether or not the user was delegated the role, or if the role
was inherited from the design tree. These structures will also indicate if the user's
capability is primary or secondary.
Prototype
int
PcmsGetUserRoles (
int connectId,
int reserved,
int options,
PcmsObjStruct *objPtr,
int partUid,
int noRoles,
char *roles[],
char *userName,
int *noUserRoles,
PcmsUserRoleStruct **ptrUserRoles
);
Parameters
connectId is the database connection identifier.
reserved is reserved for future use.
options is reserved for future use.
objPtr is a pointer to PcmsObjStruct that has been initialized through
PcmsInitSpec() or PcmsInitUid().
partUid is the partUid for which to obtain roles.
noRoles is the optional number of roles on which you wish to filter.
roles is an optional array of char * roles that are used to filter the data
returned.
userName is an optional username.
noUserRoles is the address of an integer variable to contain the number of
PcmsUserRole structures returned.
ptrUserRoles is a pointer to a contiguous block of allocated memory that lists the
structures of type PcmsUserRole. If no objects are found
noUserRoles is set to zero and ptrUserRoles is set to
(PcmsUserRoleStruct *) zero.
Developer's Reference 93
Chapter 3 DTK API Functions for C/C++
Return Codes
PcmsGetUserRoles() returns:
PCMS_OK on success.
PCMS_FAIL on failure to find any data.
PCMS_ERROR on failure and sets PcmsErrorNo, PcmsErrorStr,
PcmsDbErrorNo, and PcmsDbErrorStr.
Comments
If partUid is zero, then the appropriate parent part is calculated and used by the function
for the tree walk.
You can use the userName parameter to act as a filter for the user against which this
function will apply. If you specify a NULL value, then all users are retrieved.
If you know which particular roles that interest you, you can use the noRoles and roles
parameters to filter for these roles. If noRoles is zero (0), all the roles will be retrieved.
Related Functions
PcmsGetPendingUsers().
Prototype
int
PcmsGetWsetObj (
int connectId,
int options,
PcmsObjStruct **ptrPcmsObjStruct);
Parameters
connectId is the database connection identifier.
options is not currently supported (use 0).
ptrPcmsObjStruct is a dynamically allocated buffer containing a PcmsObjStruct,
whose objType field will be PCMS_WORKSET.
Return Codes
PcmsGetWsetObj() returns:
PCMS_OK on success.
PCMS_ERROR on failure and sets PcmsErrorNo, PcmsErrorStr,
PcmsDbErrorNo, and PcmsDbErrorStr.
Sample
static char*
GetWorkset(int conId)
{
static char workset_id[PCMS_L_PRODUCT_ID + PCMS_L_CD_ID + 5];
PcmsObjStruct *wsobj = (PcmsObjStruct *)0;
workset_id[0] = '\0';
switch(PcmsGetWsetObj(conId, 0, &wsobj))
{
case PCMS ERROR:
case PCMS FAIL:
return((char *)0);
default:
break;
}
(void)sprintf(workset_id,"\"%s\":\ "%s\"",
wsobj->productId,wsobj->objId);
return(workset_id);
}
Developer's Reference 95
Chapter 3 DTK API Functions for C/C++
Purpose
This function populates a PcmsObjStruct with the details on a specific object.
Prototype
int
PcmsInitSpec (
int connectId,
char *objSpec,
int objType,
PcmsObjStruct *ptrPcmsObjStruct
);
Parameters
connectId is the database connection identifier.
objSpec is the textual specification of an object, for example,
"FS:HITOMI_C.A-SRC;main#1".
objType is the type of the object that the specification refers to. You
can use PCMS_PART, PCMS_ITEM, PCMS_BASELINE,
PCMS_USER, PCMS_CHDOC, PCMS_WORKSET, or
PCMS_DIRECTORY.
ptrPcmsObjStruct is a pointer to a structure of type PcmsObjStruct in which to
store the details on the object specified by objSpec.
Return Codes
PcmsInitSpec() returns:
PCMS_OK on success.
PCMS_FAIL on not finding the object.
PCMS_ERROR on failure and sets PcmsErrorNo, PcmsErrorStr,
PcmsDbErrorNo, and PcmsDbErrorStr.
Comments
This function does not populate the attribute details within the PcmsObjStruct structure.
This has to be done separately by calling PcmsGetAttrs().
Related Functions
PcmsInitUid(), PcmsGetAttrs().
Purpose
This function populates a PcmsObjStruct with the details on a specific object.
Prototype
int
PcmsInitUid (
int connectId,
int objUid,
int objType,
PcmsObjStruct *ptrPcmsObjStruct
);
Parameters
connectId is the database connection identifier.
objUid is the integer uid of the object.
objType is the type of the object that the specification refers to. You
can use PCMS_PART, PCMS_ITEM, PCMS_BASELINE,
PCMS_USER, PCMS_CHDOC, PCMS_WORKSET, or
PCMS_DIRECTORY.
ptrPcmsObjStruct is a pointer to a structure of type PcmsObjStruct in which to
store the details on the object specified by the uid.
Return Codes
PcmsInitUid() returns:
PCMS_OK on success.
PCMS_FAIL on not finding the object.
PCMS_ERROR on failure and sets PcmsErrorNo, PcmsErrorStr,
PcmsDbErrorNo, and PcmsDbErrorStr.
Comments
This function does not populate the attribute details within the PcmsObjStruct structure.
This has to be done separately by calling PcmsGetAttrs().
Related Functions
PcmsInitSpec(), PcmsGetAttrs().
Developer's Reference 97
Chapter 3 DTK API Functions for C/C++
Purpose
This function frees an array of strings returned by PcmsAttrGetLov().
Prototype
int
PcmsLovFree (
int noValues,
char **values
);
Parameters
noValues is the number of strings in the array.
values is the array name.
Return Codes
PcmsLovFree() returns:
PCMS_OK on success.
Related Functions
PcmsAttrGetLov().
Purpose
This function frees any memory that may have been allocated internally to the
PcmsObjStruct structure. This includes any attributes or attribute definition structures.
Prototype
int
PcmsObjFree (
PcmsObjStruct *ptrPcmsObjStruct
);
Parameters
ptrPcmsObjStruct is a pointer to a structure of type PcmsObjStruct from which to
free the memory.
Return Codes
PcmsObjFree() returns:
Developer's Reference 99
Chapter 3 DTK API Functions for C/C++
Purpose
This function can be used to navigate objects and their relationships to other objects. For
example, to return predecessor revisions of an item. This function performs the inverse
navigation of PcmsObjGetRels().
Prototype
int
PcmsObjGetBackRels (
int connectId,
int fromObjUid,
int objType,
int options,
int contextUid,
int *noRels,
PcmsRelStruct **ptrPcmsRelStruct);
Parameters
connectId is the database connection identifier.
fromObjUid is the integer uid for a Dimensions CM object.
objType is the type of the Dimensions CM object. This type must be one
of PCMS_PART, PCMS_ITEM, PCMS_CHDOC, PCMS_BASELINE, or
PCMS_DIRECTORY.
options is a collection of bits set that indicates the type of objects to
return in ptrPcmsRelStruct. If this value is zero, then all
object relationship types are returned. You can restrict the list
of objects returned by specifying one or more of the types
PCMS_PART, PCMS_ITEM, PCMS_CHDOC, PCMS_BASELINE, or
PCMS_DIRECTORY.
NOTE For directories, you must specify PCMS_DIRECTORY.
contextUid can be used to limit the objects navigated to a specific
baseline_uid.
noRels is a pointer to an integer variable in which to store the number
of structures returned in ptrPcmsRelStruct.
ptrPcmsRelStruct is a pointer to a contiguous block of allocated memory that
contains a number of structures of type PcmsRelStruct. If no
objects are found then noRels is set to zero and
ptrPcmsRelStruct is set to (PcmsRelStruct *) zero.
Return Codes
PcmsObjGetBackRels() returns:
PCMS_OK on success.
PCMS_FAIL when no objects where found.
PCMS_ERROR on failure and sets PcmsErrorNo, PcmsErrorStr, PcmsDbErrorNo,
and PcmsDbErrorStr.
Comments
If PCMS_OPT_PRED is set, then contextUid will be ignored and the fromObjUid's
predecessor revision will be returned. This option is only valid when objType is set to
either PCMS_PART or PCMS_ITEM.
The following table lists combinations of object reference, object type and query options
that are valid for this function. Note that the PCMS_BASELINE option is always invalid
when obtaining the reverse relationships recorded in a baseline.
Options
CHDOC
objType
B'LINE
PART
ITEM
PART V I V V
ITEM V V V V
BASELINE I I I V
CHDOC I I V V
Related Functions
PcmsObjGetRels().
Purpose
This function can be used to navigate objects and their relationships to other objects. For
example, to return successor revisions of an item.
Prototype
int
PcmsObjGetRels (
int connectId,
int fromObjUid,
int objType,
int options,
int contextUid,
int *noRels,
PcmsRelStruct **ptrPcmsRelStruct);
Parameters
connectId is the database connection identifier.
fromObjUid is the integer uid for a Dimensions CM object.
objType is the type of the Dimensions CM object. This type must be one
of PCMS_PART, PCMS_ITEM, PCMS_CHDOC, PCMS_BASELINE, or
PCMS_DIRECTORY.
options is a collection of bits set that indicates the type of objects to
return in ptrPcmsRelStruct. If this value is zero, then all
object relationship types are returned. You can restrict the list
of objects returned by specifying one or more of the following
types PCMS_PART, PCMS_ITEM, PCMS_CHDOC, PCMS_BASELINE,
or PCMS_DIRECTORY.
NOTE For directories, you must specify PCMS_DIRECTORY.
contextUid can be used to limit the objects navigated to a specific
baseline_uid.
noRels is a pointer to an integer variable in which to store the number
of structures returned in ptrPcmsRelStruct.
ptrPcmsRelStruct is a pointer to a contiguous block of allocated memory that
contains a number of structures of type PcmsRelStruct. If no
objects are found then noRels is set to zero and
ptrPcmsRelStruct is set to (PcmsRelStruct *) zero.
Return Codes
PcmsObjGetRels() returns:
PCMS_OK on success.
PCMS_FAIL when no objects were found.
PCMS_ERROR on failure and sets PcmsErrorNo, PcmsErrorStr, PcmsDbErrorNo,
and PcmsDbErrorStr.
Comments
If fromObjUid is zero, then the top of the Dimensions CM database is used as the
starting point for the navigation.
If fromObjUid is zero and options is set to PCMS_PART, then only the
Dimensions CM products will be returned.
If PCMS_OPT_LATEST is set, then only the latest version of any related objects is
returned. This option is only valid when objType is set to either PCMS_ITEM or
PCMS_PART, and only applies to 'item to design part' relationships.
If PCMS_OPT_SUCC is set, then contextUid will be ignored and the fromObjUid's
successor revision will be returned. This option is only valid when objType is set to
either PCMS_PART or PCMS_ITEM.
The option PCMS_OPT_MERGED can be used in conjunction with PCMS_OPT_SUCC to
return objects that have resulted as a merge based on the object specified in
fromObjUid. Currently this option is only available for items.
The following table lists the combinations of object references, object types and query
options that are valid for this function. Note that the PCMS_BASELINE option is always
invalid when obtaining the relationships recorded in a baseline.
Options
BASELINE
fromObjUid objType
CHDOC
PART
ITEM
Zero Ignored V V V V
Non-zero PART V V I I
Non-zero ITEM I V I I
Non-zero BASELINE V V I V
Non-zero CHDOC V V V V
Related Functions
PcmsGetBackRels().
Purpose
This macro will return an integer indicating whether the object specified by the parameter
objPtr is a request in the secondary catalog.
Prototype
int
PcmsObjInSecondary (
PcmsObjStruct *objPtr
);
Parameters
objPtr is a pointer to a PcmsObjStruct.
Return Codes
PcmsObjInSecondary() returns:
Purpose
This function retrieves the inbox of items and/or requests for the current or a specified
user.
CAUTION! The parameter userName will turn into an object uid for a Dimensions CM
user object in the future.
Prototype
int
PcmsPendGet (
int connectId,
char *userName,
char *reserved,
int options,
int *noStructs,
PcmsPendStruct **ptrPcmsPendStructs
);
Parameters
connectId is the database connection identifier.
userName is the user to query the objects inbox for. If this parameter is
NULL then the current user's inbox is queried.
reserved is reserved for future use.
options this determines which objects are to be returned by this
function. You can specify one of the following:
Zero (0) that returns all inbox object types
PCMS_CHDOC that returns all inbox requests
PCMS_ITEM that returns all inbox items.
noStructs is a pointer to an integer variable in which to store the number
of structures of type PcmsPendStruct returned in
ptrPcmsPendStruct.
ptrPcmsPendStructs is a pointer to a contiguous block of allocated memory that
lists the objects that the function returned. If no objects are
found, then this value is set to 0 and ptrPcmsPendStructs is
set to (PcmsPendStruct*) zero.
Return Codes
PcmsPendGet() returns:
PCMS_OK on success.
PCMS_FAIL when no objects are found.
PCMS_ERROR on failure and sets PcmsErrorNo, PcmsErrorStr,
PcmsDbErrorNo, and PcmsDbErrorStr.
Comments
This function allows users with the above privilege to use the userName parameter to
query another user's item or request inbox.
Purpose
This function retrieves the users who will have a specified object in their inbox at a user-
defined status.
Prototype
int
PcmsPendWhoGet (
int connectId,
int objUid,
int objType,
char *status,
int options,
int *noStructs,
PcmsPendStruct **ptrPcmsPendStructs
);
Parameters
connectId is the database connection identifier.
objUid is the uid for a Dimensions CM object against which this
function will be run.
NOTE objUid cannot be zero (0).
objType is the type of the Dimensions CM object. This type must be
one of PCMS_PART, PCMS_BASELINE, PCMS_ITEM, or
PCMS_CHDOC.
status is the status in the lifecycle for which you wish to return the
list of users.
options is reserved for future use.
noStructs is a pointer to an integer variable in which to store the
number of structures of type PcmsPendStruct returned in
ptrPcmsPendStructs.
ptrPcmsPendStructs is a pointer to a contiguous block of allocated memory that
lists the users that the function has found. If no objects are
found noStructs is set to zero and ptrPcmsPendStructs is
set to (PcmsPendStructs *) zero.
Return Codes
PcmsPendWhoGet() returns:
PCMS_OK on success.
PCMS_FAIL when no objects were found.
PCMS_ERROR on failure and sets PcmsErrorNo, PcmsErrorStr,
PcmsDbErrorNo, and PcmsDbErrorStr.
Related Functions
PcmsPendGet().
Comments
This function allows users with the above privilege to use the userName parameter to
query another user's item or request inbox.
Purpose
This function populates a given PcmsObjStruct with attributes, attribute definitions and
values. The values are copied from an existing object that you supply, and are merged
with the attributes generic to a specified type uid.
Prototype
int
PcmsPopulate (
int connectId,
int options,
int objType,
int typeUid,
PcmsObjStruct *primeObj,
PcmsObjStruct **outObject
);
Parameters
connectId is the database connection identifier.
options is reserved for future use.
objType is the type of the outObject, for example, PCMS_ITEM.
typeUid is the typeUid for the outObject.
primeObj is a pointer to another object to prime the values of the outObject
from.
outObject is the address of a pointer to a PcmsObjStruct that will be allocated
and populated by this function.
Return Codes
PcmsPopulate() returns:
PCMS_OK on success.
PCMS_FAIL on failure to find any data.
PCMS_ERROR on failure and sets PcmsErrorNo, PcmsErrorStr, PcmsDbErrorNo,
and PcmsDbErrorStr.
Purpose
This function finds a list of Dimensions CM objects from the fields specified in the
PcmsObjStruct. If values are present in the fields of the ptrPcmsObjStruct, they will
be used to further refine the query. The only field in ptrPcmsObjStruct that must be
filled in is objType. This means that the returned object uids will all be of the same type.
Prototype
int
PcmsQuery (
int connectId,
PcmsObjStruct *ptrPcmsObjStruct,
int options,
int *noObjs,
int **ptrObjUids
);
Parameters
connectId is the database connection identifier.
PtrPcmsObjStruct is a pointer to a PcmsObjStruct that will be used to further
refine the query. The objType field in the PcmsObjStruct must
be one of PCMS_ITEM, PCMS_PART, PCMS_CHDOC, PCMS_USER,
PCMS_BASELINE, or PCMS_WORKSET.
options is a collection of bits that is used to change the default behavior
of this function.
noObjs is a pointer to an integer variable in which to store the number of
integer uids returned in ptrObjUids.
ptrObjUids is a pointer to a contiguous block of allocated memory that lists
the uids that the query returned. If no objects are found as a
result of the function call, then noObjs is set to zero and
ptrObjUids is set to (int *) zero.
Return Codes
PcmsQuery() returns:
PCMS_OK on success.
PCMS_FAIL when no objects were found.
PCMS_ERROR on failure and sets PcmsErrorNo, PcmsErrorStr,
PcmsDbErrorNo, and PcmsDbErrorStr.
Sample
/*
*-------------------------------------------------------------
* FUNCTION SPECIFICATION
* Name:
* CountPcmsItems
* Description:
* Count items in Dimensions
* Parameters:
* char *itemId
* Return:
* no of items
* Notes:
*-------------------------------------------------------------
*/
static int
CountPcmsItems(int conId, char *itemId)
{
/*
* Query the database for items with the itemId passed in.
*/
int *uids = 0;
int noUids = 0;
int noAttrs = 2;
int i = 0;
int xx = PCMS_OK;
PcmsObjStruct obj = { 0 };
#define SET_ATTR(_attr,_value,p) \
{\
register int x = p;\
x--;\
obj.attrs[x].attr = _attr;\
PcmsSvaSetVal(obj.attrs[x].value,_value,0);\
p++;\
}
obj.objType = PCMS_ITEM;
obj.noAttrs = noAttrs;
obj.attrs = 0;
obj.attrs =
(PcmsObjAttrStruct *)
PcmsEvntCalloc(sizeof(PcmsObjAttrStruct)
*obj.noAttrs);
(void)strcpy(obj.objId,itemId);
i=1;
/* Search for items with TXT as format and of SPEC_UID 121 */
SET_ATTR(PCMS_ATTR_FORMAT,"TXT",i);
SET_ATTR(PCMS_ATTR_ITEM_SPEC_UID,"121",i);
/* Run the query */
if ((xx = PcmsQuery(conId,&obj,0,&noUids,&uids))==PCMS_OK)
{
/* Free memory */
if (uids && noUids > 0)
PcmsEvntFree((int *)uids);
}
else
{
(void)fprintf(stdout,"\nNo objects found - %s",
(xx == PCMS_ERROR) ? "Error" : "Fail");
if (xx == PCMS_ERROR)
(void)fprintf(stdout,PcmsErrorStr);
}
/* Free memory */
(void)PcmsObjFree(&obj);
return ((xx == PCMS_ERROR) ? xx : noUids);
}
Comments
By manipulating the *attrs pointer and associated noAttrs members of the
PcmsObjStruct structure it is possible to use system and user attributes as additional
components within the query. If you wish to make use of this functionality, then you only
need to specify values in the attr and value members of the PcmsObjAttrStruct
structure. All other member fields are ignored.
Both the members of the PcmsObjStruct structure and the value field member of the
PcmsObjAttrStruct structure support the use of wildcard characters. There are two
different kinds of wildcard that you can use:
'%' (per cent) that allows pattern matching on many characters
'_' (underscore) that allows pattern matching against one character.
If the objType field member of the PcmsObjStruct is set to PCMS_CHDOC, you can use
the options parameter (PCMS_OPT_SECONDARY_CATALOGUE) to make the function query
against the secondary request catalog instead of the primary catalog. By default, the
function will always query the primary request catalog.
If the objType field member of the PcmsObjStruct is set to PCMS_ITEM, you can use the
options parameter (PCMS_OPT_LATEST) to return only the latest revisions of the items
that match the query.
If you use attribute filters or the options parameter to further restrict the list of uids
returned, the speed of the query will be affected.
Object Attribute
PCMS_PART PCMS_ATTR_PARTNO
PCMS_ATTR_LOCALNO
PCMS_ITEM PCMS_ATTR_FORMAT
PCMS_ATTR_FILENAME PCMS_ATTR_ITEM_SPEC_UID
PCMS_ATTR_LIB_FILENAME PCMS_ATTR_COMPRESSED
PCMS_ATTR_SENDER_ID
PCMS_ATTR_CREATE_DATE
PCMS_ATTR_ORIGINATOR
PCMS_ATTR_PHASE
PCMS_ATTR_LIFECYCLE
PCMS_BASELINE PCMS_ATTR_TEMPLATE
PCMS_ATTR_BASELINE_TYPE
Object Attribute
PCMS_CHDOC PCMS_ATTR_CREATE_DATE
PCMS_ATTR_ORIGINATOR
PCMS_ATTR_PHASE
PCMS_ATTR_SUPER_TYPE PCMS_ATTR_UPDATE_DATE
PCMS_ATTR_LIFECYCLE
PCMS_USER PCMS_ATTR_GROUP PCMS_ATTR_FULL_USERNAME
PCMS_ATTR_PHONE
PCMS_ATTR_DEPT
PCMS_ATTR_SITE
PCMS_ATTR_BASEDB
PCMS_ATTR_EMAIL
PCMS_ATTR_PRIVILEGE
PCMS_WORKSET PCMS_ATTR_TRUNK (PCMS_ATTR_TRUNC) PCMS_ATTR_ENFORCE_REV
If you use a multi-valued attribute as a filter, only the first element of the attribute list will
be used. The other elements will be ignored.
Related Functions
PcmsFullQuery().
Purpose
This function sends a command to Dimensions CM and returns without waiting for it to
complete. See the Command-Line Reference for information on legal syntax for command
mode applications.
Prototype
int
PcmsSendCommand (
int connectId,
char *command,
int *cmdId
);
Parameters
connectId is the database connection identifier.
command is the command to execute.
cmdId is a unique command identifier that is returned to the user.
Return Codes
PcmsSendCommand () returns:
PCMS_OK on success.
PCMS_ERROR on failure and sets PcmsErrorNo and PcmsErrorStr.
Comments
You must call the function PcmsCheckMessages() to check whether the results of
commands submitted using PcmsSendCommand() are available. If results are available,
your callback function will be invoked (see PcmsSetCallback on page 118).
NOTE If your application does not call PcmsCheckMessages() periodically, commands
sent with PcmsSendCommand() may not be executed by Dimensions CM.
The commands EXIT and exit will result in an error being returned. A null string will also
result in an error. Use PcmsDisconnect() to terminate the connection with the
Dimensions CM Server.
Related Functions
PcmsExecCommand,PcmsSetCallback(), PcmsCheckMessages().
Purpose
This function uses the attribute details defined in a PcmsObjStruct and sets these
attributes on the appropriate Dimensions CM object.
By using this function you can populate a PcmsObjStruct with the details on an object,
such as an item, manipulate the noAttrs and *attrs member fields and then apply
these attributes to the Dimensions CM object.
Prototype
int
PcmsSetAttrs (
int connectId,
PcmsObjStruct *ptrPcmsObjStruct
);
Parameters
connectId is the database connection identifier.
ptrPcmsObjStruct is a pointer to a structure of type PcmsObjStruct that has
been initialized through PcmsInitUid() or PcmsInitSpec()
and into which the new attributes have been defined. Each
element of the array pointed to by the *attrs field must have
the attr and value member fields set.
Return Codes
PcmsSetAttrs() returns:
PCMS_OK on success.
PCMS_FAIL on not setting the attributes successfully. PcmsErrorStr will
contain the message returned from Dimensions CM.
PCMS_ERROR on failure and sets PcmsErrorNo, PcmsErrorStr,
PcmsDbErrorNo, and PcmsDbErrorStr.
Comments
PcmsSetAttrs() can set user-defined attributes on parts, items, and requests, but
non-visible attributes (those that are not displayed in client interfaces) can be set only
on requests.
The *attrs pointer in the PcmsObjStruct must only be populated with attributes
that you wish to add or modify.
This function can be used only to setup user-defined attributes on objects of type
PCMS_ITEM, PCMS_CHDOC, and PCMS_PART.
This function enforces the same checks used when setting attribute values as
performed by any other interface.
This function is intended for applications using the Client Architecture Model. It is not
supported when called from within DTK events. If you wish to change attributes from
within an event, then please use the Validate event as described in Chapter 5,
"Dimensions CM Events Callout Interface" on page 145.
Related Functions
PcmsInitUid(), PcmsInitSpec(), PcmsGetAttrs().
Purpose
This function sets up a callback function for the specified connectId. The previous callback
function and associated clientData are returned in the ptrOldPcmsCallback pointer.
The callback function is used to register the results of Dimensions CM commands
submitted asynchronously by the function PcmsSendCommand(). The callback function will
be invoked when a user calls PcmsCheckMessages().
Prototype
int
PcmsSetCallback (
int connectId,
PcmsCallbackStruct *ptrNewPcmsCallback,
PcmsCallbackStruct *ptrOldPcmsCallback
);
typedef struct
{
PcmsCallbackProc callback;
void *clientData;
} PcmsCallbackStruct;
Parameters
connectId is the database connection identifier.
ptrNewPcmsCallback is a pointer to a structure of type PcmsCallbackStruct. In
this structure the member field callback is a pointer to the
callback function. This function must have the following
prototype.
void sampleCallbackProc(
int connectId,
void *clientData,
int commandStatus,
int commandId,
char *commandStr,
char *callData,
...
)
The clientData field of the PcmsCallbackStruct will be
passed as one of the parameters to the callback function.
Specifying a NULL
Return Codes
PcmsSetCallback () returns:
PCMS_OK on success.
PCMS_ERROR on failure and sets PcmsErrorNo and PcmsErrorStr.
Comments
The parameters passed to the callback function are:
Related Functions
PcmsExecCommand(),PcmsSendCommand(), PcmsCheckMessages(),
PcmsSetNoErrorCallback().
Purpose
This function sets up a callback function to be executed when the RDBMS is no longer
available. The callback function will be invoked when an application invokes a DTK
function and the DTK detects that the Dimensions CM repository is no longer available.
For example, this error may occur if the Dimensions CM server has been powered down.
Prototype
int
PcmsSetDbErrorCallback (
int connectId,
PcmsCallbackStruct *ptrPcmsCallback
);
typedef struct
{
PcmsCallbackProc callback;
void *clientData;
} PcmsCallbackStruct;
Parameters
connectId is the database connection identifier.
ptrPcmsCallback is a pointer to a structure of type PcmsCallbackStruct. In this
structure the member field callback is a pointer to the callback
function. This function must have the following prototype.
void sampleCallbackProc(
intconnectId,
void*clientData,
intcommandStatus,
intcommandId,
char*commandStr,
char*callData,
...
)
The clientData field of the PcmsCallbackStruct will be passed
as one of the parameters to the callback function.
Return Codes
PcmsSetDbErrorCallback () returns:
PCMS_OK on success.
PCMS_ERROR on failure and sets PcmsErrorNo and PcmsErrorStr.
Comments
The parameters passed to the callback function are:
Related Functions
PcmsSetCallback().
Purpose
This function changes the default directory of the Dimensions CM process being managed
by your application.
Prototype
int
PcmsSetDirectory (
int connectId,
char *new_directory
);
Parameters
connectId is the database connection identifier.
new_directory is the full specification of the default directory the Dimensions CM
process is to use.
Return Codes
PcmsSetDirectory() returns:
PCMS_OK on success.
PCMS_ERROR on failure and sets PcmsErrorNo and PcmsErrorStr.
Comments
The function does not change directory until all commands in the PcmsSendCommand()
queue (if any) are executed.
Related Functions
PcmsExecCommand(),PcmsSendCommand().
Purpose
This function installs an application function to be called before any Dimensions CM DTK
functions are blocked on a read. PcmsSetIdleChecker() will be called before making a
connection to a database, and may be useful in X applications to process events from the
X event queue while the Dimensions CM DTK is waiting for input.
Prototype
int
PcmsSetIdleChecker(
int (*userIdleChecker )(int fd, int flag)
);
Parameters
userIdleChecker is the address of the application function that will be called.
Return Codes
PcmsSetIdleChecker() returns:
PCMS_OK on success.
PCMS_ERROR on failure and sets PcmsErrorNo, PcmsErrorStr,
PcmsDbErrorNo, and PcmsDbErrorStr.
Comments
The prototype of the idle checker function is:
int idleCheckerFunction(int fd, int flag)
where
If the flag is set to PCMS_MSG_WAIT, the function should only return when data is
available to be read from the file descriptor, in which case the return value will be
PCMS_OK. If the flag is set to PCMS_MSG_NOWAIT, the function will return immediately with
a return value of PCMS_OK if data is available; and a return value of PCMS_FAIL if no data
is available.
For X applications, XtAddInput() can be used to set a callback procedure when input is
pending on fd.
Purpose
This function allows the user to reset the current project in which this Dimensions CM
session is active.
Prototype
int
PcmsSetWsetObj (
int connectId,
int options,
PcmsObjStruct *ptrPcmsObjStruct,
char *dir);
Parameters
connectId is the database connection identifier.
options is not currently supported (use 0).
ptrPcmsObjStruct is a pointer to a structure of type PcmsObjStruct that is
populated by the user to indicate what project to change to.
dir is the project directory to use.
Return Codes
PcmsSetWsetObj() returns:
PCMS_OK on success.
PCMS_ERROR on failure and sets PcmsErrorNo, PcmsErrorStr,
PcmsDbErrorNo, and PcmsDbErrorStr.
Purpose
This function allows users to write request attachments to disk. It will process the array of
attachments, writing the attachments out to a location specified by the "userFile"
members.
The "userFile" member will be user-allocated memory, and the user will be responsible
for freeing it.
Prototype
int PcmsWriteAttachments (
int conId,
PcmsObjStruct *objPtr,
int archived,
int noAttachs,
PcmsChdAttachmentStruct **ptrAttachment
)
Parameters
connectId is the database connection identifier.
object is the request - PcmsObjStruct that has been initialized
through PcmsInitSpec() or PcmsInitUid().
archived is the integer used to indicate if the specified request object can
be found in the main catalog or the secondary catalog. 0
indicates the request can be found in the main catalog, 1
indicates the request can be found in the secondary catalog.
noAttachs is the integer containing the number of attachments structures
supplied.
ptrAttachment is a pointer to a contiguous block of allocated memory that lists
the attachment structures.
Return Codes
PcmsSetWsetObj() returns:
PCMS_OK on success.
PCMS_FAIL on failure or when no attachments are found.
Attribute Macros
Defined in the file pcms_api.h are a set of macros that have been provided to help you in
writing your application. These macros are public but the structures that they use may
change in the future and should not be used directly.
NOTE This macro works only on PcmsObjStructs that have not had attributes
already setup.
valuePtr the value structure being initialized and set (for a PcmsObjStruct
object objPtr and attribute number n, valuePtr is
objPtr.attrs[n].value).
string the value itself expressed as a char * string.
reserved is an integer field reserved for future use (use 0).
valuePtr the value structure being initialized and set (for a PcmsObjStruct
object objPtr and attribute number n, valuePtr is
objPtr.attrs[n].value).
string the value itself expressed as a char * string.
Reserved is an integer field reserved for future use (use 0).
PcmsSvaGetVal (valuePtr)
This macro returns a char * corresponding to the string value of this attribute.
The parameter is:
valuePtr the value structure pointer being queried (for an object objPtr
and attribute number n, valuePtr is objPtr.attrs[n].value).
valueSetPtr the value set being added to (for an object objPtr and attribute
number n the valueSetPtr is objPtr.attrs[n].value).
index the index into the list. This index is incremented within the macro.
For the first value in the value-set, this index is zero.
string the value itself as a char * string.
reserved is an integer field reserved for future use (use 0).
PcmsMvaNumVals(valueSetPtr)
This macro returns an integer value corresponding to the number of values currently
in the value-set.
The parameter is:
PcmsMvaFree (valueSetPtr)
This macro frees a complete PcmsMva, that is, frees the whole list.
The parameters is:
NOTE It is useful to note that the SVA macros are only a convenience. It is possible
to access all attribute value structures with PcmsMvaNumVals() and
PcmsMvaGetVal(). For single value attributes PcmsMvaNumVals() will return 1.
Introduction 130
Building Client Applications 130
Sample Code Fragment 131
PcmsClntApiConnect - Connect to a Dimensions CM Database 132
PcmsClntApiDisconnect - Disconnect from a Dimensions CM Database 133
PcmsClntApiExecCommand - Execute a Dimensions CM Command 134
PcmsClntApiFree – Free Memory 135
PcmsClntApiGetLastError - Get the Last Dimensions CM Message 136
PcmsClntApiGetLastErrorEx - Get the Last Dimensions CM Message (Dynamic Buffer)
137
PcmsClntApiModeBinary - Set File Transfer Mode to Binary 138
PcmsClntApiModeText - Set File Transfer Mode to ASCII 139
PcmsClntApiSilentConnect - Connect Silently to a Dimensions CM Database 140
Additional Supported DTK Functions 142
Introduction
This chapter describes a set of functions that have been specifically written for Windows
client machines that have had only the Serena® Dimensions® CM Windows clients
installed. These functions give you access to the full functionality of the DTK but are
specifically written for Windows clients.
Before reading this chapter, ensure that you have familiarized yourself with the contents
of Chapter 2, "Writing Dimensions CM DTK Applications" because it contains important
information relating to data structures, return codes, and manifest constants that are
referenced in this chapter.
Any source file that references the functions or constants must include clientapi.h.
Purpose
This function provides you with a login window allowing you to connect to a
Dimensions CM database. This function will return a connectId (integer) that represents
your database connection.
Prototype
int
PcmsClntApiConnect
(
HWND parent=NULL
);
Parameters
HWND parent is the parent window for the login dialog.
Return Codes
PcmsClntApiConnect() returns:
Related Functions
PcmsClntApiSilentConnect()
Purpose
This function disconnects from the Dimensions CM database as specified by the conId.
The connectId must be a valid connectId returned by PcmsClntApiConnect() or
PcmsClntApiSilentConnect().
Prototype
int
PcmsClntApiDisconnect
(
int connectId
);
Parameters
connectId is the database connection identifier.
Return Codes
PcmsClntApiDisconnect() returns:
PCMS_OK on success.
PCMS_ERROR on error.
PCMS_FAIL on failure.
Related Functions
PcmsClntApiConnect(), PcmsClntApiSilentConnect()
Purpose
This function sends a command to the Dimensions CM server specified by connectId.
Prototype
int
PcmsClntApiExecCommand
(
int conId,
char *command
);
Parameters
connectId is the database connection identifier.
command is a pointer to a user allocated character array that is populated
with the command to be executed.
Return Codes
PcmsClntApiExecCommand() returns:
PCMS_OK on success.
PCMS_ERROR on error.
PCMS_FAIL on failure.
Purpose
This function is a wrapper to the C function free(). It must be used to free memory
allocated by PcmsClnt API DTK functions, such as PcmsClntApiGetLastErrorEx(). The
reason for this is that on some platforms, like Windows, the memory that is allocated
within a shared library must be freed by the same shared library. If this is not done, then
memory errors begin to occur.
Prototype
void PcmsClntApiFree (void *buffer);
Parameters
buffer is a pointer to the memory block that will be freed.
Purpose
This function allows you to access the output from the last Dimensions CM command that
was run on the server through PcmsClntApiExecCommand().
Prototype
int
PcmsClntApiGetLastError
(
int connectId,
char *errorBuffer,
int maxLength
);
Parameters
connectId is the database connection identifier. If the error prevented the
establishment of a connection, pass a connectID value of -1.
errorBuffer is a pointer to a user allocated character array that is populated
with the text of the server message.
maxLength is the maximum length of the server message to be displayed.
Return Codes
PcmsClntApiGetLastError() returns:
PCMS_OK on success.
PCMS_ERROR on error.
PCMS_FAIL on failure.
Related Function
PcmsClntApiGetLastErrorEx()
Purpose
This function allows you to access the output from the last Dimensions CM command that
was run on the server through PcmsClntApiExecCommand(). The functionality of this
command is the same as for PcmsClntApiGetLastError() except that the buffer size is
dynamically allocated.
Prototype
int
PcmsClntApiGetLastErrorEx
(
int connectId,
char **errorBuffer
);
Parameters
connectId is the database connection identifier. If the error prevented the
establishment of a connection, pass a connectID value of -1.
errorBuffer is a pointer to a contiguous block of allocated memory that is
populated with the message text.
Return Codes
PcmsClntApiGetLastErrorEx() returns:
PCMS_OK on success.
PCMS_ERROR on error.
PCMS_FAIL on failure.
Related Function
PcmsClntApiGetLastError()
Purpose
This function sets the file transfer format to binary for any subsequent item commands
that are issued.
Prototype
void
PcmsClntApiModeBinary
(
int connectId
);
Parameters
connectId is the database connection identifier.
Return Codes
None.
Comments
You must use this command if you are going to perform operations that require file
transfer from the client to the server (or vice versa) to occur in binary mode. An example
of this might be getting a binary item into your PC. When you perform any file transfer
operations, such as check in (RI), Dimensions CM will not validate the format of the file
being transferred.
Purpose
This function sets the file transfer format to ASCII for any subsequent item commands
that are issued.
Prototype
void
PcmsClntApiModeText
(
int connectId
);
Parameters
connectId is the database connection identifier.
Return Codes
None.
Comments
You must use this command if you are going to perform operations that require file
transfer from the client to the server (or vice versa) to occur in ASCII mode. An example
of this might be getting an ASCII item into your PC. When you perform any file transfer
operations, such as check in (RI), Dimensions CM will not validate the format of the file
being transferred.
Purpose
This function provides you with a connection to a Dimensions CM database as specified by
your input parameters. This function will return a conId that represents your connection
to the Dimensions CM server.
Prototype
int
PcmsClntApiSilentConnect
(
char *user,
char *password,
char *host,
char *pcms_install,
char *db_name,
char *db_pword,
char *db_node
);
Parameters
user is your operating system login name.
password is your operating system password.
host is the Dimensions CM server node name that you wish to connect
to.
pcms_install is the Dimensions CM server installation directory, for example,
/opt/serena/dimensions/10.1/cm. If a null entry is submitted,
this parameter is ignored.
db_name is the name of the Dimensions CM database that you wish to
connect to, for example, intermediate.
db_pword is the password of the database. If a null entry is submitted, this
parameter is ignored.
db_node is the RDBMS service name assigned to the node where the RDBMS
database is located.
Return Codes
PcmsClntApiSilentConnect() returns:
Related Functions
PcmsClntApiConnect()
PcmsAttrDefInit() PcmsGetRSNamest() *
PcmsAttrGetLov() * PcmsGetUserRelTypes() *
PcmsAttrValidate() * PcmsGetUserRoles() *
PcmsCntrlPlanGet() * PcmsGetWsetObj() *
PcmsEvntCalloc() PcmsInitSpec()
PcmsEvntFree() PcmsInitUid()
PcmsEvntMalloc() PcmsLovFree()
PcmsEvntRealloc() PcmsObjFree()
PcmsFullQuery() * PcmsObjGetBackRels() *
PcmsGetAttrDefNum() * PcmsObjGetRels() *
PcmsGetAttrs() PcmsPendGet() *
PcmsGetCandidates() * PcmsPendWhoGet()
PcmsGetPendingUsers() * PcmsPopulate() *
PcmsGetRSAttrs() * PcmsQuery() *
NOTE Functions marked with an asterisk (*) require that the following file to be installed
on each client: %DM_ROOT%\msg\pcms_api_sql_uk.msb. This can be accomplished by a
default client installation or by copying the file from the Dimensions CM server, where it
resides in the same directory.
Description 146
Shared Libraries 146
MBCS Versus UTF-8 Support 146
Large File Support 147
Public Function Call 147
Event Callout Interface 148
Determining the Event You Want 151
First and Second Event Calls 152
Event Call Summary 153
Writing a DTK Callout Event 153
DTK Event Internals 156
Changing System-Attributes on Validate Events 157
Changing User-Attributes on Validate Events 158
Recommendations on How to Change Attribute Values 158
Calling DTK Functions Within Events 159
Using the ptrEventInfo in Events 160
Recompiling With New Versions of Dimensions CM 161
Event Examples 161
Events - A Final Word and a Warning 161
Description
This chapter outlines the functionality, design and implementation of applications using
the Serena® Dimensions® CM Event Callout Interface. Before reading this chapter ensure
that you familiarize yourself with the concept of shared libraries because it is through this
mechanism that this event interface is implemented.
Shared Libraries
The Dimensions CM Event Callout Interface is provided by giving you access to a public
function call that is invoked when certain Dimensions CM commands are run. This
function is called userSuppliedFunction() and is resolved in a shared library called
libpcmsu. On a default Dimensions CM installation a stub version of this library is
provided. If you wish to implement your own event callout, you will need to build your
own shared library and use this in place of the stub.
For more information on how to build shared libraries please refer to your system
documentation or for guidelines refer to the examples provided in:
UNIX: $DM_ROOT/pcms_api/examples/
Windows: %DM_ROOT%\pcms_api\examples\
You can determine the nature of the database you are connecting to by selecting from the
DM_CHARACTERSET view in the PCMS_SYS schema. If this view returns null or a value
other than AL32UTF8, then you are connecting to an MBCS database.
The example DTK events provided generate UTF-8 compatible shared libraries by default,
that is, the libraries ending end in 'u'. To change this behavior, use the MBCS_NEEDED=y
make flag when you run the Dimensions CM dm_make command. This will generate a
shared library with 'm' at the end of the library name.
Copy the appropriate library you require to your usual installation directory:
If your database has a UTF-8 character set, search the installation directory to locate
the library, and remove the 'u' in the library name.
For any other kind of database character set, you must not rename the library name,
that is, you must leave it with the 'm' extension.
If you use an MBCS shared library against a UTF-8 database or vice versa, the results will
be unpredictable as the server will probably experience memory issues.
int userSuppliedFunction(
PcmsEventStruct *ptrPcmsEventStruct,
PcmsObjStruct *ptrObj,
PcmsObjStruct *ptrUser,
char **ptrErrorMessage,
int *noEventInfo,
void **ptrEventInfo);
Each of the event calls allows you to perform a number of operations on the
Dimensions CM object on which the event has been called.
You can access the type of event being fired by examining the ptrPcmsEventStruct as
described on page 151.
Validate Events
Validate events are called prior to any Dimensions CM validation being run on the data
supplied. Typically, you can use validation events to inspect information (such as the
object details, default, and user attributes) and then change this information. You could,
for example, use this event to implement your own automatic item identity generator or
perform extra validation on user-defined date attributes. Once this event has been fired
Dimensions CM will then proceed with its normal validation checks. This event is indicated
by the use of the constant PCMS_EVENT_VALIDATE_OP.
NOTE Validate events are fired only when user or system attributes change as a result
of a command. This means that events captured on the validate event will be Type
PCMS_EVENT_UPDATE events
Pre-Events
Pre-events are called prior to the Dimensions CM command being executed. You can use
this event to stop the execution of this command by returning the failure status
PCMS_FAIL. If you populate ptrErrorMessage, then this error string will be displayed
through whatever interface invoked the command. Typically, you can use this event to
perform any specific validation before deciding to let the command proceed. This event is
indicated by the use of the constant PCMS_EVENT_PRE_OP.
Post-Events
Post-events are called after the Dimensions CM command has been run. Typically you can
use this event to perform any 'clean up' or post-command logging to other applications.
This event is indicated by the use of the constant PCMS_EVENT_POST_OP.
Event Types
In addition to the event hierarchy described in the previous sub-sections, each event fired
also has an event type that relates to the type of Dimensions CM command being run.
These event types are:
* These events are for information purposes only (PCMS_EVENT_PRE_OP) or for aborting
the operation (PCMS_EVENT_POST_OP)—you cannot manipulate the objects passed into
them (PCMS_EVENT_VALIDATE_OP)
While a single Dimensions CM command, such as 'getting an item', can fire a single event
type (PCMS_EVENT_FETCH) it is also possible for a command to generate multiple different
events. Consider, for example, the following command:
UI "FS:TEST.A-SRC,1" /REV=2.1/ATTRIBUTE=(COMPLEXITY="Delta7")
This command performs a check out, check in, and an update of attribute values. Thus, if
you ran the command as described previously, the following events would be fired.
The table below describes the commands that fire events and the objects types they
involve.
BASELINE
REQUEST
PROJECT
RELEASE
PART
ITEM
EventId
PCMS_EVENT_
ACTION SPV, UP AI, SI AC AWS
ADD AIWS
CANCEL (N/A) CIU
CREATE CP, CPV CI CC CWSD, CBL, REL
DWS, CMB,
MWS CRB
DELETE DPV DI DWSD, DLB DREL
RWS
DEMOTE DMI DMRQ DMBL
DLGC (N/A) DLGC
DLGI DLGI
EXTRACT UP EI, UI
FETCH FI BC
LOCK LCK LCK
BASELINE
REQUEST
PROJECT
RELEASE
PART
ITEM
EventId
PCMS_EVENT_
MAIL CP, DPV, AI, AC,CC, AWS, ABL,
SPV, UP, AIWS, DLGC, DWS, CBL,
UPA, CPV CI, DI, RBCD, LCK, CMB,
DLGI, RCCD, RWS, CBL, DBL
DPI, EI, RICD, ULCK,
LCK, RI, RWCD, UWA
RIWS, UC,
UI, UIA, XBCD,
ULCK XCCD,
XICD,
XWCD
PROMOTE PMI PMRQ PMBL
RELATE RIP RII RCCD,
RICD,
RPCD,
RWCD
REMOVE RIWS MWSD
RENAME SWF
RETURN UP RI, UI
UNLOCK ULCK ULCK
UNRELATE XIP XII XCCD,
XICD,
XPCD,
XWCD
UPDATE UPA, UP, CI, EI, CC, UC UWA UBLA
CP, CPV RI, UI,
UIA
By examining the following fields of the PcmsEventStruct you can trap the event you
specifically require.
The first call to an event populates only the sparse details on the Dimensions CM object
and the PcmsEventStruct to allow you to determine if you are interested in this event.
The specific details provided in the PcmsObjStruct depend on what command is called,
on what object, and under what circumstances—as shown in the next two tables.
If you select the first call, then only the ptrPcmsEventStruct will be fully populated. The
ptrObj will only have the object-specification fields and uid filled in. If as a result of
examining these partial details, you decide that you really want this event, then returning
the status PCMS_OK will generate a second event call. If you are not interested in this
event, then return PCMS_FAIL and the second call to this event will not be fired.
The second event call can be regarded as the 'real' event call. This has all the data
structures filled in and allows you to access all the attribute information for the object. It
is on this call that your event should perform its operation.
Step Command
1 Read Dimensions CM Command.
2 FIRST CALL VALIDATE EVENT and check that VALIDATE EVENT is required.
3 If VALIDATE EVENT is required, then call VALIDATE EVENT again.
4 If VALIDATE EVENT not required, then END.
5 Evaluate User Data and Execute the Dimensions CM Command.
6 FIRST CALL PRE-EVENT and check that PRE-EVENT is required.
7 If PRE-EVENT is required, then call PRE-EVENT again with fully detailed data.
8 If PRE-EVENT not required, then END.
9 COMMIT Dimensions CM Command to database.
10 FIRST CALL POST-EVENT and check that POST-EVENT is required.
11 If POST-EVENT is required, call POST-EVENT again with fully detailed data.
Steps 3, 7, and 11 occur when the real VALIDATE, PRE and POST EVENTS are done.
Once you know the list of commands and type of events that you are going to trap, you
need to consider where in the callout hierarchy this trapping will occur. The basic rules are
to trap:
The validate event if you wish to change any information.
The pre-event if you wish to be able to stop the operation.
The post-event if you wish to perform an action after the Dimensions CM operation
has committed data to the database and freed all the locks on that object.
In the first event call you need to interrogate the ptrPcmsEventStruct to determine
whether or not to trap this event and, if so, return PCMS_OK, else return PCMS_FAIL.
In the second event call you need to place the code to support your event logic and return
the appropriate status.
• If you are removing an attribute definition, then you will need to resize the
attrsChanged pointer to remove this attribute and decrease the
noAttrsChanged index by 1.
The PcmsObjStruct – pointer ptrObj
This pointer contains all the details on the object that the event is currently
processing. On a first call to the event this object contains only minimal data. On the
second call to the event this object is fully populated.
When you create a new object, such as an item or a part, a validate-event is fired
during which you can manipulate the contents of this pointer to change the object's
details. You are able to change entries in the objId, variant, and revision fields.
Using this mechanism you could write an event that changes item Ids to suit your
own automatic object identity generator.
The PcmsObjStruct – pointer ptrUser
This pointer contains all the details on the user currently running the event. This
pointer is populated only on the second call and is 'read only'.
The error pointer – ptrErrorMessage
This pointer allows you to set up an error message that will be printed by
Dimensions CM when a validate-event or pre-event returns a status other than
PCMS_OK. This allows you to print your own custom error messages when an event
fails.
The noEventInfo and ptrEventInfo pointers
These pointers operate together. Their usage is described on page 160.
LIB_FILENAME
DIRPATH
USER_FILENAME
PART PARTNO
LOCALNO
RELEASE DIRPATH
a.Check out.
b.Check in.
If you specify any other values for system-attributes, these will be ignored.
The above-mentioned attributes can be changed only when a new object is created or an
item is checked out at a new revision.
PtrPcmsEventStruct->attrsChanged[0].attr=<ATTR_NO>
PcmsSvaSetValue(ptrPcmsEventStruct->attrChanged[0].value,
"text String",0);
ptrPcmsEventStruct->attrChanged[0].attrDef =
(PcmsObjAttrDefStruct *)0;
If the pointer currently has attributes setup, then you need to check if the attribute
you want to change is currently in that pointer. You can do this by looping through the
attrChanged[x].attr(s) and looking for a match to your attribute number. Once
you have found a match then use PcmsSvaSetVal() or PcmsMvaReSetVal()to reset
the value. If you are resetting the MVA values for an attribute, then remember to free
the attribute value set first through PcmsMvaFree().
If the pointer currently has attributes setup, but you cannot find a match using the
search method indicated above then you need to re-allocate memory to the
attrsChanged pointer to add a new PcmsObjAttrStruct. Using this newly allocated
structure you can set the attribute values as described above and increment the
noAttrsChanged variable by 1.
If you need to access the information in these structures, then your event needs to do the
following:
For RELATE and UNRELATE event types, typecast the ptrEventInfo through:
PcmsChdAttachmentStruct *ptrAttachs =
(PcmsChdAttachmentStruct*)*ptrEventInfo;
For other events, typecast the pointer through:
Once you have typecast the pointer, you can use the ptrEventInfo pointer to access the
information. For example, in a MAIL event you might do the following:
{
PcmsUserRoleStruct *ptrUser =
(PcmsUserRoleStruct*)*ptrEventInfo;
int noUses = *noEventInfo;
int i = 0;
In Delegate Events (DLGI and DLGC) the applyDeny and treeWalk members of
PcmsUserRoleStruct have special meanings that relate to the option specified on the
command line. These meanings are listed below:
Event Examples
The release media contains a number of example events and makefiles to help you get
started. These are contained in the examples subdirectories of the Dimensions CM
installation specified below:
$DM_ROOT/pcms_api/examples (UNIX)
%DM_ROOT%\pcs_api\examples (WINDOWS)
IMPORTANT! To be able to successfully build these example events, you must use the
compiler versions as specified in the readme.
carefully, you do run the risk of affecting Dimensions CM functionality, especially if your
event causes memory corruption. You are strongly advised to test any complex events
thoroughly before deploying them, and if possible use a memory tracking tool to verify
memory use.
Overview 164
Approach 164
Implementation of Action Driven Promotion Event Triggers 164
Overview
You can additionally assign deployment stages to request and baseline lifecycle states in a
similar manner.
Approach
To keep the action driven promotion logic separate from the Dimensions CM server, it has
been implemented as a Dimensions CM Event Trigger (a separate Dynamic-Link Library
(DLL) containing a function that will be called after the action command).
The event trigger is called as a POST event (after the action item, action request, or
action baseline operation completes) and issues a command to promote the item, request
or baseline to the stage associated with the new lifecycle state.
NOTE Because the event trigger is a POST event, if the promotion fails for any reason
the action will still succeed—it will not be atomic. You will need to manually determine
what caused the failure.
Prior to Dimensions CM 12.1, only two event triggers were supported, namely:
One customer supplied.
One Serena supplied. This, however, is used by the Serena Mover integration and
Serena Release Control (formerly called Application Release Manager (ARM)).
Starting with Dimensions CM 12.1, the event mechanism now supports an unlimited
number of event libraries.
Event Mechanism
Prior to Dimensions CM 12.1, the Dimensions CM server runtime loaded two libraries:
libpcmsu.dll and libpcmsu2.dll on Windows and libpcmsu.so and libpcmsu2.so
on UNIX. The process address of the function userSuppliedFunction was then obtained
from the first DLL and the address of the function userSuppliedFunction2 was obtained
from the second DLL. When an operation occurred. it was these functions that were called
one after the other.
However, this mechanism only offered support for two event triggers to be called and with
automatic promotion, ARM, and Mover this would not be sufficient.
Starting with Dimensions CM 12.1, all DLLs in the Dimensions CM server lib/prog folder
are enumerated with the name libpcmsu*. All DLLs found are loaded together with the
For backwards compatibility with respect to the libpcmsu2 library, Dimensions CM first
attempts to get the process address for the function userSuppliedFunction, but if that
fails it gets the process address of userSuppliedFunction2 instead.
Check if the object being actioned is going to a state that has been mapped to a stage.
If the state is not mapped to a stage
return from the event code
If the state is mapped to a stage
{
If the object being actioned is not an item revision
Issue a promotion/demotion command for the object to the right stage in the
current project
else
{
Find all the projects/streams containing the item revision
For each project/stream
{
If the Project/Stream is not using local stages or the Project/stream is the
current one
issue a promotion/demotion command for the item revision to the right stage in
that project/stream
}
}
}
dmclient 169
Introduction 170
Using dmclient 171
Javadoc 173
Examples 173
Introduction
The dmclient Java API provides full, programmatic access to the features of Serena®
Dimensions® CM. dmclient allows users to create and manipulate versioning, change
management, and process modeling data while under the control of the permissions of
Dimensions CM and the change management rules framework.
The table below highlights the important interfaces and classes that a consumer of the
API is likely to make frequent use of. Examples of their use can be found in examples
located in the Dimensions CM installation (see "Examples" on page 173).
Interface
Name /Class Description
DimensionsArObject Interface Represents a Dimensions CM
business object that has attributes
and relationships to other business
objects.
DimensionsConnectionManager Class Entry point to the API for obtaining
an instance of the
DimensionsConnection interface.
DimensionsConnectionManager Interface Represents a connection to a
Dimensions CM server. Provides
access to an instance of the
DimensionsObjectFactory
interface.
DimensionsDatabase Interface Represents the base database to
which the current connection
pertains. Provides access to
collections of key Dimensions CM
business objects such as products
and attribute definitions.
DimensionsLcObject Interface Represents a Dimensions CM
business object that has a lifecycle.
DimensionsObjectFactory Interface Provides access to key
Dimensions CM business objects
such as the base database and the
current user.
Using dmclient
jar files To use dmclient, include the following jar files in your runtime classpath:
dmclient.jar
darius.jar
dmnet.jar
dmfile.jar
commons-logging.jar
com.serena.dmclient.api.DimensionsConnectionManager
com.serena.dmclient.api.DimensionsConnection
com.serena.dmclient.api.DimensionsObjectFactory
Getting Started
To get started, include the following lines at the start of a Java program:
import com.serena.dmclient.api.
import com.serena.dmclient.collections.
import com.serena.dmclient.objects.
TIP To begin you only need access to the first package listed above.
For example, to search for requests with an action date greater than a specified date, you
would have a code like:
lastCheck = Calendar.getInstance().getTime();
filter.criteria().add(new
Filter.Criterion(SystemAttributes.LAST_ACTIONED_DATE, lastCheck,
Filter.Criterion.GREATER_EQUAL));
List<Request> releaseRequests =
conn.getObjectFactory().getBaseDatabase().getAllRequests(filter);
The time format string you need to supply needs to be the same as returned by the
query:
For non-Oracle databases this is "DD-MON-YYYY HH24:MI:SS", where the three letter
month name is one of "JAN", "FEB", "MAR", "APR", "MAY", "JUN", "JUL", "AUG",
"SEP", "OCT", "NOV", "DEC"—for example, "31-AUG-2008 23:59:59". For most
system date attributes, this should be in the timezone of the machine where the
dmappsrv is; excepting the revised date, which is in UTC.
For Oracle databases with English or American NLS settings, the situation is much the
same (except the Oracle server machine's timezone is used instead of the dmappsrv
machine's—this timezone is usually the same, but is a peculiarity of the fact that date
translation is done by the database for Oracle, and by the server for other RDBMS).
For Oracle databases with non-English/American NLS settings, the situation should
also be the same, but you may find that for system date attributes the date string
needs to be in locale-specific "DD-MON-YYYY HH24:MI:SS" format (that is, with the
abbreviated month names not being English).
Javadoc
Javadoc is the industry standard for documenting Java classes. The Javadoc for dmclient
provides full documentation about all the packages, interfaces, and classes, and can be
found at the following locations:
Windows %DM_ROOT%\java_api\docs\api\index.html
UNIX ${DM_ROOT}/java_api/docs/api/index.html
Examples
Examples of the important interfaces and classes that a consumer of the API is likely to
make frequent use of are located in the Dimensions CM installation as follows:
Windows %DM_ROOT%\java_api\examples
UNIX ${DM_ROOT}/java_api/examples
NOTE You can also use the Dimensions CM CruiseControl plug-in with the
Dimensions CM Ant task to implement a continuous integration build based on changes in
a Dimensions CM project. For more details, see Part 5 "Integrating Dimensions CM with
Build Management Tools" in the Dimensions CM Build Tools User’s Guide.
Introduction 178
About Templates 178
Directives 180
Special Directives 191
General Predefined Symbols 191
Remote Job Execution Predefined Symbols 196
Dimensions Build Standard Symbols 196
Dimensions Build User-Defined Optional Symbols 200
Dimensions for z/OS Predefined Symbols 204
Template Expansion and Scripts 205
Complex Symbol References 208
Template Inline Functions 208
Testing Templates 213
Adding Template Variables to the Dimensions Configuration File 215
Extending the Template Processor with User Written Functions 217
The Template Processor Interface 229
Enhancements To Dimensions Command Processing To Supported Structured Information
Return (SIR) 230
Introduction
A template is a customizable text file containing variables and control words. In Serena®
Dimensions® CM, templates are used to execute builds, execute general commands
through remote job execution, control deployments, and to construct the body of e-mail
messages used for notifications.
A stand-alone utility for testing templates enables you to check the behavior of your
templates, for details see page 213.
This chapter describes the templating language and processor. For information about
writing different types of templates see the following chapters:
Build templates on page 233.
Openmake build templates on page 261.
Remote execution templates on page 267.
Deployment area scripts on page 277.
E-mail templates, see the Process Modeling User’s Guide.
About Templates
Templates are organized into records. Records starting with a ')' in column one are
directives. Symbols are used to name values that are either a single value or an array of
one-dimensional tables. Symbol references are expressed by '%variable.' where the
variable is looked up and substituted. A template is inspected record by record and
symbols are replaced and written to the output stream. Dimensions CM constructs a
symbol table using the information passed from the commands and environment
variables. For each single value a scalar is created, and for each multiple value an array
is created. The symbol table represents the context in which template substitution
occurs.
Character Usage
) Directive
% Start substitution
. End substitution
( Used in complex references to control nesting. For example:
) %(symt(10)).
references element 11 of the symbol table symt. For more details about
complex symbol references, see page 208.
: Used to reference symbol tables nested inside other symbol tables. For
example:
%(symt(10):fred)%
references the symbol fred nested in element 11 of the symbol table
symt. For more details about complex symbol references, see page 208.
NOTE You can use the )ATTR directive to change the default characters used by the
templater, for details see page 180.
Example Input:
)SET name=World
Hello %name.
Output:
Hello World
Example Input:
)SET A=B
This line uses %A.
)IF %A.=B
The value of A is B.
)ELSE
The value of A is not B.
)ENDIF
Output:
Directives
Directives are commands that are processed by the templater. The templating language
includes the directives listed below.
)ADJUST
Description Adjusts the value of the integer <variable> by adding the integer <value>. You can
use this directive to control loops.
where:
<variable> specifies a variable you define with the directive )SET (see page 188).
<value> specifies an integer value that you use to adjust <variable>.
Example Input:
)SET TEST=205
)ADJUST TEST -10
The value of TEST is %TEST.
Output:
)ATTR
Description Changes the default characters used by the template. You must specify a list of exactly
six characters in the following order:
Value #1: Directive character
Value #2: Start substitution character
Value #3: End substitution character
Values #4, #5, and #6: Complex references characters
)ATTR #%.():
)ATTR )%%():
)ATTR )%.():
NOTE If you use the )IM directive to embed a file inside a template you can use )ATTR
to change that file's defaults. This does not change the default settings of the parent
template.
)CALL
See "Additional Template Directives" on page 217.
)CALLBACK
Description Enables you to inject data directly into a template using a programming API.
where:
<ref> specifies parameters that are delivered to the user's )CALLBACK function.
<NT> specifies that the data provided by the )CALLBACK function is treated as
literal. If you do not specify <NT> the data provided by the )CALLBACK function is
subject to further expansion by the templater.
)CM
Description Enables you to insert comments into a template.
where:
Example )CM
)CM The following is a single line command!
)CM
)DUMP
Description A dump utility to assist in debugging and writing templates. it is available is various
guises as explained below.
)DUMP
dumps the symbol table as a series of I level messages.
The form
)DUMP comment
puts the symbol table into the output file from templating using 'comment' as a start
of line comment operator.
The form
interprets 'colno' as a number (which must be positive) and truncates all output in
this form to the specified column number.
The forms
outputs //* in front of each )SET or )VECTOR and also truncates the line at 70.
)ELSE
Description Switches inclusion on or off in a conditional block.
Syntax )ELSE
)ENDIF
Description Ends an )IF conditional block.
Syntax )ENDIF
Operators:
=
EQ (equals)
NE (not equal)
!=
STRCONTAINS
Example Input:
)SET n=1
%n.
)IF %n. = 1
echo Is one
)ELSE
echo Is not one
)ENDIF
)ADJUST n 1
%n.
)IF %n. = 1
echo Is one
)ELSE
echo Is not one
)ENDIF
Output:
1
Is one
2
Is not one
Example The following example controls when compile options are used:
)SET debug=Y
%debug.
)IF %debug.=Y
<compile options>
)ENDIF
Input:
Output:
Input:
)SET A=
)IF %A. != ""
This line is actioned
)ENDIF
)IF %A. !=
This line IS actioned
)ENDIF
)IF "%A." != " "
This line is also actioned
)ENDIF
Output:
)ENDEXPAND
Description Ends template expansion started with )EXPAND.
Syntax )ENDEXPAND
)ENDR
Description Ends a repeat block
Syntax )ENDR
)ENDSCRIPT
See "Additional Template Directives" on page 217.
)EXPAND
Description Expands a template. You can define )EXPAND with or without a script:
)EXPAND without a script
In a simple )EXPAND where you do not specify a script, the text block between
)EXPAND and )ENDEXPAND is expanded by the template processor:
)EXPAND
<text>
<text> Expanded by the template processor
<text>
)ENDEXPAND
For example, you can use )EXPAND to specify an action that might be confused by
the special template characters, or to restrict the sections of a template that are
expanded.
)EXPAND with a script
When you specify a script, the text block between )EXPAND and )ENDEXPAND is
processed by the named script processor, and the result is embedded into the
template at the point where you insert this directive.
Syntax:
NOTE This directive is implemented by invoking the system command on the specified
file. On z/OS this will cause an address space to be created, and this will exist only for
the duration of the script invocation. That operation is expensive and should be avoided if
possible.
For more details about using )EXPAND to expand templates, see page 205.
)IF
Description Starts an )IF conditional block.
where:
)IFDEF
Description Starts a conditional block based on a symbol's existence.
where <symbol> specifies the symbol whose existence you are checking.
)IFNDEF
Description Starts a conditional block based on a symbol's non-existence.
where <symbol> specifies the symbol whose non-existence you are checking.
)IM
Description Embeds a file into the template at the point where you insert this directive. You can also
nest )IM directives inside other )IM directives.
NOTE When you use )IM to embed a file you can use )ATTR to change that file's
defaults. This does not change the default settings of the parent template. For details see
page 180.
where:
<filespec> specifies the file you want to embed.
<NT> specifies that the named template is literal text and is not a template.
This is section 1
)SET NAME=John Doe
)IM inner.tpl
This is section 2
This is section 3
)IM inner.tpl NT
This is section 4
Input (inner.tpl)
My name is %NAME.
Output
This is section 1
My name is John Doe
This is section 2
This is section 3
My name is %NAME.
This is section 4
)LOGON
Description Log on to the specified Dimensions CM server. This logon will be active until the end of
the script.
where:
<user> specifies the user-id.
<pwd> specifies the user-id’s password.
<host> specifies the server host name.
<db> specifies the Dimensions CM database.
<dsn> specifies the database connection string (data source name).
)REP
Description Starts a repeat block that you can use in conjunction with array variables. The directive
repeats until it has been round all the elements in the specified array.
Example The example below has a single array variable containing three elements.
Input:
)VECTOR dates(3)
)SET dates(0)=12th Nov 2005
)SET dates(1)=13th Nov 2005
)SET dates(2)=14th Nov 2005
)REP dates
%dates.
)ENDR
Output:
Example The example below has two arrays each containing three elements. The second )REP
directive (chdocs) is nested inside the first (dates). The output is a list of three dates,
each containing a list of all the change documents.
Input:
)VECTOR chdocs(3)
)SET chdocs(0)=PVCS_EC_124
)SET chdocs(1)=PVCS_EC_567
)SET chdocs(2)=PVCS_EC_444
)VECTOR dates(3)
)SET dates(0)=12th Nov 2005
)SET dates(1)=13th Nov 2005
)SET dates(2)=14th Nov 2005
)REP dates
%dates.
)REP chdocs
%chdocs.
)ENDR
)ENDR
Output:
PVCS_EC_124
PVCS_EC_567
PVCS_EC_444
PVCS_EC_124
PVCS_EC_567
PVCS_EC_444
PVCS_EC_124
PVCS_EC_567
PVCS_EC_444
Example The example below has two arrays each containing three elements. The array variables
are embedded inside the text. The output is three text strings, each containing a
different change document and date.
)VECTOR chdocs(3)
)SET chdocs(0)=PVCS_EC_124
)SET chdocs(1)=PVCS_EC_567
)SET chdocs(2)=PVCS_EC_444
)VECTOR dates(3)
)SET dates(0)=12th Nov 2005
)SET dates(1)=13th Nov 2005
)SET dates(2)=14th Nov 2005
)ENDR
Output:
)SCRIPT
See "Additional Template Directives" on page 217.
)SET
Description Creates or changes a value in the symbol table.
where var can be a scalar variable name or a reference to an array element when in the
form var[n].
)SETL
Description Creates a value in lowercase, or changes an existing value to lowercase.
where var can be a scalar variable name or a reference to an array element when in the
form var[n].
Example Input:
Output:
john
)SET_PATH
Description Treats <value> as a path specification in UNIX format. This value is converted to the
equivalent path specification in the local operating-system format, for example:
/a/b/c
becomes
\a\b\c
A.B(C)
where:
<variable> specifies the variable to which you are specifying a path
specification.
<value> specifies the path specification.
)SET_PATH_MVS
Description Treats <value> as a path specification in UNIX format. This value is converted to the
equivalent path specification in MVS format, for example:
/a/b/c
becomes
A.B(C)
where:
<variable> specifies the variable to which you are specifying a path
specification.
<value> specifies the path specification.
)SET_PATH_NT
Description Treats <value> as a path specification in UNIX format. This value is converted to the
equivalent path specification in Windows format, for example:
/a/b/c
becomes
\a\b\c
where:
<variable> specifies the variable to which you are specifying a path
specification.
<value> specifies the path specification.
)SET_PATH_UNIX
Description Treats <value> as a path specification in Unix format, this value is converted to the
equivalent path specification in UNIX format (noop), for example:
/a/b/c
becomes
/a/b/c
where:
<variable> specifies the variable to which you are specifying a path
specification.
<value> specifies the path specification.
)SETU
Description Creates a value in uppercase, or changes an existing value to uppercase.
where var can be a scalar variable name or a reference to an array element when in the
form var[n].
Example Input:
Output:
JOHN
)SLICE
Description Enables you to send arbitrary quantities of data to a program from a single string
variable. The directive creates an array in var2 that is long enough to hold all the
information in var1 in 32 byte chunks. var1 must already exist.
Example Input:
Output:
)VECTOR
Description Creates an array of elements.
Special Directives
The directives listed below enable a template processing step to pass data to a later
processing step:
)SAVE
)LOAD
)DELETE
)IFGROUPDEF
)IFGROUPNDEF
See "pBem Template Processing—Passing Data Between Steps" on page 221 for details.
%DMCOMBINEOUTERR.
Description Is similar to %DMSAVESTDERR. (see page 194) and %DMSAVESTDOUT. (see page 194)
but combines the output and the errors into one file and places them in the variable
%DMOSTDOUT..
template_test -g c
Setting up build configurations.
Writing a template, for example add the line:
)SET DMCOMBINEOUTERR=Y
%DMCURRENTDIRECTORY.
Description The current directory.
%DMCYGWIN.
Description This is for Windows only. It is the current directory in Cygwin (Windows UNIX utilities)
style, that is, '.'.
%DMDAY.
Description Two digit string representing the day in the month when this template process is started.
Example 07s
%DMFOLDERSEPARATOR.
Description The folder separator for the operating system being used. This will be '/' (forward slash)
for UNIX and '\' (backward slash) for Windows.
%DMHOUR.
Description Two digit string representing the hour when this template process is started. Uses GMT
in a 24-hour format.
Example 12
%DMMICROSEC.
Description Six digit string representing the microsecond when this template process is started.
Example 01348
%DMMINUTE.
Description Two digit string representing the minute when this template process is started.
%DMMONTH.
Description Two digit string representing the month in the year when this template process is
started.
Example 12
%DMOSTDERR.
Description Reveals the filename containing the errors of the template execution. This file exists on
the machine where the script is executing.
%DMOSTDOUT.
Description Reveals the filename containing the output of the template execution. This file exists on
the machine where the script is executing.
%DMOSTYPE.
Description The operating system being used. This will be 'UNIX' for UNIX and 'Windows' for
Windows.
%DMOXTMPLT.
Description Reveals the filename containing the expanded template. This file exists on the machine
where the script is executing.
%DMPASSWORD.
Description Set to the value of the node password specified for the work or deployment area. This
password can be different to the one you used to log on with.
%DMPATHSEPARATOR.
Description The path separator for the operating system being used. This will be ':' (colon) for UNIX
and ';' (semi-colon) for Windows.
%DMSAVESTDERR.
Description Requests that the errors from the template execution are saved. The filename where the
errors are saved is put into the variable DMOSTDERR.
template_test -g e
Setting up build configurations.
Writing a template, for example add the line:
)SET DMSAVESTDERR=Y
%DMSAVESTDOUT.
Description Requests that the output of the template execution is saved. The filename where the
output is saved is put into the variable DMOSTDOUT.
template_test -g s
Setting up build configurations.
Writing a template, for example add the line:
)SET DMSAVESTDOUT=Y
%DMSECOND.
Description Two digit string representing the second when this template process is started.
Example 24
%DMUNIQUE.
Description An eight character encoding of the date and time to within one second in the century,
formatted to conform to MVS member naming standards and lexically ordered by time.
Example Input:
//INPUT DD DSN=BLD.%DMUNIQUE..COBOL,DISP=SHR
Output:
//INPUT DD DSN=BLD.A3664E3.COBOL,DISP=SHR
%DMUSER.
Description Set to the value of the node user ID specified for the work or deployment area. This user
ID can be different to the one you used to log on with.
%DMUSERU.
Description Same as for DMUSER, but truncated to seven characters and converted to upper case.
%DMYEAR.
Description Four digit string representing the year when this template process is started.
Example 2005
%DMCERTIFICATE.
Specifies a one-time certificate used to reconnect to Dimensions CM to perform post-
build processing such as updating a job status or collecting build outputs.
%DMJOBID.
Specifies the remote job key.
NOTE There is also a set of optional Dimensions Build symbols described in "Dimensions
Build User-Defined Optional Symbols" on page 200. To be utilized, these optional
symbols must be explicitly added as Dimensions Build options, that is, they are not
defined by default.
%DMPATH.
Description DMPATH tells the build step template where the source is to be found. It always contains
at least one element, namely, the disk location where the build is being performed. This
disk location element will always be the first element in the array.
For deployment area builds, further elements of the DMPATH array are formed by
examining all deployment areas for the build configuration that are:
firstly, located on the same node as the area being built, and
secondly, for which the GLC sequence is higher than or equal to that of the area
being built.
On MVS systems, this is the stem of the area with // preceding each entry.
If the area being built is a work area, and if the DM_SP_START_STAGE symbol is set to a
GLC identifier, the first array entry will be the location of the work area and the
remainder of the DMPATH variable is constructed as though the work area were a
deployment area at the specified stage.
NOTE On MVS platforms the data set stem does not contain low level qualifiers, which
are added by the template.
MVS format:
//ACCOUNT.TEST
//ACCOUNT.SYSTEM
//ACCOUNT.PRODUCTION
Distributed format:
NOTE There is usually only one useful row in Windows and UNIX distributed
environments, namely, the first.
Windows:
c:\account\test
c:\account\system
d:\account\production
UNIX:
/account/test
/account/system
/account/production
)VECTOR DMPATH(3)
)SET DMPATH(0)=//BUILD.LEVEL1 This mimics the set up done by
)SET DMPATH(1)=//BUILD.LEVEL2 the pBem.
)SET DMPATH(2)=//BUILD.LEVEL3
)SET FIRST=SYSIN
)REP DMPATH
)SET THSDIR=_MDHEXTRACT_(+d,%DMPATH)
//%FIRST. DD DSN=%DMPATH..COBOL,DISP=SHR
)SET FIRST=
)ENDR
Output:
//SYSIN DD DSN=BUILD.LEVEL1.COBOL,DISP=SHR
// DD DSN=BUILD.LEVEL2.COBOL,DISP=SHR
// DD DSN=BUILD.LEVEL3.COBOL,DISP=SHR
Distributed Input:
Example
)VECTOR DMPATH(3)
)SET DMPATH(0)=c:\stu\my-area This mimics the set up done by
)SET DMPATH(1)=d:\build\system-test the pBem.
)SET DMPATH(2)=e:\build\production
)SET INCLUDES=
)REP DMPATH
)SET INCLUDES=%INCLUDES. -I %DMPATH.
)ENDR
Output:
%DMINPUT.
Description Specifies an array of sources expressed as relative filenames, where each row names an
input file. Each file is categorized according to the filename extension (on distributed
platforms) or the low level qualifier (on mainframe platforms). The file type decides
where the input goes in the template. See also "MDHDSN" on page 208.
NOTE If a template only reads in one file the category is irrelevant as there is only one
place where the information can go.
Distributed prog1.c
examples
account\account1.c (Windows)
account/account1.c (UNIX)
%DMTARGET.
Description Specifies an array of relative filenames that are the outputs from a build. Each file is
categorized according to the filename extension (on distributed platforms) or the low
level qualifier (on mainframe platforms).
Distributed prog1.c
examples
account\account1.c (Windows)
account/account1.c (UNIX)
%DMSTEP.
This is constructed by Dimensions Build. It specifies the sequence number of the current
step in the build process and can be used in a build template to signal to the pBem the
end of a step. For more details about Dimensions Build see the Dimensions CM Build
Tools User’s Guide.
%DMRUNMODE.
Description This is set by pBem. It is a read only symbol that conveys the actual runmode to the
template. It can be used to trigger asynchronous specific actions.
%DMSERVER.
This is set by the Dimensions Build server. It is a string such as <MACHINE>:<PORT> that
can be used as a network address to locate the build server when sending messages. It
is used when messages are sent directly to the build server. To send messages back to
the controlling pBem use the variables DMPBEMNODE and DMPBEMPORT (see below).
%DMTOKEN.
This is constructed by the Dimensions Build server. It is an abstract build token that is
used internally by the build server to create a Bill of Materials report (BOM).
%DMJOBID.
This is constructed by the Dimensions listener. It is an abstract symbol generated by the
REXEC mechanism to track jobs. In Dimensions 9.x, the RSTAT and RLIST commands
used this symbol as the primary build tracking mechanism. This symbol has been
retained for backwards compatibility though the Dimensions Build server now manages
the build history.
%DMXFERSOURCE.
Set this symbol to ’Y’ to transfer sources automatically to work areas. By default
Dimensions, does not transfer sources to work areas.
DMEXECENV
Description Sets one of three modes that control the script execution environment after a template
has been expanded. It is user-defined in the template.
In this mode the template is processed as an MVS batch job and is submitted to be run.
The script execution environment treats the template as JCL and submits it.
Syntax:
In this mode the template is processed with a command, with or without arguments.
Syntax:
Example:
In this mode the expanded template is processed again by the templater using a
different template that you specify. This allows a specific template to be wrapped by
another.
Syntax:
Example:
In the example below the )CALLBACK directive indicates where to insert the text from
the inner template.
Input (outer.tpl):
)EXPAND
echo off
echo Building started
)CALLBACK NT
echo Building continuing
Input (inner.tpl):
Output:
DMEXPAND
This is user-defined in the template.
If DMEXPAND is:
Set to 'Y'
EXPAND mode is enabled, where only the parts of the template delimited by )EXPAND
and )ENDEXPAND are expanded.
Not set to ’Y’
The template behaves as in Dimensions 9.x, where the entire template is expanded.
Dimensions Build automatically sets DMEXPAND to 'Y' by default. For examples see
"Template Expansion and Scripts" on page 205.
DMTASKNAME
Description This is used to create a message that is displayed in the Task column of the Build Monitor
Events section of the Build Job Details dialog box in Dimensions Build. You can also use
other symbols, for example, to insert program names.
DMTIMEOUT
This is set to override the time (in seconds) that the pBem waits for a step to complete
before it is marked as failed. Note that Dimensions Build also has an overall build
timeout value, which might be wait forever.
DMSTEPMODE
Description This is set to override the synchronous and asynchronous setting of a build for a given
step; usually used to ensure that certain activities are synchronous.
DMMAXRC
This is set in a build configuration or for doing a run to specify the highest acceptable
return code set by build, step, area, or config. It enables a template to pass back the
actual return code for information and allow certain values to be treated only as
warnings. Set this symbol to the maximum value that is considered safe for that step. If
the return code is higher than this value the pBem will not schedule dependent steps as
the step will have failed.
DMNOCACHE
This symbol is set to 'Y' for a template or build configuration to disable the caching of
some file information. It produces a slower but more accurate build for poorly defined
build configurations.
DMREBUILDALL
The default value of this symbol is ’NO’, in which case neither of the rebuild operations
described below will occur.
To initiate one of the rebuild operation described, set the symbol to the appropriate
value:
’YES’ or ’ALL’ to rebuild all the steps in the BRD irrespective of the stage they are in.
’CURRENT’ to rebuild all the targets that are physically located at the stage where
the build is occurring (the current stage). Does not automatically rebuild targets that
are higher up the lifecycle, such as at REL.
DMMUSTRUN
Define this symbol in a template or build configuration to indicate that a step is essential
and must run even if a prior dependent step has failed. Note that cleanup activities
should be done in post-build steps defined in the build configuration.
DMFINAL
Define this symbol for a template or build configuration to indicate that a step should run
last. Forces dependencies to be created to ensure that the step does run last. Note that
it is best practice to use a correctly configured build configuration to specify when steps
are run.
DMTTLOG
Causes detailed trace messages from the templating process to be produced, their
destination depending on the context in which they are generated. These messages can
be useful in some error situations to determine why a template failed.
DMALTSERVER
Enables you to change the address of the build server that is defined in the BRD file—
typically the server from where the build is launched—and specify the address of an
alternative build server.
http://<IP address of the machine hosting the build server>:<Tomcat port number>/bws/
services/monitor
Example http://<dimensions-dev>:<8080>/bws/services/monitor
Usage scenario When you launch a build from a virtual machine, and are building on a remote node, the
address of the build server in the BRD file on the remote node may be the physical
machine hosting the virtual machine (not the actual virtual machine). You can use
DMALTSERVER to change the address to that of the virtual machine.
DM_SP_START_STAGE
Enables you to limit a search path by specifying from what stage in the Global Stage
Lifecycle (GSL) you want to start appending deployment area paths to search paths in a
BRD file. Can only contain only one value, which is the name of a stage in the GSL.
DM_BUILDER_PROGRESS_REPORTING
If you specify this symbol, any step that has a non-zero return code causes the SBEM to
issue the following message with a severity of W:
MDHSB16D112W Step <step number> Program <program> returned COND CODE = <cc>
Default: YES
The sequence number is made visible to the JCL tailoring skeleton through the following
predefined symbols:
There are two ways that you can implement scripts in a template:
Expansion—use a script, delimited by the directives )EXPAND and )ENDEXPAND, to
expand a specific part of a template to complete it, for example, to insert a date.
Execution—use a script to execute an entire expanded template, for example, to
call a compiler and run the expanded template through it.
A script can be any shell scripting language, typically REXX on a mainframe, and Perl,
Python or any other command-line language on a distributed platform. Script mode
allows you to generate complex scripts and to interpret the body of the expanded section
as a command script, the output of which becomes the expanded text.
NOTE The )EXPAND directive is implemented by invoking the system command on the
specified file. On z/OS this will cause an address space to be created, and this will exist
only for the duration of the script invocation. That operation is expensive and should be
avoided if possible.
Example The example below illustrates one simple use of template expansion.
Input:
)EXPAND %%s
echo echo Hello
)ENDEXPAND
Output:
When the script runs, it outputs "echo Hello". So these three lines will be replaced by
one line containing "echo Hello". This command will execute when the template runs,
printing "hello".
Example The example below illustrates another simple use of template expansion.
Input:
)EXPAND %%s
echo Hello > c:\temp\foo.txt
)ENDEXPAND
Output:
This particular script does not output anything, the three lines simply disappearing
from the template. However, during execution, the file named (foo.txt) will get
created.
Example The mainframe example below demonstrates the power of an external scripting
language. The template does the following:
Creates a temporary file, referred to by '%%s', containing the script delimited by
)EXPAND and )ENDEXPAND.
Executes the temporary file with the REXX interpreter. REXX outputs the string 'job
submitted on <date>'. This line then becomes part of the template.
Input:
//*
)EXPAND %%s
/*REXX*/
Say "//* job submitted on" date()
exit 0
)ENDEXPAND
)EXPAND
//*
Output:
NOTE Two percent characters '%%' are required if '%' is being used as a special
character. The role of '%s' is to allow a command line to be generated where the script
name is not necessarily the last parameter.
Example The mainframe example below shows how to pass variables into and out of an executed
script, where REXX is used to set a template variable called MYVAR.
Input:
//*
This )EXPAND starts the block that ends with )ENDEXPAND.
)EXPAND %%s
As it is followed by a script, this expansion is in script mode.
/*REXX*/
This )EXPAND forces the template to treat the output from REXX as
Say ")EXPAND" template lines (the default for an expanded script is not to expand).
REXX outputs this line, which is interpreted by the
Say ")SET MYVAR=" date()
templater, and causes the variable MYVAR to be set.
//*
//* %MYVAR.
//*
Output:
//*
//* job submitted on 8 Dec 2005
//*
//* 8 Dec 2005
//*
Example The Perl distributed platform example below is a template with a nested Perl script that
splits out the PATH environment variable into a template array.
Input:
)VECTOR MYPATH(20)
)EXPAND perl
This )EXPAND starts the block that ends with )ENDEXPAND. As it
%%s
is followed by a script, this expansion is in script mode.
This )EXPAND forces the template to treat the
print ")EXPAND\n"; output from Perl as template lines.
@dirs = split(/:/,$ENV{'PATH'});
$i=0;
foreach $dir (@dirs)
{
print ")SET MYPATH($i) = $dir\n";
$i=$i+1;
}
)ENDEXPAND
)EXPAND This )EXPAND forces the variable 'MYPATH' to be expanded.
//*
//* First element = %(MYPATH(0)).
//* Second element= %(MYPATH(1)).
//*
//* This is the complete array:
//*
)REP MYPATH
===> %MYPATH.
)ENDR
//*
//* End
//*
Output:
//*
//* First element = /cygdrive/c/stu/exec
//* Second element= /cygdrive/c/WINDOWS/system32
//*
//* This is the complete array:
//*
===> /cygdrive/c/stu/exec
===> /cygdrive/c/WINDOWS/system32
===> /cygdrive/c/WINDOWS
===> /cygdrive/c/WINDOWS/System32/Wbem
===> /cygdrive/c/Oracle/jre/1.4.2/bin/client
===> /cygdrive/c/Oracle/jre/1.4.2/bin
===> /cygdrive/c/Oracle/bin
===> /cygdrive/c/unix_utils
===> /cygdrive/c/jakarta-ant-1.5/bin
===> /cygdrive/c/j2sdk1.4.2_10/bin
===> /cygdrive/c/Serena/Dimensions/10.1/prog
===> /cygdrive/c/Program Files/Serena/License Manager
===> /usr/bin
===> /cygdrive/c/Program Files/QuickTime/QTSystem/
//*
//* End
//*
The example below accesses the third row of the array DMPATH (arrays start at zero
therefore (2) is the third row).
%(DMPATH(2)).
In the example below the index to the array is the variable index.
%(DMPATH(index)).
NOTE When a variable appears in parentheses inside a complex reference, you do not
need to prefix the variable with %.
Overview
Template inline functions enable you to add functionality to your templates that is not
available with the standard template directives. Inline functions are processed after
symbols are expanded but before template directives are executed. The text string
returned by an inline function is inserted into a template at the point where the function
is named.
Syntax:
_function name_(parameters)_
MDHDSN
Description MDHDSN is a C function that helps you to manage search paths in templates in JCL and in
distributed scripts.
Syntax _MDHDSN_(default-name,lookup-array,type,path-array,error_flag)_
where:
default-name specifies a name if you do not specify 'type'.
(Optional) lookup-array specifies an array of objects.
(Optional) type specifies a file or object type.
Example The following directives create two arrays that are used by the inline functions in this
example:
)VECTOR DMPATH(5)
)SET DMPATH(0) = /zero/
)SET DMPATH(1) = /one/
)SET DMPATH(2) = /two/
)SET DMPATH(3) = /three/
)SET DMPATH(4) = /four/
)VECTOR DMSOURCE(3)
)SET DMSOURCE(0) = foo.c
)SET DMSOURCE(1) = bar.input
)SET DMSOURCE(2) = middle/blim.txt
The following function returns hello.c (the default) as no other parameters are
specified:
_MDHDSN_(hello.c,,,)_
The following function searches for test in the array DMSOURCE and returns the default
(hello.c) as there is no match:
_MDHDSN_(hello.c,DMSOURCE,test,)_
The following function searches for a 'c' type in the array DMSOURCE and returns
'foo.c':
_MDHDSN_(,DMSOURCE,c,)_
The following function searches for 'foo.c' in the array DMPATH and returns '/two/
foo.c':
_MDHDSN_(foo.c,,,DMPATH)_
The following function combines two operations by searching for a 'c' type in the arrays
DMSOURCE and DMPATH, and returns '/two/foo.c':
_MDHDSN_(hello.c,DMSOURCE,c,DMPATH)_
Example The following directives find an entry in the array 'S', which has a type of 'b'. This
matches f2.b. If this had not worked, it would use the default of default.txt. Then,
using this filename (f2.b), it would look for it on disk in all the locations in the array
'A', until found. If this does not work, it specifies not to issue an error message.
)VECTOR A(4)
)SET A(0)=d:\stu\c\tpl\1\
)SET A(1)=d:\stu\c\tpl\2\
)SET A(2)=d:\stu\c\tpl\3\
)SET A(3)=d:\stu\c\tpl\4\
)CM
)CM
)CM
)VECTOR S(3)
)SET S(0)=f1.a
)SET S(1)=f2.b
)SET S(2)=f3.c
)CM
)CM
)CM
%(A(0)).
%(A(1)).
%(A(2)).
%(A(3)).
%(S(0)).
%(S(1)).
%(S(2)).
)CM
found _MDHDSN_(default.txt,S,b,A,0)_
Example The following example shows how the function works with an MVS JCL template:
Input:
//SYSIN DD DSN=_MDHDSN_(COBOL(FOO),DMSOURCE,COBOL,DMPATH)_,DISP=SHR
Output:
//SYSIN DD DSN=SMITCHE.BLD.UNIT.COBOL(FOO),DISP=SHR
MDHEXTRACT
Description MDHEXTRACT explodes filenames and data set names into component parts.
Syntax _MDHEXTRACT_(format,filename,[root])_
where:
format is a literal string that can optionally contain one or more of the following
operators:
Operator Description
+p Returns the filename prefix, usually 'null' on distributed platforms and
'//' on MVS platforms.
+r Returns the root of the filename with a trailing directory character.
Distributed example: \test-machine\builds\test_1\
MVS example: //test-machine.builds.test_1.
See the explanation below this table about specifying a root.
+n Returns the name of the object, for example, foo.
filename specifies the filenames or data set name that you want to explode.
[root] specifies the part of the filename or data set name that is the root. For
example:
\test-machine\builds\test_1\ unit_test\build_1\
Input:
_MDHEXTRACT_(+n,/root/test/fred.txt,)_
Output:
fred
Input:
_MDHEXTRACT_(+n,//'MDH.DEV.UT.THING.C(FOO)',)_
Output:
FOO
Example This example specifies the root, and returns the subdirectory, the type, and the name of
the object.
Input:
Output:
Input:
_MDHEXTRACT_(t(+t) name(+n),//'MDH.DEV.UT.TEST.TEXT',)_
Output:
t(TEXT) name(TEST)
NOTE It is common for problems to occur with different kinds of slashes appearing in
filenames, particularly when the names are computed from parts. You can use a
particular form of the MDHEXTRACT function to normalize names, according to the current
platform. On Windows backslashes are used ("\") and on UNIX forward slashes are used
("/") in the output. For example:
)SET NEWNAME=_MDHEXTRACT_(+d,%OLDNAME.)_
substring
Description This function reads nothing and writes back nothing, but the first variable V1 is set to the
substring of V2 specified by the spos and len values. If spos is negative, the start
position is the specified number of characters from the end.
where:
spos is optional and defaults to 0.
len is optional and defaults to -1 (meaning the rest of the string).
Example Input:
Input:
Output: F
pos
Description This function creates the variable V3 and sets its value to the result of the operation. The
variable VMAIN is searched for by the substring VSUB. If there is no match, V3 is set to
the string -1. Otherwise it is set to the string representing the decimal number equal to
the starting offset of the substring.
Example Input:
Input:
Testing Templates
For a Dimensions CM server or agent installation, a template testing program called
template test is located in the 'prog' subdirectory of the Dimensions CM root
installation directory. This template testing program enables you to unit test your own
templates. It is command-line driven and invokes the template processor on a single
input file for processing.
Command-line
template_test <input file> <switches>
Switches
Result codes
NOTE The file headtest.template provides a test template that sets up values similar
to those used in a build environment in Dimensions CM.
Variable Description
DM_TEMPLATE_CATALOGn Specifies a data set or directory search path where
templates are located. You can specify an array of
multiple search paths by adding multiple instances of
DM_TEMPLATE_CATALOGn and incrementing the value
of n, for example:
DM_TEMPLATE_CATALOG1 c:\prod\templates
DM_TEMPLATE_CATALOG2 d:\dist\templates
Default locations:
Windows: %DM_ROOT%templates
UNIX and MVS: $DM_ROOT/templates
(Sheet 1 of 2)
Variable Description
DM_TEMPLATE_CATALOGn Notes:
(continued) On distributed platforms the search path
specifies a single directory.
If you specify a file type, Dimensions CM looks in
the search paths for matching files. On MVS, if
you do not specify a file type, the default is
TEMPLATE.
DM_TPLB_LOG Switches on tracing of template processing. Specifies
the name of the file that will contain detailed
messages issued during template processing, and the
substitutions performed. You can customize this string
before using it as follows:
%d—inserts the date in the format yyyymmdd.
%t—inserts the time in the format hhmmss.
%p—inserts the process id.
%%—inserts one '%' character.
Default: none
Example: tmp/template_log_%d_%t.log
DM_TPLB_SPOOL Specifies the name of the file or data set where the
JCL will be written. The file is not passed for
execution. This field may be useful when testing new
templates.
Maximum field length: 100 bytes
Default: null
Example: tmp/spooled.jcl
DM_TPLB_TTLOG Specifies that any trace sent to the file that you
specify in DM_TPLB_LOG is also sent to the message
routine (the trace comes back to the client to be
displayed).
Default: null
Example: yes
DM_TPLB_SEQUENCE_PATH Specifies the directory where the HFS file that
maintains the build sequence number is stored.
Default: the directory specified in the variable DM_TMP.
If this variable is not set, the defaults are:
UNIX: /TMP
Windows: c:\temp
(Sheet 2 of 2)
Introduction
The functionality described here is a generalized call-out facility that allows user written
code to run in-process as part of the template processing logic. User written code can
live in user DLLs or on z/OS in an assembler module. The template processor can 'call
out' to these routines, passing values in both directions. The user code is called with a
control block (TEB) that holds the addresses of some callback routines and a context
pointer, and a count and pointer array to the parameter list.
These directives are implemented by the same code. The parameter dllname is
optional:
If you do not specify dllname some internal entrypoints are exposed.
If you do specify dllname the DLL is loaded once and any entrypoints that are
referenced in that DLL are resolved against the single handle.
On z/OS, if you use the special Dllname Assembler, the entry point is fetched and
called (no dll load is attempted).
The 'cards' are records that are processed by the template processor (with replacement)
that the function 'reads' using a specialized read processor. The function writes output
back using a specialized 'Write' function that is passed through the template processor
again, so any ')' directives in this stream are honoured.
Predefined Functions
durules
This function gets details from Dimensions CM useful for uploading that item into
Dimensions CM. The syntax is as follows:
<product_id> specifies the product into which the item will be placed.
<project_id> specifies the project into which the item will be placed.
<project_root> specifies the location of the root of the project within the
project hierarchy (if using sub-projects, use "\" if not).
<context_root> specifies the path that will be prepended to the file to get
the full path.
<file> specifies the file for which information is to be gathered.
Returned This is a set of vectors, with one entry in each vector corresponding to each object;
information. that is, all the [0] values pertain to the first object returned, all the [1] values to
the second object returned, and so on.
pos
The built-in function pos is called as follows:
<directory path> specifies the location of the directory that will be the root of
the search. It may be in NODE::DIR format.
<area root> specifies the root of the area that contains the target
directory. To scan the whole area <directory path> and
<area root> will be the same.
<filter> if specified, then only files matching this filter will be
returned. An example filter is "*.txt".
Returned This is a set of vectors, with one entry in each vector corresponding to each object;
information. that is, all the [0] values pertain to the first object returned, all the [1] values to
the second object returned, and so on.
substring
There are some predefined functions that are implemented using this logic. The
built-in substring entry point is provided, and is called as follows:
where:
spos is optional and defaults to 0. If spos has a negative value, then the start
position is that many characters from the end.
len is optional and defaults to -1 (meaning the rest of the string).
This directive reads nothing and writes back nothing, but the first variable V1 is set
to the substring of V2 specified by the spos and len values.
For example:
Extensibility
Depending on the context, additional pre-defined functions may be available.
Overview
A template processing step can pass data to a later template processing step. To do this,
five additional directives are provided:
where:
variable specifies both the name the variable will be saved as and, by looking
that up, the value to save.
For example:
If 'FROG' does not already exist as a symbol, ')SAVE
NewDomain FROG' will fail.
If 'FROG' does already exist as a symbol, then:
• If additionally the group ’NewDomain' does not exist, it will
be created;
• otherwise, if ’NewDomain' does exist, it will be updated by
the addition of the symbol 'FROG' set to its current value in
the template processor symbol table.
variable mask a variable mask is handled if the variable name contains either
asterisk '*' or question-mark '?'. '*' matches any number of
characters; whereas, ’?' matches a single character at that point.
option On a load, any variable in the group will be added to the current
symbol table. By default, any variable of the same name in the
current symbol table will be lost; this default behavior can be
modified by specifying one of the following optional values:
OVERWRITE
WARN
ERROR
DISCARDDUPLICATES
Semantics
)SAVE saves the specified symbol or all matching symbols. If the group
specified by group name does not exist, it will be created.
)LOAD merges the specified group with the current symbol table. If no
such group exists, an error will result. Remember, the incoming
)LOAD symbol gets priority.
)DELETE destroys the entire group, freeing the associated storage.
)IFGROUPDEF behaves as )IFDEF and allows conditional logic based on the
existence of the named group.
)IFGROUPNDEF behave as )IFNDEF and allows conditional logic based on the
existence of the named group.
Example Template
First line
)SET V2=This is a string of data
)CALL substring V1 V2 -6 8
'%V1.'
)CALL libsampleexit101uD.so.GetIdeas
)SET V4=My own parm 4
)SCRIPT libsampleexit101uD.so.DumpParameters P1 "prm 2" "prm 3"
"%V4."
This is the first line of input to Dump - %V1.
And this the second
)ENDSCRIPT
***END***
The command:
First line
'f data'
Next parameter[0] = 'libsampleexit101uD.so.DumpParameters'
Next parameter[1] = 'P1'
Next parameter[2] = 'prm 2'
Next parameter[3] = 'prm 3'
Next parameter[4] = 'My own parm 4'
This is the first line of input to Dump - f data
And this the second
***END***
To create this output, the routine libsampleexit101uD.so has been created, and this
looks like this:
#ifdef _WIN32
# define VBCALL __stdcall
# define IMPFUN __declspec(dllimport)
# define EXPFUN __declspec(dllexport)
#else
# ifdef PLATFORM_OS390UNIX
# pragma linkage(GetIdeas, OS)
# pragma linkage(DumpParameters, OS)
# endif
# define VBCALL
# define IMPFUN
# ifdef __GNUC__
# if __GNUC__ >= 4
# define EXPFUN __attribute__ ((visibility("default")))
# else
# define EXPFUN
# endif
#else
# define EXPFUN
# endif /* __GNUC__ */
#endif /* WIN32 */
/*
* This is the common copybook for using this facility
*/
#include "template_callout_public.h"
/*
* This first example just shows a call back to issue a message.
* It does nothing else.
* The last character of the prefix (JMH....W) is the severity of
the message.
* You should use 'E' for errors, 'W' for warnings, 'I' for
information.
*/
/*
* This function demonstrates a way of seeing what parameters are
* passed to this function - both on the )SCRIPT line and in
* the lines between the )SCRIPT and the )ENDSCRIPT.
* All newlines have been stripped on input and should be left off
on
* output.
*/
for (i=0;i<pData->TEB_ParameterCount;i++)
{
sprintf(szBuffer,
"Next parameter[%d] = '%s'",
i,
pData->TEB_Parameters[i]);
(pData->TEB_WriteData) (pData->TEB_pHandle, szBuffer);
}
/*-----------------------------------------------------------------
* Copyright (C) 2008, Serena Software Europe, Ltd. All rights
reserved.
*
* No part of this software may be reproduced, stored, or
transmitted, in any
* form or by any means, without the prior permission in writing of
Serena
* Software Europe, Ltd and Serena Software, Inc.
*-----------------------------------------------------------------
* MODULE SPECIFICATION
* %PID%
* Description:
* %PD%
*%PCMS_HEADER_SUBSTITUTION_END%
*/
#ifndef TPCI_PUBLIC
#ifdef __cpluspls
#ifdef PLATFORM_OS390UNIX
extern "OS" {
#pragma pack(1)
#else
extern "C" {
#endif
#else
#ifdef PLATFORM_OS390UNIX
#pragma linkage(fReadData,OS)
#pragma linkage(fWriteData, OS)
#pragma linkage(fGetString, OS)
#pragma linkage(fSetString, OS)
#pragma linkage(fMessage, OS)
#pragma pack(1)
#endif
#endif
struct TplExtensionBlock {
void *TEB_pHandle; /* handle to use with read/
write/message */
/* READ routine
* - call this to get each line of the data up to the
* )ENDSCRIPT.
* - NULL marks the end of the script.
* - lines are terminated by a null with no newline.
* Templater symbols will have been replaced in here.
*/
fReadData *TEB_ReadData;
/* WRITE routine
* - call this to create new template lines for inclusion into
the output stream.
* - templater commands issued here will be honoured.
* - The lines should terminate with a \0 character (and no \n).
* - returns -1 on error.
*/
fWriteData *TEB_WriteData;
/* MESSAGE routine
* - Call this interface to issue messages.
* - The Message Prefix is a code which should end in a severity
(E - error, W - warning, I - information)
* - Processing will be deemed to have failed iff the callout has
written an E message back.
*/
fMessage *TEB_Message;
};
#ifdef __cplusplus
#ifdef PLATFORM_OS390UNIX
#pragma pack(reset)
}
#else
}
#endif
#else
#ifdef PLATFORM_OS390UNIX
#pragma pack(reset)
#endif
#endif
#define TPCI_PUBLIC
#endif
This sample exit has two routines implemented, and uses an include file
template_callout_public.h which will be available to customers. The first routine
just puts out a message. The second routine dumps its parameters (both the input line
parameters and the script) back into the template processor.
)SCRIPT MDHDREXX.REXX
..
..
..
)ENDSCRIPT
4 If you define a procedure, you need to add "expose (mdhexpose)" to the definition.
5 If you need to send a MsgX message, use "call mdherr 'MDHREX4700001E ...'".
6 You can specify one, two or three numbers after this space delimited. These are:
the size of the w/s the REXX interpreter needs to hold local data (in bytes)
the size of the area for storing mdhsay and mdherr messages (with some
overheads for control) in bytes.
the number of lines the REXX occupies.
These numbers default to 32000, 32000, and 2000. These values are the minimum;
if you specify less it will not get used.
)SET URL=http://www.serena.com/splat/bim/bam
)SCRIPT MDHDREXX.REXX
url="%URL."
parse var url "http://" . "." company "." .
call mdhsetvar "COMPANY",company
)ENDSCRIPT
COMPANY = %COMPANY.
Rexx example 2 This example reverses the slashes, "/" to "\" in an array
)VECTOR DMPATH(5)
)SET DMPATH(0)=/a/1/x/fo.c
)SET DMPATH(1)=/b/2/x/fo.c
)SET DMPATH(2)=/c/3/x/fo.c
)SET DMPATH(3)=/d/4/x/fo.c
)SET DMPATH(4)=/e/5/x/fo.c
)SCRIPT MDHDREXX.REXX
i=0
)REP DMPATH
tmp = "%DMPATH."
tmp=translate(tmp,"\","/")
call mdhszy ")SET DMPATH("i")="tmp
i=i+1
)ENDR
)ENDSCRIPT
)REP DMPATH
%DMPATH.
)ENDR
For example
will create a series of variables ppxxxxx each of which is an array with one row
describing each member of the specified dataset in turn. The pp denotes a user-settable
prefix.
Once this command has been executed, additional variables are available in the template
processor symbol table. These are prefixed DMCS by default, but there as an option to set
a user specified value (pfx).
These variables can then be used within a )REP—)ENDR block to provide one-match-at-
a-time logic.
Background
To provide better support in Dimensions CM for:
Enhanced scripting.
Automated testing.
XML/SOAP interfaces.
in conjunction with the need to find a better solution to that of using message scraping
mechanisms to retrieve important data, led to the idea of passing back another type of
object from the Dimensions CM command interface.
Key features
The structured information return feature is optional.
The structured object can be requested (through an alternate outargs structure for
the COMMAND RPC) and will then be created for any command that has a request
structured in this way.
On the server end, the symbol table is added prior to command processing and
deleted after command processing.
On the client end, there is, by default, initially no symbol table. Local commands
have been added to control symbol table processing. Once symbol table processing
is turned on, there are always two symbol tables:
• a persistent one, which is explicitly added to as execution progresses, and
• a symbol table resulting from the last remote command RPC issued.
In addition, symbolic replacement is performed on the remote command lines to be
passed to the Dimensions Server for execution.
The structured object minimally contains a return code (a number which indicates
the success or otherwise of the operation, 0 means total success).
The structured object will have values added to it dependent upon the processing of
the particular command. An example command which has this feature is the
command used to create a change document.
Since these enhancements have been made in the client API library, all interfaces
using this can take advantage of this feature. For example, it can be used from:
• The desktop client in the command window.
• dmcli
• The z/OS batch command client.
Commands
SPPM
The SSPM command has the forms:
SSPM DBOTH
SPPM DPERSISTENT
SPPM DTEMP
SPM NONE
SSPM OFF
SSPM ON [/USER_FILENAME="file"]
SSPM DUMP /USER_FILENAME="file"
SSPM DBOTH
SPPM DPERSISTENT
SPPM DTEMP
In any command line, if SSPM processing is enabled, then the special character '&' will
mark the start of a parameter name and '.' character the end. The text between the '&'
and the '.' characters is used as a symbol for lookup in the local symbol table and then
the persistent symbol tables and is replaced. The form '&&' is replaced by ’&' and then
just passed.
SAVE
The commands:
or
SAVE sym1 /LIT[ERAL]=value
SAVE sym1 /LIT[ERAL]=(value1,value2,,,)
will cause the value of sym2 to be added to the persistent symbol table as sym1. The
special form SAVE sym1 will lookup sym1 in the local symbol table and save it to the
persistent symbol table. The optional qualifier of /LITERAL= can be used to create a
literal set command.
Introduction 234
Using Build Templates with Build Configurations 237
High Level Build Templates 238
Compilation Templates 245
Link Templates 248
Collection Templates 254
z/OS Return Codes 256
Miscellaneous Examples of Using Build Templates 256
Introduction
This chapter describes how to write build templates. A build template is a customizable
text file containing variables and control words that is processed and expanded when you
run a build. You can use build templates to control the execution of build steps in
Dimensions Build. Dimensions Build is a build management, execution, and monitoring
tool that is part of Serena® Dimensions® CM.
NOTE For information about extending templates with user written functions, see page
217.
Platforms
This chapter discusses MVS build templates separately from distributed build templates.
For distributed platforms the syntax for UNIX and Windows is very similar and Windows
examples are used. USS templates on the UNIX side of z/OS are identical to UNIX
templates.
Examples
Where the contents of example templates are supplied the side-head in the left margin
clearly states if it is a Windows or MVS template, for example:
Default Locations
The default locations of the templates are:
Distributed platforms: %DM_ROOT%\templates
MVS platforms: %INSTANCE%.TEMPLATE
If the templates are under Dimensions CM source control they can be in a build area or
the search path of a deployment area.
Pre-Requisites
To understand the concepts discussed in this chapter you require prior knowledge of the
following:
Setting up build configurations, running and monitoring build jobs, the Primary Batch
Execution Monitor (PBEM), and the Secondary Batch Execution Monitor (SBEM). For
details see the Dimensions CM Build Tools User’s Guide.
Dimensions deployment including projects and areas. For details see Introduction to
Dimensions CM.
The template syntax used in build templates. For details see "The Templating
Language and Processor" on page 177.
Source control can apply to high level templates. You should set up build configurations to
include all the source files needed for the whole build, using wildcard patterns.
Dimensions keeps a search path of deployment areas up to date, or Dimensions Build can
populate a work area at build time. If the configuration is setup properly a set of created
targets can be collected and preserved in Dimensions CM after a build.
All features of the configuration are available to the template but their effect depends on
the tool being used. For example, the search path will only be searched for source files if
the tool allows such operations to be defined.
Compilation Templates
A compilation template configures a finely tuned compile operation including inputs,
outputs, and options. Typical examples are compiling a single source file or pre-processing
a single input. A compilation template can include multiple inputs and outputs but is not
intended to iterate over multiple steps. For more details see page 245.
Collection Templates
Collection templates capture the common LINK paradigm where a set of objects of the
same type are combined. This build configuration can contain multiple inputs and outputs,
but the core of the operation is a loop, where each object in turn is combined to create the
output. These operations are typical towards the end of a build where they collect
together intermediate targets created earlier. For example, collecting a set of obj files
into an exe file using a linker. For more details see page 254.
Other Templates
Dimensions Build includes the following system templates that are not build templates:
Area pre and post templates
Area pre and post templates are properties of an area definition and are executed
when objects are moved around in Dimensions controlled areas. For details see
"Deployment Area Scripts" on page 277.
Build pre and post templates
Build pre and post templates are properties of a build configuration and run before
and after a build. They are identical to build templates though their purpose is not to
create targets. Usually a pre template sets up a build and a post template cleans up
after a build has executed.
NOTE The PBEM always tries to optimize a build process by only building what is
required. To rebuild all targets irrespective of their timestamps set the symbol
DMREBUILDALL to 'Y' in the Build Options section of a build configuration or in a
template using a )SET statement.
For details about the PBEM architecture see the Dimensions CM Build Tools User’s
Guide.
Secondary Batch Execution Monitor
The SBEM is a standalone MVS only program that reads in JCL and executes the JCL in
a controlled environment. This allows inputs and outputs of a compile step to be
automatically detected by examining when files are opened and closed.
The SBEM runs a build step in a controlled environment to generate dependency
information that details all the source files that were used. The SBEM is invoked by a
standard SBEM template called TEMPLATE(MDHBSBM0). The SBEM introduces extra
syntax to a template to control its operation and is described on page 241.
For details about the SBEM architecture see the Dimensions CM Build Tools User’s
Guide.
Bill of Materials (BOM)
The BOM is an XML report file detailing all the components the went into a build. The
physical creation of this file is controlled by the template TEMPLATE(MDHBBOM0) that
is only shipped with MVS. For details see page 244.
CANCEL
When a build timeout occurs, or you cancel a build, a template is executed that
cancels all current build steps. This template is called:
• MVS: TEMPLATE(MDHBEND)
• Windows: pbem_stop.cmd
• UNIX: pbem_stop.sh
Openmake
To support Openmake in Dimensions Build the following build templates are provided:
• MVS: TEMPLATE(MDHBOMT0)
• Windows: bldtplt.cmd
• UNIX: bldtplt.sh
For details about using Openmake search paths see page 242. For details about
writing Openmake templates see page 261.
Build Options
A transition step defined in a build configuration can be expressed as a set of options with
pre-defined special names that encode what the step does. For example, the option
DMINPUT contains the names of the input files.
You can also add pre-defined options to a configuration or specify new options. These are
available to the template at expansion time and can be used to allow a single fixed
template to be used in a very flexible way. For example, you can inject options directly
into compiler option strings, or use other options as conditional triggers, causing arbitrary
changes in the way the template is expanded.
A build option group is a logical collection of build tool options that are passed to the build
engines and templates that execute builds, for example, Compile_Options or
Link_Options.
A transition rule template describes a generic rule for building an item and applying it to
specific source items at a later time. It describes how to change or transition an item of
one type (for example, *.c) to an item of another type (for example, *obj) using a
template or script.
TIPS
To check what actions a build step has performed, inspect the script that expanded
the template. To check what actions a build step will perform, inspect the original
template.
To understand the examples used in this chapter, you must have a solid working
knowledge of the template syntax. For details see page 177.
The simplest case of a distributed high level build template is a script that is invoked
directly from a shell or DOS prompt. Any valid scripting technique will work including
executing further scripts or .bat files that are present in the search sequence. The
statements are processed by the default shell and can use any programming structures
normally available in that language.
The simple one line example below runs an Ant script. Assume that the build area
contains a file called build.xml that controls a large java build. In the build configuration
the inputs are *.java and the outputs are *.war or similar.
Variables
Variables are the central feature of a build template. You can enhance a template by using
variables from a build configuration to insert values, for example:
You can also use the variables to drive build logic used in IF statements:
When you use templates there can be problems with special characters when there is a
conflict between the script language and the templater. For example, by default template
variables are introduced with %, which is also used by DOS. You can work around this
issue by turning off template expansion as follows:
Sometimes this solution is not enough. To mix template variables with other syntax you
may need to use the )ATTR command to change the special characters that the template
uses. In the example below, PATH is a DOS variable and DMPATH is a template symbol:
You can also use special characters twice though this produces results that are more
difficult to read:
Sometimes you might need a particular element. The example below gets the first
element of the search path.
Occasionally you might want to test the filename inside a loop to find items that match a
criteria. A common criteria is to loop around all inputs and find all those that match a
particular type. This is the purpose of the MDHEXTRACT function, which can break a
filename into pieces so that they can be compared (only on MVS and UNIX)
NOTE To find a given unique file in a list and search for it in the search path, use the
MDHDSN function. For details see page 208.
A common technique is to build up a larger structure from a list of files or directories. The
example below makes a single list from all the elements of DMINPUT.
The example below creates an MVS concatenated DDNAME from the same array.
//SYSUT1 DD DISP=SHR,DSN=AAAA.COBOL
// DD DISP=SHR,DSN=BBBB.COBOL
// DD DISP=SHR,DSN=DDDD.COBOL
// DD DISP=SHR,DSN=EEEE.COBOL
Asynchronous Templates
UNIX and Windows build templates can run synchronously or asynchronously. MVS
templates must run asynchronously as they become batch jobs using JCL. A small piece of
template syntax is required to allow the asynchronous task to communicate back to the
controlling build monitor (PBEM) when it has completed.
The standalone utility bldcomms, which is supplied with Dimensions CM, can communicate
with the PBEM or a Dimensions Build server depending on the parameters that you specify.
The MVS version of bldcomms is MDHLBLCM.
The example below shows how to use bldcomms on distributed systems to communicate
with the PBEM:
Windows template …
…
)SET RC = <result of the step>
…
)IF %DMRUNMODE. = ASYNC
)CM
)CM the following is a single line command!
)CM
bldcomms monitormessage %DMPBEMNODE. %DMPBEMPORT. "R=%RC. I=%DMSTEP.
T=%DMYEAR.%DMMONTH.%DMDAY.%DMHOUR.%DMMINUTE.%DMSECOND.%DMMICROSEC."
)ELSE
exit %RC.
)END
In this example the result is RC. When run synchronously this is the return from the
template. When run asynchronously this return is part of a message passed back to the
PBEM. The other variables used in this example are pre-set by Dimensions CM and
described in "The Templating Language and Processor" on page 177.
On MVS you can use a JCL equivalent of the above example. However, the continuation
rules for JCL are complicated and alternatively you can use the SBEM component on MVS,
see page 241 for details. To run from plain JCL without the SBEM do the following:
To create an MVS high level style build step add the above JCL to an existing JCL
procedure. The JCL runs normally and tells the PBEM when it has finished.
For additional details about bldcomms and MDHLBLCM see the Dimensions CM Build Tools
User’s Guide.
In the example above note how the DMEXECENV special variable gets the JCL in the file
embedded inside the actual runtime JCL, which runs the SBEM.
The SBEM has syntax to control the generation of the BOM and the detection of inputs, for
more details see "Creating a BOM from the SBEM" on page 244.
NOTE To avoid problems with the COBOL compiler, you must explicitly define SYSOUT
DD in the build template.
It you write a procedure to support search paths you can use the Dimensions deployment
areas model to efficiently manage the hierarchy of build areas in a typical setup where
most files are at the RELEASE level and a few active versions are at TEST.
Openmake supports search paths but in an indirect way. You can only define the named
search path in Openmake itself, and only the name of this object is passed in the build
configuration. The Openmake search path is not automatically created from the contents
of the DMPATH array.
The example below shows how to use a make script template on Windows with a search
path. The script itself is the makefile and DMEXECENV ensures that it is run through make
and not the normal shell. The make vpath statement is generated from the DMPATH array
that causes make to search for objects in the search path.
Messaging
When you run in asynchronous mode the steps communicate back to the PBEM using the
bldcomms utility. In both asynchronous and synchronous modes the PBEM then
communicates with Dimensions Build server to update it about the progress of the build.
Dimensions Build displays build messages in the Task column of the Build Monitor Events
section of the Build Job Details dialog box (which appears after you start a build).
You can specify messages for a particular step by providing the PBEM with a meaningful
description string that is used instead of the generic message. To supply a message, set
the variable DMTASKNAME to the required string and optionally add other variables:
You can also send messages directly from the template that is executing to Dimensions
Build. The purpose of these messages is to report on the progress of long steps. For
example, a large make script could send a message for every sub-directory that it starts
to build or for every target it creates. To send these types of messages use the bldcomms
utility but with different parameters:
There are many parameters for bldcomms, however the key ones are the last three string
fields that you can be use for any message. The messages also appear in the Build
Monitor Events section of the Build Job Details dialog box. For more details about
bldcomms see the Dimensions CM Build Tools User’s Guide.
NOTE Due to limitations in the length of the PARM field you cannot use the above
technique with the MVS MDHLBLCM utility from an MVS build template.
You can also use scripts to directly set the same variables:
For a UNIX/Windows template these options refer to the stdout and stderr streams.
On MVS you can use the same flags but you need to use SBEM directives to insert the
specific data set names containing the listings or error reports into the BOM. You can also
choose the file to be used for the output. For example, in a compile you can specify a full
compile listing such as stdout or a smaller summary list.
In the example above Assembly_Listing specifies a listing type for this target. Without
this SYSPRINT will be interpreted as a target and not a listing. This parameter is optional
and can have any value. If it is not defined the SBEM will consider it to be a normal target
such as a load module.
NOTE The dependencies listed in a BOM can also refer to header files discovered during
a compile process that are not specified in a build configuration.
To generate a BOM you need to indicate the presence of the BOM to the PBEM by setting
the variable DMOBOMRPT to the data set name. The supplied PBEM and SBEM templates on
MVS create container PDSs that store the BOMs so that they are unique across parallel
steps and parallel builds. However, you can changed this to any scheme. The example
below uses different member names in a private PDS that already exists:
This example triggers a different mode of output collection where the process is driven by
the contents of the BOM, and creates relationships between all the items listed in the
BOM. Without a BOM, only the items specifically mentioned in the build configuration will
be collected into Dimensions CM. For information about upload rules see the Process
Modeling User’s Guide. For information about virtual items see the User’s Guide.
END
//*SBEM END I=<step> T=<timestamp>
A single END directive indicates success or failure, brings the job to an end, and
sends a message to the PBEM. A common ending for an MVS template would be:
//….
)SET TIMESTAMP=%DMYEAR.%DMMONTH.%DMDAY.%DMHOUR.%DMMINUTE.
)SET TIMESTAMP=%TIMESTAMP.%DMSECOND.%DMMICROSEC.
//*SBEM END I=%DMSTEP. T=%TIMESTAMP.
)SET DMEXECENV=TEMPLATE TEMPLATE(MDHBSBM0)
CDE
//*SBEM CDE [MAX/IGNORE/FAIL]
Controls how the return code from the current step affects the return code for the
whole job.
• MAX accumulates the MAX code of all steps.
• IGNORE means this step does not count.
• FAIL means this step must return 0 or be considered a failure.
DEP
//*SBEM DEP DDNAME [(*)]
Creates a dependency. This is a file that the current process needs to work, such
as a copy book used during a Cobol compile.
You can manually add explicit dependencies, in which case the DDNAME must refer
to a readable file (rather than a container). In this case multiple DEP statements
are allowed.
If (*) is coded the SBEM will monitor disk activity on that DDNAME and look for
open members.
SRC
//*SBEM SRC DDNAME [(*)]
Similar to DEP but declares a DDNAME to be an input to the process. Usually this will
correspond to an item listed as an input in the build configuration. Note that this
names an actual input. By this stage the search path resolution has been
performed so that this becomes the name where the input is located even if it is
higher up the search path.
TGT
//*SBEM TGT DDNAME [(*)] [listing-type-name]
Similar to SRC and DEP. Usually used without (*) to indicate the DDNAME of the
step that is the output of the process, such as an OBJ deck from a compile.
Can be used with (*) in which case the SBEM will detect members written to that
DDNAME. The optional listing type name causes this output to be treated as a listing
type. The type name does not matter.
Compilation Templates
The main part of a compilation template is choosing the correct filenames for the inputs
and outputs according to the build configuration. There can be multiple inputs and outputs
of different types.
When you create a build configuration in Dimensions Build you can specify any names for
inputs and outputs. Templates that you write must honor those names. For each input of
a particular type find the name specified in the build configuration for that object. Then
search for that item in the search path, which is possibly a list of locations. This gives the
actual on-disk name of the object that you want to use as your input file.
The key to writing a compilation template is the operation of built-in functions and the
array variables that capture the essence of the configuration:
DMPATH is an array of the search path. The first element is the build area where the
build is occurring.
DMINPUT is an array of input files.
DMTARGET is an array of target files.
_MDHDSN_ is a function for dealing with the above arrays.
_MDHEXTRACT_ is a function for dealing with individual filenames.
The operations you typically see at the start of a compilation template are as follows.
Windows Example
The example below is a complete Windows compilation template:
MVS Example
The process for writing compilation templates on MVS is very similar to that on Windows
as the template inline helper functions (MDHDSN and MDHEXTRACT) work on data sets as
well as files. The main difference is the actual build process, which uses JCL. In JCL you
typically create a concatenated DDNAME for the input sources and add SBEM directives to
pick up any additional inputs.
// DD DISP=SHR,DSN=SYS1.MACLIB
//SYSUT1 DD UNIT=SYSDA,SPACE=(CYL,(10,10))
//SYSUT2 DD UNIT=SYSDA,SPACE=(CYL,(10,10))
//SYSUT3 DD UNIT=SYSDA,SPACE=(CYL,(10,10))
//SYSUT4 DD UNIT=SYSDA,SPACE=(CYL,(10,10))
//SYSPRINT DD DISP=SHR,DSN=%CUR..ASMLIST(%PRM.)
//SYSTERM DD DISP=SHR,DSN=%CUR..ASMTERM(%PRM.)
//SYSLIN DD DISP=SHR,DSN=%CUR..%DST.
)CM
)CM -------------------------------------------
)CM
)CM SBEM Control
)CM
)CM -------------------------------------------
)CM
//*SBEM SRC SYSIN(*)
//*SBEM DEP SYSLIB(*)
//*SBEM TGT SYSLIN
//*SBEM TGT SYSPRINT Assembly_Listing
//*SBEM CDE MAX
)CM
)CM -------------------------------------------
)CM
)CM Call SBEM
)CM
)CM -------------------------------------------
)CM
)SET TIMESTAMP=%DMYEAR.%DMMONTH.%DMDAY.%DMHOUR.%DMMINUTE.
)SET TIMESTAMP=%TIMESTAMP.%DMSECOND.%DMMICROSEC.
//*SBEM END I=%DMSTEP. T=%TIMESTAMP.
)SET DMEXECENV=TEMPLATE TEMPLATE(MDHBSBM0)
Link Templates
A link template is similar to a compilation template. The main difference is that link
templates are mainframe only. The following lines perform the same function as they do
in a compilation template:
The lines identify the DD names of the dependency modules you are interested in
discovering during the link. This process is done using a DESERV exit which is compatible
with DFSMSMVS 1.3 or above. While the link template is executing, this exit will monitor
all disk access performed on these DD names and report the data set and member names
that were accessed. This information is then returned to Dimensions via the BOM report.
Example
)CM (c) Serena 2008
)CM Common link template
)CM - implements footprinting
)CM - used by both MDHBLNK0 and MDHBLNK1
)CM
)IM TEMPLATE(MDHBSTD0)
)IFNDEF DMLNKMULTI
)SET DMLNKMULTI=NO
)ENDIF
)SET DMSAVESTDERR=NO
)SET DMSAVESTDOUT=YES
)SET CURDIR=%(DMPATH(0)).
)SET CURDIR=_MDHEXTRACT_(+r+n.+t,%CURDIR.)_
)SET DMOBOMRPT=//%DMBOMDSN.(B%DMSTEP.)
//*+------------------------------------------------------------------+
//** *
//** LINK - CONSTRUCT THE FINAL PRODUCT FROM THE SYSLIN DATA *
//** SUPPLIED BY THE APPLICATION *
//** *
//** The FOOTPRINT is information which describes the baseline *
//** or workset from which the dimensions components were used. *
//** *
//** This information is dropped into a CSECT which can be browsed *
//** or dumped at your leisure. *
//** *
//*+------------------------------------------------------------------+
)IFNDEF LPARM
)SET LPARM=
)ENDIF
//* Inputs:
)REP DMINPUT
//* Input - %DMINPUT.
)ENDR
//* Path:
)REP DMPATH
//* Path element - %DMPATH.
)ENDR
)SET SRCLOC=_MDHDSN_(,DMINPUT,SYSLIN,DMPATH)_
)SET SRCMOD=_MDHEXTRACT_(+n,//%SRCLOC.)_
)SET TGTMOD=_MDHDSN_(,DMTARGET,LOAD,)_
)SET DMTASKNAME=S%DMSTEP. Link %SRCMOD.
)SET DMOSTDOUT=//%CURDIR..LNKTERM(%SRCMOD.)
)IFDEF DMFOOTPRNT
)SET PRELKOPT=-f
)ELSE
)SET PRELKOPT=
)ENDIF
)IF %DMLNKMULTI. = NO
)SET UOPT=-u0
)ELSE
)SET UOPT=-u1
)ENDIF
//*
)SET THSDIR=_MDHEXTRACT_(+r+n.+t,%DMPATH.)_
//%NAME. DD DISP=SHR,
// DSN=%THSDIR..IMPORT
)SET NAME=
)ENDR
// DD DISP=SHR,DSN=CBC.SCLBSID
// DD DISP=SHR,DSN=CEE.SCEELIB
//SYSLMOD DD DISP=SHR,
// DSN=%CURDIR..%TGTMOD.
//MDHFLAT DD DISP=SHR,
// DSN=%CURDIR..MDHFLAT(%SRCMOD.)
//MDHLPRNT DD SYSOUT=*
//MDHTTRC DD SYSOUT=*
//*
)IFDEF DMFOOTPRNT
//*
//* Construct a foot print
//* - this can have several components
//*
//FPMAKE EXEC PGM=ASMA90,
// PARM='RENT,LIST,OBJECT'
//SYSPRINT DD SYSOUT=*
//SYSUT1 DD UNIT=SYSDA,SPACE=(CYL,(1,1))
//SYSUT2 DD UNIT=SYSDA,SPACE=(CYL,(1,1))
//SYSUT3 DD UNIT=SYSDA,SPACE=(CYL,(1,1))
//SYSUT4 DD UNIT=SYSDA,SPACE=(CYL,(1,1))
//SYSLIB DD DISP=SHR,DSN=SYS1.MACLIB
// DD DISP=(OLD,PASS),
// DSN=&&TEMPPDS
//SYSLIN DD DISP=(NEW,CATLG),
// DSN=%DMMVSUSR..TEMP.%DMUNIQUE..M%DMMICROSEC..FOOTPRNT,
// LRECL=80,BLKSIZE=3120,RECFM=FB,DSORG=PS,
// SPACE=(TRK,(2,5))
//SYSIN DD *
MDHAFOOT TITLE 'Footprint'
*
* The serena footprint is extensible - you can
* add your own sections if you want. All sections
* are described by a little table scanned by a vector
*
* TAble entires look like this
*
TABENT DSECT
FPSECT DC 0D
FPSECTVN DS CL8 'SERENA' for standard ones
FPSECTID DS CL8
FPSTART DC A(0)
FPLEN DC A(0)
TABENTLN EQU *-TABENT
MDHAFOOT AMODE 31
MDHAFOOT RMODE ANY
MDHAFOOT CSECT
DC CL24'SERENA FOOTPRINT'
FTPRNVEC DC A(SECTS,TABENTLN,SECTSE-TABENTLN)
*
* Table of footprint information
*
SECTS DS 0D
DC CL8'SERENA '
DC CL8'CLASSIC '
DC A(OLDSTYLE)
DC A(OLDSTYLEE-OLDSTYLE)
*
DC CL8'SERENA '
DC CL8'FOOTPRNT'
DC A(NEWSTYLE)
DC A(NEWSTYLEE-NEWSTYLE)
*
DC CL8'SERENA '
DC CL8'SYSLIN '
DC A(SYSLIN)
DC A(SYSLINE-SYSLIN)
SECTSE EQU *
*
* Old style footprint (just a string) is here
*
OLDSTYLE DS 0D
)SLICE DMFOOTPRNT DMFOOT
)REP DMFOOT
DC CL32'%DMFOOT.'
)ENDR
OLDSTYLEE EQU *
*
* New style footprint (name of footprint doc
* checked into dimensions) goes here
*
NEWSTYLE DS 0D
)SLICE DMFOOTPRINTDOC DMFPNAME
)REP DMFPNAME
DC CL32'%DMFPNAME.'
)ENDR
DC CL1' '
NEWSTYLEE EQU *
*
* Link deck goes here
*
SYSLIN DS 0D
DC CL80'***START***'
COPY LINKDECK
DC CL80'***END***'
SYSLINE EQU *
END
/*
)ENDIF
//*
//* Link the lot
//*
//LINKEDIT EXEC PGM=IEWL,
// PARM='LET,LIST,MAP,XREF,TERM,OPTIONS=LNKOPT'
//*SBEM DEP OBJECT(*)
//*SBEM DEP LNKLIB(*)
//*SBEM DEP IMPORT(*)
)IF %DMLNKMULTI. = NO
//*SBEM TFP SYSLMOD(*)
)ELSE
//*SBEM TFP SYSLMOD(*)
)ENDIF
//*SBEM TGT SYSDEFSD(*)
//*SBEM TGT SYSPRINT Final_Link_Listing
//*SBEM CDE MAX
//LNKOPT DD *
)REP LPARM
%LPARM.
)ENDR
/*
//SYSPRINT DD DISP=SHR,
// DSN=%CURDIR..LNK2LIST(%SRCMOD.)
//SYSTERM DD DISP=SHR,
// DSN=%CURDIR..LNKTERM(%SRCMOD.)
//SYSUT1 DD UNIT=SYSDA,SPACE=(CYL,(10,10))
//SYSUT2 DD UNIT=SYSDA,SPACE=(CYL,(10,10))
//SYSUT3 DD UNIT=SYSDA,SPACE=(CYL,(10,10))
//SYSUT4 DD UNIT=SYSDA,SPACE=(CYL,(10,10))
//CSSLIB DD DISP=SHR,DSN=SYS1.CSSLIB
//SYSDEFSD DD DISP=SHR,
// DSN=%CURDIR..IMPORT
//* USE AUTOCALL TO RESOLVE SYSTEM EXTERNALS ONLY
//SYSLIB DD DISP=SHR,DSN=ISP.SISPLOAD
// DD DISP=SHR,DSN=CEE.SIBMCALL
// DD DISP=SHR,DSN=CEE.SCEELKED
// DD DISP=SHR,DSN=CEE.SCEELKEX
// DD DISP=SHR,DSN=CEE.SCEECPP
// DD DISP=SHR,DSN=CEE.SCEELOCX
// DD DISP=SHR,DSN=ISP.SISPLOAD
)SET NAME=OBJECT
)REP DMPATH
)SET THSDIR=_MDHEXTRACT_(+r+n.+t,%DMPATH.)_
//%NAME. DD DISP=SHR,
// DSN=%THSDIR..OBJ
)SET NAME=
)ENDR
)SET NAME=LNKLIB
)REP DMPATH
)SET THSDIR=_MDHEXTRACT_(+r+n.+t,%DMPATH.)_
//%NAME. DD DISP=SHR,
// DSN=%THSDIR..LNKLIB
)SET NAME=
)ENDR
//SYSLIN DD DISP=SHR,
// DSN=%CURDIR..MDHFLAT(%SRCMOD.)
)IFDEF DMFOOTPRNT
//MDHAFOOT DD DISP=(OLD,DELETE),
// UNIT=SYSDA,
// DSN=%DMMVSUSR..TEMP.%DMUNIQUE..M%DMMICROSEC..FOOTPRNT
)ENDIF
)SET NAME=DEPENDCY
)REP DMPATH
)SET THSDIR=_MDHEXTRACT_(+r+n.+t,%DMPATH.)_
//%NAME. DD DISP=SHR,
// DSN=%THSDIR..DEPENDCY
)SET NAME=
)ENDR
//SYSLMOD DD DISP=SHR,
// DSN=%CURDIR..LOAD
)SET NAME=IMPORT
)REP DMPATH
)SET THSDIR=_MDHEXTRACT_(+r+n.+t,%DMPATH.)_
//%NAME. DD DISP=SHR,
// DSN=%THSDIR..IMPORT
)SET NAME=
)ENDR
// DD DISP=SHR,DSN=CBC.SCLBSID
// DD DISP=SHR,DSN=CEE.SCEELIB
//*
//* DUMP LINK LISTING TO PAPER
//*
//LNK2LIST EXEC PGM=IEBGENER
)SET TIMESTAMP=%DMYEAR.%DMMONTH.%DMDAY.%DMHOUR.%DMMINUTE.
)SET TIMESTAMP=%TIMESTAMP.%DMSECOND.%DMMICROSEC.
//*SBEM END I=%DMSTEP. T=%TIMESTAMP.
//SYSPRINT DD SYSOUT=*
//SYSIN DD DUMMY
//SYSUT1 DD DISP=SHR,
// DSN=%CURDIR..LNK2LIST(%SRCMOD.)
//SYSUT2 DD SYSOUT=*
)SET DMEXECENV=TEMPLATE TEMPLATE(MDHBSBM0)
Collection Templates
A collection template is similar to a compilation template, the main difference is an
iteration over all the inputs of the same type. For example, a normal OBJ link receives a
variable sized array of input OBJs to be linked together. The template loops over this array
and generates the correct link control cards. This is called a collection step.
Windows Example
The example below shows the key part of a Windows link template that constructs a list of
inputs that can be given to a link or copy command. Note the use of the MDHDSN function
to locate a given filename. This time only the first and fourth parameters of MDHDSN are
set, which look for a given default name in a search path.
MVS Examples
On MVS for a link you may need to generate a list of INCLUDE statements. You may also
want to add the DMPATH list of object libraries to SYSLIB.
The example below generates a concatenated input DD of all the files using the technique
described in "Handling Array Variables" on page 239. Note the similar use of MDHDSN to
the Windows example above.
The example below is extracted from a link template, the key part generates a list of
INCLUDE statements:
The example below is a DDNAME of all the OBJ search path locations:
This example allows you to construct a link JCL that is responsive to the build
configuration and does not require pre-defined link decks to be checked in as source
items.
Another possible link model, one of many, is to treat the link instructions as a source item
and the primary input to the link. This method works well if the input dependencies are
detected by the SBEM.
Mixed Inputs
In the above examples it is assumed that all the inputs in the DMINPUT array are the OBJs
that you require. If there are other inputs in the configuration of a different type, such as
a configuration named side-file, DBRM or similar, the loops around DMINPUT have to be
enhanced to only select entries of the correct type. The example below, based on the
Windows example, shows you how to do this:
The process is similar on MVS. Note that even though this is a link style collection
template you can use patterns from compilation templates. For example, if the input array
contains a single side file of the type SYSDEFSD that is needed in the link, its name can be
found from the MDHDSN function, as used in the compilation examples:
MDHSB16D112W Step <step number> Program <program> returned COND CODE = <cc>
’I’ messages are not sent back to the build log. However, ’W’ messages are sent to the log
therefore these steps are signalled to the log as an alert.
TIP If you name the steps carefully in the template you can give users a clear
understanding of the nature of the warnings.
Annotated version
1 //*
//* <<<<< REXX START
//* <<<<< REXX START
The top of the template.
2 )SET SERENA=_MDHDSN_(,DMINPUT,COB,DMPATH)_
Set the variable SERENA to the filename of the Cobol input file. Rather
than hard code the name, use the inbuilt facilities for finding it. The above
statement searches for an entry of type COB in the array DMINPUT. (If
your type is different, you'll have to change this.)
Assuming the statement finds that one of your inputs is indeed of type
COB, it will then search for this in the search path array DMPATH. This is
important when reading in files like this, as you don't know in advance
where the build is going to find the member; for example, it may be in
RELEASE.
NOTE
The above statement is also available in UNIX and Windows templates,
and works in a similar way.
3 )SET SERENA=_MDHEXTRACT_(+d,%SERENA.)_
The return from this function is a name suitable for use in UNIX allocates,
which means it will have '//' at the front, which we don't want. The
above statement "normalizes" the name into regular JCL syntax.
If you do not have a file of type COB as an input to this step, or it cannot
be found on disk, then the result is the string <NULL>, which you could
test for if you wanted. This string will give an JCL error (which is good, as
you want the build to fail in this case).
NOTE
The above statement is also available in UNIX and Windows templates,
and works in a similar way.
4 )EXPAND %%s
Start an EXPAND block that specifies a script (in this case it is just the
name of the file itself, %%S, as this will be executable in its own right). The
double '%%' is to protect the '%'from template expansion. (%% becomes
%).
This must not appear inside of a )REP, as that doesn't work.
5 /* rexx */
Start of the Rexx itself.
6 say ")EXPAND"
say "//* Hi from rexx" date()
Get Rexx to emit the ')EXPAND' instruction. This means that when the
templater processes the output from Rexx, it will expand it as if it were
further template lines, rather than just literal text.
7 call bpxwdyn "alloc fi(stu) da('%SERENA.') shr reuse"
Use BPXWDYN as a stand in for the TSO allocate command (remember that
we are not in a TSO environment at this point.). This is basically a
wrapper around the IBM SVC99 dynalloc function. The template variable
SERENA is set above to be the full data set name of the input file.
NOTE
Documentation for BPXWDYN (the IBM Dynamic Allocation Text interface)
can be found at:
ftp://ftp.software.ibm.com/s390/zos/tools/bpxwdyn/
bpxwdyn.html
The rexx stem called 's' now contains lines from the file. You can do
whatever we like with this data. In the remainder of this example, it is
demonstrated how you would put this data into some templater variables,
so the lines would be available direct from JCL using a )REP command. At
this point, you could do any rexx based logic you liked, and set flag
variables in a similar fashion.
11 do i=1 to s.0
Loop round each line of the file.
14 end
End of loop.
15 exit 0
End of rexx.
16 )ENDEXPAND
End of expand block.
The procedure is now back in templater mode, having finished with rexx.
It is also now in non-expand mode, as a by-product of the above
statement.
17 )EXPAND
Turn expand mode back on to enable further template syntax to be used.
20 //*
//* Cobol source is %LINECOUNT. lines long
//*
An example of using the new knowledge about the build input file.
)SCRIPT MDHDREXX.REXX
..
..
..
)ENDSCRIPT
Usage rules:
Instead of "say" use "call mdhsay".
Instead of "exit", use "return”.
Do not define any REXX signal handlers.
If you define a procedure, add "expose (mdhexpose)" to the definition.
If you need to send a MsgX message, use "call mdherr 'MDHREX4700001E ...'"
)SET URL=http://www.serena.com/splat/bim/bam
)SCRIPT MDHDREXX.REXX
url="%URL."
parse var url "http://" . "." company "." .
call mdhsetvar "COMPANY",company
)ENDSCRIPT
COMPANY = %COMPANY.
)VECTOR DMPATH(5)
)SET DMPATH(0)=/a/1/x/fo.c
)SET DMPATH(1)=/b/2/x/fo.c
)SET DMPATH(2)=/c/3/x/fo.c
)SET DMPATH(3)=/d/4/x/fo.c
)SET DMPATH(4)=/e/5/x/fo.c
)SCRIPT MDHDREXX.REXX
i=0
)REP DMPATH
tmp = "%DMPATH."
tmp=translate(tmp,"\","/")
call mdhszy ")SET DMPATH("i")="tmp
i=i+1
)ENDR
)ENDSCRIPT
)REP DMPATH
%DMPATH.
)ENDR
Introduction 262
Variables 263
Introduction
NOTE
For information about the templating language and syntax see page 177.
For information about Dimensions Build see the Dimensions CM Build Tools User’s
Guide.
For information about using Openmake see the documentation that was installed
with the product.
1 The build configuration, and other parts of Dimensions CM, make available variables
that describe the build that is to be executed.
3 When the Openmake utilities have completed (the template has finished executing),
the build steps created by Openmake are run. You can monitor these steps from the
Openmake knowledgebase server.
4 The final om build step communicates to Dimensions Build that the build has
completed.
5 By this stage Openmake build steps have created a BOM (bill of materials) containing
a description of all the inputs and outputs in the build. The name of this file is passed
back to Dimensions Build so that the BOM to be picked up, parsed, and the relevant
target items collected into Dimensions CM.
In the flow above the BOM is created after the entire build submitted by om has
completed. These jobs are run asynchronously with respect to Openmake.
Variables
The input to the Openmake template is a set of variables. The table below lists the
variables and their source. Some of the variables are unique to Openmake and are
provided by the build configuration as area or configuration symbols. Most of the variables
are described in one of the following documents:
Chapter 8, "The Templating Language and Processor" on page 177.
The Serena Dimensions CM Administrator’s Guide.
Introduction 268
Templates 268
Simple Synchronous Templates 268
Asynchronous Remote Jobs 270
Remote Job Template Example 271
Introduction
The Serena® Dimensions® CM REXEC command creates a remote job on a Dimensions CM
node. You can view the details of remote jobs in the Remote Jobs cluster in the
administration console, for details see the Administrator’s Guide or the administration
console help.
You can also manage remote jobs from the command line using the commands REXEC,
RDEL, and RSTAT, for details see the Command-Line Reference.
Templates
Remote job execution templates are expanded and executed on the node specified in the
REXEC command. The templates use the syntax and variables described in "The
Templating Language and Processor" on page 177. However, these are not build
templates and build specific variables are not available.
Remote job execution templates are located in the system directories specified by the
remote node dm.cfg variable DM_TEMPLATE_CATALOGn. For details about this variable see
page 215.
Parameters
The REXEC system delivers a set of variables to the template that contain information
about the context of the request. The system can also deliver additional parameters that
you can supply using the /PARAM option of the REXEC command. You can use this
technique to define remote subroutines and supply them with varying arguments at run
time.
Parameters that you supply can be single values or arrays, for example:
Template test.tpl:
synchronous templates do not connect back to the Dimensions CM server, and you cannot
use MVS batch JCL.
Feedback
Synchronous templates generate two types of feedback:
Numeric return code is reported and corresponds to the exit status of the script. 0 is
considered success.
An error string is also collected and is reported at the command prompt in the event
of a failure. You can use error strings to communicate template expansion time errors.
To see this error message, the return code has to be non-zero.
The example below is a synchronous template that returns an expansion time error
message:
When this template is executed from the REXEC command the message is displayed as
feedback. You can use this feature for messages other than error messages, as shown in
the example above. The template expansion process can use shell or Perl scripts therefore
you can make it as complicated as required.
You can also use this feature to send back listings from the remote node. The template
can allocate DMERRMSG as an array, and fill it with lines of output.
The example below is a synchronous REXEC template that returns the environment
variable PATH list in the DMERRMSG array to be displayed at the command prompt. This is
a UNIX example that uses an embedded Perl script during the template expansion time.
)VECTOR DMERRMSG(20)
)EXPAND perl %%s
print ")EXPAND\n";
@dirs = split(/:/,$ENV{'PATH'});
$i=0;
foreach $dir (@dirs)
{
print ")SET DMERRMSG($i) = $dir\n";
$i=$i+1;
}
)ENDEXPAND
)EXPAND
exit 5
The following command transcript shows an REXEC command from a Windows system
executing the above template on a Linux node. Note that inside the message feedback
from REXEC is the array of PATH locations in the UNIX host.
C:\temp>dmcli
Serena Dimensions CM 10.1.0 FT1 at 20:32:08 Wednesday 09 August 2006
Copyright (c) 1988-2006 Serena Software, Inc. All rights reserved.
Dimensions>auth /network=suse /user=xxx /password=xxxx
Operation completed
Dimensions>rexec /nobatch /nocapture /network=suse /template=t.txt
execute expanding script, cmd= perl /tmp/tpl11832-1.sh
Passing the template for execution
The return code above (1280) is 0x500. This is the UNIX shell exit code in the high word
of the result code, and importantly it is not zero.
The DMERRMSG variable is relevant during template expansion time and not during script
execution time. In the example above the Perl script does run at expand time because it is
an inline script and not an execution script. For details about template expansion see page
205.
The MVS JCL equivalent uses the batch command program, MDFLCMD. However, the
certificate on MVS is longer than 80 bytes. To use it with JCL, use the slice option to split
it into an array suitable for use as instream JCL input.
After issuing the command, the results are displayed in the administration console and
the output log from the individual Dimensions CM commands is available in the Job
Details/Job log view.
C:\temp>dir
Volume in drive C has no label.
Volume Serial Number is A8CE-8883
Directory of C:\temp
The REXEC returns. Inspection of the remote job queue shows that the job has finished
and additional log records are available:
The grabdir.tpl template shown below is for Windows, though you can port it easily to
UNIX. Although this is a Windows example, it uses Perl. To try this example, make sure
you have a version of Perl in your path. Note that there is a dm.cfg symbol on the server
controlling how many lines of log output can be attached to a remote job. Set
DM_REXEC_RESPONSE_MAX_LINES to a small number (about 50) to ensure that rouge
scripts do not fill the database with output.
)CM
)CM ===========================================================================
)CM grabdir
)CM ===========================================================================
)CM
)CM Example REXEC template
)CM
)CM Windows version
)CM
)CM 1. Lists contents of a given directory with a DOS pattern
)CM 2. For each file, creates an item in Dimensions, using supplied parameters
)CM 3. Updates remote job, and supplies the trace as a response file.
)CM
)CM Parameters:
)CM
)CM P_DIR - directory on remote node, ending in "\"
)CM P_PAT - pattern (dos format)
)CM P_BASE - base name to generate new items
)CM P_PROD - Product name
)CM P_TYPE - item type
)CM P_FORM - item format
)CM P_PART - design part
)CM P_WSD - Workset directory. If present, should end in a "/"
)CM P_CLEAN- delete working files
)CM
)CM ===========================================================================
)CM
)SET DMSAVESTDOUT=Y
)SET DMSAVESTDERR=Y
)SET DMCOMBINEOUTERR=Y
)CM
)CM ===========================================================================
)CM default the parameters
)CM ===========================================================================
)CM
)IFNDEF DM_TMP
)SET DM_TMP=c:\temp
)ENDIF
)IFNDEF P_DIR
)SET P_DIR=c:\temp\
)ENDIF
)IFNDEF P_PAT
)SET P_PAT=*.txt
)ENDIF
)IFNDEF P_BASE
)SET P_BASE=auto
)ENDIF
)IFNDEF P_PROD
)SET P_PROD=payroll
)ENDIF
)IFNDEF P_TYPE
)SET P_TYPE=txt
)ENDIF
)IFNDEF P_FORM
)SET P_FORM=src
)ENDIF
)IFNDEF P_PART
)SET P_PART=payroll
)ENDIF
)IFNDEF P_WSD
)SET P_WSD=
)ENDIF
)CM
)CM ===========================================================================
)CM create our perl script
)CM ===========================================================================
)CM
)CM
)CM ===========================================================================
)CM create the input file for the perl script
)CM ===========================================================================
)CM
)EXPAND
)CM
)CM ===========================================================================
)CM create the Dimensions commands
)CM ===========================================================================
)CM
)CM
)CM ===========================================================================
)CM EXECUTE
)CM ===========================================================================
)CM
)CM
)CM ===========================================================================
)CM cleanup
)CM ===========================================================================
)CM
)IFDEF P_CLEAN
del "%DM_TMP.\perl-%DMUNIQUE..pl"
del "%DM_TMP.\input-%DMUNIQUE..txt"
del "%DM_TMP.\output-%DMUNIQUE..txt"
del "%DM_TMP.\log-%DMUNIQUE.txt"
)ENDIF
exit 0
Introduction 278
Variables 280
Differences in Relation to Build Templates 282
Debugging 282
Other Features 282
Example 283
Introduction
NOTE For information about the templating language and syntax see Chapter 8, "The
Templating Language and Processor" on page 177.
Use these scripts when you require detailed control of a deployment, for example, to
insert rows into an external database, or to perform a bind operation on a deployed
object. The pre and post event scripts enable you to control the timing of these
operations. In the event of a failure the fail-event transfer script enables you to roll back
any external changes that you made.
NOTE
As of Serena® Dimensions® CM 10.1.1, the Dimensions CM server runs the scripts
on the node hosting the area in bulk once per command, as opposed to once per
item, which was the case for previous Dimensions CM releases. As before, when a
DPI command results in a single item transfer into one area, then transfer scripts will
be executed before and after the item transfer into the area. However, when a DPR or
a DPB command results in multiple item transfers into one area, then:
• The pre-event transfer script will be executed once before any items are
transferred into the area.
• The post-event transfer script will be executed once after all items are
successfully transferred into the area.
• The fail-event transfer script will be executed once if there were any errors
transferring items into the area or the post script failed to execute successfully.
Bulk script execution results in significant improved deployment performance.
You can store area scripts in your Dimensions repository. However, the preferred
location is on the node where the deployment area is located, in the system template
folder specified by the Dimensions configuration file (dm.cfg) symbol
DM_TEMPLATE_CATALOGn. For details about this variable see page 215. Note that this
is the configuration file that belongs to the node and not to the Dimensions server.
Areas scripts are implemented differently from build templates, which you can
execute from a build area using search paths.
Variables
IMPORTANT! Please note that the server generated scripts, described below, are not
automatically checked for syntax. Any syntax errors present in the scripts will cause the
scripts to fail to work as expected.
A set of area script template variables is created by the server and is made available to
give the context of the operation being performed. These variables are listed below, for
details see the Deploy Item command in the Command-Line Reference. The single-valued
variables represent properties common to the operation and all items being transferred.
The array-valued variables represent properties specific to each item being transferred.
Arrayed over items
DMBRANCH
DMCTIME
DMDIR
DMFILENAME
DMFORMAT
DMID
DMISDIR
DMPREFIX
DMPRODUCT
DMREVISION
DMSUFFIX
DMTRANSFERTYPE
DMTYPE
DMVARIANT
DMWSID
DMWSPRODUCT
From change set (arrayed):
DMBLNID
DMBLNPRODUCT
DMREQUEST
From original command (arrayed):
DMCMDREQUESTS
From original command (single value):
DMCOMMAND
Single Value:
DMAREA
DMAREANODE
DMCERTIFICATE
DMCMDCOMMENT
DMDJQJOBID
DMJOBID
DMJOBTYPE
DMSERVER
DMSTAGE
Testing Variables
To test the variables create a dummy area template that expands all of the variables listed
above, and execute it on items and projects. The example below is the trace output from
such a run. To get a trace similar to this, use the debugging symbols described on page
282.
16TP1021T IN DMCERTIFICATE.
16TP1034T OUT
2DC74AB5E8F698998A898CE7F049CA777D45BBD491C5D575A8C9E52E100DF39809511D50EC89E531CABCB8035
FE52F5C86A24678F4EE581073F42EF0AEFD2928B84BED26C12DD518C273778781988111E902E762B5A797343B
77E420FE76ED0A4F4D229F09583C6E9BE433BA788D2D44CE19405FC3ED275772D502168D4D75C5
16TP1021T IN DMSERVER.
16TP1034T OUT STAL-DEV-SJM3
16TP1021T IN DMAREA.
16TP1034T OUT SCRIPTTEST1
16TP1021T IN DMDIR.
16TP1034T OUT c:\temp\scripttest1\t1\
16TP1021T IN DMCOMMENT.
16TP1034T OUT Initial Revision
16TP1021T IN DMFILENAME.
16TP1034T OUT tm.c
16TP1021T IN DMTRANSFERTYPE.
16TP1034T OUT c
16TP1021T IN DMREVISION.
16TP1034T OUT 1
16TP1021T IN DMBRANCH.
16TP1034T OUT
16TP1021T IN DMFORMAT.
16TP1034T OUT TEXT
16TP1021T IN DMPREFIX.
16TP1034T OUT tm
16TP1021T IN DMSUFFIX.
16TP1034T OUT c
16TP1021T IN DMWSPRODUCT.
16TP1034T OUT PAYROLL
16TP1021T IN DMWSID.
16TP1034T OUT DIRTEST2
16TP1021T IN DMPRODUCT.
16TP1034T OUT PAYROLL
16TP1021T IN DMID.
16TP1034T OUT TM C
16TP1021T IN DMVARIANT.
16TP1034T OUT A
16TP1021T IN DMTYPE.
16TP1034T OUT SRC
16TP1021T IN DMCTIME.
16TP1034T OUT Wed Aug 09 10:20:18 2006
16TP1021T IN DMCOMMAND.
16TP1034T OUT CI "PAYROLL:TM C.A-SRC;1" /USER_FILENAME="C:\tm.c" /FILENAME="tm-01.c" /
PART="PAYROLL:PAYROLL.A;1" /WS_FILENAME="t1\tm.c" /FORMAT="TEXT" /COMMENT="Initial
Revision"
16TP1021T IN
16TP1034T OUT
Area scripts should be synchronous as the server waits for success or failure to organize
the next operation. You can have MVS batch JCL templates, but the success flag only
indicates the successful submission of the job, not its completion. In a production
environment it is unlikely that you would want a batch job submitted for each item that is
deployed.
Debugging
An error during the execution of an area script can prevent item operations from working
in the projects associated with that area. Use the following variables to help you to get the
template to execute successfully:
In the dm.cfg file on the Dimensions CM server specify the following variables:
DM_KEEP_DEPLOYMENT_SCRIPTS YES
DM_VERBOSE_DEPLOYMENT_SCRIPTS YES
These variables allow easier analysis of what happens when a server tries to execute
a template. The %DM_ROOT%/temp folder on the remote node contains evidence of any
attempted script execution, and template messages are passed back to the server in
the normal flow of messages.
In the dm.cfg file on the remote node where the deployment area is located specify the
following variable:
DM_TPLB_TTLOG YES
This variable creates more detailed trace messages from the templating routines that
expand the template. These messages appear in the console window of desktop client
when, for example, an item is deployed.
Other Features
Although performance is degraded significantly, it is possible for area scripts to use the
DMCERTIFICATE variable to gain access back to the Dimensions CM server from which the
request came. For details see page 270.
If you are going to use DMCERTIFICATE, test it carefully to avoid an endless cycle of
recursive area scripts if the area script itself causes another script to be fired, for
example, if the area script tries to perform a CI operation in the same project.
Example
The example below is a simple pre-transfer event script that records the actions being
performed into a cumulative log file.
)SET TM=%DMYEAR.%DMMONTH.%DMDAY.%DMHOUR.%DMMINUTE.%DMSECOND.%DMMICROSEC.
)REP DMDIR DMFILENAME
echo "%TM. %DMDIR. %DMFILENAME." >>c:\temp\deployment.log
)ENDR
exit 0
NOTE the script uses a repeat block (shown in bold) to correctly deal with single item
transfers as well as multiple item transfers.
NOTE This appendix discusses a number of known issues that you should keep in mind
when using DTK events.
Missing Events
Some operations are currently missing events being fired that you might expect to be
fired. The Serena® Dimensions® CM commands that are affected are listed below.
External executables called from event triggers run as the Dimensions CM proxy user
unless you have specified the -dont_use_proxy option in the dmlsnr configuration file
or the dmlsnr command line. Specifying this option causes dmappsrv processes to run as
the authenticated user instead of the Dimensions CM proxy user. This means that external
executables will run as the authenticated user; however, it also locks the dmappsrv to the
user session, which disables dmappsrv pooling.
Suitable command syntax for use with the system() C function is:
UNIX
NOTE On Windows there must be no whitespace between the DMDB value and the
ampersand (&).
Connecting to a remote server is possible, but you must specify a password to dmcli, so
this is not recommended.
The legacy command alias pcms exists for dmcli. If your existing event trigger code uses
pcms connecting to the same database as the session that called the event trigger, no
code changes should be necessary.
The following sections provide example code snippets for running dmcli through
system().
Windows Example
/* start of snippet */
status = snprintf(cmdBuf, sizeof(cmdBuf),
"set DMDB=%s&dmcli \"%s\" 1>%s 2>%s", databaseSpecifier,
dimensionsCommand, stdoutLog, stderrLog);
if (status < 0)
{
/* Command formatting error. */
}
else
{
_flushall();
status = system(cmdBuf);
}
/* end of snippet */
UNIX Example
/* start of snippet */
status = snprintf(cmdBuf, sizeof(cmdBuf),
"DMDB=%s dmcli '%s' >%s 2>&1",
databaseSpecifier,dimensionsCommand, logFile);
status = system(cmdBuf);
}
/* end of snippet */
C
A catsearch 229
account predefined template symbols 204 CDE, SBEM directive 244
action driven promotion event trigger change Dimensions CM default directory 122
approach 164 check results of Dimensions CM command 54
event mechanism 164 client architecture 22
the new event 165 complex symbol references, templating language
allocate memory 64 205
allocate zero initialized memory 62 connect silently to a Dimensions CM database
API library file names 26 140
architecture connect to a Dimensions CM database 59, 132
client 22 connection functions 130
event 23 constants
interaction between client and event architecture PCMS_BASELINE 40
23 PCMS_CHDOC 40
scope of the DTK architecture 23 PCMS_CUSTOMERS 40
array variables, high level build templates 239 PCMS_EVENT_POST_OP 149
asynchronous templates, high level build PCMS_EVENT_PRE_OP 148
templates 240 PCMS_EVENT_VALIDATE_OP 148
attribute macros 126 PCMS_ITEM 40
attributes PCMS_PART 40
system-defined 35 PCMS_REL_AFF 40
user-defined 35 PCMS_REL_BREAKDOWN 40
PCMS_REL_DEP 40
PCMS_REL_DERIVED 40
PCMS_REL_INFO 40
B PCMS_REL_IRT 40
PCMS_REL_OWN 40
bill of materials, high level build templates 244 PCMS_REL_PERMANENT 41
build templates PCMS_REL_PRED 40
collection templates 254 PCMS_REL_SUCC 40, 41
compilation templates 245 PCMS_REL_TOP 40, 41
default locations 234 PCMS_REL_USE 40, 41
high level build templates PCMS_USER 40
array variables 239 PCMS_WORKSET 40
asynchronous templates 240 contacting technical support 18
bill of materials 244
CDE, SBEM directive 244
DEP, SBEM directive 245
code snippets for running dmcli through system() time format strings 172
289 Javadoc 173
collection templates 254 job sequence number template symbols, on z/OS
compilation templates 246 204
deployment area script 283
remote job template 271
synchronous REXEC template 269
execute a Dimensions CM command 134
K
asynchronously 114
known DTK event issues
synchronously 66
missing events 288
running dmcli from event triggers 288
running external executables 288
F
find Dimensions CM objects and return complete
objects 68
L
find Dimensions CM objects and return uids 110 large file support (greater than 4Gbytes) 26
free a list of values 98 logs, high level build templates 243
free Dimensions CM object structures 99 look up symbol in structured information return
free memory 63, 135 table 89
function call results 28
M
G
MBCS 26
get attribute MDHDSN template inline function 208
definition 49 MDHEXTRACT template inline function 211
definition number 73
memory allocation 41
get attribute's list of values 50 messaging, high level build templates 242
get Dimensions CM object Multi-Byte Character Set 26
attributes 76
details by specification 96
details by uid 97
relationships 102 O
reverse relationships 100
get Dimensions CM process model information obtain
inbox user structures 82
56
role section names for a product 86
get input file description 80
user relationship subtypes 91
get request descriptions 74 user role structures 93
get the Dimensions CM command 79 obtain list of loaded DLLs and dates and times for
get the last Dimensions CM message 136 each 81
get the last Dimensions CM message (dynamic obtain values associated with a symbol 88
buffer) 137 Openmake templates
get user's current project 95 introduction 262
variables 263
I
P
include file 26
install idle checker 123 pcms_api_sql_uk.msb 142
is request object in secondary catalog 104 pcms_api.h 26
pcms_api.lib 26
pcms_api.so 26
J PCMS_ERROR 27
PCMS_FAIL 27
Java API pcms_len.h 26
Ant 173
PCMS_OK 27
CruiseControl 173
set Dimensions CM API server callback 118 Dimensions Build standard symbols
set Dimensions CM object attributes 116 %DMINPUT. 198
set file transfer mode to ASCII 139 %DMPASS. 199
set file transfer mode to binary 138 %DMPATH. 196
set server error callback 120 %DMPBEMNODE. 199
set user's current project 124 %DMPBEMPORT. 199
SIR 230 %DMRUNMODE. 199
SPPM 232 %DMSERVER. 199
SRC, SBEM directive 245 %DMSTEP. 199
structured information return (SIR) %DMTARGET. 198
background 230 %DMTOKEN. 199
key features 231 %DMXFERSOURCE. 200
SAVE command 232 directives 180
SPPM command 232 )ADJUST 180
when to use 231 )ATTR 180
substring predefined call 220 )CALL 217
system-defined attributes 35 )CALLBACK 181
)CM 181
)DELETE 221, 222
T )DUMP 181
)ELSE 182
technical support )ENDEXPAND 183
contacting 18
)ENDIF 182
template processor interface 229
)ENDR 184
templating language
)ENDSCRIPT 217
build templates
)EXPAND 184
collection templates 254
)IF 185
compilation templates 245
)IFDEF 185
high level build templates 238
)IFGROUPDEF 221, 222
introduction 234
)IFGROUPNDEF 221, 222
link templates 248
)IFNDEF 185
types of 235
)IM 185
z/OS return codes 256
complex symbol references 205 )LOAD 221, 222
default template characters 179 )LOGON 186
deployment area scripts )REP 186
debugging 282 )SAVE 221, 222
example 283 )SCRIPT 217
introduction 278 )SET 188
variables 280 )SET_PATH 189
Dimensions Build optional symbols )SET_PATH_MVS 189
DM_BUILDER_PROGRESS_REPORTING )SET_PATH_NT 189
203 )SET_PATH_UNIX 190
DM_SP_START_STAGE 203 )SETL 188
DMALTSERVER 203 )SETU 190
DMEXECENV 200 )SLICE 190
DMEXPAND 201 )VECTOR 191
DMFINAL 203 inline functions 208
DMMAXRC 202 introduction 178
DMMUSTRUN 202 job sequence number symbols, on z/OS 204
MDHDSN inline function 208
DMNOCACHE 202
MDHEXTRACT inline function 211
DMREBUILDALL 202
Openmake symbols
DMTASKNAME 201 ANT_HOME 263
DMTIMEOUT 202 DM_CURRENT_USERNAME 263
DMTLOG 203 DM_LICENSE 263
Dimensions Build predefined symbols
DM_META_DATASET 263
DMSTEPMODE 202
user-defined attributes 35
V
validate an attribute value 53
validate events 148
variables, high level build templates 238
W
windows.h 130
write specified request attachments to disk 125