Application Development Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 

Posting a Parked Document to Today's date FM/BAPI 'PRELIMINARY_POSTING_POST

Former Member
0 Kudos

Hi All,

Here is my scenario, i have an incoming file in which i will get the 'Parked Documents' (VBKPF-BSTAT = V).

I want to Post these documents.

I am using the FM 'PRELIMINARY_POSTING_POST_ALL' to post thse docs.I am posting them on system date(BUDAT= Sys-date)

rec_vbkpf-belnr = rec_file-belnr.

rec_vbkpf-bukrs = c_1500.

rec_vbkpf-budat = sy-datum.

rec_vbkpf-gjahr = rec_wms_file-invoice_dt+4(4).

APPEND rec_vbkpf TO t_vbkpf.

CALL FUNCTION 'PRELIMINARY_POSTING_POST_ALL'

EXPORTING

nomsg = c_x

TABLES

t_vbkpf = t_vbkpf

t_msg = t_msg

EXCEPTIONS

OTHERS = 1.

But stil posting is not done on system date.

I want all the postings to be done on system date.

Regards,

Abhishek Kokate

9 REPLIES 9

Former Member
0 Kudos

hi abhishek,

Are you able to post the document?

If 'yes'.

what date you are getting in the posted document?

Harshita Saxena

0 Kudos

I am able to post the document ...but the posting date comes out to be the date original BUDAT with which document was parked.

Say I have parked the document on date 01/02/2010 ,with posting date = 02/02/2010...when i try to post this document today ...i get the document posting date as 02/02/2010 i.e the original posting date on document.

0 Kudos

hi,

one thing you can do is first change the posting date of the parked documents using a bdc and then post them.

Secondly, if u can send me your full code , so that i can chek it on my system, and help u.

Harshita Saxena

0 Kudos

HI Harshita,

Below is the code .

let me know if anything else is needed.

CLEAR:rec_vbkpf.
  rec_vbkpf-belnr = rec_wms_file-belnr.
  rec_vbkpf-bukrs = c_1500.
  rec_vbkpf-tcode =    rec_belnr-tcode.
  rec_vbkpf-gjahr = rec_wms_file-invoice_dt+4(4).
  *rec_vbkpf-budat = sy-datum.* 
  CALL FUNCTION 'CONVERT_DATE_TO_INTERNAL'
    EXPORTING
      date_external            = rec_wms_file-invoice_dt
    IMPORTING
      date_internal            = rec_vbkpf-bldat
    EXCEPTIONS
      date_external_is_invalid = 1
      OTHERS                   = 2.
  
    IF NOT t_vbkpf IS INITIAL.
*-- Posting all parked documents with status A at a time
      PERFORM parked_invoice_post.
    ENDIF.

FORM parked_invoice_post.

  DATA: t_msg TYPE TABLE OF fimsg1,
        rec_msg TYPE fimsg1,
        w_message TYPE string,
        fl_not_posted TYPE flag.

  CLEAR rec_error.

  CALL FUNCTION 'PRELIMINARY_POSTING_POST_ALL'
    EXPORTING
      nomsg   = c_x
    TABLES
      t_vbkpf = t_vbkpf
      t_msg   = t_msg
    EXCEPTIONS
      OTHERS  = 1.

  IF sy-subrc = 0.

    COMMIT WORK AND WAIT.
    IF sy-subrc = 0.
      CLEAR fl_not_posted.
    ENDIF.

  ENDIF.

*-- If not posted successfully, fill error internal table
  LOOP AT t_msg INTO rec_msg WHERE posted NE c_x.
    fl_not_posted = c_x.
    READ TABLE t_vbkpf INTO rec_vbkpf INDEX sy-tabix.
    IF sy-subrc = 0.
      READ TABLE t_wms_file INTO rec_wms_file
                            WITH KEY belnr = rec_vbkpf-belnr
                            BINARY SEARCH.
      IF sy-subrc = 0.
*-- Fetching the exact error message
        CALL FUNCTION 'FORMAT_MESSAGE'
          EXPORTING
            id        = rec_msg-msgid
            lang      = sy-langu
            no        = rec_msg-msgno
            v1        = rec_msg-msgv1
            v2        = rec_msg-msgv2
            v3        = rec_msg-msgv3
            v4        = rec_msg-msgv4
          IMPORTING
            msg       = w_message
          EXCEPTIONS
            not_found = 1
            OTHERS    = 2.

*-- Update the internal table of errors
        IF sy-subrc <> 0.
          rec_error-reason = text-014.
        ELSE.
          rec_error-reason = w_message.
        ENDIF.
        PERFORM update_errors.
      ELSE.
        CLEAR rec_wms_file.
      ENDIF.
    ELSE.
      CLEAR rec_vbkpf.
    ENDIF.
  ENDLOOP.

  IF fl_not_posted IS INITIAL.
    cnt_posted = cnt_posted + 1.
  ENDIF.

ENDFORM.                    " PARKED_INVOICE_POST

hi,

IN this function ' PRELIMINARY_POSTING_POST_ALL'. chek lines :

LOOP AT T_VBKPF.

ADD 1 TO LD_LOOP_COUNT.

CALL FUNCTION 'PRELIMINARY_POSTING_POST'

EXPORTING

BUKRS = T_VBKPF-BUKRS

BELNR = T_VBKPF-BELNR

GJAHR = T_VBKPF-GJAHR

NOCHECK = NOCHECK.

In this its not passing the posting date ,so you need to first change the posting date of the parked documents using a BDC or manually. then post it.

Harshita Saxena

0 Kudos

same to me, direct pass posting date to this BAPI by code will not overwrite the original posting date

Former Member
0 Kudos

Below code used....first document was chnaged and then posted...

CALL FUNCTION 'PRELIMINARY_POSTING_DOC_READ'

EXPORTING

belnr = rec_vbkpf-belnr

bukrs = rec_vbkpf-bukrs

gjahr = rec_vbkpf-gjahr

TABLES

t_vbkpf = t_vbkpf1

t_vbsec = t_vbsec1

t_vbseg = t_vbseg1

t_vbset = t_vbset1

EXCEPTIONS "#EC *

document_line_not_found = 1

document_not_found = 2

input_incomplete = 3

OTHERS = 4.

*// Change Posting Date to Current Date(Required)

CLEAR:rec_vbkpf1.

LOOP AT t_vbkpf1 INTO rec_vbkpf1.

rec_vbkpf1-budat = sy-datum.

MODIFY t_vbkpf1 FROM rec_vbkpf1 TRANSPORTING budat.

CLEAR:rec_vbkpf1.

ENDLOOP.

*// Change BZALT to BUZEI. - !!!! - it's obligatory

CLEAR:rec_vbseg1.

LOOP AT t_vbseg1 INTO rec_vbseg1.

CLEAR:rec_vbseg1-fipos .

rec_vbseg1-bzalt = rec_vbseg1-buzei.

MODIFY t_vbseg1 FROM rec_vbseg1 TRANSPORTING bzalt fipos.

CLEAR:rec_vbseg1.

ENDLOOP.

CALL FUNCTION 'PRELIMINARY_POSTING_DOC_WRITE'

TABLES

t_vbkpf = t_vbkpf1

t_vbsec = t_vbsec1

t_vbseg = t_vbseg1

t_vbset = t_vbset1

EXCEPTIONS "#EC *

abnormal_termination = 1

insert_error = 2

update_error = 3

read_error = 4

OTHERS = 5.

CALL FUNCTION 'PRELIMINARY_POSTING_POST_ALL'

EXPORTING

nomsg = c_x

TABLES

t_vbkpf = t_vbkpf

t_msg = t_msg

EXCEPTIONS

OTHERS = 1.

Former Member
0 Kudos

There is a BTE which I was able to successfully leverage to result in the exact requirements;

Business Transaction Event - RWBAPI01 - For Accounting Document Interface used with BAPI: BAPI_ACC_DOCUMENT_POST

Let me know if you need help to implement!

0 Kudos

Hi Rocco,

I am facing same issue. What was written inside that BTE? could you please provide more details?

Regards,

Anand R