SAP R/3 форум ABAP консультантов
Russian ABAP Developer's Club

Home - FAQ - Search - Memberlist - Usergroups - Profile - Log in to check your private messages - Register - Log in - English
Blogs - Weblogs News

Example: Table of dynamic objects



 
Post new topic   Reply to topic    Russian ABAP Developer's Club Forum Index -> Dynamic Programming | Динамическое программирование
View previous topic :: View next topic  
Author Message
admin
Администратор
Администратор



Joined: 01 Sep 2007
Posts: 1640

PostPosted: Fri Sep 21, 2007 4:56 pm    Post subject: Example: Table of dynamic objects Reply with quote

Code:
REPORT s_dynamic_data_objects.

* Data declarations

TYPES: BEGIN OF t_item,
         content TYPE i,
         next TYPE REF TO data,
       END OF t_item.

DATA: dref_start TYPE REF TO data,
      dref_new TYPE REF TO data.

FIELD-SYMBOLS <fs_new> TYPE t_item.

* Create dynamic list

DO 10 TIMES.
  CREATE DATA dref_new TYPE t_item.
  ASSIGN dref_new->* TO <fs_new>.
  <fs_new>-content = sy-index ** 2.
  IF sy-index = 1.
    dref_start = dref_new.
  ENDIF.
  PERFORM append_item USING dref_start
                            dref_new.
ENDDO.

PERFORM show_list_content USING dref_start.

* Subroutines

FORM append_item USING dref_start TYPE REF TO data
                       dref_new TYPE REF TO data.
  FIELD-SYMBOLS <fs_curitem> TYPE t_item.
  DATA dref_cur TYPE REF TO data.
  IF dref_start = dref_new.
    EXIT.
  ENDIF.
  dref_cur = dref_start.
  ASSIGN dref_cur->* TO <fs_curitem>.
  WHILE NOT <fs_curitem>-next IS INITIAL.
    dref_cur = <fs_curitem>-next.
    ASSIGN dref_cur->* TO <fs_curitem>.
  ENDWHILE.
  <fs_curitem>-next = dref_new.
ENDFORM.

*

FORM show_list_content USING dref_start TYPE REF TO data.
  FIELD-SYMBOLS <fs_curitem> TYPE t_item.
  DATA dref_cur TYPE REF TO data.
  dref_cur = dref_start.
  WHILE NOT dref_cur IS INITIAL.
    ASSIGN dref_cur->* TO <fs_curitem>.
    WRITE:/ <fs_curitem>-content.
    dref_cur = <fs_curitem>-next.
  ENDWHILE.
ENDFORM.
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    Russian ABAP Developer's Club Forum Index -> Dynamic Programming | Динамическое программирование All times are GMT + 4 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


All product names are trademarks of their respective companies. SAPNET.RU websites are in no way affiliated with SAP AG.
SAP, SAP R/3, R/3 software, mySAP, ABAP, BAPI, xApps, SAP NetWeaver and any other are registered trademarks of SAP AG.
Every effort is made to ensure content integrity. Use information on this site at your own risk.