‎2014 Jan 22 1:49 PM
Hi Gurus.
Iam work with BAPI : BAPI_CONTRACT_CHANGE and
if I put a wrong code purposely imposed, the error message appears:
The tax code entered is not defined in the company's country.
the problem is that this message is displayed on the first screen. I want him to put this message in t_return which is the return table like other error messages.
How can I do this?
Thanks
‎2014 Jan 22 2:09 PM
‎2014 Jan 22 2:17 PM
In this moment I dont can see the table because the error message in screen.
‎2014 Jan 22 2:56 PM
Have you built out your BAPI call in code and test run it?
Neal
‎2014 Jan 22 3:14 PM
‎2014 Jan 22 3:19 PM
So, you send that error through you BAPI and the message is not returmed. I'm guessing the message is not a hard error, then.
There are configuration points to convert some messages from warnings to errors. Have you looked for one of those?
Neal
‎2014 Jan 22 3:52 PM
Hi
Can you please put a break point at statement message to check if some exit is throwing this errror or SAP standard code if SAP standard then raise a ticket to SAP. As correctly mentioned by Suhas such kind of behaviour of BAPI is not normal
Nabheet
‎2014 Jan 22 6:38 PM
Or to put this more simple - does his error message ID start with letter Z ?
‎2014 Jan 22 2:22 PM
To catch such errors you should use ERROR_MESSAGE exception when calling given BAPI.
And afterwards you can retrieve specific error message ID from SY variable.
That would look something like this:
CALL FUNCTION 'BAPI_CONTRACT_CHANGE'
EXPORTING
purchasingdocument = lv_purch_doc
TABLES
return = lt_return[]
EXCEPTIONS
error_message = 1.
IF sy-subrc = 1.
ls_return-type = sy-msgty.
ls_return-id = sy-msgid.
ls_return-number = sy-msgno.
ls_return-message_v1 = sy-msgv1.
ls_return-message_v2 = sy-msgv2.
ls_return-message_v3 = sy-msgv3.
ls_return-message_v4 = sy-msgv4.
INSERT ls_return INTO TABLE lt_return.
ENDIF.
(in given example online error is getting caught and immediately added to BAPI return table for further processing)
‎2014 Jan 22 3:05 PM
Reinis Dzenis wrote:
in given example online error is getting caught and immediately added to BAPI return table for further processing
But the point is a (well-designed)BAPI should not raise any message. I am not sure why the OP is facing this error.
If it is due to the BAPI & not due to an custom code i'll suggest to raise a message with SAP.
BR,
Suhas
‎2014 Jan 22 3:06 PM
Thanks Reinis But How know what row (item) have problem?
Thanks
‎2014 Jan 22 3:12 PM
BAPI's most often receive EDI. Amazingly enough, it is not that uncommon for EDI to send some real trash. Exceptions have to be handled...
Neal
‎2014 Jan 22 6:30 PM
Unfortunately you can't know that using given approach. It only goes as far as catches given error instead of outputting it to screen (and terminating your process).
As Suhas pointed out above, normally there shouldn't be such "unhandled errors" in SAP standard BAPI. Therefore, if you need as well to have proper reference to input item which caused the problem, your only option would be to open OSS incident and complain there about improper behavior of given standard BAPI.
One final work-a-round would be before actual posting, to call BAPI several times in TEST mode (if such is available for given BAPI) - once per each item. That could allow you to identify and filter out problematic item before you call BAPI with all items in productive mode. Yet this is by far not elegant approach and rather last resort work-a-round in case OSS would fail to fix given BAPI in reasonable time.
‎2014 Jan 22 6:32 PM
Point well made! Indeed such approach would be more common to reusing some other SAP standard function modules rather than BAPI.