Change set processing in RAP

*  All-or-nothing processing of multiple changes in one request.

* #CHANGE_SET can be used with 

                        @Ul.lineltem.invocationGrouping

                        @UI.statusinfo.invocationGrouping

                        @Ul.chart.actions.invocationGrouping 

                        @Ul.fieldGroup.invocationGrouping

                        @Ul.identification.invocationGrouping

Steps to implement CHANGE_SET processing

                                     Refer - Sample example for managed scenario in RAP

Step 1: Create a table with following fields.

@EndUserText.label : 'Students table'

@AbapCatalog.enhancement.category : #NOT_EXTENSIBLE

@AbapCatalog.tableCategory : #TRANSPARENT

@AbapCatalog.deliveryClass : #A

@AbapCatalog.dataMaintenance : #RESTRICTED

define table ztl_ab_rap_stu11

{


key client : abap.clnt not null;

key stu_id : abap.dec(10,0) not null;

stu_name : abap.char(25);

stu_age : abap.numc(2);

stu_course : abap.char(30);

stu_cour_dur : abap.numc(2);

stu_status : abap_boolean;

stu_gender : abap.char(1);

stu_dob : abap.dats;

last_ch_time : timestampl;

last_ch_date : timestampl;


}

Step 2: Create interface view for above table.

@AbapCatalog.viewEnhancementCategory: [#NONE]

@AccessControl.authorizationCheck: #NOT_REQUIRED

@EndUserText.label: 'Interface entity view for student'

@Metadata.ignorePropagatedAnnotations: true

@ObjectModel.usageType:{

serviceQuality: #X,

sizeCategory: #S,

dataClass: #MIXED

}

define root view entity ZIV_AB_RAP_STU11

as select from ztl_ab_rap_stu11

{

key stu_id as StuId,

stu_name as StuName,

stu_age as StuAge,

stu_course as StuCourse,

stu_cour_dur as StuCourDur,

stu_status as StuStatus,

stu_gender as StuGender,

stu_dob as StuDob,

last_ch_time as LastChTime,

last_ch_date as LastChDate

}

Step 3: Create projection/consumption view for above interface view.

@AbapCatalog.viewEnhancementCategory: [#NONE]

@AccessControl.authorizationCheck: #NOT_REQUIRED

@EndUserText.label: 'Consumption view for student'

@Metadata.ignorePropagatedAnnotations: true

@Metadata.allowExtensions: true

@ObjectModel.usageType:{

serviceQuality: #X,

sizeCategory: #S,

dataClass: #MIXED

}

define root view entity ZCV_AB_RAP_STU11

as projection on ZIV_AB_RAP_STU11

{

key StuId,

StuName,

StuAge,

StuCourse,

StuCourDur,

StuStatus,

StuGender,

StuDob,

LastChTime,

LastChDate

}

Step 4: Create meta data extension for consumption view.

@Metadata.layer: #CORE

@UI: {

headerInfo:

{

typeName: 'Student',

typeNamePlural: 'Students',

title: {

type: #STANDARD,

label: 'Student',

value: 'StuId'

}

}

}

annotate view ZCV_AB_RAP_STU11

with

{

@UI.facet:

[{

id : 'Student',

purpose: #STANDARD,

type: #IDENTIFICATION_REFERENCE,

label: 'Student',

position: 10

}

]

@UI:

{

lineItem: [{ position: 10 , label : 'Update Status',

type: #FOR_ACTION,

dataAction: 'StatusUpdate',

invocationGrouping: #CHANGE_SET }],

identification: [{ position: 10 , label : 'Student ID' }],

selectionField: [{ position: 10 }]

}

StuId;

@UI:

{

lineItem: [{ position: 20 , label : 'Student Name'}],

identification: [{ position: 20 , label : 'Student Name' }],

selectionField: [{ position: 20 }]

}

StuName;

@UI:

{

lineItem: [{ position: 30 , label : 'Student Age'}],

identification: [{ position: 30 , label : 'Student Age' }]

}

StuAge;

@UI:

{

lineItem: [{ position: 40 , label : 'Student Course'}],

identification: [{ position: 40 , label : 'Student Course' }]

}

StuCourse;

@UI:

{

lineItem: [{ position: 50 , label : 'Student Course Duration'}],

identification: [{ position: 50 , label : 'Student Course Duration' }]

}

StuCourDur;

@UI:

{

lineItem: [{ position: 60 , label : 'Student Status'}],

identification: [{ position: 60 , label : 'Student Status' }]

}

StuStatus;

@UI:

{

lineItem: [{ position: 70 , label : 'Student Gender'}],

identification: [{ position: 70 , label : 'Student Gender' }]

}

StuGender;

@UI:

{

lineItem: [{ position: 80 , label : 'Student DOB'}],

identification: [{ position: 80 , label : 'Student DOB' }]

}

StuDob;

}

Step 5: Create behavior definition for interface view.

managed implementation in class zbp_iv_ab_rap_stu11 unique;

strict ( 2 );


define behavior for ZIV_AB_RAP_STU11 alias Student

persistent table ztl_ab_rap_stu11

lock master

authorization master ( global )

//etag master <field_name>

{

create ( authorization : global );

update;

delete;

action StatusUpdate;

mapping for ztl_ab_rap_stu11

{

StuId = stu_id;

StuName = stu_name;

StuAge = stu_age;

StuCourse = stu_course;

StuCourDur = stu_cour_dur;

StuStatus = stu_status;

StuGender = stu_gender;

StuDob = stu_dob;

LastChDate = last_ch_date;

LastChTime = last_ch_time;

}


}

Step 6: Create behavior definition for consumption view.

projection;

strict ( 2 );


define behavior for ZCV_AB_RAP_STU11 alias Student

{

use create;

use update;

use delete;

use action StatusUpdate;

}

Step 7: Implement the class and method.

CLASS lhc_Student DEFINITION INHERITING FROM cl_abap_behavior_handler.

PRIVATE SECTION.


METHODS get_global_authorizations FOR GLOBAL AUTHORIZATION

IMPORTING REQUEST requested_authorizations FOR Student RESULT result.


METHODS StatusUpdate FOR MODIFY

IMPORTING keys FOR ACTION Student~StatusUpdate.


ENDCLASS.


CLASS lhc_Student IMPLEMENTATION.


METHOD get_global_authorizations.

ENDMETHOD.


METHOD StatusUpdate.

READ ENTITIES OF ziv_ab_rap_stu11 IN LOCAL MODE

ENTITY Student

ALL FIELDS WITH CORRESPONDING #( keys )

RESULT data(lt_students)

failed failed.

SORT lt_students BY StuStatus DESCENDING.

LOOP AT lt_students ASSIGNING FIELD-SYMBOL(<ls_students>).

<ls_students>-StuStatus = abap_true.

ENDLOOP.

MODIFY ENTITIES OF ziv_ab_rap_stu11 IN LOCAL MODE

ENTITY Student

UPDATE FIELDS ( StuStatus ) WITH CORRESPONDING #( lt_students ).

ENDMETHOD.


ENDCLASS.

Step 8: Create service definition for consumption view.

@EndUserText.label: 'Service definition for Student'

define service Zsd_ab_rap_stu11

{

expose ZCV_AB_RAP_STU11;

}

Step 9:  Create service binding for above service definition with binding type OData V2 - UI.

            * Check and activate then publish the service.

Step 10: Create entries and perform actions.

                * Click on create and give details.


                * Select the entry and click on update status button. Student status set to true.



Step 11: Goto Business Application Studio and create application.

        * Right click on menu - File - New project from template.

        * Select SAP Fiori generator and click on start.

        * Select list report page and click on next.

        * Select data source - connect to system, choose system and give service as ZSB_AB_RAP_STUS11.


      
 * Click on next and check entity is correct or not.

        * Click on next, give module and app title select path and finish.

        * Preview the application (Right click on project and click on preview application).

        * Radio buttons selects only single row.

        * Expand web app, Click on Manifest.json and add logic.


Step 12: Testing

        * Preview the application.


        * Check boxes are added you can select multiple and click on status update.

        * Multiple records are updated.


********************************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+ ).