cancel
Showing results for 
Search instead for 
Did you mean: 

persistence class

ravi_kumar221
Participant
0 Kudos

hi help me i need to create   persistence  class  in my application        how to create it and how to uuse it help me

Accepted Solutions (0)

Answers (2)

Answers (2)

jayanthi_jayaraman
Active Contributor
0 Kudos

Hi,

Go to SE24 and then click the class and then choose persistance class.

JanarthananE
Contributor
0 Kudos

Hi Ravi,

Refer the following link for classes workflow in abap WDA.

http://www.saptechnical.com/Tutorials/OOPS/InWorkflow/page3.htm

even better understanding refer the following tutorial for step by step process to create persistence object.

http://www.saptechnical.com/Tutorials/OOPS/Persistent/BusinessKey.htm

about persistence class, why we need persistence class , go through the following thread.

http://scn.sap.com/thread/1735340

http://scn.sap.com/thread/1398772

Hope its useful to u.

Regards

Jana

ravi_kumar221
Participant
0 Kudos

hi the linke which uhave given me i  created persistence class   but in code  igot  some problem

zca_persist_02=>agent.    did not get attribute 

REPORT  Z_PERSISTENT_GUID.
selection-screen begin of block b1 with frame title tit1.
parameters: sno   like zstudent02-sno,
            sname like zstudent02-sname,
            mark1 like zstudent02-mark1,
            mark2 like zstudent02-mark2,
            guid  like zstudent02-guid.
selection-screen end of block b1.

selection-screen begin of block b2 with frame title tit2.
parameters: r1 radiobutton group rad1,
            r2 radiobutton group rad1,
            r3 radiobutton group rad1.
selection-screen end of block b2.
data: agent type ref to zca_persist_02,
      students type ref to zcl_persist_02.
data: result1 type ref to object,
      result2 type ref to zcl_persist_02.
*-------------------------------------------------------------------*
*       Load-of-Program
*-------------------------------------------------------------------*
load-of-program.
  tit1 = text-001.
  tit2 = tit1.
*-------------------------------------------------------------------*
*       At Selection Screen
*-------------------------------------------------------------------*
at selection-screen.
  if ( r2 eq 'X' ).
    if sno is initial or sname is initial.
      MESSAGE 'Enter the values in Sno/Sname fields'
      TYPE 'E' DISPLAY LIKE 'E'.
    endif.
  endif.
*-------------------------------------------------------------------*
*       Start-of-Selection
*-------------------------------------------------------------------*
start-of-selection.
  agent = zca_persist_02=>agent.
  if r1 eq 'X'.
    TRY.
        CALL METHOD AGENT->IF_OS_CA_PERSISTENCY~GET_PERSISTENT_BY_OID
          EXPORTING
            I_OID  = guid
          RECEIVING
            RESULT = result1.
        result2 ?= result1.
        sno = result2->get_sno( ).
        sname = result2->get_sname( ).
        mark1 = result2->get_mark1( ).
        mark2 = result2->get_mark2( ).
        
write:/ sno,
                sname,
                mark1,
                mark2.
      CATCH CX_OS_OBJECT_NOT_FOUND .
*      CATCH CX_OS_CLASS_NOT_FOUND .
        MESSAGE 'Object doesn''t exists' TYPE 'I' DISPLAY LIKE 'E'.
    ENDTRY.
  elseif r2 eq 'X'.
    TRY.
        CALL METHOD AGENT->CREATE_PERSISTENT
          EXPORTING
            I_MARK1 = mark1
            I_MARK2 = mark2
            I_SNAME = sname
            I_SNO   = sno
          RECEIVING
            RESULT  = students.
        commit work.
        write 'Object Created'.
      CATCH CX_OS_OBJECT_EXISTING .
        MESSAGE 'Object already exists' TYPE 'I' DISPLAY LIKE 'E'.
    ENDTRY.
  else.
    TRY.
        CALL METHOD AGENT->IF_OS_CA_PERSISTENCY~GET_PERSISTENT_BY_OID
          EXPORTING
            I_OID  = guid
          RECEIVING
            RESULT = result1.
      CATCH CX_OS_OBJECT_NOT_FOUND .
*      CATCH CX_OS_CLASS_NOT_FOUND .
        MESSAGE 'Object doesn''t exists' TYPE 'I' DISPLAY LIKE 'E'.
    ENDTRY.
    result2 ?= result1.
    TRY.
        CALL METHOD AGENT->IF_OS_FACTORY~DELETE_PERSISTENT
          EXPORTING
            I_OBJECT = result2.
        commit work.
        write 'Object Deleted'.
      CATCH CX_OS_OBJECT_NOT_EXISTING .
        MESSAGE 'Object doesn''t exists' TYPE 'I' DISPLAY LIKE 'E'.
    ENDTRY.
  endif.
JanarthananE
Contributor
0 Kudos

Hi Ravi,

Did u tried with coding part what was d exact one.  read other links which i have already shared above for concept of persistence class in WDA.

Regards

Jana