Capture a value of field only read value

447 views
Skip to first unread message

Guilherme Ramalho

unread,
Aug 25, 2014, 2:35:11 PM8/25/14
to lr-loadrunner
Hey guys

I am recording a script using sapgui protocol, and I need to capture a value of a field read and use the value in another field in sapgui.

Anyone can you help me?

Thanks.

--
Breski

Hamish Goodwin

unread,
Aug 26, 2014, 2:53:27 AM8/26/14
to LR-Loa...@googlegroups.com
Hi Breski,

This can be challenging. 

The way I've done it in the past is to start a transaction while recording, call it something related the field you want, eg "Clicking Name Field," then double click the field and end the transaction. If you're lucky that will cause VUGen to record a step. The transaction is so that you can find it easily in your script (you could use comments instead). 

You can then grab the object definition and use a sapgui_get_text on that object to get it's text and save in a parameter, which you can then use in subsequent steps. 

I'm not sure if there's a better way to get the object references, please let me know if you find one! SAPGUI has a scripting interface (which VUGen uses) so there may well be tools to do this. 

Cheers,
Hamish 

Kevyland

unread,
Aug 26, 2014, 9:19:20 AM8/26/14
to LR-Loa...@googlegroups.com
Isn't this correlation?

Since I see its SAP you probably want to search this forums topics as its been heavily discussed.

Bhavin Patel

unread,
Aug 26, 2014, 9:46:17 AM8/26/14
to LR-Loa...@googlegroups.com
Kevyland is spot on but here are steps if this is your first time.. 


1. Turn on your extended logs and run a script
2. After reply of your script search of the word you are looking for in reply log
3. use correlation function to get value you want using appropriate left and right boundaries.
4. store that value into string variable
5. now you can replace/edit that value in script..

I hope this helps. if you know how correlation works this is the same.

Pradhyumna Gupta

unread,
Aug 26, 2014, 10:11:08 AM8/26/14
to LR-Loa...@googlegroups.com
I dont remember the exact function at this time but it's something like sapgui_get_text.

basically fetches the contents of a textbox or cell. Browse through the functions and you will find it.


--
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.
To post to this group, send email to LR-Loa...@googlegroups.com.
Visit this group at http://groups.google.com/group/LR-LoadRunner.
For more options, visit https://groups.google.com/d/optout.

Pradhyumna Gupta

unread,
Aug 26, 2014, 10:54:41 AM8/26/14
to LR-Loa...@googlegroups.com
i use a tool called SAPGUI-Spy which gives the object ID of almost all objects on the screen. very handy while scripting and making changes to the script


--

Guilherme Ramalho

unread,
Aug 26, 2014, 12:22:26 PM8/26/14
to lr-loadrunner
Hey guys!

Thanks for the reply.

I captured the value of the field, and now I need to reuse this data using only the first 5 bytes (Only 17-01) of the value.

         sapgui_get_text("txtLTAP1",
        txtLTAP1, 
        BEGIN_OPTIONAL, 
            "AdditionalInfo=sapgui1017", 
        END_OPTIONAL);

Action.c(182): Notify: Saving Parameter "OPT_START = 17-01-21".

I tried to use the function below, but the LR don't recognize the parameter:

strncpy(StringAux, lr_eval_string( "{txtLTAP1}"),5);
    
lr_output_message("Parameter = %s", lr_eval_string(StringAux));

Action.c(190): Parameter = {txtL
    
Anyone know why LR don't recognize the parameter?

TIA

Breski 


--
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.
To post to this group, send email to LR-Loa...@googlegroups.com.
Visit this group at http://groups.google.com/group/LR-LoadRunner.
For more options, visit https://groups.google.com/d/optout.



--
Guilherme B. Ramalho

André Luyer

unread,
Aug 27, 2014, 6:51:00 AM8/27/14
to LR-Loa...@googlegroups.com
Hi Breski,

The name of your LR parameter is OPT_START (according to the supplied log), the name of the sapgui_get_text description is txtLTAP1. Because the name of the LR parameter is missing in the sapgui_get_text function call, BEGIN_OPTIONAL is now treated as the name of the parameter (being the third parameter).

Since there is no LR parameter called "txtLTAP1" lr_eval_string("{txtLTAP1}") will return the original string because there nothing to evaluate, and a warning is logged (using extended logging).
Next strncpy(..., 5) means "copy max 5 characters". Since the string is longer it does exactly that - thus without the terminating null-character. Your lucky if StringAux was zeroed before the strncpy.. ( http://www.cplusplus.com/reference/cstring/strncpy/ )

This will work:
lr_param_sprintf("new_param", "%.5s", lr_eval_string("{OPT_START}"));

Or this:
char *StringAux;
StringAux = lr_eval_string("{OPT_START}");
if (strlen(StringAux) > 5) StringAux[5] = 0; // truncate string
lr_log_message("Parameter = %s", StringAux);


André

Guilherme Ramalho

unread,
Aug 27, 2014, 2:04:37 PM8/27/14
to lr-loadrunner
Hi Andre

I found the problem. The parameter name  was missing in sapgui_get_text function

   sapgui_get_text("Read back the entry",
        txtLTAP1, // Control ID
        "Order", // parameter name
        LAST );

lr_output_message("%s", lr_eval_string("{Order}"));

strncpy(StringAux, lr_eval_string( "{Order}"),5);


 lr_output_message("Parameter= %s", lr_eval_string(StringAux));

After changing it, the script worked.

Thanks all.

Breski.
Reply all
Reply to author
Forward
0 new messages