内表的操作(内表的定义,插入,修改,删除)

时间:2020-12-01 00:37:14
*根据表类型zsean_school1创建一张带工作区的内表
DATA gs_student_a TYPE zsean_school1.
DATA gt_student_a LIKE TABLE OF gs_student_a WITH HEADER LINE.
gt_student_a-zcode = '2269'.
gt_student_a-zname = '熊猫'.
gt_student_a-sex   = 'M'.
gt_student_a-weigh = '70'.
gt_student_a-zunit = 'kg'.
APPEND gt_student_a.
WRITE:gt_student_a-zcode,gt_student_a-zname,gt_student_a-sex,gt_student_a-weigh,gt_student_a-zunit,

测试结果:

内表的操作(内表的定义,插入,修改,删除)

*根据结构类型zsean_school创建一张带工作区的内表
DATA gs_student TYPE zsean_student.
DATA gt_student LIKE TABLE OF gs_student WITH HEADER LINE .
gt_student-zcode = '2269'.
gt_student-zname = '熊猫'.
gt_student-sex   = 'M'.
gt_student-zschool = '100'.
gt_student-zschool-zsname = '广西科技大学'.
gt_student-zadd = '广西柳州'.
APPEND gt_student.
WRITE:gt_student-zschool,gt_student-zschool-zsname,gt_student-zadd,gt_student-zcode,gt_student-zname,gt_student-sex ,
      /.

测试结果:参考的表类型的时候,表类型里引用的其他结构,在显示的是时候该该结构会一起显示。

内表的操作(内表的定义,插入,修改,删除)

*内表的声明及操作
DATA :BEGIN OF gs_student_1,
        code LIKE zsean_school1-zcode,
        name LIKE zsean_school1-zname.
    INCLUDE STRUCTURE zsean_school.
DATA : weigh LIKE zsean_school1-weigh,
       END OF gs_student_1.

DATA itab_student LIKE TABLE OF gs_student_1  INITIAL SIZE 10 WITH HEADER LINE.

itab_student-code = '100'.
itab_student-name = '大熊猫'.
itab_student-zschool = '100'.
itab_student-zsname  = '广西科技大学'.
itab_student-zadd    = '广西柳州'.
APPEND itab_student.

itab_student-code = '200'.
itab_student-name = '超级熊猫'.
itab_student-zschool = '100'.
itab_student-zsname  = '广西科技大学'.
itab_student-zadd    = '广西柳州'.
INSERT itab_student INDEX 1.

itab_student-code = '300'.
itab_student-name = '超级大熊猫'.
itab_student-zschool = '100'.
itab_student-zsname  = '广西科技大学'.
itab_student-zadd    = '广西柳州'.
MODIFY itab_student INDEX 1.

itab_student-code = '300'.
itab_student-name = '超级大熊猫'.
itab_student-zschool = '100'.
itab_student-zsname  = '广西科技大学'.
itab_student-zadd    = '广西柳州'.
APPEND  itab_student.
DELETE itab_student INDEX 4.

READ TABLE itab_student INDEX 1.

WRITE: / itab_student-code ,
         itab_student-name ,
         itab_student-zschool ,
         itab_student-zsname  ,
         itab_student-zadd  ,
         /.