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

Help Required - BAPI_INCOMINGINVOICE_CREATE

Former Member
0 Likes
4,716

Hi - I am executing BAPI_INCOMINGINVOICE_CREATE from Java. I am getting an error that says "For document type RE, an entry is required in field Reference". I am not able to decipher what the Reference field is. At the moment, I am passing values for the following attributes:

HeaderData:

INVOICE_IND = X

DOC_DATE = 2009-01-20

PSTNG_DATE = 2010-05-20

COMP_CODE = 1000

CURRENCY = EUR

GROSS_AMOUNT = 200.0000

PMNTTRMS = 0001

PO_REF_NO = 1000

INV_REF_NO = IA-BA-0910

BUS_AREA = 1000

BUSINESS_PLACE = 1000

ITEMDATA

INVOICE_DOC_ITEM = 000001

PO_NUMBER = 4500017251

PO_ITEM = 00010

TAX_CODE = VN

ITEM_AMOUNT = 200.0000

QUANTITY = 10.000

PO_UNIT = KG

The response I get is

- <table name="RETURN">

- <row id="0">

<field name="TYPE">E</field>

<field name="ID">F5</field>

<field name="NUMBER">480</field>

<field name="MESSAGE">For document type RE, an entry is required in field Reference</field>

<field name="LOG_NO" />

<field name="LOG_MSG_NO">000000</field>

<field name="MESSAGE_V1">RE</field>

<field name="MESSAGE_V2">Reference</field& gt;

<field name="MESSAGE_V3" />

<field name="MESSAGE_V4" />

<field name="PARAMETER" />

<field name="ROW">0</field>

<field name="FIELD" />

<field name="SYSTEM">T90CLNT090</field>

</row>

</table>

How do I identify what attribute is being missed? My requirement is to post the invoice using this BAPI, do a BAPI_TRANSACTION_COMMIT and retrieve the SAP REF NO or INV_REF_NO.

Please help.

Laksh

1 ACCEPTED SOLUTION
Read only

former_member206439
Contributor
0 Likes
3,272

Hi ,

When you got OBF4 Tcode.

Go to OBF4. Select the invoice document type it is usually by default taken as RE and some time it is takenb as RN by the user if the pursue to have cash discount. SO to both this document type you can assign the reference fiels as required

in this BAPI when your entering the data .

in Header section you can find one field name - Reference document number

(REF_DOC_NO field)

You have to pass this value because of the above mandatory field set in OBF4.

This field is same as when your posting Invoice from MIRO under basic data tab you can see this field .

Thanks

Naresh

12 REPLIES 12
Read only

Former Member
0 Likes
3,272

Moderator message - Welcome to SCN. Try HEADERDATA-REF_DOC_NO Rob

Read only

former_member206439
Contributor
0 Likes
3,273

Hi ,

When you got OBF4 Tcode.

Go to OBF4. Select the invoice document type it is usually by default taken as RE and some time it is takenb as RN by the user if the pursue to have cash discount. SO to both this document type you can assign the reference fiels as required

in this BAPI when your entering the data .

in Header section you can find one field name - Reference document number

(REF_DOC_NO field)

You have to pass this value because of the above mandatory field set in OBF4.

This field is same as when your posting Invoice from MIRO under basic data tab you can see this field .

Thanks

Naresh

Read only

0 Likes
3,272

The same error persists. How do we decipher the error being returned? Is there any way I can get the exact field name missing?

Laksh

Read only

0 Likes
3,272

Didn't I give you the exact field name??

Rob

Read only

0 Likes
3,272

The error message saying you that Reference field is missing.

In MIGO you can find the Reference number in the header part only.

Return part will give max the description of the error not always field names.

Read only

0 Likes
3,272

Hi,

Implement the solution given by Rob.

Regards

Vinod

Read only

0 Likes
3,272

Thanks Rob, However when I pass a value to REF_DOC_NO, I get "Document or line item does not exist for invoice reference". I actually cannot find any value for REF_DOC_NO when I view the PO details. What am I missing? I am a Java programmer and entirely new to SAP - my questions may be pretty basic, apologies for this.

Laksh

Read only

0 Likes
3,272

Hi,

I don't think the field 'REF_DOC_NO' validates any reference data. Reference PO number and Line item is to be passed in the structure fields ITEMDATA-PO_NUMBER and ITEMDATA-PO_ITEM.

Regards

Vinod

Read only

0 Likes
3,272

I am passing ITEMDATA-PO_NUMBER and ITEMDATA-PO_ITEM - they match the detail available on the PO. Here is the entire method:

JCoFunction function = connect.getFunction("BAPI_INCOMINGINVOICE_CREATE");

function.getImportParameterList().getStructure("HEADERDATA").setValue("INVOICE_IND", "X");

function.getImportParameterList().getStructure("HEADERDATA").setValue("DOC_DATE", "2009-09-21");

function.getImportParameterList().getStructure("HEADERDATA").setValue("PSTNG_DATE", "2010-05-21");

function.getImportParameterList().getStructure("HEADERDATA").setValue("COMP_CODE", "1000");

function.getImportParameterList().getStructure("HEADERDATA").setValue("CURRENCY", "EUR");

function.getImportParameterList().getStructure("HEADERDATA").setValue("GROSS_AMOUNT", "10000.0000");

function.getImportParameterList().getStructure("HEADERDATA").setValue("PMNTTRMS", "0001");

function.getImportParameterList().getStructure("HEADERDATA").setValue("INV_REF_NO", "IA-BA-0910-05628");

function.getImportParameterList().getStructure("HEADERDATA").setValue("BUS_AREA", "1000");

function.getImportParameterList().getStructure("HEADERDATA").setValue("REF_DOC_NO", "TESTING DOWN PAY");

function.getTableParameterList().getTable("ITEMDATA").appendRow();

function.getTableParameterList().getTable("ITEMDATA").setValue("INVOICE_DOC_ITEM", "000001");

function.getTableParameterList().getTable("ITEMDATA").setValue("PO_NUMBER", "4500017363"); function.getTableParameterList().getTable("ITEMDATA").setValue("PO_ITEM", "00010");

function.getTableParameterList().getTable("ITEMDATA").setValue("ITEM_AMOUNT", "10000.0000");

function.getTableParameterList().getTable("ITEMDATA").setValue("TAX_CODE", "VN");

function.getTableParameterList().getTable("ITEMDATA").setValue("PO_UNIT_ISO", "PCE");

function.getTableParameterList().getTable("ITEMDATA").setValue("QUANTITY", "10");

All the values match what I have on the PO.

Laksh

Read only

0 Likes
3,272

Hi,

Document or line item does not exist for invoice reference

I feel the problem is related to the value you are passing in the structure field HEARDATA-INV_REF_NO. Try to call the bapi after commenting the line which pass value to this field.

Regards

Vinod

Read only

0 Likes
3,272

Thanks a lot! It was a copy/paste issue.

this worked, Just missed reading into plain english error should have looked for Invoice reference.

Lakshman

Read only

0 Likes
3,272

Hi Vinod!

         Below is my code! my exact requirement is, i have created Sales order success fully,

Now i want to fetch the invoice no as well delivery invoice amount by using customer no.. can you pls help me?

  I don;t know  am going in a right way?  pls advice me!

        try {

            function = this.createFunction("BAPI_INCOMINGINVOICE_CREATE");

            if (function == null) {

                System.exit(1);

            }

           

            mConnection.execute(function);

     mStructure = function.getImportParameterList().getStructure("HEARDATA-INV_REF_NO");

 

      String doc = "ZHAT";                                

     

      mStructure.setValue(doc,"DOC_TYPE");

     

      //mStructure.setv

      mStructure.setValue("1000","SALES_ORG");

      mStructure.setValue("10","DISTR_CHAN");

      mStructure.setValue("10","DIVISION");

          codes = function.getTableParameterList().getTable("VBRK");

           

           

           

            for (int loop = 0; loop < codes.getNumRows(); loop++)

            {

                myArrList.add(codes.getValue("KUNAG"));

                codes.nextRow();

            }

            System.out.println( myArrList);

            if (myArrList.isEmpty()) {

                System.out.println("No data retirved for selection criteria");   

                System.exit(1);

            }

Regards,

Raja M