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

Как передать field-symbol на таблицу в подпрограмму?



 
Post new topic   Reply to topic    Russian ABAP Developer's Club Forum Index -> ABAP
View previous topic :: View next topic  
Author Message
Garik
Специалист
Специалист



Joined: 11 Oct 2007
Posts: 60

PostPosted: Tue Jan 22, 2008 12:05 pm    Post subject: Как передать field-symbol на таблицу в подпрограмму? Reply with quote

Здравствуйте, эксперты.
Пожалуйста, посмотрите в чем проблема с кодом?

Мой код:
Code:
DATA: it_mch1 TYPE STANDARD TABLE OF mch1,
      wa_mch1 TYPE mch1.

FIELD-SYMBOLS: <fs_tab> TYPE STANDARD TABLE.
ASSIGN it_mch1 TO <fs_tab>.

PERFORM proc_table USING <fs_tab>.

LOOP AT it_mch1 INTO wa_mch1.
  WRITE: / wa_mch1-matnr, wa_mch1-charg.
ENDLOOP.

FORM proc_table USING fs_tab.

  FIELD-SYMBOLS: <fs_tab>.
  DATA dref TYPE REF TO data.

  CREATE DATA dref TYPE TABLE OF (fs_tab).
  ASSIGN dref->* TO <fs_tab>.
ENDFORM. " proc_table


При выполнении кода получаю дамп:

'The current statement (CREATE DATA dref ... ) requires a character-type data object.'
Back to top
View user's profile Send private message
John Doe
Модератор
Модератор


Age: 46
Joined: 05 Nov 2007
Posts: 725
Location: КраснАдар

PostPosted: Tue Jan 22, 2008 12:30 pm    Post subject: Reply with quote

Все что происходит в подпрограмме - лишнее, на мой взгляд. Я немного код переработал.
Code:
DATA: IT_MCH1 TYPE STANDARD TABLE OF SFLIGHT,
      WA_MCH1 TYPE SFLIGHT.

FIELD-SYMBOLS: <FS_TAB> TYPE STANDARD TABLE.

SELECT * FROM SFLIGHT INTO TABLE IT_MCH1.
ASSIGN IT_MCH1 TO <FS_TAB>.

PERFORM PROC_TABLE TABLES <FS_TAB>.

WRITE /.
WRITE / 'FS table values after'.
LOOP AT <FS_TAB> INTO WA_MCH1.
  WRITE: / WA_MCH1-CARRID, WA_MCH1-CONNID.
ENDLOOP.

*&---------------------------------------------------------------------*
*&      Form  PROC_TABLE
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
*      -->FS_TAB     text
*----------------------------------------------------------------------*
FORM PROC_TABLE TABLES FS_TAB.
  WRITE / 'FS table values before'.
  LOOP AT FS_TAB INTO WA_MCH1.
    WRITE: / WA_MCH1-CARRID, WA_MCH1-CONNID.
    IF WA_MCH1-CARRID = 'LH'.
      DELETE TABLE FS_TAB FROM WA_MCH1.
    ENDIF.
  ENDLOOP.
ENDFORM. " proc_table


Теперь поясню:
1. Филд-симбол объявлен как таблица, передавать его надо в подпрограмму через TABLES.
2. В подпрограмме Вы уже начинаете работать с филд-симболом, но через таблицу FS_TAB, т.е. все уже реализовано относительно темы топика.
Back to top
View user's profile Send private message Blog
Garik
Специалист
Специалист



Joined: 11 Oct 2007
Posts: 60

PostPosted: Wed Jan 23, 2008 11:03 am    Post subject: Reply with quote

John Doe, спасибо, ваш вариант рабочий.
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 -> ABAP 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.