메뉴 건너뛰기

SAP 한국 커뮤니티

BAPI_MATERIAL_SAVEDATA 자재마스터 생성시에 사용하세요.

노름마치 2007.12.11 06:36 조회 수 : 9437 추천:2

REPORT z_bapi_mat.
**********************************************************************
*                STRUCTURE  DECLARATIONS                             *
**********************************************************************


TABLES: bapimathead,  "Headerdata
        bapi_mara,    "Clientdata
        bapi_marax,   "Clientdatax
        bapi_marc,    "Plantdata
        bapi_marcx,   "Plantdatax
        bapi_makt,    "Material description
        bapiret2.     "Return messages


DATA:v_file TYPE string.



DATA:
  BEGIN OF lsmw_material_master,
    matnr(018) TYPE c,  "Material number
    mtart(004) TYPE c,  "Material type
    mbrsh(001) TYPE c,  "Industry sector
    werks(004) TYPE c,  "Plant
    maktx(040) TYPE c,  "Material description
    dismm(002) TYPE c,  "Extra Field Added In the Program as itsrequired
    meins(003) TYPE c,  "Base unit of measure
    matkl(009) TYPE c,  "Material group
    spart(002) TYPE c,  "Division
    labor(003) TYPE c,  "Lab/office
    prdha(018) TYPE c,  "Product hierarchy
    mstae(002) TYPE c,  "X-plant matl status
    mtpos_mara(004) TYPE c,  "Gen item cat group
    brgew(017) TYPE c,  "Gross weight
    gewei(003) TYPE c,  "Weight unit
    ntgew(017) TYPE c,  "Net weight
    groes(032) TYPE c,  "Size/Dimensions
    magrv(004) TYPE c,  "Matl grp pack matls
    bismt(018) TYPE c,  "Old material number
    wrkst(048) TYPE c,  "Basic material
    profl(003) TYPE c,  "DG indicator profile
    kzumw(001) TYPE c,  "Environmentally rlvt
    bstme(003) TYPE c,  "Order unit
    vabme(001) TYPE c,
    ekgrp(003) TYPE c,  "Purchasing group
    xchpf(001) TYPE c,  "Batch management
    ekwsl(004) TYPE c,  "Purchasing key value
    webaz(003) TYPE c,  "GR processing time
    mfrpn(040) TYPE c,  "Manufacturer part number
    mfrnr(010) TYPE c,  "Manufacturer number
    vprsv(001) TYPE c,  "Price control indicator
    stprs(015) TYPE c,  "Standard price
    bwprh(014) TYPE c,  "Commercial price1
    bklas(004) TYPE c,  "Valuation class
  END OF lsmw_material_master.



**********************************************************************
*                INTERNAL TABLE DECLARATIONS                         *
**********************************************************************


*to store the input data
DATA: BEGIN OF it_matmaster OCCURS 0.
        INCLUDE STRUCTURE lsmw_material_master.
DATA: END OF it_matmaster.


*for material description
DATA:BEGIN OF it_materialdesc OCCURS 0.
        INCLUDE STRUCTURE bapi_makt .
DATA:END OF it_materialdesc.


*to return messages
DATA:BEGIN OF it_return OCCURS 0.
        INCLUDE STRUCTURE bapiret2.
DATA:END OF it_return.


************************************************************************
*  SELECTION SCREEN
************************************************************************
SELECTION-SCREEN BEGIN OF BLOCK b1 WITH FRAME TITLE text-002.


PARAMETERS:p_file LIKE rlgrap-filename OBLIGATORY.
SELECTION-SCREEN END OF BLOCK b1 .


************************************************************************
* AT SELECTION SCREEN
************************************************************************
AT SELECTION-SCREEN ON VALUE-REQUEST FOR p_file.
  CALL FUNCTION 'F4_FILENAME'
    EXPORTING
      program_name  = syst-cprog
      dynpro_number = syst-dynnr
      field_name    = 'P_FILE'
    IMPORTING
      file_name     = p_file.


**********************************************************************
*                TO UPLOAD THE DATA                                  *
**********************************************************************


START-OF-SELECTION.
  v_file = p_file.
  CALL FUNCTION 'GUI_UPLOAD'
    EXPORTING
      filename                = v_file
      filetype                = 'ASC'
      has_field_separator     = 'X'
    TABLES
      data_tab                = it_matmaster
    EXCEPTIONS
      file_open_error         = 1
      file_read_error         = 2
      no_batch                = 3
      gui_refuse_filetransfer = 4
      invalid_type            = 5
      no_authority            = 6
      unknown_error           = 7
      bad_data_format         = 8
      header_not_allowed      = 9
      separator_not_allowed   = 10
      header_too_long         = 11
      unknown_dp_error        = 12
      access_denied           = 13
      dp_out_of_memory        = 14
      disk_full               = 15
      dp_timeout              = 16
      OTHERS                  = 17.
  IF sy-subrc <> 0.
    MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
            WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
  ENDIF.


**********************************************************************
*                DATA POPULATIONS                                    *
**********************************************************************


  LOOP AT it_matmaster.
    bapimathead-material      = it_matmaster-matnr.
    bapimathead-ind_sector    = it_matmaster-mbrsh.
    bapimathead-matl_type     = it_matmaster-mtart.
    bapimathead-basic_view    = 'X'.
    bapimathead-purchase_view = 'X'.
    bapimathead-account_view  = 'X'.
    bapi_mara-matl_group      = it_matmaster-matkl.
    bapi_mara-old_mat_no      = it_matmaster-bismt.
    bapi_mara-base_uom        = it_matmaster-meins.
    bapi_mara-basic_matl      = it_matmaster-wrkst.
    bapi_mara-mfr_no          = it_matmaster-mfrnr.
    bapi_marax-matl_group     = 'X'.
    bapi_marax-old_mat_no     = 'X'.
    bapi_marax-base_uom       = 'X'.
    bapi_marax-basic_matl     = 'X'.
    bapi_marax-mfr_no         = 'X'.
    bapi_marc-plant           = it_matmaster-werks.
    bapi_marc-pur_group       = it_matmaster-ekgrp.
    bapi_marcx-plant          = it_matmaster-werks.
    bapi_marcx-pur_group      = 'X'.
    it_materialdesc-langu     = 'EN'.
    it_materialdesc-matl_desc = it_matmaster-maktx.
    APPEND it_materialdesc.


    CALL FUNCTION 'BAPI_MATERIAL_SAVEDATA'
      EXPORTING
        headdata            = bapimathead
        clientdata          = bapi_mara
        clientdatax         = bapi_marax
        plantdata           = bapi_marc
        plantdatax          = bapi_marcx
      IMPORTING
        return              = it_return
      TABLES
        materialdescription = it_materialdesc.


    WRITE:/    it_return-type,
           2   it_return-id,
           22  it_return-number,
           25  it_return-message.
  ENDLOOP.

번호 제목 글쓴이 날짜 조회 수
208 CLUSTER 테이블 찾는법~~ [4] 첼시 2008.02.28 3862
207 스마트 폼에서 워드를 기본에디터로 설정하는 방법. [8] 혀나미 2008.01.31 5505
206 ABAP_INTEGRATION_GUIDE_22 [1] file kk 2008.01.23 4004
205 ICC_INTEGRATION_GUIDE_22 [1] kk 2008.01.23 3961
204 jco_tutorial-ja_doo [2] file kk 2008.01.23 3204
203 ALV autorefresh 입니다. [13] eclipse 2008.01.15 4955
202 경고음 없애는 방법 [8] 도련님 2008.01.11 4434
201 화면에 드롭다운 리스트 박스 추가 하기. ABCD [8] 버즈즈 2008.01.05 5184
200 alv 메뉴만들기.. [9] 버즈즈 2008.01.05 4793
199 ABAP TIP 정리(영문 60페이지) [31] file sapjoy 2008.01.04 4487
198 BAPI_SALESDOCU_CREATEFROMDATA1 판매오더를 이렇게 생성해도 되는군요. [4] 노름마치 2007.12.11 5534
197 BAPI_RESERVATION_CREATE1 MB21의 예약생성시 사용하세요. [2] 노름마치 2007.12.11 7698
196 BAPI_PR_CREATE 구매요청 생성시에 사용하세요. 이렇게도 쓸 수 있군요. [1] 노름마치 2007.12.11 7835
195 BAPI_PR_CREATE 구매요청 생성시에 사용하세요 [2] 노름마치 2007.12.11 23767
194 BAPI_PO_CHANGE 구매오더 변경시에 사용하세요 [7] 노름마치 2007.12.11 5567
193 BAPI_MESSAGE_GETDETAIL 작업결과에 대한 메세지는 이렇게도 보여줄수 있겠군요 [1] 노름마치 2007.12.11 4895
» BAPI_MATERIAL_SAVEDATA 자재마스터 생성시에 사용하세요. [1] 노름마치 2007.12.11 9437
191 BAPI_MATERIAL_AVAILABILITY 가용성체크시에 사용하세요. [1] 노름마치 2007.12.11 6363
190 BAPI_INCOMINGINVOICE_CREAE 송장처리시에 사용하세요. [1] 노름마치 2007.12.11 4576
189 BAPI_GOODSMVT_CREATE 입고/출고/재고이동시에 사용하세요. [5] 노름마치 2007.12.11 15290