Skip to Content
0
Former Member
May 30, 2011 at 10:47 AM

BAPI error for mvmt types 201 and 202

1943 Views

Hi all,

I'm using a bapi BAPI_GOODSMVT_CREATE for the movement type 201 and 202 with the gm_code = '03' for the transaction mb11- Goods movement. But it returns an error u201D Account 400000 requires an assignment to a CO object u201D...I'm unable to resolve this one....I have attached the code below. Please help me in fixing this issue...

if sy-subrc = 0.

*

loop at it_mchb into wa_mchb.

if wa_mchb-clabs gt 0.

clear wa_header.

wa_header-pstng_date = sy-datum. " fill header data

wa_header-doc_date = sy-datum.

wa_code-gm_code = '03'. "fill code data

clear wa_item.

wa_item-material = wa_mchb-matnr. " fillitem data

wa_item-plant = wa_mchb-werks.

wa_item-stge_loc = wa_mchb-lgort.

wa_item-batch = wa_mchb-charg.

wa_item-entry_qnt = wa_mchb-clabs.

wa_item-move_type = '201'.

  • wa_item-entry_uom = wa_mchb-meins.

append wa_item to it_item.

elseif wa_mchb-clabs lt 0.

clear wa_header.

wa_header-pstng_date = sy-datum. " fill header data

wa_header-doc_date = sy-datum.

wa_code-gm_code = '03'. "fill code data

clear wa_item.

wa_item-material = wa_mchb-matnr. " fillitem data

wa_item-plant = wa_mchb-werks.

wa_item-stge_loc = wa_mchb-lgort.

wa_item-batch = wa_mchb-charg.

wa_item-entry_qnt = wa_mchb-clabs.

wa_item-move_type = '202'.

  • wa_item-entry_uom = wa_mchb-meins.

append wa_item to it_item.

endif.

endloop.

clear lv_lin.

describe table it_item lines lv_lin.

if lv_lin = 0.

write : / 'No records found'.

endif.

call function 'BAPI_GOODSMVT_CREATE'

exporting

goodsmvt_header = wa_header

goodsmvt_code = wa_code

importing

materialdocument = lv_matdoc

tables

goodsmvt_item = it_item

return = it_return.

if it_return is initial. " if record created successfully

call function 'BAPI_TRANSACTION_COMMIT'. " commit work

write : / lv_matdoc, 'IS CREATED SUCCESSFULLY' color 5.

loop at it_item into wa_item.

write : / 'Mat :', wa_item-material,'bat :', wa_item-batch.

endloop.

else. " if record is not created successfylly

loop at it_return into wa_return.

write : / wa_return-message color 6.

endloop.

uline.

endif.

else.

write : / 'No Records found' color 7.

endif. " gt_s035 is not initial

Edited by: Arunmozhi_06 on May 30, 2011 12:48 PM