on 08-13-2014 11:13 PM
Hello,
I've started using "Record script" and I've found it very useful, it's very powerful combined with VBA code.
By now, I'm executing it from Excel and I would love to know how can I handle SAP error messages.
For example:
Sub Test ()
'Some code
Dim material As String
material = "123456"
session.findById("wnd[0]/usr/ctxtRC29N-MATNR").Text = material
'Some code
End Sub
I wrote this routine to change 1000 materials information.
Everything went fine until the code tryed to modify a material that has some weird configuration and SAP returned an error message.
Thanks in advance,
Richard
Hello.
I have created an dynamic Excel VBA template which include as well this log-function.
Public Function Create_Log(lngRow As Long, lngCol As Long, strLog As String)
Dim lngCounter As Long
Dim lngLast_Col As Long
Dim strLog_Line As String
lngCounter = lngRow
lngLast_Col = lngCol
strLog_Line = strLog
If ThisWorkbook.Sheets("SAP_PROCESS").Cells(lngCounter, lngLast_Col).Value = "" Then
ThisWorkbook.Sheets("SAP_PROCESS").Cells(lngCounter, lngLast_Col).Value = strLog_Line
Else
ThisWorkbook.Sheets("SAP_PROCESS").Cells(lngCounter, lngLast_Col).Value = ThisWorkbook.Sheets("SAP_PROCESS").Cells(lngCounter, lngLast_Col).Text & Chr(10) & strLog_Line
End If
End Function
In my process code I use this function like this:
'Log
If Session.FindById("wnd[0]/sbar").Text <> "" Then Create_Log lngCounter, lngLast_Col, Session.FindById("wnd[0]/sbar").Text
We can check as well if we receive an error (sy-msgty = 'E')
If Session.FindById("wnd[0]/sbar").messagetype = "E" Then Create_Log lngCounter, lngLast_Col, Session.FindById("wnd[0]/sbar").Text
Hope this give you an idea how to handle this.
Best regards,
Holger
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.