<ruby id="bdb3f"></ruby>

    <p id="bdb3f"><cite id="bdb3f"></cite></p>

      <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
        <p id="bdb3f"><cite id="bdb3f"></cite></p>

          <pre id="bdb3f"></pre>
          <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

          <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
          <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

          <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                <ruby id="bdb3f"></ruby>

                企業??AI智能體構建引擎,智能編排和調試,一鍵部署,支持知識庫和私有化部署方案 廣告
                # SAP ABAP 內部表:創建,讀取,填充,復制&刪除 > 原文: [https://www.guru99.com/all-about-sap-internal-tables.html](https://www.guru99.com/all-about-sap-internal-tables.html) ## 什么是內部表? **內部表**用于從固定結構中獲取數據,以便在 ABAP 中動態使用。 內部表中的每一行都具有相同的字段結構。 內部表的主要用途是存儲和格式化程序中數據庫表中的數據。 在本教程中,您將學習: * [什么是內部表?](#1) * [什么是工作區?](#2) * [內部表和工作區之間的區別?](#3) * [內部表的類型](#4) * [創建內部表](#5) * [填充內部表](#6) * [復制內部表](#7) * [讀取內部](#8) * [刪除內部表](#9) ## 什么是工作區? 工作區是單行數據。 它們應具有與任何內部表相同的格式。 它用于一次處理一行內部表中的數據。 ## 內部表與工作區之間的區別? 圖片說了一千個字:-) ![SAP ABAP Internal Table: Create, Read, Populate, Copy & Delete](https://img.kancloud.cn/9b/ab/9babcd6e1e7bd5c45597b813225e3e73_413x273.png "sap-internal-table") ## 內部表的類型 內部表有兩種類型。 1. 帶 HEADER 行的內部表 2. 沒有 HEADER 行的內部表。 **內部表帶有標題行** * 系統在此處自動創建工作區。 * 工作區與內部表具有相同的數據類型。 * 該工作區稱為 HEADER 行。 * 在這里,所有更改或對表內容的任何操作均已完成。 結果,記錄可以直接插入表中,也可以直接從內部表訪問。 **內部表不帶標題行**: * 這里沒有與表格關聯的工作區。 * 當我們需要訪問此類表時,應明確指定工作區。 * 因此,這些表不能直接訪問。 ## 創建內部表 有多種創建內部表的方法。 讓我們一一看一下- **1.通過使用類型語句** 現在讓我們使用 TYPE 創建一個內部表 *itab* 聲明。 語法是- ``` Types : begin of line, column1 type I, column2 type I, end of line. ``` 例: ``` TYPES : begin of line, empno type I, empname(20) type c , end of line. ``` TYPES 語句按定義創建結構*行*。 要實際創建內部表 *Itab* ,請使用以下命令- ``` Data itab type line occurs 10. ``` 使用 line 的結構創建內部表 *itab* 。除了聲明內部表的結構外,OCCURS 子句還定義了在主存儲器中維護多少個表條目(在本例中為 10)。 多余的記錄會寫到分頁區域,并會影響性能 **2.通過引用另一個表** ,您可以通過引用現有表來創建內部表。 現有表可以是標準 SAP 表,Z 表或另一個內部表。 語法- ``` Data <f> <type> [with header line]. ``` 例- ``` DATA itab TYPE line OCCURS 10 with header line. ``` 在此,創建帶有標題行的類型行的內部表 *itab* 。 請注意,“帶有標題行”是可選的 **3.通過引用現有結構** 語法- ``` Data <f> LIKE <struct> occurs n [with header line]. ``` Example- ``` DATA itab LIKE sline OCCURS 10. ``` 這里創建了一個表 *itab* ,其結構與行 **相同。4.通過創建新結構** ,讓我們創建一個 內部表具有我們自己的結構。 在這里,表是用標題行創建的,默認為為**。 語法-** ``` Data : Begin of <f> occurs <n>, <component declaration>, ................................., End of <f>. ``` 范例- ``` Data : Begin of itab occurs 10, column1 type I, column2(4) type C, column3 like mara-ernam, End of itab. ``` 內部表 *Itab* 已創建 ## 填充內部表 Now that we have successfully created some internal tables, let us see how do we populate them with some records. There are various methods available to populate tables**1.Append Data line by line**The first method available is the use of the APPEND statement. Using the APPEND statement we can either add one line from another work area to the internal table or we can add one initial line to the internal table.. Syntax - ``` APPEND [<wa> TO / INITIAL LINE TO] <itable>. ``` Here work area *<wa>* or the Initial Line is appended to the internal table *<itable>.* The system variable *SY-TABIX* contains the index of the appended line. Example: ``` Data: Begin of itab occurs 10, col1 type C, col2 type I, end of itab. Append initial line to itab. ``` Results : ' ' '0' Initial lines adds a line initialized with the correct value for its type to the table. Here ,? col1 is an character and col2 is a integer. Then APPEND initial line, adds a line initialized with respect to the data type of the columns, i.e. space for col1 and 0 for col2. **2.Using COLLECT statement** ?COLLECT is another form of statement used for populating the internal tables. Generally COLLECT is used while inserting lines into an internal table with unique standard key. Syntax- ``` COLLECT [<wa> INTO] <itable>. ``` Incase of tables with Header line, INTO option is omitted. Suppose there is already an entry having a key same as the one you are trying to append, then a new line is not added to the table, but the numeric fields of both the entries are added and only one entry corresponding to the key is present. Value of SY-TABIX is changed to the row of the original entry. Else COLLECT acts similar to APPEND and SY-TABIX contains the index of the processed line. **3**.**Using INSERT statement** INSERT statement adds a line/work area to the internal table. You can specify the position at which the new line is to be added by using the *INDEX* clause with the INSERT statement. Syntax ``` INSERT [<wa> INTO / INITIAL LINE INTO] <itable> [index <idx>]. ``` Here,? the work area *<wa>* or INITIAL LINE is inserted into internal table <*itable>* at index *<idx>*. ## 復制內部表 The contents of one internal table can be copied to another by using the APPEND LINES or INSERT LINES statement. A more simpler way is to usetany of the following syntax's. ``` MOVE <itab1> To <itab2>. OR <itab1> = <itab2>. ``` These copy the contents of ITAB1 to ITAB2\. Incase of internal tables with header line we have to use [] inorder to distinguish from work area. So, to copy contents of internal tables with header line the syntax becomes, ``` itab1[] = itab2[]. ``` ## 讀取內部表 We are now? familiar with the creation of internal tables and populating them with data. We will now see how do we actually use the data or retrieve the data from the internal tables. **1\. Using Loop -Endloop** One of the ways of accessing or reading the internal table is by using LOOP-ENDLOOP. Syntax ``` LOOP AT <itable> [INTO <wa>] ................................... ENDLOOP. ``` Here when you say LOOP AT ITABLE, then the internal table ITABLE is read line by line. You can access the values of the columns for that line during any part of the LOOP-ENDLOOP structure. The value of the *SY-SUBRC* is set to **0**, even if only one record is read. **2\. Using READ** The other method of reading the internal table is by using the READ statement. Syntax- ``` READ TABLE <itable> [INTO <wa>] INDEX <idx>. ``` This statement reads the current line or line as? specified by index *<idx>*. The value of *SY-TABIX* is the index of the line read. If an entry with the specified index is found, then *SY-SUBRC* is set to 0\. If the specified index is less than 0, then run-time error occurs. If the specified index exceeds table size then SY-SUBRC is set to 4. ## 刪除內部表 There are many ways for deleting lines from an internal table. **1.Deleting lines in a loop.** This is the simplest way for deleting lines. Sytax ``` DELETE <ITABLE>. ``` This statement works only within a loop. It deletes the current line. You can delete the lines in a loop conditionally by adding the WHERE clause. **2.Deleting lines using the index.** This is used to delete a line from internal table at any know index. Syntax ``` DELETE <ITABLE> INDEX <IDX>. ``` The line with the index <IDX> is deleted. The index of the following line is decremented by 1.
                  <ruby id="bdb3f"></ruby>

                  <p id="bdb3f"><cite id="bdb3f"></cite></p>

                    <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
                      <p id="bdb3f"><cite id="bdb3f"></cite></p>

                        <pre id="bdb3f"></pre>
                        <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

                        <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
                        <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

                        <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                              <ruby id="bdb3f"></ruby>

                              哎呀哎呀视频在线观看