ITPub博客

首页 > Linux操作系统 > Linux操作系统 > VL01N BDC

VL01N BDC

原创 Linux操作系统 作者:ytfsrs2008 时间:2010-05-06 13:29:51 0 删除 编辑
data: begin of line,
        vbeln like vbak-vbeln,
        posnr like vbap-posnr,
        dn_posnr like lips-posnr,
        matnr like vbap-matnr,
        kwmeng like vbap-kwmeng,
        c_kwmeng(10),
        vstel like vbap-vstel,  "shipping point
      end of line. 
data: itab like table of line with header line.
data: cursor_tmp(20),
        tmp(2),
        l_vbeln like vbak-vbeln,
        l_error type c.
data: messtab like bdcmsgcoll occurs 0 with header line.
data: bdcdata like bdcdata    occurs 0 with header line.
  clear line.
  clear messtab.
  refresh messtab.
  clear itab.refresh itab.
    select single vbeln_ds into l_vbeln
    from zmm015
    where vbeln_hft = so.
    if sy-subrc = 0 .
      select posnr matnr lfimg into
         (line-dn_posnr, line-matnr, line-kwmeng)
      from lips
      where vbeln = dn.
        select single vbeln posnr vstel
         into (line-vbeln, line-posnr, line-vstel)
          from vbap
          where vbeln = l_vbeln and
                matnr = line-matnr.
        line-c_kwmeng = line-kwmeng.
          line-vstel = 'PAAD'.
        append line to itab.
      endselect.

  sort itab by dn_posnr vbeln posnr matnr.
  clear count.
  describe table itab lines count.
  if l_error <> 'E' or count > 0 .
    read table itab index 1.
    if p_type = 'H'.
      tempdn = dn.
    else.
      tempdn = ''.
    endif.
    perform. bdc_dynpro      using 'SAPMV50A' '4001'.
    perform. bdc_field       using 'BDC_CURSOR'
                                  'LV50C-BIPOS'.
    perform. bdc_field       using 'BDC_OKCODE'
                                  '/00'.
    perform. bdc_field       using 'LIKP-VSTEL'
                                  itab-vstel.
    perform. bdc_field       using 'LV50C-DATBI'
                                  '12/31/9999'.
    perform. bdc_field       using 'LV50C-VBELN'
                                  itab-vbeln.
    perform. bdc_dynpro      using 'SAPMV50A' '1000'.
    perform. bdc_field       using 'BDC_OKCODE'
                                  '=HADM_T'.
    perform. bdc_dynpro      using 'SAPMV50A' '2000'.
    perform. bdc_field       using 'BDC_OKCODE'
                                  '=SICH_T'.
    perform. bdc_field       using 'BDC_CURSOR'
                                  'LIKP-LIFEX'.
    perform. bdc_field       using 'LIKP-LIFEX'
                                  tempdn.
    perform. bdc_transaction tables messtab
                            using 'VL01N'
                                  'X'
                                  mode
                                  'L'.
    loop at messtab where msgnr = '311'.
      if p_type = 'D' .
         *dn_ds = messtab-msgv2.
      elseif p_type = 'H' .
         *dn_hh = messtab-msgv2.
      endif.
      exit.
    endloop.
    loop at messtab .
      it_result-msg = messtab-msgv1.
      append it_result.
      it_result-msg = messtab-msgv2.
      append it_result.
      it_result-msg = messtab-msgv3.
      append it_result.
      it_result-msg = messtab-msgv4.
      append it_result.
    endloop.

    if sy-subrc <> 0.
      exit.
    endif.
  endif.

*&--------------------------------------------------------------------*
*&      Form  BDC_TRANSACTION
*&--------------------------------------------------------------------*
form. bdc_transaction tables p_messtab
                     using  p_tcode
                            p_ctu
                            p_mode
                            p_update.
  data: l_subrc like sy-subrc.
  if p_ctu <> 'X'.
    call function 'BDC_INSERT'
         exporting
              tcode     = p_tcode
         tables
              dynprotab = bdcdata
         exceptions
              others    = 1.
  else.
    call transaction p_tcode using bdcdata
                     mode   p_mode
                     update p_update
                     messages into p_messtab.
  endif.
  l_subrc = sy-subrc.
  refresh bdcdata.
  sy-subrc = l_subrc.
endform.                    "BDC_TRANSACTION

来自 “ ITPUB博客 ” ,链接:http://blog.itpub.net/15117617/viewspace-662034/,如需转载,请注明出处,否则将追究法律责任。

上一篇: BAPI_GOODSMVT_CREATE
下一篇: BAPI_PO_CREATE
请登录后发表评论 登录
全部评论

注册时间:2008-10-31

  • 博文量
    52
  • 访问量
    49839