BDC内循环的一个例子

report Z_CO02_WCDEL
       no standard page heading line-size 255.

include bdcrecx1.

parameters: dataset(132) lower case.
***    DO NOT CHANGE - the generated data section - DO NOT CHANGE    ***
*
*   If it is nessesary to change the data section use the rules:
*   1.) Each definition of a field exists of two lines
*   2.) The first line shows exactly the comment
*       '* data element: ' followed with the data element
*       which describes the field.
*       If you don't have a data element use the
*       comment without a data element name
*   3.) The second line shows the fieldname of the
*       structure, the fieldname must consist of
*       a fieldname and optional the character '_' and
*       three numbers and the field length in brackets
*   4.) Each field must be type C.
*
*** Generated data section with specific formatting - DO NOT CHANGE  ***
data: begin of record_i OCCURS 0,
* data element: AUFNR
        AUFNR_001(012),
* data element: FLG_OVIEW
*        FLG_OVIEW_002(001),
* data element: SPO_VALUE
        VALUE_01_003(132),
* data element: FLG_SEL
*        FLG_SEL_01_004(001),
* data element: VORNR
        VORNR_005(004),
* data element: UVORN
        UVORN_006(004),
* data element: FLG_SEL
*        FLG_SEL_01_007(001),
      end of record_i.

*** End generated data section ***

selection-screen begin of block s_b1 with frame. title text-001.
  parameters:
    p_infile like rlgrap-filename obligatory default 'C:\ZCA01.txt'.
  parameters: p_t as checkbox.
selection-screen end of block s_b1.

*** End generated data section ***
at selection-screen on value-request for p_infile.
  call function 'F4_FILENAME'
    importing
      file_name = p_infile.

start-of-selection.
*  PERFORM. open_dataset USING dataset.
  perform. open_group.
*从文本文件上将计划批量数据读到内表中
  perform. read_bdc_data.
*数据检查
  if p_t = 'X'.
*    PERFORM. CHECK_BDC_DATA.
  else.
*执行批量导入数据
    perform. input_bdc_data.
*  ENDIF.
  endif.
  perform. close_group.

*start-of-selection.
form. read_bdc_data .
  call function 'WS_UPLOAD'
   exporting
*   CODEPAGE                      = ' '
     filename                      = p_infile
     filetype                      = 'DAT'
*   HEADLEN                       = ' '
*   LINE_EXIT                     = ' '
*   TRUNCLEN                      = ' '
*   USER_FORM                     = ' '
*   USER_PROG                     = ' '
*   DAT_D_FORMAT                  = ' '
* IMPORTING
*   FILELENGTH                    =
    tables
      data_tab                      = record_i
   exceptions
*     conversion_error              = 1
     file_open_error               = 2
     file_read_error               = 3
     invalid_type                  = 4
     no_batch                      = 5
     unknown_error                 = 6
     invalid_table_width           = 7
     gui_refuse_filetransfer       = 8
     customer_error                = 9
     no_authority                  = 10
     others                        = 11
            .
  if sy-subrc <> 0.
*    MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
*            WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
    message id sy-msgid type 'I' number sy-msgno
            with sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
    stop.
  endif.

endform.                    " read_bdc_data

*start-of-selection.

*perform. open_dataset using dataset.
*perform. open_group.

*do.

*read dataset dataset into record.
*if sy-subrc <> 0. exit. endif.
form. input_bdc_data.
  data record like table of record_i with header line.

 loop at record_i.
    move-corresponding record_i to record.
 at new AUFNR_001.
perform. bdc_dynpro      using 'SAPLCOKO1' '0110'.
perform. bdc_field       using 'BDC_CURSOR'
                              'CAUFVD-AUFNR'.
perform. bdc_field       using 'BDC_OKCODE'
                              '=FLGU'.
perform. bdc_field       using 'CAUFVD-AUFNR'
                              record-AUFNR_001.
endat.

perform. bdc_dynpro      using 'SAPLCOVG' '0200'.
perform. bdc_field       using 'BDC_OKCODE'
                              '=AUFS'.
perform. bdc_field       using 'BDC_CURSOR'
                              'PSFC_DISP-AUFNR'.

at NEW VALUE_01_003.
perform. bdc_dynpro      using 'SAPLSPO4' '0300'.
perform. bdc_field       using 'BDC_CURSOR'
                              'SVALD-VALUE(01)'.
perform. bdc_field       using 'BDC_OKCODE'
                              '=FURT'.
perform. bdc_field       using 'SVALD-VALUE(01)'
                              record-VALUE_01_003.
perform. bdc_dynpro      using 'SAPLCOVG' '0200'.
perform. bdc_field       using 'BDC_CURSOR'
                              'AFFLD-PLNFL(01)'.
perform. bdc_field       using 'BDC_OKCODE'
                              '=VGUE'.
perform. bdc_field       using 'RC27X-FLG_SEL(01)'
                              'X'.
endat.

perform. bdc_dynpro      using 'SAPLCOVG' '0100'.
perform. bdc_field       using 'BDC_OKCODE'
                              '=AUFS'.
perform. bdc_field       using 'BDC_CURSOR'
                              'PSFC_DISP-AUFNR'.
perform. bdc_dynpro      using 'SAPLCO05' '0100'.
perform. bdc_field       using 'BDC_CURSOR'
                              'RCOSU-UVORN'.
perform. bdc_field       using 'BDC_OKCODE'
                              '=MORE'.
perform. bdc_field       using 'RCOSU-VORNR'
                              record-VORNR_005.
perform. bdc_field       using 'RCOSU-UVORN'
                              record-UVORN_006.
perform. bdc_dynpro      using 'SAPLCOVG' '0100'.
perform. bdc_field       using 'BDC_CURSOR'
                              'AFVGD-VORNR(01)'.
perform. bdc_field       using 'BDC_OKCODE'
                              '=LOE'.
perform. bdc_field       using 'RC27X-FLG_SEL(01)'
                              'X'.
perform. bdc_dynpro      using 'SAPLSPO2' '0200'.
perform. bdc_field       using 'BDC_OKCODE'
                              '=OPT1'.
at end of AUFNR_001.
perform. bdc_dynpro      using 'SAPLCOVG' '0100'.
perform. bdc_field       using 'BDC_OKCODE'
                              '=BU'.
perform. bdc_transaction using 'CO02'.
endat.
endloop.

ENDFORM.

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

转载于:http://blog.itpub.net/16762150/viewspace-711757/

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值