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

BAPI_BATCH_CREATE

Former Member
0 Likes
11,699

hi,

When I'm using transaction MSC1 to create a batch i can see in table table MCH1 my material/batch created and the field CUOBJ_BM filled with value.

When using the bapi BAPI_BATCH_CREATE the field MCH1-CUOBJ_BM is empty. But the number exist in table INOB.

in the bapi i only pass Material, Batch and Expiration Date in parameter BATCHATTRIBUTE.

I just wondering why I don't get this number in MCH1 even after using BAPI_OBJCL_GET_KEY_OF_OBJECT.

thank you,

Joseph

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
7,022

Hello,

If I remember correctly, the BAPI_BATCH_CREATE simply creates all the necessary batch data. Classification must be done seperately using the corresponding classification BAPIs.

Transaction MSC1 probably classifies by default according to customizing. You have to do it "manually".

Hope this helps (please reward me if it does),

Joerg

11 REPLIES 11
Read only

Former Member
0 Likes
7,023

Hello,

If I remember correctly, the BAPI_BATCH_CREATE simply creates all the necessary batch data. Classification must be done seperately using the corresponding classification BAPIs.

Transaction MSC1 probably classifies by default according to customizing. You have to do it "manually".

Hope this helps (please reward me if it does),

Joerg

Read only

0 Likes
7,022

Yes I was also thinking about this possibility.

But I'm asking a key for this material/batch with BAPI_OBJCL_GET_KEY_OF_OBJECT and specify the parameter CREATE_MISSING_KEY = 'X'.

I was thinking that maybe it will created in table MCH1 the object but no.

I'm still looking for a missing step....

thank you Joerg

Read only

0 Likes
7,022

Hello,

Unfortunately I have only used the classification BAPIs from an external program, so I don't have any ABAP coding for you - just a textual description. I still hope this will help you.

You probably really have to create the key using the FM BAPI_OBJCL_GET_KEY_OF_OBJECT with OBJECTTABLE = 'MCHA', CLASSTYPE = <your class type>, OBJECTNAME = '<MATNR><WERKS>', CREATEMISSINGKEY = 'X'. The resulting object key in CLOBJECTKEYOUT should then be updated into the MCH* tables automatically.

Hope this helps (please reward me if it does ,

Joerg

Read only

0 Likes
7,022

Hi joerg,

I already use this method but without success.

So i decide, and i know that is not a very good thing to do, to create the Batch with a batch input and then update the characteristics with bapi BAPI_OBJCL_CHANGE.

anyway thank Joerg for your help

Joseph

Message was edited by: joseph fryda

Read only

0 Likes
7,022

Hello,

Could you state again why the BAPI fails?

The order of steps necessary to create a batch and classify it are:

BAPI_BATCH_CREATE

BAPI_TRANSACTION_COMMIT

BAPI_OBJCL_GET_KEY_OF_OBJECT

BAPI_TRANSACTION_COMMIT

BAPI_OBJCL_CHANGE_KEY

BAPI_TRANSACTION_COMMIT

Again: Unfortunately I have only tried this from an external (VB-) program, so I don't have any ABAP coding. However, it worked for me. Maybe you should search OSS for relevant notes? Have you checked other "popular" error sources such as forgetting BAPI_TRANSACTION_COMMIT or omitting leading zeroes of MATNR etc.?

Regards, Joerg.

Read only

0 Likes
7,022

I make the same steps as you describe.

The bapi doesn't fails. The problem is why I don't see in field MCH1-CUOBJ_BM <b>an object number</b>. Why this field stay empty when you use bapi and when you use the online transaction or batch input this field contains a value?

Message was edited by: joseph fryda

Read only

0 Likes
7,022

Hello,

Is the field empty in MCHA as well?

Can you see the classification in the MSCxN transactions?

Regards, Joerg

Read only

Former Member
0 Likes
7,022

Hi, Joseph!

For classified batch creation you can use VB_CREATE_BATCH:

CALL FUNCTION 'VB_CREATE_BATCH'

EXPORTING

ymcha = wa_mcha

new_lgort = lgort

kzcla = '1'

xkcfc = 'X'

IMPORTING

ymcha = wa_mcha

TABLES

char_of_batch = it_clbatch

EXCEPTIONS

<exception list>.

where you have to set for wa_mcha(for my working example):

wa_mcha-matnr

wa_mcha-werks

wa_mcha-bwtar

and all approporiate classification for it_clbatch:

it_clbatch-atnam

it_clbatch-atwtb

After succesful execution you can find batch number in wa_mcha-charg.

Regards,

Maxim.

Read only

0 Likes
7,022

Just for information I am created Batch for material <b>and not</b> Batch for material/werks, so table MCHA is useless for me (i don't think that i'm suppose to update it).

I will send a note to oss and keep you guys updated.

thanks

joseph

Read only

0 Likes
7,022

Hi Guys,

Does anyone knows a solution to this problem?

Thanks,

Abdullah

Read only

0 Likes
7,022

Hi all ,

Was facing the same issue and came across this post.

Only passing    kzcla                              = '1'  in FM 'VB_CREATE_BATCH'  , will help in populating the field  , MCH1-CUOBJ_BM.