0% found this document useful (0 votes)
65 views2 pages

4eml Crud

This document defines a class called zrap_test_bo_using_eml that implements the CRUD operations on a sales order entity using EML. It contains a method that performs different operations based on a passed operation code, including: creating a new sales order, updating an existing order's currency, deleting an order, and reading an order.

Uploaded by

sai b
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
65 views2 pages

4eml Crud

This document defines a class called zrap_test_bo_using_eml that implements the CRUD operations on a sales order entity using EML. It contains a method that performs different operations based on a passed operation code, including: creating a new sales order, updating an existing order's currency, deleting an order, and reading an order.

Uploaded by

sai b
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 2

"1"EML<==>CRUD

CLASS zrap_test_bo_using_eml DEFINITION


PUBLIC
FINAL
CREATE PUBLIC .

PUBLIC SECTION.
DATA: lv_oper TYPE c VALUE 'R'.
"DATA: lv_oper TYPE c VALUE 'D'.
"DATA: lv_oper TYPE c VALUE 'U'.
"DATA: lv_oper TYPE c VALUE 'C'
INTERFACES if_oo_adt_classrun.
PROTECTED SECTION.
PRIVATE SECTION.
ENDCLASS.

CLASS zrap_test_bo_using_eml IMPLEMENTATION.


METHOD if_oo_adt_classrun~main.
CASE lv_oper.
WHEN 'C'.

DATA: it_so_create TYPE TABLE FOR CREATE zrap_cds_sales_order.


"populate the data in the internal table
it_so_create = VALUE #( ( SoId = '0001' Customer = 'XXXBAS DMO'
GrossAmount = 8000 CurrencyCode ='EUR'
OrderStatus ='Y'
%control = VALUE #( SoId = if_abap_behv=>mk-on
Customer =
if_abap_behv=>mk-on
GrossAmount =
if_abap_behv=>mk-on
CurrencyCode =
if_abap_behv=>mk-on
A OrderStatus =
if_abap_behv=>mk-on
)

) ).
MODIFY ENTITIES OF zrap_cds_sales_order
ENTITY orders
CREATE FROM it_so_create
FAILED DATA(lt_failed)
REPORTED DATA(lt_reported).

IF lt_failed IS NOT INITIAL.


out->write(
EXPORTING
data = lt_failed
name = 'failed'
* RECEIVING
* output =
).

ENDIF.

WHEN 'U'.
DATA: it_instance_u TYPE TABLE FOR UPDATE zrap_cds_sales_order.
it_instance_u = VALUE #( ( SoId = '0002' CurrencyCode = 'INR'
%control = VALUE #( CurrencyCode =
if_abap_behv=>mk-on )
) ).

MODIFY ENTITIES OF zrap_cds_sales_order


ENTITY orders
UPDATE FROM it_instance_u
FAILED lt_failed
REPORTED lt_reported.

WHEN 'D'.
DATA: it_instance_d TYPE TABLE FOR DELETE zrap_cds_sales_order.
it_instance_d = VALUE #( ( SoId = '0001' ) ).
MODIFY ENTITIES OF zrap_cds_sales_order
ENTITY orders
DELETE FROM it_instance_d
FAILED lt_failed

REPORTED lt_reported.
*
* if ( 0 = 1 ).
* endif.

WHEN 'R'.
READ ENTITIES OF zrap_cds_sales_order
ENTITY orders
FROM VALUE #( ( SoId = '0002' %control = VALUE #(
SoId = if_abap_behv=>mk-on
Customer = if_abap_behv=>mk-on
GrossAmount = if_abap_behv=>mk-on
CurrencyCode = if_abap_behv=>mk-
on
OrderStatus = if_abap_behv=>mk-on
) ) )
RESULT DATA(lt_read)
FAILED lt_failed
REPORTED lt_reported.

out->write(
EXPORTING
data = lt_read
* name =
* RECEIVING
* output =
).

ENDCASE.
COMMIT ENTITIES.

ENDMETHOD.

ENDCLASS.

You might also like