How to use BAPI

Share Embed Donate


Short Description

sap abap bapi...

Description

How to use BAPI_SHIPMENT_CHANGE ? Hi everyone.

I want to use BAPI_SHIPMENT_CHANGE for change 'Contents'.

You can see that info. on screen capture by following step. : VT03N -> Button - Means of transport and Packaging Matl for Currnet Shipment (Shift+F9) -> Double click 'Handling Unit'.

As you can see above, TRUCKID1 was packed with DO 10, 20, 30. When I change the 'Contents' with BAPI_SHIPMENT_CHANGE, the changing is successful but TRUCKID1 is unpacked. (it's my Problem)

So I'd like to know how to change 'Contents' with keeping pack status.

Current parameter for the bapi is like below.

HEADERDATA - SHIPMENT_N : shipment no.

HDUNHEADER - HDL_UNIT_EXID : TRUCKID1 - CONTENT

: TEST1,2,3

HDUNHEADERACTION - HDL_UNIT_EXID : C - CONTENT

:C

Goods Movement Transaction - BAPI created by Venkateswaran K on Jun 5, 2012 1:32 PM, last modified by Venkateswaran K on Jun 5, 2012 1:54 PM Version 1 inShare

Scenario

At the time of implementation, we need to upload large amount master data and transactional data in the MM Module. For Example to Upload the initial stock. Secondly there may be a situation that we need to upload a large amount of Goods Movement transaction. In order to achieve that we can use the following BAPI. This document explains the steps to arrange the data and upload in the system using BAPI.

This document will provide a guideline with respect to your requirement. Use this BAPI template for all types of Goods movement transaction by Changing appropriate movement indicator, GMcode of header information of BAPI and execute it.

Pre-requisite

Arrange the Data in the following format. Preferably in the Excel format

Ths is a comprehensive list of data. You can use the relevent fields based on your movement type. But do not change the sequence. External Document Number - Any reference document number you need to maintain             

Movement Type - Movement type viz 561 311 etc Plant - plant code Material Number - Material code Quantity - Quantity Issuing Location - From Storage location Receiving Location - Receiving Storage location Purchase Document No - PO document Purchase Document Item No - PO item number Delivery Purchase Order Number - Delivery document no Delivery Item - Delivery item no Production Document No - Production doc no Scrap Reason - Reason code Document Date - Document date on which you post it Posting Date - Posting date

Header level flags

There are some header level flags for BAPI we set based on the movement type we execute.

GMCODE Table T158G - 01 - MB01 - Goods Receipts for Purchase Order 02 - MB31 - Goods Receipts for Prod Order

03 - MB1A - Goods Issue 04 - MB1B - Transfer Posting 05 - MB1C - Enter Other Goods Receipt 06 - MB11

Movement Indicator

Goods movement w/o reference B - Goods movement for purchase order F - Goods movement for production order L - Goods movement for delivery note K - Goods movement for kanban requirement (WM - internal only) O - Subsequent adjustment of "material-provided" consumption W - Subsequent adjustment of proportion/product unit material

BAPI - Details Name : BAPI_GOODSMVT_CREATE Header Data : Header, Code Item Details : Internal table that contain material details that we fetch from Excelsheet

Technical details Now we see the technical details for writing this BAPI Execution code

Data Defention

parameters: p-file like ibipparms-path default 'c:\datasource\MB1C.xls'. data: begin of gmhead. include structure bapi2017_gm_head_01. data: end of gmhead.

data: begin of gmcode. include structure bapi2017_gm_code. data: end of gmcode. data: begin of mthead. include structure bapi2017_gm_head_ret. data: end of mthead. data: begin of itab occurs 100. include structure bapi2017_gm_item_create.

data: begin of itemtab occurs 100, ext_doc(10),

"External Document Number

mvt_type(3),

"Movement Type

plant(4),

"Plant

material(18), qty(13),

"Material Number "Quantity

issue_loc(4),

"Issuing Location

recv_loc(4),

"Receiving Location

pur_doc(10),

"Purchase Document No

po_item(3),

"Purchase Document Item No

del_no(10),

"Delivery Purchase Order Number

del_item(3),

"Delivery Item

prod_doc(10), scrap_reason(10),

"Production Document No "Scrap Reason

doc_date(8),

"Document Date

post_date(8),

"Posting Date

end of itemtab.

Read Data

Read data from Excel and store in Internal table

form UPLOAD_DATA . DATA: loc_filename TYPE rlgrap-filename. "string. DATA: it_raw TYPE truxs_t_text_data. loc_filename = p-file. CALL FUNCTION 'TEXT_CONVERT_XLS_TO_SAP' EXPORTING i_line_header = 'X' i_tab_raw_data = it_raw i_filename = loc_filename TABLES i_tab_converted_data = pcitab EXCEPTIONS conversion_failed = 1 OTHERS = 2. endform.

" UPLOAD_DATA

Set Header information

gmhead-pstng_date = sy-datum. "you can change it from the data you read from excl gmhead-doc_date = sy-datum. gmhead-pr_uname = sy-uname. gmcode-gm_code = '04'. "04 - MB1B - Transfer Posting

Set Item Details

loop at itemtab. itab-move_type = itemtab-mvt_type. itab-mvt_ind = ''. itab-plant = itemtab-plant. itab-material = itemtab-material. itab-entry_qnt = itemtab-qty. itab-move_stloc = itemtab-recv_loc. itab-stge_loc = itemtab-issue_loc. itab-po_number = itemtab-pur_doc. itab-po_item = itemtab-po_item. itab-move_reas = itemtab-scrap_reason. append itab. endloop.

Now Call BAPI

call function 'BAPI_GOODSMVT_CREATE' exporting goodsmvt_header = gmhead goodsmvt_code = gmcode * TESTRUN ='' IMPORTING goodsmvt_headret = mthead * MATERIALDOCUMENT = * MATDOCUMENTYEAR = tables goodsmvt_item = itab * GOODSMVT_SERIALNUMBER = return = errmsg.

Display errors if any clear errflag. loop at errmsg. if errmsg-type eq 'E'.

write:/'Error in function', errmsg-message. errflag = 'X'. else. write:/ errmsg-message. endif. endloop. You can use this BAPI template for Goods movement by setting appropriate header flags

Create BAPI & Run BAPI Step By Step created by Soumen Roy on Feb 7, 2013 6:32 AM, last modified by Soumen Roy on Feb 7, 2013 3:51 PM Version 1 inShare Go to transaction SE11 and create a structure as shown or as per your requirement.

Give the name in the Data type field and click create.

In the pop-up that comes up, select the radio button “ structure”.

In the components tab of the structure, give the different fields and their corresponding field types and press enter to check the compatibility and corrective ness.

Do not forget to save it in a package. You can even save it as a local object. For my example, I save it in a package.

Check the structure (ctrl + F2) and activate (ctrl + F3) the structure.

++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ +++++++++

Now we are done with the creation of a Structure.

++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ +++++++++

Go to transaction SE37 where you create function modules. Click on create after you enter the name of the Function module.

A screen as shown above would pop-up where you mention the function group to save the function module and also provide some short text describing your function module.

In the next pop-up that follows, click on continue as shown above.

The function module screen would look like the one above.

Go to the Attributes tab and select the radio button reading “remote-enabled module”. Come back to the imports tab and provide the import parameters as shown or as per your requirement.

Now in the Export tab, provide the export parameters as shown or as per your requirement.

In the tables tab, provide the information as shown or as per your requirement.

The next screen you visit is the source code. It would look like this.

In the source code tab, write the following code in order to pick the data based on the input you provide.

Now, save and check the code and activate the function module.

After successful activation, Go to the attributes tab. Go to Function module->Release>Release.

+++++++++++++++++++++++++++++++++++++++++++++++

Now we are done with the creation of a Function Module.

+++++++++++++++++++++++++++++++++++++++++++++++

Go to transaction SWO1 and enter the name of the BAPI you would like to create or as shown in the screen and click the create button.

Give the name of the BAPI as above and click on create.

Give the above-mentioned details and click on the continue icon.

Save in a package.

The resulting screen is as follows.

Now click on the methods to drop down and see what methods are provided by default. There would be two methods, showing in red color which come by default while creating the BAPI.

Click or select the method as shown above and go to the path “Utilities->API methods>Add methods”.

On the screen that follows, provide the function module name and click on the continue icon.

In the ultimate pop-up, click the next step icon. We observe that the information is predefined in the fields.

This is the next screen where you would just click on the “next” icon.

Click on Yes. You can see an information message reading “ ZBAPIFMT001” inserted.

Now save after you add the method. Select & Double click on the API method.

Go to Tab: ABAP Check 'API Function'.

The above screen is displayed. Go to the ABAP tab as shown below.

Select the Radio button reading “API Function” as already said above.

click on the continue icon to proceed further.

Now select the Object “ZBAPI_T001” as shown below.

Go to : Edit -> Change Release Status->Object type ->To Modeled.

The above shown screen will be displayed. Click on yes.

The message shows, The object type status set to modeled. (or already modeled)

Go to : Edit->Change Release Status -> Object type -> To Implemented.

You can see a message reading “Object type status set to implemented”

Now, go to: Edit -> Change Release Status -> Object -> To Released.

There would be two pop ups coming up. Click continue on the Pop Ups.

Keep the cursor on the 'Method'.

Go to: Edit -> Change Release Status -> Object type component -> TO Modeled.

You can see the message reading “ status for method „zbapifmt001‟ set to modeled”.

Now, go to: Edit -> Change Release Status -> Object type component -> TO Implemented

You can see the message reading “ status for method „zbapifmt001‟ set to implemented”.

Now go to: Edit -> Change Releasse Status -> Object type component -> To Released

You can see the message reading “ status for method „zbapifmt001‟ set to Released”.

Click on Generate Button. (the red ball kind of button is the Generate button)

After clicking on the generate button, you can see the message reading “Object type 'ZBAPI_T001' generated successfully”.

Now go to BAPI Tcode (BOR) there we can find the BAPI (our BAPI)

The BAPI browser would look like the screen below.

You can click on the Alphabetical tab so that you can browse the BAPI‟s in an alphabetical order. Find your BAPI as shown.

++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ +++++++++

Now we are done with the creation of a BAPI.

++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ +++++++++

Test Your BAPI.

Enter the name of your BAPI in the transaction SWO1 and click on „Test‟.

The above screen is displayed. Click on the Execute icon against the BAPI as shown.

The above screen is displayed where you would require entering the data against the empty input fields.

We have entered some data in the Field.

After entering the data, click on the execute icon as shown below.

The following screen is displayed which has some values as is indicated by the ITEMTAB.

Click on the Edit table icon as shown below.

The results as per our input are as shown below.

By this, we would get it confirmed that our BAPI is working properly.

We can even check it by passing different values again. Come back to the input and execution screen.

After executing the BAPI based on the input provided, we get the following screen.

Hit on the execute icon.

In the above shown screen, hit on the edit table icon.

The above is the output we get from the input we provided.

We are now done with the creation and successful execution of a BAPI. njoyyyyyyy you have done it.

Create a Material with reference using BAPI created by Sameer Ahmed on Jul 10, 2012 2:40 PM, last modified by Sameer Ahmed on Jul 10, 2012 2:40 PM Version 1 inShare Here is how to create a material with reference using BAPI_MATERIAL_GET_ALL and BAPI_MATERIAL_SAVEDATA.

Also contains the logic of how to find out what views to update from the reference material by using the Maintenance status field (PSTAT) from MARC

report ZSA_TEST002. selection-screen: begin of block b1 with frame. PARAMETERS: p_werks0 LIKE marc-werks DEFAULT '7530', p_vkorg0 LIKE mvke-vkorg DEFAULT '7530', p_disnso LIKE mvke-vtweg DEFAULT '01', p_mbrsh LIKE mara-mbrsh DEFAULT 'M'. selection-screen: end of block b1. selection-screen: begin of block b2 with frame. PARAMETERS: P_MATNR LIKE MARA-MATNR.

PARAMETERS: p_matcfg LIKE mara-matnr DEFAULT 'Z750-CFGPROD-SALES'. selection-screen: end of block b2. start-of-selection. data: gt_marc type table of marc. data: gt_mara type table of mara. DATA : str_clientdata LIKE bapi_mara_ga, str_plantdata LIKE bapi_marc_ga, str_forecastparameters LIKE bapi_mpop_ga, str_planningdata LIKE bapi_mpgd_ga, str_storagelocationdata LIKE bapi_mard_ga, str_valuationdata LIKE bapi_mbew_ga, str_salesdata LIKE bapi_mvke_ga, str_warehousenumberdata LIKE bapi_mlgn_ga, str_storagetypedata LIKE bapi_mlgt_ga, str_prtdata LIKE bapi_mfhm_ga, str_lifovaluationdata LIKE bapi_myms_ga, tab_get_all_r TYPE TABLE OF bapireturn. DATA: BEGIN OF tab_head. INCLUDE STRUCTURE bapimathead. DATA: END OF tab_head. DATA: BEGIN OF tab_plantdata. INCLUDE STRUCTURE bapi_marc. DATA: END OF tab_plantdata.

DATA: BEGIN OF tab_plantdatax. INCLUDE STRUCTURE bapi_marcx. DATA: END OF tab_plantdatax. DATA: BEGIN OF tab_client. INCLUDE STRUCTURE bapi_mara. DATA: END OF tab_client. DATA: BEGIN OF tab_clientx. INCLUDE STRUCTURE bapi_marax. DATA: END OF tab_clientx. DATA: BEGIN OF tab_salesdata. INCLUDE STRUCTURE bapi_mvke. DATA: END OF tab_salesdata. DATA: BEGIN OF tab_salesdatax. INCLUDE STRUCTURE bapi_mvkex. DATA: END OF tab_salesdatax. DATA : BEGIN OF tab_return. INCLUDE STRUCTURE bapiret2 . DATA : END OF tab_return. DATA : tab_return_msgs type table of BAPI_MATRETURN2 . data: tab_forecast like BAPI_MPOP, tab_forecastx like BAPI_MPOPX, tab_plangdata like BAPI_MPGD, tab_plangdatax like BAPI_MPGDX,

tab_stlocdata like BAPI_MARD, tab_stlocdatax like BAPI_MARDX, tab_valdata like bapi_mbew, tab_valdatax like bapi_mbewx, tab_warehouse like BAPI_MLGN, tab_warehousex like BAPI_MLGNX, tab_stortyped like BAPI_MLGT, tab_stortypedx like BAPI_MLGTX. data gt_makt type table of bapi_makt. data: gv_len type i, view, counter type sy-index, gv_i type i, gv_msg(200). field-symbols: type marc, type any, type any, type BAPI_MATRETURN2, type any, type any. CALL FUNCTION 'BAPI_MATERIAL_GET_ALL' EXPORTING

material = p_matcfg COMP_CODE = 'L153' VAL_AREA = '7530'

* VAL_TYPE =

PLANT = p_werks0

* STGE_LOC =

SALESORG = p_vkorg0 DISTR_CHAN = p_disnso

* WHSENUMBER = * STGE_TYPE = * LIFO_VALUATION_LEVEL =

IMPORTING CLIENTDATA = str_clientdata PLANTDATA = str_plantdata FORECASTPARAMETERS = str_forecastparameters PLANNINGDATA = str_planningdata STORAGELOCATIONDATA = str_storagelocationdata VALUATIONDATA = str_valuationdata

WAREHOUSENUMBERDATA = str_warehousenumberdata SALESDATA = str_salesdata STORAGETYPEDATA = str_storagetypedata PRTDATA = str_prtdata LIFOVALUATIONDATA = str_lifovaluationdata TABLES

* MATERIALDESCRIPTION = * UNITSOFMEASURE = * INTERNATIONALARTNOS = * MATERIALLONGTEXT = * TAXCLASSIFICATIONS = * EXTENSIONOUT =

RETURN = tab_get_all_r.

* Material views update ---

select * from marc into table gt_marc where matnr = p_matcfg and werks = p_werks0. if sy-subrc = 0. read table gt_marc assigning index 1. if sy-subrc = 0.

counter = 0. clear view. gv_i = strlen( -pstat ). do gv_i times. view = -pstat+counter(sy-index). if view is initial. exit. endif. counter = counter + 1. case view. when 'K'. tab_head-basic_view = view. when 'V'. tab_head-sales_view = view. when 'E'. tab_head-purchase_view = view. when 'D' . tab_head-mrp_view = view. when 'P'. tab_head-forecast_view = view. when 'A'. tab_head-WORK_SCHED_VIEW = view. when 'F'. tab_head-PRT_VIEW = view. when 'L'. tab_head-storage_view = view.

when 'S'. tab_head-warehouse_view = view. when 'Q'. tab_head-quality_view = view. when 'B'. tab_head-account_view = view. when 'G'. tab_head-cost_view = view. when others. endcase. enddo. endif. endif. tab_head-material = p_matnr. tab_head-ind_sector = str_clientdata-ind_sector. tab_head-matl_type = str_clientdata-matl_type. move-corresponding str_clientdata to tab_client. move-corresponding str_plantdata to tab_plantdata. move-corresponding str_forecastparameters to tab_forecast. move-corresponding str_planningdata to tab_plangdata. move-corresponding str_storagelocationdata to tab_stlocdata. move-corresponding str_valuationdata to tab_valdata. move-corresponding str_warehousenumberdata to tab_warehouse.

move-corresponding str_salesdata to tab_salesdata. move-corresponding str_storagetypedata to tab_stortyped.

* Fill the update struktur

do . case sy-index. when 1. assign tab_client to . assign tab_clientx to . perform fill_update_struct using . when 2. assign tab_plantdata to . assign tab_plantdatax to . perform fill_update_struct using . when 3. assign tab_forecast to . assign tab_forecastx to . perform fill_update_struct using . when 4. assign tab_plangdata to . assign tab_plangdatax to . perform fill_update_struct using . when 5.

assign tab_stlocdata to . assign tab_stlocdatax to . perform fill_update_struct using . when 6. assign tab_valdata to . assign tab_valdatax to . perform fill_update_struct using . when 7. assign tab_warehouse to . assign tab_warehousex to . perform fill_update_struct using . when 8. assign tab_salesdata to . assign tab_salesdatax to . perform fill_update_struct using . when 9. assign tab_stortyped to . assign tab_stortypedx to . perform fill_update_struct using . when others. exit. endcase. enddo.

tab_salesdata-sales_org = p_vkorg0. tab_salesdata-distr_chan = p_disnso. clear: tab_salesdatax-sales_org, tab_salesdatax-distr_chan. tab_salesdatax-sales_org = tab_salesdata-sales_org. tab_salesdatax-distr_chan = tab_salesdata-distr_chan. clear tab_plantdatax-plant. tab_plantdatax-plant = tab_plantdata-plant. CLEAR tab_valdatax-val_area. tab_valdatax-val_area = tab_valdata-val_area. CALL FUNCTION 'BAPI_MATERIAL_SAVEDATA' EXPORTING headdata = tab_head CLIENTDATA = tab_client CLIENTDATAX = tab_clientx PLANTDATA = tab_plantdata PLANTDATAX = tab_plantdatax FORECASTPARAMETERS = tab_forecast FORECASTPARAMETERSX = tab_forecastx PLANNINGDATA = tab_plangdata PLANNINGDATAX = tab_plangdatax STORAGELOCATIONDATA = tab_stlocdata STORAGELOCATIONDATAX = tab_stlocdatax

VALUATIONDATA = tab_valdata VALUATIONDATAX = tab_valdatax WAREHOUSENUMBERDATA = tab_warehouse WAREHOUSENUMBERDATAX = tab_warehousex SALESDATA = tab_salesdata SALESDATAX = tab_salesdatax STORAGETYPEDATA = tab_stortyped STORAGETYPEDATAX = tab_stortypedx * FLAG_ONLINE = ' ' * FLAG_CAD_CALL = ' '

* NO_DEQUEUE = ' '

IMPORTING RETURN = tab_return TABLES MATERIALDESCRIPTION = gt_makt

* UNITSOFMEASURE = * UNITSOFMEASUREX = * INTERNATIONALARTNOS = * MATERIALLONGTEXT = * TAXCLASSIFICATIONS =

RETURNMESSAGES = tab_return_msgs.

* PRTDATA = * PRTDATAX = * EXTENSIONIN = * EXTENSIONINX =

if tab_return-type = 'S'. CALL FUNCTION 'BAPI_TRANSACTION_COMMIT' EXPORTING WAIT = 'X'. else. CALL FUNCTION 'BAPI_TRANSACTION_ROLLBACK'. endif. loop at tab_return_msgs assigning . gv_msg = . write:/ gv_msg. endloop.

*&---------------------------------------------------------------------* *& Form fill_update_struct *&---------------------------------------------------------------------* * text

*----------------------------------------------------------------------* * -->P_ text * -->P_ text *----------------------------------------------------------------------*

FORM fill_update_struct USING P_F1 type any P_F2 type any. do. assign component sy-index of structure P_F1 to . if sy-subrc 0. exit. endif. if is not initial. assign component sy-index of structure P_F2 to . if sy-subrc = 0. = 'X'. endif. endif. enddo. ENDFORM. " fill_update_struct

Disclaimer: Please customize according to your specific requirements.

Function Module: BAPI_MATERIAL_AVAILABILITY

Posted by Tuncay Karaca in ABAP Connectivity on Apr 26, 2007 9:45:52 PM inShare I have used BAPI_MATERIAL_AVAILABILITY in iWay project to create CheckMaterialAvailability web service. Firstly let's look at its documentation: Using this function module, you can determine the receipt quantity still available for a particular material in a certain plant according to ATP logic (MRPII). The availability check is carried out on transferring the material number, the plant and the input table (WMDVSX). The scope of the check, that is, which stocks, receipts and issues are to be included in the check is defined by the combination of checking group (material master) and cheking rule. In the function module, the system uses the checking rule defined in Sales & Distribution (A). You can overrule this checking rule by using an interface or a user-exit (exit_saplw61v_001). A similar procedure is also valid for the plant parameters. The customer number in the user-exit means that the plant selection can be controlled via the customer. If no plant parameters are given via the interface, the system uses the parameter 'WRK' saved in the user's fixed values. The results of the availability check are recorded in the output table (WMDVEX). This table contains dates and available receipt quantities (ATP quantities). The results of the check depends on the following entries:   

If no date and no quantity is transferred, the system displays the ATP situation from today's date into the future as the result. If only a date and no quantity is transferred, the system displays the ATP situation from the corresponding date as the result. If both a date and a quantity are transferred, the system calculates the availability situation for the quantity specified.

In the last two cases, the parameter 'DIALOGFLAG' is supplied. This can result in the following:   

' ' (blank) quantity completely available 'X' only partial quantity available or not available at all 'N' Material not included in the availability check (Material not relevant to the availability check)

The system also displays the end of the replenishment lead time (ENDLEADTME).

You can run BAPI_MATERIAL_AVAILABILITY for only one material, one plant, one unit at a time. But we needed to check availability for multiple materials at a time, so I wrote a Z* RFC which wraps BAPI_MATERIAL_AVAILABILITY. Simply Z* RFC accepts multiple materials in a table parameter, then call BAPI_MATERIAL_AVAILABILITY in a loop.

Here is how call it:

1. * 2. 3. 4. 5. 6. 7. 8. 9. 10. 11. 12.

Call BAPI Material Availability CALL FUNCTION 'BAPI_MATERIAL_AVAILABILITY' EXPORTING plant = ls_plant-werks material = it_material-material unit = it_material-unit check_rule = it_material-check_rule IMPORTING return = ls_return TABLES wmdvsx = lt_req wmdvex = lt_com.

Import Parameters:

PLANT: give a plant number MATERIAL: give a material number UNIT: unit of measure for the material CHECK_RULE: give a check rule, value table is T441R (Values Table for Checking Rule). If you don't give check_rule, the function module gets A (SD order).

Table parameter WMDVSX (Input table (date and quantity)):    

REQ_DATE: Requirement date. If no date and no quantity is transferred, the system displays the ATP situation from today's date into the future as the result. REQ_QTY: Required quantity. DELKZ: You can give MRP element indicator, it isn't obligatory. YLINE: You can give index number to each line for internal table processing.

Export Parameters:

RETURN: If something returns with this parameter, it shows something is wrong. After calling function module, firstly check this parameter. For example you can get a message like that: "Material MMM not maintained in plant" Table parameter WMDVEX (Output table (date and ATP quantity)):   



REQ_DATE: Requirement date from import table WMDVSX. REQ_QTY: Required quantity from import table WMDVSX. COM_DATE: Committed date. If there is available quantity for required quantity, it is same as REQ_DATE. It could be different than requirement date; it means there is no available quantity on required date, but it is available in the (near) future. COM_QTY: Committed quantity. It must be same as required quantity.

If even you don't give (fill out WMDVSX table), any required quantity,

you get a result in table WMDVEX.

But requirement date was accepted today's date, and required quantity was accepted as much as big number like 9,999,999,999.000.

COM_QTY (committed quantity) shows available quantity on COM_DATE (committed quantity).

Its documentation says export parameter DIALOGFLAG can be used to see whether required quantity is available or not ( ' (blank): Available, 'X': Not available or partially available, 'N': Material not relevant to the availability check ). But as you see I didn't use DIALOGFLAG. I used table WMDVEX to do that. If I require 600 EAch material, and if it gives me less than this number as committed quantity, it means there is no available quantity for my requirement.

If you want to compare the result, you can use transaction CO09 (Availability Overview). It gives the same result as BAPI_MATERIAL_AVAILABILITY does.

On SDN forums there are several discussions keep going about BAPI_MATERIAL_AVAILABILITY:        

bapi_material_availability returning strange values BAPI_MATERIAL_AVAILABILITY CALLING BAPI in ABAP program BAPI for displaying stock How to get material availibility What is the difference between CO09,MD04 and MMBE? Get real stock available to sell. ATP Quantity Calculation Logic in transaction in CO09

Here is another link mentions BAPI_MATERIAL_AVAILABILITY: 

BAPI_MATERIAL_AVAILABILITY

Have you used BAPI_MATERIAL_AVAILABILITY? http://www.newtosap.info/2012/06/create-custom-bapi-easily.html Create a custom BAPI easily BAPI's are very useful in SAP to perform some business function as well as to exchange data / interact between different SAP systems or Non SAP systems as well. Though SAP provides a whole bunch of ready to use BAPI's, one can create there own BAPI(s) easily if required. Steps involved in creating a custom BAPI: 1 ) Create a BAPI import structure Example : I am creating a BAPI import structure ZABPI_ADIIMPORT having MATNR component.

2 ) Create a BAPI return table structure: I am creating a structure with matnr and werks , this will be output table of my BAPI.

3) Go to SE37 and create a custom BAPI FM(Function Module). ZBAPI_GET_WERKS is the bapi name. All custom BAPI FM’s should begin with ZBAPI* Make the FM remote enabled by selecting Remote Enabled Module. All BAPI FM’s are RFC enabled.

Now add the bapi import structure we created in import tab. Always remember to tick Pass by value since BAPI FM which is a RFC enabled FM cannot use pass by reference.

In the export tab we will put BAPI return parameters. BAPIRETURN is a standard BAPI return structure. In the source code of the program we need to make use of this parameter to show success or failure status along with messages.

In the tables we will use our BAPI export table structure we created. We always use LIKE for tables.

4) Source code: Add the logic of the FM here. FUNCTION ZBAPI_GET_WERKS. *"---------------------------------------------------------------------*"*"Local Interface: *" IMPORTING *" VALUE(MATNR) TYPE ZBAPI_ADIIMPORT-MATNR *" EXPORTING *" VALUE(RETURN) TYPE BAPIRETURN *" TABLES *" ZTABLE STRUCTURE ZBAPI_ADIEXPORT *"---------------------------------------------------------------------select matnr werks from marc into TABLE ztable where matnr eq matnr. if sy-subrc eq 0. "Update BAPI return table accordingly to show success here else. "Update BAPI return table accordingly to show failure here ENDIF. ENDFUNCTION.

Logic of our BAPI is simple; it fetches matnr and werks value from marc table based on input matnr values and fills the BAPI table. Lets test the FM, click execute and input a test data

ZTABLE will be filled with values from marc table corresponding to input matnr value

5 ) Place this Function Module in to BOR(Business object repository) using the T-code SWO1. Provide the name of the object and press create button.

Add our Custom BAPI FM using Utilities = > API Method = >Add Method

Press next to see the parameters involved

Press next and it will ask you that method has not been implemented, and will ask for confirmation to generate a template. Press Yes

Go back and change the BOR status to Implemented.

Next generate the BOR by clicking

After generation of BOR , release the BOR.

We can test the BOR by clicking execute

Test is similar to FM test and we can see the result

Thats it :) . Our custom BAPI is now created. Now you can use this BAPI like other BAPI.To learn how to use BAPI in reports , refer

BAPI- What is it and how its used [Part 1] BAPI- What is it and how its used [Part 2] BAPI- What is it and how its used [Part 1] BAPI's are basically function modules only. ALL BAPI's are remote enabled function modules which enables to access via non SAP systems. A remote function enabled FM(Function Module) will be attached to BOR(Business Object Repository) , then only it is termed as BAPI. Using BAPIs you can develop applications without detailed knowledge of the underlying R/3 System. Each BAPI is having its own business application and area. The integration between R/3 and third-party software, legacy systems, and custom-developed software can be achieved via BAPI.

BAPI explorer with TCODE 'BAPI'.

BAPI explorer All BAPI's are arraigned according to the business area. Details documentation is also available for some BAPI's to show the usage of the BAPI

Documentation of each BAPI

BAPI since its RFC enabled FM, has no exceptions. There are BAPI return tables which can be used to analyze the success/failure of the process. Since BAPI's are basically FM only , we call BAPI the same way we call a normal FM.

Its very important to select appropriate BAPI and also to pass the data in a way required by BAPI. Go through all I/O structures for the BAPI selected to understand this better. We can also call BAPI of other SAP systems. Just mention destination and you are good to go. Ex: call function 'BAPI_SALESORDER_GETSTATUS' destination 'PW2' exporting salesdocument = order importing return = return tables statusinfo = statusinfo.

We need to call BAPI_TRANSACTION_COMMIT after each BAPI call to finalize or commit the change or if some error occurs and we have identified the errors we need to use BAPI_TRANSACTION_ROLLBACK to rollback the changes made if any.

View more...

Comments

Copyright ©2017 KUPDF Inc.
SUPPORT KUPDF