计算寄售料(客户)期末库存函数

计算寄售料(客户)期末库存函数 [转贴 2007-08-24 16:26:37]    

   计算寄售料在任意期间内的库存(非限制+质检中)
    用到的透明表:MSKU、MSKUH
    寄售料和其他性质物料有些许区别,属工厂级别下的财产,其库存统计对应到的最小单位为工厂,非仓储地点。
    其具体函数实现如下:
 

FUNCTION Z_GET_PERIOD_WSTOCK_3.

*"----------------------------------------------------------------------

*"*"Local interface:

*"  IMPORTING

*"     REFERENCE(MATNR) LIKE  MSKU-MATNR "物料编号

*"     REFERENCE(WERKS) LIKE  MSKU-WERKS "工厂

*"     REFERENCE(KUNNR) LIKE  MSKU-KUNNR "购货方编号

*"     REFERENCE(LFGJA) LIKE  MSKU-LFGJA "会计年度

*"     REFERENCE(LFMON) LIKE  MSKU-LFMON "会计期间

*"  EXPORTING

*"     REFERENCE(CURR_STOCK) LIKE  MSKU-KULAB "期末库存

*"----------------------------------------------------------------------

  data: cyear(4),cmonth(2),currmonth(6),mskUmonth(6).

  data: h_tab like mskUH occurs 0 with header line.

  TABLES: MSKU.

  cyear = lfgja. cmonth = lfmon.

  concatenate cyear cmonth into currmonth.

*----------------------------------------------------------------

  select single * INTO MSKU from MSKU where KUNNR = KUNNR AND matnr =

matnr and werks = werks.

  if sy-subrc = 0.

    cyear = mskU-lfgja. cmonth = mskU-lfmon.

    concatenate cyear cmonth into mskUmonth.

    if mskUmonth > currmonth.

*-----本期期末库存已经存入MSKUH

      select * into table h_tab

          from mskUh where KUNNR = KUNNR

          AND matnr = matnr

          and werks  = werks

          and ( ( lfgja = lfgja and

          lfmon >= lfmon ) or lfgja > lfgja )

          order by lfgja ascending lfmon ascending .

      if sy-subrc = 0.

        loop at h_tab.

          cyear = h_tab-lfgja. cmonth = h_tab-lfmon.

          concatenate cyear cmonth into mskUmonth.

          if mskUmonth >= currmonth.

            CURR_STOCK = h_tab-KULAB + h_tab-KUINS.

            exit.

          endif.

        endloop.

      endif.

    else.

*-----本期期末库存还未存入MSKUH

      CURR_STOCK = mskU-KULAB + mskU-KUINS.

    endif.

  endif.

ENDFUNCTION.
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值