What Condition to be used

Hi Team,

Need your advise.

I am working for SAP automation where I have to extract data from one T code in an excel sheet and send that excel sheet as attachment in email.

Once I execute the Tcode I will get the Option to click a button “TODAY” which will give me today’s data but sometime there will be no data for the day.

So if I click today, it wont proceed ahead as there is no data available, so what should I to so that if there is no data available it will directly send an email without attachment.

image

Above is the click buttom.
Do I need to give If condition/Try catch??
Please let me know how to proceed on this.

@lakshman @Pablito @SowmyaLeo

2 Likes

Fine you were almost done
Like keep the whole sequence inside a TRY block of TRY CATCH ACTIVITY
—the sequence would be once after clicking on the Today button with click activity we will be using Data scrapping method to get the data we want or any output method of fetching data and adding that to a excel
—next to this set of data fetching activity use WRITE RANGE activity and SEND OUTLOOK MAIL activity to send that excel file

—if this output fetching method works fine no worries the send outlook mail activity in TRY Block itself will send it with the file

But if that data dey hing method fails if there is no data to be obtained then it will go to CATCH block of TRY CATCH ACTIVITY, where use a SEND OUTLOOK MAIL ACTIVITY without excel file attachment

That’s all buddy
Kindly try this and let know for any queries or clarification
Cheers @Rahulsinha

2 Likes

Buddy,

what exception I need to give in Catches.

image

1 Like

Just one more addition, I have a sequence like when I click TODAY button, I will get the data then there is only an option to extrat the data into excel, so I click that hay using Type I save the file in respective folder.

BUT not the scenario is after clicking TODAY button (if there is no data) I am not able to go to the next screen. In this scenario I want to send an emails no data exist.

image

Above is the screen shot sharing which I will get if there is no data available.

Option 1:
When you click on today , I think you will be assigning a variable with the data received.
If youa re using an If block:
If variable is Nothing
Then block:
You can send an email saying no data exist.
Else block:
Contains the code of what is done with the data.

Option 2 (If using try catch block):
You can check for Image Exists and select the content you have highlighted (“No short dumps match the selection criteria”) above.
The ImageExists will return true/false
In the true block, you can send the email.

Hi
we can choose the type as System.Exception in CATCH block

Yah this can be handled with TRY CATCH block as suggested above

But if you could access that text as a element or as a image then these sequnce is activity can be used
—once after reaching the step where we will be deciding whether to proceed further to get the data or not without using TRY CATCH Block,
—use ELEMENT EXISTS ACTIVITY or IMAGE EXISTS ACTIVITY and choose that text either as element or image and get the output with a variable of type Boolean named bool_exists
—then use IF CONDITION like this
bool_exists = FALSE
If this condition is true it will go to THEN apart where we can have the sequence of getting the data and then forward that to a send outlook mail activity
Or
If that fails it will go to ELSE part where we can have only send outlook mail activity without attachment

Or if we are not able to choose that as a element or image we can go ahead with the TRY CATCH a method itself

Hope this would help you
Kindly try this and let know for any queries or clarification
Cheers @Rahulsinha

1 Like

@Rahulsinha, You can track SAP messages which appear on SAP’s taskbar. When there would be no data, it will show you a kind of message. you can check that using element exist activity. If it doesn’t show up any message then you can use trick for any other element which appears if there is any data available. Please let me know if it doesn’t work.

#HappyRobotics

@vikaskulhari Buddy, I am doing the recording where after clicking Today Button I am getting the data and continuing the recording by clicking the button to “Export to excel”.

How element exist activity will work if I put it next to TODAY button because if there is no data TODAY it will look for the “Export to excel button as per my recording sequence.”

Did TRY CATCH method helped us on this
Cheers @Rahulsinha

Yes buddy I will try it now. :slight_smile:
Can you please also let me k ow what I need to put in Final

1 Like

We don’t need to include any activities in Final block
Buddy
Once after exception occurs it will go to CATCH block where we have the send outlook mail activity without any attachment in it
Cheers @Rahulsinha

1 Like

Thanks a ton Buddy!!! :slight_smile:

1 Like

Cheers @Rahulsinha

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.