cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

BAPI For Getting Purchase Order Information

Former Member
0 Kudos
4,532

Hi,

I need to use a BAPI method for fetching the given PO number information in my VB program. I need following information regarding a PO.

a) PO Date

b) PO Release Status

c) Vendor

d) PO Type

e) PO organization

f) PO Item details (including site).

Any help is appreciated.

Regards,

Farrukh Shaheer

Accepted Solutions (0)

Answers (3)

Answers (3)

oliver_wurm
Active Participant
0 Kudos

Hi Farrukh,

have you tried to search for similar Posts in SCN? For example in thread http://scn.sap.com/thread/3481472 the Problem seems to be solved ...


Regards

Oliver

Former Member
0 Kudos

Try BAPI_PO_GETDETAIL.

Thanks,

Vikram.M

oliver_wurm
Active Participant
0 Kudos

Hi Farrukh,

the BAPI to read PO Details is BAPI_PO_GETDETAIL1. You can find PO Date, Release Status, Vendor, PO Type and PO Organization on the returned PO Header and the complete item Details are returned as well. Please note that the indicators you can pass to the BAPI are influencing if the corresponding data is returned or not.

Regards

Oliver

Former Member
0 Kudos

Hi Oliver,


Thanks for the information, I need to understand if the following code i wrote is correct to fetch the PO details for a given PO number?

Dim BAPICTRL As Object

Dim BOORDER As Object

Dim OHEADER As Object

Dim ORETURN As Object

Dim OCONN As Object

Private Sub Form_Load()


Set BAPICTRL = CreateObject("SAP.BAPI.1")

Set OCONN = BAPICTRL.Connection

OCONN.LOGON

Set BOORDER = BAPICTRL.GetSAPObject("PurchaseOrder")

Set OHEADER = BAPICTRL.DimAs(BOORDER, "GetDetail1", "PoHeader")

Set ORETURN = BAPICTRL.DimAs(BOORDER, "GetDetail1", "RETURN")

End Sub

Private Sub Command1_Click()

Dim X As String

OHEADER.Value("PURCH_NO") = Text2   ' Text2=Find this PO Detail

BOORDER.GetDetail1 PoHeader:=OHEADER, Return:=ORETURN

X = ORETURN.Value("message")

If X = "" Then

    TxtHdrs(0) = OHEADER.Value("DOC_TYPE")

    TxtHdrs(1) = OHEADER.Value("PURCH_ORG")

    TxtHdrs(2) = OHEADER.Value("PUR_GROUP")

    TxtHdrs(3) = OHEADER.Value("VENDOR")

    TxtHdrs(4) = OHEADER.Value("DOC_DATE")

    TxtHdrs(5) = OHEADER.Value("CO_CODE")

Else

    MsgBox (ORETURN.Columns("MESSAGE").Value(1))

End If

End Sub

oliver_wurm
Active Participant
0 Kudos

Hi Farrukh,

I'm sorry, I'm an ABAPer .

Regards

Oliver

Former Member
0 Kudos

there is a little ABAP in your visual basic .

When you debugg your code, does it fill the values?

Former Member
0 Kudos

No, it doesn't fill. gives error.

I need to know how to invoke GetDetail1 method for fetching a specified PO number details (in any language not just VB)

I used following method with just two parameters. Where the first parameter assuming to be both import/export type and containing the PO Number in its field for which details are requested.

BOORDER.GetDetail1 PoHeader:=OHEADER, Return:=ORETURN


Thanks

Former Member
0 Kudos

Hi Farrukh,

I am not an VB expert but I believe you are passing passing the PO number via this statement.

Set BOORDER = BAPICTRL.GetSAPObject("PurchaseOrder") and then


OHEADER.Value("PURCH_NO") = Text2   ' Text2=Find this PO Detail .


Text 2 is the PO number and is being used an input.


Right?


Please note all the field values are named in UPPERCASE send them in UPPERCASE.


Also OHEDER is referencing Structure "PoHeader". It is "POHEADER" again in upper case in  and it is an exporting structure which you will get back after the call so you cannot use it to pass the PO number


Send the PO number in the Importing field  "PURCHASEORDER". You get the Details back in structure  POHEADER. If you need other info first check with somebody in SAP side via transaction SE37 for the correct field names


R

Former Member
0 Kudos

Hi,

Thanks everyone for your inputs.

I am using following statement to call the function,

The variable strFindPO contains the PO number whose details are requested

The statement BOORDER.GetDetail1 is used to invoke the function and the parameters are passed to it,


strFindPO = "5200000001"

BOORDER.GetDetail1  PURCHASEORDER:=strFindPO, POHEADER:=OHEADER, RETURN:=ORETURN

The system is returning the message that named argument not found. Please let me know if i am correctly invoking the function. Any example of this function in any programming language will be appreciated.

Thanks.

Former Member
0 Kudos

Hi Farrukh,

Here you go. In ABAP 🙂

DATA : ls_poheader TYPE bapimepoheader.

DATA : lt_return TYPE bapiret2_t.

CALL FUNCTION 'BAPI_PO_GETDETAIL1'

   EXPORTING

     purchaseorder      = '2000011131'

   IMPORTING

     poheader           = ls_poheader

   TABLES

     return             = lt_return.

WRITE : / ls_poheader-comp_code.


R