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

Does Anyone knows how bapi_batch_change works?

rahul_1996
Participant
7,454

I want to update the data like length, width, country of origin etc. from excel file in the classification tab of batches.

1 ACCEPTED SOLUTION
Read only

vipinsaraika
Participant
6,874

Functionality

You use this method to

  • Change a batch master record
  • Create and/or change classification of a batch in the background (object characteristics only)

You use this method, for example, when distributing batches.

The INPUT information contains

  • the batch key; parameters Material, Batch and Plant
  • the batch attributes; parameter BatchAttributes
  • control parameters; parameter BatchControlFields

Notes

The following authorization objects with activity 01 (create) are checked:

  • M_MATE_CHG Material master: Batches/Packaging
  • M_MATE_WRK Material master: Plant

Batch Level

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

Classification

If the batch is to be classified, you must specify a class in the BatchControlFields parameter. Only single classification is possible.

I want to update the data like length, width, country of origin etc. from excel file in the classification tab of batches.

13 REPLIES 13
Read only

vipinsaraika
Participant
6,875

Functionality

You use this method to

  • Change a batch master record
  • Create and/or change classification of a batch in the background (object characteristics only)

You use this method, for example, when distributing batches.

The INPUT information contains

  • the batch key; parameters Material, Batch and Plant
  • the batch attributes; parameter BatchAttributes
  • control parameters; parameter BatchControlFields

Notes

The following authorization objects with activity 01 (create) are checked:

  • M_MATE_CHG Material master: Batches/Packaging
  • M_MATE_WRK Material master: Plant

Batch Level

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

Classification

If the batch is to be classified, you must specify a class in the BatchControlFields parameter. Only single classification is possible.

Read only

6,874

Thanks Vipin it works for me program is running fine.

Read only

matt
Active Contributor
6,874

Copied straight from the FM documentation. Not cool.

Read only

0 Likes
6,874

@ Matthew: When something is readily available then why should one type in own words. I believe in saving time and accurate response.

Thanks

Read only

6,874

vipin_saraika I think that what Matthew calls "not cool", is what SAP calls "Unacceptable Content":

  • Content copied and posted without the permission of the content owner (e.g., text, photos, videos).
  • Content copied from another Community member or copied from SAP materials, such as SAP help files or SAP training documents.
  • etc.

so publishing any SAP non-public documentation is theoretically a problem, and I think even worse if you don't credit the author or the source. I sometimes do copy/paste of some parts of documents, but I always credit the source. Hopefully, I think SAP don't pursue people for so little.

Read only

0 Likes
6,874

@ Sandra just to let you know I am copy pasting the owner content in the owners website itself, the owner has purposely released these FM documentation for knowledge sharing not for restricting to there ownselves. I have nothing else to say.

Read only

matt
Active Contributor
0 Likes
6,874

vipin_saraika I'm sure you have nothing else to say. I do though.

As Sandra pointed out the site rules say:

  • Content copied from another Community member or copied from SAP materials, such as SAP help files or SAP training documents.

What you have posted may have come from SE80 or some other similar website, but it is nonetheless a SAP help file - online documentation of the BAPI.

Personally, I've no problem with reproducing it here so long as it is correctly attributed. E.g. this is from website se80 or this is from the online help concerning the function.

In that way you give the OP a hint on how to find information for themselves. If you don't then when, as this poster did, they need help on another BAPI, they'll ask here instead. Which is not a good way to learn. Spoon feeding answers is a poor way to teach as well.

Oh, and it's probably true to say that sites such as se80 are technically violating SAP's copyright. Them publishing it does not give you a right to copy paste it.

TL;DR Not cool.

Read only

0 Likes
6,874

Matthew just to tell you I copied pasted from SE37 function module documentation and nowhere else. Let's close this discussion here, I will adhere to norms of this community.

Thanks

Read only

matt
Active Contributor
0 Likes
6,874

Just give the source next time.

I will adhere to norms of this community.

Thank you.

Read only

RaymondGiuseppi
Active Contributor
6,874

Where are you stuck, reading Excel, identifying BAPIs, mapping Excel data to BAPIs parameters?

Some samples

" Change Batch
CALL FUNCTION 'BAPI_BATCH_CHANGE'
  EXPORTING
    material         = matnr
    batch            = batch
    plant            = werks
    batchattributes  = batchattrib
    batchattributesx = batchattribx
  TABLES
    return           = return.
" Get the key to update classification
CONCATENATE  matnr  batch INTO object.
CALL FUNCTION 'BAPI_OBJCL_GET_KEY_OF_OBJECT'
  EXPORTING
    objectname         = object
    objecttable        = 'MCH1'
    classtype          = clastype
    create_missing_key = 'X'
  IMPORTING
    clobjectkeyout     = cuobj
  TABLES
    return             = return.
* Change classification
CALL FUNCTION 'BAPI_OBJCL_CHANGE_KEY'
  EXPORTING
    clobjectkey         = cuobj
    classnum            = class_lot
    status_new          = '1'
    standardclass_new   = ' '
    changenumber        = ' '
    keydate             = sy-datum
  TABLES
    allocvaluesnum_new  = allocvaluesnum
    allocvalueschar_new = allocvaluescha
    allocvaluescurr_new = allocvaluescurr
    return              = return.
* Commit
CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'
  EXPORTING
    wait = 'X'.

Read the BAPI documentation and use those in your forum/google search, there are many discussions already.

Read only

0 Likes
6,874

Hi Raymond,

actually i have to create batches with batch classification.

for e.g. i give the data of batch classification through excel (e.g. country of origin,import declaration number, commodity code etc.) with this data i have to create batches can you give me the solution.

Read only

6,874

Just replace the change BAPI with the matching create BAPI

Read only

Dominik_Tylczynski
SAP Champion
SAP Champion
6,874

Hello rahul_1996

The BAPI_BATCH_CHANGE function allows updating of batch master data but not batch classification. You mentioned "length, width, country of origin" Of these, only country of origin, the HERKL field is part of the batch master record and you can update it with the BAPI. The field is available in the BATCHATTRIBUTES import parameter of the BAPI. Notice that if you want to change the country of origin, you need to provide the value in BATCHATTRIBUTES-COUNTRYORI and put X value in the BATCHATTRIBUTESX-COUNTRYORI. The latter tells the system that you actually want to update the country of origin field.

SAP provides the BAPI_OBJCL_CHANGE_KEY function to update classification of various object, including batches. I'm not able to provide you detailed input parameters as I don't know your setup of batch classification. Nevertheless the BAPI is quite well documented so you should be able to find you way around.

Best regards

Dominik Tylczynski