CO02 BDC:Update BOM Component Explosion type

6 篇文章 0 订阅




*----------------------------------------------------------------------*
*        Start new screen                                              *
*----------------------------------------------------------------------*
form bdc_dynpro using program dynpro.
  clear bdcdata.
  bdcdata-program  program.
  bdcdata-dynpro   dynpro.
  bdcdata-dynbegin 'X'.
  append bdcdata.
endform.                    "BDC_DYNPRO

*----------------------------------------------------------------------*
*        Insert field                                                  *
*----------------------------------------------------------------------*
form bdc_field using fnam fval.
  clear bdcdata.
  bdcdata-fnam fnam.
  bdcdata-fval fval.
  append bdcdata.
endform.                    "BDC_FIELD
*&--------------------------------------------
*&---------------------------------------------------------------------*
*&      Form  WRITE_LOG
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
*  -->  p1        text
*  <--  p2        text
*----------------------------------------------------------------------*
form write_log .
  if not it_log[] is initial.
    modify zpp031 from table it_log.
    refresh it_log.
    free:it_matnr,it_log,itab,it_matnr1,it_100,it_no100,it_mara.
  endif.
endform.                    " WRITE_LOG
*&---------------------------------------------------------------------*
*&      Form  GET_USED_MATERIAL
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
*      -->P_IT_MATNR_IDNRK  text
*      -->P_IT_MATNR_WERKS  text
*      <--P_LTB  text
*----------------------------------------------------------------------*
form get_used_material  using    p_matnr
                                 p_erks
                        changing p_subrc .
  data:pm_datub like stpo-datuv,
         pm_datuv like stpo-datuv,
         pm_postp like stpo-postp,
         pm_stlan like stzu-stlan ,
         pm_idnrk like stpo-idnrk,                          "YHG078090
         pm_werks like marc-werks .
  data: begin of selpool.
          include structure mc29s.
  data: end of selpool.
*  data: begin of ltb occurs 0.
*          include structure stpov.
*  data: end of ltb.
  data: begin of equicat  occurs 0.
          include structure cscequi.
  data: end of equicat .
  data: begin of kndcat   occurs 0.
          include structure cscknd.
  data: end of kndcat  .
  data: begin of matcat   occurs 0.
          include structure cscmat.
  data: end of matcat  .

  data: begin of stdcat   occurs 0.
          include structure cscstd.
  data: end of stdcat  .
  data: begin of tplcat   occurs 0.
          include structure csctpl.
  data: end of tplcat  .

  pm_datuv  sy-datum.
  pm_idnrk p_matnr.
  pm_werks  p_erks.

  call function 'CS_WHERE_USED_MAT_ANY'
    exporting
      datub                      pm_datub
      datuv                      pm_datuv
      matnr                      pm_idnrk
      postp                      pm_postp
      stlan                      pm_stlan
      werks                      pm_werks
    importing
      topmat                     selpool
    tables
      wultb                      ltb
      equicat                    equicat
      kndcat                     kndcat
      matcat                     matcat
      stdcat                     stdcat
      tplcat                     tplcat
    exceptions
      call_invalid               1
      material_not_found         2
      no_where_used_rec_found    3
      no_where_used_rec_selected 4
      no_where_used_rec_valid    5
      others                     6.
  p_subrc sy-subrc.
endform.                    " GET_USED_MATERIAL
*&---------------------------------------------------------------------*
*&      Form  PROCESS_DATA
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
*  -->  p1        text
*  <--  p2        text
*----------------------------------------------------------------------*
form process_data_bdc .
  data:lv_dat(10type c.
  describe table itab lines lv_total_line.
  loop at itab.
    lv_line =  sy-tabix  / lv_total_line * 100.
    call function 'SAPGUI_PROGRESS_INDICATOR'
      exporting
        percentage lv_line
        text       'Changing BOM........'.
    it_log-bldat sy-datum.
    it_log-aezet sy-uzeit.
    it_log-werks itab-werks.
    it_log-matnr itab-matnr.
    it_log-idnrk itab-idnrk.
    it_log-dspst_old itab-dspst.
    it_log-dspst_new itab-dspst_new.
    it_log-posnr itab-posnr.
    it_log-stlnr itab-stlnr.
    it_log-stlty itab-stlty.
    it_log-stlan itab-stlan.
    it_log-datuv itab-datuv.

    perform bdc_dynpro      using 'SAPLCSDI' '0100'.
    perform bdc_field       using 'BDC_CURSOR' 'RC29N-STLAN'.
    perform bdc_field       using 'BDC_OKCODE' '/00'.
    perform bdc_field       using 'RC29N-MATNR' it_log-matnr.
    perform bdc_field       using 'RC29N-WERKS' it_log-werks.
    perform bdc_field       using 'RC29N-STLAN' it_log-stlan.
    perform bdc_field       using 'RC29N-STLAL'  '01'. "PRD default '01' no '02' '03'
    perform change_date_format using sy-datum changing lv_dat.  "itab-datuv
    perform bdc_field       using 'RC29N-DATUV'
                                  lv_dat.

    perform bdc_dynpro      using 'SAPLCSDI' '0150'.
    perform bdc_field       using 'BDC_CURSOR' 'RC29P-POSNR(01)'.
    perform bdc_field       using 'BDC_OKCODE' '=SETP'.


    perform bdc_dynpro      using 'SAPLCSDI' '0708'.
    perform bdc_field       using 'BDC_OKCODE' '=CLWI'.
    perform bdc_field       using 'BDC_CURSOR' 'RC29P-SELID'.
    perform bdc_field       using 'RC29P-SELID' it_log-idnrk.
    perform bdc_field       using 'RC29P-SELPO' it_log-posnr.


    perform bdc_dynpro      using 'SAPLCSDI' '0150'.
    perform bdc_field       using 'BDC_CURSOR'   'RC29P-AUSKZ(01)'.
    perform bdc_field       using 'BDC_OKCODE' '=PALL'.
    perform bdc_field       using 'RC29P-AUSKZ(01)' 'X'.



    perform bdc_dynpro      using 'SAPLCSDI' '2130'.
    perform bdc_field       using 'BDC_OKCODE' '=FCBU'.
    perform bdc_field       using 'BDC_CURSOR'  'RC29P-DSPST'.
*    perform bdc_field       using 'RC29P-POSNR'
*                                  record-posnr_007.
*    perform bdc_field       using 'RC29P-IDNRK'
*                                  record-idnrk_008.
*    perform bdc_field       using 'RC29P-MENGE'
*                                  record-menge_009.
*    perform bdc_field       using 'RC29P-MEINS'
*                                  record-meins_010.
    perform bdc_field       using 'RC29P-DSPST' it_log-dspst_new.

    call transaction 'CS02'
             using bdcdata
             mode pr_mode "Background performance
             update 'S' "local updata
             messages into it_bdcmsg. "all message table

    call function 'CONVERT_BDCMSGCOLL_TO_BAPIRET2'
      tables
        imt_bdcmsgcoll it_bdcmsg
        ext_return     it_return.

    read table it_return with key type 'E'.
    if sy-subrc eq 0.
      it_log-msgds it_return-message.
    else.
      read table it_return with key type 'S' id '29' number '031'.
      if sy-subrc eq 0.
        it_log-msgds  =  'OK'.
      else.
        loop at  it_return.
          if it_log-msgds  is initial.
            it_log-msgds =  it_return-message .
          else.
            concatenate it_log-msgds  it_return-message into it_log-msgds  separated by space.
          endif.
        endloop.
      endif.
    endif.
    append it_log.
    clear:it_log.
  endloop.
endform.                    " PROCESS_DATA
*&---------------------------------------------------------------------*
*&      Form  DISPLAY_DATA
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
*  -->  p1        text
*  <--  p2        text
*----------------------------------------------------------------------*
form display_data .
  define alv_field.
    clear:wa_hier.
    wa_hier-fieldname &1.
    wa_hier-seltext_m &2.
    wa_hier-seltext_l &3.
    wa_hier-outputlen &4.
    wa_hier-just &5.
    wa_hier-do_sum &6.
    wa_hier-ref_tabname &7 .
    wa_hier-ref_fieldname &8 .
    append wa_hier to fc_hier.
  end-of-definition.
  refresh: fc_hier.
  alv_field  'WERKS' 'Plant' '' '5' 'L' '' '' ''.
  alv_field  'MTART' '' 'Material Type' '10' 'L' '' '' ''.
  alv_field  'MATNR' '' 'Material' '18' 'L' '' 'MARA' 'MATNR'.
  alv_field  'STLAN' '' 'BOM Usage' '6' 'L' '' '' ''.
  alv_field  'IDNRK' '' 'Component' '18' 'L' '' 'MARA' 'MATNR'.
  alv_field  'GP_MATNR' '' 'Logic Group' '40' 'L' '' '' ''.
  alv_field  'DSPST' '' 'Old Explosion type' '15' 'L' ''  '' ''.
  alv_field  'DSPST_NEW' '' 'New Explosion type' '15' 'L' ''  '' ''.

  free:it_matnr,it_matnr1,it_100,it_no100,it_mara.

  call function 'REUSE_ALV_GRID_DISPLAY'
    exporting
      it_fieldcat        fc_hier[]
      i_save             'A'
      i_callback_program sy-repid
    tables
      t_outtab           itab[]
    exceptions
      program_error      1
      others             2.

endform.                    " DISPLAY_DATA

 

*&      Form  CHANGE_DATE_FORMAT
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
*      -->P_<GT_OUT>_DATUV  text
*      <--P_LV_DAT  text
*      <--P_PERFORM  text
*      <--P_BDC_FIELD  text
*      -->P_0208   text
*      -->P_<GT_OUT>_DATUV  text
*----------------------------------------------------------------------*
form change_date_format  using pi_date changing pt_date.
  call function 'CONVERT_DATE_TO_EXTERNAL'
    exporting
      date_internal            pi_date
    importing
      date_external            pt_date
    exceptions
      date_internal_is_invalid 1
      others                   2.
  if sy-subrc <> 0.
    message 'Date Format Error' type 'E'.
  endif.
endform.                    " CHANGE_DATE_FORMAT

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值