Adding draft functionality in RAP

            Refer -  Sample example for managed scenario

                   Refer -  Validations in Rap

Step 1: Adding new fields in main table.

@EndUserText.label : 'Student interview details'

@AbapCatalog.enhancement.category : #NOT_EXTENSIBLE

@AbapCatalog.tableCategory : #TRANSPARENT

@AbapCatalog.deliveryClass : #A

@AbapCatalog.dataMaintenance : #RESTRICTED

define table ztl_ab_rap_stus

{


key client : abap.clnt not null;

key student_id : zde_ab_rap_studen not null;

student_name : abap.char(30);

student_i_loc : abap.char(20);

student_i_date : abap.datn;

student_status : abap_boolean;

student_gender : abap.char(1);

description : abap.char(6);

last_chdate : timestampl;

loc_last_chdate : timestampl;


}

        * Check and activate.

Step 2: Adding new fields in interface entity view.

@AbapCatalog.viewEnhancementCategory: [#NONE]

@AccessControl.authorizationCheck: #NOT_REQUIRED

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

@Metadata.ignorePropagatedAnnotations: true

@Metadata.allowExtensions: true

@ObjectModel.usageType:{

serviceQuality: #X,

sizeCategory: #S,

dataClass: #MIXED

}

define root view entity ZI_AB_RAP_STUS

as select from ztl_ab_rap_stus

composition [0..*] of ZI_AB_RAP_STUQ as _qualify

association [0..1] to ZI_D_AB_RAP_STUDS as _gender on $projection.StudentGender = _gender.Value

{

@EndUserText.label: 'Student ID'

key ztl_ab_rap_stus.student_id as StudentId,

@EndUserText.label: 'Student Name'

ztl_ab_rap_stus.student_name as StudentName,

@EndUserText.label: 'Student Int Loc'

ztl_ab_rap_stus.student_i_loc as StudentILoc,

@EndUserText.label: 'Student Int Date'

ztl_ab_rap_stus.student_i_date as StudentIDate,

@EndUserText.label: 'Student Status'

ztl_ab_rap_stus.student_status as StudentStatus,

@EndUserText.label: 'Student Gender'

ztl_ab_rap_stus.student_gender as StudentGender,

@EndUserText.label: 'Gender Desc'

ztl_ab_rap_stus.description as Description,

last_chdate,

loc_last_chdate,

_gender,

_qualify

}

        *  Check and activate.

Step 3: Change behavior definition - Adding draft in behavior definition.

managed implementation in class zbp_i_ab_rap_stus unique;

strict ( 2 );


with draft;

define behavior for ZI_AB_RAP_STUS alias Student

persistent table ztl_ab_rap_stus

draft table ztl_ab_dra_stus

lock master total etag last_chdate

authorization master ( instance )

etag master loc_last_chdate

{

create ( authorization : global );

update;

delete;

draft action edit;

draft action resume;

draft determine action prepare;

draft action activate;

draft action discard;

association _qualify{ create; }

action ( features : instance ) Selected result [1] $self;

validation validateid on save { field StudentId; create; }

mapping for ztl_ab_rap_stus

{

StudentId = student_id;

StudentName = student_name;

StudentILoc = student_i_loc;

StudentIDate = student_i_date;

StudentStatus = student_status;

StudentGender = student_gender;

Description = description;


}


}

define behavior for ZI_AB_RAP_STUQ alias Qualification

persistent table ZTL_AB_RAP_STUQ

draft table ZTL_AB_drf_STUQ

lock dependent by _student

authorization dependent by _student

{


update;

delete;

association _student;

field ( readonly ) StudentId;

field ( readonly ) QualDesc;

mapping for ZTL_AB_RAP_STUQ

{

StudentId = student_id;

StudentQual = student_qual;

QualDesc = qual_desc;

StudentFrom = student_from;

StudentTo = student_to;

StudentPercent = student_percent;

}


}

Step 4: Create draft tables.

@EndUserText.label : 'Draft table for entity ZI_AB_RAP_STUS'

@AbapCatalog.enhancement.category : #EXTENSIBLE_ANY

@AbapCatalog.tableCategory : #TRANSPARENT

@AbapCatalog.deliveryClass : #A

@AbapCatalog.dataMaintenance : #RESTRICTED

define table ztl_ab_dra_stus {


key mandt : mandt not null;

key studentid : zde_ab_rap_studen not null;

studentname : abap.char(30);

studentiloc : abap.char(20);

studentidate : abap.datn;

studentstatus : abap_boolean;

studentgender : abap.char(1);

description : abap.char(6);

last_chdate : timestampl;

loc_last_chdate : timestampl;

"%admin" : include sych_bdl_draft_admin_inc;


}


@EndUserText.label : 'Draft table for entity ZI_AB_RAP_STUQ'

@AbapCatalog.enhancement.category : #EXTENSIBLE_ANY

@AbapCatalog.tableCategory : #TRANSPARENT

@AbapCatalog.deliveryClass : #A

@AbapCatalog.dataMaintenance : #RESTRICTED

define table ztl_ab_drf_stuq {


key mandt : mandt not null;

key studentid : zde_ab_rap_studen not null;

key studentqual : zde_ab_rap_stuq not null;

qualdesc : abap.char(30);

studentfrom : abap.datn;

studentto : abap.datn;

studentpercent : abap.numc(2);

"%admin" : include sych_bdl_draft_admin_inc;


}

        * Check and activate.

Step 5: Preview the application.

----------------------------------------------------------------------------------------------

Testing:

Step 1: Click on go to see all records.


Step 2: Goto object page and click on edit. I changed the name from 'Ajay' to 'Ajay babu'.


Step 3: Go back without saving. These data stored in draft table not a main table.


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