We have added search box. Key in SAP issue keyword to search
TopBottom

Announcement: wanna exchange links? contact me at sapchatroom@gmail.com.

RE:[sap-dev] f-22 write off BAPI

Posted by Admin at
Share this post:
Ma.gnolia DiggIt! Del.icio.us Yahoo Furl Technorati Reddit

Posted by sapwes (Jack)
on Dec 30 at 1:43 PM
Here is a snippet - hopefully it will come through.

* Build Document Header.
*
CLEAR gs_documentheader.

gs_documentheader-bus_act = c_rfbu.
gs_documentheader-username = sy-uname.
gs_documentheader-header_txt = c_written_off.
gs_documentheader-comp_code = p_row-bukrs.
gs_documentheader-doc_date = sy-datum.
gs_documentheader-pstng_date = sy-datum.
gs_documentheader-trans_date = sy-datum.
gs_documentheader-fisc_year = lv_gjahr.
gs_documentheader-fis_period = lv_monat.
gs_documentheader-doc_type = c_dg.
gs_documentheader-ref_doc_no = p_row-belnr.

********************************************************
* Build records for Credit Item
********************************************************

*
* Build GL Account Credit Item.
*
CLEAR gs_accountgl.
ADD +1 TO lv_itemno_acc.

gs_accountgl-itemno_acc = lv_itemno_acc.
gs_accountgl-gl_account = p_row-hkont.
gs_accountgl-item_text = c_written_off.
gs_accountgl-acct_type = c_d.
gs_accountgl-doc_type = c_dg.
gs_accountgl-comp_code = p_row-bukrs.
gs_accountgl-fis_period = lv_monat.
gs_accountgl-fisc_year = lv_gjahr.
gs_accountgl-pstng_date = sy-datum.
gs_accountgl-customer = p_row-kunnr.
gs_accountgl-profit_ctr = p_row-prctr.
gs_accountgl-de_cre_ind = c_h.
APPEND gs_accountgl TO gt_accountgl.

---------------Original Message---------------
From: dboyd
Sent: Thursday, December 30, 2010 10:04 AM
Subject: f-22 write off BAPI

Hello again.
I am converting a BDC for transaction F-22 write off by trying to use BAPI_ACC_DOCUMENT_POST. I am getting an error 'Cost center 1000/908800 does not exist on 12/30/2010'. I assume that 1000 is the company even though I explicitly am sending company code 2000 in the Bapi. 908800 is the cost center.
Attached is my test program that is erroring. Do you see something amiss?
Thank you again.
Debbie
REPORT Z_TEST_BAPI_ACC_DOCUMENT_POST2.
data:
l_type like bapiache09-obj_type,
l_key like bapiache09-obj_key,
l_sys like bapiache09-obj_sys,
obj_type like bapiache09-obj_type,
obj_key like bapiache09-obj_key,
obj_sys like bapiache09-obj_sys,
documentheader like bapiache09,
accountgl like bapiacgl09 occurs 0 with header line,
accountpayable like bapiacar09 occurs 0 with header line,
accountreceivable like bapiacar09 occurs 0 with header line,
currencyamount like bapiaccr09 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-username = sy-uname.
documentheader-header_txt = 'Test BAPI CC number'.
documentheader-comp_code = '2000'.
documentheader-doc_date = sy-datum.
documentheader-pstng_date = sy-datum.
documentheader-doc_type = 'DW'.
accountgl-itemno_acc = '2'.
accountgl-gl_account = 'C607060'.
accountgl-costcenter = '908800'.
append accountgl.
accountreceivable-itemno_acc = '1'.
accountreceivable-customer = '0006008665'.
append accountreceivable.
currencyamount-itemno_acc = '1'.
currencyamount-currency = 'USD'.
currencyamount-amt_doccur = '-75.00'.
append currencyamount.
currencyamount-itemno_acc = '2'.
currencyamount-currency = 'USD'.
currencyamount-amt_doccur = '75.00'.
append currencyamount.
call function 'BAPI_ACC_DOCUMENT_POST'
exporting
documentheader = documentheader
* CUSTOMERCPD =
* CONTRACTHEADER =
IMPORTING
OBJ_TYPE = l_type
OBJ_KEY = l_key
OBJ_SYS = l_sys
tables
ACCOUNTGL = accountgl
ACCOUNTRECEIVABLE = accountreceivable
* ACCOUNTPAYABLE = accountpayable
* ACCOUNTTAX =
currencyamount = currencyamount
* CRITERIA =
* VALUEFIELD =
* EXTENSION1 =
return = return
* PAYMENTCARD =
* CONTRACTITEM =
* EXTENSION2 =
* REALESTATE =
* ACCOUNTWT =
.
if sy-subrc <> 0.
write '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'.
write 'Problem occured'.
rollback work.
else.
commit work.
endif.
endif.
.

__.____._
Copyright © 2010 Toolbox.com and message author.

Toolbox.com 4343 N. Scottsdale Road Suite 280, Scottsdale, AZ 85251
Mark as helpful
View this online
  
sapwes
SAP Development Helper

Posted helpful replies on 5 threads in a group to earn a Bronze Achievement
Most Popular White Papers

In the Spotlight
Toolbox.com Groups Discussions Now Support BBCode. Share Code Snippets with Peers
_.____.__

0 comments:

Post a Comment

T r a n s l a t e to your language