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

Incomplete type inference in quick fix?

Former Member
0 Likes
512

Hi all,

I'm implementing the examples from the REST How-To and have come across the following behaviour: I've created the basic classes and want to add the method REGISTER_RESOURCES as described in section 2.3.2. Now I have the following code:

  METHOD register_resources.

    registry->register_discoverable_resource(
      EXPORTING
        url             = '/restflights/01/carriers'
        handler_class   = 'CL_SFLIGHT_ADT_RES_CARRIERS'
        description     = 'Carriers'
        category_scheme = 'http://www.mycompany,com/adt/categories/examples/flights'
        category_term   = 'carriers' ).

    collection = registry->register_discoverable_resource(
        url             = '/restflights/01/flights'
*        accepted_types  =
*        handler_class   =
*        parameter       =
        description     = 'Flights'
        category_scheme = 'http://www.mycompany,com/adt/categories/examples/flights'
        category_term   = 'flights'
    ).

  ENDMETHOD.

Naturally, the editor will complain about collection not being defined. If I use the quick fix to declare a local variable, I get

DATA: collection TYPE any.

which is not quite what I expected - I think this should be a TYPE REF TO IF_ADT_DISCOVERY_COLLECTION since this is what the method returns. The backend is SAP_BASIS/ABA 7.31 SP 13. Is this a known issue?

Thanks

  Volker

1 ACCEPTED SOLUTION
Read only

sebastian_wolf
Product and Topic Expert
Product and Topic Expert
0 Likes
461

Hi Volker,

yes, this behavior is known - especially in SAP_BASIS 7.31. In this release we can't infer the type to that extent as we currently do it in SAP_BASIS 7.4. In the higher releases we are much better - nevertheless there are still some cases when we need to propose TYPE ANY instead of the complete (correct) type.

We plan to improve this in the future, but unfortunately I can't give you any date.

Thanks for your understanding and best regards, Sebastian

Hi all,

I'm implementing the examples from the REST How-To and have come across the following behaviour: I've created the basic classes and want to add the method REGISTER_RESOURCES as described in section 2.3.2. Now I have the following code:

  METHOD register_resources.

    registry->register_discoverable_resource(
      EXPORTING
        url             = '/restflights/01/carriers'
        handler_class   = 'CL_SFLIGHT_ADT_RES_CARRIERS'
        description     = 'Carriers'
        category_scheme = 'http://www.mycompany,com/adt/categories/examples/flights'
        category_term   = 'carriers' ).

    collection = registry->register_discoverable_resource(
        url             = '/restflights/01/flights'
*        accepted_types  =
*        handler_class   =
*        parameter       =
        description     = 'Flights'
        category_scheme = 'http://www.mycompany,com/adt/categories/examples/flights'
        category_term   = 'flights'
    ).

  ENDMETHOD.

Naturally, the editor will complain about collection not being defined. If I use the quick fix to declare a local variable, I get

DATA: collection TYPE any.

which is not quite what I expected - I think this should be a TYPE REF TO IF_ADT_DISCOVERY_COLLECTION since this is what the method returns. The backend is SAP_BASIS/ABA 7.31 SP 13. Is this a known issue?

Thanks

  Volker

1 REPLY 1
Read only

sebastian_wolf
Product and Topic Expert
Product and Topic Expert
0 Likes
462

Hi Volker,

yes, this behavior is known - especially in SAP_BASIS 7.31. In this release we can't infer the type to that extent as we currently do it in SAP_BASIS 7.4. In the higher releases we are much better - nevertheless there are still some cases when we need to propose TYPE ANY instead of the complete (correct) type.

We plan to improve this in the future, but unfortunately I can't give you any date.

Thanks for your understanding and best regards, Sebastian