03-05-2010 11:33 PM
I wrote a program code to post a document for F-43 transaction using a BAPI.
Unfortunately, the BAPI comes back with an error message
1 E RW 609 Error in document: BKPF 1900022387208 2010 SYS01 1900022387208 2010
2 E RW 628 Incorrect entry in field OBJ_TYPE: BKPF DOCUMENTHEADER 1 OBJ_TYPE
Any help would be appreciated.
REPORT z_test_f44 NO STANDARD PAGE HEADING LINE-COUNT 65 LINE-SIZE 132
MESSAGE-ID zfi.
TABLES: bsik, t003.
TYPES:
BEGIN OF tp_tab_bsik,
bukrs TYPE bukrs,
lifnr TYPE lifnr,
gjahr TYPE gjahr,
budat TYPE budat,
bldat TYPE bldat,
blart TYPE blart,
bschl TYPE bschl,
END OF tp_tab_bsik.
SELECTION-SCREEN:BEGIN OF BLOCK blck01 WITH FRAME TITLE text-001.
PARAMETERS:
p_per(2) TYPE c DEFAULT sy-datum+4(2),
p_dt LIKE sy-datum DEFAULT sy-datum,
p_hkont TYPE hkont DEFAULT '105010',
p_waers LIKE bkpf-waers DEFAULT 'USD',
p_blart LIKE bkpf-blart DEFAULT 'KR',
p_xblnr LIKE bkpf-xblnr DEFAULT 'V01',
p_xblnr1 LIKE bkpf-xblnr DEFAULT 'A01',
p_amt LIKE bseg-wrbtr DEFAULT '10.00',
p_bukrs LIKE bkpf-bukrs DEFAULT '208',
p_lifnr LIKE lfa1-lifnr DEFAULT '1000165'.
SELECTION-SCREEN:END OF BLOCK blck01.
*----------------end of selection parameters-----------------------*
*------------------START OF SELECTION----------------------------------*
START-OF-SELECTION.
PERFORM process_data. "Posting using F-44(Bapi)
*&---------------------------------------------------------------------*
*& Form process_data
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
FORM process_data.
DATA:
l_documentheader LIKE bapiache09,
l_accountgl LIKE bapiacgl09 OCCURS 2 WITH HEADER LINE,
l_vendoritem LIKE bapiacap09 OCCURS 2 WITH HEADER LINE,
l_currencyamount LIKE bapiaccr09 OCCURS 2 WITH HEADER LINE,
l_currencytype LIKE bapiaccr09-currency_iso,
l_return LIKE bapiret2 OCCURS 5 WITH HEADER LINE,
l_obj_type LIKE bapiache02-obj_type,
l_obj_key LIKE bapiache02-obj_key,
l_obj_sys LIKE bapiache02-obj_sys,
l_obj_sys_1 LIKE tbdls-logsys,
ls_t003 TYPE t003,
l_belnr TYPE bkpf-belnr,
l_awtyp LIKE acchd-awtyp, " Anwendungsreferenz
l_awref LIKE acchd-awref, "
l_aworg LIKE acchd-aworg, "
l_awsys LIKE acchd-awsys, "
l_awkey LIKE bkpf-awkey. "
BREAK-POINT.
CLEAR:
l_documentheader, l_vendoritem, l_accountgl,
l_currencyamount, l_return.
REFRESH:l_vendoritem, l_currencyamount, l_return.
* Get Your Logical System
CALL FUNCTION 'OWN_LOGICAL_SYSTEM_GET'
IMPORTING
own_logical_system = l_obj_sys_1
EXCEPTIONS
own_logical_system_not_defined = 1
OTHERS = 2.
* Number Range Information
SELECT SINGLE *
FROM t003
INTO CORRESPONDING FIELDS OF t003
WHERE blart = p_blart.
* Get the additional Number Range Details.
CALL FUNCTION 'FAGL_GET_NUMBER_RANGE_FOR_PN'
EXPORTING
i_rldnr = '0L' "Ledger
i_blart = p_blart
IMPORTING
es_t003 = ls_t003
EXCEPTIONS
error_message = 1.
* Get the next BELNR
t003-numkr = ls_t003-numkr.
CALL FUNCTION 'RF_GET_DOCUMENT_NUMBER'
EXPORTING
company = p_bukrs
range = t003-numkr
year = sy-datum+0(4)
IMPORTING
document_number = l_belnr.
* Create Reference Keys
CALL FUNCTION 'FI_REFERENCE_CREATE'
EXPORTING
i_awtyp = 'BKPF '
i_bukrs = p_bukrs
i_gjahr = sy-datum+0(4)
i_belnr = l_belnr
IMPORTING
e_awtyp = l_awtyp
e_awref = l_awref
e_aworg = l_aworg
e_awkey = l_awkey
e_awsys = l_awsys
EXCEPTIONS
object_type = 1
missing_parameter = 2
OTHERS = 3.
IF sy-subrc <> 0.
MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ENDIF.
* Build Document Header
l_documentheader-obj_type = l_awtyp. "'BKPF'.
l_documentheader-obj_key = l_awkey.
l_documentheader-obj_sys = l_obj_sys_1.
l_documentheader-bus_act = 'RFBU'.
l_documentheader-ac_doc_no = l_belnr.
l_documentheader-username = sy-uname.
l_documentheader-comp_code = p_bukrs.
l_documentheader-fis_period = p_per.
l_documentheader-doc_date = p_dt.
l_documentheader-pstng_date = sy-datum.
l_documentheader-fisc_year = sy-datum+0(4).
l_documentheader-doc_type = p_blart.
l_documentheader-ref_doc_no = p_xblnr.
CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT'
EXPORTING
input = p_hkont
IMPORTING
output = p_hkont.
* G/L Item
l_accountgl-itemno_acc = '000000001'.
* l_accountgl-acct_key = 'RFBU'.
l_accountgl-gl_account = p_hkont.
l_accountgl-comp_code = p_bukrs.
l_accountgl-pstng_date = sy-datum.
l_accountgl-doc_type = p_blart.
APPEND l_accountgl. CLEAR l_accountgl.
* G/L Item $$$s
* Posting Key 50
l_currencyamount-itemno_acc = '000000001'.
l_currencyamount-currency_iso = p_waers.
l_currencyamount-currency = p_waers.
l_currencyamount-amt_doccur = p_amt.
APPEND l_currencyamount. CLEAR l_currencyamount.
* Vendor Item
l_vendoritem-itemno_acc = '000000002'.
* l_accountgl-acct_key = 'RFBU'.
l_vendoritem-vendor_no = p_lifnr.
l_vendoritem-comp_code = p_bukrs.
APPEND l_vendoritem. CLEAR l_vendoritem.
* Vendor Item $$$s
* Posting Key 31
l_currencyamount-itemno_acc = '000000002'.
l_currencyamount-currency_iso = p_waers.
l_currencyamount-currency = p_waers.
l_currencyamount-amt_doccur = p_amt.
l_currencyamount-amt_doccur = l_currencyamount-amt_doccur * -1.
APPEND l_currencyamount. CLEAR l_currencyamount.
BREAK-POINT.
CALL FUNCTION 'BAPI_ACC_DOCUMENT_CHECK'
EXPORTING
documentheader = l_documentheader
TABLES
accountgl = l_accountgl
accountpayable = l_vendoritem
currencyamount = l_currencyamount
return = l_return.
* CALL FUNCTION 'BAPI_ACC_DOCUMENT_POST'
* EXPORTING
* documentheader = l_documentheader
* IMPORTING
* obj_key = l_obj_key
* TABLES
* accountgl = l_accountgl
* accountpayable = l_vendoritem
* currencyamount = l_currencyamount
* return = l_return.
BREAK-POINT.
* CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'.
ENDFORM. "process_data
03-06-2010 12:31 AM
First guess, since I don't have access to FI....the message would indicate to me that I have supplied a value to the OBJ_TYPE field that is not an "acceptable", e.g., configured value for OBJ_TYPE. Go to SE11, look up the OBJ_TYPE, forward navigate to the domain, and look for a value range (or more likely) a config table. Look at the entries in that T table.... I think it's likely that you're supplying a value in your input that has not been defined to SAP.
03-06-2010 12:31 AM
First guess, since I don't have access to FI....the message would indicate to me that I have supplied a value to the OBJ_TYPE field that is not an "acceptable", e.g., configured value for OBJ_TYPE. Go to SE11, look up the OBJ_TYPE, forward navigate to the domain, and look for a value range (or more likely) a config table. Look at the entries in that T table.... I think it's likely that you're supplying a value in your input that has not been defined to SAP.
03-06-2010 1:09 AM
Actually I am using Standard SAP Function modules to generate the OBJ_TYP.
Unfortunately the "Code" tag is not working for me in this browser to align the program code correctly.
But yes, to answer your question obj_typ is correctly done.
* Create Reference Keys
call function 'FI_REFERENCE_CREATE'
exporting
i_awtyp = 'BKPF '
i_bukrs = p_bukrs
i_gjahr = sy-datum+0(4)
i_belnr = l_belnr
importing
e_awtyp = l_awtyp
e_awref = l_awref
e_aworg = l_aworg
e_awkey = l_awkey
e_awsys = l_awsys
exceptions
object_type = 1
missing_parameter = 2
others = 3.