cancel
Showing results for 
Search instead for 
Did you mean: 

Error: ENDMETHOD missing, when using a FORM on a BSP Event handler

Former Member

Hello,

In my ONREQUEST event I have the following FORM

FORM REPLACE_STRING USING STRING TEMPLATE NEW.

CALL FUNCTION 'SDIT_REPLACE_STRING'

EXPORTING

IN_STRING = STRING

NEW = NEW

TEMPLATE = TEMPLATE

IMPORTING

OUT_STRING = STRING.

ENDFORM. "REPLACE_STRING

However when running a check on the code I get the error:

"Statement ENDMETHOD is missing"

Is it not possible to use a FORM in the event handler in a BSP?

Accepted Solutions (0)

Answers (3)

Answers (3)

thomas_jung
Developer Advocate
Developer Advocate

Your problem is that your BPS page is actually an ABAP OO class. All the event handlers are actually methods of this class. Therefore anything you program in these event handlers has to follow the rules for ABAP OO. Forms are not really valid constructs inside ABAP OO Methods. What you are trying to do is similar to trying to declair a new form within an existing form.

Form Test1.

Form Test2.

endform.

endform.

Former Member
0 Kudos

OK, so I understand now that I am trying in essence to build nested "forms" which is working (changing the name did not change anything as well)

So then my only chance is to build a method in the application class correct?

Does anyone have any "good" examples of that? I'm beginning to think EJB's are easier than BSP's in the moment.

Former Member
0 Kudos

I've created a new METHOD in my application class and assigned the application class to the BSP.

method REPLACE_STRING .

CALL FUNCTION 'SDIT_REPLACE_STRING'

EXPORTING

IN_STRING = STRING

NEW = NEW

TEMPLATE = TEMPLATE

IMPORTING

OUT_STRING = STRING.

endmethod.

In my event handler I am now trying:

tmpRFC = 'H=%HOST,S=%SID,M=%MANDT,U=%USER,L=%LANGU,Z=%PWD,'.

CALL METHOD application->REPLACE_STRING

EXPORTING

STRING = tmpRFC

TEMPLATE = '%HOST'

NEW = tmphost

IMPORTING

OUT_STRING = tmpRFC.

However I get the error that:

The statement "IMPORTING" is not expected. A correct similar statement is "IMPORT".

How can I retrieve the newly changed string??

Former Member
0 Kudos

If you create a new method you could also declare

parameters (first field is name of parameter second is kind of parameter) maybe you have to check this...

Former Member
0 Kudos

Thank you I will try that, I think from a coding point of view it will the code easier to read.

Former Member
0 Kudos

OK, finished and it works!

I add a new temporary entry to RFCDES use it and then delete it.

Former Member
0 Kudos

Craig:

You may want to change the name of the variable "STRING" to something else. "STRING" is an ABAP data type; use as a parameter / variable name may be confusing the compiler, thus causing the error message.

Regards,

D.

Former Member
0 Kudos

OnRequest, OnInit and so on are methods of you BSP Context so this will ever work. Why don't you create

a method in your application class??

Regards Matthias

Former Member
0 Kudos

Well I am pretty new to BSP's and I've not had much luck with the examples of doing a method in my application class.

Any suggestions on how to get started?