cancel
Showing results for 
Search instead for 
Did you mean: 

Draft not working for Association RAP

AbhishekSharma
Active Contributor
0 Kudos

Hi Gurus,

lloydfernandes

siddhartha_routh

I am facing Issue in saving draft for Association table. Below is my Behavior definition code...

When I am saving draft only non Key field is getting saved in Draft table but key fields are not saving...

highlighted fields are key fields which are not getting updated in draft.. Even they are not getting saved with Draft as well... and this started when I activated Draft functionality.

managed implementation in class zbp_i_stud5001 unique; //Everything will be taken care by Framework
//strict;
with draft;

define behavior for ZI_STUD5001 alias Student

persistent table zrap_stud5001
draft table zrap_drstud5001
lock master total etag Lastchangedat
authorization master ( instance )
etag master Locallastchangedat
{
  create;
  update;
  delete;
  association _academicres { create; }
  field ( numbering : managed, readonly ) Id;
  field ( readonly ) Courseduration;
  action ( features : instance ) setActive result [1] $self;
  validation validateAge on save { field  Age; create; }
  determination updateCourseDuration on save  { field Course; }
  //instance : Operations of a business object can be enabled or disabled depending on instance-specific criteria
  //result : The output parameter for an action or function is defined with the keyword result.
  //It can be used to store the result of an action or function in an internal table.
  //$self : specifies that the result type is the same type as the entity for which the action or function is defined.

  mapping for zrap_stud5001
  {
    Id = id;
    Firstname = firstname;
    Lastname = lastname;
    Age = age;
    Course = course;
    Courseduration = courseduration;
    Status = status;
    Gender = gender;
    Dob = dob;
    Lastchangedat = lastchangedat;
    Locallastchangedat = locallastchangedat;

  }
}

define behavior for ZI_AR_5001 alias AcademicResult
persistent table zcim_rap_ar_5001
draft table zrap_dr_ar_5001
lock dependent by _student
authorization dependent by _student
//etag master <field_name>
{
  update;
  delete;
  association _student;

  field ( readonly ) Id;
  field ( readonly ) course_desc;
  field ( readonly ) semester_desc;
  field ( readonly ) semres_desc;

  mapping for zcim_rap_ar_5001
  {
    Id = id;
    Course = course;
    Semester = semester;
    Semresult = semresult;
  }

}

Please help. let me know if I need to make my question more clear..

Thanks-

Abhishek

Marissa
Advisor
Advisor
0 Kudos

We helped you to accept the answer, since there were no updates after 7 days.

You can unaccept it anytime if you have further questions.

Accepted Solutions (1)

Accepted Solutions (1)

Ramjee_korada
Active Contributor
0 Kudos

abhi.sharma05

First of , please check if course and semester are needs to be key ? As per my understanding, you wanted them to be entered by user.

If they have to be key, then implement early numbering in the behavior definition and define values to the key field in the method.

Refer below blogpost :

https://blogs.sap.com/2021/11/23/how-to-use-early-numbering-with-semantic-keys-rap-managed-bo/

In your case, all key fields to be filled in this method so that required entry is created in draft table and you can update only non-key fields later in the fiori app or in the code for a draft application.

So better solution would be removing them as a key so that user can fill them .

  METHOD earlynumbering_create.
    
	" Get number for course

    LOOP AT entities ASSIGNING FIELD-SYMBOL(<ls_entity>).
      INSERT VALUE #( %cid            = <ls_entity>-%cid
                      Id = << generate guid >>
	              Course = << course # >>
		      Semester = << sem #>> ) 
		INTO TABLE mapped-header.
    ENDLOOP.
  ENDMETHOD.

Best wishes,

Ramjee Korada.

mustafa_74199
Participant
0 Kudos

Hi Ramjee,

I cant implement Early Numbering in the behavior definition. I have exactly the same problem which is described in the question. I am working on-premise, not in any cloud platform.

What is the solution if we dont have any UUID key field in the database table and we have some key fields which will be taken from user?

Regards

Answers (2)

Answers (2)

0 Kudos

I am facing the same issue .. did you solve it ?

SiddharthaR
Advisor
Advisor
0 Kudos

Hi Abhishek,

I am not very clear about you question. Can you show us the draft table and its content? Are you saying it data is being stored in draft table without a key, i dont think that is possible.

Also always go with "Strict" implementation, it will force you to follow best standards.

AbhishekSharma
Active Contributor
0 Kudos

Hi siddhartha_routh

below is my draft table...

Draft table output, blank field value...

yes I observed key fields are not getting saved...

Thanks-

Abhishek