Application Development and Automation Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

Idoc errors with status text.

Former Member
0 Likes
8,007

Hello, I'm new to SAP and forum searches have not revealed what I'm looking for.  What I need is a report of idoc errors that have occurred in the past two weeks with the Status Text.  I don't care what the idocs' current status is, I only want to know what the Status text was for the idoc when it was in 51 status.  I don't just need to know how many errors, but also exactly what the error was regardless of how it was processed afterward.  Any help would be greatly appreciated.

3 REPLIES 3
Read only

marvelmurugan
Explorer
0 Likes
3,716

Hi ,

EDI Idoc status will be stored in the Table EDIDS - Status Record (IDoc)

SELECT *

     from table

     INTO TABLE it_edids

     WHERE

     STACOD = '51' and

     CREDAT = sy-datum . "  give the required date

You can get the required fields from the table it_edids ,

you can design your report.

DOCNUM  IDoc number

STACOD  Status code

STATXT   Text for status code

Regards,

Vel


Read only

Former Member
0 Likes
3,716

Hi,

The requirement is seems to be simple; however it’s not straight forward to extract the error messages directly from EDIDS table.  IDOC error log will be stored in different ways in the table.

For example the message is storing with place holders, we can’t display directly to it so need to concatenate the relevant information in the place holders to display the meaning full message.

Another example, sometimes the error message will be stored with message ID and number only! You can’t have the STATXT field. It means you need fill the log with the message ID.

Developed the example report to show the error messages!  Just copy paste the code and try.

TABLES: t100,
edids.

TYPES: BEGIN OF status_log,
idocno
TYPE edids-docnum,
error_text
TYPE bdidocattr-message,
END OF status_log.

DATA: t_idoc_status TYPE STANDARD TABLE OF edids WITH HEADER LINE,
ev_idoc_message
TYPE bdidocattr-message.

DATA: t_status_log TYPE STANDARD TABLE OF status_log WITH HEADER LINE.


DATA: msgid LIKE sy-msgid,
msgno
LIKE sy-msgno,
back_date
LIKE sy-DATUM.

*GET THE DATE REAGES
data: l_date_range TYPE STANDARD TABLE OF DATE_RG WITH HEADER LINE.


* Date selection
PARAMETERS: P_DATE TYPE SY-DATUM.

* Entered date is caclualting backward date ( 2 weeks )
back_date
= p_date - 14.

*build the ranges table for dates

L_date_range
-sign = 'I'.
L_date_range
-option = 'BT'.
L_date_range
-low = P_DATE.
L_date_range
-high = back_date.
append l_date_range.


*Extract the IDOC status information with in the date range
SELECT * FROM edids INTO TABLE t_idoc_status
WHERE   CREDAT in l_date_range AND
status
= '51'.

*Build the error log
LOOP AT t_idoc_status.
* first try to get the message number ID. In other words Get msgid and
*  msgno from STAMID, STAMNO. If empty, use STACOD.

msgid
= t_idoc_status-stamid.
msgno
= t_idoc_status-stamno.

IF NOT    msgid IS INITIAL AND
NOT msgno IS INITIAL    AND
NOT t_idoc_status-stamqu IS INITIAL.


CLEAR t100.
SELECT SINGLE * FROM t100 WHERE sprsl = sy-langu
AND arbgb = msgid
AND msgnr = msgno.

ev_idoc_message
= t100-text.
*replacing the placeholders with the proper information
PERFORM replace_placeholders.
t_status_log
-idocno =   t_idoc_status-DOCNUM .
t_status_log
-error_text = ev_idoc_message.
APPEND t_status_log.
CLEAR t_status_log.

ELSE.
ev_idoc_message
= t_idoc_status-statxt.

*replacing the placeholders with the proper information
PERFORM replace_placeholders.
t_status_log
-idocno =   t_idoc_status-DOCNUM .
t_status_log
-error_text = ev_idoc_message.
APPEND t_status_log.
CLEAR t_status_log.
ENDIF.
ENDLOOP.


*test the output//
LOOP at t_status_log.

WRITE:/10 t_status_log-idocno,
40 t_status_log-error_text.
ENDLOOP.



*&---------------------------------------------------------------------*
*&      Form  REPLACE_PLACEHOLDERS
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
*  -->  p1        text
*  <--  p2        text
*----------------------------------------------------------------------*
FORM replace_placeholders .

SEARCH ev_idoc_message FOR '&1'.
IF sy-subrc = 0.
REPLACE '&1' WITH t_idoc_status-stapa1 INTO ev_idoc_message.
CONDENSE ev_idoc_message.
ELSE.
REPLACE '&' WITH t_idoc_status-stapa1 INTO ev_idoc_message.
CONDENSE ev_idoc_message.
ENDIF.

SEARCH ev_idoc_message FOR '&2'.
IF sy-subrc = 0.
REPLACE '&2' WITH t_idoc_status-stapa2 INTO ev_idoc_message.
CONDENSE ev_idoc_message.
ELSE.
REPLACE '&' WITH t_idoc_status-stapa2 INTO ev_idoc_message.
CONDENSE ev_idoc_message.
ENDIF.

SEARCH ev_idoc_message FOR '&3'.
IF sy-subrc = 0.
REPLACE '&3' WITH t_idoc_status-stapa3 INTO ev_idoc_message.
CONDENSE ev_idoc_message.
ELSE.
REPLACE '&' WITH t_idoc_status-stapa3 INTO ev_idoc_message.
CONDENSE ev_idoc_message.
ENDIF.

SEARCH ev_idoc_message FOR '&4'.
IF sy-subrc = 0.
REPLACE '&4' WITH t_idoc_status-stapa4 INTO ev_idoc_message.
CONDENSE ev_idoc_message.
ELSE.
REPLACE '&' WITH t_idoc_status-stapa4 INTO ev_idoc_message.
CONDENSE ev_idoc_message.
ENDIF.
ENDFORM.                    " REPLACE_PLACEHOLDERS

Read only

0 Likes
3,716

Thanks for the advice.