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

create batch classification using FM VB_CREATE_BATCH

Former Member
0 Likes
7,751

Hi Experts,

Here is my situation, some of the batch dose not have classificatioin when displaying using MSC3N, so I have to create the classification of the batch in my program.

I have a test of using FM VB_CREATE_BATCH , I execute FM VB_CREATE_BATCH directly in SE37 and the result is successfully and in the return table of YMCHA, the CUOBJ_BM has value filled.

Then I go to table INOB using the CUOBJ_BM for selection, but no result exits in the table.

It seems the classification of the batch dose not created.

What else should I do ?

Please give me some advice.

Thanks for your time.

Kiki

3 REPLIES 3
Read only

Former Member
0 Likes
3,682

Dear Use below code :

I mean Use BAPI.

it_object-key_field = 'MATNR'.

it_object-value_int = wa_tab-matnr.

APPEND it_object.

it_object-key_field = 'WERKS'.

it_object-value_int = wa_tab-werks.

APPEND it_object.

it_object-key_field = 'CHARG'.

it_object-value_int = wa_tab-charg.

APPEND it_object.

  • build the object key

CALL FUNCTION 'BAPI_OBJCL_CONCATENATEKEY'

EXPORTING

objecttable = w_obtab

IMPORTING

objectkey_conc = w_object

TABLES

objectkeytable = it_object

return = rettab.

  • extract the original characteristic data if exists

CLEAR: numtab, chatab, curtab, rettab.

REFRESH: numtab, chatab, curtab, rettab.

CALL FUNCTION 'BAPI_OBJCL_GETDETAIL'

EXPORTING

objectkey = w_object

objecttable = w_obtab

classnum = class

classtype = klart

TABLES

allocvaluesnum = numtab

allocvalueschar = chatab

allocvaluescurr = curtab

return = rettab.

*Change your characteristics here.

CALL FUNCTION 'BAPI_OBJCL_CHANGE'

EXPORTING

objectkey = w_object

objecttable = w_obtab

classnum = class

classtype = klart

TABLES

allocvaluesnumnew = numtab

allocvaluescharnew = chatab

allocvaluescurrnew = curtab

return = rettab.

LOOP AT rettab WHERE type = 'E' OR type = 'A'.

PERFORM update_error_tab USING rettab-message ' ' wa_tab-matnr wa_tab-charg.

ENDLOOP.

if sy-subrc <> 0.

CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'.

endif.

Read only

andrea_olivieri
Contributor
0 Likes
3,682

Hi Anna,

You cannot assign values to characteristics of an object if, at first, the object is not assigned to the class which contains the characteristics you want to valuate.

In general you have to:

1. Assign the object to the class

2. If step 1 is done, then you can assign values to the characteristics of the class

Before start with the characteristics valuation you need to verify if the material is assigned to the batch class (Type 022/023); batches without classification data often mean just that.

A typical scenario for this behavior occurs when the batches are created during the goods receipt, the classification is not automatic and the user doesn't have the authorization to classify the material during the goods receipt.

I suggest you 2 function modules for your issue:

To assign the material to the class use CACL_OBJECT_ALLOCATION_MAINT

To evaluate the characteristics of the CACL_OBJECT_VALIDATION_MAINT

Regards,

Andrea

Read only

former_member404244
Active Contributor
0 Likes
3,682

Hi,

You can very well use "BAPI_BATCH_SAVE_REPLICA", this will update the batch characteristics..

Regards,

Nagaraj