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

CALLING BAPI in ABAP program

Former Member
0 Likes
5,899

Hi,

I want to call BAPI_MATERIAL_AVAILABILITY in ABAP program. Please give me some sample code how i can do this??? Please help

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
3,030

Decalre

<b>ET_PROCUREMENT_ITEM LIKE BBPPOGN.</b>

33 REPLIES 33
Read only

Former Member
0 Likes
3,030
DATA: LV_TABIX  LIKE SY-TABIX,
        LT_WMDVSX LIKE BAPIWMDVS OCCURS 0 WITH HEADER LINE,
        LT_WMDVEX LIKE BAPIWMDVE OCCURS 0 WITH HEADER LINE.

  LV_TABIX = SY-TABIX.

  CLEAR: LT_WMDVSX, LT_WMDVEX.
  REFRESH: LT_WMDVSX, LT_WMDVEX.

* Fill communication table
  LT_WMDVSX-REQ_DATE = ET_PROCUREMENT_ITEM-DELIV_DATE.
  LT_WMDVSX-REQ_QTY  = ET_PROCUREMENT_ITEM-QUANTITY.
  APPEND LT_WMDVSX.

* Availability check with check rule '03'
  CALL FUNCTION 'BAPI_MATERIAL_AVAILABILITY'
       EXPORTING
            PLANT      = ET_PROCUREMENT_ITEM-PLANT
            MATERIAL   = ET_PROCUREMENT_ITEM-MATERIAL
            UNIT       = ET_PROCUREMENT_ITEM-UNIT
            CHECK_RULE = '03'
       TABLES
            WMDVSX     = LT_WMDVSX
            WMDVEX     = LT_WMDVEX
       EXCEPTIONS
            OTHERS     = 1.

  IF SY-SUBRC EQ 0.
    READ TABLE LT_WMDVEX WITH KEY
                         COM_DATE = ET_PROCUREMENT_ITEM-DELIV_DATE.
    IF SY-SUBRC EQ 0.
      ET_PROCUREMENT_ITEM-AVAIL_QTY = LT_WMDVEX-COM_QTY.
    ENDIF.
  ENDIF.
Read only

Former Member
0 Likes
3,030

Have you done a "where used"? This may help.

Rob

Read only

Former Member
0 Likes
3,031

Decalre

<b>ET_PROCUREMENT_ITEM LIKE BBPPOGN.</b>

Read only

0 Likes
3,030

Hi,

Thanks for your help. I want to check whether this BAPI will return ATP quantity. What are all input values i should pass to this BAPI. Please give me Sample code to call & display this BAPI results in ABAP program....

Help me...

Read only

0 Likes
3,030

Hi this will return ATP quantity, you can find this in table WMDVEX.

regards

vijay

Read only

0 Likes
3,030
check the rules avialble in T441r.
WMDVEX-COM_QTY will hold ATP quantity.

* Fill communication table
  LT_WMDVSX-REQ_DATE = ET_PROCUREMENT_ITEM-DELIV_DATE.
  LT_WMDVSX-REQ_QTY  = ET_PROCUREMENT_ITEM-QUANTITY.
  APPEND LT_WMDVSX.
pass Plant,Material,Unit , Checking Rule, in tables pass
LT_WMDVSX, you will get the Data to lt_WMDVEX.
it will have ATp qauntity.

regards

vijay

Read only

0 Likes
3,030

Hi,

Great help. Just one more help, How i can write Structure wmdvex values using Write statement.

I tried this Loop at Wmdvex

write : / t_wmdvex.

endloop.

But it's saying me that cann't convert to text field.

Please help me..........

Read only

0 Likes
3,030
Loop at Wmdvex
write : / t_wmdvex-COM_QTY,
          t_wmdvex-BDCNT,
           t_wmdvex-REQ_QTY.

*like this try 

endloop
Read only

0 Likes
3,030

loop at t_wmdvex.

write:/ t_wmdvex-BDCNT,

t_wmdvex-REQ_DATE,

t_wmdvex-REQ_QTY,

t_wmdvex-COM_DATE,

t_wmdvex-COM_QTY.

endloop.

please reward if it solves your problem.

Message was edited by: Vijay Babu Dudla

Read only

0 Likes
3,030

Hi,

I want to pass Hardcoded Value Like My own values to this BAPI. How i can do that? Ex. Plant

'ALB1' Material "100000223" Unit "EA" like this. Is that possible????

Read only

0 Likes
3,030
CALL FUNCTION 'BAPI_MATERIAL_AVAILABILITY'
       EXPORTING
            PLANT      = 'ALB1'
            MATERIAL   = '100000223'
            UNIT       = 'EA'
            CHECK_RULE = '03'
       TABLES
            WMDVSX     = LT_WMDVSX
            WMDVEX     = LT_WMDVEX
       EXCEPTIONS
            OTHERS     = 1.
 
  IF SY-SUBRC EQ 0.

Message was edited by: Vijay Babu Dudla

Read only

0 Likes
3,030

Please Reward If your Problem solves.

reagards

vijay

Read only

0 Likes
3,030

hi,

REPORT YATP.

DATA: LV_TABIX LIKE SY-TABIX,

LT_WMDVSX LIKE BAPIWMDVS OCCURS 0 WITH HEADER LINE,

LT_WMDVEX LIKE BAPIWMDVE OCCURS 0 WITH HEADER LINE.

data ET_PROCUREMENT_ITEM LIKE BBPPOGN.

LV_TABIX = SY-TABIX.

CLEAR: LT_WMDVSX, LT_WMDVEX.

REFRESH: LT_WMDVSX, LT_WMDVEX.

  • Fill communication table

LT_WMDVSX-REQ_DATE = ET_PROCUREMENT_ITEM-DELIV_DATE.

LT_WMDVSX-REQ_QTY = ET_PROCUREMENT_ITEM-QUANTITY.

APPEND LT_WMDVSX.

  • Availability check with check rule '03'

CALL FUNCTION 'BAPI_MATERIAL_AVAILABILITY'

EXPORTING

PLANT = 'ALB1'

MATERIAL = '100000223'

UNIT = 'EA'

CHECK_RULE = '03'

TABLES

WMDVSX = LT_WMDVSX

WMDVEX = LT_WMDVEX

EXCEPTIONS

OTHERS = 1.

IF SY-SUBRC EQ 0.

READ TABLE LT_WMDVEX WITH KEY

COM_DATE = ET_PROCUREMENT_ITEM-DELIV_DATE.

IF SY-SUBRC EQ 0.

ET_PROCUREMENT_ITEM-AVAIL_QTY = LT_WMDVEX-COM_QTY.

ENDIF.

ENDIF.

write 😕 et_procurement_item-avail_qty.

Loop at lt_wmdvex.

write : / lt_wmdvex-COM_QTY,

lt_wmdvex-BDCNT,

lt_wmdvex-REQ_QTY.

endloop.

This is my program but no value written for WMDVEX.

Read only

0 Likes
3,030

please help mee ........

Read only

0 Likes
3,030

Check the materials you have inputted correctly or not

vlaues to mantnr,plant.

Read only

0 Likes
3,030

Remember material number is stored internally with leading zeros, so if you really want to access the data using a hardcoded value then you must do it like this...

call function 'BAPI_MATERIAL_AVAILABILITY'
     exporting
          plant      = 'ALB1'
          material   = '000000000100000223'
          unit       = 'EA'
          check_rule = '03'
     tables
          wmdvsx     = lt_wmdvsx
          wmdvex     = lt_wmdvex
     exceptions
          others     = 1.

Regards,

Rich heilman

Read only

0 Likes
3,030

hi First what you do

Go to MARC table take one matnr,plant

with this matnr go to mara then select take meins from that and for now don't pass rule, and pass only those.

i suggested you before it self , rules are maintained in one table check and based on that you pass , but now you can check with out any rule.

regards

vijay

Read only

0 Likes
3,030

Notice here that in my sample program the conversion is done for you when using parameters.




report zrich_0001.

data: lv_tabix like sy-tabix,
lt_wmdvsx like bapiwmdvs occurs 0 with header line,
lt_wmdvex like bapiwmdve occurs 0 with header line.
data et_procurement_item like bbppogn.
lv_tabix = sy-tabix.

<b>parameters: p_werks type marc-werks.
parameters: p_matnr type mara-matnr.</b>

clear: lt_wmdvsx, lt_wmdvex.
refresh: lt_wmdvsx, lt_wmdvex.

* Fill communication table
lt_wmdvsx-req_date = et_procurement_item-deliv_date.
lt_wmdvsx-req_qty = et_procurement_item-quantity.
append lt_wmdvsx.

* Availability check with check rule '03'
call function 'BAPI_MATERIAL_AVAILABILITY'
     exporting
<b>          plant      = P_werks
          material   = p_matnr</b>
          unit       = 'EA'
          check_rule = '03'
     tables
          wmdvsx     = lt_wmdvsx
          wmdvex     = lt_wmdvex
     exceptions
          others     = 1.

if sy-subrc eq 0.
  read table lt_wmdvex with key
  com_date = et_procurement_item-deliv_date.
  if sy-subrc eq 0.
    et_procurement_item-avail_qty = lt_wmdvex-com_qty.
  endif.
endif.

write :/ et_procurement_item-avail_qty.

loop at lt_wmdvex.
  write : / lt_wmdvex-com_qty,
  lt_wmdvex-bdcnt,
  lt_wmdvex-req_qty.

endloop.


Regards,

Rich Heilman

Read only

0 Likes
3,030

Hi I think Now you got the solution,

if you got the solution try to reward points .

Go to tables and get the values....pass them to FM

thanks

vijay

Read only

0 Likes
3,030

The Units It Always Never Be 'EA' so try to pass the correct info.

regards

vijay

Read only

0 Likes
3,030

Hi guys,

Thanks a lot for Solution. I got the answer. Really i will appreciate your help. thanks again. I rewarded points....

Read only

0 Likes
3,030

So then you did have you use internal formatting for the material number?

<b>  material   = '000000000100000223'</b>

Regards,

Rich Heilman

Read only

0 Likes
3,030

yes. When i change that input as leading zero I got the ATP Quantity........

Read only

0 Likes
3,030

Good Finally You Reached the Target.

Regards

vijay

Read only

0 Likes
3,030

Glad that it worked out for ya.

Regards,

Rich Heilman

Read only

0 Likes
3,030

Hi,

I rewared points for u too....... My special rewards "CLAPS" & thanks....for such a timely help...

Read only

0 Likes
3,030

And Solved your Problem.

That is really Good..

Read only

0 Likes
3,030

Yes, Yes. Good work guys!!

Regards,

Rich Heilman

Read only

0 Likes
3,030

Hi,

I got this ATP Quantity, I want to display this ATP Qunatity in Material Search help, that's in VA01 if i enter Standard order press enter it will take me to next screen. In that screen material field if i press f4 or Mouse click i will get Search help screen . in that result list i need to add Plant & ATP value. Any idea guys?????????

Read only

0 Likes
3,030

Hi

Try to Open in another thread and people can see your question.

regards

vijay

Read only

0 Likes
3,030

I did that.......

I opened new thread.... Thanks

Read only

Former Member
0 Likes
3,030

Hi,

I am using a BAPI in sales order simplification program. I just want to know that is it really necessary to "COMMIT WORK" calling the BAPI function?

Read only

0 Likes
3,030

Oh My god!!! U bought back Three years Old post!!!!!1

OK. Coming to your answer... You need to give commit after BAPI's to reflect the changes in the database.

After calling your particular BAPI, you should use "BAPI_TRANSACTION_COMMIT".

Regards,

Vishwa.