Dynamic MODIFY ENTITIES OPERATIONS

 In RAP, MODIFY ENTITIES is an EML (Entity Manipulation Language) statement used to:

  •  Create
  •  Update
  •  Delete
  • Execute actions
Dynamic here means you build the modification request at runtime instead of hardcoding entity names and fields.


                       Refer - Working with Large objects(LOB) in RAP
                                        Download the file into local machine.
                                        File type validations in RAP
                                             
Step 1: Create a class and declare interface- if_oo_adt_classrun and implement the main method.

CLASS zcl_ab_eml_dynam DEFINITION

PUBLIC

FINAL

CREATE PUBLIC .

PUBLIC SECTION.

INTERFACES if_oo_adt_classrun.

PROTECTED SECTION.

PRIVATE SECTION.

ENDCLASS.


CLASS zcl_ab_eml_dynam IMPLEMENTATION.

METHOD if_oo_adt_classrun~main.

DATA: lt_create TYPE TABLE FOR CREATE ziv_ab_hdr_stu13,

lt_update TYPE TABLE FOR UPDATE ziv_ab_hdr_stu13,

lt_delete TYPE TABLE FOR UPDATE ziv_ab_hdr_stu13,

lt_op TYPE abp_behv_changes_tab,

lt_failed TYPE abp_behv_response_tab,

LT_reported TYPE abp_behv_response_tab,

LT_mapped TYPE abp_behv_response_tab.


lt_create = VALUE #( ( StuName = 'Anil' StuAge = '28' StuCourse = 'ITI'

StuCourDur = 2 StuStatus = ' ' StuGender = 'M' StuDob = '20010825' ) ).


lt_update = VALUE #( ( %cid_ref = '0EA662BBBE9E1FE097BDAE8EDE7348A9'

StuStatus = 'X' %control-StuStatus = if_abap_behv=>mk-on ) ) .

lt_delete = VALUE #( ( %tky-StuId = '0EA662BBBE9E1FE097B53C800EB768A9' ) ).


lt_op = VALUE #(

( op = if_abap_behv=>op-m-create

entity_name = 'ZIV_AB_HDR_STU13'

instances = REF #( lt_create ) )

( op = if_abap_behv=>op-m-update

entity_name = 'ZIV_AB_HDR_STU13'

instances = REF #( lt_update ) )

( op = if_abap_behv=>op-m-delete

entity_name = 'ZIV_AB_HDR_STU13'

instances = REF #( lt_delete ) )

) .

MODIFY ENTITIES OPERATIONS lt_op

FAILED lt_failed

REPORTED lt_reported

MAPPED lt_mapped.


COMMIT ENTITIES.

ENDMETHOD.

ENDCLASS.


Step 2: Check and activate.

Testing: 
         * Preview the application.
        * Check the entries are created or updated or deleted.


********************************Thank you*****************************

Comments

Popular posts from this blog

New syntax for append- VALUE (new syntax 7.4+) in ABAP

Read statement new syntax in ABAP. (7.4+).

Concatenation new syntax( 7.4+ ).