cancel
Showing results for 
Search instead for 
Did you mean: 

To make field mandatory during create, but readonly during update

tjarliman
Explorer
0 Kudos
3,855

Hi All,

I have just tried to build an app using ABAPRestfull programming concept, I have managed to make the app work fine until now, but I have question related to like I mentioned in the title of this question.

I have tried to put code like:

managed; // implementation in class zbp_tj_i_xxx unique;

define behavior for ZTJ_I_xxx //alias <alias_name>

persistent table ztjt_xxx

lock master

//authorization master ( instance )

//etag master <field_name>

{

mapping for ztjt_xxx corresponding;

// mandatory fields that are required to create data

field ( mandatory : create, readonly : update ) team; //=> this does not work during creation

create; update; delete;

}

So the issue is, during creation of new data, the field are in readonly mode which I do not expect to happen, but during updating of existing data, the the fields are in readonly mode which I expect to happen.

If I code like this:

field ( mandatory : create ) team;

The field is editable during creation of new data which I expected.

But this also happend during updating of existing data, this field is editable which I dont want to happen.

I hope anybody can help me with this issue.

Thanks

TJ

Accepted Solutions (0)

Answers (5)

Answers (5)

Andre_Fischer
Product and Topic Expert
Product and Topic Expert

I don't understand why it does not work for you.

But when I set

 field ( mandatory : create, readonly : update ) INventoryID;

in my behavior definition.

I get a popup that asks me to provide a value for the field InventoryID when creating a new object

and after I have saved it the field is read-only.

tjarliman
Explorer

Sorry for late reply.

From my understanding it should work also. But not sure why it is not happening.

I will try again later, and will post it here if I can manage to make it work, and explain the reason too.

marcosmata
Participant
0 Kudos
This did not work for me neither. I just did it like the photo. Weird.
rajib3301
Explorer
0 Kudos
@Andre_Fischer I am getting this on Odata V4 but for Odata v2 its no use
mohan_kumar49
Explorer
0 Kudos

Hi Andre, can you use the option in the unmanaged application. when i am trying in the unmanaged app expected behaviour is not working. can you please let me know how we can achieve this in unmanaged app.

tjarliman
Explorer
0 Kudos

Managed to work it done by using this statement:

field ( feature : instant ) fieldname...

and also I need to create logic to control when that field should enabled / disabled

Thanks

TJ

Andre_Fischer
Product and Topic Expert
Product and Topic Expert
0 Kudos
managed;
with draft;
define behavior for ZI_Test_JONA alias Jonathan
implementation in class ZBP_I_Test_JONA unique
persistent table zrap_inven_jona
draft table ztestha00d_jona
etag master LastChangedAt
lock master total etag LastChangedAt
authorization master ( global )
{
field ( mandatory : create, readonly : update ) INventoryID;
field ( numbering : managed )
UUID;
create;
update;
delete;
draft action Edit;
draft action Activate;
draft action Discard;
draft action Resume;
draft determine action Prepare;
mapping for ZRAP_INVEN_JONA
{
UUID = UUID;
InventoryID = INVENTORY_ID;
ProductID = PRODUCT_ID;
Quantity = QUANTITY;
QuantityUnit = QUANTITY_UNIT;
Price = PRICE;
CurrencyCode = CURRENCY_CODE;
Remark = REMARK;
NotAvailable = NOT_AVAILABLE;
CreatedBy = CREATED_BY;
CreatedAt = CREATED_AT;
LastChangedBy = LAST_CHANGED_BY;
LastChangedAt = LAST_CHANGED_AT;
}
determination CalculateInventoryID on save { create; }
}

Ravi_Prasad_K
Explorer
0 Kudos

Hi Andre,

It is only working when the Service Binding is of V4 version. How can we make it to work for Odata version V2?

Please suggest

Andre_Fischer
Product and Topic Expert
Product and Topic Expert
0 Kudos

field ( readonly : update ) <field_name>;

tjarliman
Explorer
0 Kudos

Thanks for replying Andre.

I have tried That statement, it will make the field in READONLY mode during UPDATE process as well as during CREATE.

I am expecting that during UPDATE the fields will be in READONLY mode, but during CREATE the same fields will be in EDITABLE mode.

I have tried this:

field ( mandatory : create, readonly : update ) team;

but also did not work.

any idea?

ankahit
Explorer
0 Kudos
Hi @tjarliman, Any luck? I have same requirement.