2

I wrote a function in ABAP which gets called via SAP pyrfc.

If there is a SAPSQL_PARSE_ERROR the RFC caller (the client written in Python) gets a meaningless error message:

ABAPRuntimeError: RFC_ABAP_RUNTIME_FAILURE (rc=3): key=SAPSQL_PARSE_ERROR, message=Beim Parsen einer dynamischen Angabe trat ein Fehler auf. [MSG: class=, type=, number=, v1-4:=;;;]

Via tcode st22 I can look at the details. To make the round-trip faster I would like to improve the error message which is visible at the python client.

I guess, but don't know, that the abap function needs to be changed. How to obtain the valuable text which is visible in st22?

I know the output of st22 is very long. The valuable text is in the german sap gui the box called "Fehleranalyse" which means roughly "Troubleshooting" or more literal "error analysis"

Sandra Rossi
  • 11,934
  • 5
  • 22
  • 48
guettli
  • 25,042
  • 81
  • 346
  • 663

1 Answers1

4

SAPSQL_PARSE_ERROR suggests that your remote-enabled function at some point or other submits an incorrect OpenSQL query to the database. This should result in a handleable exception of the type CX_SY_DYNAMIC_OSQL_SYNTAX.

Not catching this exception results in a dump. Transaction ST22 is the dump analysis tool that lets you inspect those.

Putting a TRY ... CATCH around the OpenSQL query should allow you to catch that exception and parse its attributes for a more meaningful message. You can then throw an exception of your own to forward something more helpful to the RFC caller.

Florian
  • 4,821
  • 2
  • 19
  • 44
  • 4
    And eventually, if your function module builds an SQL query from the parameters, it may require a protection from SQL injection, by calling the methods of the class `CL_ABAP_DYN_PRG`, which might detect some errors before the query is built and executed. – Sandra Rossi Oct 26 '18 at 15:32