Invoice Receipt Date in SAP MIR7 Transaction
Last step is Save and Open MIR7 Transaction
A step-by-step guide to extend AR01 functionality with custom fields and logic in SAP ABAP.
In this tutorial, we will explore how to add a custom file in tcode AR01 by
enhancing the program RABEST_ALV01. The approach involves using the
main structure FIAA_SALVTAB_RABEST and the include structure
CI_REPRABEST.
Below is the ABAP code snippet inserted into the program
RABEST_ALV01 to fetch additional information such as
cost center, profit center, asset class description, and long text:
FIELD-SYMBOLS: <ANLN1> TYPE ANY.
FIELD-SYMBOLS: <ANLKL> TYPE ANY.
FIELD-SYMBOLS: <KOSTL> TYPE ANY.
FIELD-SYMBOLS: <PRCTR> TYPE ANY.
FIELD-SYMBOLS: <LTEXT> TYPE ANY.
FIELD-SYMBOLS: <TXK50> TYPE ANY.
LOOP AT <itab_data>[] ASSIGNING FIELD-SYMBOL(<fs_csfield>).
ASSIGN COMPONENT 'KOSTL' OF STRUCTURE <fs_csfield> TO <KOSTL>.
ASSIGN COMPONENT 'PRCTR' OF STRUCTURE <fs_csfield> TO <PRCTR>.
ASSIGN COMPONENT 'ANLKL' OF STRUCTURE <fs_csfield> TO <ANLKL>.
ASSIGN COMPONENT 'TXK50' OF STRUCTURE <fs_csfield> TO <TXK50>.
ASSIGN COMPONENT 'LTEXT' OF STRUCTURE <fs_csfield> TO <LTEXT>.
SELECT SINGLE PRCTR FROM CSKS
INTO <PRCTR> WHERE KOSTL = <KOSTL>.
SELECT SINGLE LTEXT FROM CEPCT
INTO <LTEXT> WHERE PRCTR = <PRCTR> AND SPRAS = sy-langu.
SELECT SINGLE TXK50 FROM ANKT
INTO <TXK50> WHERE SPRAS = sy-langu AND ANLKL = <ANLKL>.
ENDLOOP.
By adding the above logic into RABEST_ALV01, you can extend the AR01
report to include additional information like cost center descriptions, profit
center texts, and asset class details. This approach provides flexibility for
financial reporting in SAP.
Summary: This tutorial shows how to build a REST API in SAP ABAP by creating a handler class, configuring SICF service, registering endpoints with
cl_rest_router, implementing endpoint logic (example GET method), and testing the API. Based on an internal implementation reference.
REST APIs allow SAP systems to integrate with web, mobile, and external services using standard HTTP and JSON payloads. Implementing REST endpoints in ABAP provides secure, reusable, and maintainable integration points for modern applications.
CL_REST_RESOURCE, CL_REST_ROUTER and utilities like /UI2/CL_JSON.ZCL_API_HANDLER).cl_rest_router./sap/bc/zapi01).Create class ZCL_API_HANDLER in SE24, implement CL_REST_HTTP_HANDLER, and register endpoints.
DATA(lo_router) = NEW cl_rest_router( ).
lo_router->attach(
EXPORTING
iv_template = '/ZFLIGHTLIST'
iv_handler_class = 'ZCL_FLIGHT01' ).
ro_root_handler = lo_router.
In SICF, create a new service node (e.g. ZAPI01) and attach your handler class ZCL_API_HANDLER. Activate the service.
Make class ZCL_FLIGHT01 inheriting from CL_REST_RESOURCE. Redefine GET/POST methods.
METHOD if_rest_resource~get.
" Parse JSON request
DATA(lo_entity) = mo_request->get_entity( ).
DATA(lv_data) = lo_entity->get_string_data( ).
DATA: ls_params TYPE ty_flight.
/ui2/cl_json=>deserialize( json = lv_data changing data = ls_params ).
" Read SFLIGHT
IF ls_params IS NOT INITIAL.
SELECT * FROM sflight INTO TABLE @DATA(lt_flight)
WHERE carrid = @ls_params-carrid
AND connid = @ls_params-connid.
ELSE.
SELECT * FROM sflight INTO TABLE @lt_flight.
ENDIF.
" Build JSON response
IF lt_flight IS NOT INITIAL.
/ui2/cl_json=>serialize( data = lt_flight RECEIVING r_json = lv_result ).
lv_result = '{"Status":"OK","Message":"SUCCESS","Data":' && lv_result && '}'.
ELSE.
lv_result = '{"Status":"ERROR","Message":"DATA NOT FOUND"}'.
ENDIF.
lo_response->set_string_data( iv_data = lv_result ).
lo_response->set_header_field(
EXPORTING iv_name = 'CONTENT-TYPE'
iv_value = 'APPLICATION/JSON' ).
ENDMETHOD.
Test with Postman or cURL. Example:
curl -u username:password -X GET "https://your-sap-host/sap/bc/zapi01/ZFLIGHTLIST" \
-H "Content-Type: application/json" \
-d '{"carrid":"AA","connid":"0017"}'
Inside cl_rest_router in the handler class.
SICF is used to create and activate the service node.
/UI2/CL_JSON is commonly used for JSON serialization and deserialization.
In SAP MM, supplier invoice approval is often handled using the Flexible Workflow. However, standard configuration may not fully cover complex approval requirements. In such cases, Custom Agent Determination can be implemented using BAdI MRM_WORKFLOW_AGENTS.
This blog explains how to implement a custom approval workflow for supplier invoices (MIR7), including creating custom tables, CDS views, Fiori custom logic, and defining workflow conditions.
Two custom tables are required:
Table: ZMMT007 (Supplier Invoice Approval Agent Assignment)
FUNCTION – Function keyFUNDESC – Function descriptionAPP_LVL – Approval levelBUS_USR – Business userTable: ZMMT008 (Invoice Release Strategy)
ZREL_GROUP – Release groupZREL_STRAT – Release strategyZFUNCTION – FunctionZSIGN – Comparison signZCURR – CurrencyZAMOUNT – Amount thresholdCDS views are required for retrieving approval mapping data. Example definitions:
@AbapCatalog.sqlViewName: 'ZIWFINVOICE'
define view ZI_SUPP_INV_WF as select from zmmt007 {
key function as Function,
fundesc as FuncDesc,
app_lvl as AppLvl,
bus_usr as BusUser
}
@AbapCatalog.sqlViewName: 'ZIWFINVOICEREL'
define view ZI_SUPP_INV_REL_MAP as select from zmmt008 {
key zrel_group,
key zrel_strat,
zfunction,
zsign,
zcurr,
zamount
}
Make sure to release CDS Views for usage in custom logic by setting the API State to Use System-Internally (Contract C1).
Navigate to Custom Logic app in Fiori and create a new implementation:
Sample ABAP snippet for custom agent selection:
DATA: lt_wf TYPE TABLE OF ZI_SUPP_INV_WF,
lt_wf_rel TYPE TABLE OF zi_supp_inv_rel_map,
ls_wf_relx TYPE zi_supp_inv_rel_map.
SELECT * FROM I_SupplierInvoiceAPI01
WHERE SupplierInvoice = @supplierinvoice
AND FiscalYear = @FiscalYear
INTO TABLE @DATA(lt_SupplierInv).
IF ls_invoice-companycode = 'JSB'
AND ls_invoice-ACCOUNTINGDOCUMENTTYPE = 'RE'
AND ls_invoice-INVOICEGROSSAMOUNT >= 1.
SELECT * FROM zi_supp_inv_rel_map
WHERE zrel_group = 'WPO-GEN-WF'
AND zrel_strat = 'ALL'
INTO TABLE @lt_wf_rel.
ENDIF.
In the Filter tab, set the filter: workflowscenario = WS00800303.
In the Fiori app Manage Workflows for Supplier Invoices, configure the workflows according to business rules. For example:
By combining custom tables, CDS views, and Fiori custom logic, businesses can implement robust and flexible approval workflows for supplier invoices in SAP. This approach ensures compliance, supports complex approval hierarchies, and automates the agent determination process.
👉 If you’re also interested in other SAP MM workflow enhancements, check out our related article on SAP Invoice Splitting.
In SAP Business Partner (BP) transactions, setting default values can help streamline data entry and ensure consistency across the system. For example, you may want to predefine a default language or tolerance group at the company level. SAP provides a standard way to handle this through the BUSDEFAULT structure and enhancement options.
This guide explains how to set default BP values using customer exits and the function module BUP_BUPA_FIELDVALUES_SET.
SAP provides a structure called BUSDEFAULT, which contains fields that can be configured with default values. You can explore it using transaction SE11.
Some of the key fields available in BUSDEFAULT include:
For a detailed reference, SAP Note 2992030 provides more insights into this feature.
Follow these steps to configure default values for SAP BP:
BUP_BUPA_FIELDVALUES_SET to populate default values.
DATA i_busdefault TYPE busdefault.
CLEAR i_busdefault.
i_busdefault-langu = sy-langu.
CALL FUNCTION 'BUP_BUPA_FIELDVALUES_SET'
EXPORTING
i_busdefault = i_busdefault.
This example sets the default language (LANGU) based on the system language (sy-langu).
In transaction BUS7, add a new entry to link the function module with the event:
Z_BUP_BUPA_DEFAULTS)This ensures the default values are applied automatically whenever BP data is processed.
By leveraging the BUSDEFAULT structure and BUP_BUPA_FIELDVALUES_SET function module, you can automate the process of setting default values in SAP Business Partner (BP). This not only saves time but also improves data consistency and reduces manual errors.
For complex requirements, you can extend this approach by customizing additional fields within the BUSDEFAULT structure and linking them to events in BUS7.
In SAP Financial Accounting (FI), managing invoices efficiently is critical for smooth financial operations. One of the most requested enhancements by businesses is invoice splitting, especially when dealing with complex procurement or billing scenarios. SAP provides flexibility through Business Add-Ins (BAdIs), allowing developers to customize invoice processing in both MIRO (Invoice Receipt) and VF01 (Billing Document Creation).
This article explains the process of invoice splitting in SAP using the relevant BAdIs:
By the end, you’ll have a clear understanding of how to implement and optimize invoice splitting to meet business needs.
Invoice splitting refers to dividing a single invoice into multiple accounting documents based on predefined criteria, such as:
This ensures accurate financial postings and better transparency for reporting and auditing.
When processing supplier invoices in MIRO, SAP allows enhancement through the BAdI:
BAdI Name: FI_INVOICE_RECEIPT_SPLIT
For billing documents created in VF01, SAP provides another enhancement:
BAdI Name: FI_BILL_ISSUE_SPLIT
SE18/SE19 to locate and enhance the BAdI. Write custom ABAP logic for splitting criteria.Invoice splitting in SAP is a powerful way to enhance financial accuracy and reporting. By leveraging BAdIs such as FI_INVOICE_RECEIPT_SPLIT (for MIRO) and FI_BILL_ISSUE_SPLIT (for VF01), businesses can tailor invoice processing to match their financial and compliance needs.
Implementing these enhancements not only improves transparency but also saves significant manual effort, making financial operations more reliable and efficient.
👉 Looking to implement SAP invoice splitting in your system? Our step-by-step guide and best practices will help you streamline the process and achieve compliance with ease.
In SAP Financial Accounting (FI), line item reports such as
FBL1N (Vendor Line Items),
FBL3N (G/L Account Line Items), and
FBL5N (Customer Line Items) are heavily used.
Business users often require custom fields in these reports.
This guide explains how to add custom fields step by step with ABAP.
Extend the standard structure RFPOSX by appending your custom fields.
Execute program RFPOSXEXTEND to regenerate the structure and make
the appended fields available in the FBL reports.
Implement BADI FI_ITEMS_CH_DATA and enhance method
CHANGE_ITEMS to fill the new custom fields.
METHOD if_ex_fi_items_ch_data~change_items.
CONSTANTS : lc_fbl1n TYPE tcode VALUE 'FBL1N'.
CONSTANTS : lc_fbl3n TYPE tcode VALUE 'FBL3N'.
CONSTANTS : lc_fbl5n TYPE tcode VALUE 'FBL5N'.
IF sy-tcode = lc_fbl1n.
LOOP AT ct_items ASSIGNING FIELD-SYMBOL(<fs_items>).
IF NOT <fs_items>-konto IS INITIAL.
SELECT CONCAT( adrc~name1, adrc~name2 )
FROM adrc
INNER JOIN lfa1 ON adrc~addrnumber = lfa1~adrnr
WHERE lfa1~lifnr = @<fs_items>-konto
INTO @<fs_items>-zvend_name UP TO 1 ROWS.
ENDSELECT.
ENDIF.
SELECT SINGLE txt50 FROM skat INTO <fs_items>-zhkontnm
WHERE ktopl = '2000' AND saknr = <fs_items>-hkont AND spras = 'E'.
ENDLOOP.
ENDIF.
IF sy-tcode = lc_fbl5n.
LOOP AT ct_items ASSIGNING <fs_items>.
IF NOT <fs_items>-konto IS INITIAL.
SELECT CONCAT( adrc~name1, adrc~name2 )
FROM adrc
INNER JOIN kna1 ON adrc~addrnumber = kna1~adrnr
WHERE kna1~kunnr = @<fs_items>-konto
INTO @<fs_items>-zcust_name UP TO 1 ROWS.
ENDSELECT.
ENDIF.
SELECT SINGLE txt50 FROM skat INTO <fs_items>-zhkontnm
WHERE ktopl = '2000' AND saknr = <fs_items>-hkont AND spras = 'E'.
ENDLOOP.
ENDIF.
IF sy-tcode = lc_fbl3n.
LOOP AT ct_items ASSIGNING <fs_items>.
SELECT SINGLE txt50 FROM skat INTO <fs_items>-zhkontnm
WHERE ktopl = '2000' AND saknr = <fs_items>-hkont AND spras = 'E'.
IF NOT <fs_items>-konto IS INITIAL.
SELECT SINGLE txt50 FROM skat INTO <fs_items>-zsaknrnm
WHERE ktopl = '2000' AND saknr = <fs_items>-konto AND spras = 'E'.
ENDIF.
ENDLOOP.
ENDIF.
ENDMETHOD.
RFPOSXEXTEND after appending fields to regenerate structures.SPRSL for language-dependent texts.
By appending structure RFPOSX, running program
RFPOSXEXTEND, and implementing
BADI FI_ITEMS_CH_DATA,
you can successfully add custom fields to reports
FBL1N, FBL3N, and FBL5N.
This enhancement ensures upgrade safety, flexibility,
and fulfills business requirements effectively.
Upload Count PID dengan BAPI di ABAP — Contoh Program YMMC100 Upload Count PID dengan BAPI di ABAP — Progr...