Hi,

Below some sample winrunner 7.5 code to have fun with TDAPI* functions including more documentation available than you think on those funcitons.

Read your data directly from TestDirector 7.6 no need for ODBC/DB functions local installed databasedrivers etc.

Read directly your stepparams from testdirector.

Did not work thru the full SQL example just to show the possibilities.

Watch out for the size of your SQL result.

regards,

Elwin Wildschut

</font><blockquote><font size="1" face="Verdana, Arial, Helvetica">code:</font><hr /><pre style="font-size:x-small; font-family: monospace;">###################################### ######################
# Using the TDAPI functions from within WinRunner
################################################## ##########
# Author: Elwin Wildschut
# Company: Pecoma Informatica, www.pecoma.nl
# Date: February 2004
# Version: 1.0
################################################## ##########
# Advice
# - Study the tdapi lib script for the correct functions and constants
# so use MITDAPI_MOVE_NEXT instead of TDAPI_MOVE_NEXT
# - Study TDAPI.HLP and replace the ampersand (&amp with nothing to get it to work within WinRunner
# - Study the TDCLIENT.DLL from within VBA in excel or word to show the undocumented ones like TDAPI_GETBLOBFIELD
# - Study the OTAG.PDF file from testdirector
# - to know how the tablestructures are
# - to find the fieldnames you can use in SQL expressions
# - Make sure you have the correct version of TDCLIENT.DLL installed everywhere on your drive
# (about 300 KB in size not 500 KB) do a DIR TDCLIENT.DLL /S on your drive
# - It looks like you cannot nest TDAPI list functions directly
# Alternative 1
# First load all tests in an array
# Second use this array to get all the steps from the test
# Alternative 2
# see the bonus below
################################################## ##########
# This demo code dumps some testdescriptions
################################################## ##########
# This is your free bonus to have something usefull with TDAPI.
# BONUS BONUS BONUS BONUS BONUS BONUS BONUS BONUS BONUS BONUS
################################################## ##########
# Fun with another SQL statement to get the dataparameters of a file reading data directly from testdirector instead of separate datafiles
# Tables involved
# TEST, DESSTEPS, STEP_PARAMS having the following fiels one line for each table
# TS_TEST_ID;TS_NAME;TS_STEPS;TS_PATH;TS_SUBJECT;TS_ STATUS;TS_RESPONSIBLE;TS_CREATION_DATE;TS_DESCRIPT ION;TS_TYPE;TS_TIMEOUT;TS_ATTACHMENT;TS_USER_01;TS _USER_02;TS_USER_03;TS_USER_04;TS_USER_05;TS_USER_ 06;TS_USER_07;TS_USER_08;TS_USER_09;TS_USER_10;TS_ USER_11;TS_USER_12;TS_USER_HR_01;TS_USER_HR_02;TS_ USER_HR_03;TS_USER_HR_04;TS_USER_HR_05;TS_USER_HR_ 06;TS_ESTIMATE_DEVTIME;TS_TEST_VER_STAMP;TS_EXEC_S TATUS;TS_TEMPLATE;TS_STEP_PARAM;TS_VTS;TS_VC_CUR_V ER;TS_USER_13;TS_USER_14;TS_USER_15;TS_USER_16;TS_ USER_17;TS_USER_18;TS_USER_19;TS_USER_20;TS_USER_2 1;TS_USER_22;TS_USER_23;TS_USER_24
# DS_TEST_ID;DS_STEP_ID;DS_STEP_ORDER;DS_STEP_NAME;D S_DESCRIPTION;DS_EXPECTED;DS_USER_01;DS_USER_02;DS _USER_03;DS_USER_04;DS_USER_05;DS_USER_06;DS_ATTAC HMENT;DS_LINK_TEST;DS_HAS_PARAMS
# SP_ENTITY;SP_KEY;SP_PARAM_NAME;SP_PARAM_VALUE;SP_O RIGIN_TEST;SP_VALUE_FROM_ENTITY;SP_VALUE_FROM_KEY; SP_REF_COUNT;SP_ASSIGNED_BY;SP_ASSIGN_DATE;SP_ASSI GN_TIME
#
# SP_KEY should be split at ~ within this field to link to correct DS_TEST_ID;DS_STEP_ID;
# Oracle SQL functions
# SUBSTR (s, x1, x2) - Return a portion of string s starting at position x1 and ending with position x2. If x2 is omitted, it's value defaults to the end of s.
# INSTR (s1, s2, x) - Returns the position of s2 in s1 where the search starts at position x.
#
# so finally we create the following SQL string
# SELECT TS_TEST_ID, TS_NAME, SP_PARAM_NAME,SP_PARAM_VALUE
# FROM TEST,DESSTEPS,STEP_PARAMS
# WHERE
# TS_TEST_ID=DS_TEST_ID
# AND SUBSTR(SP_KEY,1,INSTR(SP_KEY,&quot;~&quot;,1)-1) = DS_TEST_ID
# AND SUBSTR(SP_KEY,INSTR(SP_KEY,&quot;~&quot;,1)) = DS_STEP_ID
# AND TS_STEPS &gt;= 1
################################################## ##########
# BONUS BONUS BONUS BONUS BONUS BONUS BONUS BONUS BONUS BONUS
################################################## ##########

#Change this to your server and project information
tmpServer= getvar(&quot;td_server_name&quot;

# Notation : SERVER as UNC like http:\\.........\wcomsrv.dll
if (index(tmpServer,&quot;.dll&quot==0)
MyServerDLL = &quot;http://&lt;WhateverIsYourServername&gt;/td...srv.dll&quot;;
else
MyServerDLL=tmpServer;

# Notation : DOMAIN.PROJECT
tmpProject = getvar(&quot;td_database_name&quot;
if (index(tmpProject,&quot;.&quot==0)
MyProject = &quot;&lt;WhateverDomain&gt;.&lt;WhateverProject&g t;&quot;;
else
MyProject=tmpProject;

MyUser = &quot;guest&quot;;
MyPWD = &quot;&quot;;

#MyServerDLL = &quot;http://SERVER/tdbin/wcomsrv.dll&quot;; # Notation : SERVER as UNC
#MyProject = &quot;DOMAIN.PROJECT&quot;; # Notation : DOMAIN.PROJECT

# Load the tdapi library
m_root = getenv (&quot;M_ROOT&quot;
report_msg(&quot;M_ROOT=&quot; &amp; m_root);
reload(m_root &amp; &quot;\\lib\\tdapi&quot;,0,1);

#Just make sure there is no server active anymore
TdServerRelease();

# Initialize the TestDirector server
if((nStatus=TdServerInitInstance(&quot;apartment&q uot;, MyServerDLL )) != TDAPI_NOERROR)
{
report_msg(&quot;Server not initialized&quot;
}

# Connect to TestDirector_Demo project
if(TDAPI_Connect(MyProject, NULL, MyUser, MyPWD) != TDAPI_NOERROR)
{
TdServerRelease();
report_msg(&quot;Not connected to project&quot;
}

#Create a list of tests, make sure that all fields you want to get are mentioned
#nStatus = TDAPI_CreateTestList(&quot;SELECT TS_TEST_ID, TS_NAME FROM TEST&quot;, ListSize);

tSQL = &quot;SELECT TS_TEST_ID, TS_NAME FROM TEST WHERE TS_STEPS &gt;= 1&quot;;

#BONUS not fully functional but the concept works
#tSQL= &quot;SELECT TS_TEST_ID, TS_NAME, SP_KEY, SP_PARAM_NAME, SP_PARAM_VALUE, DS_STEP_ID, DS_TEST_ID&quot;;
#tSQL= &quot;SELECT SP_KEY, SP_PARAM_NAME, SP_PARAM_VALUE, DS_STEP_ID, DS_TEST_ID&quot;;
#tSQL= tSQL &amp; &quot; FROM DESSTEPS, STEP_PARAMS&quot;; #
#tSQL= tSQL &amp; &quot; WHERE&quot;;
#tSQL= tSQL &amp; &quot; DS_TEST_ID=10201&quot;;
#tSQL= tSQL &amp; &quot; TS_TEST_ID = DS_TEST_ID&quot;;
#tSQL= tSQL &amp; &quot; AND SUBSTR(TS_NAME,1,2) = 'SE'&quot;;
#tSQL= tSQL &amp; &quot; AND TS_TEST_ID = SP_KEY&quot;;
#tSQL= tSQL &amp; &quot; AND DS_TEST_ID = SUBSTR(STEP_PARAMS.SP_KEY,1,INSTR(STEP_PARAMS.SP_K EY,'~',1)-1)&quot;;
#tSQL= tSQL &amp; &quot; AND SUBSTR(SP_KEY,INSTR(SP_KEY,'~',1)) = DS_STEP_ID&quot;;
#tSQL= tSQL &amp; &quot; AND TS_STEPS &gt;= 1&quot;;

nStatus = TDAPI_CreateDesStepList(tSQL, TestListSize);
#END BONUS

nStatus = TDAPI_CreateTestList(tSQL, TestListSize);

if (nStatus != TDAPI_NOERROR)
{
report_msg(&quot;Error: Cannot create list of tests.&quot;
TdServerRelease();
}
nStatus = TDAPI_TestListMove(MITDAPI_MOVE_FIRST, TestKey);

#Show the first 10
i=1;
while ((nStatus == TDAPI_NOERROR) &amp;&amp; (i &lt; 10))
{
#Get the name (should be in the SQL statement above)
nStatus = TDAPI_GetTestValue(TestKey,&quot;TS_NAME&quot; ,Value);
report_msg(i &amp; &quot;;&quot; &amp; &quot;test &quot; &amp; i &amp; &quot;;&quot; &amp; Value &amp; &quot;;&quot; &amp; TestListSize);

#Create a list of steps, make sure that all fields you want to get are mentioned
#Uncomment below
# nStatus = TDAPI_CreateDesStepList(&quot;SELECT DS_STEP_ID, DS_TEST_ID from DESSTEPS where DS_TEST_ID =&quot; &amp; TestKey, DesSepListSize);
# if (nStatus != TDAPI_NOERROR)
# {
# report_msg(&quot;Error: Cannot create list of steps.&quot;
# TdServerRelease();
# }
#
# nStatus = TDAPI_DesStepListMove(MITDAPI_MOVE_FIRST, TestKey, StepKey);
# stepCounter = 0;
# #Show the steps
# while (stepCounter = 0 )
# while (nStatus == TDAPI_NOERROR)
# {
# #Get the name (should be in the SQL statement above)
# nStatus = nStatus = TDAPI_GetDesStepValue(TestKey, StepKey, &quot;DS_DESCRIPTION&quot;, Value);
# report_msg(&quot;test step&quot; &amp; stepCounter &amp; Value);
# nStatus = TDAPI_DesStepListMove(MITDAPI_MOVE_NEXT, TestKey, StepKey);
# stepCounter++;
# }
#end uncomment

nStatus = TDAPI_TestListMove(MITDAPI_MOVE_NEXT, TestKey);
i++;
}

#Disconnect from the repository
TDAPI_Disconnect();

#Release the connection to the server
TdServerRelease();</pre><hr /></blockquote><font size="2" face="Verdana, Arial, Helvetica">

[ 02-12-2004, 01:19 AM: Message edited by: elwinwildschut ]