Application Development and Automation Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 

String templates in host expressions - unexpected syntax error

Volodymyr_S
Explorer
0 Kudos
1,453

Hi All,

I know there is a question with almost the same title. However, mine is different because we are on the SAP BASIS 7.53, and therefore host expressions in WHERE must be supported. Moreover, this code has been successfully working for a year in DEV and for 7 months in PROD:

select single docnum, modus from zcaout_int_drive
where object = @zcl_asset_distribute=>obj_type_fixed_asset
and   objectid = @( |{ me->company_code }{ me->asset }{ me->subnumber }| )
into (@me->send_idoc_number, @me->send_idoc_modus).

However, suddenly this codes started failing in all environments with the SYNTAX_ERROR. The message is misleading:

The field "SEND_IDOC_NUMBER, @ME" is unknown, but there is a field with the similar name "SEND_IDOC_NUMBER". "SEND_IDOC_NUMBER".

I discovered that if I comment out the OBJECTID condition, it compiles successfully:

select single docnum, modus from zcaout_int_drive
where object = @zcl_asset_distribute=>obj_type_fixed_asset
into (@me->send_idoc_number, @me->send_idoc_modus).

I also discovered that I can't use a construction expression VALUE here or even declaring a helper variable:

data(object_id) = value char90( |{ me->company_code }{ me->asset }{ me->subnumber }| ). 

The error I'm getting is this:

1 errors found. Activate anyway?
Line 26: The type
"CHAR90" is not a structure.

This is really weird. I know there was a mysterious security patch on our S/4 system over the weekend, but whatever it was, it shouldn't have broken the existing working code. It looks like it downgraded the kernel version... though it still shows 7.53. Any ideas on what that could be? Or should we raise it with SAP directly?

13 REPLIES 13

FredericGirod
Active Contributor
0 Kudos
1,199

at first Try to replace VALUE by CONV

could you debug the code and check before the execution the content of "me" ?

Volodymyr_S
Explorer
0 Kudos
1,199

Well, CONV works in the assignment:

data(object_id) = conv char90( |{ me->company_code }{ me->asset }{ me->subnumber }| ).

However, it fails in WHERE with exactly the same error:

select single docnum, modus from zcaout_int_drive
where object = @zcl_asset_distribute=>obj_type_fixed_asset
and objectid = @( conv char90( |{ me->company_code }{ me->asset }{ me->subnumber }| ) )
into (@me->send_idoc_number,
@me->send_idoc_modus).

And the error:

1 errors found. Activate anyway?
Line 34: The field
"SEND_IDOC_NUMBER, @ME" is unknown, but there
is a field with the similar name
"SEND_IDOC_NUMBER". "SEND_IDOC_NUMBER".

So, the issue is not with "me", but with the host expression that involves a string template. As soon as I remove the string template, the syntax error disappears. It's strange that the original code had been working for almost 8 months till last weekend...

FredericGirod
Active Contributor
0 Kudos
1,199

Maybe there was a patch or an oss note, did you check the SPAM ?

Did you check also for simple thing, like someone change the structre of the table 🙂

Volodymyr_S
Explorer
0 Kudos
1,199

The structure wasn't changed. I can confirm. As for the patch - yes, our vendor applied a patch over the weekend. Monday morning - lots of dumps in production. Once correct, the code started crashing with a syntax error.

FredericGirod
Active Contributor
0 Kudos
1,199

Maybe horst.keller could help you, or directly SAP Support.

If you could check this security patch info, it could help.

I know some security recommendation is to avoid dynamic code & select. But it should be a warning.

There is also a parameter in program ABAP Version I think, it could impact the code allowed, but I am not sure about it (Check example DEMO_ABAP_VERSIONS)

Volodymyr_S
Explorer
0 Kudos
1,199

There was a security patch from PL 800 to PL 900, kernel 7.53. Probably, it's a side effect...

FredericGirod
Active Contributor
1,199

You have oss note looks like your issu:

2433966 - Programs contained Host Variables are terminated with SYNTAX_ERROR

but it seems to be corrected by other patch

Sandra_Rossi
Active Contributor
0 Kudos
1,199
frdric.girod

concerning the note you mentioned, it's worth an answer!

FredericGirod
Active Contributor
1,199

Ola sandra.rossi, this is not related to the release of volodymyr.shcheglov

Volodymyr_S
Explorer
1,199

Thank you all for your contribution. I was overloaded with numerous production issues in our systems so I could not respond.

As for the patch (whatever it was), they rolled back the kernel to the previous version, and all worked well.

BTW, the vendor specified 2 kernel versions in the SOW: 7.53 and 7.73. The latter was upgraded to 7.77 PL400, while 7.53 was updated to PL 900. I don't know what that means. What I can see in System -> Status is this:

Component    Release   SP Level
SAP_BASIS     753	0002
SAP_ABA       75D	0002
S4CORE        103	0002<br>

I don't know where 7.73 comes from - that's with our vendor and their BASIS team.

Based on this, I don't think the note is relevant. Besides, the error is different. Moreover, host variables don't cause syntax errors - it's the host expression containing string template that was causing the syntax error after the patch. However, the note was useful - it described the process of searching for regressions introduced by particular kernel patches. Unfortunately, neither KRNL753PL900 nor KRNL777PL400 documented any regression we are experiencing.

Once I have more info on that from our vendor, I'll update the post here.

Volodymyr_S
Explorer
0 Kudos
1,199

Hi All,


That much time has passed, but still no update from SAP. We raised an incident, 902273 / 2021, but SAP blames the user code. However, to me it doesn't make sense that in KRNL773PL400 the code is working, and in KRNL777PL400 it fails to even compile. Moreover, it seems like this regression was introduced in Kernel 7.77 right from the start. We tried with the lowest PL available, KRNL777PL5, and it showed the same syntax error. I'm surprised nobody discovered it till now. Am I the only person using string templates in host expressions?!

What I managed to do is to isolate the issue to the use of string templates in host expressions. As a reminder, the following code fails in KRNL777PL400:

select single docnum, modus from zcaout_int_drive
where object = @zcl_asset_distribute=>obj_type_fixed_asset
and objectid = @( |{ me->company_code }{ me->asset }{ me->subnumber }| )
into (@me->send_idoc_number, @me->send_idoc_modus).

However, if the host expression is modified slightly, it compiles just fine on the same kernel:

select single docnum, modus from zcaout_int_drive
where object = @zcl_asset_distribute=>obj_type_fixed_asset
and objectid = @( me->company_code && me->asset && me->subnumber )
into (@me->send_idoc_number, @me->send_idoc_modus).

So, it looks like kernel 7.77 breaks backward compatibility with 7.73 in the area of using string templates in host expressions. However, even now the SNote 3079989 doesn't list anything resembling this ABAP syntax regression. We really depend on SAP to accept it as a regression and investigate it further. The behaviour is consistent in our system.

Anyone on KRNL777, any patch level, can you please test a simple SELECT with string templates in host expressions in the WHERE clause? If you have the same issue, it will be a good proof of broken compatibility.

Thanks.

Volodymyr_S
Explorer
0 Kudos
1,199

Anyone tested string templates in host expressions on kernel 777? Unfortunately, I can't track this issue anymore as I resigned from the company where I identified this issue. Moreover, my independent S-user ID got deleted so that I lost access to my content that I had created using that S-ID...

Sandra_Rossi
Active Contributor
0 Kudos
1,199

Just to say, kernel 785 is fine (code that anyone can try, not sure for Cloud):

DATA(first) = '0'.
DATA(second) = '00'.
SELECT SINGLE mandt, MTEXT FROM t000
  WHERE mandt = @( |{ first }{ second }| )
  INTO (@DATA(mandt), @DATA(mtext)).
Now, looking at what you have posted previously, that "SAP blames the user code", as it's unrelated to the issue you have posted, I'm surprised that they didn't say anything else specific to the actual issue... Usually, they do a test. Pity that you don't have access to the message anymore.