We have added three buttons EDIT, CANCEL and SAVE buttons to the over view page in the previous tutorial.
Let us code in the event handlers of those buttons.
Go to the component and overview page and create event handlers with name ‘EDIT’, ‘CANCEL’ and ‘SAVE’. (Event handler names are case sensitive;all these name of event handlers should match with on click properties of buttons that we have created in the previous chapter).
EDIT event handler.
First we are reading current record from the context node HEADER into LR_ENTITY.
Next, we are checking, it is bound or not.
Next we are using method IS_CHANGE_ALLOWED or not, if change is allowed, then we are applying LOCK on that record.
Next if lock is successful, using VIEW_GROUP_CONTEXT, we are setting all views editable else we are just resetting the view group context, which put all views into display mode.
We are reading the current record and getting the instance of transaction from it. calling the revert method will cancel all the changes that we have done.
Calling reset method will put all views into display mode.
We are reading the current record from the context node. If node is bound, then we are taking the transaction context of it.
If it is initial, then we are asking core class to provide the transaction context.
Then we are checking whether save operation is possible or not using CHECK_SAVE_POSSIBLE method. If we can save the transaction, then we are calling SAVE method and commit the work with one more method COMMIT.
One save is done, then put all views into display mode by resetting the view group context.
Activate all methods and test the application.
Clicking on EDIT button will make all views shift into edit mode.
Press cancel button, all views will go into display mode.
Next , we will learn one important topic called UI OBJECT TYPE.
Let us code in the event handlers of those buttons.
Go to the component and overview page and create event handlers with name ‘EDIT’, ‘CANCEL’ and ‘SAVE’. (Event handler names are case sensitive;all these name of event handlers should match with on click properties of buttons that we have created in the previous chapter).
EDIT event handler.
Write the following code in the event handler.
First we are reading current record from the context node HEADER into LR_ENTITY.
Next, we are checking, it is bound or not.
Next we are using method IS_CHANGE_ALLOWED or not, if change is allowed, then we are applying LOCK on that record.
Next if lock is successful, using VIEW_GROUP_CONTEXT, we are setting all views editable else we are just resetting the view group context, which put all views into display mode.
CANCEL event handler:
We are reading the current record and getting the instance of transaction from it. calling the revert method will cancel all the changes that we have done.
Calling reset method will put all views into display mode.
SAVE event handler:
We are reading the current record from the context node. If node is bound, then we are taking the transaction context of it.
If it is initial, then we are asking core class to provide the transaction context.
Then we are checking whether save operation is possible or not using CHECK_SAVE_POSSIBLE method. If we can save the transaction, then we are calling SAVE method and commit the work with one more method COMMIT.
One save is done, then put all views into display mode by resetting the view group context.
Activate all methods and test the application.
Clicking on EDIT button will make all views shift into edit mode.
Press cancel button, all views will go into display mode.
Next , we will learn one important topic called UI OBJECT TYPE.