ITPub博客

首页 > Linux操作系统 > Linux操作系统 > BDC内循环的一个例子

BDC内循环的一个例子

原创 Linux操作系统 作者:tomato_plp 时间:2011-11-22 13:58:51 0 删除 编辑

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/,如需转载,请注明出处,否则将追究法律责任。

下一篇: 没有了~
请登录后发表评论 登录
全部评论

注册时间:2011-07-11

  • 博文量
    23
  • 访问量
    33707