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: 
Read only

Error while activating BAdI enhancement implementation

lucy_gray2
Active Participant
0 Likes
6,995

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.

12 REPLIES 12
Read only

RobertVit
Active Contributor
0 Likes
6,436

Hi,

sounds like you are in Steampunk (ABAP Cloud) ?

Kind regards
Robert
Read only

Sandra_Rossi
Active Contributor
0 Likes
6,436

If it's a syntax error, you should have a line number and a line of ABAP code...

Or is it an ATC check?

Read only

Saumil_Kadukkatt
Explorer
0 Likes
6,436

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.

Read only

vipinsaraika
Participant
Read only

lucy_gray2
Active Participant
0 Likes
6,436

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

Read only

Sandra_Rossi
Active Contributor
0 Likes
6,436

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.
Read only

Sandra_Rossi
Active Contributor
0 Likes
6,436

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)

Read only

lucy_gray2
Active Participant
0 Likes
6,436

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

Read only

Sandra_Rossi
Active Contributor
0 Likes
6,436

No. I just answer your several questions.

In your case, I would recommend that you create a BAdI implementation as you initially planned!

Read only

Sandra_Rossi
Active Contributor
0 Likes
6,436

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

Read only

Sandra_Rossi
Active Contributor
6,436

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?

Read only

lucy_gray2
Active Participant
6,436

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