Dynamic number of name / value pair in a web_submit_data statement

Dynamic number of name / value pair in a web_submit_data statement

The number of items in web_submit_data is normally fixed during recording. It may be necessary in some cases to dynamically generate a different number of ITEMDATAs in a web_submit_data request. There is no built-in functionality for this provided in LoadRunner.

Dynamic number of ITEMDATAs in web_submit_data

You need to input each parameter separately for each name-value pair as shown below. At the end of every pair of name-value, use ENDITEM to denote that is the end of a pair.

EXAMPLE :

web_submit_data("StepName",
"Action=http://SomeAddress",
"Method=POST",
"TargetFrame=",
"RecContentType=text/html",
//"Referer=http://SomeAddress",
//"Snapshot=t4.inf",
"Mode=HTTP",
ITMEDATA,
name[0], value[0], ENDITEM,
name[1], value[1], ENDITEM,
name[2], value[2], ENDITEM,
name[3], value[3], ENDITEM,
name[4], value[4], ENDITEM,
name[5], value[5], ENDITEM,
LAST);

If the number of name-value pairs is not known ahead of time, and if it is required to construct the string dynamically, you need to reserve a maximum size array for the name-value pair and mark the last "name" array to "LAST" (e.g. name[max] = "LAST"; ). This will make sure that the replay engine will not parse anything else (the rest of the name-value pairs).

EXAMPLE :
If the name and value arrays had the following values:
name[0] = "SomeName"; value[0] = "SomeValue";
name[1] = "LAST";

Then the web_submit_data in the above sample will only replay the web_submit_data statement to the end of the name[1] statement.

web_submit_data("StepName",
"Action=http://SomeAddress",
"Method=POST",
"TargetFrame=",
"RecContentType=text/html",
//"Referer=http://SomeAddress",
//"Snapshot=t4.inf",
"Mode=HTTP",
ITMEDATA,
name[0], value[0], ENDITEM,
LAST);
Advertisements

One thought on “Dynamic number of name / value pair in a web_submit_data statement

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s