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-SYMBOLS for TABLE types



 
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: 1639

PostPosted: Wed Oct 17, 2007 3:17 pm    Post subject: FIELD-SYMBOLS for TABLE types Reply with quote

Code:

TYPES: BEGIN OF line,
         col1 TYPE c,
         col2 TYPE c,
       END OF line.

DATA: wa TYPE line,
      itab TYPE HASHED TABLE OF line WITH UNIQUE KEY col1,
      key(4) TYPE c VALUE 'COL1'.

FIELD-SYMBOLS <fs> TYPE ANY TABLE.

ASSIGN itab TO <fs>.

READ TABLE <fs> WITH TABLE KEY (key) = 'X' INTO wa.


The internal table ITAB is assigned to the generic field symbol <FS>, after which it is possible to address the table key of the field symbol dynamically. However, the static address

READ TABLE <fs> WITH TABLE KEY col1 = 'X' INTO wa.

is not possible syntactically, since the field symbol does not adopt the key of table ITAB until runtime. In the program, the type specification ANY TABLE only indicates that <FS> is a table. If the type had been ANY (or no type had been specified at all), even the specific internal table statement READ TABLE <FS> would not have been possible.


Code:

      TYPES: ty_iscj_postings TYPE TABLE OF iscj_postings.
      FIELD-SYMBOLS:
               <it_tab>     TYPE ty_iscj_postings,
               <wa_tab>     TYPE iscj_postings.

      ASSIGN ('(SAPMFCJ0)ITCJ_E_POSTINGS[]') TO <it_tab>.

      IF <it_tab> IS ASSIGNED.

        READ TABLE <it_tab> ASSIGNING <wa_tab> WITH KEY
          CAJO_NUMBER = <tab>-CAJO_NUMBER
          COMP_CODE   = <tab>-COMP_CODE
          FISC_YEAR   = <tab>-FISC_YEAR
          POSTING_NUMBER = <tab>-POSTING_NUMBER.

        IF sy-subrc IS INITIAL.

          <wa_tab>-DOCUMENT_NUMBER = zgfordn_str-payment_xblnr.
          MODIFY TABLE <it_tab> FROM <wa_tab>
            TRANSPORTING DOCUMENT_NUMBER.

        ENDIF.
*        LOOP AT <it_tab> ASSIGNING <wa_tab>.
*          CHECK <wa_tab>-CAJO_NUMBER = <tab>-CAJO_NUMBER
*            AND <wa_tab>-COMP_CODE = <tab>-COMP_CODE
*            AND <wa_tab>-FISC_YEAR = <tab>-FISC_YEAR
*            AND <wa_tab>-POSTING_NUMBER = <tab>-POSTING_NUMBER.
*           <wa_tab>-DOCUMENT_NUMBER = zgfordn_str-payment_xblnr.
*           MODIFY TABLE <it_tab> FROM <wa_tab>.
**        LOOP AT <it_tab> ASSIGNING <wa_tab>.
**          <wa_tab>-DOCUMENT_NUMBER = <tab>-DOCUMENT_NUMBER.
*        ENDLOOP.
      ENDIF.
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.