[函数]routing展开-[CP_EX_PLAN_READ]

1, CP_EX_PLAN_READ

可以通过函数 CP_EX_PLAN_READ对PP模块中的routing进行展开。

SE37,展开的结果放在各个Table参数中。

2, 前台操作

前台可以通过tcode:CA03来查看routing的展开

输入物料,工厂,销售订单和行项目后回车,

3, 例子代码

下面这个例子将2中的工厂 8800,物料SMA50620100,销售订单690000090行项目100的对应的routing展开。

简单逻辑:

1,从MAPL中取得routing对应的group和group counter

2,调用函数CP_EX_PLAN_READ展开

其中,

task list type:

status:04是release

Task list usage:

REPORT ztest_explode_routing.

DATA:git_plpo_exp LIKE STANDARD TABLE OF coplpo,
     gwa_plpo_exp LIKE LINE OF git_plpo_exp,
     git_plko_exp LIKE STANDARD TABLE OF plko,
     gwa_plko_exp LIKE LINE OF git_plko_exp,
     git_plmk_exp LIKE STANDARD TABLE OF plmkb,
     gwa_plmk_exp LIKE LINE OF git_plmk_exp,
     git_plmz_exp LIKE STANDARD TABLE OF plmz,
     gwa_plmz_exp LIKE LINE OF git_plmz_exp,
     git_plfh_exp TYPE STANDARD TABLE OF plfh,
     gwa_plfh_exp TYPE plfh,
     git_plas_exp TYPE STANDARD TABLE OF plas,
     gwa_plas_exp TYPE plas.
DATA:g_plnnr TYPE mapl-plnnr, "Group
     g_plnal TYPE mapl-plnal, "Group Counter
     g_vbeln TYPE vbap-vbeln, "Sales Order
     g_posnr TYPE vbap-posnr, "Item
     g_werks TYPE vbap-werks.


* explode material routing
g_vbeln = '0690000090'.
g_posnr = '000100'.
g_werks = '8800'.

SELECT SINGLE mapl~plnnr  "Group
              mapl~plnal  "Group Counter
  FROM mapl
 INNER JOIN plko ON mapl~plnty = plko~plnty
                AND mapl~plnnr = plko~plnnr
                AND mapl~plnal = plko~plnal
                AND mapl~zaehl = plko~zaehl
                AND mapl~werks = plko~werks
  INTO ( g_plnnr, g_plnal )
 WHERE mapl~plnty = 'N'  "Task List Type
   AND mapl~werks = g_werks
   AND mapl~matnr = 'SMA50620100'
   AND mapl~datuv <=  sy-datum
   AND mapl~loekz = ''
   AND mapl~vbeln = g_vbeln "SO copy from
   AND mapl~posnr = g_posnr "Item copy from
   AND plko~loekz = ''
   AND plko~verwe = '1'  "Task list usage
   AND plko~statu = '4'  "release routing
  .

CALL FUNCTION 'CP_EX_PLAN_READ'
  EXPORTING
*   CMODE_IMP     = 'R'
    plnty_imp     = 'N'      "N:routing
    plnnr_imp     = g_plnnr  "Group
    plnal_imp     = g_plnal  "Group Counter
    sttag_imp     = sy-datum
*   CHECK_IMP     = abap_true
*   cuobj_imp     = i_cuobj  "Configuration
*   PARNT_IMP     = ' '
*   FCAPO_IMP     = ' '
*   TCA11_IMP     = ' '
*   FLG_VAL_REC_IMP                      = ' '
*   STLNR_IMP     =
*   I_PLAS_KEY_TAB                       =
*   PRODCOST      = ' '
*   I_BUSINESS_OBJECT                    =
*   I_FLG_CHARACTERISTICS_PLANNING       = ' '
*   I_EDGNO       =
    vbeln_imp     = g_vbeln  "Sales Order
    posnr_imp     = g_posnr  "Item
*   LOSGR_IMP     = 1
    i_plant       = g_werks
*   I_FLG_CALLED_F_MRP                   = ' '
*   IMPORTING
*   RES_APPR_CHK_EXP                     =
*   ERROR_EXP     =
*   E_MAPL        =
*   PI_SET_USED   =
  TABLES
*   MLST_EXP      =
*   PLAB_EXP      =
    plas_exp      = git_plas_exp
    plfh_exp      = git_plfh_exp
*   PLFL_EXP      =
*   PLFT_EXP      =
*   PLFV_EXP      =
    plko_exp      = git_plko_exp
    plmz_exp      = git_plmz_exp
    plpo_exp      = git_plpo_exp
*   PLTX_EXP      =
*   AENNR_EXP     =
    plmk_exp      = git_plmk_exp
*   PLMW_EXP      =
  EXCEPTIONS
    not_found     = 1
    plnal_initial = 2
    OTHERS        = 3.
IF sy-subrc = 0.
  WRITE: 'Routing exploded successfully'.
ENDIF.

4, 测试

运行代码,加断点debug测试,可以发现展开的结果保存在函数返回内表中。

以组件分配(Allocation)为例,组件分配保存在内表git_plmz_exp中,

在CA03中也可以看到组件分配情况,与内表中内容一致。

以上。

posted @ 2019-08-30 10:28  真的是很难  阅读(413)  评论(0编辑  收藏  举报