ZSDR006: Approve SO VA02

47 篇文章 0 订阅
6 篇文章 0 订阅
*&---------------------------------------------------------------------*
*& Progarm      :  ZSDR004                        Author : Jimmy Wong
*& Created      :  17 OCT 2012                    App    : SD
*& Title        :  Upload Forecast
*& Description  :  Upload Forecast
*&---------------------------------------------------------------------*
*&  Version       Author      Date        description
*&                Jimmy       17 Sep 2012 the first version
*&  the last update time  2012.09.17 17:00
*&---------------------------------------------------------------------*
report  zsdr006 no standard page heading.
tables:vbak.
data:begin of itab occurs 10,
     vbeln    like vbak-vbeln,
     message  type length 700,
    end of itab.
data:lv_tabix like sy-tabix.

data: it_bdcmsg like bdcmsgcoll occurs with header line,
      bdcdata like bdcdata occurs with header line,
      pr_mode  type ctu_mode .
type-pools: slis.
data: fc_hier type slis_t_fieldcat_alv,
      wa_hier type slis_fieldcat_alv .
*&---------------------------------------------------------------------*
* parameter & select-options
*&---------------------------------------------------------------------*
selection-screen begin of block with frame title text-010.
select-options: s_vbeln for vbak-vbeln. "default '01*'.  "custmer p/n"
selection-screen end of block 1.

initialization.
  s_vbeln-sign 'I'.
  s_vbeln-option 'CP'.
  s_vbeln-low '01*'.
  append s_vbeln.

*&---------------------------------------------------------------------*
* start of process
*&---------------------------------------------------------------------*
start-of-selection.
  perform get_data.
  perform process_data.
  perform dispaly_data.
*&---------------------------------------------------------------------*
*&      Form  GET_DATA
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
*  -->  p1        text
*  <--  p2        text
*----------------------------------------------------------------------*
form get_data .
  select  vbeln
      into corresponding fields of table itab
      from vbak
      where vbeln in s_vbeln.
endform.                    " GET_DATA
*&---------------------------------------------------------------------*
*&      Form  PROCESS_DATA
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
*  -->  p1        text
*  <--  p2        text
*----------------------------------------------------------------------*
form process_data .
  pr_mode 'N'.
  loop at itab.
    clear:it_bdcmsg,it_bdcmsg[], bdcdata, bdcdata[].
*        check sy-tabix <= 10.
    lv_tabix sy-tabix.
    perform bdc_dynpro      using 'SAPMV45A' '0102'.
    perform bdc_field       using 'BDC_CURSOR'
                                  'VBAK-VBELN'.
    perform bdc_field       using 'BDC_OKCODE'
                                  '=SUCH'.
    perform bdc_field       using 'VBAK-VBELN'
                                  itab-vbeln.

    perform bdc_dynpro      using 'SAPMV45A' '4001'.
    perform bdc_field       using 'BDC_OKCODE'
                                  '=KSTA'.

    perform bdc_field       using 'BDC_CURSOR'
                                  'RV45A-MABNR(01)'.
    perform bdc_dynpro      using 'SAPMV45A' '4002'.
    perform bdc_field       using 'BDC_OKCODE'
                                  '=KSTC'.
    perform bdc_field       using 'BDC_CURSOR'
                                  'VBAK-VBELN'.
    perform bdc_dynpro      using 'SAPLBSVA' '0300'.
    perform bdc_field       using 'BDC_OKCODE'
                                  '=BACK'.
    perform bdc_field       using 'BDC_CURSOR'
                                  'J_STMAINT-ANWS(02)'.
    perform bdc_field       using 'J_STMAINT-ANWS(02)'
                                  'X'.
    perform bdc_dynpro      using 'SAPMV45A' '4002'.
    perform bdc_field       using 'BDC_OKCODE'
                                  '=SICH'.
    perform bdc_field       using 'BDC_CURSOR'
                                  'VBAK-VBELN'.

    call transaction 'VA02'
                using bdcdata
                mode pr_mode "Background performance
                update 'S' "local updata
                messages into it_bdcmsg. "all message table
    read table it_bdcmsg with key msgtyp 'E'.
    if sy-subrc ne 0.
      itab-message  it_bdcmsg-msgv1.
      modify itab index lv_tabix.
    endif.

  endloop.
endform.                    " PROCESS_DATA
*----------------------------------------------------------------------*
*        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  DISPALY_DATA
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
*  -->  p1        text
*  <--  p2        text
*----------------------------------------------------------------------*
form dispaly_data .
  refresh fc_hier.
  define alv_field.
    clear:wa_hier.
    wa_hier-col_pos &1.
    wa_hier-fieldname &2.
    wa_hier-seltext_m &3.
    wa_hier-seltext_l &4.
    wa_hier-outputlen &5.
    append wa_hier to fc_hier.
  end-of-definition.
  alv_field '1' 'VBELN' '' 'SO No.' ''.
  alv_field '2' 'MESSAGE' 'Message' '' '50'.

  call function 'REUSE_ALV_GRID_DISPLAY'
    exporting
      it_fieldcat   fc_hier[]
    tables
      t_outtab      itab[]
    exceptions
      program_error 1
      others        2.
  if sy-subrc ne 0.
    "     message i004(zmm)
  endif.

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值