I want to get a list of all products in the database using C/C API DTK. Is it possible ?
Cybersecurity
DevOps Cloud (ADM)
IT Operations Cloud
If an answer to your question is correct, click on "Verify Answer" under the "More" button. The answer will now appear with a checkmark. Please be sure to always mark answers that resolve your issue as verified. Your fellow Community members will appreciate it!  Learn more
Hello,
You can use PcmsQuery for the object type PCMS_PRODUCT to obtain UIDs of all products. Then get details per each UID via PcmsInitUid. For instance:
// "conId" is obtained via connecting somewhere above PcmsObjStruct obj = { 0 }; obj.objType = PCMS_PRODUCT; int noUids = 0; int *uids = NULL; if (PcmsQuery(conId, &obj, 0, &noUids, &uids) == PCMS_OK && noUids) { for (int i = 0; i < noUids) { if (PcmsInitUid(conId, *uids, PCMS_PRODUCT, &obj) != PCMS_OK) continue; // use "obj" to get details of Product } }--
Regards,
Alex
--
Alex Shevchenko
Sr Development Manager
Although I work for OpenText, I am speaking for myself and not for OpenText.
If you found this post useful, give it a “Like” or click on "Verify Answer" under the "More" button.
That's correct - obj.objId will be a universal member for object ID (Name) in any type of read object. Though for products that value also matches obj.productId.
BTW - there is a bug in my earlier example: "PcmsInitUid(conId, *uids,..." should be "PcmsInitUid(conId, uids[i],..." to properly iterate through UIDs
--
Alex Shevchenko
Sr Development Manager
Although I work for OpenText, I am speaking for myself and not for OpenText.
If you found this post useful, give it a “Like” or click on "Verify Answer" under the "More" button.
I try like you say.
I get noUids = 373. but obj.productId always empty also for obj.objId.
As below the code that i used :
PcmsObjStruct obj = { 0 };
obj.objType = PCMS_PRODUCT;
int noUids = 0;
int *uids = NULL;
if (PcmsQuery(conId, &obj, 0, &noUids, &uids) == PCMS_OK && noUids)
{
for (int i = 0; i < noUids; i )
{
if (PcmsInitUid(conId, uids[i], PCMS_PRODUCT, &obj) != PCMS_OK)
{
continue;
}
// use "obj" to get details of Product
printf("%s\n",obj.productId);
}
}
Which version of Dimensions CM are you trying with?
Can your current user has no privileges to access those Product(s)?
Can the code be shared to see how API is used?
--
Alex Shevchenko
Sr Development Manager
Although I work for OpenText, I am speaking for myself and not for OpenText.
If you found this post useful, give it a “Like” or click on "Verify Answer" under the "More" button.
OK. Let's sync on how we compile and execute that.
VS2015 Update 3 is installed.
I replace main() of "C:\Program Files\Micro Focus\Dimensions 14.5\cm\pcms_api\examples\progs\FetchItems\fetchitems.c" with your main() code [adjusting connection details to my local server].
I invoke from Windows | Start | "VS2015 x64 Native Tools Command Prompt".
In VS2015 command prompt: "cd C:\Program Files\Micro Focus\Dimensions 14.5\cm\pcms_api\examples\"
Then compile C file for x64 platform there:
dm_make --no-cm ARCH=WIN64VC2015 PROG=FetchItems TYPE="prog" all
This results in "C:\Program Files\Micro Focus\Dimensions 14.5\cm\pcms_api\examples\WIN64VC2015\FetchItems\fetchitems.exe". Moving that to "C:\Program Files\Micro Focus\Dimensions 14.5\CM\prog\" and executing: Products IDs are listed as expected.
If the same steps for you result in empty output at the end, please enable Dimensions CM Server SDP traces, execute the program and provide traces to Support case, so we research that further.
I also tries with x86 compilation at client installation - still proper Product listing.
--
Alex Shevchenko
Sr Development Manager
Although I work for OpenText, I am speaking for myself and not for OpenText.
If you found this post useful, give it a “Like” or click on "Verify Answer" under the "More" button.
I think that the only difference between my configuration and your configuration that you use x64 plugins and i use x86 plugins.
I use CVI/LABWINDOWS 2015 to develop interconnection between Dimension CM and C code.
I try to import my main file with all dependency files like (lib and dll) in visual Studio 2019 but always i have empty result.
Please help.