Uploaded by Shashikant Maurya

complete-process-to-create-change-document-in-abap-and-sapui5-

advertisement
Community
Topics
Groups
Answers
Blogs
Events
Programs
Resources
What's New
Home › Community › Blogs
Ask a Question
Write a Blog Post
Login / Sign-up
Technical Articles
Shaurya Tripathi
Assigned Tags
February 10, 2021 | 6 minute read
ABAP Development
Complete process to create Change Document in
ABAP and SAPUI5
#ABAP
#odata
sapui5
Follow
 1  7  6,398
Requirement:
 Like
 RSS Feed
To show the record of changes in ‘city’ and ‘name’ defined as fields in customer-specific table using SAP Fiori
app.
Similar Blog Posts

Learning frustrations of an SAP
Developer
By Radoslaw Chudziak Jan 14, 2022
Solution:
SAP Fiori Tools: Deploy to ABAP server
Create Change Document Object for the respective table.
Implementation:
Step by step procedure to implement the solution.
By Jhodel Cailan Aug 10, 2020
2.SAPUI5 application with ABAP OData
Service as backend
By Ram Prasath Satheesh Feb 19, 2019
Part1:
Create table and Activate the change document for the required fields (transaction SE11).
Related Questions

Create the change document with Change Document Objects (transaction SCDO).
Part2:
Expose CDS views and Insert the appropriate calls in the corresponding redefined methods.
Incorporate UI changes.
Creation of Change Document Object in ABAP:
Problem with CDS views with parameter
By Former Member Sep 01, 2015
What are the criteria for deciding
whether to create a new custom report
in SAPUI5/Fiori or ABAP?
By GED HURST Aug 06, 2019
1. Run the transaction code SE11.
2. Create a table ‘ZDB_STUDENT’. (For which you want to keep change document). Column name: MNDT,
GUID, NAME, DOB, CITY
BSP development with ADT?
By Former Member Nov 11, 2013
Join the Conversation

SAP TechEd
Tune in for tech talk. Stay for
inspiration. Upskill your
future.
SAP BTP Learning Group
SAP Business Technology
3. Maintain a user defined Data Element and in ‘Further Characteristics’ check the box for ‘Change
Document’ for those fields you want to maintain changes.
Platform Learning Journeys.
Coffee Corner
Join the new Coffee Corner
Discussion Group.
Note: Don’t check ‘log changes’ for the table in technical settings.
4. Run the transaction code SCDO.
5. Now create a change document for the table. Give ’zcd_student’ name of the change document object
and click ‘create’ button.
6. Follow the instructions in the next dialog box and enter the package name, to which the change
document object belongs, and enter a transport request. Click on ‘save’ button.
7. In the dialog box ‘Properties of Change Document Object’, enter a description for the change document
under Text and enter the database tables that belong to this info type under Table. Save these changes
and then click on ‘Generate’.
8. The “Generate Update Pgm” dialog box is displayed. Fill the required details and give the name of
function group. This function group will contain function module and includes, generated by further
process. Then click on ‘Generate’ button.
9. Then click on the ‘Activate’ button.
10. After this process Change Document Object is created and we can use created function module and
includes to track created, updated and deleted entries.
Changes will be logged in the following tables: CDHDR and CDPOS. CDHDR is a header table and CDPOS
contains the actual data. Created function module ‘ZDB_STUDENT_CD_WRITE_DOCUMENT’ will be used to
write changes to these tables.
cdhdr
cdpos
11. Create a CDS view for the ‘ZDB_C_STUDENT’ database table in SAP HANA Studio/Eclipse.
Expose CDS views to OData service.
12. Run the transaction code SEGW.
13. Expose the CDS view to OData service.
And redefine methods in data provider class (dpc_ext).
14. Create_Entity Method ==> In this method:
i. Read data (received from the front-end) using ‘io_data_provider’ into ‘ls_data’ work area.
ii. Insert entry into database table to create new record.
iii. After creating entry, write following code to create entry for change document.
DATA:
DATA: lt_cdtxt TYPE STANDARD TABLE OF cdtxt,
cdtxt,
YZDB_STUDENT,
,
lt_xstu TYPE STANDARD TABLE OF YZDB_STUDENT
YZDB_STUDENT.
.
ls_xstu TYPE YZDB_STUDENT
ls_xstu.
.
MOVE-CORRESPONDING ls_data TO ls_xstu
ls_xstu-kz = 'I'
'I'.
.
ls_xstu
lt_xstu.
.
APPEND ls_xstu TO lt_xstu
CALL FUNCTION 'ZDB_STUDENT_CD_WRITE_DOCUMENT' "Create Change Doc for New
EXPORTING
objectid
cdobjectv(
( lv_guid )
= CONV cdobjectv
tcode
sy-tcode
= sy
utime
sy-uzeit
= sy
udate
sy-datum
= sy
username
= sysy-uname
object_change_indicator
= 'I'
upd_icdtxt_zdb_student_cd = 'I'
upd_zdb_student
= 'I'
TABLES
icdtxt_zdb_student_cd
= lt_cdtxt
lt_xstu.
.​
xzdb_student
= lt_xstu
After successful creation of entry in database, we’ll call ‘ZDB_STUDENT_CD_WRITE_DOCUMENT’ function
module to create entry in change document object.
15. Update_Entity Method ==> In this method:
i. Read data (received from the front-end) using ‘io_data_provider’ into ‘lt_new’ table.
ii. Before updating database record, select the old record into ‘ls_data’ work area.
@DATA(
(ls_data
ls_data)
) WHERE guid EQ @lv_guid
SELECT SINGLE * FROM ZDB_STUDENT INTO @DATA
iii. Write the logic to update database record.
iv. After Updating record in database table, write following code to maintain changes for change
document.
DATA:
: lt_cdtxt TYPE STANDARD TABLE OF cdtxt
cdtxt,
,
DATA
cdtxt,
,
lw_cdtxt TYPE cdtxt
YZDB_STUDENT,
,
lt_xstu TYPE STANDARD TABLE OF YZDB_STUDENT
YZDB_STUDENT,
,
ls_xstu TYPE YZDB_STUDENT
YZDB_STUDENT.
.
lt_ystu TYPE STANDARD TABLE OF YZDB_STUDENT
lt_xstu.
.
MOVE-CORRESPONDING lt_new TO lt_xstu
READ TABLE lt_xstu INTO ls_xstu INDEX 1.
lt_xstu.
.
REFRESH lt_xstu
ls_xstu-guid = lv_guid
lv_guid.
.
ls_xstu
ls_xstu-mandt = sy
sy-mandt
mandt.
.
ls_xstu
ls_xstu-kz = 'U'
'U'.
.
ls_xstu
lt_xstu.
.
APPEND ls_xstu TO lt_xstu
ls_xstu.
.
CLEAR ls_xstu
ls_xstu.
.
MOVE-CORRESPONDING ls_data TO ls_xstu
ls_xstu-kz = 'U'
'U'.
.
ls_xstu
lt_ystu.
.
APPEND ls_xstu TO lt_ystu
CALL FUNCTION 'ZDB_STUDENT_CD_WRITE_DOCUMENT' " Function Module for w
EXPORTING
objectid
CDOBJECTV(
( lv_guid )
= conv CDOBJECTV
tcode
sy-tcode
= sy
utime
sy-uzeit
= sy
udate
sy-datum
= sy
username
sy-uname
= sy
" For Updating
object_change_indicator = 'U'
upd_zdb_student
= 'U'
TABLES
icdtxt_zdb_student_cd
= lt_cdtxt
XZDB_STUDENT
= lt_xstu " Updated Data
lt_ystu.
. " Old Data ​
YZDB_STUDENT
= lt_ystu
16. Delete_Entity Method ==> In this method:
i. Take primary key(’iv_guid’) of the record to be deleted.
ii. Before deleting record from the database, select the record into ‘ls_xstu’ work area.
iii. Write the logic to delete database record.
iv. After deleting record from the database table, write code to maintain changes for change
document.
DATA:
: lt_cdtxt TYPE STANDARD TABLE OF cdtxt
cdtxt,
,
DATA
YZDB_STUDENT,
,
lt_xstu TYPE STANDARD TABLE OF YZDB_STUDENT
YZDB_STUDENT,
,
ls_xstu TYPE YZDB_STUDENT
YZDB_STUDENT.
.
lt_ystu TYPE STANDARD TABLE OF YZDB_STUDENT
iv_guid.
. "#EC
SELECT SINGLE * FROM ZDB_STUDENT INTO ls_xstu WHERE guid = iv_guid
DELETE FROM ZDB_STUDENT WHERE guid = iv_guid.
iv_guid.
ls_xstu'D'.
.
ls_xstu-kz = 'D'
lt_ystu.
.
APPEND ls_xstu TO lt_ystu
CALL FUNCTION 'ZDB_STUDENT_CD_WRITE_DOCUMENT' " Create Change Document
EXPORTING
CDOBJECTV(
( iv_guid )
objectid
= conv CDOBJECTV
sy-tcode
tcode
= sy
sy-uzeit
utime
= sy
sy-datum
udate
= sy
sy-uname
username
= sy
object_change_indicator = 'D'
upd_zdb_student
= 'D'
TABLES
icdtxt_zdb_student_cd
= lt_cdtxt
YZDB_STUDENT
= lt_ystu.
lt_ystu.​
17. Expose ‘C_ChangeDocuments’ CDS view in OData Service. This CDS view will fetch data from CDHDR
and CDPOS tables. This is standard CDS view to show the details of all available change document
objects. To see the change records of only our change document object, we will filter records from the
UI based on change document object name (ChangeDocObjectClass) and primary key field of our
database table (ChangeDocObject).
SAPUI5 Changes
18. Create Project.
19. OData service:
i. Add destination for OData service.
ii. Right click on the project and then click on new then choose OData service.
20. View and Controller.
i. ‘Main’ View: Create a ‘Main’ view to show the records of ‘zdb_student’ table. Create a smart table
and bind it to created CDS entity for ‘zdb_student’ table.
ii. ‘ChangeHistory’ View: Create another view to show the list of changes made in ‘city’ and ‘name’
field of the selected record from ‘Main’ view. Create a smart table in view and on
‘beforeRebindTable’ event, add filter and set ‘entitySet’ to this smart table.
Set ‘setDefaultCountMode’ of model to ‘inline’ so that there is no OData call to count.
Then it will set following filters to make sure that only necessary records are being fetched.
‘ChangeDocObjectClass’ should be equal to ’zcd_student’ (Change Document of
‘zdb_student’ table).
‘ChangeDocObject’ should be equal to value of Key (primary key of the record).
Then set property ‘setEntitySet’ to ‘C_ChangeDocuments’ of change history smart table.
This is the whole process to create the change document object for your customer specific
table in ABAP and displaying changes in a SAP Fiori App.
Alert Moderator
1 Comment
You must be Logged on to comment or reply to a post.
Albert Moran Lopez
March 24, 2021 at 7:41 am
Hi,
Thanks for all the info, is very usefull!
I made a SAP Fiori App where I also want to make the updates and not only see them. In my case I used entity and entity set imported from DDIC
structures and mapped the update_entity to an RFC module function.
My problem is when I call my mapped function to update via Fiori App, the sy-tcode is empty. Is it a problem and I have to put another text on the tcode
import variable of the function who creates change documents or can I leave it blank?
Like 0 | Share
Find us on
Privacy Terms of Use
Legal Disclosure
Copyright
Trademark
Newsletter
Support
Download