cancel
Showing results for 
Search instead for 
Did you mean: 

Dynamic mandatory field or force refresh view

693

Hello.
I am trying to make a field mandatory depending on the status of an object. I do it through "external_calculation".

View Code:

@AbapCatalog.sqlViewName: 'ZIDVAGOODSRECSTP'
@AbapCatalog.compiler.compareFilter: true
@AbapCatalog.preserveKey: true
@AccessControl.authorizationCheck: #CHECK
@EndUserText.label: 'Goods Records View'

@VDM.viewType: #TRANSACTIONAL

@ObjectModel.modelCategory: #BUSINESS_OBJECT
@ObjectModel.compositionRoot: true
@ObjectModel.transactionalProcessingEnabled: true
@ObjectModel.writeActivePersistence:'ZTDVA_GOODS'
@ObjectModel.createEnabled: true
@ObjectModel.deleteEnabled: true
@ObjectModel.updateEnabled: true
@ObjectModel.draftEnabled: true
@ObjectModel.writeDraftPersistence: 'ZTDVA_GOODS_D'
@ObjectModel.semanticKey: ['GoodUuid', 'StoreUuid']

define view ZI_DVA_GoodsRecordsTP 
as select from ZI_DVA_Goods 
{   
    @ObjectModel.readOnly: true
    key GoodUuid,
    @ObjectModel.mandatory: true
    StoreUuid,
    @ObjectModel.mandatory: true
    Name,
    @ObjectModel.mandatory: 'EXTERNAL_CALCULATION'
    Quantity,
    @Semantics.amount.currencyCode : 'Currency'
    @ObjectModel.mandatory: true
    Price,
    @Semantics.currencyCode: true
    @ObjectModel.mandatory: true
    Currency,
    @ObjectModel.mandatory: true
    StatusUuid,
    
    _Statuses.Status,
    _Stores.Name as StoreName,

    _Statuses,
    _Stores,
    _GoodsLogs
}

Code in determination:

method /BOBF/IF_FRW_DETERMINATION~EXECUTE.

    DATA lt_goods TYPE ztidva_goodsrecordstp.

    io_read->retrieve(
    EXPORTING
        iv_node = is_ctx-node_key
        it_key  = it_key
    IMPORTING
        et_data = lt_goods ).

    data(lo_property_helper) = new /bobf/cl_lib_h_set_property( io_modify = io_modify
                                                    is_context = is_ctx ).

    LOOP AT lt_goods INTO DATA(ls_good).

        IF ls_good-StatusUuid = 'mS{Jam7V7ko6s72CWlRP{W'.
            lo_property_helper->set_attribute_mandatory(
                iv_attribute_name = zif_i_dva_goodsrecordstp_c=>sc_node_attribute-zi_dva_goodsrecordstp-quantity
                iv_value          = abap_true
                iv_key            = ls_good-key ).
        ELSE.
            lo_property_helper->set_attribute_mandatory(
                iv_attribute_name = zif_i_dva_goodsrecordstp_c=>sc_node_attribute-zi_dva_goodsrecordstp-quantity
                iv_value          = abap_false
                iv_key            = ls_good-key ).
        ENDIF.

    ENDLOOP.
  endmethod.

This way works. Only if you change the status and refresh the page or click on the save button, the action of which updates the view. How do I make the view change without refreshing the page or how do I refresh the view?

former_member751591
Participant
0 Kudos

Thank you for visiting SAP Community to get answers to your questions. Since you're asking a question here for the first time, I recommend that you familiarize yourself with Community Q&A , as it provides tips for preparing questions that draw responses from our members.

For example, you can:

- outline what steps you took to find answers (and why they weren't helpful)

- share screenshots of what you've seen/done

- make sure you've applied the appropriate tags

- use a more descriptive subject line.

The more details you provide, the more likely it is that members will be able to respond. Feel free to also take our Q&A tutorial Q&A tutorial

Should you wish, you can revise your question by selecting Actions, then Edit.

By adding a picture to your Profile you encourage readers to respond.

View Entire Topic
maheshpalavalli
Active Contributor
0 Kudos

Hi Mahesh,

Is this available only for RAP? Does ABAP Programming model also has this feature?

I couldn't find 'Side effect' from annotation

Thanks

Shabnam