Application Development and Automation Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

Update New Field with Persistent Data Objects

GreggHinkle
Participant
0 Likes
2,556

Hi,

I have a table which I previously created a persistent object class, generated my base and agent classes and mapped the fields using the persistent data mapper. Everything worked great and I can read and update the records from this table using the get and set methods perfectly.

A new requirement came in recently and I needed to add an additional field to this table. So I appended the new field to the end of the table (saved and activated changes) and then I went back to my persistent object class and using the persistent data mapper, added the new field. (saved and activated). The new set and get methods were generated for the new field. However when I call the get_persistent method to get the persistent data object, and then use the get method to view the new field, the contents are empty even though the table contains data in this field. When I use the set method to update the new field, nothing is written to the database. All the other get and set methods for the other fields still work perfectly. Has anyone come across this before?

Thanks,

Gregg

5 REPLIES 5
Read only

Former Member
0 Likes
1,792

Hi,

Could you please give us the code of set and get method so that it becomes easier to analyze ur issue...

Regards,

Siddarth

Read only

0 Likes
1,792

Hi Siddarth,

Thanks for responding. The get and set methods that are used are the SAP generated get and set methods that are created when you use the persistent data mapper. Following is the generated get and set methods:

The SAP generated Get method

method GET_PERID.
***BUILD 051401
     " returning RESULT
     " raising CX_OS_OBJECT_NOT_FOUND
************************************************************************
* Purpose        : Get Attribute PERID
*
* Version        : 2.0
*
* Precondition   : -
*
* Postcondition  : The object state is loaded, result is set
*
* OO Exceptions  : CX_OS_OBJECT_NOT_FOUND
*
* Implementation : -
*
************************************************************************
* Changelog:
* - 2000-03-14   : (BGR) Version 2.0
* - 2000-07-28   : (SB)  OO Exceptions
************************************************************************

* * Inform class agent and handle exceptions
  state_read_access.

  result = PERID.

           " GET_PERID
endmethod.

The SAP generated Set method

method SET_PERID.
***BUILD 051401
     " importing I_PERID
     " raising CX_OS_OBJECT_NOT_FOUND
************************************************************************
* Purpose        : Set attribute PERID
*
* Version        : 2.0
*
* Precondition   : -
*
* Postcondition  : The object state is loaded, attribute is set
*
* OO Exceptions  : CX_OS_OBJECT_NOT_FOUND
*
* Implementation : -
*
************************************************************************
* Changelog:
* - 2000-03-14   : (BGR) Version 2.0
* - 2000-07-28   : (SB)  OO Exceptions
* - 2000-10-04   : (SB)  Namespaces
************************************************************************

* * Inform class agent and handle exceptions
  state_write_access.

  if ( I_PERID <> PERID ).

    PERID = I_PERID.

*   * Inform class agent and handle exceptions
    state_changed.

  endif. "( I_PERID <> PERID )

           " GET_PERID
endmethod.

Edited by: Gregg Hinkle on Aug 24, 2009 8:41 AM

Read only

0 Likes
1,792

Continued from previous post.....

I created a sample test program to illustrate the problem. One of the fields on this table, FANAM existed when the table was initially created and the persistent object class was generated and the fields were mapped using the mapper. This get and set methods work perfectly. The new field PERID was added to the table after the persistent class was created and mapped. I went back into the mapper and mapped this field as well. The get and set methods were generated automatically. However when I attempt to update this field using the set method, the field is not updated.

REPORT  zzpggah_test_persistent.

DATA: lr_agent     TYPE REF TO zca_openrl_it0021_pers,
      lr_pers_obj  TYPE REF TO zcl_openrl_it0021_pers.

TRY .

    lr_agent    = zca_openrl_it0021_pers=>agent.
    lr_pers_obj = lr_agent->get_persistent(
                    i_begda    = '20090101'
                    i_endda    = '99991231'
                    i_famsa    = '1'
                    i_infty    = '0021'
                    i_objps    = ''
                    i_pernr    = 13
                    i_zzloadid = '20090006' ).

  CATCH cx_os_object_not_found.

ENDTRY.

lr_pers_obj->set_fanam( 'AAAAAAA' ).
lr_pers_obj->set_perid( '123456789' ).
COMMIT WORK.

So using this sample program I field FANAM is updated, but PERID is not. No errors or exceptions are raised when running this code. If you have any ideas, please let me know.

Thanks,

Gregg

Edited by: Gregg Hinkle on Aug 24, 2009 8:44 AM

Edited by: Gregg Hinkle on Aug 24, 2009 8:46 AM

Read only

1,792

I solved my own issue. For whatever reason when I mapped the new field using the mapping tool, the ZCB_* class did not regenerate the MAP_* methods. Therefore the data in the field was never updated or read. What I did to fix it was run the Option Utilities - Generate - Class Agent - Class from the mapping screen. This regenerated the agent classes with the new field added. I hope this helps others with the same issue.

Read only

florian_pichler
Discoverer
0 Likes
1,792

Hey Gregg,

thank you very much for your help!

BR

Florian