You are on page 1of 7

Object Oriented Programming – Persistent Objects

Object Oriented Programming Persistent Objects – Quick reference
Brought to you by

For more tips, tutorials, Interview questions, certification questions, please visit SAPTechnical.com

Step: 2 ->Create a Persistent Class In the next screen select the class type as Persistent Class and then hit Save Button. please visit SAPTechnical.Object Oriented Programming – Persistent Objects By Abdul Hakim. Satyam Computer Services Ltd Objective To store references to the persistent object persistently in the database. The first field is used to store the instance GUID while the other is used to store the class GUID. Interview questions. tutorials. certification questions.com . For more tips. Step: 1 -> Create a database table This table should contain 2 fields of type OS_GUID in addition to the GUID object attribute.

For e. please visit SAPTechnical.com . Interview questions. certification questions.g.Object Oriented Programming – Persistent Objects Step: 3 -> Persistent Mapping or Mapping Goto->Persistence Representation Give the table name. ZSTUDENT03 and hit the enter button For more tips. tutorials.

ZCL_PERSIST_03 For more tips. While adding the field INST_GUID choose the assignment type as Object reference and for the attribute type specify the class name for e.Object Oriented Programming – Persistent Objects Table fields appear in the lower half of the tool screen. please visit SAPTechnical. tutorials.g. Add the remaining fields. Interview questions.com . certification questions. Double Click the table field and press the button.

tutorials. Interview questions. please visit SAPTechnical. Screen looks like below. Press the Yes Button to activate the class actor as well. Enter the name of the reference attribute for the attribute name. Activate the Class.Object Oriented Programming – Persistent Objects To assign a class indicator. Press Save.com . For more tips. certification questions. select the corresponding table field of type OS_GUID by doubleclicking.

certification questions. TRY. DATA: SNO LIKE ZSTUDENT04-SNO VALUE '1000'. Interview questions. please visit SAPTechnical. Go to SE16 and check the entries. MARK1 LIKE ZSTUDENT04-MARK1 VALUE '100'. ENDTRY. Source Code excerpt. CALL METHOD AGENT->CREATE_PERSISTENT EXPORTING * I_INST_GUID = I_MARK1 = MARK1 I_MARK2 = MARK2 I_SNAME = SNAME I_SNO = SNO * RECEIVING * RESULT = . CALL METHOD AGENT->IF_OS_CA_PERSISTENCY~GET_PERSISTENT_BY_OID EXPORTING I_OID = '30EA9E25999F0843BE6F7B86063F2916' RECEIVING RESULT = REF1 For more tips.com . AGENT = ZCA_PERSIST_03=>AGENT. REF1 TYPE REF TO OBJECT. MARK2 LIKE ZSTUDENT04-MARK2 VALUE '100'. tutorials. Store the Persistent Object Reference in the database. CATCH CX_OS_OBJECT_EXISTING . STUDENT TYPE REF TO ZCL_PERSIST_03.Object Oriented Programming – Persistent Objects Write a Program to create the persistent object. COMMIT WORK. TRY. SNAME LIKE ZSTUDENT04-SNAME VALUE 'HAKIM'. Source Code excerpt: DATA: AGENT TYPE REF TO ZCA_PERSIST_03.

Interview questions. ENDTRY. please visit For more tips. please visit SAPTechnical. STUDENT->SET_INST_GUID( STUDENT ). STUDENT ?= REF1. For Tutorials on various Technical Topics. CATCH CX_OS_CLASS_NOT_FOUND . COMMIT WORK. CATCH CX_OS_OBJECT_NOT_FOUND . certification questions. tutorials. Go to SE16 and check the entries.Object Oriented Programming – Persistent Objects .com .