Application Development 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: 

Problem in select_options in AMDP

Former Member
0 Kudos

Hello Expert,

I am using select_options in SAP AMDP. But it is showing the below error:

CLASS ZCL_HANA_AMDP DEFINITION

  PUBLIC

  FINAL

  CREATE PUBLIC .

  PUBLIC SECTION.

 

   INTERFACES:if_amdp_marker_hdb,

                          IF_SHDB_DEF.

  

   TYPES: ty_where_t type TABLE OF IF_SHDB_DEF=>TT_NAMED_DREF.

        

   CLASS-METHODS: select_options importing value(iv_where_cond) type ty_where_t

                                                        exporting value(et_sflight) type tt_sflight.                                

                             

  PROTECTED SECTION.

 

  PRIVATE SECTION.

 

   DATA : itab TYPE TABLE OF sflight.

ENDCLASS.

Error Details:

The method "SELECT_OPTIONS" contains a database procedure, which means that the row type of "IV_WHERE_COND" must be structured. All components of the row type must be elementary.

Please help me to fix this problem.

Thank you.

Best Regards,

Kailash

5 REPLIES 5

former_member289261
Active Contributor
0 Kudos

Hi,

The type you are using has one of the fields of "TYPE REF". The parameters of an AMDP class can only have scalar elements i.e each field should have a fixed data type.

This is one of the limitations of AMDP.

Regards,

Ashish

0 Kudos

Hello Ashish,

Thank you for your reply.

Then in this case what we will do. What is the solution for this. The link I refer is

Can you please check this and help me to fix this issue.

Best Regards,

Kailash

0 Kudos

To use select option in AMDP, you need to convert your select-option table into a "where clause" string.

That can be done using FM "RSDS_RANGE_TO_WHERE".

Please find sample code below :

data : lt_range               type rs_t_rscedst,

          ls_range               type rs_rscedst,

         lv_whereclause     type string.

loop at s_optiontab.

     clear ls_range.

     ls_range-fname = 'FIELDNAME'.                "name of column on which the filter will act

     ls_range-sign = s_optiontab-sign.

     ls_range-option = s_optiontab-option.

     ls_range-low = s_optiontab-low.

l     s_range-high = s_optiontab-high.

     append ls_range to lt_range.

endloop.

call function 'RSDS_RANGE_TO_WHERE'

     exporting

          i_t_range = lt_range

     importing

          e_where = lv_whereclause

     exceptions

     internal_error = 1

     others = 2.

Now, pass this lv_whereclause string to the AMDP class.

Inside the AMDP after you have selected the data into the internal table use the where clause string to filter data by the following syntax.

it_data = APPLY_FILTER(:it_data,:lv_whereclause);

PS: the column on which the filter needs to work has to be in the selected columns i.e it needs to exist in the internal table.

kilian_kilger
Active Participant
0 Kudos

Hi Kailash,

the answer of Ashish is correct.

Another remark would be, what you want to do with the select options in AMDP? You have to resolve them beforehand to a dynamic WHERE condition. See the article on how to solve your problem:

But why are you using AMDP at all? Can't your problem be solved within CDS or Open SQL? Open SQL can handle select options naturally. It is very questionable if you gain any speed by first converting the select options to a dynamic where within the ABAP code and then calling a HANA stored procedure.

Best regards,
Kilian.

0 Kudos

Hello Kilian,

Thank you for your reply.

Yes, we can achieve the same using open sql or CDS view. But for practice purpose i want to do this using AMDP. Can you please help me to fix the problem.

Best Regards,

Kailash