10-16-2007 8:31 PM
Hi guys,
I m trying to post a GL document using the BAPI_ACC_DOCUMENT_POST and try to the reverse the document using code generated by shdb of transaction FB08. The problem is that when i execute the program with out any break points the program stops at FB08 saying the document is either not posted or in the archive but when im doing the same with breakpoints in it, its posting correctly.
Guys this is little urgent.
10-16-2007 9:22 PM
Hi vijay,
i tried to call this statement soon after the bapi_transaction_commit and it still stops at fb08 saying that the document is not present in that fiscal year or is stored in the archive and when i hit save over thers its getting posted.
I do not understand why its not posting with out stopping at that point.
Heres the code where iam calling those two subroutines where posting and reverse posting occurs. can you look at the code and tell me if theres any mistake.
FORM Posting_Data_Prepare .
select single logsys from t000 into logsys where mandt = sy-mandt.
if sy-subrc = 0.
g_docheader-obj_sys = logsys.
endif.
*Header data.
g_docheader-obj_type = 'BKPFF'.
g_docheader-obj_key = '$'.
g_docheader-username = sy-uname.
g_docheader-header_txt = 'GL POSITNG'.
g_docheader-comp_code = pos_ccod.
g_docheader-bus_act = 'RFBU'.
if pos_ddat is initial.
g_docheader-doc_date = sy-datum.
else.
g_docheader-doc_date = pos_ddat.
endif.
g_docheader-doc_type = pos_type.
if not pos_dnum is initial.
g_docheader-ac_doc_no = pos_dnum.
endif.
if pos_pdat is initial.
g_docheader-pstng_date = sy-datum.
else.
g_docheader-pstng_date = pos_pdat.
endif.
Header data End.
loop at bestand.
clear: grir_amount,
iniv_amount,
utp_amount.
perform clear_internal_tables.
Item Account Details.
perform Get_Item_Account.
Currency and Amount Details for Normal Posting.
perform Get_Item_Amount.
perform GL_Posting.
perform gl_posting_rev.
endloop.
loop at gi_return1.
write: gi_return1-message.
endloop.
ENDFORM. " Posting_Data_Prepare
FORM GL_Posting .
*data: p1(30),p2(30),p3(30),p4(40),p5(30),p6(30),p7(1) value ' '.
clear p5.
CALL FUNCTION 'BAPI_ACC_DOCUMENT_POST'
EXPORTING
DOCUMENTHEADER = g_docheader
CUSTOMERCPD =
CONTRACTHEADER =
IMPORTING
OBJ_TYPE =
OBJ_KEY = p5
OBJ_SYS =
TABLES
ACCOUNTGL = gi_accountgl
ACCOUNTRECEIVABLE =
ACCOUNTPAYABLE =
ACCOUNTTAX =
CURRENCYAMOUNT = gi_amount
CRITERIA =
VALUEFIELD =
EXTENSION1 =
RETURN = gi_return
PAYMENTCARD =
CONTRACTITEM =
EXTENSION2 =
REALESTATE =
.
CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'
EXPORTING
WAIT =
IMPORTING
RETURN =
.
Preparing header for the reversal
SET UPDATE TASK LOCAL.
loop at gi_return into g_return.
append g_return to gi_return1.
endloop.
ENDFORM. " GL_Posting
FORM gl_posting_rev .
refresh bdcdata.
*split g_return-message at p7 into p1 p2 p3 p4 p5 p6.
condense p5 no-gaps.
*select single belnr from bkpf into doc_num
where awkey eq p5 and
bukrs = pos_ccod .
doc_num = p5(10).
perform bdc_dynpro using 'SAPMF05A' '0105'.
perform bdc_field using 'BDC_CURSOR' 'BSIS-MONAT'.
perform bdc_field using 'RF05A-BELNS' DOC_NUM.
perform bdc_field using 'BKPF-BUKRS' POS_CCOD.
perform bdc_field using 'RF05A-GJAHS' ''.
perform bdc_field using 'UF05A-STGRD' '02'.
POS_DAT = POS_PDAT + 1.
concatenate pos_dat6(2) pos_dat4(2) pos_dat(4) into dat.
perform bdc_field using 'BSIS-BUDAT' dat.
perform bdc_field using 'BDC_OKCODE' '=BU'.
call transaction 'FB08' using bdcdata
update c_s
mode c_e.
ENDFORM. " gl_posting_rev
10-16-2007 8:33 PM
Hi,
After the BAPI call use the command SET UPDATE LOCAL. This will force the update to happen without time delay.
Cheers
VJ
10-16-2007 8:34 PM
10-16-2007 9:22 PM
Hi vijay,
i tried to call this statement soon after the bapi_transaction_commit and it still stops at fb08 saying that the document is not present in that fiscal year or is stored in the archive and when i hit save over thers its getting posted.
I do not understand why its not posting with out stopping at that point.
Heres the code where iam calling those two subroutines where posting and reverse posting occurs. can you look at the code and tell me if theres any mistake.
FORM Posting_Data_Prepare .
select single logsys from t000 into logsys where mandt = sy-mandt.
if sy-subrc = 0.
g_docheader-obj_sys = logsys.
endif.
*Header data.
g_docheader-obj_type = 'BKPFF'.
g_docheader-obj_key = '$'.
g_docheader-username = sy-uname.
g_docheader-header_txt = 'GL POSITNG'.
g_docheader-comp_code = pos_ccod.
g_docheader-bus_act = 'RFBU'.
if pos_ddat is initial.
g_docheader-doc_date = sy-datum.
else.
g_docheader-doc_date = pos_ddat.
endif.
g_docheader-doc_type = pos_type.
if not pos_dnum is initial.
g_docheader-ac_doc_no = pos_dnum.
endif.
if pos_pdat is initial.
g_docheader-pstng_date = sy-datum.
else.
g_docheader-pstng_date = pos_pdat.
endif.
Header data End.
loop at bestand.
clear: grir_amount,
iniv_amount,
utp_amount.
perform clear_internal_tables.
Item Account Details.
perform Get_Item_Account.
Currency and Amount Details for Normal Posting.
perform Get_Item_Amount.
perform GL_Posting.
perform gl_posting_rev.
endloop.
loop at gi_return1.
write: gi_return1-message.
endloop.
ENDFORM. " Posting_Data_Prepare
FORM GL_Posting .
*data: p1(30),p2(30),p3(30),p4(40),p5(30),p6(30),p7(1) value ' '.
clear p5.
CALL FUNCTION 'BAPI_ACC_DOCUMENT_POST'
EXPORTING
DOCUMENTHEADER = g_docheader
CUSTOMERCPD =
CONTRACTHEADER =
IMPORTING
OBJ_TYPE =
OBJ_KEY = p5
OBJ_SYS =
TABLES
ACCOUNTGL = gi_accountgl
ACCOUNTRECEIVABLE =
ACCOUNTPAYABLE =
ACCOUNTTAX =
CURRENCYAMOUNT = gi_amount
CRITERIA =
VALUEFIELD =
EXTENSION1 =
RETURN = gi_return
PAYMENTCARD =
CONTRACTITEM =
EXTENSION2 =
REALESTATE =
.
CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'
EXPORTING
WAIT =
IMPORTING
RETURN =
.
Preparing header for the reversal
SET UPDATE TASK LOCAL.
loop at gi_return into g_return.
append g_return to gi_return1.
endloop.
ENDFORM. " GL_Posting
FORM gl_posting_rev .
refresh bdcdata.
*split g_return-message at p7 into p1 p2 p3 p4 p5 p6.
condense p5 no-gaps.
*select single belnr from bkpf into doc_num
where awkey eq p5 and
bukrs = pos_ccod .
doc_num = p5(10).
perform bdc_dynpro using 'SAPMF05A' '0105'.
perform bdc_field using 'BDC_CURSOR' 'BSIS-MONAT'.
perform bdc_field using 'RF05A-BELNS' DOC_NUM.
perform bdc_field using 'BKPF-BUKRS' POS_CCOD.
perform bdc_field using 'RF05A-GJAHS' ''.
perform bdc_field using 'UF05A-STGRD' '02'.
POS_DAT = POS_PDAT + 1.
concatenate pos_dat6(2) pos_dat4(2) pos_dat(4) into dat.
perform bdc_field using 'BSIS-BUDAT' dat.
perform bdc_field using 'BDC_OKCODE' '=BU'.
call transaction 'FB08' using bdcdata
update c_s
mode c_e.
ENDFORM. " gl_posting_rev
10-16-2007 9:39 PM
Change the commit to:
CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'
EXPORTING
WAIT = 'X'. "<========
Rob
10-16-2007 9:51 PM
10-16-2007 9:52 PM