Highlighted
Honored Contributor.
Honored Contributor.
443 views

Lr_get_transaction_status not working as expected

Hello Experts,

I am working on SAP GUI protocol and on GUI protocol, when transaction fails, users are getting dropped and reducing the concurreny of users on the system. I have used "Continue on error" in Runtime setting and it works as expected..

My objective here is not to reduce users from the system, but if one transaction fails, user to exit out of the transaction and do the next iteration. So that i can reduced the fail transactions during the test.

i am trying to handle the failed transaction in my script and i am using the lr_get_transaction_status function to get the status of transaction and confition to exit if fails. Basically my code looks like below.

When i run the script, giving the wrong transaction(Instead of IW32, i am giving IW3232 which is invalid t-code in SAP) as per understanding, it should check the transaction status , fail and exit out of iteration. But it continues showing in log as transaction passed and fails at different step... 


Can you please advise if i am missing anything here or doing anything wrong.

lr_start_transaction("PTP_RWO_06_IW32");

    sapgui_set_ok_code("/nIW32",BEGIN_OPTIONAL,"AdditionalInfo=sapgui4053",END_OPTIONAL);
    sapgui_send_vkey(ENTER,BEGIN_OPTIONAL,"AdditionalInfo=sapgui4054",END_OPTIONAL);

    
    if(lr_get_transaction_status("PTP_RWO_06_IW32") == LR_FAIL){
        lr_output_message("Transaction has failed #%d",lr_get_transaction_status("PTP_RWO_06_IW32"));
        lr_end_transaction("PTP_RWO_06_IW32",LR_FAIL);
        //lr_error_message("PTP_RWO_06_IW32 failed!");
        return 0 ;
    }

 

0 Likes
2 Replies
Highlighted
Honored Contributor.
Honored Contributor.

Re: Lr_get_transaction_status not working as expected

Any suggestions/help?

0 Likes
Highlighted
Contributor.
Contributor.

Re: Lr_get_transaction_status not working as expected

Hi

Transaction "PTP_RWO_06_IW32" will be "LR_FAIL" when the steps(in the transaction) get error.

If step sapgui_set_ok_code or sapgui_send_vkey get error, I think your check "if(lr_get_transaction_status("PTP_RWO_06_IW32") == LR_FAIL)" will work.

But if the steps next to your check get error, you have to move your check next to it.

I'm not sure why you use "Continue on error" if you really want to exit current iteration when get error.

If you still want "Continue on error", but exit when transaction "PTP_RWO_06_IW32" gets fail, you have to check every step in it. Or just do the check after lr_end_transaction("PTP_RWO_06_IW32", LR_AUTO);

 

0 Likes
The opinions expressed above are the personal opinions of the authors, not of Micro Focus. By using this site, you accept the Terms of Use and Rules of Participation. Certain versions of content ("Material") accessible here may contain branding from Hewlett-Packard Company (now HP Inc.) and Hewlett Packard Enterprise Company. As of September 1, 2017, the Material is now offered by Micro Focus, a separately owned and operated company. Any reference to the HP and Hewlett Packard Enterprise/HPE marks is historical in nature, and the HP and Hewlett Packard Enterprise/HPE marks are the property of their respective owners.