‎2021 Sep 09 6:23 AM
Hi,
I got the below syntax error while activating a BAdI enhancement implementation, can you please help me to get rid of it?
Error message : "The variant of command enhancement is not allowed in the restricted language scope."
I am only a novice at ABAP, trying to implement this enhancement for a PoC.
‎2021 Sep 09 6:25 AM
Hi,
sounds like you are in Steampunk (ABAP Cloud) ?
‎2021 Sep 09 7:02 AM
If it's a syntax error, you should have a line number and a line of ABAP code...
Or is it an ATC check?
‎2021 Sep 09 7:13 AM
Can you please put a screenshot of the error?
Also for which Tcode you are trying to implement the Badi and the name of the Badi.
‎2021 Sep 09 7:31 AM
Please go through below link it might help
https://blogs.sap.com/2020/07/23/restricted-abap-and-sap-s-4hana-on-premise/
‎2021 Sep 09 8:24 AM
Hi all,
Thank you for your responses.
I have attached a screenshot of the error.
The BAdI is "FCO_COEP_QUANTITY"
Enhancement Spot EHS_FCO_COEP_QUANTITY
sandra.rossi , when I double click on the error, it does not point to any specific line, but points to the very first line of the Method.
P.S. : I created the enhancement implementation directly via SE24, and below is the reason for that:
Initially, for the above enhancement spot, when I tried to create an enhancement implementation via SE19, after saving the implementation name as a local object, I got a screen where I assigned this new implementation to a class CL_FIN_CODOC_ITEM_QUANTITY_EX, and to the above BAdI. But then further I got the below question pop-up. When I selected yes for this question, then it asked for a Transport request, which I wanted to avoid.
"Class does not implement the BAdI interface. Add an interface relationship?"
Hence, I implemented the enhancement directly in the method of the above class, where I got the error.
Thanks
Lucy

‎2021 Sep 09 10:47 AM
It seems you implemented a implicit enhancement option at the end of the method, you did not implement an explicit enhancement option of an enhancement spot. By the way, your screenshot looks strange to me, you should normally have this:
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""$"$\SE:(1) Form SHOW_APPL_LOG, End A
*$*$-Start: (1)---------------------------------------------------------------------------------$*$*
ENHANCEMENT 1 Z_TRANSFER_QUANTITIES. "active version
" your code
ENDENHANCEMENT.
*$*$-End: (1)---------------------------------------------------------------------------------$*$*
ENDFORM.
‎2021 Sep 09 10:50 AM
Concerning the message "Class does not implement the BAdI interface. Add an interface relationship?" it's like if you had created the class before creating the implementation. So, you should just say YES so that the line "INTERFACES IF_FCO_COEP_QUANTITY" is automatically added to your public section. (or you can do it manually and you avoid the message, anyway it leads to the same result)
‎2021 Sep 09 11:07 AM
Hi sandra.rossi
Thank you for your reply.
Do you mean that I should be performing an explicit enhancement instead? I can't find an option for an explicit enhancement in the menu, all I can see is the option to create an implicit enhancement.
So, you should just say YES so that the line "INTERFACES IF_FCO_COEP_QUANTITY" is automatically added to your public section.
>>> Is this step mandatory? If I click Yes, it asks to create a Transport reuquest, there is no option save as a local object.
Thank you & Regards,
Lucy
‎2021 Sep 09 12:03 PM
No. I just answer your several questions.
In your case, I would recommend that you create a BAdI implementation as you initially planned!
‎2021 Sep 09 12:05 PM
Concerning your question about creating a transport request, it means that this existing class has already been assigned a transport request in the past (it's assigned a transportable package). Nothing prevents you to create a class locally, without a transport request.
EDIT but it's bad practice to develop locally, because you risk errors when you decide to really transport, except if you are in a sandbox system, and you will recreate everything from scratch in the dev system
‎2021 Sep 09 12:30 PM
To your question "Is this step mandatory?" Yes, it's how you can implement the method(s) of the BAdI.
EDIT: because you must define the custom code inside a method, you need a method definition (METHODS) with the right BAdI method parameters. How would you indicate it otherwise?
‎2021 Sep 09 12:57 PM
Hi sandra.rossi
Thank you for your reply.
I realized my mistake, while defining the BAdI implementation initially, when I was asked to assign it to a BAdI, in the field for Class, I had provided the name of a SAP delivered demo Class, and because this Class's namespace was a SAP reserved one, the system was not allowing me to save the implementation locally.
I should have given a Class name starting with Z.
Furthermore, performing an implicit enhancement in a SAP delivered Class was another fundamental mistake, which might be causing the syntax error.
Now I have implemented the BAdI correctly, and no such syntax error occurred.
Thanks for being there and guiding me.
Regards,
Lucy