Chinaunix首页 | 论坛 | 博客
  • 博客访问: 481879
  • 博文数量: 199
  • 博客积分: 0
  • 博客等级: 民兵
  • 技术积分: 1902
  • 用 户 组: 普通用户
  • 注册时间: 2020-05-14 13:25
个人简介

代码5S

文章分类

全部博文(199)

文章存档

2021年(5)

2020年(194)

我的朋友

分类: 其他平台

2020-10-30 11:26:51


点击(此处)折叠或打开

  1. REPORT ztest.

  2. *----------------------------------------------------------------------*
  3. * CLASS cl_get_material_name DEFINITION
  4. *----------------------------------------------------------------------*
  5. *
  6. *----------------------------------------------------------------------*
  7. CLASS cl_get_material_name DEFINITION.
  8.   PUBLIC SECTION.
  9.     CLASS-METHODS get IMPORTING cf TYPE char1 OPTIONAL "删除内表重复行
  10.                       CHANGING it_itab TYPE ANY TABLE.
  11. ENDCLASS. "cl_get_material_name DEFINITION

  12. *----------------------------------------------------------------------*
  13. * CLASS cl_get_material_name IMPLEMENTATION
  14. *----------------------------------------------------------------------*
  15. *
  16. *----------------------------------------------------------------------*
  17. CLASS cl_get_material_name IMPLEMENTATION.

  18.   METHOD get.
  19.     DATA:BEGIN OF ls_makt,
  20.            matnr TYPE makt-matnr,
  21.            maktx TYPE makt-maktx,
  22.          END OF ls_makt,
  23.          lt_makt LIKE TABLE OF ls_makt.

  24.     DATA:lv_cond TYPE string.

  25.     FIELD-SYMBOLS:<ls_itab> TYPE any,
  26.                   <lv_matnr> TYPE any,
  27.                   <lv_maktx> TYPE any.

  28.     DATA:lo_itab TYPE REF TO data..
  29.     FIELD-SYMBOLS:<lt_itab> TYPE ANY TABLE.
  30.     CHECK it_itab IS NOT INITIAL.

  31.     IF cf EQ 'X'."删除重复行
  32.       CREATE DATA lo_itab LIKE it_itab.

  33.       ASSIGN lo_itab->* TO .
  34.        = it_itab.

  35.       SORT BY ('MATNR').
  36.       DELETE ADJACENT DUPLICATES FROM COMPARING ('MATNR').

  37.       lv_cond = 'matnr EQ -matnr'.
  38.       SELECT matnr maktx INTO TABLE lt_makt
  39.         FROM makt
  40.         FOR ALL ENTRIES IN
  41.         WHERE (lv_cond).

  42.     ELSE.
  43.       lv_cond = 'matnr EQ it_itab-matnr'.
  44.       SELECT matnr maktx INTO TABLE lt_makt
  45.         FROM makt
  46.         FOR ALL ENTRIES IN it_itab
  47.         WHERE (lv_cond).
  48.     ENDIF.

  49.     SORT lt_makt BY matnr.

  50.     LOOP AT it_itab ASSIGNING .
  51.       ASSIGN COMPONENT 'MATNR' OF STRUCTURE TO .
  52.       ASSIGN COMPONENT 'MAKTX' OF STRUCTURE TO .

  53.       READ TABLE lt_makt INTO ls_makt
  54.         WITH KEY matnr = BINARY SEARCH.
  55.       IF sy-subrc EQ 0.
  56.          = ls_makt-maktx.
  57.       ENDIF.
  58.     ENDLOOP.

  59.   ENDMETHOD. "get
  60. ENDCLASS.
















阅读(1858) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~