Friday, May 13, 2005

Post an FI document using BAPI

To post an FI document with AR/AP/GL information one can use the BAPI BAPI_ACC_DOCUMENT_POST. Example usage is as below:

*-- Fill Header
  ls_document_hdr-username = sy-uname.
  ls_document_hdr-header_txt = ls_v_tree-mblnr.
  ls_document_hdr-bus_act = 'RMRP'.
  ls_document_hdr-comp_code = ls_v_master-cur_bukrs.
  ls_document_hdr-doc_date = sy-datum.
  ls_document_hdr-pstng_date = sy-datum.
  ls_document_hdr-doc_type = 'SA'.
  ls_document_hdr-header_txt = ls_v_tree-vbeln.
  ls_document_hdr-ref_doc_no = ls_v_tree-vbeln.
*-- fill AR (line 1)
  lt_accountreceivable-itemno_acc = 1.
  lt_accountreceivable-customer = ls_v_tree-kunnr.
  lt_accountreceivable-ref_key_1 = ls_v_tree-vbeln.
  lt_accountreceivable-ref_key_2 = ls_v_tree-vbeln.
  lt_accountreceivable-ref_key_3 = ls_v_tree-vbeln.
  APPEND lt_accountreceivable.
*-- Get
  lt_currency_amt-itemno_acc = 1.
  lt_currency_amt-currency = lv_currency.
  lt_currency_amt-amt_doccur = lv_amount * -1.
  APPEND lt_currency_amt.
  CLEAR lt_currency_amt.
** fill AP (line 2)
  lt_accountpayable-itemno_acc = 2.
  lt_accountpayable-vendor_no = lv_vendor.
  lt_accountpayable-ref_key_1 = ls_v_tree-vbeln.
  lt_accountpayable-ref_key_2 = ls_v_tree-vbeln.
  lt_accountpayable-ref_key_3 = ls_v_tree-vbeln.
  APPEND lt_accountpayable.
  lt_currency_amt-itemno_acc = 2.
  lt_currency_amt-currency = lv_currency.
  lt_currency_amt-amt_doccur = lv_amount.
  APPEND lt_currency_amt.
  CLEAR lt_currency_amt.
  CALL FUNCTION 'BAPI_ACC_DOCUMENT_POST'
    EXPORTING
      documentheader          = ls_document_hdr
*     CUSTOMERCPD             =
*     CONTRACTHEADER          =
    IMPORTING
*     OBJ_TYPE                =
      obj_key                 = lv_key
*     OBJ_SYS                 =
    TABLES
*     ACCOUNTGL               =
      accountreceivable       = lt_accountreceivable
      accountpayable          = lt_accountpayable
*     ACCOUNTTAX              =
      currencyamount          = lt_currency_amt
*     CRITERIA                =
*     VALUEFIELD              =
*     EXTENSION1              =
      return                  = lt_return
*     PAYMENTCARD             =
*     CONTRACTITEM            =
*     EXTENSION2              =
*     REALESTATE              =
*     ACCOUNTWT               =
            .

SD Invoice Verification: Post Invoice

Do Invoice verification and create and post incoming invoices with this BAPI: BAPI_INCOMINGINVOICE_CREATE. Here is an example:

ls_miro_head-invoice_ind = 'X'.
ls_miro_head-doc_date = sy-datum.
ls_miro_head-pstng_date = sy-datum.
ls_miro_head-currency = ls_ekko-waers.
ls_miro_head-comp_code = ls_ekko-bukrs.
ls_miro_items-invoice_doc_item = '000001'.
ls_miro_items-po_number = wa_ekpo-ebeln.
ls_miro_items-po_item = wa_ekpo-ebelp.
ls_miro_head-gross_amount = ls_miro_items-item_amount = wa_ekpo-netwr.
ls_miro_items-quantity = 1.
ls_miro_items-po_unit = gv_isocode.
ls_miro_items-ref_doc = it_migo_beleg-mat_doc.
ls_miro_items-ref_doc_year = it_migo_beleg-doc_year.
ls_miro_items-ref_doc_it = '0001'.
ls_miro_items-tax_code = wa_ekpo-mwskz.
APPEND ls_miro_items TO lt_miro_items.
ls_miro_split-split_key = '000001'.
ls_miro_split-split_amount = wa_ekpo-netwr.
APPEND ls_miro_split TO lt_miro_split.
* --- Call the bapi to create the invoice
CALL FUNCTION 'BAPI_INCOMINGINVOICE_CREATE'
  EXPORTING
    headerdata = ls_miro_head
* ADDRESSDATA =
  IMPORTING
    invoicedocnumber = lw_invoice
* FISCALYEAR =
  TABLES
    itemdata = lt_miro_items
* NFMETALLITMS =
* ACCOUNTINGDATA =
* GLACCOUNTDATA =
* MATERIALDATA =
* TAXDATA =
* WITHTAXDATA =
    vendoritemsplitdata = lt_miro_split
    return = lt_miro_return
. 

Sunday, February 06, 2005

Selection options in output

Sometimes we need to print selection screen values in the output. Use these Functions for that:
  • PRINT_SELECTIONS
  • RS_REPORTSELECTIONS_INFO
  • RS_REFRESH_FROM_SELECTOPTIONS
  • RS_LIST_SELECTION_TABLE

Wednesday, January 26, 2005

Billing Output Type for ALE

Config can be accessed via (V/40):
  • Sales & Dist->Basic Func->Output Control->Output Determination->Determination Using Condition technique->Maintain Output for Billing Documents-Maintain Output type
  • In the processing routines choose Program: RSNASTED and FORM routine: ALE_PROCESSING
In Partner profile (WE20):
  • Choose message type DESADV and process code SD09

Shipping/Deliver Output Type for ALE

Output Type config can be accessed via (V/34):
  • Logistic Executions->Shipping->Basic Functions->Output Control->Output Determination->Maintain Output for Outbound Deliveries->Maintain Output Types
  • In the processing routines choose Program: RSNASTED and FORM routine: ALE_PROCESSING

In Partner profile (WE20):
  • Choose message type DESADV and process code SD05

Sunday, January 23, 2005

ALV list

To create a list using ALV can be done using methods of the class under the package SALV_OBJECT

Tuesday, January 11, 2005

Dynamic modification of Application toolbar area

Sometimes you need to remove a functionality from a screen. For example you want to remove function code LIST from the status CREATE, the code to do this would be:.

SET PF-STATUS 'CREATE' EXCLUDING 'LIST'.

Wednesday, January 05, 2005

Convert CSV to SAP using

To convert CSV text to SAP format use the function module TEXT_CONVERT_TEX_TO_SAP