研究、分享我学习零售业SAP的历程
------------打造中国第一个零售SAP博客

三个SAP标准的FM
1. BAPI_MATERIAL_AVAILABILITY  获得商品可用库存

2. CO_ZA_AVAILABILITY_CHECK 

3.AVAILABILITY_CHECK_CONTROLLER   

4.AVAILABILITY_CHECK   获得可用库存和总库存

DEMO:以下参数的值是我一个个试的,如果想知道为什么,请看源程序。
  
      wa_ATPCS-MATNR = wa_marc-matnr.
      wa_ATPCS-WERKS = wa_marc-werks.
      wa_ATPCS-PRREG = 'BO'.              "ATP type
      wa_ATPCS-BDTER = SY-DATUM.           "availability date
      wa_ATPCS-XLINE = '1'.           "
      wa_ATPCS-IDXATP = '1'.
      wa_ATPCS-RESMD = 'X'.
      wa_ATPCS-CHKFLG = 'X'.
      wa_ATPCA-ANWDG = '8'.
      APPEND wa_ATPCS TO it_ATPCS.
      CALL FUNCTION 'AVAILABILITY_CHECK'
*       EXPORTING
*         P_SCHEDSH           =
*         P_SCHEDTR           =
        TABLES
*         P_ATPALLX           =
*         P_ATPASSRESX        =
*         P_ATPASSX           =
          p_atpcsx            = it_ATPCS
*         P_ATPCSX_R3         =
          P_ATPDSX            = it_ATPDS
*         P_ATPFIELDX         =
*         P_ATPMATX           =
*         P_ATPMATX_R3        =
*         P_ATPPLANTX         =
*         P_ATPREX            =
*         P_ATPSDUX           =
*         P_ATPSOPX           =
*         P_ATPSSPX           =
*         P_ATPTERMX          =
*         P_ATPREQTERMX       =
*         P_MDVEX             =
*         P_MDVEX_R3          =
*         P_MDVEX_APO         =
*         P_QTDERGX           =
*         P_QTDOBJX           =
*         P_QTDQTYX           =
*         P_T441VX            =
*         P_TMVFX             =
*         P_ATPDIAX           =
*         P_ATPDIAWX          =
*         P_QUOT_CHX          =
*         P_QUOT_VBX          =
       CHANGING
          P_ATPCA             = wa_ATPCA
*         P_ATPCB             =
*         P_ATPCC             =
         EXCEPTIONS
            ERROR               = 1
            OTHERS              = 2
                .
      IF sy-subrc = 0.
          SORT it_ATPDS.
          READ TABLE it_ATPDS INTO wa_ATPDS WITH KEY DELKZ = 'WB' BINARY SEARCH. "wb stock
          IF sy-subrc = 0.
             wa_ArticleStock-TOTALQTY = wa_ATPDS-QTY_O. "total qty
             wa_ArticleStock-VALIDQTY = wa_ATPDS-QTY.   "val qty
          ENDIF.
      ENDIF.

posted on 2008-03-05 09:45  会东  阅读(2885)  评论(0编辑  收藏  举报