SAP Function Modules

VB_CREATE_BATCH SAP Function module - Create Batch







VB_CREATE_BATCH is a standard SAP function module available within R/3 SAP systems depending on your version and release level. Below is the pattern details for this FM showing its interface including any import and export parameters, exceptions etc as well as any documentation contributions (Comments) specific to the object.

See here to view full function module documentation and code listing, simply by entering the name VB_CREATE_BATCH into the relevant SAP transaction such as SE37 or SE80.

Associated Function Group: V01Z
Released Date: Not Released
Processing type: Normal fucntion module
Normal function module settings


Pattern for FM VB_CREATE_BATCH - VB CREATE BATCH





CALL FUNCTION 'VB_CREATE_BATCH' "Create Batch
* EXPORTING
*   new_lgort =                 " mchb-lgort    Storage location of batch
*   bypass_lock = SPACE         " am07m-xselk   Communication Structure
*   message_when_auto = SPACE   " am07m-xselk
*   x_bncom =                   " bncom         Communication Structure
*   qm_zustd =                  " dm07m-qm_zustd
*   ref_matnr =                 " mcha-matnr    Reference Material
*   ref_charg =                 " mcha-charg
*   ref_werks =                 " mcha-werks    Reference Plant
*   kzcla =                     " t156-kzcla
*   xkcfc =                     " t156-xkcfc
*   class =                     " klah-class
*   no_check_of_qm_char = SPACE  " am07m-xselk
*   buffer_refresh = SPACE      " am07m-xselk
*   no_change_document = SPACE  " am07m-xselk
*   check_external = X          " am07m-xselk
*   check_customer = X          " am07m-xselk
*   no_cfc_calls = SPACE        " am07m-xselk
*   no_change_of_bwtar = SPACE  " am07m-xselk   Checkbox
  IMPORTING
    ymcha =                     " mcha
* TABLES
*   char_of_batch =             " clbatch
*   new_batch =                 " mcha
*   new_batch_stoloc =          " mchb
*   return =                    " bapiret2      Return Parameter(s)
  EXCEPTIONS
    NO_MATERIAL = 1             "
    NO_BATCH = 2                "
    NO_PLANT = 3                "
    MATERIAL_NOT_FOUND = 4      "
    PLANT_NOT_FOUND = 5         "
    STOLOC_NOT_FOUND = 6        "
    LOCK_ON_MATERIAL = 7        "
    LOCK_ON_PLANT = 8           "
    LOCK_ON_BATCH = 9           "
    LOCK_SYSTEM_ERROR = 10      "
    NO_AUTHORITY = 11           "
    BATCH_EXIST = 12            "
    STOLOC_EXIST = 13           "
    ILLEGAL_BATCH_NUMBER = 14   "
    NO_BATCH_HANDLING = 15      "
    NO_VALUATION_AREA = 16      "
    VALUATION_TYPE_NOT_FOUND = 17  "
    NO_VALUATION_FOUND = 18     "
    ERROR_AUTOMATIC_BATCH_NUMBER = 19  "
    CANCELLED = 20              "
    WRONG_STATUS = 21           "
    INTERVAL_NOT_FOUND = 22     "
    NUMBER_RANGE_NOT_EXTERN = 23  "
    OBJECT_NOT_FOUND = 24       "
    ERROR_CHECK_BATCH_NUMBER = 25  "
    NO_EXTERNAL_NUMBER = 26     "
    NO_CUSTOMER_NUMBER = 27     "
    NO_CLASS = 28               "
    ERROR_IN_CLASSIFICATION = 29  "
    INCONSISTENCY_IN_KEY = 30   "
    REGION_OF_ORIGIN_NOT_FOUND = 31  "
    COUNTRY_OF_ORIGIN_NOT_FOUND = 32  "
    .  "  VB_CREATE_BATCH

ABAP code example for Function Module VB_CREATE_BATCH





The ABAP code below is a full code listing to execute function module VB_CREATE_BATCH including all data declarations. The code uses the latest in-line data DECLARATION SYNTAX but I have included an ABAP code snippet at the end to show how declarations would look using the original method of declaring data variables up front. This will allow you to compare and fully understand the new inline method. Please note some of the newer syntax such as the @DATA is not available until a later 4.70 service pack (SP8).

DATA:
ld_ymcha  TYPE MCHA ,
it_char_of_batch  TYPE STANDARD TABLE OF CLBATCH,"TABLES PARAM
wa_char_of_batch  LIKE LINE OF it_char_of_batch ,
it_new_batch  TYPE STANDARD TABLE OF MCHA,"TABLES PARAM
wa_new_batch  LIKE LINE OF it_new_batch ,
it_new_batch_stoloc  TYPE STANDARD TABLE OF MCHB,"TABLES PARAM
wa_new_batch_stoloc  LIKE LINE OF it_new_batch_stoloc ,
it_return  TYPE STANDARD TABLE OF BAPIRET2,"TABLES PARAM
wa_return  LIKE LINE OF it_return .


SELECT single LGORT
FROM MCHB
INTO @DATA(ld_new_lgort).


DATA(ld_bypass_lock) = some text here

DATA(ld_message_when_auto) = some text here
DATA(ld_x_bncom) = 'Check type of data required'.

DATA(ld_qm_zustd) = some text here

SELECT single MATNR
FROM MCHA
INTO @DATA(ld_ref_matnr).


SELECT single CHARG
FROM MCHA
INTO @DATA(ld_ref_charg).


SELECT single WERKS
FROM MCHA
INTO @DATA(ld_ref_werks).


SELECT single KZCLA
FROM T156
INTO @DATA(ld_kzcla).


SELECT single XKCFC
FROM T156
INTO @DATA(ld_xkcfc).


SELECT single CLASS
FROM KLAH
INTO @DATA(ld_class).


DATA(ld_no_check_of_qm_char) = some text here

DATA(ld_buffer_refresh) = some text here

DATA(ld_no_change_document) = some text here

DATA(ld_check_external) = some text here

DATA(ld_check_customer) = some text here

DATA(ld_no_cfc_calls) = some text here

DATA(ld_no_change_of_bwtar) = some text here

"populate fields of struture and append to itab
append wa_char_of_batch to it_char_of_batch.

"populate fields of struture and append to itab
append wa_new_batch to it_new_batch.

"populate fields of struture and append to itab
append wa_new_batch_stoloc to it_new_batch_stoloc.

"populate fields of struture and append to itab
append wa_return to it_return. . CALL FUNCTION 'VB_CREATE_BATCH' * EXPORTING * new_lgort = ld_new_lgort * bypass_lock = ld_bypass_lock * message_when_auto = ld_message_when_auto * x_bncom = ld_x_bncom * qm_zustd = ld_qm_zustd * ref_matnr = ld_ref_matnr * ref_charg = ld_ref_charg * ref_werks = ld_ref_werks * kzcla = ld_kzcla * xkcfc = ld_xkcfc * class = ld_class * no_check_of_qm_char = ld_no_check_of_qm_char * buffer_refresh = ld_buffer_refresh * no_change_document = ld_no_change_document * check_external = ld_check_external * check_customer = ld_check_customer * no_cfc_calls = ld_no_cfc_calls * no_change_of_bwtar = ld_no_change_of_bwtar IMPORTING ymcha = ld_ymcha * TABLES * char_of_batch = it_char_of_batch * new_batch = it_new_batch * new_batch_stoloc = it_new_batch_stoloc * return = it_return EXCEPTIONS NO_MATERIAL = 1 NO_BATCH = 2 NO_PLANT = 3 MATERIAL_NOT_FOUND = 4 PLANT_NOT_FOUND = 5 STOLOC_NOT_FOUND = 6 LOCK_ON_MATERIAL = 7 LOCK_ON_PLANT = 8 LOCK_ON_BATCH = 9 LOCK_SYSTEM_ERROR = 10 NO_AUTHORITY = 11 BATCH_EXIST = 12 STOLOC_EXIST = 13 ILLEGAL_BATCH_NUMBER = 14 NO_BATCH_HANDLING = 15 NO_VALUATION_AREA = 16 VALUATION_TYPE_NOT_FOUND = 17 NO_VALUATION_FOUND = 18 ERROR_AUTOMATIC_BATCH_NUMBER = 19 CANCELLED = 20 WRONG_STATUS = 21 INTERVAL_NOT_FOUND = 22 NUMBER_RANGE_NOT_EXTERN = 23 OBJECT_NOT_FOUND = 24 ERROR_CHECK_BATCH_NUMBER = 25 NO_EXTERNAL_NUMBER = 26 NO_CUSTOMER_NUMBER = 27 NO_CLASS = 28 ERROR_IN_CLASSIFICATION = 29 INCONSISTENCY_IN_KEY = 30 REGION_OF_ORIGIN_NOT_FOUND = 31 COUNTRY_OF_ORIGIN_NOT_FOUND = 32 . " VB_CREATE_BATCH
IF SY-SUBRC EQ 0. "All OK ELSEIF SY-SUBRC EQ 1. "Exception "Add code for exception here ELSEIF SY-SUBRC EQ 2. "Exception "Add code for exception here ELSEIF SY-SUBRC EQ 3. "Exception "Add code for exception here ELSEIF SY-SUBRC EQ 4. "Exception "Add code for exception here ELSEIF SY-SUBRC EQ 5. "Exception "Add code for exception here ELSEIF SY-SUBRC EQ 6. "Exception "Add code for exception here ELSEIF SY-SUBRC EQ 7. "Exception "Add code for exception here ELSEIF SY-SUBRC EQ 8. "Exception "Add code for exception here ELSEIF SY-SUBRC EQ 9. "Exception "Add code for exception here ELSEIF SY-SUBRC EQ 10. "Exception "Add code for exception here ELSEIF SY-SUBRC EQ 11. "Exception "Add code for exception here ELSEIF SY-SUBRC EQ 12. "Exception "Add code for exception here ELSEIF SY-SUBRC EQ 13. "Exception "Add code for exception here ELSEIF SY-SUBRC EQ 14. "Exception "Add code for exception here ELSEIF SY-SUBRC EQ 15. "Exception "Add code for exception here ELSEIF SY-SUBRC EQ 16. "Exception "Add code for exception here ELSEIF SY-SUBRC EQ 17. "Exception "Add code for exception here ELSEIF SY-SUBRC EQ 18. "Exception "Add code for exception here ELSEIF SY-SUBRC EQ 19. "Exception "Add code for exception here ELSEIF SY-SUBRC EQ 20. "Exception "Add code for exception here ELSEIF SY-SUBRC EQ 21. "Exception "Add code for exception here ELSEIF SY-SUBRC EQ 22. "Exception "Add code for exception here ELSEIF SY-SUBRC EQ 23. "Exception "Add code for exception here ELSEIF SY-SUBRC EQ 24. "Exception "Add code for exception here ELSEIF SY-SUBRC EQ 25. "Exception "Add code for exception here ELSEIF SY-SUBRC EQ 26. "Exception "Add code for exception here ELSEIF SY-SUBRC EQ 27. "Exception "Add code for exception here ELSEIF SY-SUBRC EQ 28. "Exception "Add code for exception here ELSEIF SY-SUBRC EQ 29. "Exception "Add code for exception here ELSEIF SY-SUBRC EQ 30. "Exception "Add code for exception here ELSEIF SY-SUBRC EQ 31. "Exception "Add code for exception here ELSEIF SY-SUBRC EQ 32. "Exception "Add code for exception here ENDIF.







ABAP code to compare 7.40 inline data declaration with original syntax

The below ABAP code uses the older none in-line data declarations. This allows you to see the coding differences/benefits of the later inline syntax. It may also be useful if you are using an older version of SAP as some of the newer syntax above, such as the @DATA is not available until 4.70 EHP 8.

DATA:
ld_ymcha  TYPE MCHA ,
it_char_of_batch  TYPE STANDARD TABLE OF CLBATCH ,
wa_char_of_batch  LIKE LINE OF it_char_of_batch,
ld_new_lgort  TYPE MCHB-LGORT ,
it_new_batch  TYPE STANDARD TABLE OF MCHA ,
wa_new_batch  LIKE LINE OF it_new_batch,
ld_bypass_lock  TYPE AM07M-XSELK ,
it_new_batch_stoloc  TYPE STANDARD TABLE OF MCHB ,
wa_new_batch_stoloc  LIKE LINE OF it_new_batch_stoloc,
ld_message_when_auto  TYPE AM07M-XSELK ,
it_return  TYPE STANDARD TABLE OF BAPIRET2 ,
wa_return  LIKE LINE OF it_return,
ld_x_bncom  TYPE BNCOM ,
ld_qm_zustd  TYPE DM07M-QM_ZUSTD ,
ld_ref_matnr  TYPE MCHA-MATNR ,
ld_ref_charg  TYPE MCHA-CHARG ,
ld_ref_werks  TYPE MCHA-WERKS ,
ld_kzcla  TYPE T156-KZCLA ,
ld_xkcfc  TYPE T156-XKCFC ,
ld_class  TYPE KLAH-CLASS ,
ld_no_check_of_qm_char  TYPE AM07M-XSELK ,
ld_buffer_refresh  TYPE AM07M-XSELK ,
ld_no_change_document  TYPE AM07M-XSELK ,
ld_check_external  TYPE AM07M-XSELK ,
ld_check_customer  TYPE AM07M-XSELK ,
ld_no_cfc_calls  TYPE AM07M-XSELK ,
ld_no_change_of_bwtar  TYPE AM07M-XSELK .


"populate fields of struture and append to itab
append wa_char_of_batch to it_char_of_batch.

SELECT single LGORT
FROM MCHB
INTO ld_new_lgort.


"populate fields of struture and append to itab
append wa_new_batch to it_new_batch.

ld_bypass_lock = some text here

"populate fields of struture and append to itab
append wa_new_batch_stoloc to it_new_batch_stoloc.

ld_message_when_auto = some text here

"populate fields of struture and append to itab
append wa_return to it_return.
ld_x_bncom = 'Check type of data required'.

ld_qm_zustd = some text here

SELECT single MATNR
FROM MCHA
INTO ld_ref_matnr.


SELECT single CHARG
FROM MCHA
INTO ld_ref_charg.


SELECT single WERKS
FROM MCHA
INTO ld_ref_werks.


SELECT single KZCLA
FROM T156
INTO ld_kzcla.


SELECT single XKCFC
FROM T156
INTO ld_xkcfc.


SELECT single CLASS
FROM KLAH
INTO ld_class.


ld_no_check_of_qm_char = some text here

ld_buffer_refresh = some text here

ld_no_change_document = some text here

ld_check_external = some text here

ld_check_customer = some text here

ld_no_cfc_calls = some text here

ld_no_change_of_bwtar = some text here

Contribute (Add Comments)

Please help keep this info upto date and use the comments section below to add useful hints, tips and information specific to this SAP function. This will then be available for you and other users to easily find by simply searching on the object name VB_CREATE_BATCH or its description.