Skip to Content
avatar image
-4
Former Member

Using ABAP Function module in CDS view

Hello,

Could you please let me know if it is possible to use ABAP function module into CDS ?

The aim here is to convert quantity field with the FM MATERIAL_CONVERT_QUANTITY.

Thanks in advance.

Hicham

Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

6 Answers

  • Best Answer
    Mar 06, 2017 at 04:25 PM

    Exactly, "CDS view serves to define the structure of an SQL view". How should a SQL view of the database layer call an ABAP FM of the application layer?

    Add comment
    10|10000 characters needed characters exceeded

  • Mar 06, 2017 at 07:21 PM

    Google -> CDS view unit conversion site:sap.com -> looks like plenty of information

    Add comment
    10|10000 characters needed characters exceeded

  • Mar 06, 2017 at 02:12 PM

    Do you have any idea what CDS is? If yes, how should that work?

    Add comment
    10|10000 characters needed characters exceeded

  • avatar image
    Former Member
    Mar 06, 2017 at 03:07 PM

    if i understood correctly, CDS view is defined for existing database tables. this CDS view serves to define the structure of an SQL view and represents a projection onto one or several Dictionary tables.

    the question here is if it is possible to add a new column to my cds view for example :

    • converted_value

    and convert 1KG to 1000G with MATERIAL_CONVERT_QUANTITY ABAP FM instead of function UNIT_CONVERSION like bellow :

    define view demo_cds_unit_conversion
    with parameters to_unit:abap.unit(3)
    as select from demo_expressions
    { id,
    dec3 as original_value,
    cast( 'MI' as abap.unit(3) ) as original_unit,
    unit_conversion( quantity => dec3,
    source_unit => cast( 'MI' as abap.unit(3) ),
    target_unit => :to_unit,
    error_handling => 'SET_TO_NULL' ) as converted_value,
    :to_unit as converted_unit }

    Thanks in advance.

    Hicham

    Add comment
    10|10000 characters needed characters exceeded

  • avatar image
    Former Member
    Oct 11, 2017 at 01:02 PM

    hi,

    Did you manage to consume bapi in cds view ?

    Add comment
    10|10000 characters needed characters exceeded

  • Jan 16 at 09:43 AM

    Hi,

    CDS Views are basically designed to interact the DB directly and CDS create entity in DB level so basically we are using native DB quarry in CDS. But for any ABAP function or class method there is a way we can use inside our CDS via AMDP, so we call it CDS view with table functions. for that we have to create AMDP class and method and inside our method we can call Function module or Bapi. Then we can use the AMDP class method in side our CDS view to achive our requarement but compare to other CDS views AMDP uses CDS will decrease your performance.

    https://blogs.sap.com/2016/03/25/my-cds-view-self-study-tutorial-part-6-consume-table-function-in-cds-view/

    Thanks,

    Suman Sekhar Mohapatra

    Add comment
    10|10000 characters needed characters exceeded