Convering a substring to another substring in Corelated value

130 views
Skip to first unread message

Ruchi Dubey

unread,
Feb 13, 2013, 3:43:01 PM2/13/13
to LR-Loa...@googlegroups.com
Hello,

I am working on a SAP application and creating Web(HTTP/HTML) script.
I came acroos a strange correlation. This is SAP SID. It comes in
server response in following format

R*VV7H*UArFQjcVf*ZGhPA--Z1JulYFN4Lh23ChZeO53*w--

But when it is passed from cl;ient to server,it goes in foolowing
format. All * get replaced by *.

R*VV7H*UArFQjcVf*ZGhPA--Z1JulYFN4Lh23ChZeO53*w--

I find some c functions in which they replace a substring in a string
with another striong. But it seemstricky to write a code to deal with
multiple substrings.

Does any of you know any loadrunner function like Convert to Url
/html, which can directly make this type of conversion?

Thanks

Deepak Kashyap

unread,
Feb 14, 2013, 2:24:07 AM2/14/13
to LR-Loa...@googlegroups.com
Try using web_convert_param function if you r using Web(http/html) protocol

Warm Regards,
Deepak

Sent from my iOS
> --
> You received this message because you are subscribed to the Google Groups "LoadRunner" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to LR-LoadRunne...@googlegroups.com.
> For more options, visit https://groups.google.com/groups/opt_out.
>
>

Arul Prasath

unread,
Feb 14, 2013, 12:25:07 AM2/14/13
to LR-Loa...@googlegroups.com
hi Ruchid,
                 You can use this function :
The web_convert_param function either converts HTML text to plain text or URL, or converts plain text to URL. 
  Correct me, if i am wrong

Thanks

Bhushan Deodhar

unread,
Feb 14, 2013, 1:39:14 PM2/14/13
to LR-Loa...@googlegroups.com
if you are receiving same value in server response as sent in the request (except for the difference of #a vs. *)...why are you putting up a correlation? just convert the value in parameter file manually and use it (simple workaround)

Dinesh Reddy

unread,
Feb 18, 2013, 7:28:08 AM2/18/13
to LR-Loa...@googlegroups.com
Hi Ruchi,

Please use String token function seperated by &. You will get 5 tokens and replace the value #x2a with  using strcat function. Send it final value.

For ex:

SAP SID original value =R*VV7H*UArFQjcVf*ZGhPA--Z1JulYFN4Lh23ChZeO53*w--

You have to send R*VV7H*UArFQjcVf*ZGhPA--Z1JulYFN4Lh23ChZeO53*w--

first you need capture original value like

1)web_reg_save_param("SAPSID_1","LB=XXXX","RB=XXXX",LAST);

2)Print that value
3)lr_output_message("SAPSID_1 value= %S",lr_eval_string("{SAPSID_1}");

4)Create seperate action called Convertcode

5)There you need to use string token in a Convertcode action.
Convertcode(char* inputstr, char* outputStr)
{

    extern char* strtok(char* string, const char* delimiters ); // Explicit declaration
    char* path;
    char separators[] = "&";
    char* token;
    char p_tmp[1024];
    char temp[1024];
    char final[1024];

 
    path = inputstr;
    token = (char *)strtok(path, separators); // Get the first token

    if (!token) {
        lr_output_message("No tokens found in string!");
        return( -1 );
    }

   lr_output_message("%s", token);
   strcpy(final, token);
   while (token != NULL )
   { // While valid tokens are returned
       lr_output_message("%s", token);
       token = (char *)strtok(NULL, separators); // Get the next token
       if (token != NULL)
       {
           p_tmp[0] = 0;
           lr_output_message("tmp value is: %s", p_tmp);
           strncpy(p_tmp, token, 5);
           lr_output_message("unicode value is: %s", p_tmp);

           if (strncmp(p_tmp,"#x2a;", 5) == 0)
              {
                    strcat(final, "*");
              }
  strcpy(temp, token + 5);
           strcat(final, temp);
        }
           lr_output_message("%s", final);
    }
           lr_output_message("%s", final);

lr_save_string(final,outputStr);

   return 0;
}

6) Just call this function in your script

Convertcode(lr_eval_string("{SAPSID_1}"), "SAPSID_Convertedvalue");
    lr_output_message("SAPSID_Convertedvalue = %s",lr_eval_string("{SAPSID_Convertedvalue}"));

7)Replace this Parameter {SAPSID_Convertedvalue} in your script.

If you follow my steps, I am sure definitely you will find a solution. Still if you have any problems please let me know.

Thanks,
Dinesh Kumar
Dinesh Reddy
Reply all
Reply to author
Forward
0 new messages