小练习BDC

关于物料创建的BDC.

 

 

report zxxx       no standard page heading line-size 255.

include bdcrecx1.
TABLESsscrfields.

TYPES:BEGIN OF wa,
  matnr TYPE mara-matnr,"物料
  mbrsh LIKE mara-mbrsh,  "行业领域
  mtart LIKE mara-mtart,  "物料类型
  maktx LIKE makt-maktx,  "物料描
  meins LIKE mara-meins,  "单位
  matkl TYPE mara-matkl,
  END OF wa.

DATA:itab TYPE TABLE OF wa WITH HEADER LINE.

DATAfunctxt TYPE smp_dyntxt.

selection-screenfunction key 1.

selection-screen begin of block b2 with frame title text-002.
parametersp_file type string." default 'D:\Reward_record.xlsx'.
selection-screen end of block b2.


at selection-screen on value-request for p_file.

  CALL FUNCTION 'GUI_FILE_LOAD_DIALOG'
    EXPORTING
      window_title      '打开文件'
      default_extension ''
      initial_directory 'D:\'
    IMPORTING
      fullpath          p_file.


START-OF-SELECTION.

  PERFORM open_data.

start-of-selection.

*perform open_dataset using dataset.
  perform open_group.

  LOOP AT itab.

    perform bdc_dynpro      using 'SAPLMGMM' '0060'.
    perform bdc_field       using 'BDC_CURSOR'
                                  'RMMG1-MTART'.
    perform bdc_field       using 'BDC_OKCODE'
                                  '=AUSW'.
    perform bdc_field       using 'RMMG1-MATNR'
                                  ITAB-MATNR.
    perform bdc_field       using 'RMMG1-MBRSH'
                                  ITAB-MBRSH.
    perform bdc_field       using 'RMMG1-MTART'
                                  ITAB-MTART.
    perform bdc_dynpro      using 'SAPLMGMM' '0070'.
    perform bdc_field       using 'BDC_CURSOR'
                                  'MSICHTAUSW-DYTXT(01)'.
    perform bdc_field       using 'BDC_OKCODE'
                                  '=ENTR'.
    perform bdc_field       using 'MSICHTAUSW-KZSEL(01)'
                                  'X'.
    perform bdc_dynpro      using 'SAPLMGMM' '4004'.
    perform bdc_field       using 'BDC_OKCODE'
                                  '=BU'.
    perform bdc_field       using 'MAKT-MAKTX'
                                  ITAB-MAKTX.
    perform bdc_field       using 'BDC_CURSOR'
                                  'MARA-MATKL'.
    perform bdc_field       using 'MARA-MEINS'
                                  ITAB-MEINS.
    perform bdc_field       using 'MARA-MATKL'
                                  ITAB-MATKL.
    perform bdc_transaction using 'MM01'.

  ENDLOOP.

  perform close_group.
*perform close_dataset using dataset.
*&---------------------------------------------------------------------*
*&      Form  OPEN_DATA
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
*  -->  p1        text
*  <--  p2        text
*----------------------------------------------------------------------*
FORM OPEN_DATA .
  TYPE-POOLS truxs.
  DATAlt_txt TYPE truxs_t_text_data.
  DATA lc_datafile TYPE localfile.
  lc_datafile p_file.
  IF lc_datafile IS INITIAL.
*    MESSAGE s000 WITH '文件路径不能为空!' DISPLAY LIKE 'E'.
    STOP.
  ENDIF.
  CALL FUNCTION 'TEXT_CONVERT_XLS_TO_SAP'
    EXPORTING
      i_line_header        'X'
      i_tab_raw_data       lt_txt
      i_filename           lc_datafile
    TABLES
      i_tab_converted_data itab
    EXCEPTIONS
      conversion_failed    1
      OTHERS               2.


  IF sy-subrc EQ 0.
    LOOP AT itab.
      itab-matkl '0001'.
      MODIFY itab.
      CLEAR itab.
    ENDLOOP.
  ENDIF.


ENDFORM.                    " OPEN_DATA

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值