You must have completed the required steps in Defining and Using a Basic Type .
In the case of synchronous methods, you do not have to define an event which is used by the method for confirmations.
You have implemented a method using a specified ABAP program. You must now create a 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 source text 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 using forward navigation (double-click). The function module reads the data from the IDoc and generates an event if an error occurs (by calling the 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 source text 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.
Application abbreviation |
V (Sales and Distribution) |
Processing type |
Normal, start immediately |
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
* Create a function module (direct
inbound processing)
ENDFORM. " INITIALIZE_ORGANIZATIONAL_DATA
FORM READ_IDOC_TESTER.
...
* Form
routine and called routines as in section
* Create a function module (direct
inbound processing)
ENDFORM. " READ_IDOC_TESTER
FORM CALL_VA01_IDOC_ORDERS using errorcode.
* call transaction first dynpro
PERFORM DYNPRO_START.
* call transaction double-line entry
PERFORM DYNPRO_DETAIL2.
* incoterms
PERFORM DYNPRO_HEAD_300.
* call transaction item datas
PERFORM DYNPRO_POSITION.
PERFORM DYNPRO_SET USING 'BDC_OKCODE' 'SICH'.
* call transaction VA01
CALL TRANSACTION 'VA01' USING BDCDATA
MODE 'N'
UPDATE 'S'
MESSAGES INTO XBDCMSGCOLL.
errorcode = SY-SUBRC. " remember returncode for status update
ENDFORM. " CALL_VA01_IDOC_ORDERS
FORM DYNPRO_START.
...
* Form
routine and called routines as in section
* Create a function module (direct
inbound processing)
ENDFORM. " DYNPRO_START
FORM WRITE_STATUS_RECORD TABLES i_edids STRUCTURE edi_ds
USING errorcode.
* fill status record
I_EDIDS-DOCNUM = IDOC_CONTRL-DOCNUM.
I_EDIDS-LOGDAT = SY-DATE.
IF errorcode = 0.
I_EDIDS-STATUS = BELEG_GEBUCHT. "value 53
GET PARAMETER ID 'AUN' FIELD BELEGNUMMER.
I_EDIDS-STAMID = 'V1'.
I_EDIDS-STAMNO = '311'.
I_EDIDS-STAPA1 = 'Standard order'.
I_EDIDS-STAPA2 = DOCUMENT NUMBER.
ELSE.
I_EDIDS-STATUS = BELEG_NICHT_GEBUCHT. "value 51
I_EDIDS-STAMID = SY-MSGID.
I_EDIDS-STAMNO = SY-MSGNO.
I_EDIDS-STAPA1 = SY-MSGV1.
I_EDIDS-STAPA2 = SY-MSGV2.
I_EDIDS-STAPA3 = SY-MSGV3.
I_EDIDS-STAPA4 = SY-MSGV4.
ENDIF.
CALL FUNCTION 'EDI_DOCUMENT_STATUS_SET'
EXPORTING
document_number = idoc_contrl-docnum
idoc_status = i_edids
IMPORTING
idoc_control = idoc_contrl
EXCEPTIONS
document_number_invalid = 01
other_fields_invalid = 02
status_invalid = 03.
ENDFORM. " WRITE_STATUS_RECORD
Globale Daten von IDOC_INPUT_WF_TESTER
data:
idoc_data LIKE edidd occurs 10 WITH HEADER LINE,
idoc_contrl LIKE edidc occurs 1 WITH HEADER LINE.
* further data like
in the section
* Create a function module (direct
inbound processing)