BAPI에서 계속 찾아보고 있는데 TCODE MB1A 해당 BAPI를 못찾겠습니다.
아시는분좀 가르쳐 주세요
댓글 4
-
e-abap
2007.11.08 17:31
-
김화영
2007.11.08 19:24
전 항상 bapi 실행 후 결과 Data를 받는 부분에서 막히더라구요..이렇게 적용하세요.
CALL FUNCTION 'BAPI_GOODSMVT_CREATE'
EXPORTING
GOODSMVT_HEADER = LW_GOODSMVT_HEADER
GOODSMVT_CODE = LW_GOODSMVT_CODE
IMPORTING
GOODSMVT_HEADRET = LW_GOODSMVT_HEADRET
MATERIALDOCUMENT = F_MATERIALDOCUMENT
MATDOCUMENTYEAR = F_MATDOCUMENTYEAR
TABLES
GOODSMVT_ITEM = LT_GOODSMVT_ITEM
RETURN = LT_RETURN.
IF NOT F_MATERIALDOCUMENT IS INITIAL.
CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'
EXPORTING
WAIT = 'X'.
RT_MBLNR = F_MATERIALDOCUMENT.
RT_CPUDT = SY-DATUM.
ENDIF.
-
노름마치
2007.11.08 19:53
*** 이렇게 사용하시던가
BAPI_GOODSMVT_CREATE to post Goods Movement
The following is an abap program making used of the BAPI function BAPI_GOODSMVT_CREATE to do Goods Receipts for Purchase Order after importing the data from an external system.
*
* BAPI TO Upload Inventory Data
*
* GMCODE Table T158G - 01 - MB01 - Goods Receipts for Purchase Order
* 02 - MB31 - Goods Receipts for Prod Order
* 03 - MB1A - Goods Issue
* 04 - MB1B - Transfer Posting
* 05 - MB1C - Enter Other Goods Receipt
* 06 - MB11
*
* Domain: KZBEW - Movement Indicator
* Goods movement w/o reference
* B - Goods movement for purchase order
* F - Goods movement for production order
* L - Goods movement for delivery note
* K - Goods movement for kanban requirement (WM - internal only)
* O - Subsequent adjustment of "material-provided" consumption
* W - Subsequent adjustment of proportion/product unit material
*
report zbapi_goodsmovement.
parameters: p-file like rlgrap-filename default
'c:sapdataTEST.txt'.
parameters: e-file like rlgrap-filename default
'c:sapdatagdsmvterror.txt'.
parameters: xpost like sy-datum default sy-datum.
data: begin of gmhead.
include structure bapi2017_gm_head_01.
data: end of gmhead.
data: begin of gmcode.
include structure bapi2017_gm_code.
data: end of gmcode.
data: begin of mthead.
include structure bapi2017_gm_head_ret.
data: end of mthead.
data: begin of itab occurs 100.
include structure bapi2017_gm_item_create.
data: end of itab.
data: begin of errmsg occurs 10.
include structure bapiret2.
data: end of errmsg.
data: wmenge like iseg-menge,
errflag.
data: begin of pcitab occurs 100,
ext_doc(10), "External Document Number
mvt_type(3), "Movement Type
doc_date(8), "Document Date
post_date(8), "Posting Date
plant(4), "Plant
material(18), "Material Number
qty(13), "Quantity
recv_loc(4), "Receiving Location
issue_loc(4), "Issuing Location
pur_doc(10), "Purchase Document No
po_item(3), "Purchase Document Item No
del_no(10), "Delivery Purchase Order Number
del_item(3), "Delivery Item
prod_doc(10), "Production Document No
scrap_reason(10), "Scrap Reason
upd_sta(1), "Update Status
end of pcitab.
call function 'WS_UPLOAD'
exporting
filename = p-file
filetype = 'DAT'
* IMPORTING
* FILELENGTH =
tables
data_tab = pcitab
* EXCEPTIONS
* FILE_OPEN_ERROR = 1
* FILE_READ_ERROR = 2
* NO_BATCH = 3
* GUI_REFUSE_FILETRANSFER = 4
* INVALID_TYPE = 5
* OTHERS = 6
.
if sy-subrc <> 0.
message id sy-msgid type sy-msgty number sy-msgno
with sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
exit.
endif.
gmhead-pstng_date = sy-datum.
gmhead-doc_date = sy-datum.
gmhead-pr_uname = sy-uname.
gmcode-gm_code = '01'. "01 - MB01 - Goods Receipts for Purchase Order
loop at pcitab.
itab-move_type = pcitab-mvt_type.
itab-mvt_ind = 'B'.
itab-plant = pcitab-plant.
itab-material = pcitab-material.
itab-entry_qnt = pcitab-qty.
itab-move_stloc = pcitab-recv_loc.
itab-stge_loc = pcitab-issue_loc.
itab-po_number = pcitab-pur_doc.
itab-po_item = pcitab-po_item.
concatenate pcitab-del_no pcitab-del_item into itab-item_text.
itab-move_reas = pcitab-scrap_reason.
append itab.
endloop.
loop at itab.
write:/ itab-material, itab-plant, itab-stge_loc,
itab-move_type, itab-entry_qnt, itab-entry_uom,
itab-entry_uom_iso, itab-po_number, itab-po_item,
pcitab-ext_doc.
endloop.
call function 'BAPI_GOODSMVT_CREATE'
exporting
goodsmvt_header = gmhead
goodsmvt_code = gmcode
* TESTRUN = ' '
* IMPORTING
goodsmvt_headret = mthead
* MATERIALDOCUMENT =
* MATDOCUMENTYEAR =
tables
goodsmvt_item = itab
* GOODSMVT_SERIALNUMBER =
return = errmsg
.
clear errflag.
loop at errmsg.
if errmsg-type eq 'E'.
write:/'Error in function', errmsg-message.
errflag = 'X'.
else.
write:/ errmsg-message.
endif.
endloop.
if errflag is initial.
commit work and wait.
if sy-subrc ne 0.
write:/ 'Error in updating'.
exit.
else.
write:/ mthead-mat_doc, mthead-doc_year.
perform upd_sta.
endif.
endif.
*---------------------------------------------------------------------*
* FORM UPD_STA *
*---------------------------------------------------------------------*
* ........ *
*---------------------------------------------------------------------*
form upd_sta.
loop at pcitab.
pcitab-upd_sta = 'X'.
modify pcitab.
endloop.
call function 'WS_DOWNLOAD'
exporting
filename = p-file
filetype = 'DAT'
* IMPORTING
* FILELENGTH =
tables
data_tab = pcitab
* EXCEPTIONS
* FILE_OPEN_ERROR = 1
* FILE_READ_ERROR = 2
* NO_BATCH = 3
* GUI_REFUSE_FILETRANSFER = 4
* INVALID_TYPE = 5
* OTHERS = 6
.
endform.
*--- End of Program
-
노름마치
2007.11.08 19:54
*** 아니면 이렇게 사용하셔도 되고요
*----------------------------------------------------------------
* goodsmvt_header-pstng_date: 전표전기일
* goodsmvt_header-doc_date: 전표 내 증빙일
*----------------------------------------------------------------
* 자재이동코드는 해당 비지니스플로우별로 다음과 같습니다.
* 01: Goods receipt for purchase order
* 02: Goods receipt for production order
* 03: Goods issue
* 04: Transfer posting
* 05: Other goods receipts
* 06: Reversal of goods movements
* Goodsmvt_code: 자재이동코드
* ----------------------------------------------------------------
* Goodsmvt_item-material: 자재번호
* Goodsmvt_item-plant: 플랜트
* Goodsmvt_item-stge_loc: 저장위치
* Goodsmvt_item-move_type: '311' 등...
* Goodsmvt_item-entry_Qnt: 이동수량
* Goodsmvt_item-move_stloc: 이동저장위치
----------------------------------------------------------------
DATA : st_goodsmvt_header LIKE bapi2017_gm_head_01,
st_goodsmvt_code LIKE bapi2017_gm_code,
st_goodsmvt_headret LIKE bapi2017_gm_head_ret,
g_goodsmvt_doc LIKE bapi2017_gm_head_ret-mat_doc,
g_materialdocument TYPE bapi2017_gm_head_ret-mat_doc,
g_matdocumentyear TYPE bapi2017_gm_head_ret-doc_year,
it_goodsmvt_item LIKE bapi2017_gm_item_create
OCCURS 0 WITH HEADER LINE,
it_goodsmvt_serialnumber LIKE bapi2017_gm_serialnumber
OCCURS 0 WITH HEADER LINE,
it_return LIKE bapiret2 OCCURS 0 WITH HEADER LINE.
*================================================================================
DATA l_tabix LIKE sy-tabix.
CLEAR st_goodsmvt_header.
REFRESH: it_goodsmvt_item, it_goodsmvt_serialnumber, it_return.
CLEAR: it_goodsmvt_item, it_goodsmvt_serialnumber, it_return.
LOOP AT gt_display.
l_tabix = sy-tabix.
CLEAR st_goodsmvt_header.
st_goodsmvt_header-pstng_date = sy-datum. " 기표일자
st_goodsmvt_header-doc_date = sy-datum. " 증빙일자
st_goodsmvt_code-gm_code = '04'. " 재고이동
REFRESH: it_goodsmvt_item, it_goodsmvt_serialnumber, it_return.
CLEAR: it_goodsmvt_item, it_goodsmvt_serialnumber, it_return.
it_goodsmvt_item-move_type = '309'.
it_goodsmvt_item-material = gt_display-fr_matnr.
it_goodsmvt_item-plant = gt_display-fr_werks.
it_goodsmvt_item-stge_loc = gt_display-fr_lgort.
it_goodsmvt_item-batch = gt_display-fr_charg.
it_goodsmvt_item-move_mat = gt_display-to_matnr.
it_goodsmvt_item-move_plant = gt_display-to_werks.
it_goodsmvt_item-move_stloc = gt_display-to_lgort.
it_goodsmvt_item-move_batch = gt_display-to_charg.
it_goodsmvt_item-entry_qnt = gt_display-fr_labst.
it_goodsmvt_item-entry_uom = gt_display-fr_meins.
APPEND it_goodsmvt_item.
CLEAR : g_materialdocument, g_matdocumentyear.
CALL FUNCTION 'BAPI_GOODSMVT_CREATE'
EXPORTING
goodsmvt_header = st_goodsmvt_header
goodsmvt_code = st_goodsmvt_code
IMPORTING
goodsmvt_headret = st_goodsmvt_headret
materialdocument = g_materialdocument
matdocumentyear = g_matdocumentyear
TABLES
goodsmvt_item = it_goodsmvt_item
return = it_return.
CLEAR g_goodsmvt_doc.
IF NOT st_goodsmvt_headret IS INITIAL.
g_goodsmvt_doc = st_goodsmvt_headret-mat_doc.
CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'
EXPORTING
wait = 'X'.
gt_display-msgty = 'S'.
gt_display-msglin = g_goodsmvt_doc.
MODIFY gt_display INDEX l_tabix TRANSPORTING msgty msglin.
ELSE.
READ TABLE it_return INDEX 1.
gt_display-msgty = 'E'.
gt_display-msglin = it_return-message.
MODIFY gt_display INDEX l_tabix TRANSPORTING msgty msglin.
ENDIF.
ENDLOOP.
CALL FUNCTION 'BAPI_GOODSMVT_CREATE' "
이 bapi를 사용하면 될거 같습니다.