I developed a program to park documents using BAPI_ACC_DOCUMENT_POST and working fine.
Developed another program, which displays all parked documents only and user will select single or may select multiple documents and post them. I used PRELIMINARY_POSTING_POST_ALL function module inside program. Documents are successfully posted and respective data is saving properly in BKPF, BSEG and in its dependent tables.
But while posting using PRELIMINARY_POSTING_POST_ALL, error log is recording in SM13 as update failure. Everyday BASIS people are reporting the same.
I had gone through the issue and found that this is happening because of reprocessing of already posted document. There is one check inside PRELIMINARY_POSTING_POST_ALL, which checks whether document is parked document or not. If it is parked document, it will post the document. If it is not parked document it will through ERROR and same will fall into SM13 as update failure.
I took all precautions like clearing exporting parameters, table parameters. For your reference below is code which I used. Please help me how to use PRELIMINARY_POSTING_POST_ALL and do I need clear any buffer or calling any additional FMs is required ?.
LOOP AT lt_final INTO gs_final.
CLEAR: gs_post, gs_vbkpf_alv, gt_post, gt_msg, gt_msg_tab, gs_msg, gs_t100.
READ TABLE gt_vbkpf_alv INTO gs_vbkpf_alv WITH KEY ausbk = gs_final-bukrs
belnr = gs_final-belnr
gjahr = gs_final-gjahr
IF sy-subrc = 0.
CLEAR: gs_post, gt_post, gt_msg, gt_msg_tab.
MOVE-CORRESPONDING gs_vbkpf_alv TO gs_post.
APPEND gs_post TO gt_post.
EXPORT gv_tcode TO SHARED BUFFER indx(zt) ID 'ZPOST'.
EXPORT gv_tcode1 TO SHARED BUFFER indx(zu) ID 'ZPOS1'.
EXPORT gv_tcode2 TO SHARED BUFFER indx(zv) ID 'ZPOS2'.
CALL FUNCTION 'PRELIMINARY_POSTING_POST_ALL'
nomsg = 'X'
t_vbkpf = gt_post
t_msg = gt_msg
t_msg_tab = gt_msg_tab.
IF gt_msg IS NOT INITIAL.
WAIT UP TO 1 SECONDS .
CLEAR: gs_msg, gs_t100.
READ TABLE gt_msg INTO gs_msg INDEX 1.
IF sy-subrc = 0.
SELECT SINGLE * FROM t100 INTO gs_t100 WHERE sprsl EQ 'E'
AND arbgb EQ gs_msg-msgid
AND msgnr EQ gs_msg-msgno.
gs_log-bukrs = gs_post-bukrs.
gs_log-belnr = gs_post-belnr.
gs_log-gjahr = gs_post-gjahr.
REPLACE ALL OCCURRENCES OF '&' IN gs_t100-text WITH ''.
gs_log-text = gs_t100-text.
APPEND gs_log TO gt_log.
CLEAR: gs_post, gs_final, gs_vbkpf_alv, gt_post, gt_msg, gt_msg_tab,