此博客为原创博客,都是个人工作经历所得,转载请注明出处

单层反查BOM

 

*&---------------------------------------------------------------------*
*& Report YCX_001
*&---------------------------------------------------------------------*
*&
*&---------------------------------------------------------------------*
REPORT ycx_001.

DATA: datub LIKE rc29l-datub,
      datuv LIKE rc29l-datuv.

DATA:
  lt_wultb   TYPE TABLE OF stpov,
  lt_equicat TYPE TABLE OF cscequi,
  lt_kndcat  TYPE TABLE OF cscknd,
  lt_matcat  TYPE TABLE OF cscmat,
  lt_stdcat  TYPE TABLE OF cscstd,
  lt_tplcat  TYPE TABLE OF csctpl.

SELECTION-SCREEN BEGIN OF BLOCK bk1 WITH FRAME.
PARAMETERS: p_werks LIKE marc-werks.
PARAMETERS: p_matnr LIKE marc-matnr.
SELECTION-SCREEN END OF BLOCK bk1.

START-OF-SELECTION.

  "单层反查BOM
  CALL FUNCTION 'CS_WHERE_USED_MAT'
    EXPORTING
      datub                      = sy-datum
      datuv                      = sy-datum
      matnr                      = p_matnr  " 物料
      stlan                      = '1'     " 物料清单用途
      werks                      = p_werks  " 工厂
    TABLES
      wultb                      = lt_wultb
      equicat                    = lt_equicat
      kndcat                     = lt_kndcat
      matcat                     = lt_matcat
      stdcat                     = lt_stdcat
      tplcat                     = lt_tplcat
    EXCEPTIONS
      call_invalid               = 1
      material_not_found         = 2
      no_where_used_rec_found    = 3
      no_where_used_rec_selected = 4
      no_where_used_rec_valid    = 5
      OTHERS                     = 6.

  READ TABLE  lt_wultb INTO DATA(ls_wultb) INDEX 1.
  IF sy-subrc EQ 0.
    DATA(LV_MJ) = ls_wultb-matnr.
  ENDIF.
  WRITE:LV_MJ.

 

posted @ 2019-09-22 22:08  Rainystuday  阅读(208)  评论(0编辑  收藏  举报