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: 

mb1b transaction for BAPI_GOODSMVT_CREATE

Former Member
0 Kudos

Hello,

i have to create a zbapi in which the user has to expose only selected fields(lgort, charg, and receiving storage location).

i ll expose only those fields in importparameters of ZBAPI.

In the source code, how to approach this and call the fm bapi_goodsmvt_create to update mb1b transaction.

Can anyone give me source code to develop this in function module???

11 REPLIES 11

former_member181962
Active Contributor
0 Kudos

In YOur Z Bapi call the original bapi.

Fill the bapi structures with the import parameters you have for the z bapi.

Pass the exporting parameters that are obtained from the original bapi to the exporting parameters of the Z bapi.

Sample:

FUNCTION Z_GOODSMVT_CREATE.

*"----


""Local interface:

*" IMPORTING

*" VALUE(GOODSMVT_HEADER) LIKE BAPI2017_GM_HEAD_01 STRUCTURE

*" BAPI2017_GM_HEAD_01

*" VALUE(GOODSMVT_CODE) LIKE BAPI2017_GM_CODE STRUCTURE

*" BAPI2017_GM_CODE

*" VALUE(TESTRUN) LIKE BAPI2017_GM_GEN-TESTRUN DEFAULT SPACE

*" EXPORTING

*" VALUE(GOODSMVT_HEADRET) LIKE BAPI2017_GM_HEAD_RET STRUCTURE

*" BAPI2017_GM_HEAD_RET

*" VALUE(MATERIALDOCUMENT) TYPE BAPI2017_GM_HEAD_RET-MAT_DOC

*" VALUE(MATDOCUMENTYEAR) TYPE BAPI2017_GM_HEAD_RET-DOC_YEAR

*" TABLES

*" GOODSMVT_ITEM STRUCTURE BAPI2017_GM_ITEM_CREATE

*" GOODSMVT_SERIALNUMBER STRUCTURE BAPI2017_GM_SERIALNUMBER

*" OPTIONAL

*" RETURN STRUCTURE BAPIRET2

  • Pass variables here..

CALL FUNCTION 'BAPI_GOODSMVT_CREATE'

EXPORTING

GOODSMVT_HEADER = GOODSMVT_HEADER

GOODSMVT_CODE = GOODSMVT_CODE

TESTRUN = TESTRUN

IMPORTING

GOODSMVT_HEADRET = GOODSMVT_HEADRET

MATERIALDOCUMENT = MATERIALDOCUMENT

MATDOCUMENTYEAR = MATDOCUMENTYEAR

TABLES

GOODSMVT_ITEM = GOODSMVT_ITEM

GOODSMVT_SERIALNUMBER = GOODSMVT_SERIALNUMBER

RETURN = RETURN.

endfunction.

Regards,

Ravi

Former Member
0 Kudos

First you need to test this function module to check which values you need to create a material document. How will decide the material and the quantity to be used, if all you are getting is storage locations and batch? Search the forum with "BAPI_GOODSMVT_CREATE ", you will find a lot of examples.

0 Kudos

they mentioned that only in import batch number will be used.

so the corresponding material and quantity should come automatically in that batch.

they mentioned..bwart=311,werks=2000,budat and erdat default to sy-datum.

only we have to import storagelocation in first screen of mb1b, In next screen they only enter batchnumber and receiving storage location and save it.

Only they want to expose these fields in the ZBAPI to the user.

0 Kudos

Are you sure entering just a batch number will result in finding a material and the quantity? Theoritically, same batch numbers can be there for more than one material number. Have you tried doing that in MB1B directly, by just entering the dates, batch, storage locations? Is it determining the material number and quantity automatically?

0 Kudos

HI,

IN that case, you need to hard code whwtever is given in your spec.

The fields that are exposed in the import parameters will be passed to the appropriate structures of the original bapi.

IN any case for the bapi to be succesfully run , all the required fields are to be passed.(YOu either hard code it, get from the interface parameters or get some data from some other tables using the import parameters).

REgards,

Ravi

0 Kudos

I tried in mb1b , when i give batch number it is picking material number automatically but not quantity. They mentioned that whatever the quantity that is there for this batch to transfer i.e.,why they don't want to mention this quantity as import parameter . Just in ZBapi logic it has to pick up the entire quanity existing for this batch.

0 Kudos

Hi Christopher,

are you sure of what ever you pass will create the record . is your ZBAPI should always works for one set of data then in that case you may need to hardcode some values as mentioned above.

Regards

vijay

0 Kudos

So I am assuming you are entering the storage locations, batch in the batch number field and the system is automatically identifying the material. You need to find all the available batch inventory and use that. You will need to find how the system is deriving the material based on the batch number. All the batches are stored in MCHA, MCH1 depending on how the batch is created(material level or plant level). MCHB stores the batch inventory. So you need to get the material number from the batch number, then get the inventory from MCHB and use these values to pass them to the BAPI. Calling the BAPI is not the issue here. Finding out all the values needed is the big one.

Which inventory do you have to move? Is it all of it or is it jsut the unrestricted, blocked etc.?

0 Kudos

Hai vijay,

can u please give me sample code on this req.

only import parameters are storage location and in next screen : batchnumber and receivng storge location and here..material and quantity should automatically come based on logic and finally saving it will be transferred.

0 Kudos

Hi Christopher,

i don't have any sample code, related . you need to do little work inside your ZBAPI, and call the STandard BAPI. and bfore that you need to take care of all required import parameters etc.

and pass it to BAPI.

regards

vijay

former_member188685
Active Contributor
0 Kudos

Hi Christopher,

first check the bapi <b>bapi_goodsmvt_create</b> with the parameters which you want to pass, if it is able to create then you can call this BAPI inside your Custom BAPI and proceed.

make sure that all required parameters passing while calling your BAPI

Regards

vijay