2010 Feb 06 12:42 PM
Hi,
can any1 plz tel me the bapi for T.code MB31.
what i have to do is:
MB31 --->give movt. type (101), order, plant, stor. location, and press enter
selct item > press Adopt+ details, then click on Adopt->Goto Details from items
then Goto --> Classify Batch --> gives values and save.
Plz let me what bapi to be used and that are the field need to be export to BAPI function module
Thanks
2010 Feb 07 2:38 AM
chk this wiki for BAPI_GOODSMVT_CREATE(To Post Goods Movement) sample code
http://wiki.sdn.sap.com/wiki/display/Snippets/BAPI_GOODSMVT_CREATE-ABAP
2010 Feb 06 2:26 PM
Hie
To create Goods Receipt you can use the BAPI below:
BAPI_GOODSMVT_CREATE
see the sample code also:
*------------------------------------------------------------------------
* Populate the header data
*------------------------------------------------------------------------
* Convert date to internal format recognizable by BAPI
CALL FUNCTION 'CONVERT_DATE_TO_INTERN_FORMAT'
EXPORTING
datum = xheader-pstng_date
dtype = 'DATS'
IMPORTING
idate = xgd_header-pstng_date.
* Convert date to internal format recognizable by BAPI
CALL FUNCTION 'CONVERT_DATE_TO_INTERN_FORMAT'
EXPORTING
datum = xheader-doc_date
dtype = 'DATS'
IMPORTING
idate = xgd_header-doc_date.
xgd_header-pr_uname = xheader-pr_uname.
xgd_header-ref_doc_no = xheader-works_order.
xgd_header-header_txt = xheader-header_txt.
*--------------------------------------------------------------------------
*Populate the trailer items
*--------------------------------------------------------------------------
CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT'
EXPORTING
input = xtrailer-material
IMPORTING
output = xgoodsmvt_item-material.
xgoodsmvt_item-plant = xtrailer-plant.
xgoodsmvt_item-stge_loc = xtrailer-stge_loc.
xgoodsmvt_item-move_type = xtrailer-move_type.
xgoodsmvt_item-vendor = xtrailer-vendor.
xgoodsmvt_item-item_text = xtrailer-item_text.
xgoodsmvt_item-entry_qnt = xtrailer-quantity.
CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT'
EXPORTING
input = xtrailer-costcenter
IMPORTING
output = xgoodsmvt_item-costcenter.
CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT'
EXPORTING
input = xtrailer-gl_account
IMPORTING
output = xgoodsmvt_item-gl_account.
CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT'
EXPORTING
input = xtrailer-gl_account
IMPORTING
output = xgoodsmvt_item-gl_account.
*-----------------------------------------------------------------------
*Meaning of the GM Code
*-----------------------------------------------------------------------
* GM_Code 01: Goods receipt for purchase order
* GM_Code 02: Goods receipt for production order
* GM_Code 03: Goods issue
* GM_Code 04: Transfer posting
* GM_Code 05: Other goods receipt
* GM_Code 06: Reversal of goods movements
* GM_Code 07: Subsequent adjustment with regard to a subcontract order
*------------------------------------------------------------------------
xgd_code-gm_code = '01'.
*-------------------------------------------------------------------------
*Append the data records to the BAPI transfer structures
*-------------------------------------------------------------------------
APPEND xgoodsmvt_item.
*-------------------------------------------------------------------------
ENDLOOP.
*-------------------------------------------------------------------------
*Append detail to header structure outside of line items loop
*-------------------------------------------------------------------------
APPEND xgd_header.
*-------------------------------------------------------------------------
*Create the goods receipt
CALL FUNCTION 'BAPI_GOODSMVT_CREATE'
EXPORTING
goodsmvt_header = xgd_header
goodsmvt_code = '01' "xgd_code
IMPORTING
materialdocument = xmat_doc
matdocumentyear = xmat_doc_yr
TABLES
goodsmvt_item = xgoodsmvt_item
return = xreturn.
read table xreturn.
if sy-tfill <> 0.
LOOP AT xreturn.
CLEAR xf_return.
MOVE-CORRESPONDING xreturn TO xf_return.
IF xreturn-type = 'A' OR xreturn-type = 'E'.
xf_return-error_flag = 'X'.
error_flag = 'X'.
ENDIF.
APPEND xf_return.
endloop.
else.
IF error_flag = 'X'.
ROLLBACK WORK.
ELSE.
COMMIT WORK.
xfinal-works_order = xheader-works_order.
xfinal-mat_doc = xmat_doc.
xfinal-mat_doc_yr = xmat_doc_yr.
2010 Feb 06 2:39 PM
BAPI_GOODSMVT_CREATE
Check the function module documentation ... Its very clear.
2010 Feb 07 2:38 AM
chk this wiki for BAPI_GOODSMVT_CREATE(To Post Goods Movement) sample code
http://wiki.sdn.sap.com/wiki/display/Snippets/BAPI_GOODSMVT_CREATE-ABAP
2010 Feb 07 7:40 AM
Hi,
Thanks all of you for your kind reply.
My main concern is i have to give some valuse in classfy batch.
MB31 --->give movt. type (101), order, plant, stor. location, and press enter
selct item > press Adopt+ details, then click on Adopt->Goto Details from items
then Goto --> Classify Batch --> gives values and save.
wher and how to export this data to BAPI.
we have header for header data and item table for item data etc... for for this classify batch-- i have to give some characterstics.
Kindly let me know
Thanks n regards