2008 Apr 01 7:46 AM
Have declared a internal table edids have to check the status of idoc in status 51 and 63 then according to that have to perform some tasks.How to code to check the status of IDOC?
2008 Apr 01 8:05 AM
Hi hema,
U can read the control record and compare the Segment Name,
If it is fine then,
U can read the internal table of type EDIDS with index,
which will give u the status of the iDoc.
Now u implement if else according whether it is 51 or 63.
Thanx,
Navin
Have declared a internal table edids have to check the status of idoc in status 51 and 63 then according to that have to perform some tasks.How to code to check the status of IDOC?
2008 Apr 01 7:49 AM
Use this Tcodes.
WE09 / WE02 IDoc lists according to content.
WE05 View IDocs
Reward if helpful
~Lakshmiraj~
2008 Apr 01 7:52 AM
Hi Hema,
Also the whole list of IDOC status is below
Status Description
00 Not used, only R/2
01 IDoc created
02 Error passing data to port
03 Data passed to port OK
04 Error within control information of EDI subsystem
05 Error during translation
06 Translation OK
07 Error during syntax check
08 Syntax check OK
09 Error during interchange handling
10 Interchange handling OK
11 Error during dispatch
12 Dispatch OK
13 Retransmission OK
14 Interchange Acknowledgement positive
15 Interchange Acknowledgement negative
16 Functional Acknowledgement positive
17 Functional Acknowledgement negative
18 Triggering EDI subsystem OK
19 Data transfer for test OK
20 Error triggering EDI subsystem
21 Error passing data for test
22 Dispatch OK, acknowledgement still due
23 Error during retransmission
24 Control information of EDI subsystem OK
25 Processing despite syntax error (outbound)
26 Error during syntax check of IDoc (outbound)
27 Error in dispatch level (ALE service)
28 Not used
29 Error in ALE service
30 IDoc ready for dispatch (ALE service)
31 Error - no further processing
32 IDoc was edited
33 Original of an IDoc which was edited
34 Error in control record of IDoc
35 IDoc reloaded from archive
36 Electronic signature not performed (timeout)
37 IDoc added incorrectly
38 IDoc archived
39 IDoc is in the receiving system (ALE service)
40 Application document not created in receiving system
41 Application document created in receiving system
42 IDoc was created by test transaction
50 IDoc added
51 Error: Application document not posted
52 Application document not fully posted
53 Application document posted
54 Error during formal application check
55 Formal application check OK
56 IDoc with errors added
57 Test IDoc: Error during application check
58 IDoc-Copy from an R/2 connection
59 Not used
60 Error during syntax check of IDoc (inbound)
61 Processing despite syntax error (inbound)
62 IDoc passed to application
63 Error passing IDoc to application
64 IDoc ready to be transferred to application
65 Error in ALE service
66 IDoc is waiting for predecessor IDoc (serialization)
67 Not used
68 Error - no further processing
69 IDoc was edited
70 Original of an IDoc which was edited
71 IDoc reloaded from archive
72 Not used, only R/2
73 IDoc archived
74 IDoc was created by test transaction
Reward if helpful
~Lakshmiraj~
2008 Apr 01 7:56 AM
2008 Apr 01 8:07 AM
Hi Hema,
Can u explain me ur actual requirment??? Whether idoc is created ????
As per my undestanding pls find the solution below
READING AN IDOC
CALL FUNCTION 'IDOC_READ_COMPLETELY'
EXPORTING
document_number = p_docnum
IMPORTING
idoc_control = s_ordchg_edidc
TABLES
int_edidd = itab_ordchg_edidd
EXCEPTIONS
document_not_exist = 1
document_number_invalid = 2
OTHERS = 3.
Eample Open document for read
CALL FUNCTION 'EDI_DOCUMENT_OPEN_FOR_READ'
EXPORTING
DOCUMENT_NUMBER = iedidc-docnum
IMPORTING
IDOC_CONTROL = IEDIDC
EXCEPTIONS
DOCUMENT_FOREIGN_LOCK = 01
DOCUMENT_NOT_EXIST = 02
DOCUMENT_NUMBER_INVALID = 03
ERROR_MESSAGE = 04
OTHERS = 05.
call function 'EDI_SEGMENTS_GET_ALL'
exporting
document_number = iedidc-docnum
tables
idoc_containers = data_rec
exceptions
document_number_invalid = 1
end_of_document = 2
others = 3.
if not sy-subrc is initial.
CALL FUNCTION 'EDI_DOCUMENT_CLOSE_READ'
EXPORTING
DOCUMENT_NUMBER = iedidc-docnum
IMPORTING
IDOC_CONTROL = iedidcTry to loop that IEDIDC to check its STATUS
The Best way to say thanks in SDN is by rewarding points for helpful answers
Rgds~ Lakshmiraj
2008 Apr 01 8:19 AM
The idocs are generated for a particular range of date.now i have to display a report.
1)In that first have to fetch the idocs of status 51 or 68.
2)Then have to link this idoc to the particular vendor
3)The segment related to the vendor is E1EDKA1LF and the field is PARTN and get the details such as invoice number,date etc and display in a report.
Can u get me?I dont know how to code in this part?
2008 Apr 01 7:56 AM
Hi
Hope it will help you.
Reward if help.
IDOC STATUS:
WE05 T CODE gives the status
Subject: Re: how to know the idocs which are under process
Message: Tcode: WE02
outbound
if the status is 26,29,30 ..idoc is in waiting status
03,12,38 successfully transferres
2,4,5,25 processing error
inbound
53 successfully updated
64 waiting
This is list you will get containing the various status and Idoc could be
00 Not used, only R/2
01 IDoc created
02 Error passing data to port
03 Data passed to port OK
04 Error within control information of EDI subsystem
05 Error during translation
06 Translation OK
07 Error during syntax check
08 Syntax check OK
09 Error during interchange handling
10 Interchange handling OK
11 Error during dispatch
12 Dispatch OK
13 Retransmission OK
14 Interchange Acknowledgement positive
15 Interchange Acknowledgement negative
16 Functional Acknowledgement positive
17 Functional Acknowledgement negative
18 Triggering EDI subsystem OK
19 Data transfer for test OK
20 Error triggering EDI subsystem
21 Error passing data for test
22 Dispatch OK, acknowledgement still due
23 Error during retransmission
24 Control information of EDI subsystem OK
25 Processing despite syntax error (outbound)
26 Error during syntax check of IDoc (outbound)
27 Error in dispatch level (ALE service)
28 Not used
29 Error in ALE service
30 IDoc ready for dispatch (ALE service)
31 Error - no further processing
32 IDoc was edited
33 Original of an IDoc which was edited
34 Error in control record of IDoc
35 IDoc reloaded from archive
36 Electronic signature not performed (timeout)
37 IDoc added incorrectly
38 IDoc archived
39 IDoc is in the receiving system (ALE service)
40 Application document not created in receiving system
41 Application document created in receiving system
42 IDoc was created by test transaction
50 IDoc added
51 Error: Application document not posted
52 Application document not fully posted
53 Application document posted
54 Error during formal application check
55 Formal application check OK
56 IDoc with errors added
57 Test IDoc: Error during application check
58 IDoc-Copy from an R/2 connection
59 Not used
60 Error during syntax check of IDoc (inbound)
61 Processing despite syntax error (inbound)
62 IDoc passed to application
63 Error passing IDoc to application
64 IDoc ready to be transferred to application
65 Error in ALE service
66 IDoc is waiting for predecessor IDoc (serialization)
67 Not used
68 Error - no further processing
69 IDoc was edited
70 Original of an IDoc which was edited
71 IDoc reloaded from archive
72 Not used, only R/2
73 IDoc archived
74 IDoc was created by test transaction
2008 Apr 01 8:05 AM
Hi hema,
U can read the control record and compare the Segment Name,
If it is fine then,
U can read the internal table of type EDIDS with index,
which will give u the status of the iDoc.
Now u implement if else according whether it is 51 or 63.
Thanx,
Navin
2008 Apr 01 8:11 AM
Hi sorry am new to ABAP so can u explain me better way.
I should give as read table itab(internal table name) with index r8.what does the index specifies.
2008 Apr 01 8:17 AM
HI Hema,
This should help...
Consider
Idoc message type is :
constants:
l_c_msgtyp TYPE edimsg-mestyp VALUE '/GLB/RGTKNKK'.
TYPE:
l_wa_edidc TYPE edidc, " Idoc_Control
l_wa_edids type edids-status.
Check:
READ TABLE idoc_contrl INTO l_wa_edidc INDEX 1.
IF idoc_contrl-mestyp = l_c_msgtyp.
Now since IDoc_status is a internal table with header line.
Read table idoc_status[] index 1.
l_wa_edids = idoc_status-status.
l_wa_edids holds the value i.e 51 or 63.
Here u will get the latest status of idoc which u see in T-Code WE05.
Here u can find the status whether it is 51 or 63 and code accordingly.
2008 Apr 01 8:23 AM
I have already got the status of the idocs using FM idoc_Read_completely now have to only filter the idocs of status 51 0r 68
2008 Apr 01 8:25 AM
Hema,
In the case of outbound, when you call the function module 'MASTER_IDOC_DISTRIBUTE', there is a parameter 'COMMUNICATION_IDOC_CONTROL' which is of type EDIDC.
After calling the above function module, the generated IDoc details can be read from the Communication IDoc Control internal table.
Use the following code:
Read table index 1 gt_comm_idoc into gw_comm_idoc.
You can then check the status of the generated IDoc using the field gw_comm_idoc-status. Based on this you can include your logic.
Hope this helps.
Arun
2008 Apr 01 8:29 AM
Understood that your requirement is in inbound.
When you call the FM 'IDOC_READ_COMPLETELY', there is an Import parameter IDOC_CONTROL.
Use the case statement like this to achieve your functionality.
CASE IDOC_CONTROL-STATUS.
WHEN '51' OR '67'.
......add your logic here.
...... perform f_do_this.
WHEN OTHERS.
......
Hope this helps.
Regards,
Arun
2008 Apr 01 8:30 AM
i have to make use of idoc_read_completely in my requirement so have used it and got the status of the idocs within particular range of date.now i have to filter the idocs of status 51 0r 68 alone and have to link to the segment inorder to relate to the vendor and get the details of the vendor
2008 Apr 01 8:32 AM
For performance issue it would be better if i use read statement .how to use it?
2008 Apr 01 8:34 AM
Hi Hema,
Pls check this program . It is closely related to IDOC status checking , meanwhile I'l try to work on your requirement...
***********************************************
*Change IDoc status to error status and send to workflow
REPORT ZS7BM000007 MESSAGE-ID ZS7 .
*______________________________________________________________________
*/ Program Name: Process invoice IDocs with Goods Receipt
*/ Description : This program checks all INVOIC MM IDocs in status 64
* and 66 to determine if they have been received. Those
* IDocs older than 10 days that have still not been
* goods receipted are given error status 51.
*/ Transaction : N/A - run via scheduled job
*______________________________________________________________________
TABLES: EDIDC,
MKPF,
EKPO,
RBKP,
E1EDK01,
E1EDKA1,
E1EDK02,
E1EDP02.
DATA: IEDIDC LIKE EDIDC OCCURS 1 WITH HEADER LINE,
DATA_REC LIKE EDIDD OCCURS 1 WITH HEADER LINE.
DATA: C_DOCNUM(16) TYPE C,
C_MBLNR(10) TYPE C,
C_INVOIC(10) TYPE C,
RC(1) TYPE C,
LEAD_TIME LIKE LFM1-PLIFZ,
GR_QTY LIKE MSEG-ERFMG,
TEST_DATE LIKE SY-DATUM,
GR_REQUIRED LIKE EKPO-WEBRE,
PO_NUMBER(10) TYPE N,
PO_LINENO LIKE EKPO-EBELP,
N_VEND(10) TYPE N,
VENDOR_ID LIKE LFA1-LIFNR.
DATA: BEGIN OF ITAB_GR OCCURS 0,
MBLNR LIKE MKPF-MBLNR,
BWART LIKE MSEG-BWART,
ERFMG LIKE MSEG-ERFMG,
END OF ITAB_GR.
CONSTANTS:
* name of container element (workitem object id)
C_ELEMENT_WI_OBJ_ID LIKE SWCONT-ELEMENT VALUE '_WI_OBJECT_ID',
* name of container element (NumberPlusEventcode)
C_ELEMENT_NO_PLUS_INFO LIKE SWCONT-ELEMENT
VALUE 'NumberPlusEventcode'.
RANGES: R_STATUS FOR EDIDC-STATUS.
TYPE-POOLS:
* general idoc type pool
TIDOC.
************************************************************************
* INCLUDES *
************************************************************************
* include for workflow programming
INCLUDE <CNTN01>.
************************************************************************
* INNITIALIZATION *
************************************************************************
INITIALIZATION.
* create IDoc status selection table.
CLEAR R_STATUS. REFRESH R_STATUS.
MOVE: 'EQ' TO R_STATUS-OPTION, "equals
'I' TO R_STATUS-SIGN, "include
'64' TO R_STATUS-LOW.
APPEND R_STATUS.
MOVE: '66' TO R_STATUS-LOW.
APPEND R_STATUS.
************************************************************************
* START-OF-SELECTION
************************************************************************
START-OF-SELECTION.
SELECT * FROM EDIDC INTO TABLE IEDIDC
WHERE STATUS IN R_STATUS AND
DIRECT = '2' AND "inbound
MESTYP = 'INVOIC' AND
MESCOD = 'MM'.
LOOP AT IEDIDC.
CLEAR RC.
CALL FUNCTION 'EDI_DOCUMENT_OPEN_FOR_READ'
EXPORTING
DOCUMENT_NUMBER = IEDIDC-DOCNUM
IMPORTING
IDOC_CONTROL = IEDIDC
EXCEPTIONS
DOCUMENT_FOREIGN_LOCK = 01
DOCUMENT_NOT_EXIST = 02
DOCUMENT_NUMBER_INVALID = 03
ERROR_MESSAGE = 04
OTHERS = 05.
IF NOT SY-SUBRC IS INITIAL.
C_DOCNUM = IEDIDC-DOCNUM.
SHIFT C_DOCNUM LEFT DELETING LEADING '0'.
* 'Cannot open INVOIC IDoc & for Goods Receipt processing'
MESSAGE W025 WITH C_DOCNUM.
CONTINUE.
ENDIF.
CALL FUNCTION 'EDI_SEGMENTS_GET_ALL'
EXPORTING
DOCUMENT_NUMBER = IEDIDC-DOCNUM
TABLES
IDOC_CONTAINERS = DATA_REC
EXCEPTIONS
DOCUMENT_NUMBER_INVALID = 1
END_OF_DOCUMENT = 2
OTHERS = 3.
IF NOT SY-SUBRC IS INITIAL.
CALL FUNCTION 'EDI_DOCUMENT_CLOSE_READ'
EXPORTING
DOCUMENT_NUMBER = IEDIDC-DOCNUM
IMPORTING
IDOC_CONTROL = IEDIDC
C_DOCNUM = IEDIDC-DOCNUM.
SHIFT C_DOCNUM LEFT DELETING LEADING '0'.
* 'Cannot retrieve data for INVOIC IDoc & (Goods Receipt processing)'
MESSAGE W030 WITH C_DOCNUM.
CONTINUE.
ELSE.
CALL FUNCTION 'EDI_DOCUMENT_CLOSE_READ'
EXPORTING
DOCUMENT_NUMBER = IEDIDC-DOCNUM
IMPORTING
IDOC_CONTROL = IEDIDC.
* If this is a change or modify IDoc, change status to 51 (error).
* One & only one K01 segment should exist -
READ TABLE DATA_REC WITH KEY SEGNAM = 'E1EDK01'.
IF SY-SUBRC IS INITIAL.
MOVE DATA_REC-SDATA TO E1EDK01.
CASE E1EDK01-ACTION.
WHEN '000'. "original data
* OK - do nothing
WHEN '002'. "modified data
* 'Invoice & - IDoc for Review Only'
PERFORM IDOC_STATUS_UPDATE USING '51' '028'
'Modification' ' '.
WHEN '002'. "modified data
* 'Invoice & - IDoc for Review Only'
PERFORM IDOC_STATUS_UPDATE USING '51' '028'
'Cancellation' ' '.
ENDCASE.
ENDIF.
CHECK RC IS INITIAL.
* get the vendor no.
CLEAR VENDOR_ID.
LOOP AT DATA_REC WHERE SEGNAM = 'E1EDKA1'.
MOVE DATA_REC-SDATA TO E1EDKA1.
CHECK: E1EDKA1-PARVW = 'LF',
E1EDKA1-PARTN CO ' 0123456789',
E1EDKA1-PARTN <> ' '.
N_VEND = E1EDKA1-PARTN.
VENDOR_ID = N_VEND.
ENDLOOP.
* if this is a new IDoc, check to make sure it even needs the GR test
CLEAR GR_REQUIRED.
LOOP AT DATA_REC WHERE SEGNAM = 'E1EDP02'.
MOVE DATA_REC-SDATA TO E1EDP02.
CHECK: E1EDP02-QUALF = '001',
E1EDP02-BELNR <> ' ',
E1EDP02-ZEILE <> ' '.
* Note that a missing PO number / line number is NOT an error here -
* the IDoc will error in the standard SAP processing in RBDAPP01
SHIFT E1EDP02-BELNR LEFT DELETING LEADING '0'.
CLEAR: PO_NUMBER, PO_LINENO.
IF E1EDP02-BELNR CO ' 0123456789'.
PO_NUMBER = E1EDP02-BELNR.
ENDIF.
IF E1EDP02-ZEILE CO ' 0123456789'.
PO_LINENO = E1EDP02-ZEILE.
ENDIF.
SELECT SINGLE WEBRE FROM EKPO INTO GR_REQUIRED
WHERE EBELN = PO_NUMBER
AND EBELP = PO_LINENO.
IF ( SY-SUBRC IS INITIAL AND GR_REQUIRED = 'X' ).
EXIT.
ENDIF.
ENDLOOP. "E1EDP02 segments
* if any line item on this invoice requires a goods receipt, continue
* receipt evaluation. Otherwise, status the IDoc to go to standard SAP
* processing. (Assumption is made that if an IDoc has status 66, the GR
* flag was turned "on" at some point and has since been removed.)
IF GR_REQUIRED IS INITIAL. "no goods receipt required
IF IEDIDC-STATUS = '66'.
* 'Goods Receipt no longer required'
PERFORM IDOC_STATUS_UPDATE USING '64' '026' ' ' ' '.
ENDIF.
CONTINUE. "next IDoc
ENDIF.
* Should be only one K02, but loop just in case...
LOOP AT DATA_REC WHERE SEGNAM = 'E1EDK02'.
MOVE DATA_REC-SDATA TO E1EDK02.
IF E1EDK02-QUALF = '009'.
* if an invoice already exists for this ref. no., give the IDoc
* an error status
SELECT SINGLE BELNR FROM RBKP INTO RBKP-BELNR
WHERE XBLNR = E1EDK02-BELNR(16)
AND BLART = 'KR' "invoice
AND STBLG = ' '. "no reversal
IF SY-SUBRC IS INITIAL.
*'Invoice & already exists for ref.no. &'
C_INVOIC = RBKP-BELNR.
SHIFT C_INVOIC LEFT DELETING LEADING '0'.
PERFORM IDOC_STATUS_UPDATE USING '51' '027'
C_INVOIC E1EDK02-BELNR(16).
EXIT. "exit loop on data recs for this IDoc
ENDIF.
CLEAR: ITAB_GR, GR_QTY.
REFRESH: ITAB_GR.
SELECT A~MBLNR
B~BWART B~ERFMG
INTO CORRESPONDING FIELDS OF TABLE ITAB_GR
FROM MKPF AS A
INNER JOIN MSEG AS B
ON A~MBLNR = B~MBLNR
WHERE A~VGART = 'WE' "goods receipt for PO
AND A~BLART = 'WE' "goods receipt
AND A~XBLNR = E1EDK02-BELNR(16).
LOOP AT ITAB_GR.
CASE ITAB_GR-BWART.
WHEN '101'. "receipt
GR_QTY = GR_QTY + ITAB_GR-ERFMG.
WHEN '102'. "reversal
GR_QTY = GR_QTY - ITAB_GR-ERFMG.
ENDCASE.
ENDLOOP.
* if no goods receipt
IF GR_QTY <= 0.
CASE IEDIDC-STATUS.
* if new IDoc, status to '66'
WHEN '64'.
* 'Waiting for Goods Receipt'
PERFORM IDOC_STATUS_UPDATE USING '66' '022' ' ' ' '.
* if reprocessed IDoc, check length of delay and status to 51
* (late receipt) if > 10 days.
WHEN '66'.
CLEAR LEAD_TIME.
SELECT SINGLE PLIFZ FROM LFM1 INTO LEAD_TIME
WHERE LIFNR = VENDOR_ID
AND EKORG = '7100'.
IF LEAD_TIME IS INITIAL.
LEAD_TIME = 10.
ENDIF.
TEST_DATE = IEDIDC-CREDAT + LEAD_TIME.
**TEST
** if test_date > sy-datum.
**TEST
IF TEST_DATE <= SY-DATUM.
* 'Goods Receipt Overdue'
PERFORM IDOC_STATUS_UPDATE USING '51' '024' ' ' ' '.
ELSE.
* do nothing - IDoc stays in status 66 and gets tested for GR in next
* job run
ENDIF.
ENDCASE.
ELSE. "goods receipt exists
* if this is a reprocess of an IDoc for which a goods receipt now
* exists, give the IDoc status 64, so it is processed by RBDAPP01
* in the next job step.
IF IEDIDC-STATUS = '66'.
C_MBLNR = MKPF-MBLNR.
SHIFT C_MBLNR LEFT DELETING LEADING '0'.
* 'Goods Receipt found for ref.no. &'
PERFORM IDOC_STATUS_UPDATE
USING '64' '023' E1EDK02-BELNR(16) ' '.
ENDIF.
ENDIF.
ELSE. "wrong K02 qualifier
* do nothing - IDoc will try to post and be handled manually
ENDIF. "QUALF='009'
ENDLOOP. "data_rec
ENDIF. "successful retrieval of IDoc data segments > data_rec
ENDLOOP. "iedidc
END-OF-SELECTION.
*-----------------------------------------------------------------------
* FORM IDOC_STATUS_UPDATE
* Creates status records for the selected IDocs.
*-----------------------------------------------------------------------
FORM IDOC_STATUS_UPDATE USING VALUE(I_STAT)
VALUE(I_MSGNO)
VALUE(I_MSGV1)
VALUE(I_MSGV2).
TABLES: EDI_DS, TEDE2.
DATA: MESS LIKE EDIMESSAGE.
DATA:
L_COMMIT_COUNTER LIKE EDIGLODATA-COMCOUNT VALUE '00000001',
INBSYNC LIKE EDIGLODATA-INBSYNC,
T_COUPLE_TO_PROCESS LIKE EDIINBOUND OCCURS 0 WITH HEADER LINE.
CALL FUNCTION 'EDI_DOCUMENT_OPEN_FOR_PROCESS'
EXPORTING
DOCUMENT_NUMBER = IEDIDC-DOCNUM
IMPORTING
IDOC_CONTROL = IEDIDC
EXCEPTIONS
DOCUMENT_FOREIGN_LOCK = 01
DOCUMENT_NOT_EXIST = 02
DOCUMENT_NUMBER_INVALID = 03
ERROR_MESSAGE = 04
OTHERS = 05.
IF NOT SY-SUBRC IS INITIAL.
C_DOCNUM = IEDIDC-DOCNUM.
SHIFT C_DOCNUM LEFT DELETING LEADING '0'.
* 'Cannot open INVOIC IDoc & for Goods Receipt processing'
MESSAGE W025 WITH C_DOCNUM.
RC = 'X'.
EXIT.
ENDIF.
CLEAR EDI_DS.
EDI_DS-DOCNUM = IEDIDC-DOCNUM.
EDI_DS-STATUS = I_STAT.
EDI_DS-REPID = 'ZS7BM000007'.
EDI_DS-TABNAM = 'EDI_DS'.
EDI_DS-MANDT = SY-MANDT.
EDI_DS-STAMQU = 'SAP'.
EDI_DS-STAMID = 'ZS7'.
EDI_DS-STAMNO = I_MSGNO.
EDI_DS-STAPA1 = I_MSGV1.
EDI_DS-STAPA2 = I_MSGV2.
GET TIME.
EDI_DS-LOGDAT = SY-DATUM.
EDI_DS-LOGTIM = SY-UZEIT.
CALL FUNCTION 'EDI_DOCUMENT_STATUS_SET'
EXPORTING
DOCUMENT_NUMBER = IEDIDC-DOCNUM
IDOC_STATUS = EDI_DS
IMPORTING
IDOC_CONTROL = IEDIDC
EXCEPTIONS
DOCUMENT_NUMBER_INVALID = 1
OTHER_FIELDS_INVALID = 2
STATUS_INVALID = 3
OTHERS = 4
.
IF NOT SY-SUBRC IS INITIAL.
C_DOCNUM = IEDIDC-DOCNUM.
SHIFT C_DOCNUM LEFT DELETING LEADING '0'.
* IDoc no. & failed status update to &
MESSAGE W021 WITH C_DOCNUM I_STAT.
ENDIF.
CALL FUNCTION 'EDI_DOCUMENT_CLOSE_PROCESS'
EXPORTING
DOCUMENT_NUMBER = IEDIDC-DOCNUM.
IF I_STAT = '51'.
CLEAR: T_COUPLE_TO_PROCESS.
REFRESH: T_COUPLE_TO_PROCESS.
SELECT SINGLE * FROM TEDE2 INTO TEDE2
WHERE EVCODE = 'INVL'.
IF SY-SUBRC IS INITIAL.
T_COUPLE_TO_PROCESS(16) = IEDIDC-DOCNUM.
T_COUPLE_TO_PROCESS+16(138) = TEDE2.
APPEND T_COUPLE_TO_PROCESS.
PERFORM ANALYZING_EVENT_CREATE
TABLES
T_COUPLE_TO_PROCESS
USING
L_COMMIT_COUNTER
INBSYNC.
IF SY-SUBRC IS INITIAL.
MESS-MSGID = 'ZS7'.
MESS-MSGTY = 'E'.
MESS-MSGNO = I_MSGNO.
MESS-MSGV1 = I_MSGV1.
MESS-MSGV2 = I_MSGV2.
CALL FUNCTION 'IDOC_ERROR_WORKFLOW_START'
EXPORTING
DOCNUM = 0
EVENTCODE = 'EDIM'
MESS = MESS
STATUSMESS = MESS
EXCEPTIONS
NO_ENTRY_IN_TEDE5 = 1
ERROR_IN_START_WORKFLOW = 2
OTHERS = 3.
COMMIT WORK.
ENDIF. "link created
ENDIF. "tede2 found
ENDIF.
* Set return code to stop further processing of this IDoc
RC = 'X'.
ENDFORM.
*-----------------------------------------------------------------------
* FORM ANALYZING_EVENT_CREATE
* Creates link between IDoc and workflow container.
* SAP code stolen from LEDINF01
*-----------------------------------------------------------------------
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.
* cast
L_START_RECFB_SYNCHRON = START_RECFB_SYNCHRON_IN.
* declaration of container
SWC_CONTAINER L_T_EV_CONTAINER.
* initialize container
SWC_CLEAR_CONTAINER L_T_EV_CONTAINER.
* 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.
* fire event that will trigger the idoc inbound processing
CALL FUNCTION 'SWE_EVENT_CREATE'
EXPORTING
OBJTYPE = C_OBJECT_TYPE
OBJKEY = L_OBJECT_KEY
EVENT = C_IDC_EVT
* CREATOR = ' '
* START_WITH_DELAY = ' '
START_RECFB_SYNCHRON = L_START_RECFB_SYNCHRON
IMPORTING
EVENT_ID = L_EVENT_ID
TABLES
EVENT_CONTAINER = L_T_EV_CONTAINER
EXCEPTIONS
OBJTYPE_NOT_FOUND = 1
OTHERS = 2.
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.
ENDFORM. " ANALYZING_EVENT_CREATEReward if useful
Lakshmiraj
2008 Apr 01 8:44 AM
Hi,Really your answer would be helpful.Think u can understand my requirement.In my report The output needs to show:
Vendor
Inbound iDoc Number
iDoc Date
iDoc Status: 51 or 68
PO Number
Invoice Number
Invoice date
Invoice Amount
Error Message: For multiple errors on a single iDoc, multiple records should be shown.
2008 Apr 01 9:18 AM
Hema,
Usage of CASE is preferred to READ, when considering performance issues.
Anyway, usage of the Read Statement is given below.
READ TABLE IDOC_CONTROL WITH KEY STATUS = 57 OR 68.
2008 Apr 01 10:25 AM
Hi if i give that syntax it is showing the syntax error as "= ..." expected after "OR".how to code using if.for both the status same action only should be performed
2008 Apr 02 8:08 AM
Hi for fetching the vendor details i used ur code.I get a error in line E1EDKA1-PARTN ' '. as Unable to interpret "' '". Possible causes of error: Incorrect spellingor comma error.whats the error?
2008 Apr 02 1:24 PM
| User | Count |
|---|---|
| 4 | |
| 2 | |
| 2 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 |