cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

RAP Managed Scenario - Is it possible to make key fields editable during copy action?

SrividhyaKarthick
Discoverer
0 Likes
1,044

Hi Experts,

I have implemented factory action for "copy". When a record is selected and clicked on "copy" action, object page opens with all the non-key fields in edit mode except key fields. Key fields appear with '-'

I want the key fields in edit mode either empty or the same value from copied record so that I can maintain them.

Need help how to achieve my requirement.

 

 

 

 

METHOD copy.

    DATA it_selected_records    TYPE TABLE FOR CREATE Z_MATERIAL.   "Instance of the BO entity

    " remove travel instances with initial %cid (i.e., not set by caller API)

    READ TABLE keys WITH KEY %cid = '' INTO DATA(key_with_inital_cid).
    ASSERT key_with_inital_cid IS INITIAL.

    " read the data from the Material instances(selected record(s) for copy)

    READ ENTITIES OF Z_MATERIAL IN LOCAL MODE
      ENTITY mat_data
       ALL FIELDS WITH CORRESPONDING #( keys )
    RESULT DATA(material_read_result)
    FAILED failed.

    LOOP AT material_read_result ASSIGNING FIELD-SYMBOL(<material>).

      " fill in Material container for creating new Material instance

      APPEND VALUE #( %cid      = keys[ KEY entity %key = <material>-%key ]-%cid
                      %is_draft = keys[ KEY entity %key = <material>-%key ]-%param-%is_draft
                      %data     = CORRESPONDING #( <material>  EXCEPT Plant Material )
                   )
        TO it_selected_records ASSIGNING FIELD-SYMBOL(<new_record>).

      " adjust the copied Material instance data

      "" ChangedOn must be Current date and ChangedBy must be Current User

      <new_record>-ChangedOn     = cl_abap_context_info=>get_system_date( ).

      <new_record>-ChangedBy     = cl_abap_context_info=>get_user_technical_name( ).

    ENDLOOP.

    " create new BO instance
    MODIFY ENTITIES OF Z_MATERIAL IN LOCAL MODE
      ENTITY mat_data
        CREATE FIELDS (
                        Plant
                        Material
                        ObjectID
DeletionIndicator
                        ProfitCenter
                        BaseQuantity
                        Production Time  )
          WITH it_selected_records
      MAPPED DATA(mapped_create)
      FAILED DATA(failed_create)
      REPORTED DATA(reported_create).

    READ ENTITIES OF Z_MATERIAL IN LOCAL MODE
      ENTITY mat_data
      ALL FIELDS WITH CORRESPONDING #( mapped_create-mat_data )
      RESULT DATA(read_created_result).

    " set the new BO instances
    mapped-mat_data   =  mapped_create-mat_data .

  ENDMETHOD.

 

 

SrividhyaKarthick_0-1720072792775.png

 

SrividhyaKarthick_1-1720072792762.png

Regards

Srividhya

Accepted Solutions (0)

Answers (0)