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

cannot compile a method, field is unknown

former_member183924
Active Participant
0 Likes
3,995

this is how I create my method, if there is any other way or additional work to do, please let me know:

-rightclick on the class ZCL_ES_BSP_ELMNT_DWN_TBL_EXCL -> Create -> Method

now there is a dialog:

-insert methodname "process_xls_download"

-insert description "xls download processing"

-insert the two parameters "ITAB" and "R_XSTRING"

-attributes: "public" and "static" (but I already tried "instance")

-no abstract, no final, no event handler, no modeled

-no entries in "exceptions"

-save changes to ZCL_ES_BSP...

and voila I can see my new method. I double click on it and paste your code in it.

CTRL+F2 gives me "no syntax errors found"

CTRL+F3 gives me "Method "PROCESS_XLS_DOWNLOAD" is not declared or inherited in class"

So I am not able to compile the class, cause "Field "PROCESS_XLS_DOWNLOAD" is unknown. It is neither in one of the specified tables nor defined by a "DATA" statement."

so what did I wrong?

I don't know that I have to declare a new method manually, in case of the dialog-creation?!?

Regards.

1 ACCEPTED SOLUTION
Read only

seshatalpasai_madala
Product and Topic Expert
Product and Topic Expert
0 Likes
2,338

Hi,

If there are no syntax errors , that is if cntrl F2 does not give any error then cntrl + F3 gives you an option to activate it anyway. Try and activate it anyway.

Regards,

Sesh

8 REPLIES 8
Read only

RichHeilman
Developer Advocate
Developer Advocate
0 Likes
2,338

Look at the code in your method, please make sure that the first line reads as follows....

<b>method</b> PROCESS_XLS_DOWNLOAD.

I think that you may have deleted the word method or something.

Regards,

Rich Heilman

Read only

0 Likes
2,338

my method begins with


method PROCESS_XLS_DOWNLOAD.

  data: r_string type string.

  data: lapp_type type char30,
        str       type string.

****Set the application Type - character set for conversion from string
****to Binary String - Excel Requires UTF-16 with Little Endian
 lapp_type = 'text/unicode; charset=utf-16le'.

  field-symbols: <tab>         type table,
                 <wa>          type any,
                 <f>           type any.
...
...

and ends with


  concatenate  cl_abap_char_utilities=>byte_order_mark_little
               r_xstring
               into r_xstring in byte mode.
endmethod.

And there is no double expression for "method" or "endmethod". If I want to compile my complete class, I get the error:

"Field "PROCESS_XLS_DOWNLOAD" is unknown. It is neither in one of the specified tables nor defined by a "DATA" statement."

But the dialogcreation of this method, already created this code:


class ZCL_ES_BSP_ELMNT_DWN_TBL_EXCL definition
  public
  inheriting from ZCLG_ZKEG_DOWNLOADTABLEEXCEL
  create public .
 
*"* public components of class ZCL_ES_BSP_ELMNT_DWN_TBL_EXCL
*"* do not include other source files here!!!
public section.
 
  interfaces IF_HTMLB_DATA .
 
  data SELECTED_STRING type STRING .
  data SELECTED_ID type STRING .
  data SELECTED_TEXT type STRING .
 
  class-methods CLASS_CONSTRUCTOR .
  methods GET_TABLE_STRUCTURE
    importing
      !ITAB type ref to DATA
    returning
      value(STRUCT) type EXTDFIEST .
  methods PROCESS_XLS_DOWNLOAD
    importing
      !ITAB type ref to DATA
    returning
      value(R_XSTRING) type XSTRING 
...
...

into the public-section of the class

By the way my class has a superclass, but this shouldn't make any problems?!?

With a other case of this program, I created a class and a method successfully.

Read only

Former Member
0 Likes
2,338

Hi,

When you double click on the new method's name, you would be taken to an editor where there is a

method <method name>.

endmethod.

already there.

When you paste your code, it might have had an extra method statement.YOu need only to paste the code between the method-enmethod block.

REgards,

Ravi

Read only

seshatalpasai_madala
Product and Topic Expert
Product and Topic Expert
0 Likes
2,339

Hi,

If there are no syntax errors , that is if cntrl F2 does not give any error then cntrl + F3 gives you an option to activate it anyway. Try and activate it anyway.

Regards,

Sesh

Read only

Former Member
0 Likes
2,338

Hi,

When you try to activate the code, how many object are you getting in the pop up?

Select all the objects and activate them at a time.

Regards,

ravi

Read only

0 Likes
2,338

Right, activate all, if that doesn't help, say "Activate Anyway" then try to activate again and see if you still get the message.

Regards,

Rich Heilman

Read only

0 Likes
2,338

Hi,

so I have 6 items in "transportation objects"

CPU ZCL_ES_BSP...

METH (5 times)

I tried to activate anyway these items. This activation process works (all my six objects are active now), but when I change just a word from "METHOD" to "method" --> save it --> CTRLF2 (no errors) --> CTRLF3 (same error as I described above)

Very strange, my example is taken from a blog (/people/thomas.jung3/blog/2004/09/02/creating-a-bsp-extension-for-downloading-a-table) by Thomas Jung, but I couldn't helped me anyway :-(. Maybe you can see any advices there.

Read only

Former Member
0 Likes
2,338

Hi Stefan,

You need not have to worry about the error that is coming... The error comes when you try to activate a method in a class.

After typing the code in the method and saving it, what you can do is check if it has any syntax errors. After it is clean with no syntax errors, come out of the method . Now you will be in your class. Now press CTRL + F3. This will work.

Regards,

SP.