Skip to Content
1
Jul 04, 2018 at 09:25 AM

Runtime error with dynamic form of NON-strict SQL but not with static form

657 Views Last edit Jul 04, 2018 at 12:40 PM 2 rev

Hello,

In my ABAP 7.52 SP 0 system, I have a runtime error with the following code with dynamic NON-strict SQL :

  DATA lines_of_stxh TYPE TABLE OF stxh.
  DATA from TYPE string.
  DATA where TYPE string.

  from = 'STXH AS CGT'.
  where = `EXISTS ( SELECT * FROM CVI_CUST_LINK AS O WHERE CGT~TDNAME = O~CUSTOMER`
      && ` AND CGT~TDOBJECT = 'KNA1' AND EXISTS ( SELECT * FROM BUT000 AS H WHERE`
      && ` O~PARTNER_GUID = H~PARTNER_GUID AND H~PARTNER  =  '0000100549' ) )`.

  SELECT * FROM (from)
    INTO TABLE lines_of_stxh
    WHERE (where).

The short dump is a SAPSQL_PARSE_ERROR (uncaught CX_SY_DYNAMIC_OSQL_SEMANTICS) with error analysis "If the new Open SQL syntax is used, it must be used throughout. This includes using @ to escape host variables."

The short dump is right, it works when I write the SELECT this way - but that's not my question:

  SELECT * FROM (from)
    INTO TABLE @lines_of_stxh
    WHERE (where).

My question is about the same NON-strict SQL, but in its STATIC form, which compiles and works fine:

 DATA lines_of_stxh TYPE TABLE OF stxh.

 SELECT * FROM stxh AS cgt
 INTO TABLE lines_of_stxh
 WHERE EXISTS ( SELECT * FROM cvi_cust_link AS o WHERE cgt~tdname = o~customer
 AND cgt~tdobject = 'KNA1' AND EXISTS ( SELECT * FROM but000 AS h WHERE
 o~partner_guid = h~partner_guid AND h~partner = '0000100549' ) ).

So, the static form works, the dynamic form fails (in NON-strict mode).

Do you think whether it's an ABAP bug, or is it a restriction explained in the official ABAP documentation?

I have searched the forum and the SAP notes, but I couldn't find anything.

(please don't tell me that the code is ugly or complex, I know, thanks :) )

EDIT: sorry, I have made a mistake in the original title, the problem is with the NON-strict mode (my question is not about using the strict mode).

Thanks!

Sandra