types: begin of line, cola(2) type c, col1 type i, col2 type i, end of line.
data: tab type standard table of line with header line, st type line.
st-cola = 'A'. st-col1 = 1. st-col2 = '111'. append st to tab.
st-cola = 'B'. st-col1 = 2. st-col2 = '111'. append st to tab.
st-cola = 'B'. st-col1 = 2. st-col2 = '111'. append st to tab.
st-cola = 'B'. st-col1 = 2. st-col2 = '111'. append st to tab.
sort tab ascending by col1. "ascending descending data: line type i, l_matnr(2) type c.
loop at tab. line = line + 1. if line = 1. move tab-cola to l_matnr. else. if l_matnr <> tab-cola. line = '1'. move tab-cola to l_matnr. endif. endif. write:/ line. endloop.
**----------------------------------------------------------**** ** field-symbols 的用法 ** 用来拆分长字符,好用 ** sbook 是系统里的结构 **----------------------------------------------------------**** data: p_char(100) value '001LHF123419950627'. field-symbols: <f1> structure sbook default p_char. write:/ <f1>-mandt, <f1>-carrid, <f1>-connid, <f1>-fldate.
** 上下两段代码的效果一样
types: begin of st1, f1(3) type c, f2(3) type c, f3(4) type c, f4 type dats, end of st1.
data: it_tab type st1. field-symbols: <f2> structure it_tab default p_char. write:/ <f2>-f1, <f2>-f2, <f2>-f3, <f2>-f4.