Numbering During Create and Create by Association ... - SAP Community
Numbering During Create and Create by Association ... - SAP Community
- SAP Community
m
m
Products and Technology Groups Partners Topics Events What's New Get Started Explore SAP
u
ni
t
y
SAP Community Groups Interest Groups Application Development Blog Posts Numbering during create and create by association ...
Numbering during create and create by association in RAP Labels In This Area
- SAP 1 @sapcommunity 1
Ismail_05
A Comprehensive Guide to Using… 1
Explorer 2025 Jan 24 3:25 PM
A Dynamic Memory Allocation Tool 1
In SAP ABAP RESTful Application Programming Model (RAP), the concepts ABAP Class 1 ABAP Cloud 4
of Create and Create by Association are fundamental for managing data
ABAP development 7
persistence in business objects.
https://community.sap.com/t5/application-development-blog-posts/numbering-during-create-and-create-by-association-in-rap/ba-p/13992954 1/32
3/2/25, 1:12 AM Numbering during create and create by association ... - SAP Community
Implementing numbering mechanisms during these operations is essential ABAP Environment & RAP 4
to ensure unique identifiers for newly created entities.
abap for sap hana 1
ABAP in Eclipse 2
This blog explores strategies and best practices for numbering during the Create
operation and Create by Association, highlighting how RAP supports these processes ABAP internal sessions 1
in both managed and unmanaged scenarios. ABAP Keyword Documentation 2
ABAP Programming 4
Numbering in RAP refers to the process of assigning unique values to the key fields ABAP RAP 5
of business entities during Create operations.
ABAP RAP custom action 1
alv oo 1 AMDP 1
https://community.sap.com/t5/application-development-blog-posts/numbering-during-create-and-create-by-association-in-rap/ba-p/13992954 2/32
3/2/25, 1:12 AM Numbering during create and create by association ... - SAP Community
Developers implement custom logic to assign key values during the AMDP CURD Operations 1
creation operation.
API and Integration 2 APIs 42
Use Cases:
APIs ABAP 1
Suitable for scenarios requiring immediate key assignment, such as
App Dev and Integration 2
generating unique identifiers for new records upon clicking "Create."
Application Development 3
2. Late Numbering: application job 1
Primary key values are assigned just before the data is saved to the application jobs 1 archivelinks 1
database. aRFC 1 AUNIT 3
Triggered during the save sequence phase. authorization 1
This method is invoked during the save sequence to assign key Batch Management 1 btp 1
BTP Destination 1
Scenario Example
BTP HANA Cloud SAP 1 buffer 1
In this example, we have designed a scenario with two views: Business Application Studio 1
1. Patient View (Child entity, dependent on Hospital View) Business Technology Platform 1
https://community.sap.com/t5/application-development-blog-posts/numbering-during-create-and-create-by-association-in-rap/ba-p/13992954 3/32
3/2/25, 1:12 AM Numbering during create and create by association ... - SAP Community
The Hospital View is the root entity, and the Patient View is related to it via a Career Development 11 CDS 1
composition relationship. The patient data cannot exist independently of the hospital
CDS Access Control 1
data.
CDS Views 1
Below are the CDS view definitions and behavior implementations for the scenario: CL_GUI_FRONTEND_SERVICES 1
cl_gui_html_viewer 1
Cloud Native 20
CloudEvents 2 CMIS 1
Configuration 1 Connection 1
container 1
Customer Experience 1
Customer Portal 1
https://community.sap.com/t5/application-development-blog-posts/numbering-during-create-and-create-by-association-in-rap/ba-p/13992954 4/32
3/2/25, 1:12 AM Numbering during create and create by association ... - SAP Community
@AbapCatalog.viewEnhancementCategory: [#NONE]
Popular Blog Posts
@AccessControl.authorizationCheck: #NOT_REQUIRED
@EndUserText.label: 'Hospital interface view'
@Metadata.ignorePropagatedAnnotations: true
@ObjectModel.usageType:{
serviceQuality: #X,
sizeCategory: #S,
dataClass: #MIXED
}
define root view entity zismo_i_hospital Get Started with the ABAP
as select from zismo_dt_hosp Development Tools for SAP
composition [1..*] of zismo_i_patient as _patient NetWeaver
{
OlgaDolinskaja
@UI.facet: [{ Product and Topic Expert
label: 'Hospital information',
purpose: #STANDARD, 178676 12 1443
type: #IDENTIFICATION_REFERENCE,
position: 10
},
{ label : 'Patient information',
purpose: #STANDARD,
type: #LINEITEM_REFERENCE,
position: 20,
targetElement: '_patient' } ]
Become an ABAP in Eclipse Feature
Explorer and earn the Explorer
@UI.lineItem: [{ position: 10, label: 'Hospital Id' }]
Badge
@UI.identification: [{ position: 10, label: 'Hospital Id' }]
key hospital_id as HospitalId, ThFiedler
Product and Topic Expert
https://community.sap.com/t5/application-development-blog-posts/numbering-during-create-and-create-by-association-in-rap/ba-p/13992954 5/32
3/2/25, 1:12 AM Numbering during create and create by association ... - SAP Community
30 @UI.lineItem: [{ position: 20, label: 'Hospital name' }] 33771 147 370
31 @UI.identification: [{ position: 20, label: 'Hospital name' }]
32 hospital_name as HospitalName,
33
34 @UI.lineItem: [{ position: 30, label: 'Hospital location' }]
35 @UI.identification: [{ position: 30, label: 'Hospital location
36 hospital_location as HospitalLocation,
37
38 @UI.lineItem: [{ position: 40, label: 'No of doctors' }]
39 @UI.identification: [{ position: 40, label: 'No of doctors' }] Six kinds of debugging tips to find
40 no_of_doctors as NoOfDoctors, the source code where the message
41 is raised
42 @UI.lineItem: [{ position: 50, label: 'No of rooms' }]
JerryWang
43 @UI.identification: [{ position: 50, label: 'No of rooms' }]
Product and Topic Expert
44 no_of_rooms as NoOfRooms,
45 _patient 229737 56 324
46 }
GopalNair 3
Patient View
jwood_bowdark 2
Eberenwaobiora 2
https://community.sap.com/t5/application-development-blog-posts/numbering-during-create-and-create-by-association-in-rap/ba-p/13992954 6/32
3/2/25, 1:12 AM Numbering during create and create by association ... - SAP Community
To manage the functionality of the scenario, I have created a behavior definition for
the root view (Hospital View).
This behavior definition defines the operations and interactions that can be
performed on the hospital entity and its associated patient entities.
https://community.sap.com/t5/application-development-blog-posts/numbering-during-create-and-create-by-association-in-rap/ba-p/13992954 8/32
3/2/25, 1:12 AM Numbering during create and create by association ... - SAP Community
https://community.sap.com/t5/application-development-blog-posts/numbering-during-create-and-create-by-association-in-rap/ba-p/13992954 9/32
3/2/25, 1:12 AM Numbering during create and create by association ... - SAP Community
https://community.sap.com/t5/application-development-blog-posts/numbering-during-create-and-create-by-association-in-rap/ba-p/13992954 11/32
3/2/25, 1:12 AM Numbering during create and create by association ... - SAP Community
For managed early numbering, ensure that the key field is of type SYSUUIDx16
(RAW16)
And in the behavior definition of your BO use syntax “numbering: managed” for your
key field
https://community.sap.com/t5/application-development-blog-posts/numbering-during-create-and-create-by-association-in-rap/ba-p/13992954 12/32
3/2/25, 1:12 AM Numbering during create and create by association ... - SAP Community
Creation of record for parent entity, in our case its hospital view, using early
numbering managed
https://community.sap.com/t5/application-development-blog-posts/numbering-during-create-and-create-by-association-in-rap/ba-p/13992954 13/32
3/2/25, 1:12 AM Numbering during create and create by association ... - SAP Community
As we can see the unique ID has been generated for us by the framework
Now let’s see how to do it with child entity, in my case patient view
Same steps we need to follow to achieve early numbering managed for child entity
https://community.sap.com/t5/application-development-blog-posts/numbering-during-create-and-create-by-association-in-rap/ba-p/13992954 14/32
3/2/25, 1:12 AM Numbering during create and create by association ... - SAP Community
Creation of record for child entity, in our case patient view using early numbering
managed
https://community.sap.com/t5/application-development-blog-posts/numbering-during-create-and-create-by-association-in-rap/ba-p/13992954 15/32
3/2/25, 1:12 AM Numbering during create and create by association ... - SAP Community
Unlike managed early numbering here in unmanaged early numbering we can have
key fields of any data type
Here in our scenario, I am not changing the data type of the field
To start with early numbering unmanaged, go to your behavior definition and write
the syntax early numbering
https://community.sap.com/t5/application-development-blog-posts/numbering-during-create-and-create-by-association-in-rap/ba-p/13992954 16/32
3/2/25, 1:12 AM Numbering during create and create by association ... - SAP Community
Here if we see we are getting an error because at a time only one type of numbering
can be used, so remove other numbering and keep the early numbering syntax
https://community.sap.com/t5/application-development-blog-posts/numbering-during-create-and-create-by-association-in-rap/ba-p/13992954 17/32
3/2/25, 1:12 AM Numbering during create and create by association ... - SAP Community
The warning is related to implementing the method, so put cursor on the line and do
a quick fix (CTRL + 1)
System will give the quick fix suggestion to implement the method
Double click and you will enter the behavior pool where you can write
implementation for this method
https://community.sap.com/t5/application-development-blog-posts/numbering-during-create-and-create-by-association-in-rap/ba-p/13992954 18/32
3/2/25, 1:12 AM Numbering during create and create by association ... - SAP Community
Before writing the logic put cursor on the method name and click F2 to see the
parameters related to the method
Here we need to mandatorily fill mapped parameter consisting of %CID and our key
field hospitalID
%CID refers to content id which should be unique while creation of new record, this
%CID we can refer from entities parameter
https://community.sap.com/t5/application-development-blog-posts/numbering-during-create-and-create-by-association-in-rap/ba-p/13992954 19/32
3/2/25, 1:12 AM Numbering during create and create by association ... - SAP Community
1 METHOD earlynumbering_create.
2 SELECT MAX( hospital_id ) FROM zismo_dt_hosp INTO (lv_hos_id)
3
4 lv_hos_id = COND #( WHEN lv_hos_id IS NOT INITIAL THEN lv_hos_
5 ELSE 1 ).
6 mapped-hospital = VALUE #( ( %cid = entities[ 1 ]-%cid
7 HospitalId = lv_hos_id ) ).
8 ENDMETHOD.
It’s a simple logic where i am checking for maximum hospital id present in the DB and
if present then i will increment by one else i will start id by 1
Creation of record for parent entity in our case hospital view using early numbering
unmanaged
https://community.sap.com/t5/application-development-blog-posts/numbering-during-create-and-create-by-association-in-rap/ba-p/13992954 20/32
3/2/25, 1:12 AM Numbering during create and create by association ... - SAP Community
As we can see the record has been created using the logic we implemented for
unmanaged early numbering
Now let’s see how to do it with child entity, in my case patient view
Go to the behavior definition of patient view and write the syntax early numbering
Since creation of child entity is dependent on parent entity so the warning is being
triggered at behavior definition of parent entity at association
https://community.sap.com/t5/application-development-blog-posts/numbering-during-create-and-create-by-association-in-rap/ba-p/13992954 21/32
3/2/25, 1:12 AM Numbering during create and create by association ... - SAP Community
https://community.sap.com/t5/application-development-blog-posts/numbering-during-create-and-create-by-association-in-rap/ba-p/13992954 22/32
3/2/25, 1:12 AM Numbering during create and create by association ... - SAP Community
Before writing the logic let’s check the method signature by clicking F2
Here inside entities, we don’t have child entity’s key field patientid
So, if we click on %target then we can see the components related to child entity
https://community.sap.com/t5/application-development-blog-posts/numbering-during-create-and-create-by-association-in-rap/ba-p/13992954 23/32
3/2/25, 1:12 AM Numbering during create and create by association ... - SAP Community
So, we need to fill patientID present in %target and then we can append %target
structure to mapped parameter of patient view
1 METHOD earlynumbering_cba_Patient.
2 SELECT MAX( patient_id ) FROM zismo_dt_patient INTO (lv_pat_id
3
4 lv_pat_id = COND #( WHEN lv_pat_id IS NOT INITIAL THEN lv_pat_
5 ELSE 1 ).
6
7 DATA(ls_target) = entities[ 1 ]-%target[ 1 ].
8 ls_target-PatientId = lv_pat_id.
9
10 APPEND CORRESPONDING #( ls_target ) TO mapped-patient.
11 ENDMETHOD.
Creation of child entity in our case patient view, using unmanaged cba early
numbering
https://community.sap.com/t5/application-development-blog-posts/numbering-during-create-and-create-by-association-in-rap/ba-p/13992954 24/32
3/2/25, 1:12 AM Numbering during create and create by association ... - SAP Community
Late numbering
In late numbering also we can do numbering for key fields of any data type
To implement late numbering write the syntax late numbering in the behavior
definition of hospital view
And the moment we write late numbering for root/parent entity we get an error
The error is if parent entity is implemented as late numbering, then child entity must
also have to contain late numbering
https://community.sap.com/t5/application-development-blog-posts/numbering-during-create-and-create-by-association-in-rap/ba-p/13992954 25/32
3/2/25, 1:12 AM Numbering during create and create by association ... - SAP Community
So, lets write late numbering for child entity’s behavior definition as well
Now the error is gone but we get a warning to implement the adjust number method
In case of late numbering every time method name will be adjust numbers where
we can write the logic for late numbering
So quick fix the warning and enter behavior pool where we can see the method
https://community.sap.com/t5/application-development-blog-posts/numbering-during-create-and-create-by-association-in-rap/ba-p/13992954 26/32
3/2/25, 1:12 AM Numbering during create and create by association ... - SAP Community
Now here in this method itself we must write the late numbering logic for both parent
and child entity
Here whenever we perform create operation the mapped parameter related to that
entity will not be initial so by using this condition, we can write a logic
Here to perform create by association we need to get the parent entity key value
which we can get from %tmp of child entity, so based on that parent key the
associated child will be created
https://community.sap.com/t5/application-development-blog-posts/numbering-during-create-and-create-by-association-in-rap/ba-p/13992954 27/32
3/2/25, 1:12 AM Numbering during create and create by association ... - SAP Community
1 METHOD adjust_numbers.
2 IF mapped-hospital IS NOT INITIAL.
3
4 SELECT MAX( hospital_id ) FROM zismo_dt_hosp INTO (lv_hos_id)
5
6 lv_hos_id = COND #( WHEN lv_hos_id IS NOT INITIAL THEN lv_hos_
7 ELSE 1 ).
8
9 DATA(ls_mapped_hos) = VALUE #( mapped-hospital[ 1 ] OPTIONAL )
10
11 ls_mapped_hos-HospitalId = lv_hos_id.
12 APPEND CORRESPONDING #( ls_mapped_hos ) TO mapped-hospital.
13
14 ELSEIF mapped-patient IS NOT INITIAL.
15
16 SELECT MAX( patient_id ) FROM zismo_dt_patient INTO (lv_pat_id
17
18 lv_pat_id = COND #( WHEN lv_pat_id IS NOT INITIAL THEN lv_pat_
19 ELSE 1 ).
20
21 DATA(ls_mapped_pat) = VALUE #( mapped-patient[ 1 ] OPTIONAL )
22 ls_mapped_pat-HospitalId = ls_mapped_pat-%tmp-HospitalId.
23 ls_mapped_pat-PatientId = lv_pat_id.
24
25 APPEND CORRESPONDING #( ls_mapped_pat ) TO mapped-patient.
26 ENDIF.
27 ENDMETHOD.
https://community.sap.com/t5/application-development-blog-posts/numbering-during-create-and-create-by-association-in-rap/ba-p/13992954 28/32
3/2/25, 1:12 AM Numbering during create and create by association ... - SAP Community
Creation of record for parent entity in our case hospital view using late numbering
Creation of child entity in our case patient view, using late numbering
https://community.sap.com/t5/application-development-blog-posts/numbering-during-create-and-create-by-association-in-rap/ba-p/13992954 29/32
3/2/25, 1:12 AM Numbering during create and create by association ... - SAP Community
Labels:
3 Comments
AbhishekSharma
Active Contributor 2025 Jan 24 10:26 PM
0 Kudos
Thanks-
https://community.sap.com/t5/application-development-blog-posts/numbering-during-create-and-create-by-association-in-rap/ba-p/13992954 30/32
3/2/25, 1:12 AM Numbering during create and create by association ... - SAP Community
xSAGARx
Explorer 2025 Jan 25 5:30 AM
0 Kudos
Resolved my issue
Thanks @Ismail_05
Basant_Joshi
Explorer 15 hours ago
0 Kudos
Does the use of UUID comes under early numbering concept in manage
scenario ? rest is clear to me, they are just normal counter methods if we not
use early numbering in behavior definition we can still leverage this
functionality in cbaitem and during creation of header id in unmanage
scenario.
https://community.sap.com/t5/application-development-blog-posts/numbering-during-create-and-create-by-association-in-rap/ba-p/13992954 31/32
3/2/25, 1:12 AM Numbering during create and create by association ... - SAP Community
Because we usually use number range in projects and UUID just throws a
random number, what if i want a set range like from 1000 with SNO-1000
sequence in my manage scenario ?
Comment
Trademark Support
Cookie Preferences
Follow
https://community.sap.com/t5/application-development-blog-posts/numbering-during-create-and-create-by-association-in-rap/ba-p/13992954 32/32