2006 Jun 22 12:56 PM
Hi,
I've written a program to simulate transaction FBS1 using
FUNCTION 'POSTING_INTERFACE_DOCUMENT', it goes through with sy-subrc set 0, but I cannot see the document number in T_BLNTAB, the code is below, I think I have all the right Parameters.
DATA: i_msgid LIKE sy-msgid,
i_msgno LIKE sy-msgno,
i_msgty LIKE sy-msgty,
i_msgv1 LIKE sy-msgv1,
i_msgv2 LIKE sy-msgv2,
i_msgv3 LIKE sy-msgv3,
i_msgv4 LIKE sy-msgv4,
i_subrc LIKE sy-subrc.
DATA: ftpost LIKE ftpost OCCURS 0 WITH HEADER LINE,
fttax LIKE fttax OCCURS 1 WITH HEADER LINE,
blntab LIKE blntab OCCURS 1 WITH HEADER LINE.
blntab-BELNR =
*blntab-BUKRS = 2000.
*blntab-GJAHR =
Header Information first
ftpost-stype ='K'.
ftpost-count = 1.
ftpost-fnam = 'BKPF-BLDAT'.
ftpost-fval = '310506'.
ftpost-stype ='K'.
ftpost-count = 1.
ftpost-fnam = 'BKPF-BLART'.
ftpost-fval = 'SA'.
ftpost-stype ='K'.
ftpost-count = 1.
ftpost-fnam = 'BKPF-BUKRS' .
ftpost-fval = '2000' .
ftpost-stype ='K'.
ftpost-count = 1.
ftpost-fnam = 'BKPF-BUDAT' .
ftpost-fval = '310506' .
ftpost-stype ='K'.
ftpost-count = 1.
ftpost-fnam = 'BKPF-WAERS' .
ftpost-fval = 'GBP' .
ftpost-stype ='K'.
ftpost-count = 1.
ftpost-fnam = 'BKPF-XBLNR ' .
ftpost-fval = 'ACCRUAL POST' .
ftpost-stype ='K'.
ftpost-count = 1.
ftpost-fnam = 'BKPF-STGRD' .
ftpost-fval = '05' .
ftpost-stype ='K'.
ftpost-count = 1.
ftpost-fnam = 'BKPF-STODT' .
ftpost-fval = '010606'.
ftpost-stype ='K'.
ftpost-count = 1.
ftpost-fnam = 'FS006-DOCID' .
ftpost-fval = '*'.
ftpost-stype ='K'.
ftpost-count = 1.
ftpost-fnam = 'RF05A-NEWBS' .
ftpost-fval = '40'.
ftpost-stype ='K'.
ftpost-count = 1.
ftpost-fnam = 'RF05A-NEWKO' .
ftpost-fval = '476000'.
*Line Items Now
ftpost-stype ='P'.
ftpost-count = 1.
ftpost-fnam = 'BSEG-WRBTR' .
ftpost-fval = '5000' .
ftpost-stype ='P'.
ftpost-count = 1.
ftpost-fnam = 'BSEG-MWSKZ' .
ftpost-fval = 'v0' .
ftpost-stype ='P'.
ftpost-count = 1.
ftpost-fnam = 'BSEG-SGTXT' .
ftpost-fval = 'pallet of photo paper' .
ftpost-stype ='P'.
ftpost-count = 1.
ftpost-fnam = 'BDC_SUBSCR' .
ftpost-fval = 'SAPLKACB' .
ftpost-stype ='P'.
ftpost-count = 1.
ftpost-fnam = 'DKACB-FMORE' .
ftpost-fval = 'X'.
ftpost-stype ='P'.
ftpost-count = 1.
ftpost-fnam = 'COBL-KOSTL' .
ftpost-fval = '2-1000 '.
ftpost-stype ='P'.
ftpost-count = 1.
ftpost-fnam = 'COBL-FIPOS ' .
ftpost-fval = ''.
ftpost-stype ='P'.
ftpost-count = 1.
ftpost-fnam = 'BSEG-DMBE2' .
ftpost-fval = '70.42' .
ftpost-stype ='P'.
ftpost-count = 1.
ftpost-fnam = 'RF05A-NEWBS' .
ftpost-fval = '40' .
ftpost-stype ='P'.
ftpost-count = 1.
ftpost-fnam = 'RF05A-NEWKO' .
ftpost-fval = '417000'.
Item no. 2
ftpost-stype ='P'.
ftpost-count = 2.
ftpost-fnam = 'BSEG-WRBTR' .
ftpost-fval = '500' .
ftpost-stype ='P'.
ftpost-count = 2.
ftpost-fnam = 'BSEG-MWSKZ' .
ftpost-fval = 'V0'.
ftpost-stype ='P'.
ftpost-count = 2.
ftpost-fnam = 'BSEG-SGTXT' .
ftpost-fval = 'marketing assistants'.
ftpost-stype ='P'.
ftpost-count = 2.
ftpost-fnam = 'DKACB-FMORE' .
ftpost-fval = 'X'.
ftpost-stype ='P'.
ftpost-count = 2.
ftpost-fnam = 'COBL-AUFNR' .
ftpost-fval = ' 400157 '.
ftpost-stype ='P'.
ftpost-count = 2.
ftpost-fnam = 'BSEG-DMBE2' .
ftpost-fval = '7.04'.
ftpost-stype ='P'.
ftpost-count = 2.
ftpost-fnam = 'RF05A-NEWBS' .
ftpost-fval = '50' .
ftpost-stype ='P'.
ftpost-count = 2.
ftpost-fnam = 'RF05A-NEWKO' .
ftpost-fval = '89000' .
Next Line
ftpost-stype ='P'.
ftpost-count = 3.
ftpost-fnam = 'BSEG-WRBTR' .
ftpost-fval = '5500'.
ftpost-stype ='P'.
ftpost-count = 3.
ftpost-fnam = 'BSEG-MWSKZ' .
ftpost-fval = 'V0' .
ftpost-stype ='P'.
ftpost-count = 3.
ftpost-fnam = 'BSEG-SGTXT' .
ftpost-fval = 'accrual posting bala' .
*Next Line
ftpost-stype ='P'.
ftpost-count = 4.
ftpost-fnam = 'BSEG-WRBTR' .
ftpost-fval = '5500'.
ftpost-stype ='P'.
ftpost-count = 4.
ftpost-fnam = 'BSEG-MWSKZ' .
ftpost-fval = 'V0' .
ftpost-stype ='P'.
ftpost-count = 4.
ftpost-fnam = 'BSEG-SGTXT' .
ftpost-fval = 'accrual posting bala' .
ftpost-stype ='P'.
ftpost-count = 4.
ftpost-fnam = 'COBL-GSBER ' .
ftpost-fval = '1000' .
CALL FUNCTION 'POSTING_INTERFACE_DOCUMENT'
EXPORTING
i_tcode = 'FBS1'
I_SGFUNCT = ' '
I_NO_AUTH = ' '
IMPORTING
e_msgid = i_msgid
e_msgno = i_msgno
e_msgty = i_msgty
e_msgv1 = i_msgv1
e_msgv2 = i_msgv2
e_msgv3 = i_msgv3
e_msgv4 = i_msgv4
e_subrc = i_subrc
TABLES
t_blntab = blntab
t_ftpost = ftpost
t_fttax = fttax
EXCEPTIONS
account_missing = 1
company_code_missing = 2
posting_key_invalid = 3
posting_key_missing = 4
record_type_invalid = 5
transaction_code_invalid = 6
amount_format_error = 7
too_many_line_items = 8
OTHERS = 9.
.
IF sy-subrc <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
Any ideas anyone?
Many Thanks Sims
Hi Sims,
Make the highlighted change:
Pass 'C' to I_SGFUNCT ( To tell that we are doing a call transaction)
CALL FUNCTION 'POSTING_INTERFACE_DOCUMENT'
EXPORTING
i_tcode = 'FBS1'
<b>I_SGFUNCT = 'C'</b>
I_NO_AUTH = ' '
IMPORTING
e_msgid = i_msgid
e_msgno = i_msgno
e_msgty = i_msgty
e_msgv1 = i_msgv1
e_msgv2 = i_msgv2
e_msgv3 = i_msgv3
e_msgv4 = i_msgv4
e_subrc = i_subrc
TABLES
t_blntab = blntab
t_ftpost = ftpost
t_fttax = fttax
EXCEPTIONS
account_missing = 1
company_code_missing = 2
posting_key_invalid = 3
posting_key_missing = 4
record_type_invalid = 5
transaction_code_invalid = 6
amount_format_error = 7
too_many_line_items = 8
OTHERS = 9.
.
IF sy-subrc <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
Regards,
Ravi
2006 Jun 22 1:06 PM
Hi Sims,
Make the highlighted change:
Pass 'C' to I_SGFUNCT ( To tell that we are doing a call transaction)
CALL FUNCTION 'POSTING_INTERFACE_DOCUMENT'
EXPORTING
i_tcode = 'FBS1'
<b>I_SGFUNCT = 'C'</b>
I_NO_AUTH = ' '
IMPORTING
e_msgid = i_msgid
e_msgno = i_msgno
e_msgty = i_msgty
e_msgv1 = i_msgv1
e_msgv2 = i_msgv2
e_msgv3 = i_msgv3
e_msgv4 = i_msgv4
e_subrc = i_subrc
TABLES
t_blntab = blntab
t_ftpost = ftpost
t_fttax = fttax
EXCEPTIONS
account_missing = 1
company_code_missing = 2
posting_key_invalid = 3
posting_key_missing = 4
record_type_invalid = 5
transaction_code_invalid = 6
amount_format_error = 7
too_many_line_items = 8
OTHERS = 9.
.
IF sy-subrc <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
Regards,
Ravi
2006 Jun 22 1:11 PM
Hi,
Made that change, and I put in the append statement for the ITAB, but now getting
Two accounts were transferred but not BSEG-HKONT
Message no. F8 020
Diagnosis
Two accounts were transferred but not BSEG-HKONT.
This error also occurs if more than 1000 line items are transferred. In
this case, the transferred data must be distributed across several
documents.
2006 Jun 22 1:19 PM
When you call FM 'POSTING_INTERFACE_START', try to pass 'A' to parameter i_mode, run visible mode, and see what is wrong.
Regards.
2006 Jun 22 1:22 PM
2006 Jun 22 1:29 PM
Hi Sims,
Is the code you have presented inside a loop?
Is this the whole code or you missed something to post here?
Call the funct module one per each loop instead of calling it after the loop.
Regards.
Ravi
2006 Jun 22 1:44 PM
Hello,
It's not inside a loop, it's is a simple test to see if I can input values before I do that using this method.
This is the whole code, as I run it, Am I missing something?
Don't know what you mean by calling it once for each loop?
Help!!
Regards Sims
2006 Jun 22 1:58 PM
Hi,
Is there an example somewhere which has code?
Do I have to use :
CALL FUNCTION 'POSTING_INTERFACE_START'
and
CALL FUNCTION 'POSTING_INTERFACE_END'
MAny Thanks
2006 Jun 22 1:58 PM
FUNCTION POSTING_INTERFACE_START.
*"----------------------------------------------------------------------
*"Globale Schnittstelle:
*" IMPORTING
*" I_CLIENT LIKE SY-MANDT DEFAULT SY-MANDT
*" I_FUNCTION LIKE RFIPI-FUNCT
*" I_GROUP LIKE APQI-GROUPID DEFAULT SPACE
*" I_HOLDDATE LIKE APQI-STARTDATE DEFAULT SPACE
*" I_KEEP LIKE APQI-QERASE DEFAULT SPACE
*" <b> I_MODE LIKE RFPDO-ALLGAZMD DEFAULT 'N'</b>
*" I_UPDATE LIKE RFPDO-ALLGVBMD DEFAULT 'S'
*" I_USER LIKE APQI-USERID DEFAULT SPACE
*" I_XBDCC LIKE RFIPI-XBDCC DEFAULT SPACE
*" EXCEPTIONS
*" CLIENT_INCORRECT
*" FUNCTION_INVALID
*" GROUP_NAME_MISSING
*" MODE_INVALID
*" UPDATE_INVALID
*"----------------------------------------------------------------------You need to add FM POSTING_INTERFACE_START before POSTING_INTERFACE_DOCUMENT and POSTING_INTERFACE_END after.
2006 Jun 22 2:05 PM
First:
CALL FUNCTION 'POSTING_INTERFACE_START
EXPORTING
i_function = 'C'
i_mode = pc_mode A, N o E
i_user = sy-uname.
POSTING_INTERFACE_DOCUMENT
CALL FUNCTION 'POSTING_INTERFACE_END'
EXPORTING
I_BDCIMMED = 'X'. run inmediatly
2006 Jun 22 2:31 PM
Hello,
this is what I have at the momment, but I still get the error message
<i> Two accounts were transferred but not BSEG-HKONT
Message no. F8 020
</i>
Diagnosis
Two accounts were transferred but not BSEG-HKONT.
This error also occurs if more than 1000 line items are transferred. In
this case, the transferred data must be distributed across several
documents.
&----
*& Report Zrep1 *
*& *
&----
*& *
*& *
&----
REPORT zstaccrual .
DATA:
obj_type LIKE bapiache02-obj_type,
obj_key LIKE bapiache02-obj_key,
obj_sys LIKE bapiache02-obj_sys,
documentheader LIKE bapiache08,
accountgl LIKE bapiacgl08
OCCURS 0 WITH HEADER LINE,
currencyamount LIKE bapiaccr08
OCCURS 0 WITH HEADER LINE,
return LIKE bapiret2
OCCURS 0 WITH HEADER LINE,
extension1 LIKE bapiextc
OCCURS 0 WITH HEADER LINE,
t_edidd LIKE edidd OCCURS 0 WITH HEADER LINE,
bapi_retn_info LIKE bapiret2 OCCURS 0 WITH HEADER LINE.
DATA: error_flag.
*documentheader-obj_key = '000000000100000038'.
documentheader-obj_type = 'BKPFF'.
documentheader-obj_sys = 'RD1CLNT200'.
documentheader-username = sy-uname.
documentheader-doc_date = '310506'.
documentheader-doc_type = 'SA'.
documentheader-comp_code = 2000.
documentheader-pstng_date = '310506'.
documentheader-ref_doc_no = 'Accrual Post'.
documentheader-reason_rev = '05'.
documentheader-ac_doc_no = 476000.
documentheader-obj_key = 40.
*documentheader-ac_doc_no
*documentheader-fisc_year = '2005'.
*documentheader-trans_date
*documentheader-fis_period
documentheader-doc_type = 'SA'.
*documentheader-ref_doc_no
*documentheader-compo_acc
*documentheader-reason_rev
accountgl-itemno_acc = '1'.
accountgl-gl_account = '0000476000'.
accountgl-comp_code = '2000'.
accountgl-pstng_date = '20060506'.
accountgl-doc_type = 'SA'.
accountgl-profit_ctr = '2-1000'.
*accountgl-
APPEND accountgl.
accountgl-itemno_acc = '2'.
accountgl-gl_account = '0000476000'.
accountgl-comp_code = '2000'.
accountgl-pstng_date = '20060506'.
accountgl-doc_type = 'SA'.
accountgl-profit_ctr = '2-1000'.
*accountgl-
APPEND accountgl.
accountgl-itemno_acc = '3'.
accountgl-gl_account = '0000417000'.
accountgl-comp_code = '2000'.
accountgl-pstng_date = '20060506'.
accountgl-doc_type = 'SA'.
accountgl-profit_ctr = '0000400157'.
APPEND accountgl.
accountgl-itemno_acc = '4'.
accountgl-gl_account = '0000417000'.
accountgl-comp_code = '2000'.
accountgl-pstng_date = '20060506'.
accountgl-doc_type = 'SA'.
accountgl-profit_ctr = '0000400157'.
APPEND accountgl.
*AC_DOC_NO
*FISC_YEAR
*FIS_PERIOD
*accountgl-STAT_CON = 'X'.
*REF_KEY_1
*REF_KEY_2
*REF_KEY_3
*CUSTOMER
*VENDOR_NO
*ALLOC_NMBR
*ITEM_TEXT
*BUS_AREA
*COSTCENTER
*ACTTYPE
*ORDERID
*ORIG_GROUP
*COST_OBJ
*PROFIT_CTR
*PART_PRCTR
*WBS_ELEMENT
*NETWORK
*ROUTING_NO
*ORDER_ITNO
currencyamount-itemno_acc = '1'.
currencyamount-currency = 'EUR'.
currencyamount-amt_doccur = '5000.00'.
APPEND currencyamount.
currencyamount-itemno_acc = '2'.
currencyamount-currency = 'EUR'.
currencyamount-amt_doccur = '-5000.00'.
APPEND currencyamount.
currencyamount-itemno_acc = '3'.
currencyamount-currency = 'EUR'.
currencyamount-amt_doccur = '-500.00'.
APPEND currencyamount.
currencyamount-itemno_acc = '4'.
currencyamount-currency = 'EUR'.
currencyamount-amt_doccur = '-500.00'.
APPEND currencyamount.
call BAPI-function in this system
CALL FUNCTION 'BAPI_ACC_GL_POSTING_POST'
EXPORTING
documentheader = documentheader
importing
obj_type = obj_type
obj_key = obj_key
obj_sys = obj_sys
TABLES
accountgl = accountgl
currencyamount = currencyamount
return = return
extension1 = extension1
EXCEPTIONS
OTHERS = 1.
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.
COMMIT WORK.
ENDIF.
ENDIF.
| User | Count |
|---|---|
| 6 | |
| 2 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 |