Chinaunix首页 | 论坛 | 博客
  • 博客访问: 7203328
  • 博文数量: 655
  • 博客积分: 10264
  • 博客等级: 上将
  • 技术积分: 8278
  • 用 户 组: 普通用户
  • 注册时间: 2007-06-04 17:47
个人简介

ABAP顾问

文章分类

全部博文(655)

文章存档

2017年(2)

2014年(8)

2013年(3)

2012年(2)

2011年(18)

2010年(102)

2009年(137)

2008年(274)

2007年(134)

分类:

2009-02-27 16:25:23

*&---------------------------------------------------------------------*
*& 更改物料的MRP区域数据
*&---------------------------------------------------------------------*
REPORT  zmm025 NO STANDARD PAGE HEADING .
 
DATA: s_mdma      LIKE mdma,
      s_dpop      LIKE dpop,
      s_selfields LIKE sdibe_massfields,
      return      LIKE bapireturn1 .
DATA:had .
 
DATA: BEGIN OF itab OCCURS 0 ,
        matnr LIKE mara-matnr ,
        werks LIKE marc-werks ,
        berid LIKE mdma-berid ,
        dispo LIKE mdma-dispo ,
        lgpro LIKE mdma-lgpro ,
        lgfsb LIKE mdma-lgfsb ,
      END OF itab.
DATA: filename TYPE string ,
      lf_rc    TYPE c .
 
PARAMETERS:openfile LIKE ibipparms-path OBLIGATORY DEFAULT 'c:\ZMM025.txt' .
 
AT SELECTION-SCREEN ON VALUE-REQUEST FOR openfile .
  CALL FUNCTION 'F4_FILENAME'
    EXPORTING
      program_name  = syst-cprog
      dynpro_number = syst-dynnr
      field_name    = ' '
    IMPORTING
      file_name     = openfile.
 
AT SELECTION-SCREEN .
  filename = openfile.
  CALL METHOD cl_gui_frontend_services=>file_exist
    EXPORTING
      file                 = filename
    RECEIVING
      result               = lf_rc
    EXCEPTIONS
      cntl_error           = 1
      error_no_gui         = 2
      wrong_parameter      = 3
      not_supported_by_gui = 4
      OTHERS               = 5.
  IF lf_rc <> 'X'.
    MESSAGE e000(oo) WITH '文件不存在'.
  ENDIF.
 
START-OF-SELECTION.
  CALL FUNCTION 'GUI_UPLOAD'
    EXPORTING
      filename = filename
      filetype = 'DAT'
    TABLES
      data_tab = itab.
 
*  itab-matnr = '001100000000000385'.
*  itab-werks = '1010'.
*  itab-berid = '1010CG'.
*  itab-dispo = '102'.
*  itab-lgpro = '1040'.
*  itab-lgfsb = '1040'.
*  APPEND itab.
 
  LOOP AT itab WHERE  matnr = '' OR werks = '' OR berid = ''.
    IF had <> 'X'.
      WRITE : '下列物料信息不全:'.
      had = 'X'.
    ENDIF.
    WRITE : / itab-matnr ,itab-werks ,itab-berid .
  ENDLOOP.
  ULINE.
 
  LOOP AT itab WHERE matnr <> '' AND werks <> '' AND berid <> ''.
    CALL FUNCTION 'CONVERSION_EXIT_MATN1_INPUT'
      EXPORTING
        input        = itab-matnr
      IMPORTING
        output       = itab-matnr.
    CLEAR s_mdma.
    MOVE-CORRESPONDING itab TO s_mdma .
    CLEAR s_selfields.
    IF itab-dispo <> ''.
      s_selfields-xdispo = 'X'.
    ENDIF.
    IF itab-lgfsb <> ''.
      s_selfields-xlgfsb = 'X'.
    ENDIF.
    IF itab-lgpro <> ''.
      s_selfields-xlgpro = 'X'.
    ENDIF.
    CALL FUNCTION 'MD_MRP_LEVEL_CHANGE_DATA'
      EXPORTING
        i_matnr        = itab-matnr
        i_werk         = itab-werks
        i_mrp_area     = itab-berid
        i_berty        = '02'
        i_selfields    = s_selfields
        i_mdma         = s_mdma
        i_dpop         = s_dpop
      IMPORTING
        e_error_return = return.
    IF NOT return IS INITIAL .
      WRITE : / itab-matnr ,itab-werks ,itab-berid .
      PERFORM write_wa USING return 'XXXX' '' '' .
    ELSE.
      WRITE : / itab-matnr,itab-werks ,itab-berid ,'成功更改!'.
    ENDIF.
    CLEAR return.
  ENDLOOP.
 
*---------------------------------------------------------------------*
*       FORM write_wa                                                 *
*---------------------------------------------------------------------*
FORM write_wa USING wa fieldmask newline alllen.
  DATA: str TYPE string ,
        str_idx TYPE string ,
        f_index TYPE i ,
        f_len TYPE i .
  FIELD-SYMBOLS: .
  f_len = STRLEN( fieldmask ).
  IF newline = 'X'. WRITE  / ''.ENDIF.
*  POSITION 1 .
  DO .
    ASSIGN COMPONENT sy-index OF STRUCTURE wa TO .
    IF sy-subrc <> 0 OR sy-index > f_len.
      EXIT.
    ELSE.
      str_idx = sy-index .
      CONDENSE str_idx.
      f_index = sy-index - 1.
      IF fieldmask+f_index(1) = 'X'.
        IF alllen = ''.
          str = .
          WRITE str.
        ELSE.
          WRITE .
        ENDIF.
      ENDIF.
    ENDIF.
  ENDDO.
ENDFORM.                    "write_wa
阅读(6719) | 评论(0) | 转发(1) |
给主人留下些什么吧!~~