How to save parameter value to other parameter in LoadRunner?

How to save parameter value to other parameter in LoadRunner?

One my reader asked me - "How to save parameter value to other parameter in LoadRunner?". OK, there is a simple solution.

To save parameter value to other parameter you have to:
  1. Evaluate value of initial parameter
    Use lr_eval_string LoadRunner function.
  2. Save the evaluated string to a second parameter
    Use lr_save_string LoadRunner function.
Please, check the following code:
// save string value to initial parameter
lr_save_string("some string value", "prmStr1");
lr_output_message(lr_eval_string("Value of prmStr1: {prmStr1}"));

// save the evaluated value to second parameter
lr_save_string(lr_eval_string("{prmStr1}"), "prmStr2");
lr_output_message(lr_eval_string("Value of prmStr2: {prmStr2}"));
Let's execute this code and check the result:
(click the image to enlarge it)

As you can see, both parameters (prmStr1 & prmStr2) have the same values - "some string value".
So, we assigned the parameter value to other parameter successfully.


Related articles:


Do you have questions on this topic - working with LoadRunner parameters?
Feel free to post them in comments.

--
Dmitry

5 comments:

Sumit said...

Hi,

Is there a way in which we can store the value of a response parameter into an external file or table for all the iterations performed.

Dmitry Motevich said...

2Sumit:
Yes, there is a way. You have to save parameter value into file using C-functions.

anoop said...

Saving the parameter value into an external text file using C functions

str=lr_eval_string("{WCSParam_Diff1}");

if ((file = fopen(filename, "w+" )) == NULL) {

lr_output_message("Unable to create %s", filename);
return -1;
}

i = fwrite(str, strlen(str), 1, file);

if ( i > 0)
lr_output_message("Successfully wrote File");

fclose(file);

Chinnadurai said...

Hi Dmitry,

How can I send SAP GUI status bar value to Table type parameter dynamically.

sapgui_status_bar_get_text("paramStatusBarText", BEGIN_OPTIONAL, "Recorded status bar text: Purchase requisition number 0010000297 created",
"AdditionalInfo=sapgui1037",
END_OPTIONAL);

sapgui_status_bar_get_param("1", "PRNO", LAST);

lr_output_message(lr_eval_string("{PRNO}"));

how can I send this 'PRNO' to the below data_1 (table type parameter)

sapgui_table_fill_data("Table",
tblSAPLMEGUITC_12112,
"{data_1}",
BEGIN_OPTIONAL,
"AdditionalInfo=sapgui1043",
END_OPTIONAL);

Thanks and Regards,
Chinnadurai R

Dmitry Motevich said...

Dear Readers!
Thank you very much for you comments!

Since this article was published more than one year ago, I've just disabled an adding of new comments for this article.