2010 Jun 09 4:17 PM
Hi,
Currently I am working on a requirement to post an Incoming Invoice and using the BAPI 'BAPI_INCOMINGINVOICE_CREATE' to upload the data into SAP.
In the Input file(to be uploaded to SAP) I was not getting details like REF_DOC(Document No. of a Reference Document), REF_DOC_YEAR(Document No. of a Reference Document) and REF_DOC_IT(Item of a Reference Document) and so I need to derive these 3 fields and feed into the interface parameter 'ITEMDATA' of the BAPI.
If I do not give any input values to these 3 fields, BAPI was throwing a message saying that, the mandatory fields were missing in the structure 'ITEMDATA'. So I need to pass these 3 fields mandatorily.
I have in the input fields PO Number and PO item( only from these 2 fields ) and I need to get the above fields.
So please provide me inputs as how I can get these 3 fields from the PO number and PO item.
Thanks for the help in advance.
Regards,
Vishnu.
2010 Jun 10 6:34 AM
Hi Vishnu,
The code mentioned by Vinod is OK, but You will also have to check whether the GR has not been cancelled. For this you need to add selection criteria of
Fetch the latest GR date (movement type will be 101)
select max( budat )
into w_budat
from ekbe
where ebeln = <Po number>
and ebelp = <po Line Item>
and vgabe = '1'
and bwart = '101'.
Fetch the latest material document
Select gjahr "(Reference document year)
belnr "(Reference document No)
buzei "(Reference document item)
from ekbe
where ebeln = <Po number>
and ebelp = <po Line Item>
and vgabe = '1'
and budat = w_budat .
Regards,
Birendra
2010 Jun 09 4:21 PM
Im not sure about this,
Can you check the table EKBE , it holds the reference document no and item no.
Later refer it with BSEG.
2010 Jun 10 6:17 AM
Hi,
As mentioned by Keshav, Extract the Reference document (MIGO) information from table EKBE
Select gjahr "(Reference document year)
belnr "(Reference document No)
buzei "(Reference document item)
from ekbe
where ebeln = <Po number>
and ebelp = <po Line Item>
and vgabe = '1'.
Regards
Vinod
2010 Jun 10 6:34 AM
Hi Vishnu,
The code mentioned by Vinod is OK, but You will also have to check whether the GR has not been cancelled. For this you need to add selection criteria of
Fetch the latest GR date (movement type will be 101)
select max( budat )
into w_budat
from ekbe
where ebeln = <Po number>
and ebelp = <po Line Item>
and vgabe = '1'
and bwart = '101'.
Fetch the latest material document
Select gjahr "(Reference document year)
belnr "(Reference document No)
buzei "(Reference document item)
from ekbe
where ebeln = <Po number>
and ebelp = <po Line Item>
and vgabe = '1'
and budat = w_budat .
Regards,
Birendra
2010 Jun 10 8:26 AM
Hi,
Put Po number and Item in MSEG Table. You will get all required data.
Please refer MSEG Table for MIGO data.
Thanks
Eswar