Steps to add SAP Error Handling:
Typical Error handling involving onmessage:
- Create an onmessage command block after an enter event that writes into SAP. Onmessage commands will execute code when SAP displays an error or warning message.
- The following code is a standard template and can be repurposed with additional functionality if needed. Ensure that you change the enter command to properly navigate the user.
onmessage
if(_message){
message(_message);
enter('/niw51');
goto SCRIPT_END;
}
- Repeat step 2 after the enter command in which you write into SAP.
- Place SCRIPT_END; at the end of your function.
- Save in Designer and all the changes will appear in SAP.
If SAP returns a popup error:
- Perform your screen combine function with erroneous data. Your function will pause on the information popup.
- Get the technical name of the field on the popup. If you are unsure of the field:
- Refresh Designer while the popup is shown/li>
- Click on "Controls List" in the Task Pane. The designer will show you the display and technical name of the field. The typical field is: MESSTXT1 or MESSTXT2
- Begin a recording starting on this popup. Record the action to navigate away from it, in this instance pressing Enter.
- Stop the recording, and place the simple recording in your existing function. In this instance, the popup appears after you press the Save button (enter('/11');).
- If you are unsure where the popup appears you may use visual processing by typing: /ws_vap=1 into the transaction bar.
- You then press the button and press enter to continue through each onscreen block in the function. You can disable visual processing by typing /ws_vap=0
- Copy the message from the popup into a variable. This will be the field you noticed in step 2.
- Display the message to the user and navigate back to the screen where the user pressed the button. In this case IW51.
- Save in Designer and all the changes will appear in SAP.