SAP GUI- Table extraction from SAP taking too much time

Hi ,
Working on Account payable module of SAP GUI.
On Transaction code MIRO or MIR7 there is a table at bottom in which data got populated after putting PO number in a text box available just above that table.
While extracting data through that table using data scraping takes too much time. For 250 records its taking 5 minute of time just to extract it.
Need a solution so that this 5 min for 1 transaction or to process invoice can be reduced.
Already reached to UiPath support and they also find that data scraping is extracting data very slowly but didn’t find any solution yet.

If anyone faced such issues, then please help or if anyone know how we can extract data through that table using SAP scripting?

UiPath Studio and robot Version : 2020.10.6

@gauravku

@StefanSchnell - Any suggestions ?

Other alternative: Can you check do we have any option to export that data into Excel file in SAP application. If yes then we can export the data and we can read it from Excel file.

Hi Lakshman ,
Their is no option to export that to excel in SAP application.

@gauravku

Hello Gauravku,

I assume you mean this MIRO table:

This is a SAP Standard Table (GuiTableControl). The elevator is small (yellow arrow), that means it contains a lot of fields, as far as I can see more than 100. With 250 records you transfer > 25.000 fields. The SAP Data Provider contains only the content of the visible fields and a little bit more, so that it reloads while scrolling. The amount of data and the scrolling is expensive. SAP GUI Scripting is in this case no alternative, because the automation mechanisms used by the Studio are the same, as far as I know.

I am not familiar with SAP Material Management but maybe a BAPI could be an alternative:

Best regards
Stefan

2 Likes

@StefanSchnell

Thank for your explanation! You are right!

In the case above, we are speaking about the table to ENTER the data, which is not suitable for DATA Extraction.

There are plenty of opportunities in SAP to extract the data, eg. with help of SE16n, SAP Reports or even as mentioned above with help of BAPI

Best regards, Lev

1 Like

@StefanSchnell @LevKushnir
We need to edit data in this table for few line items based on the check (as per business rules).
So currently we are extracting complete table as datatable and identifying row index of line item which needs to be updated as per business rule.
So how we can do that if Data extraction is not a possible work around or to skip spending 5 min over extraction?

Hi Stefan ,

We checked that SAP scripting (through recording) working pretty fast on that table as compare to UiPath.
Where as on other table its same behavior of SAP scripting and UiPath.

Regards
Gaurav

@gauravku

Hello Gaurav,

a few month ago I wrote A Brief History of Performance about the speed topic. Maybe you can use this approach, if speed is your priority.

A few questions:

  • Which method, property or algorithm do you use to get the data from an SAP table control into a data table?
  • Is your VBScript code also nearly three times faster, approximate 100 seconds instead 300 seconds?
  • Did you also process roughly the same amount of data in your comparisons?
  • Were these always the same objects of type GuiTableControl?

Please let us know the answer, I am particularly interested in the answer of the first question.

Best regards
Stefan

Hi Stefan ,

Approach i followed earlier is that , i extract data from table which i mention in discusion and on that table i update values in “Text” and “HSN/SAC Code” column for each row. For 33 records ,i.e if 33 line item present in the table than using this approach through Uipath its taking 25-30min whereas if i did the same thing using VB Scripting then overall it takes 7-8 min.

Currently i figure out a way to update those using VB Scripting but as the same time i am facing issue when records is more than 150. While running a script its updating those 2 column values for each row, but after 150+ records it make SAP Gui “Not Responding”. So now i am stuck with scripting as well larger number of records.
One more twist in this if i need to traverse on these 250 records then i am able to do that with the script with out any issues but when i try to update all records then only i face this “Not responding” issues.

Below the script i am using
If Not IsObject(application) Then
Set SapGuiAuto = GetObject(“SAPGUI”)
Set application = SapGuiAuto.GetScriptingEngine
End If
If Not IsObject(connection) Then
Set connection = application.Children(0)
End If
If Not IsObject(session) Then
Set session = connection.Children(0)
End If
If IsObject(WScript) Then
WScript.ConnectObject session, “on”
WScript.ConnectObject application, “on”
End If
session.findById(“wnd[0]”).maximize
Dim x,cnt, tempError, itemVal, tempValue,itemPosition,cntValue

x= 1
on error resume next
cnt=0
Do While x=1

	on error resume next
	tempError = session.findById("wnd[0]/usr/subHEADER_AND_ITEMS:SAPLMR1M:6005/subITEMS:SAPLMR1M:6010/tabsITEMTAB/tabpITEMS_PO/ssubTABS:SAPLMR1M:6020/subITEM:SAPLMR1M:6310/tblSAPLMR1MTC_MR1M/txtDRSEG-SGTXT[99,"+CStr(cnt)+"]").text
	
	if Err.Number = 0 Then
		on error resume next
		itemVal = session.findById("wnd[0]/usr/subHEADER_AND_ITEMS:SAPLMR1M:6005/subITEMS:SAPLMR1M:6010/tabsITEMTAB/tabpITEMS_PO/ssubTABS:SAPLMR1M:6020/subITEM:SAPLMR1M:6310/tblSAPLMR1MTC_MR1M/txtDRSEG-RBLGP[0,"+CStr(cnt)+"]").text
		'MsgBox("itemVal"+CStr(itemVal) + " tempValue"+CStr(tempValue) + " Cnt Value" +CStr(cnt))
		if(IsNumeric(itemVal) )Then
			If (CInt(itemVal) > CInt(tempValue)) Then
				'MsgBox("Numeric")
				tempValue = CInt(itemVal)
				'MsgBox("tempValue"+CStr(tempValue)+ " itemVal"+CStr(itemVal) + " Cnt Value" +CStr(cnt))
				on error resume next
				session.findById("wnd[0]/usr/subHEADER_AND_ITEMS:SAPLMR1M:6005/subITEMS:SAPLMR1M:6010/tabsITEMTAB/tabpITEMS_PO/ssubTABS:SAPLMR1M:6020/subITEM:SAPLMR1M:6310/tblSAPLMR1MTC_MR1M/txtDRSEG-SGTXT[99,"+CStr(cnt)+"]").text = CStr(WScript.Arguments.Item(0))
				'Msgbox("test02")
				on error resume next
				session.findById("wnd[0]/usr/subHEADER_AND_ITEMS:SAPLMR1M:6005/subITEMS:SAPLMR1M:6010/tabsITEMTAB/tabpITEMS_PO/ssubTABS:SAPLMR1M:6020/subITEM:SAPLMR1M:6310/tblSAPLMR1MTC_MR1M/ctxtDRSEG-HSN_SAC[137,"+CStr(cnt)+"]").text = CStr(WScript.Arguments.Item(1))
				'MsgBox("The SAP GUI element exists.")
				cnt=cnt+1
			Else
				'MsgBox("Non numeric")
				x=2
			End If
		Else
			'MsgBox("Non numeric")
			x=2
		End If
		
	else
		'y=1
		'MsgBox("In else : tempValue"+CStr(tempValue)+ " itemVal"+CStr(itemVal) + " Cnt Value" +CStr(cnt))
		if (cnt=9) Then	
			'Msgbox("The SAP GUI element does not exist, count is 9")
			session.findById("wnd[0]").sendVKey 82			
			cnt=0
		End If
		on error resume next
		tempError = session.findById("wnd[0]/usr/subHEADER_AND_ITEMS:SAPLMR1M:6005/subITEMS:SAPLMR1M:6010/tabsITEMTAB/tabpITEMS_PO/ssubTABS:SAPLMR1M:6020/subITEM:SAPLMR1M:6310/tblSAPLMR1MTC_MR1M/txtDRSEG-SGTXT[99,"+CStr(cnt)+"]").text
		if Err.Number = 0 Then
			'cnt=0
		Else
			x=2
		End If
				
	End If

Loop

I tried above script by running in chukns as well , like it will run for 1st 90 records then after it stop and make SAP objects as nothing then after start the script again for remaining reocrds. Still the same issue faced of SAP Not responding.

Note : I am performing page down after each 9 records as at a time only 9 recrds appear on screan and after page down on table, index reset to zero for 1st line item.

@gauravku

Hello Gaurav,
I never tried that with GuiTableControl, only with a GuiGridView. So I will look for an example to test it and then I come back to you.
Best regards
Stefan

@gauravku

Hello Gaurav,
I tried the following code:

StartTime = Timer

TableID = "wnd[0]/usr/tblRSDEMO_TABLE_CONTROLTABLE_CONTROL"
set Table = session.findById(TableID)

RowCount = Table.RowCount
ColCount = Table.Columns.Count

For Row = 0 To RowCount - 1
 
  Table.verticalScrollbar.position = Row
  Set Table = session.findById(TableID)
  For Col = 0 To ColCount - 1

    Set Cell = Table.GetCell(0, Col)
    If Col < ColCount - 1 Then
      Out = Out & Cell.Text & ";"
    Else
      Out = Out & Cell.Text
    End If

  Next

  Out = Out & vbNewLine

  If Table.verticalScrollbar.Position = _
    Table.verticalScrollbar.Maximum Then
    Exit For
  End If

Next

EndTime = Timer
ExecTime = EndTime -StartTime

MsgBox ExecTime

But I don’t have large amounts of data in my test system. This example reads the whole table in a variable. Maybe you can use this approach.
Best regards
Stefan