‎2008 Jan 10 5:53 AM
Dear all,
I am using this BAPI for doing MIRO transaction for iNcoming Invoice. In headerdata I am seeing Business Place field. Can somebody tell me whts the field for Section Code?
Thanks.
‎2008 Jan 10 5:59 AM
Hi Vinod,
Check this, it will help u.
Invoice data is sent by the vendors in a text file and an inbound
interface is required to create Vendor Invoices in SAP.
The file contains the Purchase Order information, material quantity
received from vendor along with the amount.
Here the requirement becomes a little complex as there might be
several ocuurences of same Purchase Order item in one invoice.
-
Only a incomplete sample coding is given here and it can only be used
as a base for writing a program.
-
-
Populate internal Table I_ITAB from the data uploaded
from text data file.
*......
*......
-
Populate Item Table from item data in data file
*......
*......
Processing for header records of data file.
set up header data for BAPI call.
Check whwther it's an Incoice or Credit Memo.
And populate Invoice indicator accordingly.
IF I_ITAB-TRANS EQ '-'.
I_HEADER-INVOICE_IND = C_X.
ELSE.
CLEAR I_HEADER-INVOICE_IND.
ENDIF.
I_HEADER-PSTNG_DATE = I_ITAB-BUDAT.
I_HEADER-DOC_DATE = I_ITAB-BLDAT.
I_HEADER-CURRENCY = W_WAERS.
I_HEADER-GROSS_AMOUNT = I_ITAB-DMBTR.
I_HEADER-COMP_CODE = I_ITAB-BUKRS.
I_HEADER-HEADER_TXT = I_ITAB-SGTXT.
I_HEADER-REF_DOC_NO = I_ITAB-XBLNR.
IF NOT I_ITAB-INV_REC_DATE IS INITIAL.
I_HEADER-INV_REC_DATE = I_ITAB-INV_REC_DATE.
ELSE.
I_HEADER-INV_REC_DATE = I_ITAB-BLDAT.
ENDIF.
I_HEADER-PYMT_METH = I_ITAB-ZLSCH.
APPEND I_HEADER.
*....
*....
-
Populate Item Table from item data in data file
lv_count = 0.
LOOP AT I_ITAB.
Processing for header records of data file.
lv_count = lv_count + 1.
...........
...........
Item Data
I_ITEM-INVOICE_DOC_ITEM = lv_COUNT.
I_ITEM-PO_NUMBER = I_ITAB-EBELN.
I_ITEM-PO_ITEM = I_ITAB-EBELP.
I_ITEM-TAX_CODE = I_ITAB-MWSKZ2.
I_ITEM-ITEM_AMOUNT = I_ITAB-NETWR.
Populate quantities if not a blanket order
IF I_ITAB-BLANKET EQ SPACE.
I_ITEM-QUANTITY = I_ITAB-MENGE.
PERFORM GET_MEINS USING I_ITAB-EBELN " Use table EKPO
I_ITAB-EBELP
CHANGING I_ITEM-PO_UNIT.
I_ACCOUNTINGDATA-PO_UNIT = I_ITEM-PO_UNIT.
IF I_ITEM-QUANTITY EQ 0.
I_ITEM-PO_UNIT = SPACE.
ENDIF.
ENDIF.
Item Text
I_ITEM-ITEM_TEXT = I_ITAB-ITEM_TEXT.
APPEND I_ITEM.
Populate Accounting Data
IF I_ITAB-BLANKET EQ SPACE.
I_ACCOUNTINGDATA-INVOICE_DOC_ITEM = lv_COUNT.
I_ACCOUNTINGDATA-SERIAL_NO = '01'.
I_ACCOUNTINGDATA-TAX_CODE = I_ITAB-MWSKZ2.
I_ACCOUNTINGDATA-ITEM_AMOUNT = I_ITAB-NETWR.
SELECT SINGLE SAKTO KOSTL VBELN VBELP ANLN1 ANLN2 DABRZ
FISTL GEBER GRANT_NBR GSBER IMKEY KOKRS KSTRG PAOBJNR
PRCTR PS_PSP_PNR AUFNR MENGE
FROM EKKN
INTO (I_ACCOUNTINGDATA-GL_ACCOUNT, I_ACCOUNTINGDATA-COSTCENTER,
I_ACCOUNTINGDATA-SD_DOC, I_ACCOUNTINGDATA-SDOC_ITEM,
I_ACCOUNTINGDATA-ASSET_NO, I_ACCOUNTINGDATA-SUB_NUMBER,
I_ACCOUNTINGDATA-REF_DATE, I_ACCOUNTINGDATA-FUNDS_CTR,
I_ACCOUNTINGDATA-FUND, I_ACCOUNTINGDATA-GRANT_NBR,
I_ACCOUNTINGDATA-BUS_AREA, I_ACCOUNTINGDATA-RL_EST_KEY,
I_ACCOUNTINGDATA-CO_AREA, I_ACCOUNTINGDATA-COSTOBJECT,
I_ACCOUNTINGDATA-PROFIT_SEGM_NO, I_ACCOUNTINGDATA-PROFIT_CTR,
I_ACCOUNTINGDATA-WBS_ELEM, I_ACCOUNTINGDATA-ORDERID,
I_ACCOUNTINGDATA-QUANTITY)
WHERE EBELN EQ I_ITAB-EBELN
AND EBELP EQ I_ITAB-EBELP
AND ZEKKN EQ '01'.
IF EKKO-BSART NE 'LTV'.
CLEAR I_ACCOUNTINGDATA-QUANTITY.
CLEAR I_ACCOUNTINGDATA-PO_UNIT.
ENDIF.
APPEND I_ACCOUNTINGDATA.
ENDIF.
*.....
*.....
ENDLOOP.
-
The following coding is to solve the problem
mentioned in OSS Note 518338.
Same PO item within several invoice items.
SORT I_ITEM BY PO_NUMBER PO_ITEM.
LOOP AT I_ITEM.
ON CHANGE OF I_ITEM-PO_NUMBER OR I_ITEM-PO_ITEM.
W_COUNTER = 1.
LOOP AT I_ITEM WHERE PO_NUMBER = I_ITEM-PO_NUMBER
AND PO_ITEM = I_ITEM-PO_ITEM.
IF W_COUNTER EQ 1.
I_ACCOUNTINGDATA-SERIAL_NO = '01'.
I_ACCOUNTINGDATA-XUNPL = ' '.
ELSE.
I_ACCOUNTINGDATA-SERIAL_NO = ' '.
I_ACCOUNTINGDATA-XUNPL = 'X'.
ENDIF.
MODIFY I_ACCOUNTINGDATA
TRANSPORTING SERIAL_NO XUNPL
WHERE INVOICE_DOC_ITEM = I_ITEM-INVOICE_DOC_ITEM.
W_COUNTER = W_COUNTER + 1.
ENDLOOP.
To solve the repetition of PO item in subsequent invoices.
ELSEIF SY-TABIX EQ 1.
W_COUNTER = 1.
LOOP AT I_ITEM WHERE PO_NUMBER = I_ITEM-PO_NUMBER
AND PO_ITEM = I_ITEM-PO_ITEM.
IF W_COUNTER EQ 1.
I_ACCOUNTINGDATA-SERIAL_NO = '01'.
I_ACCOUNTINGDATA-XUNPL = ' '.
ELSE.
I_ACCOUNTINGDATA-SERIAL_NO = ' '.
I_ACCOUNTINGDATA-XUNPL = 'X'.
ENDIF.
MODIFY I_ACCOUNTINGDATA
TRANSPORTING SERIAL_NO XUNPL
WHERE INVOICE_DOC_ITEM = I_ITEM-INVOICE_DOC_ITEM.
W_COUNTER = W_COUNTER + 1.
ENDLOOP.
ENDON.
ENDLOOP.
Changes over for OSS Note 518338.
SORT I_ITEM BY INVOICE_DOC_ITEM PO_NUMBER PO_ITEM.
CALL FUNCTION 'BAPI_INCOMINGINVOICE_CREATE'
EXPORTING
HEADERDATA = I_HEADER
IMPORTING
INVOICEDOCNUMBER = W_BELNR
FISCALYEAR = W_GJAHR
TABLES
ITEMDATA = I_ITEM
ACCOUNTINGDATA = I_ACCOUNTINGDATA
TAXDATA = I_TAX
RETURN = I_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 = I_RETURN.
endif.
endif.
reward if helpful.
cheers,
Hema.
‎2008 Jan 10 6:05 AM
Hi Hema,
I have already seen this code. But here also I am not finding that field. Can you tell me the exact field?
Thanks.
Vinod.
‎2008 Jan 10 6:07 AM
Hi vinod,
also chech this which I got from SDN for u :
Q: In the line items it did not display the field Section Code beside the Business place, with out which it did not allow me to save the document. I checked with field status Groups, it did not contain the field section code nor the Business place.
Ans: Check for the Screen Variants for Document Entry in SPRO > General Ledger Accounting > Business Transactions > GL Account Posting > Carry out and Check Document Settings > Screen Variants for Document Entry.
cheers,
Hema.
‎2008 Jan 10 6:27 AM
Thanks Hema,
The above setting is ok in system.
Could u plz guide for any other soln.
Vinod.
‎2008 Jan 10 7:43 AM
Please reply.
This has not solved my problem.
Thanks in advance.
‎2010 Aug 31 9:42 AM
Hi,
I faced the same issue while trying to post Invoice through "BAPI_INCOMINGINVOICE_CREATE" as Section Code was made a mandatory field.
To solve this problem I did the following:
1. Declared a field ZZSECCO in the structure "BAPI_INCINV_CREATE_HEADER".
2. Then created an implicit enhancement point in subroutine "RBKPV_FILL_FROM_HEADERDATA" present inside the subroutine "RBKPV_FILL" in the BAPI_INCOMINGINVOICE_CREATE".
Then I moved the contents of field zzsecco, which i passed to HEADER data during the BAPI call, to e_rbkpv-secco:
enhancement 27 zxxxx. "active version
move i_headerdata-zzsecco to e_rbkpv-secco.
endenhancement.
Best Regards
Tejaswini
‎2010 Oct 28 8:27 AM
Hi Vinod ,
Can you tell me how you solve this Problem of Section Code .
Regards
Deepak.