Control action in SAP using RAP
Refer - Sample example for managed scenario in RAP
Step 1: Table creation, Interface entity creation, consumption view creation are same as mentioned in above link.
Step 2: Change the meta data extension like below (Adding action).
@Metadata.layer: #CORE
@UI: {
headerInfo:
{
typeName: 'Student',
typeNamePlural: 'Students',
title: {
type: #STANDARD,
label: 'Student',
value: 'StudentId'
}
}
}
annotate view ZC_AB_RAP_STUS
with
{
@UI.facet:
[{
id : 'Student',
purpose: #STANDARD,
type: #IDENTIFICATION_REFERENCE,
label: 'Student',
position: 10
}]
@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;
}
Step 3: Check and activate.
Step 4: Change the behavior definition for interface view like below.
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;
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;
}
// field ( mandatory ) StudentId;
}
Step 4: Check and Activate the Above Behavior definition.
Step 5: Change the behavior definition for consumption view like below.
projection;
strict ( 2 );
define behavior for ZC_AB_RAP_STUS alias Student
{
use create;
use update;
use delete;
use action Selected;
}
Step 6: Check and Activate the Above Behavior definition.
Step 7: Goto interface view behavior and implement Selected method (Better to implement all the methods).
Step 8: Select or left side click on Warning message to implement the method.
CLASS lhc_Student DEFINITION INHERITING FROM cl_abap_behavior_handler.
PRIVATE SECTION.
METHODS get_instance_authorizations FOR INSTANCE AUTHORIZATION
IMPORTING keys REQUEST requested_authorizations FOR Student RESULT result.
METHODS get_instance_features FOR INSTANCE FEATURES
IMPORTING keys REQUEST requested_features FOR student RESULT result.
METHODS get_global_authorizations FOR GLOBAL AUTHORIZATION
IMPORTING REQUEST requested_authorizations FOR student RESULT result.
METHODS selected FOR MODIFY
IMPORTING keys FOR ACTION student~selected RESULT result.
ENDCLASS.
CLASS lhc_Student IMPLEMENTATION.
METHOD get_instance_authorizations.
ENDMETHOD.
METHOD get_instance_features.
ENDMETHOD.
METHOD get_global_authorizations.
ENDMETHOD.
METHOD Selected.
MODIFY ENTITIES OF zi_ab_rap_stus IN LOCAL MODE
ENTITY Student
UPDATE
FIELDS ( StudentStatus )
WITH VALUE #( for key in keys ( %tky = key-%tky StudentStatus = abap_true ) )
FAILED failed
REPORTED reported.
READ ENTITIES OF zi_ab_rap_stus in LOCAL MODE
ENTITY Student
ALL FIELDS WITH CORRESPONDING #( keys )
RESULT data(studentdata).
RESULT = VALUE #( for studentrec in studentdata ( %tky = studentrec-%tky %param = studentrec ) ).
ENDMETHOD.
ENDCLASS.
Step 9: Check and activate the class.
Step 10: Check all are activated or not (If not activated Please activate all).
-----------------------------------------------------------------------------------------------------
Testing:
All data: Click on go to button.
* Select the first entry and click on selected.
* Status is changed to yes.
********************************Thank You*****************************
Comments
Post a Comment