ITPub博客

首页 > Linux操作系统 > Linux操作系统 > 展BOM的程序CS_BOM_EXPL_MAT_V2

展BOM的程序CS_BOM_EXPL_MAT_V2

原创 Linux操作系统 作者:ytfsrs2008 时间:2009-02-14 09:26:37 0 删除 编辑
data: begin of itab_header occurs 0,
      matnr like marc-matnr,
      werks like marc-werks,
      maktx like makt-maktx,
      stlan like mast-stlan,
      stlal like mast-stlal,
      end of itab_header.

 data: itab_item like table of stpox with header line.

 data: begin of itab occurs 0,
         matnr like marc-matnr,
         maktx like makt-maktx,   "raw material desc
         desc  like makt-maktx,   "L5 Desc
         cur   like t001-waers,   "currency
         salk3 like mbew-salk3,   "total value
         lbkum like mbew-lbkum,   "total stock
         price type string,   "price for raw
         base_qty type string,
         level(4) type c.
       include structure stpox.
 data: end of itab.

 data: p_cor type i value 1000.
 selection-screen begin of block blk1 with frame. title text-001.
   parameters: t_werks like marc-werks obligatory default '1000'.
   parameters: t_matnr like  marc-matnr
                  default '1000-4488-1'.
   parameters:  t_usage like mast-stlan default '1',
                t_alt  like mast-stlal default '1'.
    selection-screen end of block blk1.

  initialization.
    if t_matnr = ''.
       message e004(zmm)
         with 'Please enter the halb material for plant' t_werks.
    endif.

 start-of-selection.
   perform. get_data_form.
   perform. trieve_data_form.

*&--------------------------------------------------*
*&      Form  get_data_form
*&--------------------------------------------------*
FORM. get_data_form.
  select marc~werks marc~matnr mast~stlan mast~stlal
        into (itab_header-werks,itab_header-matnr,
              itab_header-stlan,itab_header-stlal)
        from marc
        join mast  on marc~werks = mast~werks
        and  marc~matnr = mast~matnr
        where marc~werks = t_werks
        and   marc~matnr = t_matnr
        and   mast~stlan = t_usage
        and   mast~stlal = t_alt.
        append itab_header.
   endselect.

    if sy-subrc <> 0.
      message e004(zmm)  with 'No data generated for' t_werks.
    endif.

ENDFORM.
*&-------------------------------------------------------*
*&      Form  trieve_data_form
* &     展BOM的程序
*&-------------------------------------------------------*

FORM. trieve_data_form.
   loop at itab_header.
     CALL FUNCTION 'CS_BOM_EXPL_MAT_V2'
         EXPORTING
              CAPID                 = 'PP01'
              DATUV                 = SY-DATUM
              MEHRS                 = 'X'
              MTNRV                 = itab_header-MATNR
              WERKS                 = itab_header-WERKS
         TABLES
              STB                   = itab_item
         EXCEPTIONS
              ALT_NOT_FOUND         = 1
              CALL_INVALID          = 2
              MATERIAL_NOT_FOUND    = 3
              MISSING_AUTHORIZATION = 4
              NO_BOM_FOUND          = 5
              NO_PLANT_DATA         = 6
              NO_SUITABLE_BOM_FOUND = 7
              CONVERSION_ERROR      = 8
              OTHERS                = 9.


        if sy-subrc = 0.
           loop at itab_item.

            data:  prce1(5) type c,
                   price2(5) type c.

            move-corresponding itab_item to itab.
               itab-base_qty = itab-menge.
               select single makt~maktx into itab-maktx
                       from makt
                       where makt~matnr = itab-idnrk
                       and  makt~spras  = 'EN'.

                select single mbew~verpr
                            into (itab-verpr)
                       from mbew
                       where mbew~matnr = itab-idnrk
                       and  mbew~BWKEY  = t_werks.

               itab-price = itab-verpr / 10.

                select single makt~maktx into itab-desc
                       from makt
                       where makt~matnr = t_matnr
                       and  makt~spras  = 'EN'.

              if t_werks = '1000'.
                select single   t001~WAERS into itab-cur
                        from t001
                        where t001~BUKRS = 'C100'.
             elseif t_werks = '2000'.
                   select single   t001~WAERS into itab-cur
                        from t001
                        where t001~BUKRS = 'C200'.
             endif.
              append itab.
        endloop.
        modify itab transporting werks matnr where werks = ''.
      endif.
    ENDLOOP.
ENDFORM.

来自 “ ITPUB博客 ” ,链接:http://blog.itpub.net/15117617/viewspace-551894/,如需转载,请注明出处,否则将追究法律责任。

上一篇: ZR_BDC_I0001程序
请登录后发表评论 登录
全部评论

注册时间:2008-10-31

  • 博文量
    52
  • 访问量
    50544