As per our scenario we are going to create Student Record and will upload multiple documents for created Student.
@EndUserText.label : 'Student Table Header'
@AbapCatalog.enhancement.category : #NOT_EXTENSIBLE
@AbapCatalog.tableCategory : #TRANSPARENT
@AbapCatalog.deliveryClass : #A
@AbapCatalog.dataMaintenance : #RESTRICTED
define table zstudent_hdr_tab {
key client : abap.clnt not null;
key id : sysuuid_x16 not null;
firstname : abap.char(100);
lastname : abap.char(100);
age : abap.numc(4);
course : abap.char(50);
courseduration : abap.numc(4);
status : abap_boolean;
gender : abap.char(1);
dob : abap.dats;
lastchangedat : timestampl;
locallastchangedat : timestampl;
}
@EndUserText.label : 'Attachment Table'
@AbapCatalog.enhancement.category : #NOT_EXTENSIBLE
@AbapCatalog.tableCategory : #TRANSPARENT
@AbapCatalog.deliveryClass : #A
@AbapCatalog.dataMaintenance : #RESTRICTED
define table zstudent_att_tab {
key client : abap.clnt not null;
key attach_id : char32 not null;
id : sysuuid_x16 not null;
comments : char30;
attachment : zattachment1;
mimetype : char128;
filename : char128;
}
@AccessControl.authorizationCheck: #NOT_REQUIRED
@EndUserText.label: 'Interface View Entity for Student'
define root view entity zstudent_hdr_tab_I as select from zstudent_hdr_tab
composition[1..*] of zstudent_att_tab_i as _Attachments
{
@EndUserText.label: 'Student ID'
key zstudent_hdr_tab.id as Id,
@EndUserText.label: 'First Name'
zstudent_hdr_tab.firstname as Firstname,
@EndUserText.label: 'Last Name'
zstudent_hdr_tab.lastname as Lastname,
@EndUserText.label: 'Age'
zstudent_hdr_tab.age as Age,
@EndUserText.label: 'Course'
zstudent_hdr_tab.course as Course,
@EndUserText.label: 'Course Duration'
zstudent_hdr_tab.courseduration as Courseduration,
@EndUserText.label: 'Status'
zstudent_hdr_tab.status as Status,
@EndUserText.label: 'Gender'
zstudent_hdr_tab.gender as Gender,
@EndUserText.label: 'DOB'
zstudent_hdr_tab.dob as Dob,
zstudent_hdr_tab.lastchangedat as Lastchangedat,
zstudent_hdr_tab.locallastchangedat as Locallastchangedat,
_Attachments // Make association public
}
@AccessControl.authorizationCheck: #NOT_REQUIRED
@EndUserText.label: 'View for Attachment'
define view entity zstudent_att_tab_i as select from zstudent_att_tab
association to parent zstudent_hdr_tab_I as _Student
on $projection.Id = _Student.Id {
key zstudent_att_tab.attach_id as AttachId,
zstudent_att_tab.id as Id,
@EndUserText.label: 'Comments'
zstudent_att_tab.comments as Comments,
@EndUserText.label: 'Attachments'
@Semantics.largeObject:{
mimeType: 'Mimetype',
fileName: 'Filename',
contentDispositionPreference: #INLINE
}
zstudent_att_tab.attachment as Attachment,
@EndUserText.label: 'File Type'
zstudent_att_tab.mimetype as Mimetype,
@EndUserText.label: 'File Name'
zstudent_att_tab.filename as Filename,
_Student.Lastchangedat as LastChangedat,
_Student // Make association public
}
@EndUserText.label: 'Projection view for Header table'
@AccessControl.authorizationCheck: #NOT_REQUIRED
define root view entity zstudent_att_tab_p
provider contract transactional_query
as projection on zstudent_hdr_tab_I
{
@UI.facet: [{
id: 'StudentData',
purpose: #STANDARD,
label: 'Student Data',
type: #IDENTIFICATION_REFERENCE,
position: 10
},{
id: 'Upload',
purpose: #STANDARD,
label: 'Upload Attachments',
type: #LINEITEM_REFERENCE,
position: 20,
targetElement: '_Attachments'
}]
@UI: {
selectionField: [{ position: 10 }],
lineItem: [{ position: 10 }],
identification: [{ position: 10 }]
}
key Id,
@UI: {
lineItem: [{position: 20 }],
identification: [{position: 20 }]
}
Firstname,
@UI: {
lineItem: [{position: 30 }],
identification: [{position: 30 }]
}
Lastname,
@UI: {
lineItem: [{position: 40 }],
identification: [{position: 40 }]
}
Age,
@UI: {
lineItem: [{position: 50 }],
identification: [{position: 50 }]
}
Course,
@UI: {
lineItem: [{position: 60 }],
identification: [{position: 60 }]
}
Courseduration,
@UI: {
lineItem: [{position: 70 }],
identification: [{position: 70 }]
}
Status,
@UI: {
lineItem: [{position: 80 }],
identification: [{position: 80 }]
}
Gender,
@UI: {
lineItem: [{position: 90 }],
identification: [{position: 90 }]
}
Dob,
Lastchangedat,
Locallastchangedat,
/* Associations */
_Attachments : redirected to composition child zstudent_att_tabl_p
}
@EndUserText.label: 'Projection for Attachment'
@AccessControl.authorizationCheck: #NOT_REQUIRED
define view entity zstudent_att_tabl_p
as projection on zstudent_att_tab_i
{
@UI.facet: [{
id: 'StudentData',
purpose: #STANDARD,
label: 'Attachment Information',
type: #IDENTIFICATION_REFERENCE,
position: 10
}]
@UI: {
lineItem: [{ position: 10 }],
identification: [{ position: 10 }]
}
key AttachId,
@UI: {
lineItem: [{ position: 20 }],
identification: [{ position: 20 }]
}
Id,
@UI: {
lineItem: [{ position: 30 }],
identification: [{ position: 30 }]
}
Comments,
@UI: {
lineItem: [{ position: 40 }],
identification: [{ position: 40 }]
}
Attachment,
Mimetype,
Filename,
LastChangedat,
/* Associations */
_Student : redirected to parent zstudent_att_tab_p
}
managed implementation in class zbp_student_hdr_tab_i unique;
strict ( 1 ); with draft;
define behavior for zstudent_hdr_tab_I alias Student
persistent table zstudent_hdr_tab
draft table zstudent_h_d_tab
lock master
total etag Locallastchangedat
authorization master ( global )
etag master Lastchangedat
{
create;
update;
delete;
association _Attachments { create; with draft; }
field ( numbering : managed, readonly ) Id;
draft action Edit;
draft action Activate;
draft action Discard;
draft action Resume;
draft determine action Prepare;
mapping for zstudent_hdr_tab
{
Id = id;
Firstname = firstname;
Lastname = lastname;
Age = age;
Course = course;
Courseduration = courseduration;
Dob = dob;
Gender = gender;
Lastchangedat = lastchangedat;
Locallastchangedat = locallastchangedat;
Status = status;
}
}
define behavior for zstudent_att_tab_i alias Attachments
persistent table zstudent_att_tab
draft table zstudent_a_d_tab
lock dependent by _Student
authorization dependent by _Student
etag master LastChangedat
{
update;
delete;
field ( readonly ) Id;
association _Student { with draft; }
mapping for zstudent_att_tab{
AttachId = attach_id;
Attachment = attachment;
Comments = comments;
Filename = filename;
Id = id;
Mimetype = mimetype;
}
}
projection;
strict ( 1 );
use draft;
define behavior for zstudent_att_tab_p //alias <alias_name>
{
use create;
use update;
use delete;
use action Edit;
use action Activate;
use action Discard;
use action Resume;
use action Prepare;
use association _Attachments { create; with draft; }
}
define behavior for zstudent_att_tabl_p //alias <alias_name>
{
use update;
use delete;
use association _Student { with draft; }
}
@EndUserText.label: 'Service Defination'
define service ZSTUDENT_ATT_SD {
expose zstudent_att_tabl_p;
expose zstudent_att_tab_p;
}
Upload another file. Multiple files are uploaded successfully
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
11 | |
8 | |
7 | |
6 | |
5 | |
5 | |
5 | |
4 | |
4 | |
3 |