Application Development and Automation Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

help need with bapi for mb1a

Former Member
0 Likes
812

Hi all,

iam creating a good movement with 201 using bapi. I created manually with the data in the t code MB1A. LATER I TRIED WITH THE SAME DATA IN PROGRAM BY PASSING THROOUGH bAPI

BUT FOR SOME REASON IAM GETTING AN ERROR SAYING

EKI 222Cost center ABCD/12345 does not exist on 03/28/2007.

but this cost center is valid till 9999. I never passed ABCD what is that?

I TRIED WITH SAME COST CENTER IT WORKED WHILE CREATE MANUALLY WITHT THE SAME DATA IN mb1a T-CODE.

tHIS IS MY CODE LET ME IF IAM MISSING ANYTHING

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 with header line.

data: gm_retmtd type bapi2017_gm_head_ret-mat_doc.

clear: gm_return, gm_retmtd. refresh gm_return.

  • Setup BAPI header data.

gm_header-pstng_date = sy-datum.

gm_header-doc_date = sy-datum.

gm_code-gm_code = '03'. " MB1A

  • Write 971 movement to table

clear gm_item.

move '201' to gm_item-move_type .

move '90998' to gm_item-material.

move '1' to gm_item-entry_qnt.

MOVE 'EA' TO GM_ITEM-ENTRY_UOM.

move 'PNT' to gm_item-plant.

move 'PPNT' to gm_item-stge_loc.

*MOVE '0901' TO GM_ITEM-MOVE_REAS.

move '12345' to gm_item-COSTCENTER.

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.

if not gm_retmtd is initial.

commit work and wait.

call function 'DEQUEUE_ALL'.

else.

commit work and wait.

call function 'DEQUEUE_ALL'.

endif.

write:/ gm_retmtd.

loop at gm_return.

write:/ gm_return.

endloop.

Thanks

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
701

Hi,

EKI 222Cost center ABCD/12345 does not exist on 03/28/2007

This ABCD may be one of the Orgn Unit like Plant/Company code/ Controlling area.

It seems that the cost center was not assigned to that ABCD (orgn Unit) that's why you are getting that error. This assignment is needed for this MB1A creation.

Just take the help of the functional consultant and ask him.

reward if useful

regards,

Anji

Hi all,

iam creating a good movement with 201 using bapi. I created manually with the data in the t code MB1A. LATER I TRIED WITH THE SAME DATA IN PROGRAM BY PASSING THROOUGH bAPI

BUT FOR SOME REASON IAM GETTING AN ERROR SAYING

EKI 222Cost center ABCD/12345 does not exist on 03/28/2007.

but this cost center is valid till 9999. I never passed ABCD what is that?

I TRIED WITH SAME COST CENTER IT WORKED WHILE CREATE MANUALLY WITHT THE SAME DATA IN mb1a T-CODE.

tHIS IS MY CODE LET ME IF IAM MISSING ANYTHING

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 with header line.

data: gm_retmtd type bapi2017_gm_head_ret-mat_doc.

clear: gm_return, gm_retmtd. refresh gm_return.

  • Setup BAPI header data.

gm_header-pstng_date = sy-datum.

gm_header-doc_date = sy-datum.

gm_code-gm_code = '03'. " MB1A

  • Write 971 movement to table

clear gm_item.

move '201' to gm_item-move_type .

move '90998' to gm_item-material.

move '1' to gm_item-entry_qnt.

MOVE 'EA' TO GM_ITEM-ENTRY_UOM.

move 'PNT' to gm_item-plant.

move 'PPNT' to gm_item-stge_loc.

*MOVE '0901' TO GM_ITEM-MOVE_REAS.

move '12345' to gm_item-COSTCENTER.

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.

if not gm_retmtd is initial.

commit work and wait.

call function 'DEQUEUE_ALL'.

else.

commit work and wait.

call function 'DEQUEUE_ALL'.

endif.

write:/ gm_retmtd.

loop at gm_return.

write:/ gm_return.

endloop.

Thanks

3 REPLIES 3
Read only

Former Member
0 Likes
702

Hi,

EKI 222Cost center ABCD/12345 does not exist on 03/28/2007

This ABCD may be one of the Orgn Unit like Plant/Company code/ Controlling area.

It seems that the cost center was not assigned to that ABCD (orgn Unit) that's why you are getting that error. This assignment is needed for this MB1A creation.

Just take the help of the functional consultant and ask him.

reward if useful

regards,

Anji

Read only

0 Likes
701

Hi,

Iam abale to create a goods issue with the same data.

The only difference i see when i create through MB1A, in the initial screen i see the collective slip has been selected and in the second when i give the cost center and hit enter it brings up the buisness area and then when i save it it creates a document number.

I tried passing the buisness area but iam getting same error.

If it work through mB1A then it should work through the BAPI RIGHT?

tAKE A LOOK AT MY BAPI CODE AND LET ME KNOW IF IA M MISSING ANYTHING IN HERE

tHANKS

Read only

Former Member
0 Likes
701

Just do one thing - keep another session open and pass all values to MB1A. Also check if there are any default values populated. . And in another session check if all respective fields are getting populated. There must be some field missing. Check if the assignments of Cost center are maintained correctly. If still you are not able to find it, debug program once which will help to identify source of error.