In this post, you will learn to handle SELECT-OPTION in AMDP. The post also explains how client handling is done in AMDP.
Select options or Range tables can not be used in SQLSCRIPT the way we use it in ABAP SQL / OPEN SQL. Due to this reason, we need special code to handle select options in AMDP.
For this tutorial, a range table is used. Select option can be used with so_name[ ] instead of range.
In previous post, method with single carrier id as input was created. You can pass a parameter to this method easily.

Select options are not passed as it though. You first need to convert them to a where clause.
Consider below range for carrier id.

Now, add rows in this range.

Convert SO/Range table to where clause – the type is string. Class method cl_shdb_seltab=>combine_seltabs
is used for this.
Multiple select options can be passed repeating the name, dref combination highlighted within red box.

Note the yellow box. This is how the client is handled. Client handling is required to be done explicitly in AMDP.
The new method definition will not use a field for carrier id, but will have a field with type string to pass the where clause.

The last thing is to apply the where clause. This can be done in two ways.
- Apply while fetching data the first time
- Apply filter on temporary table post fetching the data


This way, we can handle Select-Options in AMDP. The result is as below –

Code In Text
"AMDP with Select Option
CLASS zjp_so_amdp_class DEFINITION
PUBLIC FINAL CREATE PUBLIC .
PUBLIC SECTION.
INTERFACES : if_amdp_marker_hdb.
TYPES : tt_flights TYPE STANDARD TABLE OF /dmo/flight.
DATA : r_carrier TYPE RANGE OF /dmo/flight-carrier_id.
CLASS-METHODS :
call_amdp,
get_flights_range
IMPORTING VALUE(iv_where) TYPE string
EXPORTING VALUE(et_flights) TYPE tt_flights.
ENDCLASS.
CLASS zjp_so_amdp_class IMPLEMENTATION.
METHOD call_amdp.
"Create range | Directly use select option here
r_carrier = VALUE #( sign = 'I' option = 'EQ'
( low = 'AZ')
( low = 'JP' )
).
"Prepare where from selection tabs
DATA(lv_where) =
cl_shdb_seltab=>combine_seltabs(
EXPORTING
it_named_seltabs = VALUE #( ( name = 'CARRIER_ID'
dref = REF #( r_carrier ) ) )
iv_client_field = 'CLIENT' ). "Handle Client
get_flights_range( EXPORTING iv_where = lv_where
IMPORTING et_flights = DATA(lt_flights) ).
ENDMETHOD.
METHOD get_flights_range BY DATABASE PROCEDURE
FOR HDB
LANGUAGE SQLSCRIPT
OPTIONS READ-ONLY
USING /dmo/flight.
et_flights = APPLY_FILTER ( "/DMO/FLIGHT", :iv_where );
ENDMETHOD.
ENDCLASS.
"Another implementation of AMDP
METHOD get_flights_range BY DATABASE PROCEDURE
FOR HDB
LANGUAGE SQLSCRIPT
OPTIONS READ-ONLY
USING /dmo/flight.
temp = select * from "/DMO/FLIGHT";
et_flights = APPLY_FILTER ( :temp, :iv_where );
ENDMETHOD.
Visit ABAP on HANA series for Tutorials on CDS, AMDP, Eclipse, and ALV IDA.
If you like the content, please subscribe…