Application Development 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: 

POSTING INVOICE THROUGH MIRO

Former Member
0 Kudos

Hi every body,

I am trying to post the invoice using the bapi

BAPI_INCOMINGINVOICE_CREATE

But it is sending the error message

<b>enter a reference to valid goods receipt</b>

Plz tell me what I have to do for this.

Thanks in advance

Srinivas.

1 ACCEPTED SOLUTION

Former Member
0 Kudos

Hi

Always Incoming Invoice has to be created against a delivery or GR

enter that doc number

Regards

Anji

2 REPLIES 2

Former Member
0 Kudos

Hi

Always Incoming Invoice has to be created against a delivery or GR

enter that doc number

Regards

Anji

0 Kudos

How to find that doc.no.

this item was sum of different meterial documents values , which doc.no I have to give

as a reference? which table contains this information.

I need to post the planned delivery cost items

I am using the following code . is it correct or not plz check and guide me

they will give the flat file containing that

purchase order

item no

condition type

and vendor number

REPORT ZBAPI_MIRO .

tables: ekko,ekbe,ekpo,lfa1,EKBZ.

data: itemdata like BAPI_INCINV_CREATE_ITEM occurs 0 with header line,

headerdata like BAPI_INCINV_CREATE_HEADER occurs 0 with header line,

return like BAPIRET2 occurs 0 with header line,

DOC_NO LIKE BAPI_INCINV_FLD-INV_DOC_NO,

FISC_YEAR LIKE BAPI_INCINV_FLD-FISC_YEAR.

DATA:error_flag.

data: begin of itab occurs 0,

p_order(10) type N,

p_item like ekpo-ebelp,

p_ctype like konv-kschl,

p_lifnr like ekko-lifnr,

end of itab.

data: begin of it_doc occurs 0,

DOC_NO LIKE BAPI_INCINV_FLD-INV_DOC_NO,

p_order like ekko-ebeln,

end of it_doc.

PARAMETERS: fn LIKE rlgrap-filename OBLIGATORY.

DATA: FN1 TYPE STRING,

l .

AT SELECTION-SCREEN ON VALUE-REQUEST FOR fn. "p_file.

CALL FUNCTION 'F4_FILENAME'

EXPORTING

field_name = 'FN'

IMPORTING

file_name = fn.

START-OF-SELECTION.

FN1 = FN.

PERFORM upload.

  • parameters: p_order like ekko-ebeln,

  • p_item like ekpo-ebelp,

  • p_ctype like konv-kschl,

  • p_lifnr like ekko-lifnr.

loop at itab.

select single * from ekbz where ebeln = itab-p_order

and ebelp = itab-p_item

and kschl = itab-p_ctype

and bewtp = 'F'.

select single * from ekpo where ebeln = itab-p_order

and ebelp = itab-p_item.

SELECT SINGLE * FROM LFA1 WHERE LIFNR = itab-P_LIFNR.

headerdata-INVOICE_IND = 'X'.

headerdata-DOC_TYPE = 'KR'.

headerdata-DOC_DATE = ekbz-budat.

headerdata-PSTNG_DATE = SY-DATUM.

headerdata-REF_DOC_NO = itab-P_ORDER.

headerdata-COMP_CODE = 'HPL'.

headerdata-DIFF_INV = itab-p_lifnr.

headerdata-CURRENCY_ISO = ekbz-waers.

headerdata-GROSS_AMOUNT = ekbz-wrbtr.

headerdata-BLINE_DATE = SY-DATUM.

headerdata-DEL_COSTS_TAXC = 'V0'.

headerdata-PO_REF_NO = itab-P_ORDER.

headerdata-bus_area = 'OTHR'.

headerdata-ITEM_TEXT = LFA1-NAME1.

*headerdata-HEADER_TXT = .

headerdata-ALLOC_NMBR = itab-P_ORDER.

APPEND HEADERDATA.

  • CLEAR HEADERDATA.

itemdata-INVOICE_DOC_ITEM = '00001' .

itemdata-PO_NUMBER = itab-P_ORDER.

itemdata-PO_ITEM = itab-P_ITEM.

itemdata-REF_DOC = ekbz-belnr.

itemdata-REF_DOC_YEAR = ekbz-gjahr.

itemdata-REF_DOC_IT = itab-P_ITEM.

itemdata-TAX_CODE = 'V0'.

itemdata-ITEM_AMOUNT = ekbz-wrbtr.

itemdata-QUANTITY = ekbz-menge.

itemdata-PO_UNIT = ekpo-meins.

itemdata-PO_PR_UOM = ekpo-meins.

itemdata-COND_TYPE = itab-P_CTYPE.

*itemdata-ITEM_TEXT = .

append itemdata.

  • clear itemdata.

CALL FUNCTION 'BAPI_INCOMINGINVOICE_CREATE'

EXPORTING

HEADERDATA = HEADERDATA

IMPORTING

INVOICEDOCNUMBER = DOC_NO

FISCALYEAR = FISC_YEAR

TABLES

ITEMDATA = ITEMDATA

  • ACCOUNTINGDATA = I_ACCOUNTINGDATA

  • TAXDATA = I_TAX

RETURN = RETURN.

if sy-subrc <> 0.

message e999(re) with 'Problem occured'.

else.

loop at return.

if not return is initial.

  • clear bapi_retn_info.

  • move-corresponding return to bapi_retn_info.

if return-type = 'A' or return-type = 'E'.

error_flag = 'X'.

endif.

  • append bapi_retn_info.

endif.

endloop.

if error_flag = 'X'.

message e999(re) with 'Problem occured'.

rollback work.

else.

  • Return Table from BAPI call is empty

CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'

EXPORTING

WAIT = 'X'

IMPORTING

RETURN = RETURN.

  • write:/ 'Document no :', doc_no.

it_doc-doc_no = doc_no.

it_doc-p_order = itab-p_order.

append it_doc.

endif.

endif.

endloop.

loop at it_doc.

write:/ 'document no:' , it_doc-doc_no, 'p.order:' , it_doc-p_order.

endloop.

&----


*& Form upload

&----


  • text

----


  • --> p1 text

  • <-- p2 text

----


form upload .

CALL function 'GUI_UPLOAD'

exporting

filename = FN1

FILETYPE = 'ASC'

  • HAS_FIELD_SEPARATOR = ' '

  • HEADER_LENGTH = 0

  • READ_BY_LINE = 'X'

  • DAT_MODE = ' '

  • CODEPAGE = ' '

  • IGNORE_CERR = ABAP_TRUE

  • REPLACEMENT = '#'

  • CHECK_BOM = ' '

  • NO_AUTH_CHECK = ' '

  • IMPORTING

  • FILELENGTH =

  • HEADER =

tables

data_tab = ITAB

  • EXCEPTIONS

  • FILE_OPEN_ERROR = 1

  • FILE_READ_ERROR = 2

  • NO_BATCH = 3

  • GUI_REFUSE_FILETRANSFER = 4

  • INVALID_TYPE = 5

  • NO_AUTHORITY = 6

  • UNKNOWN_ERROR = 7

  • BAD_DATA_FORMAT = 8

  • HEADER_NOT_ALLOWED = 9

  • SEPARATOR_NOT_ALLOWED = 10

  • HEADER_TOO_LONG = 11

  • UNKNOWN_DP_ERROR = 12

  • ACCESS_DENIED = 13

  • DP_OUT_OF_MEMORY = 14

  • DISK_FULL = 15

  • DP_TIMEOUT = 16

  • OTHERS = 17

.

endform. " upload