BAPI_ACC_INVOICE_RECEIPT_POST
REPORT zacm_test NO STANDARD PAGE HEADING
LINE-COUNT 65
LINE-SIZE 132.
DATA:
wait TYPE bapita-wait,
comm_return TYPE bapiret2,
obj_type TYPE bapiache02-obj_type,
obj_key TYPE bapiache02-obj_key,
obj_sys TYPE bapiache02-obj_sys,
accountgl LIKE STANDARD TABLE OF bapiacgl03, "Structure
wa_accountgl LIKE LINE OF accountgl,
docheader TYPE bapiache03, "Structure
accountpay TYPE STANDARD TABLE OF bapiacap03, "Structure
wa_accountpay LIKE LINE OF accountpay,
accounttax TYPE STANDARD TABLE OF bapiactx01, "Structure
wa_accounttax LIKE LINE OF accounttax,
curramount TYPE STANDARD TABLE OF bapiaccr01, "Structure
wa_curramount LIKE LINE OF curramount,
return TYPE STANDARD TABLE OF bapiret2, "Structure
wa_return LIKE LINE OF return,
extension1 TYPE STANDARD TABLE OF bapiextc, "Structure
wa_extension1 LIKE LINE OF extension1.
START-OF-SELECTION.
PERFORM build_header_rec.
PERFORM build_bapi_parameters1.
PERFORM build_bapi_parameters2.
PERFORM build_bapi_parameters3.
PERFORM build_bapi_parameters4.
PERFORM update_gl.
*&---------------------------------------------------------------------*
*& Form build_header_rec
*&---------------------------------------------------------------------*
FORM build_header_rec.
*build header data for bapi
CALL FUNCTION 'OWN_LOGICAL_SYSTEM_GET'
IMPORTING
own_logical_system = docheader-obj_sys.
docheader-obj_type = 'BKPFF'.
docheader-obj_key = 'test1'.
docheader-username = sy-uname.
docheader-comp_code = '0050'. " Company Code
docheader-fisc_year = '2006'. " Fiscal Year
docheader-doc_date = '12012006'. " Document Date
docheader-pstng_date = '12012006'. " Posting Date
docheader-trans_date = '12012006'. " Translation Date
docheader-fis_period = '12'. " Fiscal Period
docheader-doc_type = 'KQ'. " Document Type
docheader-ref_doc_no = 'T&S'. " Reference
ENDFORM. " build_header_rec
*&---------------------------------------------------------------------*
*& Form build_bapi_parameters1
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
FORM build_bapi_parameters1.
*Build Accounts Payable data for BAPI
wa_accountpay-itemno_acc = 1. " Line Item Number
wa_accountpay-vendor_no = 'TSA01004'. " Vendor Number
wa_accountpay-gl_account = '0000290430'. " GL Account Number
wa_accountpay-pmnttrms = 'NT00'. " Payment Terms
wa_accountpay-bline_date = '12012006'. " Bline Date
wa_accountpay-pmtmthsupl = '06'. " Payment Method Supplement
wa_accountpay-pymt_meth = 'S'. " Payment Method
wa_accountpay-item_text = '*T&S Withdrawal'. " Text
wa_accountpay-w_tax_code = '**'. " Tax Code
APPEND wa_accountpay TO accountpay.
CLEAR wa_accountpay.
*Build account GL data for BAPI
wa_accountgl-itemno_acc = 1. " Line Item Number
wa_accountgl-gl_account = '0000290430'. " GL Account Number
wa_accountgl-comp_code = '0050'. " Company Code
wa_accountgl-pstng_date = '12012006'. " Posting Date
wa_accountgl-doc_type = 'KQ'. " Document Type
wa_accountgl-fisc_year = '2006'. " Fiscal Year
wa_accountgl-fis_period = '12'. " Fiscal Period
wa_accountgl-item_text = ''. " Item Text
APPEND wa_accountgl TO accountgl.
CLEAR wa_accountgl.
*Build currency data for BAPI
wa_curramount-itemno_acc = 1. " Line Item Number
wa_curramount-curr_type = '00'. " Currency Type
wa_curramount-currency = 'USD'. " Currency Key
wa_curramount-currency_iso = 'USD'. " ISO Code
wa_curramount-amt_doccur = '-3750.00'. " Amount
wa_curramount-amt_base = '5000.00'. " Base Amount
APPEND wa_curramount TO curramount.
CLEAR wa_curramount.
ENDFORM. " build_bapi_parameters
*&---------------------------------------------------------------------*
*& Form build_bapi_parameters2
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
FORM build_bapi_parameters2.
*Build account GL data for BAPI
wa_accountgl-itemno_acc = 2. " Line Item Number
wa_accountgl-gl_account = '0000720300'. " GL Account Number
wa_accountgl-comp_code = '0050'. " Company Code
wa_accountgl-pstng_date = '12012006'. " Posting Date
wa_accountgl-doc_type = 'KQ'. " Document Type
wa_accountgl-fisc_year = '2006'. " Fiscal Year
wa_accountgl-fis_period = '12'. " Fiscal Period
wa_accountgl-item_text = ''. " Item Text
APPEND wa_accountgl TO accountgl.
CLEAR wa_accountgl.
*Build currency data for BAPI
wa_curramount-itemno_acc = 2. " Line Item Number
wa_curramount-curr_type = '00'. " Currency Type
wa_curramount-currency = 'USD'. " Currency Key
wa_curramount-currency_iso = 'USD'. " ISO Code
wa_curramount-amt_doccur = '5000.00'. " Amount
wa_curramount-amt_base = ''. " Base Amount
APPEND wa_curramount TO curramount.
CLEAR wa_curramount.
ENDFORM. " build_bapi_parameters
*&---------------------------------------------------------------------*
*& Form build_bapi_parameters3
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
FORM build_bapi_parameters3.
*Build account GL data for BAPI
wa_accountgl-itemno_acc = 3. " Line Item Number
wa_accountgl-gl_account = '0000256166'. " GL Account Number
wa_accountgl-comp_code = '0050'. " Company Code
wa_accountgl-pstng_date = '12012006'. " Posting Date
wa_accountgl-doc_type = 'KQ'. " Document Type
wa_accountgl-fisc_year = '2006'. " Fiscal Year
wa_accountgl-fis_period = '12'. " Fiscal Period
wa_accountgl-item_text = ''. " Item Text
APPEND wa_accountgl TO accountgl.
CLEAR wa_accountgl.
*Build currency data for BAPI
wa_curramount-itemno_acc = 3. " Line Item Number
wa_curramount-curr_type = '00'. " Currency Type
wa_curramount-currency = 'USD'. " Currency Key
wa_curramount-currency_iso = 'USD'. " ISO Code
wa_curramount-amt_doccur = '-1000.00'. " Amount
wa_curramount-amt_base = ''. " Base Amount
APPEND wa_curramount TO curramount.
CLEAR wa_curramount.
ENDFORM. " build_bapi_parameters
*&---------------------------------------------------------------------*
*& Form build_bapi_parameters4
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
FORM build_bapi_parameters4.
*Build account GL data for BAPI
wa_accountgl-itemno_acc = 4. " Line Item Number
wa_accountgl-gl_account = '0000256167'. " GL Account Number
wa_accountgl-comp_code = '0050'. " Company Code
wa_accountgl-pstng_date = '12012006'. " Posting Date
wa_accountgl-doc_type = 'KQ'. " Document Type
wa_accountgl-fisc_year = '2006'. " Fiscal Year
wa_accountgl-fis_period = '12'. " Fiscal Period
wa_accountgl-item_text = ''. " Item Text
APPEND wa_accountgl TO accountgl.
CLEAR wa_accountgl.
*Build currency data for BAPI
wa_curramount-itemno_acc = 4. " Line Item Number
wa_curramount-curr_type = '00'. " Currency Type
wa_curramount-currency = 'USD'. " Currency Key
wa_curramount-currency_iso = 'USD'. " ISO Code
wa_curramount-amt_doccur = '-250.00'. " Amount
wa_curramount-amt_base = ''. " Base Amount
APPEND wa_curramount TO curramount.
CLEAR wa_curramount.
ENDFORM. " build_bapi_parameters
*&---------------------------------------------------------------------*
*& Form update_gl
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
FORM update_gl.
CALL FUNCTION 'BAPI_ACC_INVOICE_RECEIPT_POST'
EXPORTING
documentheader = docheader
IMPORTING
obj_type = obj_type
obj_key = obj_key
obj_sys = obj_sys
TABLES
accountpayable = accountpay
accountgl = accountgl
accounttax = accounttax
currencyamount = curramount
return = return
extension1 = extension1.
LOOP AT return INTO wa_return.
WRITE: / 'Return Type: ', wa_return-type.
WRITE: / 'Return ID: ', wa_return-id.
WRITE: / 'Return #: ', wa_return-number.
WRITE: / 'Message 1: ', wa_return-message.
WRITE: / 'Message 2: ', wa_return-message_v1.
WRITE: / 'Message 3: ', wa_return-message_v2.
WRITE: / 'Parameter: ', wa_return-parameter.
WRITE: / 'Row: ', wa_return-row.
WRITE: / 'Field: ', wa_return-field.
WRITE: / 'System: ', wa_return-system.
SKIP.
ULINE.
SKIP.
ENDLOOP.
* CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'
* EXPORTING
* wait = wait
* IMPORTING
* return = comm_return.
*
* REFRESH: accountgl, curramount, return, extension1.
* CLEAR: docheader.
ENDFORM. " update_gl
END-OF-SELECTION.
LINE-COUNT 65
LINE-SIZE 132.
DATA:
wait TYPE bapita-wait,
comm_return TYPE bapiret2,
obj_type TYPE bapiache02-obj_type,
obj_key TYPE bapiache02-obj_key,
obj_sys TYPE bapiache02-obj_sys,
accountgl LIKE STANDARD TABLE OF bapiacgl03, "Structure
wa_accountgl LIKE LINE OF accountgl,
docheader TYPE bapiache03, "Structure
accountpay TYPE STANDARD TABLE OF bapiacap03, "Structure
wa_accountpay LIKE LINE OF accountpay,
accounttax TYPE STANDARD TABLE OF bapiactx01, "Structure
wa_accounttax LIKE LINE OF accounttax,
curramount TYPE STANDARD TABLE OF bapiaccr01, "Structure
wa_curramount LIKE LINE OF curramount,
return TYPE STANDARD TABLE OF bapiret2, "Structure
wa_return LIKE LINE OF return,
extension1 TYPE STANDARD TABLE OF bapiextc, "Structure
wa_extension1 LIKE LINE OF extension1.
START-OF-SELECTION.
PERFORM build_header_rec.
PERFORM build_bapi_parameters1.
PERFORM build_bapi_parameters2.
PERFORM build_bapi_parameters3.
PERFORM build_bapi_parameters4.
PERFORM update_gl.
*&---------------------------------------------------------------------*
*& Form build_header_rec
*&---------------------------------------------------------------------*
FORM build_header_rec.
*build header data for bapi
CALL FUNCTION 'OWN_LOGICAL_SYSTEM_GET'
IMPORTING
own_logical_system = docheader-obj_sys.
docheader-obj_type = 'BKPFF'.
docheader-obj_key = 'test1'.
docheader-username = sy-uname.
docheader-comp_code = '0050'. " Company Code
docheader-fisc_year = '2006'. " Fiscal Year
docheader-doc_date = '12012006'. " Document Date
docheader-pstng_date = '12012006'. " Posting Date
docheader-trans_date = '12012006'. " Translation Date
docheader-fis_period = '12'. " Fiscal Period
docheader-doc_type = 'KQ'. " Document Type
docheader-ref_doc_no = 'T&S'. " Reference
ENDFORM. " build_header_rec
*&---------------------------------------------------------------------*
*& Form build_bapi_parameters1
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
FORM build_bapi_parameters1.
*Build Accounts Payable data for BAPI
wa_accountpay-itemno_acc = 1. " Line Item Number
wa_accountpay-vendor_no = 'TSA01004'. " Vendor Number
wa_accountpay-gl_account = '0000290430'. " GL Account Number
wa_accountpay-pmnttrms = 'NT00'. " Payment Terms
wa_accountpay-bline_date = '12012006'. " Bline Date
wa_accountpay-pmtmthsupl = '06'. " Payment Method Supplement
wa_accountpay-pymt_meth = 'S'. " Payment Method
wa_accountpay-item_text = '*T&S Withdrawal'. " Text
wa_accountpay-w_tax_code = '**'. " Tax Code
APPEND wa_accountpay TO accountpay.
CLEAR wa_accountpay.
*Build account GL data for BAPI
wa_accountgl-itemno_acc = 1. " Line Item Number
wa_accountgl-gl_account = '0000290430'. " GL Account Number
wa_accountgl-comp_code = '0050'. " Company Code
wa_accountgl-pstng_date = '12012006'. " Posting Date
wa_accountgl-doc_type = 'KQ'. " Document Type
wa_accountgl-fisc_year = '2006'. " Fiscal Year
wa_accountgl-fis_period = '12'. " Fiscal Period
wa_accountgl-item_text = ''. " Item Text
APPEND wa_accountgl TO accountgl.
CLEAR wa_accountgl.
*Build currency data for BAPI
wa_curramount-itemno_acc = 1. " Line Item Number
wa_curramount-curr_type = '00'. " Currency Type
wa_curramount-currency = 'USD'. " Currency Key
wa_curramount-currency_iso = 'USD'. " ISO Code
wa_curramount-amt_doccur = '-3750.00'. " Amount
wa_curramount-amt_base = '5000.00'. " Base Amount
APPEND wa_curramount TO curramount.
CLEAR wa_curramount.
ENDFORM. " build_bapi_parameters
*&---------------------------------------------------------------------*
*& Form build_bapi_parameters2
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
FORM build_bapi_parameters2.
*Build account GL data for BAPI
wa_accountgl-itemno_acc = 2. " Line Item Number
wa_accountgl-gl_account = '0000720300'. " GL Account Number
wa_accountgl-comp_code = '0050'. " Company Code
wa_accountgl-pstng_date = '12012006'. " Posting Date
wa_accountgl-doc_type = 'KQ'. " Document Type
wa_accountgl-fisc_year = '2006'. " Fiscal Year
wa_accountgl-fis_period = '12'. " Fiscal Period
wa_accountgl-item_text = ''. " Item Text
APPEND wa_accountgl TO accountgl.
CLEAR wa_accountgl.
*Build currency data for BAPI
wa_curramount-itemno_acc = 2. " Line Item Number
wa_curramount-curr_type = '00'. " Currency Type
wa_curramount-currency = 'USD'. " Currency Key
wa_curramount-currency_iso = 'USD'. " ISO Code
wa_curramount-amt_doccur = '5000.00'. " Amount
wa_curramount-amt_base = ''. " Base Amount
APPEND wa_curramount TO curramount.
CLEAR wa_curramount.
ENDFORM. " build_bapi_parameters
*&---------------------------------------------------------------------*
*& Form build_bapi_parameters3
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
FORM build_bapi_parameters3.
*Build account GL data for BAPI
wa_accountgl-itemno_acc = 3. " Line Item Number
wa_accountgl-gl_account = '0000256166'. " GL Account Number
wa_accountgl-comp_code = '0050'. " Company Code
wa_accountgl-pstng_date = '12012006'. " Posting Date
wa_accountgl-doc_type = 'KQ'. " Document Type
wa_accountgl-fisc_year = '2006'. " Fiscal Year
wa_accountgl-fis_period = '12'. " Fiscal Period
wa_accountgl-item_text = ''. " Item Text
APPEND wa_accountgl TO accountgl.
CLEAR wa_accountgl.
*Build currency data for BAPI
wa_curramount-itemno_acc = 3. " Line Item Number
wa_curramount-curr_type = '00'. " Currency Type
wa_curramount-currency = 'USD'. " Currency Key
wa_curramount-currency_iso = 'USD'. " ISO Code
wa_curramount-amt_doccur = '-1000.00'. " Amount
wa_curramount-amt_base = ''. " Base Amount
APPEND wa_curramount TO curramount.
CLEAR wa_curramount.
ENDFORM. " build_bapi_parameters
*&---------------------------------------------------------------------*
*& Form build_bapi_parameters4
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
FORM build_bapi_parameters4.
*Build account GL data for BAPI
wa_accountgl-itemno_acc = 4. " Line Item Number
wa_accountgl-gl_account = '0000256167'. " GL Account Number
wa_accountgl-comp_code = '0050'. " Company Code
wa_accountgl-pstng_date = '12012006'. " Posting Date
wa_accountgl-doc_type = 'KQ'. " Document Type
wa_accountgl-fisc_year = '2006'. " Fiscal Year
wa_accountgl-fis_period = '12'. " Fiscal Period
wa_accountgl-item_text = ''. " Item Text
APPEND wa_accountgl TO accountgl.
CLEAR wa_accountgl.
*Build currency data for BAPI
wa_curramount-itemno_acc = 4. " Line Item Number
wa_curramount-curr_type = '00'. " Currency Type
wa_curramount-currency = 'USD'. " Currency Key
wa_curramount-currency_iso = 'USD'. " ISO Code
wa_curramount-amt_doccur = '-250.00'. " Amount
wa_curramount-amt_base = ''. " Base Amount
APPEND wa_curramount TO curramount.
CLEAR wa_curramount.
ENDFORM. " build_bapi_parameters
*&---------------------------------------------------------------------*
*& Form update_gl
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
FORM update_gl.
CALL FUNCTION 'BAPI_ACC_INVOICE_RECEIPT_POST'
EXPORTING
documentheader = docheader
IMPORTING
obj_type = obj_type
obj_key = obj_key
obj_sys = obj_sys
TABLES
accountpayable = accountpay
accountgl = accountgl
accounttax = accounttax
currencyamount = curramount
return = return
extension1 = extension1.
LOOP AT return INTO wa_return.
WRITE: / 'Return Type: ', wa_return-type.
WRITE: / 'Return ID: ', wa_return-id.
WRITE: / 'Return #: ', wa_return-number.
WRITE: / 'Message 1: ', wa_return-message.
WRITE: / 'Message 2: ', wa_return-message_v1.
WRITE: / 'Message 3: ', wa_return-message_v2.
WRITE: / 'Parameter: ', wa_return-parameter.
WRITE: / 'Row: ', wa_return-row.
WRITE: / 'Field: ', wa_return-field.
WRITE: / 'System: ', wa_return-system.
SKIP.
ULINE.
SKIP.
ENDLOOP.
* CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'
* EXPORTING
* wait = wait
* IMPORTING
* return = comm_return.
*
* REFRESH: accountgl, curramount, return, extension1.
* CLEAR: docheader.
ENDFORM. " update_gl
END-OF-SELECTION.