Deletion of subcontracting BOM in Purchase Requisition

In previous post I've shown how to re-explode subcontracting components of purchase requisition using FM  ME_COMPONENTS_MAINTAIN and  ME_COMPONENTS_UPDATE_PREPARE . Using very similar code you can delete completly it's BOM. 
 
You may wonder why would need to delete subcontracting BOM? This is not possible in standard transaction ME52N and in most cases it makes no sense to have the subcontracting item without BOM. But in the case that you don't want that components are taken into consideration by MRP until you really need this then it could be helpful.
 
The code is 99% same like during the re-exploding the BOM, the difference is that FM  ME_COMPONENTS_MAINTAIN is called with parameter  i_vorga = ' D'  and message check at the end is bit different.
 
 

report zabdelprbom.


parametersp_banfn type eban-banfn,
                        p_bnfpo type eban-bnfpo default '00010'.


class lcl_subcontracting definition.
  public section.
    class-methodsdelete_pr_bom importing value(i_requsition)    type eban-banfn
                                      value(i_position)      type eban-bnfpo
                                      value(i_show_messagestype abap_bool default abap_false
                            returning value(r_deleted)   type abap_bool.

endclass.


start-of-selection.
  lcl_subcontracting=>delete_pr_bom(
      i_requsition    p_banfn
      i_position      p_bnfpo
      i_show_messages abap_true  ).

class lcl_subcontracting implementation.
  methoddelete_pr_bom.

    cl_message_handler_mm=>get_handler(  importing
                                         ex_handler data(message_handler).
    message_handler->co_handler_start).
    message_handler->set_config_for_bapi).

    call function 'ME_COMPONENTS_REFRESH'.
    dataebkn     type                   ebkn,
          eban     type                   eban,
          mdpa     type                   mdpa,
          mdlb     type                   mdlb,
          mdlb_tab type standard table of mdlb.

    select single into corresponding fields of eban
     from eban
           where  banfn  eq i_requsition
           and    bnfpo  eq i_position.
    select single from  ebkn into ebkn
            where  banfn  eq i_requsition
            and    bnfpo  eq i_position.

    call function 'ME_FILL_MDPA_FROM_EBAN'
      exporting
        im_eban eban
        im_ebkn ebkn
      importing
        ex_mdpa mdpa.

    call function 'ME_COMPONENTS_MAINTAIN'
      exporting
        i_ebeln    eban-banfn
        i_ebelp    eban-bnfpo
        i_fcall    abap_true
        i_mdpa     mdpa
        i_mdpa_old mdpa
        i_txz01    eban-txz01
        i_vorga    'D'.

    call function 'ME_FILL_MDLB_FROM_EBAN'
      exporting
        im_eban eban
        im_ebkn ebkn
      importing
        ex_mdlb mdlb.
    append mdlb to mdlb_tab.

    call function 'ME_COMPONENTS_UPDATE_PREPARE'
      exporting
        i_number eban-banfn
      tables
        t_mdlb   mdlb_tab.

    message_handler->co_handler_stop).
    data(messagesmessage_handler->get_list_for_bapi).
    if not line_existsmessages[ msgty 'E' ).
      r_deleted abap_true.
      commit work.
    endif.
    if i_show_messages eq abap_true.
      message_handler->showim_amodal abap_true ).
    endif.
  endmethod.

endclass.

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

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

ChampaignWolf

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值