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

Abap method with parameter

Former Member
0 Likes
1,939

Hi!

I have some trouble in method with parameter. I did follow https://help.sap.com/doc/abapdocu_752_index_htm/7.52/en-us/abapmethods_parameters.htm And this is was my code :

....

PUBLIC SECTION.

INTERFACES if_oo_adt_classrun.

METHODS loop.

IMPORTING num type i.

...

got error on importing says " This Statement IMPORTING is unexpected ". I using Abap Class instead of Abap Program.

Thank you for your time.

1 ACCEPTED SOLUTION
Read only

michael_piesche
Active Contributor
1,752

"METHODS loop IMPORTING num type i." is one 'statement', otherwise you will have 'statement' 'METHODS loop.' which is ok for a method without parameters, but than you would have 'IMPORTING num type i.' which cannot be interpreted. (you can have the method name and its parameters in different lines, just dont separate them with a dot.)

"....
PUBLIC SECTION.
  INTERFACES if_oo_adt_classrun.
  METHODS loop IMPORTING num type i.
"....
5 REPLIES 5
Read only

maheshpalavalli
Active Contributor
1,752

There shouldn't be dot '.' after 'Methods loop'

Read only

0 Likes
1,752

If a method don't have any params it just ends with dot, if it has params like importing, exporting or exceptions then at the end of all those params, the method definition ends with dot.

Read only

0 Likes
1,752

Thank you so much

Read only

michael_piesche
Active Contributor
1,753

"METHODS loop IMPORTING num type i." is one 'statement', otherwise you will have 'statement' 'METHODS loop.' which is ok for a method without parameters, but than you would have 'IMPORTING num type i.' which cannot be interpreted. (you can have the method name and its parameters in different lines, just dont separate them with a dot.)

"....
PUBLIC SECTION.
  INTERFACES if_oo_adt_classrun.
  METHODS loop IMPORTING num type i.
"....
Read only

0 Likes
1,752

Thank you so much!!