
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;
//ADDING FACTORY ACTION FOR COPY
factory action copyStudent[1];
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;
}
}
CLASS lhc_Student DEFINITION INHERITING FROM cl_abap_behavior_handler.
PRIVATE SECTION.
METHODS get_global_authorizations FOR GLOBAL AUTHORIZATION
IMPORTING REQUEST requested_authorizations FOR Student RESULT result.
METHODS copyStudent FOR MODIFY
IMPORTING keys FOR ACTION Student~copyStudent.
ENDCLASS.
CLASS lhc_Student IMPLEMENTATION.
METHOD get_global_authorizations.
ENDMETHOD.
METHOD copyStudent.
DATA: lt_student TYPE TABLE FOR CREATE zstudent_hdr_tab_I.
" Reading selected data from frontend
READ ENTITIES OF zstudent_hdr_tab_I IN LOCAL MODE
ENTITY Student
ALL FIELDS WITH CORRESPONDING #( keys )
RESULT DATA(students)
FAILED failed.
LOOP AT students ASSIGNING FIELD-SYMBOL(<lfs_students>).
APPEND VALUE #( %cid = keys[ KEY entity %key = <lfs_students>-%key ]-%cid
%is_draft = keys[ KEY entity %key = <lfs_students>-%key ]-%param-%is_draft
%data = CORRESPONDING #( <lfs_students> EXCEPT id )
) TO lt_student ASSIGNING FIELD-SYMBOL(<lfs_newStudent>).
ENDLOOP.
"Create BO Instance by COpy
MODIFY ENTITIES OF zstudent_hdr_tab_I IN LOCAL MODE
ENTITY Student
CREATE FIELDS ( Firstname Lastname Age Course Courseduration Status Gender Dob )
WITH lt_student
MAPPED DATA(mapped_create).
mapped-student = mapped_create-student.
ENDMETHOD.
ENDCLASS.
Since we are using Draft capability in this application and we have mentioned %is_draft and set its value dynamically (00 or 01)
APPEND VALUE #( %cid = keys[ KEY entity %key = <lfs_students>-%key ]-%cid
%is_draft = keys[ KEY entity %key = <lfs_students>-%key ]-%param-%is_draft
%data = CORRESPONDING #( <lfs_students> EXCEPT id )
) TO lt_student ASSIGNING FIELD-SYMBOL(<lfs_newStudent>).
APPEND VALUE #( %cid = keys[ KEY entity %key = <lfs_students>-%key ]-%cid
"%is_draft = keys[ KEY entity %key = <lfs_students>-%key ]-%param-%is_draft
%data = CORRESPONDING #( <lfs_students> EXCEPT id )
) TO lt_student ASSIGNING FIELD-SYMBOL(<lfs_newStudent>).
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
21 | |
19 | |
9 | |
7 | |
5 | |
5 | |
5 | |
4 | |
4 | |
4 |