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: 

HOW TO CHANGE VFDAT AND HSDAT IN MCHA TABLE USING SOME BAPI

4,681

I AM PASSING MATERIAL ,PLANT,BATCH TO BAPI_BATCH_CHANGE AND WANT TO CHNGE VFDAT AND HSDAT IN MCHA TABLE....BUT ITS NOT UPDATING IN MCHA TABLE

CAN ANY HELP ME ON THIS HOW TO UPDATE VFDAT AND HSDAT FIELDS IN MCHA TABLE BY BY PASSING MATERILA ,PLANT,BATCH,VFDAT,HSDAT FIELD TO SOME BAPI/FM?AS IT URGET

I have passed expiry date and prod date as 'X' under attributes parameter ,and also passed doclassify as 'X'.

and also used Bapi_transaction_commit in test sequnce in se37.

But still i cant see mcha table i not updated..

can anyone help me on this asap.

16 REPLIES 16

sveabecker
Community Advocate
Community Advocate
0 Kudos
2,441

Welcome and Thank you for visiting SAP Community to get answers to your questions. Please add more details to your question, e.g. you can also add a screenshot. With that, you can reach a broader range of experts to get your question answered. I also recommend to do this tutorial https://developers.sap.com/tutorials/community-qa.html

The more details you provide, the more likely it is that members will be able to assist you. Furthermore, please avoid writing in capital letters as it could be understood as shouting to the community. Please edit your question and change the capital letters to smaller ones. Thank you.

Finally, if you're hoping to connect with readers, please consider adding a picture to your profile. Here's how you do it: https://www.youtube.com/watch?v=F5JdUbyjfMA&list=PLpQebylHrdh5s3gwy-h6RtymfDpoz3vDS. By personalizing your profile with a photo of you, you encourage readers to respond.

Regards, Svea

SAP Community Global Moderator


----- Stay up-to-date with SAP Community and subscribe to What's New today! -----

DominikTylczyn
Active Contributor
2,441

Hello 472472

You can use BAPI_BATCH_CHANGE function to update both VFDAT (Shelf Life Expiration or Best-Before Date) and HSDAT (Date of Manufacture).

Both dates are available in BATCHATTRIBUTES import parameter structure as EXPIRYDATE and PROD_DATE fields respectively. You also need to put X value into EXPIRYDATE and PROD_DATE fields of BATCHATTRIBUTESX import parameter structure to indicate that you want to change the respective fields.

Take your time to read the function documentation.

Best regards

Dominik Tylczynski

0 Kudos
2,441

I have done this DOMINIK, i have also set doclassify = 'X' and also using bapi_transaction_commit but still vfdat(expiry dat) and proda_date not getting updated in MCHA table .

i am also used fm BAPI_BATCH_SAVE_REPLICA

BAPI_OBJCL_CHANGE.

BUT no use ,...

Sir could you pls help on this asap

Thanks,

Ramana

0 Kudos
2,441

I have passed expiry date and prod date as 'X' under attributes parameter ,and also passed doclassify as 'X'.

and also used Bapi_transaction_commit in test sequnce in se37.

But still i cant see mcha table i not updated..

can anyone help me on this asap.

DominikTylczyn
Active Contributor
0 Kudos
2,441

Hello 472472

I've tested the change of VFDAT and HSDAT with BAPI_BATCH_CHANGE function and it works.

You don't need to execute BAPI_TRANSACTION_COMMIT afterwards - see note 619913 - FAQ: Basic batch management functions, question 5:

Question:

What do I need to consider when maintaining batch data or using BAPIs for classification?

Answer:

You can use the BAPIs BAPI_BATCH_CREATE, BAPI_BATCH_CHANGE, and BAPI_BATCH_SAVE_REPLICA to maintain batch data.

These three BAPIs implicitly perform a separate COMMIT WORK.

If a COMMIT WORK AND WAIT is required, or if batch maintenance is to be included in a transaction, the implicit COMMIT performed by the BAPIs must be suppressed. This is done by calling the function module TRANSACTION_BEGIN before calling the individual BAPI. The calling program thus takes over the transaction control. This is ended by calling the function module TRANSACTION_END or BAPI_TRANSACTION_COMMIT.

Also depending on your batch level setting, you might have to specify plant next to material number and batch number - see the function documentation:

Batch Level

If the batch level (BatchControlFields) is on plant level, you must specify a plant in the Plant parameter.

You shouldn't try to change batch classification while changing VFDAT and/or HSDAT. These dates are part of a batch master data, not part of a batch classification.

Best regards

Dominik Tylczynski

0 Kudos
2,441

bfb5e56e-6705-4837-b634-8b1cc8a23a3e.jpeg093eff07-4739-45e0-88d9-78acca68949e.jpegHi sir

See how I am testing...

There is no updation in mcha table..

and no error message displayed in se37

0 Kudos
2,441

Hello 472472

What is your batch level? You can check it by running BAPI_BATCH_GET_LEVEL in SE37.

0 Kudos
2,440

HI SIR,

its shows Batch level as 1.Please find the below sanpshot.

batchlevel-1.png

raymond_giuseppi
Active Contributor
0 Kudos
2,440

Did you get any Error, Warning or even Success message in RETURN parameter from the BAPI call?

0 Kudos
2,440

No .. I didn’t get to any message...after exciting the bapi...

I can see result as 0.

I am trying this in sandbox system where only material,batch, and plant fields data is eixsts in mocha table...I am passing expiry and manufacturing dates and long three key fields plant,material and batch to bapi_batch_change... I cant fields updated in mcha

raymond_giuseppi
Active Contributor
0 Kudos
2,440

"I can see result as 0."

A BAPI won't usually set sy-subrc, you have to check the RETURN parameter. for TYPE = 'E' or 'A'

DominikTylczyn
Active Contributor
2,440

Hello Ramana venkata

Your batch level is 1 i.e. material level. Table MCHA is updated only if batch level is 0 i.e. plant level. Your changes are written to MCH1 table.

Best regards

Dominik Tylczynski

0 Kudos
2,440

Yes Sir...its updating MCH1 table....

In this case, which BAPI/FM, can be used to update fields in mcha table ..Sir...

Many thanks Sir,

Ramana

DominikTylczyn
Active Contributor
0 Kudos
2,440

Hello 472472

There are no separate functions to update MCH1 and MCHA tables. They are used by the system to store batch master data depending on the batch level setting. If the level is plan, MCHA is used; otherwise MCH1 is used. The system does that automatically behind the scenes.

Your batch level is 1 i.e. material level. Therefore MCH1 is updated. Instead of trying to update MCHA, just start using MCH1 in your other developments.

Best regards

Dominik Tylczynski

2,440

Many Thanks Sir...it solved my issue..

Regards,

Ramana

0 Kudos
2,440
472472If the issue is solved, make sure to up vote and accept the answers as a token of appreciation.BR, Dominik Tylczynski