Day 5: Extending Itemtypes

Priyanka Manikkoth
1 min readNov 9, 2021

--

I get confused easily. So whenever somebody asks me whether to add additional attributes directly to OOTB itemtype or create a subtype and add them, I think a lot.

I know this is not an acceptable excuse for someone with my years of experience. :( So putting this down so that I never get confused with these scenarios.

Creating a Subtype and Adding the Attributes to the Subtype

This is the recommended method as it avoids direct dependency with the OOTB itemtypes.

Let’s define a new itemtype extending an OOTB Product.

One important point to note is autocreate should be true. Otherwise it will cause build failures. The first definition of a type should always have this value as true.

Generate can be true or false. But I haven’t encountered any scenario where I didn’t need the getters and setters to avoid the business logic implementation.

<itemtype code="MyProduct" autocreate="true" generate="true" extends="Product" jaloclass="org.training.jalo.MyProduct">
<attributes>
<attribute qualifier="oldPrice" type="java.lang.Double" generate="true">
<persistence type="property"/>
<modifiers read="true" write="true" optional="true"/>
</attribute>
</attributes>
</itemtype>

Adding Attributes to a Type Directly

Not the recommended approach because it creates direct dependency with the OOTB type.

In this case, autocreate element need to be false. Setting the autocreate modifier to true causes a build failure.

<itemtype code="Product" autocreate="false" generate="false">
<attributes>
<attribute qualifier="oldPrice" type="java.lang.Double" generate="true">
<persistence type="property"/>
<modifiers read="true" write="true" optional="true"/>
</attribute>
</attributes>
</itemtype>

Hope now I will be able to recollect it faster :)

Reference :

https://help.sap.com/viewer/d0224eca81e249cb821f2cdf45a82ace/1905/en-US/8bffa9cc86691014bb70ac2d012708bc.html

Sign up to discover human stories that deepen your understanding of the world.

Free

Distraction-free reading. No ads.

Organize your knowledge with lists and highlights.

Tell your story. Find your audience.

Membership

Read member-only stories

Support writers you read most

Earn money for your writing

Listen to audio narrations

Read offline with the Medium app

--

--

Priyanka Manikkoth
Priyanka Manikkoth

Written by Priyanka Manikkoth

Coder by occupation, dreamer by choice

No responses yet