-1

I am working on SAP GUI scripting in Loadrunner.

I have one script in an Action which generates a "Delivery Number" Eg:80004600 in the script. I am able to successfully extract the value of the delivery number 80004600 in a variable called "Deliver_Number" using sap_gui functions, as shown below:

    sapgui_status_bar_get_type("Delivery_Status",LAST);
    sapgui_status_bar_get_text("Delivery",LAST);
    sapgui_status_bar_get_param("2","Delivery_Number",LAST);

I need to pass this "Delivery_Number" in the next step in a Table below:

    sapgui_table_fill_data("Table", 
        tblSAPSAMPLE_EX_OBJECT, 
        "{Delivery_Number}", 
        BEGIN_OPTIONAL, 
            "AdditionalInfo=sapgui2017", 
        END_OPTIONAL);

This can't be done as its a table and not able to take any input from a variable. Fetching the below error. enter image description here

Whereas, if the "Delivery Number" Eg:80004600 is passed via table by creating a parameter Eg:data_2.dat file, the script successfully passes.

    sapgui_table_fill_data("Table", 
        tblSAPSAMPLE_EX_OBJECT, 
        "{data_2}", 
        BEGIN_OPTIONAL, 
            "AdditionalInfo=sapgui2017", 
        END_OPTIONAL);

Parameter: enter image description here

I would like to have a code in C programming language, that can allow me to save the extracted data 80004600 i.e Delivery Number into the parameter file "data_2.dat" shown above, which can be used in the next action to pass the value to the table mentioned above. Is there any other possible way of doing this? Any aid will be really appreciated.

Angshuman Basak
  • 251
  • 1
  • 3
  • 15

2 Answers2

1

Won't work. Data files are loaded into RAM at the beginning of the script execution so any value you write to a file you will not see until the next execution (if ever). You also then have the problem of managing lock if you have multiple users writing to the same file.

Virtual Table server exists as a broker for these types of items.

Just save it to a new variable name, or even a C String instead of a LoadRunner variable, and use that C String in place of the parameter. You have many more paths to explore before resorting to Virtual TAble Server for a "within the same script" operation.

Try 1:

sapgui_table_fill_data("Table", 
        tblSAPSAMPLE_EX_OBJECT, 
        lr_eval_string("{Delivery_Number}"), 
        BEGIN_OPTIONAL, 
            "AdditionalInfo=sapgui2017", 
        END_OPTIONAL);

Try 2:

lr_save_string(lr_eval_string("{Delivery_Number}"), "data_2");

 sapgui_table_fill_data("Table", 
        tblSAPSAMPLE_EX_OBJECT, 
        lr_eval_string("{data_2}"), 
        BEGIN_OPTIONAL, 
            "AdditionalInfo=sapgui2017", 
        END_OPTIONAL);

Try 3: Assumes an appropriately declared and initialized C Variable

strcpy(MyCString, lr_eval_string("Delivery_Number"));

sapgui_table_fill_data("Table", 
    tblSAPSAMPLE_EX_OBJECT, 
    MyCString, 
    BEGIN_OPTIONAL, 
         "AdditionalInfo=sapgui2017", 
    END_OPTIONAL);
James Pulley
  • 5,606
  • 1
  • 14
  • 14
0

The below resolution worked for me: Only in Vugen, but its not working in Crontoller.

I wrote the below C Function to copy the "Delivery Number" Eg:80004600 in "data_2.dat" file.

Declare the below variables in global.sh file
char * filename;
long filestream;
Write the below code snippet after the value is extracted, Eg:Delivery_Number
    filename = "C:\\filepath\\data_2.dat";
    
    filestream = fopen(filename,"a");
    fprintf(filestream,"%s \n", lr_eval_string("{Delivery_Number}"));
    fclose(filestream);

Then I used that "data_2.dat" as a parameter{data_2}" in the next Action. It worked for me, parameter substitution successful.

So, It is possible to extract a dynamic value from one Action of the script, save it in a parameter file using C function and then use the same parameter file in another Action of the same script.

Angshuman Basak
  • 251
  • 1
  • 3
  • 15