写序号//很好用的东东

来源:互联网 发布:js uikit autocomplete 编辑:程序博客网 时间:2024/05/16 01:53

************************************************************************************写序号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 descendingdata: 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.