3

I have an ABAP program which calls a report and converts its output to JSON.

Unfortunately this does not work for SAP Queries like described in this question.

How can I detect if a report is an SAP Query or not if have the name of the report as string. e.g. AQZZZMM=========ZME80FN=======

Up to now I called reports like this:

  SUBMIT (IV_REPORT_NAME)
     WITH SELECTION-TABLE selection_table
    AND RETURN.
Boghyon Hoffmann
  • 17,103
  • 12
  • 72
  • 170
guettli
  • 25,042
  • 81
  • 346
  • 663
  • 3
    I think the system generates all ABAP Queries like AQ... So, if the first two characters of the program are AQ, than you can be pretty sure, it is an ABAP Query – József Szikszai Apr 04 '19 at 10:59
  • "Adhoc query" is a special type of query; AQ is for "ABAP query", but it has been renamed "SAP query" since release 4.6A. I have updated the question to reflect that. – Sandra Rossi Apr 04 '19 at 12:09
  • @JozsefSzikszai you say "I think the system generates all ABAP Queries like AQ... " I am paranoid (in this current context). I don't like guessing. I want a reliable method to detect this. – guettli Apr 04 '19 at 12:43
  • 3
    @guettli I understand and I am like 99.99% sure (I have not found any official statement by SAP), but the answer provided by rplantiko in the meantime is bulletproof. – József Szikszai Apr 04 '19 at 12:55

1 Answers1

6

You can use the function module RSAQ_DECODE_REPORT_NAME, as in the following test report.

report zz_test_query_report.
parameters: p_repid type repid.
call function 'RSAQ_DECODE_REPORT_NAME'
  exporting
    reportname = p_repid
  exceptions
    no_query_report = 1.
if sy-subrc eq 0.
  write: / p_repid, 'is a query report'.
else.
  write: / p_repid, 'is not a query report'.
endif.
Sandra Rossi
  • 11,934
  • 5
  • 22
  • 48
rplantiko
  • 2,698
  • 1
  • 22
  • 21