Application Development 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: 

{SOLVED] Create characteristics with BAPI_CREATE_BATCH

Former Member
0 Kudos
2,573

Hello,

In my program I create a batch before a good receipt. This good receipt is created with the bapi 'BAPI_GOODSMVT_CREATE'. In this last bapi I'm able to add the batch number.

If I create the batch I have also to add some characteristics. So I have looked for an example and found one. The example I follow is "Batch create and characteristics via BAPI (example)".

http://www.sapfans.com/forums/viewtopic.php?t=125320&highlight=bapibatchcreate.

The creation of the batch number and the creation of the objectkey works fine but when I come to the form 'extract_original_batch' with the bapi 'BAPI_OBJCL_GETDETAIL' I receive the following error message "Assignment does not exist or is not valid on".

The class it self is valid till 31129999 and I'm able to assign values during a good receipt with MIGO.

What could be wrong or has an other example to find out what's the problem.

This is what I inserting into the bapi:

p_matnr = '0000010393' a valid materialnumber

p_werks = '0010'

p_charg = '0001000125'

w_object = 00000000000001039300100001000125

p_class = 'ZMMGASOPSLAG'

p_klart = '023'

Here is a part of the program.

----


  • FORM build_object_key *

----


FORM build_object_key

TABLES

p_it_messages LIKE it_messages[]

p_it_object STRUCTURE bapi1003_object_keys

USING

P_WERKS LIKE EKPO-werks

P_MATNR LIKE EKPO-matnr

P_WA_ONTV_BEST_LGORT LIKE EKPO-lgort

P_charg LIKE mcha-charg

p_ebeln LIKE EKPO-ebeln

p_ebelp LIKE EKPO-ebelp

CHANGING

p_object LIKE bapi1003_key-object.

DATA: BEGIN OF XEMSEG OCCURS 1.

INCLUDE STRUCTURE BAPIRET2.

DATA: END OF XEMSEG.

CLEAR XEMSEG.

  • build the object key

CLEAR: it_object.

REFRESH: it_object.

it_object-key_field = 'MATNR'.

it_object-value_int = p_matnr.

APPEND it_object.

it_object-key_field = 'WERKS'.

it_object-value_int = p_werks.

APPEND it_object.

it_object-key_field = 'CHARG'.

it_object-value_int = p_charg.

APPEND it_object.

CALL FUNCTION 'BAPI_OBJCL_CONCATENATEKEY'

EXPORTING

objecttable = 'MCHA'

IMPORTING

objectkey_conc = p_object

TABLES

objectkeytable = it_object

return = XEMSEG.

IF not xemseg is initial.

PERFORM ins_errors

TABLES

it_messages

xemseg

USING

p_ebeln

p_ebelp.

ENDIF.

ENDFORM.

Kind regards,

Richard Meijn

Message was edited by: R. Meijn

11 REPLIES 11

Former Member
0 Kudos
422

1. Have you BAPI_TRANSACTION_COMMIT after creating the characteristics?

2. If yes, there might be some time lag before it is available for the code. Try introducing some wait time.

regards,

Ravi

0 Kudos
422

Ravi,

I have made a BAPI_TRANSACTION_COMMIT after creating the batchnumber.

Do you know how to create a time lag?

Kind regards,

Richard Meijn

Former Member
0 Kudos
422

Hi!

Have a look at alternative for classified batch creation:

Regards,

Maxim.

0 Kudos
422

Maxim,

I'm just starting writing ABAP code. So the example is not so clear for me.

There is no example init for creating the characteristics?

So if you could explain this to me I will be pleased.

Kind regards,

Richard Meijn

0 Kudos
422

Hi!

As I understand you have to create batch with populated characteristics values. So my assumption was you already have corresponding characteristics in your system. Is it so?

Regards,

Maxim.

Former Member
0 Kudos
422

As I see here, your "p_matnr" is having a value '0000010393' that is not in internal format. It should be converted to internal format using CONVERSION_EXIT_MATN1_INPUT before passing it to the BAPI.

Srinivas

0 Kudos
422

Srinivas,

I have jused the function 'CONVERSION_EXIT_MATN1_INPUT' but didn't solved the problem.

If I add tha values manualy in the function debugger even then I don't see anny insertions into the table INOB.

Kind Regards,

Richard Meijn

0 Kudos
422

Then let me know if you are calling the BAPI_TRANSACTION_COMMIT with WAIT = 'X' or not? You need WAIT = 'X'.

Srinivas

0 Kudos
422

Srinivas,

Thanks for your reply,

I have tried both commits with and without wait. Both didn't work but I have look and tried the hole day.

After some headache I have maybe found the solution. I will try it out.

My conclusion is the following.

The BAPI 'BAPI_BJC_CONCATENATEKEY' creates the key as shown in the table INOB but the bapi don't stores the key.

In my program I have to create a good movement. This is also done with a BAPI. When this BAPI is finalised the key is stored in the INOB table. So my conclusion is that the key is created with the BAPI 'bapi_goodsmvt_create' when necessary.

After the creation of the key I could follow the example to modify the characteristics.

If everything is working I will explain the solution.

Kind Regards,

Richard Meijn

Former Member
0 Kudos
422

Hello,

The problem is solved.

The bapi create_batch doesn't create the characteristics and also not the key.

The bapi 'BAPI_GOODSMVT_CREATE' creates the batchnumber and the characreistics with the object key. If after creation of the good movement the characteristics are changed the program works fine.

Thanks for the help in hints you gave me.

Kind regards,

Richard Meijn

0 Kudos
422

Hi All,

Can we create a Batch and charecteristic values with BAPI 'BAPI_GOODSMVT_CREATE'

If yes do let me know how to pass the input parameters.

Thanks

Ravi