cancel
Showing results for 
Search instead for 
Did you mean: 

cannot compile a class, field is unknown

former_member183924
Active Participant
0 Kudos

Hello,

I'm new in the abap world and my current quest is to finish the "Creating a BSP Extension for Downloading a Table" Blog by Thomas Jung. I have a working BSP Application (no MVC codingstyle) with a tableView-Iterator.

I implemented all the classes and code how it's described in the blog, but I get the error when I want to compile the ZCL_ES_BSP_ELMNT_DWN_TBL_EXCL class:

"Class ZCL_ES_BSP_ELMNT_DWN_TBL_EXCL,Method HANDLE_EVENT:

Field 'Prozess_xls_download' is unknown. It is neither in one of the specified tables nor defined by a 'data' statement."

But I thought by using the "class builder" I don't need to do more as described in the blog. The implementation is my code and the definition for a method is automatic set in the public section:


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

I also have an similar problem with the compilation of the GET_TABLE_STUCTURE method:

"Method GET_TABLE_STUCTURE is not declared or inherited in class ZCL_ES_BSP_ELMNT_DWN_TBL_EXCEL"

Have anybody an advice for me?

Accepted Solutions (1)

Accepted Solutions (1)

guillaume-hrc
Active Contributor
0 Kudos

Hi,

Welcome to SDN !

Are you sure is not PROCESS_XLS_DOWNLOAD (as you wrote pro<b>z</b>ess...) ?

Same thing for GET_TABLE_STUCTURE (GET_TABLE_ST<b>R</b>UCTURE).

<b>Hope it just typos ! ;-)</b>

Best regards,

Guillaume

former_member183924
Active Participant
0 Kudos

Hello Guillaume,

no my typo in the sap-program is correct.

I written off uncorrect in this thread.

thanks anyway

former_member183924
Active Participant
0 Kudos

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? Thanks a lot for any reply.

Regards.

former_member183924
Active Participant
0 Kudos

Hi,

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). And if I open my BSP-application with a browser I get an error "500 SAP Internal Server Error" exact in this class, which I cannot compile!

Regards

thomas_jung
Developer Advocate
Developer Advocate
0 Kudos

It sounds like you are perhaps cut and pasting the code and overwriting the method/endmethod statement.

You list two separate error messages:

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."

The seond one where seems to think that the method name is a field and not a method. This is what leads me to believe that you have done something wrong during the cut and paste of the code. Have you tried just creating the method and not cuting and pasting in any code - just activating the empty method?

former_member183924
Active Participant
0 Kudos

Hi Thomas,


method process_xls_download.

  data: r_string type string.

  data: lapp_type type char30,
        str       type string.

...
...

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

the first error messages

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

comes up, when I'll compile the method itself.

the second error messages, comes up when I compiled the process_xls_download alone, but I cannot reproduce this message.

Only the error-message above comes up.

When I double-click on the 'process_xls_download' method in the 'handle_event_data' method, the class builder redirects me into the right process_xls_download method. So the class builder should know where the method is.

Regards.

thomas_jung
Developer Advocate
Developer Advocate
0 Kudos

I'm not sure what else I can tell you. Something has certainly gotten messed up when creating the class. This isn't normal, nor is it necessarily related to the process of creating the extension.

Have you tried just blowing the whole thing away and starting over? The compiler must have some reason why it doesn't recognize the method name as a method, but without looking into your system and seeing the entire coding of the class I can't tell you why.

former_member183924
Active Participant
0 Kudos

hmm I know very strange.

I deleted all my methods and redefinitions and created all this from scratch. I created the methods in this order:

-get_table_structure

-process_htm_download

-process_htm_download

-process_htm_download

I check the methods witch CTRLF2 and CTRLF3. All these methods are fine and probably ready for work.

At last I created "handle_event" method and with CTRL+F2 he tells me:

'Field "PROCESS_XLS_DOWNLOAD" is unknown. It is neither in one of the....'

Should I define these methods in the "handle_event"? I don't think so.

I don't know

Regards.

thomas_jung
Developer Advocate
Developer Advocate
0 Kudos

Can you post the coding that you have in the Handle_Event method? Particularly around the method call to PROCESS_XLS_DOWNLOAD. Perhaps there is something wrong around there.

former_member183924
Active Participant
0 Kudos

Shure, here you are.


method HANDLE_EVENT .


  DATA: app_type TYPE string.

  DATA: l_string TYPE string,
        l_xstring TYPE xstring,
        extension TYPE string.

  DATA: error TYPE REF TO cx_root.

  TRY.
****Get Event ID
      DATA: ipopup TYPE REF TO zcl_es_bsp_elmnt_dwn_tbl_excl.
      ipopup ?= htmlb_event_ex.

****Process Popup Menu - Which Menu Option was selected
      IF ipopup->selected_id CS 'Item1'.
    app_type  = 'APPLICATION/XLS; charset=utf-16le'.
    l_xstring = zcl_es_bsp_elmnt_dwn_tbl_excl=>process_xls_download(ITAB=ITAB).
    extension = '.xls'.

      ELSEIF ipopup->selected_id CS 'Item2'.
    app_type  = 'APPLICATION/XML; charset=UTF-8'.
    l_xstring = zcl_es_bsp_elmnt_dwn_tbl_excl=>process_xml_download(ITAB=ITAB).
    extension = '.xml'.

      ELSEIF ipopup->selected_id CS 'Item3'.
    app_type  = 'text/html; charset=UTF-8'.
    l_xstring = zcl_es_bsp_elmnt_dwn_tbl_excl=>process_htm_download(ITAB=ITAB).
    extension = '.html'.
      ENDIF.

****Build the filename from the BSP Application Name or the supplied
****value
      DATA: value TYPE string.
      IF i_filename IS NOT INITIAL.
        CONCATENATE 'attachment; filename='
                    i_filename
                    extension
                    INTO value.
      ELSE.
        CONCATENATE 'attachment; filename='
                    runtime->application_name
                    extension
                    INTO value.
      ENDIF.

****Catch any errors and return them as file
    CATCH cx_root INTO error.
      DATA: xml_err TYPE REF TO zcl_es_serializable_error.
      CREATE OBJECT xml_err
           EXPORTING   error = error.

      DATA: g_ixml TYPE REF TO if_ixml,
            g_stream_factory TYPE REF TO if_ixml_stream_factory,
            g_encoding TYPE REF TO if_ixml_encoding.

      CONSTANTS:
* encoding for download of XML files
      encoding     TYPE string VALUE 'UTF-8'.

      DATA: resstream TYPE REF TO if_ixml_ostream.

****Create an instance of the Ixml Processor
      g_ixml = cl_ixml=>create( ).

****Create the Stream Factory
      g_stream_factory = g_ixml->create_stream_factory( ).

****Create an Endcoding and Byte Order
      g_encoding = g_ixml->create_encoding( character_set = encoding
      byte_order = 0 ).

****Create the output stream with a pointer to our binary string
      resstream =  g_stream_factory->create_ostream_xstring( l_xstring ).

****Set the Encoding into a stream
      resstream->set_encoding( encoding = g_encoding ).

      CALL TRANSFORMATION id
              SOURCE     error = xml_err
              RESULT XML resstream.

      app_type = 'APPLICATION/XML; charset=UTF-8'.
      extension = '.xml'.
      CONCATENATE 'attachment; filename='
                         'Error'
                         extension
                         INTO value.
  ENDTRY.

****Create the cached response object that we will insert our content
****into
  DATA: cached_response TYPE REF TO if_http_response.
  CREATE OBJECT cached_response TYPE cl_http_response EXPORTING
add_c_msg = 1.

****set the data and the headers
  cached_response->set_data( l_xstring ).
  cached_response->set_header_field( name  = if_http_header_fields=>content_type
                                     value = app_type ).

****Set the filename into the response header
  cached_response->set_header_field( name  = 'Content-Disposition'
                                     value = value ).

****Set the Response Status
  cached_response->set_status( code = 200 reason = 'OK' ).

****Set the Cache Timeout - 60 seconds - we only need this in the cache
****long enough to build the page and allow the IFrame on the Client to
****request it.
  cached_response->server_cache_expire_rel( expires_rel = 60 ).

****Create a unique URL for the object
  DATA: guid TYPE guid_32.
  CALL FUNCTION 'GUID_CREATE'
    IMPORTING
      ev_guid_32 = guid.
  CONCATENATE runtime->application_url '/' guid INTO url.

****Cache the URL
  cl_http_server=>server_cache_upload( url      = url
                                       response = cached_response ).
  RETURN.

endmethod.

thomas_jung
Developer Advocate
Developer Advocate
0 Kudos

Well you can't have:

l_xstring = zcl_es_bsp_elmnt_dwn_tbl_excl=>process_xls_download(ITAB=ITAB).

It has to be:

l_xstring = zcl_es_bsp_elmnt_dwn_tbl_excl=>process_xls_download( ITAB=ITAB ).

The spaces for before and after the method parameters are very important. Otherwise the compiler doesn't see this as a method call.

thomas_jung
Developer Advocate
Developer Advocate
0 Kudos

Well you can't have:

l_xstring = zcl_es_bsp_elmnt_dwn_tbl_excl=>process_xls_download(ITAB=ITAB).

It has to be:

l_xstring = zcl_es_bsp_elmnt_dwn_tbl_excl=>process_xls_download( ITAB=ITAB ).

The spaces for before and after the method parameters are very important. Otherwise the compiler doesn't see this as a method call.

former_member183924
Active Participant
0 Kudos

damn I had to compress the length of the line. Because I had the option "Default Line Length (72)" in my User-Specific Settings on.

thanks for your tips, advices and time. I'm going to answer at my question in your Blog.

Regards.

Answers (0)