Defining Inbound Processing as an Object Method 
Prerequisites
You must have completed the required steps in
Defining and Using a Basic Type .Procedure
In the case of synchronous methods, you do not have to define an event which is used by the method for confirmations.
Result
You have implemented a method using a specified ABAP program. You must now create a standard task which refers to this method and to the corresponding object type.

In the example, you should define the synchronous, dialog-free method inputBackgroundTest for your object type IDOCTEST. The ABAP coding appears as follows:
INCLUDE <OBJECT>. " Workflow-Makros zur Objektdefinition
begin_data object. " Do not change.. DATA is generated
* only private members may be inserted into structure private
data:
" begin of private,
" to declare private attributes remove comments and
" insert private attributes here...
" end of private,
begin of key,
idocnumber like edidc-docnum,
end of key.
end_data object. " Do not change.. DATA is generated
...
BEGIN_METHOD inputBackgroundTest changing container.
CALL FUNCTION 'IDOC_INPUT_WF_TESTER'
EXPORTING idocnumber = object-key-idocnumber
EXCEPTIONS
OTHERS = 01.
END_METHOD.
The transferred parameter is
idocnumber , which the object type IDOCTEST has inherited as a key field from the supertype IDOCAPPL.You can create the function module IDOC_INPUT_WF_TESTER via forward navigation (double click). The function module reads the data from the IDoc and triggers an event if an error occurs (by calling the workflow function module SWE_EVENT_CREATE). In the form routine READ_IDOC_TESTER, you can see how data from an IDoc table is turned into application tables via segment structures.

In the following coding it is often referred to the analog for direct inbound processing (for example, IDOC_INPUT_TESTER), however only for reasons of space, since you must select either the direct or the Workflow Inbound Processing.
Administration parameters for IDOC_INPUT_WF_TESTER:
Application abbreviation |
V (Sales and Distribution) |
Processing type |
normal, start immediately |
Coding example
FUNCTION IDOC_INPUT_WF_TESTER.
*---------------------------------------------------------
*Globale Schnittstelle:
* IMPORTING idocnumber LIKE EDIDC-DOCNUM
*---------------------------------------------------------
INCLUDE <CNTN01>. " Workflow-Makros zur Containerdefinition
DATA:
i_edids LIKE edi_ds OCCURS 1 WITH HEADER LINE,
event_id like swedumevid-evtid,
status like edids-status,
cidocnumber like sweinstcou-objkey,
errorcode like sy-subrc. "Für Test der Ausnahmebehandlung
swc_container ev_container.
* initialize SET/GET parameters and internal tables
PERFORM INITIALIZE_ORGANIZATIONAL_DATA.
CALL FUNCTION 'EDI_DOCUMENT_OPEN_FOR_PROCESS'
EXPORTING
document_number = idocnumber
IMPORTING
idoc_control = idoc_contrl
EXCEPTIONS
document_foreign_lock = 01
document_not_exist = 02
document_number_invalid = 03
document_is_already_open = 04.
CALL FUNCTION 'EDI_SEGMENTS_GET_ALL'
EXPORTING
document_number = idocnumber
TABLES
idoc_containers = idoc_data
EXCEPTIONS
document_number_invalid = 01
end_of_document = 02.
PERFORM READ_IDOC_TESTER.
PERFORM CALL_VA01_IDOC_ORDERS
using errorcode.
PERFORM WRITE_STATUS_RECORD TABLES i_edids "Write status
USING errorcode.
CALL FUNCTION 'EDI_DOCUMENT_CLOSE_PROCESS'
EXPORTING
document_number = idocnumber
IMPORTING
idoc_control = idoc_contrl
EXCEPTIONS
document_not_open = 01
failure_in_db_write = 02
parameter_error = 03
status_set_missing = 04.
IF errorcode <> 0.
cidocnumber = idocnumber.
CALL FUNCTION 'SWE_EVENT_CREATE'
EXPORTING
objtype = 'IDOCTEST'
objkey = cidocnumber
event = 'InputErrorOccurred'
start_recfb_synchron = 'X' "synchroner Aufruf
IMPORTING
event_id = event_id
TABLES
event_container = ev_container
EXCEPTIONS
objtype_not_found = 1
others = 2.
COMMIT WORK.
ENDIF.
ENDFUNCTION.
FORM INITIALIZE_ORGANIZATIONAL_DATA
...
* Form routine as in section
*