Custom action change state in SAP using RAP

 

                            Refer - Control action in RAP

Step 1: All the steps are same as mentioned in Above link.

Step 2: Add implementation to GET_INSTANCE_FEATURES.

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.

READ ENTITIES OF zi_ab_rap_stus IN LOCAL MODE

ENTITY Student

FIELDS ( StudentStatus ) WITH CORRESPONDING #( KEYS )

RESULT DATA(selected)

FAILED failed.


RESULT = VALUE #( FOR STUS IN selected LET

STATUSVALUE = COND #( WHEN STUS-StudentStatus = ABAP_TRUE

THEN IF_ABAP_BEHV=>fc-O-disabled

ELSE IF_ABAP_BEHV=>fc-O-enabled )


IN ( %TKY = STUS-%tky

%ACTION-Selected = statusvalue )

).

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 3: Check and activate.

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

Testing:

        * Preview the application.

        * Click on go to see all records.



        * Select the first record which is student status is YES (Selected button is disabled).



        * Select the Second record which is student status is NO (Selected button enabled).


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