05-30-2011 11:47 AM
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
05-30-2011 2:22 PM
Hi ,
when we are talking of 201 and 202 then system would definately take controlling in to picture .
Are you passing the cost center while posting the document ?
Else , check for OKB9 and maintain the cost center there or else in KA02 put the default account assignment .
I would recommend to take the help of your fi counter part for the same .
Cheers ,
Dewang
05-30-2011 2:22 PM
Hi ,
when we are talking of 201 and 202 then system would definately take controlling in to picture .
Are you passing the cost center while posting the document ?
Else , check for OKB9 and maintain the cost center there or else in KA02 put the default account assignment .
I would recommend to take the help of your fi counter part for the same .
Cheers ,
Dewang
05-31-2011 6:24 AM
Hi Trivedi,
I have included the cost center for that. Now the previous error has gone. Now the error says that the costcenter which i'm using doesnt exist on the sy-datum which has been assigned to
wa_header-pstng_date = sy-datum. " fill header data
wa_header-doc_date = sy-datum.
Is there any other way to update the posting and document date in the header table?? If so please suggest me about that...
Thanks in Advance,
Arunmozhi
05-31-2011 6:36 AM
Hi,
Did you passing the leading 0's in the cost center field?
and check the below coding..
* Structures for BAPI
data: gm_header type bapi2017_gm_head_01.
data: gm_code type bapi2017_gm_code.
data: gm_headret type bapi2017_gm_head_ret.
data: gm_item type table of
bapi2017_gm_item_create with header line.
data: gm_return type bapiret2 occurs 0.
data: gm_retmtd type bapi2017_gm_head_ret-mat_doc.
clear: gm_return, gm_retmtd. refresh gm_return.
perform show_status using 'Scrapping(551) Material'.
* Setup BAPI header data.
gm_header-pstng_date = sy-datum.
gm_header-doc_date = sy-datum.
gm_code-gm_code = '06'. " MB11
* Write 551 movement to table
clear gm_item.
move '551' to gm_item-move_type .
move xresb-matnr to gm_item-material.
move p_bdmng to gm_item-entry_qnt.
move xresb-meins to gm_item-entry_uom.
move xresb-werks to gm_item-plant.
move xresb-lgort to gm_item-stge_loc.
move p_grund to gm_item-move_reas.
* Determine cost center per plant
case xresb-werks.
when '0004'.
move '0000041430' to gm_item-costcenter."pass leading zero's in the cost center field
when '0006'.
move '0000041630' to gm_item-costcenter.
when '0007'.
move '0000041731' to gm_item-costcenter.
when '0008'.
move '0000041830' to gm_item-costcenter.
endcase.
append gm_item.
* Call goods movement BAPI
call function 'BAPI_GOODSMVT_CREATE'
EXPORTING
goodsmvt_header = gm_header
goodsmvt_code = gm_code
IMPORTING
goodsmvt_headret = gm_headret
materialdocument = gm_retmtd
TABLES
goodsmvt_item = gm_item
return = gm_return.
Maybe there is some config missing for your cost center, or maybe something missing in your code. check above.
Regards,
Dhina,..
Edited by: Dhina DMD on May 31, 2011 8:02 AM
05-31-2011 8:25 AM
Hi ,
Execute the T code KS02 and look at the validity of the Cost center .
That would solve the purpose , look at a cost center with a valid validity for your testing purpose .
cheers ,
Dewang
05-31-2011 9:03 AM
Hi Dhina,
Now the problem has been solved. As advised , i have changed the costcenter with leading zeros and the material has been created successfully...Thanks for the help mate....
Thanks and Best Regards from,
Arunmozhi
05-30-2011 8:21 PM
This error "Account 400000 requires an assignment to a CO object u201D... has nothing to do with the BAPI.
This error will as well come up if you post your goods issue using MB1A, MB11 or MIGO transaction, because the financial account is not completly setup.
Please contact your Finance or controlling team mates, they can fix the issue in FS01 transaction.
05-31-2011 9:08 AM
Hi All,
Thanks a lot for resolving this issue. Problem was with the addition of cost center involved while passing the same to BAPI and after adding the leading zeros for matching with its length in accordance with its domain length, the BAPI worked perfectly and the material has been created as well. Thanks again to all of u for helping in fixing this issue....Cheers
Regards,
Arunmozhi