Ding-Log
  • Ding Blog
  • Life
    • My Tool Box
  • Golang
    • Basic
      • Go语言学习笔记
        • Go语言 Channel
        • Go语言 goroutine
        • Go语言 如何写Godoc
        • Go语言panic, recover
        • Go语言的Defer函数
        • Go语言的闭包
        • Go语言接口(Golang - Interface)
        • Go语言的面向对象
      • Go语言爬虫
        • Go语言爬虫 - 广度优先算法
      • Map
    • Web
      • Example to handle GET and POST request in Golang
    • Exercism
      • Isogram
      • ETL
      • Accumulate
      • Scrabble Score
  • SAP
    • SAPUI5&Fiori
      • How to prepare C_FIORDEV_20 SAP Certified Development Associate — SAP Fiori Application Developer
      • SAPUI5 sap.ui.define and sap.ui.require
      • SAPUI5 Models and Binding
      • SAPUI5 MVC Walkthrough
    • ABAP
      • Working with Internal Tables
      • 关于使用内部表的时候的一些注意事项
      • Error Handling
  • Log
Powered by GitBook
On this page
  • 追加数据
  • APPEND
  • INSERT

Was this helpful?

  1. SAP
  2. ABAP

Working with Internal Tables

追加数据

APPEND

  • APPEND statement always adds the record at the end of the table and is used with standard tables.

You need to use caution when using an APPEND statement with sorted tables; the system may produce a runtime error if the new row does not match the sort sequence of the table or if the table is defined with a unique key and the new row creates a duplicate entry

  • Recommend always using the INSERT statement with sorted tables.

  • Can't use APPEND statements with hashed tables, because they only support INSERT statements.

To add a record to an internal table, first fill the work area with the required data and then append it to the table using the APPEND statement.

TYPES : BEGIN OF ty_sflight.
        CARRID TYPE S_CARR_ID.
        CONNID TYPE S_C0NN_ID, 
        FLDATE TYPE S_DATE, 
END OF ty_sf1ight.

DATA : 
        1t_sflight TYPE STANDARD TABLE OF ty_sflight, 
        wa_sflight TYPE ty_sflight.

wa_sflight-carrid - *AA’. 
wa_sflight-connid = '0004’. 
wa_sflight-fldate = "20140101••APPEND wa_sflight TO it_sf1ight. "Adds the first row to the table wa_sflight-carrid = 'AB'. 
wa_sflight-connid = '0005'. 
wa_sflight-fldate = '20140102’.

APPEND wa_sflight TO it_sf1ight. "Adds second row to the table

INSERT

  • INSERT statement behaves like an APPEND statement for standard tables in that it adds a record at the end of the table if no explicit index is speci­ fied

  • With sorted tables, the INSERT statement automatically selects the posi­tion based on the sort sequence of the table.

When an index is supplied with the INSERT statement, the record is added explicitly in that row. If the index supplied is greater than the line of the table, no record is inserted and the system field sy-subrc is set to 4.

wa_sflight-carrid = 'AC'. 
wa_sflight-connid = '0006'. 
wa_sflight-fldate = '20140103'.
INSERT wa_sflight INTO TABLE it_sflight.

wa_sflight-carrid = 'AD'.
wa_sflight-connid = ’0007’. 
wa_sflight-fldate = ’20140104'.
INSERT wa_sf1ight INTO it.sflight INDEX 1
PreviousABAPNext关于使用内部表的时候的一些注意事项

Last updated 5 years ago

Was this helpful?