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

Material and Classification using Bapi

Former Member
0 Likes
4,695

Hi all,

i used bapi_material_savedata and bapi_objcl_create to create material and assign classes to it. i completed it successfully, no issues here.

recently we assigned number range for the material types, and i customized the bapi so that it could accept the materials to create if they satisfy the number range, and if they already exist then, no need to satisfy the number range. Now, if im giving a material within the number range for classification the bapi bapi_objcl_create returning the message 'Object 3000000001 does not exist' if i give the material which already exists then the bapi bapi_objcl_create successfully assigns the classification. im not getting it.

could anyone give suggestions on this.

thanks & regards

chinta

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
4,195

Hi Satish,

I hope you are sending the input to BAPI_OBJCL_CHAGE with leading zeroes.( Up to 18 Characters ). Please check.

Regards,

R

15 REPLIES 15
Read only

Former Member
0 Likes
4,195

Hi

I suppose you call the BAPI for classification after calling the BAPI for material, so have you placed a COMMIT between the 2 BAPIs?

Max

Read only

0 Likes
4,195

Thanks for the reply brother.

its not the commit issue... i would say material gets created with bapi_material_savedata. as i said earlier i have problem only when number range is assigned to the material type.

Read only

0 Likes
4,195

we assign number ranges to have the number created by itself / automatic, whats the point in passing the number?

line 125 in BAPI_OBJCL_CREATE

*....Check existence of allocation......................................

   call function 'BAPI_OBJCL_EXISTENCECHECK'

     EXPORTING

       classnum    = classnumnew

       classtype   = classtypenew

       objectkey   = objectkeynew

       objecttable = objecttablenew

       keydate     = keydate

     TABLES

       return      = return.

Read only

0 Likes
4,195

hi, bapi cannot create internally, hence we use a standard bapi which would give a material number based on the material type which we pass to bapi_material_savedata hence we create a material.

guys i dont have problem while creating a material but while assigning a classification to it. when evere material number from the number range passes to bapi_objcl_create bapi returns no object exist. but if send already existing material but not from number range successfully done. clearly the issue is at bapi objcl create.

thanks

Read only

0 Likes
4,195

Hi

After calling bapi_material_savedata, if you don't call a COMMIT, the material is not stored in DB, so the next BAPI couldn't find the object.

Max

Read only

SimoneMilesi
Active Contributor
0 Likes
4,195

Did you check after 1st bapi if material is available on MARA table? Maybe it's only a matter of delay in DB update.

Read only

RaymondGiuseppi
Active Contributor
0 Likes
4,195

Insert a COMMIT WORK AND WAIT or call BAPI_TRANSACTION_COMMIT with WAIT parameter 'X', between the two call of BAPI.

...

CALL FUNCTION 'BAPI_STDMATERIAL_GETINTNUMBER'

...

CALL FUNCTION 'BAPI_MATERIAL_SAVEDATA'

...

CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'

  EXPORTING

    wait = 'X'

IMPORTING

    return        = return.

...

CALL FUNCTION 'BAPI_OBJCL_CREATE'

...

Regards,

Raymond

Read only

Former Member
0 Likes
4,196

Hi Satish,

I hope you are sending the input to BAPI_OBJCL_CHAGE with leading zeroes.( Up to 18 Characters ). Please check.

Regards,

R

Read only

0 Likes
4,195

+1 to Rudra's comment.  If a material number is all numeric it will contain leading zeros.  You should call the fm CONVERSION_EXIT_ALPHA_INPUT with the material number prior to  moving it to the object key field of BAPI_OBJCL_CREATE.  I would call this FM prior to moving to object key regardless of how the material number was generated.  It will only add the leading zeros if needed.

Read only

0 Likes
4,195

HI All,

Today's weather is very nice here in hyderabad... Larry what you said was correct. the material number is all numeric and i have add zeros to it. i checked it by adding zeros so it worked... now i have look for a functon module which checks wheather a given input conatins only numerics or not. to pass the input to the function module conversion_exit_alpha_input.

thanks  Larry,

thanks all.

chinta

Read only

0 Likes
4,195

Hi Satish,

I am happy to know the problem is solved. However for material you should use CONVERSION_EXIT_MATN1_INPUT(Based on the domain Conversion routine of MATNR) instead of CONVERSION_EXIT_ALPHA_INPUT then you do not need to check if the material is numeric or not.

Regards,

R

Read only

0 Likes
4,195

wow ty brother,,, this would help me a lot....thank you again

Read only

0 Likes
4,195

Actually the ALPHA FM would probably work ok as well.  It does the numeric check and determines if it needs to add leading zeros or not.  However, I do agree with Rudra that the MATN1 FM is better because it is the one tied to the domain MATNR and will do any other special conversion needed for material numbers.

Read only

0 Likes
4,195

Larry, what you said is correct, ALPHA FM works ok, because need the material number of length 18 and, ALPHA FM gives me more than that and i have to do other operation to take what i need where as, MATN1 FM gives me exactly what i need... i believe it is much better than OK..  I suggest to use MATN1 FM  for materials.

its good to share the knowledge and experience here...

Thank you.

Read only

0 Likes
4,195

Satish,

FYI,

ALPHA will also return just 18 if you send it a matnr based variable from your program.  The input and out parameters are un-typed and will automatically adapt to what it is sent.  When you run it via SE37 as a test, it returns MANY leading zeros because of the input parameter sent from se37 is very long.

Also,in our system we have material number configured to NOT pad leading zeros to an all numeric material number, so the MATN1 FM does not pad the leading zeros in our system, while ALPHA does.