FORM analyzing_event_create
TABLES
t_couple_to_process_in STRUCTURE ediinbound
USING
commit_counter_in LIKE ediglodata-comcount
start_recfb_synchron_in LIKE ediglodata-inbsync.
* local variables
DATA:
* instance that is created
l_object TYPE swc_object,
* object key, e.g IDoc number
l_object_key LIKE swotobjid-objkey,
* id of wf event
l_event_id LIKE swedumevid-evtid,
* status record for case of error
l_status_record TYPE tidoc_status_record_ext,
* flag indicating whether subscribed task is started synchronously
l_start_recfb_synchron LIKE sweflags-syncflag VALUE ' ',
* idoc number (needed because of type checking)
l_idoc_number LIKE edidc-docnum.
* local constants
CONSTANTS:
* object type 'IDOC'
c_object_type LIKE swetypecou-objtype VALUE 'IDOCINVOIC',
* name of event to be created
c_idc_evt LIKE swetypecou-event VALUE 'INPUTERROROCCURREDMM'
.
if t_couple_to_process_in[] is initial.
COMMIT WORK.
CALL FUNCTION 'DEQUEUE_ALL'.
CLEAR commit_counter_in.
exit.
endif.
* dequeue all idocs at the same time
LOOP AT t_couple_to_process_in.
* cast
l_idoc_number = t_couple_to_process_in(16).
CALL FUNCTION 'EDI_DOCUMENT_DEQUEUE_LATER'
EXPORTING
docnum = l_idoc_number
EXCEPTIONS
OTHERS = 0.
ENDLOOP.
* get first idoc number in table in order to create an object
READ TABLE t_couple_to_process_in INDEX 1.
* set object key in variable of correct type (casting)
l_object_key = t_couple_to_process_in(16).
* create an object, i.e. an IDoc
swc_create_object l_object c_object_type l_object_key.
* fill container: work item object id (idoc)
swc_set_element l_t_ev_container "EC *
c_element_wi_obj_id "EC *
l_object. "EC *
* fill container: NumberPlusEventcode (table of couples)
swc_set_table l_t_ev_container
c_element_no_plus_info
t_couple_to_process_in.
IF ( sy-subrc <> 0 )
* event was not created => error handling for this idoc (EDIM)
OR ( l_event_id = 0 ).
* stop processing, no commit
MESSAGE ID 'E0'
TYPE 'A'
NUMBER '374'
WITH l_status_record-docnum
c_idc_evt
RAISING event_create_failed.
ELSE.
* do commit and reset counter
* the commit will get the idocs to the database and at the same time
* activate the event that was created
COMMIT WORK.
* dequeue all unprocessed IDocs to avoid log-overflow
CALL FUNCTION 'DEQUEUE_ALL'.
CLEAR commit_counter_in.
* reset table of idocs that need to be processed
CLEAR t_couple_to_process_in.
REFRESH t_couple_to_process_in.
ENDIF.
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum You cannot attach files in this forum You can download files in this forum
All product names are trademarks of their respective companies. SAPNET.RU websites are in no way affiliated with SAP AG. SAP, SAP R/3, R/3 software, mySAP, ABAP, BAPI, xApps, SAP NetWeaver and any other are registered trademarks of SAP AG. Every effort is made to ensure content integrity. Use information on this site at your own risk.