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

Heap implementation in ABAP

Former Member
0 Likes
665

I try to implement in ABAP a heap. I created an class which simulate this heap but I'm interesting that in ABAP is an ready implementation of heap class?

My definition of class have methods:

- GET_LAST_TOKEN

- ADD_TOKEN

- RELEASE_TOKEN

- CHECK_IS_EMPTY

- FLIP_HEAP

Attibutes:

- HEAP //table

- TOTAL //counter

- C_FALSE //boolean false

- C_TRUE //bolean true

Implementation (only overall view)


method ADD_TOKEN .

  APPEND i_token to heap.
  IF sy-subrc = 0.
    total = total + 1.
  ENDIF.

endmethod.


METHOD release_token .

  IF total > 0.
    DELETE heap INDEX total.
    IF sy-subrc = 0.
      total = total - 1.
    ENDIF.
  ENDIF.

ENDMETHOD.


METHOD get_last_token .
  DATA: l_token LIKE LINE OF heap.

  IF total is not INITIAL.
    READ TABLE heap
      INDEX total
      INTO e_token.
  ENDIF.

ENDMETHOD.

Is this good idea?

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
530

Hello,

I think is fine, the only thing that is missing is to have a method with the number of elements, I mean something to return the counter.

Its just fine.

Gabriel.

I try to implement in ABAP a heap. I created an class which simulate this heap but I'm interesting that in ABAP is an ready implementation of heap class?

My definition of class have methods:

- GET_LAST_TOKEN

- ADD_TOKEN

- RELEASE_TOKEN

- CHECK_IS_EMPTY

- FLIP_HEAP

Attibutes:

- HEAP //table

- TOTAL //counter

- C_FALSE //boolean false

- C_TRUE //bolean true

Implementation (only overall view)


method ADD_TOKEN .

  APPEND i_token to heap.
  IF sy-subrc = 0.
    total = total + 1.
  ENDIF.

endmethod.


METHOD release_token .

  IF total > 0.
    DELETE heap INDEX total.
    IF sy-subrc = 0.
      total = total - 1.
    ENDIF.
  ENDIF.

ENDMETHOD.


METHOD get_last_token .
  DATA: l_token LIKE LINE OF heap.

  IF total is not INITIAL.
    READ TABLE heap
      INDEX total
      INTO e_token.
  ENDIF.

ENDMETHOD.

Is this good idea?

2 REPLIES 2
Read only

Former Member
0 Likes
531

Hello,

I think is fine, the only thing that is missing is to have a method with the number of elements, I mean something to return the counter.

Its just fine.

Gabriel.

Read only

Former Member
0 Likes
530

hi

good

go through this link about heap , i hope this ll help you to solve your problem

http://www.redbooks.ibm.com/redbooks/pdfs/sg246291.pdf

thanks

mrutyun^