SAP Error handling by SAP GUI Scripting

吃可爱长大的小学妹 提交于 2019-12-10 23:22:13

问题


I m using SAP GUI Scripting code for bulk record submission through SAP form. It picks records one by one from excel file and submits in SAP system.

My Question:

I want to include error handling into it. So that if any error occurs at any particular record submission, Script shouldn't stop. It should move to the next line after putting appropriate message in Comment field.

Can anyone throw some light how to identify whether SAP is facing some Error or Warning?

And if Error occurs how to get out of it i.e., how to handle that and move to next record submissions.


回答1:


Yes, You can do that.

Look for the status bar at botton

GUI Scripting help section in SAP is very helpful it will explain you things in very details.

GuiStatusBarObject --> Members --> Message Type

Us can use those properties as per your needs, If You need to move next , halt or notify user You can use these messages type and work accordingly.

SAP scripting does not throw error if error occurs in SAP itself , It will only throw error when it can not find elements or some other issue.

Sample Code :

Public Sub get_status_bar_value_exit_if_Error()
    Dim usr_resp As String
    If (session.findById("wnd[0]/sbar").messagetype = "E" Or session.findById("wnd[0]/sbar").messagetype = "W") Then
       usr_resp = MsgBox(session.findById("wnd[0]/sbar").Text & Chr(13) & "Show the Error in SAP ?", vbYesNo)
            If usr_resp = vbYes Then

        Else
            Call go_to_Sap_home
        End If

        End
    End If
End Sub

Here I chose to exit the current task and go to home if user chose not to see error in SAP ,else SAP will halt and user can see error in the status bar. You can do anything you want to do.




回答2:


The answer is basically On Error Resume Next but you can read more here... https://scn.sap.com/thread/3270803. On Error Resume Next alone will ignore all of your errors. You can make conditions through If.



来源:https://stackoverflow.com/questions/33194893/sap-error-handling-by-sap-gui-scripting

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!