SAP QM QP01 QP02 检验计划创建以及扩展 BAPI :BAPI_INSPECTIONPLAN_CREATE

调用BAPI: BAPI_INSPECTIONPLAN_CREATE
背景:需要根据系统已有的检验计划去单独扩展不同工厂的检验计划;能通过Excel表格进行批量创建,并且可以在选择屏幕输入想要扩张的工厂。
难点:根据扩展的工厂生成新的检验计划组,并且保证组计数器的自增,另外需要注意单独扩展其他工厂的检验计划时,要先从系统中取到同检验计划的最后一个组计数器,而批量导入也需要根据扩展的工厂计算表格中的检验计划组的组计数器。
单独扩展:
新增及扩展按钮:
执行结果:
仅供参考:
*-------------------------------------------------------------处理组计数器-----------------------------------------------------------------------
  data: lv_index type i,
        lv_plnnr type plnnr,
        lv_count type i.
  data: lv_conut_row type i.
  data: lalv_plnal type n length 2,
        lalv_plna2 type n length 2.


  if p_cb1 = 'X'.
    perform frm_merge_plan tables s_wer. "汇总扩展工厂
  else.
    perform frm_merge_plan tables s_plan.
  endif.

  perform frm_expa_inspection. "处理组计数器问题 获取已存在的检验计划的最后一个计数器编号

  move-corresponding gt_upload_1[] to gt_upload_temp[].
  sort gt_upload_temp by plnnr ascending plnal descending .
  delete adjacent duplicates from gt_upload_temp comparing plnnr.
  sort gt_plan by plnnr.


  loop at gt_plan.
    lv_count = sy-tabix.
    if p_cb1 <> 'X'."针对已存在数据的扩展.
      if lv_count = 1.
        lv_plnnr = gt_plan-plnnr.
      else.
        if gt_plan-plnnr <> lv_plnnr.
          clear: lv_index,lalv_plnal.
          lv_plnnr = gt_plan-plnnr.
        else.
          lv_index = 1.
        endif.
      endif.
    else.
      if lv_count = 1.
        lv_index = 1.
        lv_plnnr = gt_plan-plnnr.
        read table gt_inspection with key plnnr = gt_plan-plnnr.
        if sy-subrc = 0.
          lalv_plnal = gt_inspection-plnal + 1.
        endif.
      else.
        if gt_plan-plnnr <> lv_plnnr.
          clear: lv_index,lalv_plnal.
          lv_plnnr = gt_plan-plnnr.
        endif.
      endif.
    endif.


    loop at gt_upload_1 where plnnr = gt_plan-plnnr.
      gt_alv-row = sy-tabix.
      move-corresponding gt_upload_1 to gt_alv.


      gt_alv-zplan = gt_alv-werks. "原检验计划工厂
      gt_alv-werks = gt_plan-werks. "扩展工厂


      read table gt_upload_c with key plnnr = gt_alv-plnnr plnal = gt_alv-plnal.
      if sy-subrc = 0.
        gt_alv-lifnr = gt_upload_c-lifnr.
        gt_alv-matnr = gt_upload_c-matnr.
      endif.


      gt_alv-plnal_f = gt_alv-plnal."原计划组计数器
      if gt_alv-plnal_f <> ''. "组计数器 补零  自增+1
        unpack gt_alv-plnal_f to gt_alv-plnal_f.
      endif.


      if lalv_plnal is not initial.
        gt_alv-plnal = lalv_plnal.
      endif.

      if gt_alv-plnal <> ''. "组计数器 补零  自增+1
        unpack gt_alv-plnal to gt_alv-plnal.
      endif.

      if not gt_alv-verwmerkm is initial."主检验特性 补零
        unpack gt_alv-verwmerkm to gt_alv-verwmerkm.
      endif.

      if gt_alv-arbpl is not initial.
        select single arbpl into gt_alv-arbpl from crhd where objid = gt_alv-arbpl.
      endif.

      if gt_alv-plnme is not initial.
        read table gt_t006a with key msehi = gt_alv-plnme spras = sy-langu.
        if sy-subrc = 0.
          gt_alv-plnme = gt_t006a-mseh3.
        endif.
      endif.

      if gt_alv-probemgeh is not initial.
        read table gt_t006a with key msehi = gt_alv-probemgeh spras = sy-langu.
        if sy-subrc = 0.
          gt_alv-probemgeh = gt_t006a-mseh3.
        endif.
      endif.

      gt_alv-datub = '99991231'.

      "获取字段“标准要求”
      if p_cb1 = 'X'.
        perform frm_get_text changing gt_alv.
      endif.
      "检查数据
      perform frm_che_data changing gt_alv.
      perform frm_set_color changing gt_
评论 3
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

打赏作者

花鸟風月

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

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

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

打赏作者

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

抵扣说明:

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

余额充值