Application Development and Automation 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: 
Read only

POSTING_INTERFACE_DOCUMENT sample code

Former Member
0 Likes
4,748

Hi.. Can anyone send a sample code which uses fm POSTING_INTERFACE_DOCUMENT

1 ACCEPTED SOLUTION
Read only

Former Member
2,367

The standard report EWUMFPST has a form described as "Individuals Document" wich calls this function, from line 318.


*----------------------------------------------------------------------*
*     FORM  BUCHEN_BELEG.                                              *
*----------------------------------------------------------------------*
*     Einzelnen Beleg buchen                                           *
*----------------------------------------------------------------------*
form buchen_beleg.

  data: help_counter_before type i, help_counter_after type i.
  data: help_subrc like sy-subrc.
  describe table blntab lines help_counter_before.
  help_subrc = 1.
  clear belegnummer.

  sort ftpost by stype count.
  clear blntab.                                             "note174346
  call function 'POSTING_INTERFACE_DOCUMENT'
       exporting
           i_tcode                  = 'FBB1'
*          i_tcode                  = 'FB01'
          i_sgfunct                = 'C'
       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 eq 0.
    perform append_msg using '1' '' sy-msgty sy-msgid sy-msgno
                          i_msgv1 i_msgv2 i_msgv3 i_msgv4.
    describe table blntab lines help_counter_after.
    if help_counter_after > help_counter_before.
      read table blntab index help_counter_after.
      if sy-subrc = 0. help_subrc = 0. endif.
    endif.
    if help_subrc = 0 and blntab-belnr ne space.
      belegnummer = blntab-belnr.
      bukrs = blntab-bukrs.
      gjahr = blntab-gjahr.
      perform update_belnr.
      perform update_ewummfi.
    else.
      help_subrc = 1.
    endif.
  else.
    help_subrc = 1.
    case sy-subrc.
      when 1.
        perform append_msg using '2' '' 'A' 'FR' '451'
                   'ACCOUNT_MISSING' '' '' ''.
      when 2.
        perform append_msg using '2' '' 'A' 'FR' '451'
                'COMPANY_CODE_MISSING' '' '' ' '.
      when 3.
        perform append_msg using '2' '' 'A' 'FR' '451'
               'POSTING_KEY_INVALID' '' '' ''.
      when 4.
        perform append_msg using '2' '' 'A'  'FR' '451'
                'POSTING_KEY_MISSING' '' '' ''.
      when 5.
        perform append_msg using '2' '' 'A' 'FR' '451'
               'RECORD_TYPE_INVALID' '' '' ''.
      when 6.
        perform append_msg using '2' '' 'A'  'FR' '451'
                 'TRANSACTION_CODE_INVALID' '' '' ''.
    endcase.
  endif.

  if help_subrc = 1.
    perform skb1_xintb_setzen. "reset the changed account datas
    result = 'E'.
    perform finish_program using result upda.
    perform write_prot_and_exit.
  endif.
endform.                    "BUCHEN_BELEG

Hope it can help!

5 REPLIES 5
Read only

Former Member
0 Likes
2,367

Check the below link for the sample code.

[http://www.jt77.com/development2/programming-02712.html|http://www.jt77.com/development2/programming-02712.html]

Hope this helps.

Thanks,

Balaji

Read only

Former Member
2,368

The standard report EWUMFPST has a form described as "Individuals Document" wich calls this function, from line 318.


*----------------------------------------------------------------------*
*     FORM  BUCHEN_BELEG.                                              *
*----------------------------------------------------------------------*
*     Einzelnen Beleg buchen                                           *
*----------------------------------------------------------------------*
form buchen_beleg.

  data: help_counter_before type i, help_counter_after type i.
  data: help_subrc like sy-subrc.
  describe table blntab lines help_counter_before.
  help_subrc = 1.
  clear belegnummer.

  sort ftpost by stype count.
  clear blntab.                                             "note174346
  call function 'POSTING_INTERFACE_DOCUMENT'
       exporting
           i_tcode                  = 'FBB1'
*          i_tcode                  = 'FB01'
          i_sgfunct                = 'C'
       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 eq 0.
    perform append_msg using '1' '' sy-msgty sy-msgid sy-msgno
                          i_msgv1 i_msgv2 i_msgv3 i_msgv4.
    describe table blntab lines help_counter_after.
    if help_counter_after > help_counter_before.
      read table blntab index help_counter_after.
      if sy-subrc = 0. help_subrc = 0. endif.
    endif.
    if help_subrc = 0 and blntab-belnr ne space.
      belegnummer = blntab-belnr.
      bukrs = blntab-bukrs.
      gjahr = blntab-gjahr.
      perform update_belnr.
      perform update_ewummfi.
    else.
      help_subrc = 1.
    endif.
  else.
    help_subrc = 1.
    case sy-subrc.
      when 1.
        perform append_msg using '2' '' 'A' 'FR' '451'
                   'ACCOUNT_MISSING' '' '' ''.
      when 2.
        perform append_msg using '2' '' 'A' 'FR' '451'
                'COMPANY_CODE_MISSING' '' '' ' '.
      when 3.
        perform append_msg using '2' '' 'A' 'FR' '451'
               'POSTING_KEY_INVALID' '' '' ''.
      when 4.
        perform append_msg using '2' '' 'A'  'FR' '451'
                'POSTING_KEY_MISSING' '' '' ''.
      when 5.
        perform append_msg using '2' '' 'A' 'FR' '451'
               'RECORD_TYPE_INVALID' '' '' ''.
      when 6.
        perform append_msg using '2' '' 'A'  'FR' '451'
                 'TRANSACTION_CODE_INVALID' '' '' ''.
    endcase.
  endif.

  if help_subrc = 1.
    perform skb1_xintb_setzen. "reset the changed account datas
    result = 'E'.
    perform finish_program using result upda.
    perform write_prot_and_exit.
  endif.
endform.                    "BUCHEN_BELEG

Hope it can help!

Read only

Former Member
0 Likes
2,367

Thanks for the snippet. Can you also give the way you populated ftpost. I am facing issues there.

Read only

0 Likes
2,367

You can fill it using the field name as a string (like 'BKPF-BLDAT') and the value.

Code sample in program EWUMFPST:



*...

PERFORM BUCHEN_FELD USING 'BKPF-BLDAT' ARB1-FVAL.

*...

form buchen_feld using fnam fval.

  check fval NE space.
  ftpost-fnam = fnam.
  write fval to ftpost-fval.
  append ftpost.

endform.                    "BUCHEN_FELD

Hope it helps!

Read only

0 Likes
2,367

Check the below code snipplet.



  LOOP AT BU_TAB.
    AT NEW BUKRS.
      PERFORM GET_GEGENBUCHUNG.
    ENDAT.
*    at new bukrs.
*      if new_kopf = space.
*        perform buchen_kopf .
*        new_kopf = 'X'.
*      endif.
*    endat.

*    AT NEW waers.
    AT NEW CURTP.
      PERFORM GET_CURRENCY_INFORMATION.
      IF NEW_KOPF = SPACE.
        PERFORM BUCHEN_KOPF .
        NEW_KOPF = 'X'.
      ENDIF.
    ENDAT.
*   Zuordnung Zeile-Beleg merken.
    PERFORM ZUORDNUNG_BELEG.
*   Beträge summieren / buchen bei Belegüberlauf
    ADD-CORRESPONDING BU_TAB TO BU_SUM.
    IF  BU_SUM-DMBTR > MAX_BTR_B OR
        BU_SUM-DMBE2 > MAX_BTR_B OR
        BU_SUM-DMBE3 > MAX_BTR_B OR
       BU_SUM-POS > MAX_POS.
      PERFORM BUCHEN_BELEG.
      PERFORM BUCHEN_KOPF.
      MOVE-CORRESPONDING BU_TAB TO BU_SUM.
    ENDIF.
*   Belegzeile übertragen
    PERFORM BUCHEN_POS.
*   Buchen
    AT END OF WAERS.
      BUKRS = BU_TAB-BUKRS.
      PERFORM BUCHEN_BELEG.
      CLEAR NEW_KOPF.
    ENDAT.
  ENDLOOP.

ENDFORM.                    "BUCHEN

FORM BUCHEN_KOPF.

* Initialisieren für neuen Beleg (Belegkopf)
  CLEAR BU_SUM.
  REFRESH FTPOST.
  CLEAR FTPOST.
  FTPOST-STYPE = 'K'.
  FTPOST-COUNT = 1.

* Feldzuweisungen
  WRITE SY-DATUM TO ARB1-FVAL DD/MM/YYYY.               "Belegdatum
  PERFORM BUCHEN_FELD USING 'BKPF-BLDAT' ARB1-FVAL.
  PERFORM BUCHEN_FELD USING 'BKPF-BLART' BELEGART.     "Belegart
  PERFORM BUCHEN_FELD USING 'BKPF-BUKRS' BU_TAB-BUKRS.   "Buchungskreis
  WRITE SY-DATUM TO ARB1-FVAL DD/MM/YYYY.                "Buchungsdatum
  PERFORM BUCHEN_FELD USING 'BKPF-BUDAT' ARB1-FVAL.
  PERFORM BUCHEN_FELD USING 'BKPF-XBLNR' REFERENZ.
*  perform buchen_feld using 'BKPF-BKTXT' arb1-fval.
  PERFORM BUCHEN_FELD USING 'BKPF-WAERS' BU_TAB-OWAER.   "Währung

* Initialisieren für Belegpositionen
  CLEAR FTPOST.
  FTPOST-STYPE = 'P'.

ENDFORM.                    "BUCHEN_KOPF

FORM BUCHEN_FELD USING FNAM FVAL.

  CHECK FVAL <> SPACE.
  FTPOST-FNAM = FNAM.
  WRITE FVAL TO FTPOST-FVAL.
  APPEND FTPOST.

ENDFORM.                    "BUCHEN_FELD


Hope this helps. Check the source code of the report EWUMFPST for more details.

Thanks,

Balaji