Adding table in object level in SAP using RAP

                              Refer -  Sample example for managed scenario

                     Refer - Control action in RAP                

                    Refer - Custom action change state

                             Refer - Search help in RAP

In this blogspot we need to print Student qualifications.

Like Student Qualification, from, to, percentage.

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

Create Domain for Student Qualification

Step 1: Create a Domain for qualification. 

            * Right click -- New -- other repository object -- dictionary -- domain.

              * Check and activate the domain.

Step 2: Create data element for the above domain.


        * Check and activate the domain.

Step 3: Create data element for student.

            * Check and activate the domain.

Step 4: Change the data type in old table also when you used in student id.

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

Create a Table

   * Student ID

    * Student qualification

    * From

    * To

    * Percentage

Step 1:  Right click -- New-- Other ABAP repository object-- Dictionary-- database table.

Step 2: Click on next and give table name (ZTL_AB_RAP_STUQ) and description (Student Qualification table).

Step 3: Click on next and select TR and finish.

Step 4: Add fields.

    @EndUserText.label : 'Student Qualification table'

    @AbapCatalog.enhancement.category : #NOT_EXTENSIBLE

    @AbapCatalog.tableCategory : #TRANSPARENT

    @AbapCatalog.deliveryClass : #A

    @AbapCatalog.dataMaintenance : #RESTRICTED

    define table ztl_ab_rap_stuq

    {


     key client : abap.clnt not null;

    @AbapCatalog.foreignKey.screenCheck : false

    key student_id : zde_ab_rap_studen not null

    with foreign key ztl_ab_rap_stus

    where client = ztl_ab_rap_stuq.client

    and student_id = ztl_ab_rap_stuq.student_id;

    key student_qual : zde_ab_rap_stuq not null;

    qual_desc : abap.char(30);

    student_from : abap.datn;

    student_to : abap.datn;

    student_percent : abap.numc(2);


    }

Step 5: Check and activate the table.

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

Create data definition for that domain.

 Step 1:  Right click -- new -- other repository object -- Core data service -- data definition.

Step 2: Click on next and select the package and click on next select define view entity.

Step 3:  Write the code.

    @AbapCatalog.viewEnhancementCategory: [#NONE]

    @AccessControl.authorizationCheck: #NOT_REQUIRED

    @EndUserText.label: 'Domain for student qualification'

    @Metadata.ignorePropagatedAnnotations: true

    @ObjectModel.usageType:{

    serviceQuality: #X,

    sizeCategory: #S,

    dataClass: #MIXED

    }

    define view entity ZI_D_AB_RAP_STUQ

    as select from DDCDS_CUSTOMER_DOMAIN_VALUE_T( p_domain_name: 'ZD_AB_RAP_STUQ' )

    {

    key domain_name,

    key value_position,

    @Semantics.language: true

    key language,

    value_low as Value,

    @Semantics.text: true

    text as Description

    }

Step 4: Check and activate     

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

Create Interface view for student qualification


Step1: Right click -- New -- Other ABAP repository object -- Core data services -- Data definition.

Step 2: Give name and description.

Step 3: Click on next select package, select template as define view entity and finish.

Step 4: Write Code.

    @AbapCatalog.viewEnhancementCategory: [#NONE]

    @AccessControl.authorizationCheck: #NOT_REQUIRED

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

    @Metadata.ignorePropagatedAnnotations: true

    @Metadata.allowExtensions: true

    @ObjectModel.usageType:{

    serviceQuality: #X,

    sizeCategory: #S,

    dataClass: #MIXED

    }

    define view entity ZI_AB_RAP_STUQ as select from ztl_ab_rap_stuq

    association to parent ZI_AB_RAP_STUS as _student on $projection.StudentId = _student.StudentId

    association to ZI_D_AB_RAP_STUQ as _qual on $projection.StudentQual = _qual.Value

    {

    key ztl_ab_rap_stuq.student_id as StudentId,

    key ztl_ab_rap_stuq.student_qual as StudentQual,

    ztl_ab_rap_stuq.qual_desc as QualDesc,

    ztl_ab_rap_stuq.student_from as StudentFrom,

    ztl_ab_rap_stuq.student_to as StudentTo,

    ztl_ab_rap_stuq.student_percent as StudentPercent,

    _student,

    _qual

    }


Step 5:  Check and activate.

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

Adding composition to main entity


Step1: Double click on main entity and composition to main entity.

    @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,

    _gender,

    _qualify

    }

Step 2: Check and activate.


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

Create meta data extension for interface view (student qualification)


Step 1: Right click on interface view -- New Meta data extension.

Step 2: Give name, description 

Step 3: Click on next select package, select annotate view and click on finish.

Step 4: Write code.

@Metadata.layer: #CORE

@UI: {

headerInfo:

{

typeName: 'Student Qualifications',

typeNamePlural: 'Student Qualifications',

title: {

type: #STANDARD,

label: 'Student Qualifications',

value: 'StudentId'

}

}

}

@Search.searchable: true

annotate entity ZI_AB_RAP_STUQ

with

{

@UI.facet:

[{

id : 'Student_Qualifications',

purpose: #STANDARD,

type: #IDENTIFICATION_REFERENCE,

label: 'Student Qualifications',

position: 10

}

]

@UI:

{

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

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

selectionField: [{ position: 10 }]

}

@Search.defaultSearchElement: true

StudentId;

@UI:

{

lineItem: [{ position: 20 , importance :#HIGH , label : 'Student Qualification'}],

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

selectionField: [{ position: 20 }]

}

@Consumption.valueHelpDefinition: [{ entity : { name : 'ZI_D_AB_RAP_STUQ', element: 'Value' },

distinctValues: true,

additionalBinding: [{ localElement: 'QualDesc',

element: 'Description',

usage: #FILTER_AND_RESULT

}]

}]

@Search.defaultSearchElement: true

StudentQual;

@UI:

{

lineItem: [{ position: 25 , importance :#HIGH , label : 'Qualification Description'}],

identification: [{ position: 25 , label : 'Qualification Description' }]

}

QualDesc;

@UI:

{

lineItem: [{ position: 30 , importance :#HIGH , label : 'Student From'}],

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

}

@Search.defaultSearchElement: true

StudentFrom;

@UI:

{

lineItem: [{ position: 40 , importance :#HIGH, label : 'Student To'}],

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

}

@Search.defaultSearchElement: true

StudentTo;

@UI:

{

lineItem: [{ position: 50 , importance :#HIGH ,label : 'Student Percentage'}],

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

}

@Search.defaultSearchElement: true

StudentPercent;

}

Step 5: Check and activate.

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

Change meta data extension (Main)

Step 1: Change the MDE.

@Metadata.layer: #CORE

@UI: {

headerInfo:

{

typeName: 'Student',

typeNamePlural: 'Students',

title: {

type: #STANDARD,

label: 'Student',

value: 'StudentId'

}

}

}

annotate view ZI_AB_RAP_STUS

with

{

@UI.facet:

[{

id : 'Student',

purpose: #STANDARD,

type: #IDENTIFICATION_REFERENCE,

label: 'Student',

position: 10

},

{ id : 'Student_Qualification',

purpose: #STANDARD,

type: #LINEITEM_REFERENCE,

label: 'Student Qualification',

position: 20,

targetElement: '_qualify'

}

]

@UI:

{

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

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

selectionField: [{ position: 10 }]

}

StudentId;

@UI:

{

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

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

selectionField: [{ position: 20 }]

}

StudentName;

@UI:

{

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

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

}

StudentILoc;

@UI:

{

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

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

}

StudentIDate;

@UI:

{

lineItem: [{ position: 50 , label : 'Student Interview Status'},

{ type: #FOR_ACTION, dataAction: 'Selected', label: 'Selected' }],

identification: [{ position: 50 , label : 'Student Interview Status' },

{ type: #FOR_ACTION, dataAction: 'Selected', label: 'Selected' } ]

}

StudentStatus;

@UI:

{

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

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

}

@Consumption.valueHelpDefinition: [{ entity : { name : 'ZI_D_AB_RAP_STUDS', element: 'Value' },

distinctValues: true,

additionalBinding: [{ localElement: 'Description',

element: 'Description',

usage: #FILTER_AND_RESULT

}]

}]

StudentGender;

@UI:

{

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

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

}

Description;

}

Step 2: check and activate.


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

Change behavior definition


Step 1: Change the BD.

managed implementation in class zbp_i_ab_rap_stus unique;

strict ( 2 );


define behavior for ZI_AB_RAP_STUS alias Student

persistent table ztl_ab_rap_stus

lock master

authorization master ( instance )

//etag master <field_name>

{

create ( authorization : global );

update;

delete;

association _qualify{ create; }

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

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;


}

// field ( mandatory ) StudentId;

}



define behavior for ZI_AB_RAP_STUQ alias Qualification

persistent table ZTL_AB_RAP_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 2: check and activate.

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

Change service definition

Step 1: Change SD.

@EndUserText.label: 'Service definition for Student'

define service Zsd_ab_rap_stus

{

expose ZI_AB_RAP_STUS;

expose ZI_AB_RAP_STUQ;

}

Step 2: check and activate.

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

Testing:

Step 1: Preview the application.

Step 2: Click on go to.



Step 3: Select one record and create records.




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