Posted: Tue Sep 04, 2007 4:59 pm Post subject: Report IDOCs in Error
Applies To:
SAP 4.6 C and SAP 4.7 Enterprise Edition
Summary
This report displays all the error IDOCs for both INBOUND and OUTBOUND based on message type, it also
having a provision to drill down the number of errorsand error type for each message type and also display
the current week as well as pervious 5 weeks of IDOCS. Provides a option to drill down for each message
type, error message to find the root cause of the error
By: Suresh S Revuru
Company: INTELLIGROUP INC.,
Date: 09 March 2006
Code Sample Description
Instead of using WE05 Transaction to list the IDOCS, we can use this report to display all the error records,
Error descriptions.
Normally we will goto WE05 and find the error record and double click the record to see the exact error
message. It is very difficult to see each and every error IDOC . Lets think how it difficult to do it for a week.
So this simple report extract all the error IDOCS for current week and also shows the past 5 weeks error
IDOCS.
***********************************************************************
*Declaration for Tables
***********************************************************************
TABLES:EDIDC, "Control record (IDoc)
EDIDS, "Status Record (IDOC)
TEDS1,
TEDS2,
STACUST,
STALIGHT,
ZIDOC,
FRUN. "To store the execution date .
***********************************************************************
*-Declaration of Internal Tables
DATA:BEGIN OF IT_STATUS OCCURS 0,
STATUS LIKE STACUST-STATUS,
COUNT TYPE I,
END OF IT_STATUS.
DATA: BEGIN OF IT_DOCNUM OCCURS 0,
STATUS LIKE EDIDC-STATUS,
MESTYP LIKE EDIDC-MESTYP,
DOCNUM LIKE EDIDC-DOCNUM,
END OF IT_DOCNUM.
DATA:BEGIN OF IT_COUNT OCCURS 0,
STATUS LIKE STACUST-STATUS,
COUNT LIKE SY-TABIX,
END OF IT_COUNT.
* Internal table for displaying the output.
DATA:BEGIN OF IT_OUTPUT OCCURS 0,
CHK, " Field for checkbox
BASEWEEK LIKE SY-DATUM,
ERROR LIKE EDIDC-STATUS,
IDOC LIKE EDIDC-DOCNUM,
MESSAGE LIKE EDIDC-MESTYP,
WK1 LIKE EDIDC-MAXSEGNUM,
WK2 LIKE EDIDC-MAXSEGNUM,
WK3 LIKE EDIDC-MAXSEGNUM,
WK4 LIKE EDIDC-MAXSEGNUM,
WK5 LIKE EDIDC-MAXSEGNUM,
END OF IT_OUTPUT.
DATA: BEGIN OF IT_IDOCMESS OCCURS 0,
SNO TYPE I,
BASEWEEK LIKE SY-DATUM,
MESSAGE LIKE EDIDC-MESTYP,
ERROR LIKE EDIDC-STATUS,
TEXT LIKE BDIDOCATTR-MESSAGE,
NO_OF_ERR LIKE ZIPOPUP-NO_OF_ERR,
WEEK LIKE ZIPOPUP-WEEK,
WK1 LIKE EDIDC-MAXSEGNUM,
WK2 LIKE EDIDC-MAXSEGNUM,
WK3 LIKE EDIDC-MAXSEGNUM,
WK4 LIKE EDIDC-MAXSEGNUM,
WK5 LIKE EDIDC-MAXSEGNUM,
END OF IT_IDOCMESS.
* Internal tables to store detailed errors of the idocs
DATA: IT_IDOCMESS1 LIKE ZIPOPUP OCCURS 0 WITH HEADER LINE.
DATA: IT_IDOCMESS2 LIKE IT_IDOCMESS OCCURS 0 WITH HEADER LINE,
IT_IDOCMESS2_TEMP LIKE IT_IDOCMESS OCCURS 0 WITH HEADER LINE.
* Internal table to hold all the baseweeks
DATA:BEGIN OF IT_DATE OCCURS 0,
LOW LIKE SY-DATUM,
HIGH LIKE SY-DATUM,
END OF IT_DATE.
* Declaration of Variables
DATA: NO_OF_ERR LIKE SY-TABIX.
DATA: V_FLAG LIKE SY-TABIX,
F_FLAG TYPE I.
* Fieldcatalog for IT_OUTPUT
DATA: IT_FIELDCAT_DATA TYPE SLIS_T_FIELDCAT_ALV WITH HEADER LINE,
* Events in ALV
IT_EVENTS_DATA TYPE SLIS_T_EVENT WITH HEADER LINE,
* Sorting
IT_SORT_DATA TYPE SLIS_T_SORTINFO_ALV WITH HEADER LINE,
IT_ZIDOC LIKE ZIDOC OCCURS 0 WITH HEADER LINE,
* Storing properties for fields displayed in Popup.
IT_FIELDCAT_POPUP TYPE SLIS_T_FIELDCAT_ALV,
X_FIEDLCAT TYPE SLIS_FIELDCAT_ALV.
*- Declaration for Variables
*******************************************************************
DATA: V_TABIX LIKE SY-TABIX, " For internal table index
V_REPID LIKE SY-REPID ,
V_COUNT TYPE I,
V_FLAG1 TYPE I,
V_SNO TYPE I,
V_MESSAGE TYPE BDIDOCATTR-MESSAGE,"EDIDC-MESTYP,
V_ERROR TYPE EDIDC-STATUS,
V_DOCNUM LIKE EDIDC-DOCNUM,
X_LAYOUT_DATA TYPE SLIS_LAYOUT_ALV, " Layout for data
X_EVENTS_DATA TYPE SLIS_ALV_EVENT. " " For events.
*******************************************************************
*- Declaration for Constants
*******************************************************************
************************************************************************
* SELECTION-SCREEN
************************************************************************
*Selection Screen for data extraction using order create date and
*order change date.
SELECTION-SCREEN BEGIN OF BLOCK B1 WITH FRAME TITLE TEXT-001.
PARAMETERS: P_DATE LIKE EDIDC-CREDAT OBLIGATORY.
*SELECT-OPTIONS: P_DATE FOR EDIDC-CREDAT OBLIGATORY NO-EXTENSION.
****************************************************************
* Start of Selection
****************************************************************
START-OF-SELECTION.
**Logic to avoid the users action.
*CLEAR V_SNO.
* SELECT COUNT(*) FROM ZIDOC
* INTO V_SNO
* WHERE BASEWEEK = S_DATE-LOW OR BASEWEEK = S_DATE-HIGH
.
* IF SY-SUBRC = 0.
* MESSAGE E001.
* ENDIF.
*frun table this will be usefull in selection variant for scheduling the
* batch jobs for delta runs.
PERFORM UPDATE_LAST_RUN_TIME.
*This subroutine extracts the date from the given dates and stores in
* internal table it_date.
* PERFORM DATE_EXTRACTION.
*This subroutine extracts the data from EDIDIC table.
PERFORM GET_DATA_BASIC_LIST.
* This subroutine extracts the detail data from EDIDS table.
PERFORM GET_DATA_DETAIL_LIST.
* This subroutines gets the previous 4 weeks of data for comparison.
PERFORM PREVIOUS_WEEK.
SORT IT_OUTPUT BY BASEWEEK.
DELETE ADJACENT DUPLICATES FROM IT_OUTPUT COMPARING BASEWEEK
MESSAGE
ERROR.
*This subroutine displays the it_output internal table in screen
PERFORM DISPLAY_DATA.
****************************************************************
* End of Selection
****************************************************************
END-OF-SELECTION.
* Top of list
FORM TOP-OF-LIST.
FORMAT COLOR COL_HEADING INTENSIFIED ON.
* Display Steelcase header
CALL FUNCTION 'Z_STEELCASE_HEADER'.
FORMAT COLOR OFF.
ENDFORM.
*&---------------------------------------------------------------------*
*& Form PF_STATUS_SET
*&---------------------------------------------------------------------*
* text: This subroutine sets the pf-status
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM PF_STATUS_SET USING P_EXTAB TYPE SLIS_T_EXTAB.
SET PF-STATUS 'STANDARD'.
ENDFORM. " PF_STATUS_SET
*&---------------------------------------------------------------------*
*& Form DATE_EXTRACTION
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM DATE_EXTRACTION.
DATA: IT_DATES LIKE ZWKDATES OCCURS 0 WITH HEADER LINE.
DATA: V_DATESTART LIKE SY-DATUM.
DATA: CURRBASEWEEK LIKE SY-DATUM.
DATA: NEXBASEWEEK LIKE SY-DATUM.
*DATA: V_DATE LIKE SY-DATUM.
*CLEAR V_DATE.
*V_DATE = P_DATE.
CALL FUNCTION 'Z_GET_WEEK_DATES'
EXPORTING
DATE = P_DATE
NUMWEEKS = '000'
DIRECT = '-'
TABLES
DATES = IT_DATES
* EXCEPTIONS
* CALC_ERROR = 1
* INC_DIRECT = 2
* OTHERS = 3
.
IF SY-SUBRC <> 0.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
* WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
CLEAR V_DATESTART.
LOOP AT IT_DATES.
*& Form GET_DATA_BASIC_LIST
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM GET_DATA_BASIC_LIST.
DATA: IT_ZIDOC LIKE ZIDOC OCCURS 0 WITHHEADER LINE.
REFRESH IT_ZIDOC.
SELECT STACUST~STATUS
INTO TABLE IT_STATUS
FROM STACUST
JOIN STALIGHT
ON STACUST~STATVA = STALIGHT~STATVA
WHERE STALIGHT~STALIGHT = '03'.
IF SY-SUBRC = 0.
* To extract idocs for all the 5 weeks
LOOP AT IT_DATE.
SELECT STATUS COUNT(*)
FROM EDIDC
INTO TABLE IT_COUNT
WHERE CREDAT BETWEEN IT_DATE-LOW AND IT_DATE-HIGH
GROUP BY STATUS.
ENDLOOP.
IF SY-SUBRC EQ 0.
SORT IT_STATUS.
SORT IT_COUNT.
LOOP AT IT_COUNT.
V_TABIX = SY-TABIX.
READ TABLE IT_STATUS WITH KEY STATUS = IT_COUNT-STATUS.
IF SY-SUBRC <> 0.
DELETE IT_COUNT INDEX V_TABIX.
******************FILLING THE IT_OUTPUT TABLE WITH THE REQUIRED DATA
REFRESH IT_OUTPUT.
SELECT COUNT(*) INTO V_SNO FROM ZIDOC WHERE SNO > 0.
LOOP AT IT_COUNT.
IF IT_COUNT-COUNT > 20.
CLEAR V_FLAG1.
LOOP AT IT_DATE.
V_FLAG1 = V_FLAG1 + 1.
SELECT MESTYP COUNT( * )
FROM EDIDC
INTO (IT_OUTPUT-MESSAGE, NO_OF_ERR)
WHERE STATUS = IT_COUNT-STATUS
AND CREDAT BETWEEN IT_DATE-LOW AND IT_DATE-HIGH
GROUP BY MESTYP.
IT_OUTPUT-BASEWEEK = IT_DATE-HIGH + 1.
IT_OUTPUT-ERROR = IT_COUNT-STATUS.
*This subroutine find out the previous erros for the perticular week
* PERFORM PREVIOUS_WEEK USING IT_OUTPUT-BASEWEEK IT_OUTPUT-MESSAGE
* IT_OUTPUT-ERROR.
*
CASE V_FLAG1.
WHEN 1.
IT_OUTPUT-WK1 = NO_OF_ERR.
MOVE IT_OUTPUT-WK1 TO ZIDOC-NO_OF_ERR.
MOVE 'WK1' TO ZIDOC-WEEK.
IT_OUTPUT-WK2 = ''.
IT_OUTPUT-WK3 = ''.
IT_OUTPUT-WK4 = ''.
IT_OUTPUT-WK5 = ''.
WHEN 2.
IT_OUTPUT-WK2 = NO_OF_ERR.
MOVE IT_OUTPUT-WK2 TO ZIDOC-NO_OF_ERR.
MOVE 'WK2' TO ZIDOC-WEEK.
*& Form DISPLAY_DATA
*&---------------------------------------------------------------------*
* text: This subroutine displays the data in screen
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM DISPLAY_DATA.
*&---------------------------------------------------------------------*
*& Form BUILD_DATA_TABLE_CATALOG
*&---------------------------------------------------------------------*
* text: This forms builds the fieldcatalog
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM BUILD_DATA_TABLE_CATALOG.
DATA: L_POS(2) TYPE N VALUE 1.
REFRESH IT_FIELDCAT_DATA.
CLEAR IT_FIELDCAT_DATA.
*&---------------------------------------------------------------------*
*& Form DISPLAY_ALV_OUTPUT
*&---------------------------------------------------------------------*
* text This form displays the ALV grid
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM DISPLAY_ALV_OUTPUT.
DATA: L_USER_FORMNAME TYPE SLIS_FORMNAME VALUE 'USER_COMMAND',
L_PF_STAT_FORNAME TYPE SLIS_FORMNAME VALUE 'PF_STATUS_SET'.
* SET LAYOUT VARIABLE, EVENTS AND SORT FIELDS
X_LAYOUT_DATA-ZEBRA = 'X'. " Zebra Layout
X_LAYOUT_DATA-GET_SELINFOS = 'X'.
PROGRAM_ERROR = 1
OTHERS = 2
.
IF SY-SUBRC <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
ENDFORM. " DISPLAY_ALV_OUTPUT
*&---------------------------------------------------------------------*
*& Form IT_POPUP_DISPLAY
*&---------------------------------------------------------------------*
* text: Displays popup screen
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM POPUP_DISPLAY.
*variables
DATA : L_POS(1) TYPE N VALUE 1. " Field pos
* Fieldcatalog for popup
DATA : IT_FIELDCAT_POP TYPE SLIS_T_FIELDCAT_ALV WITH HEADER LINE.
CLEAR IT_FIELDCAT_POP.
REFRESH IT_FIELDCAT_POP.
SORT IT_IDOCMESS2.
* Base Week #
IT_FIELDCAT_POP-FIELDNAME = 'BASEWEEK'.
IF SY-SUBRC <> 0.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
* WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
REFRESH IT_FIELDCAT_POP.
CLEAR IT_FIELDCAT_POP.
IF SY-SUBRC <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
ENDFORM. " IT_POPUP_DISPLAY
*&---------------------------------------------------------------------*
*& Form USER_COMMAND
*&---------------------------------------------------------------------*
* Processing User command
*----------------------------------------------------------------------*
* -->P_UCOMM Screens, function code triggered by PAI
* -->P_SELFIELD information cursor position ALV
*----------------------------------------------------------------------*
FORM USER_COMMAND USING P_UCOMM LIKE SY-UCOMM
P_SELFIELD TYPE SLIS_SELFIELD.
CASE P_UCOMM.
WHEN 'DISPLAY'.
* P_SELFIELD-REFRESH = 'X'.
PERFORM ERROR_LIST1.
*& Form ERROR_LIST
*&---------------------------------------------------------------------*
* text: This subroutine displayes the errors of baseweek
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM ERROR_LIST.
DATA: BEGIN OF IT_IDOC_STATUS OCCURS 0.
INCLUDE STRUCTURE EDIDS.
DATA: END OF IT_IDOC_STATUS.
DATA: IT_IDOCMESS_TEMP LIKE IT_IDOCMESS OCCURS 0 WITH HEADER LINE,
V_DATE LIKE SY-DATUM.
DATA: ERROR_COUNT TYPE I.
CLEAR: V_MESSAGE, V_ERROR.
INTO TABLE IT_DOCNUM
WHERE MESTYP = IT_OUTPUT-MESSAGE AND
STATUS = IT_OUTPUT-ERROR AND
CREDAT BETWEEN IT_DATE-LOW AND IT_DATE-HIGH.
ERROR_COUNT = 1.
LOOP AT IT_DOCNUM.
*REFRESH IT_IDOC_STATUS.
CLEAR IT_IDOC_STATUS.
SELECT * FROM EDIDS INTO TABLE IT_IDOC_STATUS
WHERE DOCNUM = IT_DOCNUM-DOCNUM AND
STATUS = IT_DOCNUM-STATUS.
* Get most recent status record
SORT IT_IDOC_STATUS DESCENDING BY LOGDAT LOGTIM COUNTR.
READ TABLE IT_IDOC_STATUS INDEX 2.
IF SY-SUBRC <> 0 OR IT_IDOC_STATUS-STATXT = ''.
READ TABLE IT_IDOC_STATUS INDEX 1.
ENDIF.
READ TABLE IT_IDOCMESS WITH KEY TEXT =IT_IDOC_STATUS-STATXT.
IF SY-SUBRC EQ 0.
IT_IDOCMESS1-ERROR = IT_IDOCMESS-ERROR + 1.
MODIFY IT_IDOCMESS1 TRANSPORTING ERROR
WHERE TEXT = IT_IDOC_STATUS-STATXT.
CONTINUE.
LOOP AT IT_IDOCMESS1 WHERE TEXT EQ SPACE.
SELECT SINGLE DESCRP FROM TEDS2 INTO TEDS2-DESCRP
WHERE STATUS = V_ERROR AND
LANGUA = 'EN'.
IT_IDOCMESS1-TEXT = TEDS2-DESCRP.
MODIFY IT_IDOCMESS1 INDEX SY-TABIX.
ENDLOOP.
LOOP AT IT_IDOCMESS1.
WRITE:/5 IT_IDOCMESS1-TEXT, 80 IT_IDOCMESS1-ERROR.
ENDLOOP.
*
ENDLOOP.
ENDFORM. " ERROR_LIST
*&---------------------------------------------------------------------*
*& Form UPDATE_DATABASE_TABLES
*&---------------------------------------------------------------------*
* text : This perform commits the database inserts
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM UPDATE_DATABASE_TABLES.
***********************************************************************
* Declaration of LOCAL Variables
***********************************************************************
DATA: L_REPID LIKE SY-REPID, " Program Name.
L_TIME LIKE SY-UZEIT, " Program Execution Time
L_DATE LIKE SY-DATUM, " Program Execution Date.
L_PRGID LIKE FRUN-PRGID."ABAP program name
*_ assigning the report name, executed date and executed time to local
*variables, which are used to insert in frun table
L_REPID =SY-REPID.
L_DATE =SY-DATUM.
L_TIME = SY-UZEIT.
* Insert or Update FRUN record that was populated earlier
MODIFY FRUN.
* The insertion takes place only once for a day.
* SELECT PRGID
* INTO L_PRGID
* FROM FRUN
* WHERE PRGID = L_REPID AND LDATU = L_DATE.
*
* IF SY-SUBRC <> 0.
* DELETE FROM ZIDOC WHERE SNO > 0.
CLEAR V_SNO.
SELECT COUNT( * ) FROM ZIDOC INTO V_SNO.
LOOP AT IT_OUTPUT.
IF IT_OUTPUT-WK1 <> 0.
V_SNO = V_SNO + 1.
MOVE IT_OUTPUT-BASEWEEK TO ZIDOC-BASEWEEK.
MOVE IT_OUTPUT-ERROR TO ZIDOC-ERROR.
MOVE IT_OUTPUT-MESSAGE TO ZIDOC-MESSAGE.
MOVE V_SNO TO ZIDOC-SNO.
MOVE IT_OUTPUT-WK1 TO ZIDOC-NO_OF_ERR.
MOVE 'WK1' TO ZIDOC-WEEK.
INSERT INTO ZIDOC VALUES ZIDOC.
CLEAR ZIDOC.
ENDIF.
IF IT_OUTPUT-WK2 <> 0.
MOVE IT_OUTPUT-BASEWEEK TO ZIDOC-BASEWEEK.
MOVE IT_OUTPUT-ERROR TO ZIDOC-ERROR.
MOVE IT_OUTPUT-MESSAGE TO ZIDOC-MESSAGE.
V_SNO = V_SNO + 1.
MOVE V_SNO TO ZIDOC-SNO.
MOVE IT_OUTPUT-WK2 TO ZIDOC-NO_OF_ERR.
MOVE 'WK2' TO ZIDOC-WEEK.
INSERT INTO ZIDOC VALUES ZIDOC.
CLEAR ZIDOC.
ENDIF.
IF IT_OUTPUT-WK3 <> 0.
MOVE IT_OUTPUT-BASEWEEK TO ZIDOC-BASEWEEK.
MOVE IT_OUTPUT-ERROR TO ZIDOC-ERROR.
MOVE IT_OUTPUT-MESSAGE TO ZIDOC-MESSAGE.
V_SNO = V_SNO + 1.
MOVE V_SNO TO ZIDOC-SNO.
MOVE IT_OUTPUT-WK3 TO ZIDOC-NO_OF_ERR.
MOVE 'WK3' TO ZIDOC-WEEK.
INSERT INTO ZIDOC VALUES ZIDOC.
CLEAR ZIDOC.
ENDIF.
IF IT_OUTPUT-WK4 <> 0.
MOVE IT_OUTPUT-BASEWEEK TO ZIDOC-BASEWEEK.
MOVE IT_OUTPUT-ERROR TO ZIDOC-ERROR.
MOVE IT_OUTPUT-MESSAGE TO ZIDOC-MESSAGE.
V_SNO = V_SNO + 1.
MOVE V_SNO TO ZIDOC-SNO.
MOVE IT_OUTPUT-WK4 TO ZIDOC-NO_OF_ERR.
MOVE 'WK4' TO ZIDOC-WEEK.
INSERT INTO ZIDOC VALUES ZIDOC.
CLEAR ZIDOC.
ENDIF.
IF IT_OUTPUT-WK5 <> 0.
MOVE IT_OUTPUT-BASEWEEK TO ZIDOC-BASEWEEK.
MOVE IT_OUTPUT-ERROR TO ZIDOC-ERROR.
MOVE IT_OUTPUT-MESSAGE TO ZIDOC-MESSAGE.
V_SNO = V_SNO + 1.
MOVE V_SNO TO ZIDOC-SNO.
MOVE IT_OUTPUT-WK5 TO ZIDOC-NO_OF_ERR.
MOVE 'WK5' TO ZIDOC-WEEK.
INSERT INTO ZIDOC VALUES ZIDOC.
CLEAR ZIDOC.
ENDIF.
* INSERT INTO ZIDOC VALUES ZIDOC.
ENDLOOP.
* ELSE.
* MESSAGE S001 WITH 'Extraction Program is already excuted for this day'
* .
* ENDIF.
* ENDSELECT.
ENDFORM. " UPDATE_DATABASE_TABLES
*---------------------------------------------------------------------*
* FORM UPDATE_LAST_RUN_TIME *
*---------------------------------------------------------------------*
* Update last run date and time for the report *
*---------------------------------------------------------------------*
FORM UPDATE_LAST_RUN_TIME.
***********************************************************************
* Declaration of LOCAL Variables
***********************************************************************
DATA: L_REPID LIKE SY-REPID, " Program Name.
L_TIME LIKE SY-UZEIT, " Program Execution Time
L_DATE LIKE SY-DATUM, " Program Execution Date.
L_PRGID LIKE FRUN-PRGID."ABAP program name
*_ assigning the report name, executed date and executed time to local
*variables, which are used to insert in frun table
L_REPID =SY-REPID.
L_DATE =SY-DATUM.
L_TIME = SY-UZEIT.
SELECT SINGLE
PRGID
INTO L_PRGID
FROM FRUN
WHERE PRGID = L_REPID.
MOVE:L_REPID TO FRUN-PRGID,
L_DATE TO FRUN-LDATU,
L_TIME TO FRUN-LZEIT.
* FRUN is updated during commit work later in the program
ENDFORM.
*& Form PREVIOUS_WEEK
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* -->P_BASEWEEK text
*----------------------------------------------------------------------*
FORM PREVIOUS_WEEK.
* USING P_BASEWEEK P_MESSAGE P_ERROR.
DATA: V_LINES TYPE I.
CLEAR V_LINES.
SELECT * INTO TABLE IT_ZIDOC
FROM ZIDOC.
* WHERE
* BASEWEEK = P_BASEWEEK.
* AND
* MESSAGE = P_MESSAGE AND
* ERROR = P_ERROR.
IF SY-SUBRC = 0.
CLEAR V_TABIX.
LOOP AT IT_OUTPUT.
V_TABIX= SY-TABIX.
READ TABLE IT_ZIDOC WITH KEY BASEWEEK = IT_OUTPUT-BASEWEEK.
IF SY-SUBRC =0.
LOOP AT IT_ZIDOC WHERE BASEWEEK = IT_OUTPUT-BASEWEEK AND
MESSAGE = IT_OUTPUT-MESSAGE AND
ERROR = IT_OUTPUT-ERROR.
CASE IT_ZIDOC-WEEK.
WHEN 'WK1'.
IT_OUTPUT-WK1 = IT_ZIDOC-NO_OF_ERR.
MODIFY IT_OUTPUT INDEX V_TABIX TRANSPORTING WK1.
WHEN 'WK2'.
IT_OUTPUT-WK2 = IT_ZIDOC-NO_OF_ERR.
MODIFY IT_OUTPUT INDEX V_TABIX TRANSPORTING WK2.
WHEN 'WK3'.
IT_OUTPUT-WK3 = IT_ZIDOC-NO_OF_ERR.
MODIFY IT_OUTPUT INDEX V_TABIX TRANSPORTING WK3.
WHEN 'WK4'.
IT_OUTPUT-WK4 = IT_ZIDOC-NO_OF_ERR.
MODIFY IT_OUTPUT INDEX V_TABIX TRANSPORTING WK4.
WHEN 'WK5'.
IT_OUTPUT-WK5 = IT_ZIDOC-NO_OF_ERR.
MODIFY IT_OUTPUT INDEX V_TABIX TRANSPORTING WK5.
ENDCASE.
ENDLOOP.
ELSE.
IT_OUTPUT-MESSAGE = IT_ZIDOC-MESSAGE.
IT_OUTPUT-ERROR = IT_ZIDOC-ERROR.
IT_OUTPUT-BASEWEEK = IT_ZIDOC-BASEWEEK.
CASE IT_ZIDOC-WEEK.
WHEN 'WK1'.
IT_OUTPUT-WK1 = IT_ZIDOC-NO_OF_ERR.
*&---------------------------------------------------------------------*
*& Form GET_DATA_DETAIL_LIST
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM GET_DATA_DETAIL_LIST.
DATA: BEGIN OF IT_IDOC_STATUS OCCURS 0.
INCLUDE STRUCTURE EDIDS.
DATA: END OF IT_IDOC_STATUS.
DATA: IT_IDOCMESS_TEMP LIKE IT_IDOCMESS OCCURS 0 WITH HEADER LINE,
V_DATE LIKE SY-DATUM.
DATA: ERROR_COUNT TYPE I.
CLEAR: V_MESSAGE, V_ERROR.
DATA: V_SNO TYPE I, V_VAR1(3) TYPE C.
CLEAR V_SNO.
LOOP AT IT_OUTPUT.
FROM EDIDC
INTO TABLE IT_DOCNUM
WHERE MESTYP = IT_OUTPUT-MESSAGE AND
STATUS = IT_OUTPUT-ERROR AND
CREDAT BETWEEN IT_DATE-LOW AND IT_DATE-HIGH.
ERROR_COUNT = 1.
LOOP AT IT_DOCNUM.
*REFRESH IT_IDOC_STATUS.
CLEAR IT_IDOC_STATUS.
SELECT * FROM EDIDS INTO TABLE IT_IDOC_STATUS
WHERE DOCNUM = IT_DOCNUM-DOCNUM AND
STATUS = IT_DOCNUM-STATUS.
* Get most recent status record
SORT IT_IDOC_STATUS DESCENDING BY LOGDAT LOGTIM COUNTR.
READ TABLE IT_IDOC_STATUS INDEX 2.
IF SY-SUBRC <> 0 OR IT_IDOC_STATUS-STATXT = ''.
READ TABLE IT_IDOC_STATUS INDEX 1.
ENDIF.
IF IT_OUTPUT-WK5 <> 0.
V_VAR1 = 'WK5'.
ENDIF.
IF IT_OUTPUT-WK4 <> 0.
V_VAR1 = 'WK4'.
ENDIF.
IF IT_OUTPUT-WK3 <> 0.
V_VAR1 = 'WK3'.
ENDIF.
IF IT_OUTPUT-WK2 <> 0.
V_VAR1 = 'WK2'.
ENDIF.
IF IT_OUTPUT-WK1 <> 0.
V_VAR1 = 'WK1'.
ENDIF.
READ TABLE IT_IDOCMESS WITH KEY TEXT =IT_IDOC_STATUS-STATXT
BASEWEEK = IT_OUTPUT-BASEWEEK
MESSAGE = IT_OUTPUT-MESSAGE
ERROR = IT_OUTPUT-ERROR.
IF SY-SUBRC EQ 0.
IT_IDOCMESS-NO_OF_ERR = IT_IDOCMESS-NO_OF_ERR + 1.
MODIFY IT_IDOCMESS TRANSPORTING NO_OF_ERR
WHERE TEXT = IT_IDOC_STATUS-STATXT AND
BASEWEEK = IT_OUTPUT-BASEWEEK AND
MESSAGE = IT_OUTPUT-MESSAGE AND
LOOP AT IT_IDOCMESS WHERE TEXT EQ SPACE OR
TEXT EQ '&'.
SELECT SINGLE DESCRP FROM TEDS2 INTO TEDS2-DESCRP
WHERE STATUS = V_ERROR AND
LANGUA = 'EN'.
IT_IDOCMESS-TEXT = TEDS2-DESCRP.
MODIFY IT_IDOCMESS INDEX SY-TABIX.
ENDLOOP.
PERFORM UPDATE_ZIPOPUP.
ENDFORM. " GET_DATA_DETAIL_LIST
*&---------------------------------------------------------------------*
*& Form UPDATE_ZIPOPUP
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM UPDATE_ZIPOPUP.
DATA: IT_ZIPOPUP LIKE ZIPOPUP OCCURS 0 WITH HEADER LINE.
CLEAR V_SNO.
SORT IT_IDOCMESS BY BASEWEEK.
SELECT COUNT(*) FROM ZIPOPUP INTO V_SNO.
LOOP AT IT_IDOCMESS.
V_SNO = V_SNO + 1.
MOVE V_SNO TO IT_ZIPOPUP-SNO.
MOVE IT_IDOCMESS-BASEWEEK TO IT_ZIPOPUP-BASEWEEK.
MOVE IT_IDOCMESS-MESSAGE TO IT_ZIPOPUP-MESSAGE.
MOVE IT_IDOCMESS-ERROR TO IT_ZIPOPUP-ERROR.
MOVE IT_IDOCMESS-TEXT TO IT_ZIPOPUP-TEXT.
MOVE IT_IDOCMESS-NO_OF_ERR TO IT_ZIPOPUP-NO_OF_ERR.
MOVE IT_IDOCMESS-WEEK TO IT_ZIPOPUP-WEEK.
APPEND IT_ZIPOPUP.
CLEAR IT_ZIPOPUP.
ENDLOOP.
INSERT ZIPOPUP FROM TABLE IT_ZIPOPUP.
ENDFORM. " UPDATE_ZIPOPUP
*&---------------------------------------------------------------------*
*& Form ERROR_LIST
*&---------------------------------------------------------------------*
* text: This subroutine displayes the errors of baseweek
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM ERROR_LIST1.
DATA: BEGIN OF IT_IDOC_STATUS OCCURS 0.
INCLUDE STRUCTURE EDIDS.
DATA: END OF IT_IDOC_STATUS.
DATA: IT_IDOCMESS_TEMP LIKE IT_IDOCMESS OCCURS 0 WITH HEADER LINE,
V_DATE LIKE SY-DATUM.
DATA: ERROR_COUNT TYPE I.
CLEAR: V_MESSAGE, V_ERROR.
REFRESH IT_IDOCMESS1.
READ TABLE IT_OUTPUT WITH KEY CHK = 'X'.
IF SY-SUBRC <> 0.
MESSAGE W003.
ENDIF.
LOOP AT IT_OUTPUT WHERE CHK = 'X'.
SELECT SNO
BASEWEEK
MESSAGE
ERROR
TEXT
NO_OF_ERR
WEEK
APPENDING TABLE IT_IDOCMESS1
FROM ZIPOPUP
WHERE BASEWEEK = IT_OUTPUT-BASEWEEK AND
MESSAGE = IT_OUTPUT-MESSAGE AND
ERROR = IT_OUTPUT-ERROR.
SORT IT_IDOCMESS1 BY BASEWEEK MESSAGE ERROR.
LOOP AT IT_IDOCMESS1 WHERE TEXT EQ SPACE.
SELECT SINGLE DESCRP FROM TEDS2 INTO TEDS2-DESCRP
WHERE STATUS = V_ERROR AND
LANGUA = 'EN'.
IT_IDOCMESS1-TEXT = TEDS2-DESCRP.
MODIFY IT_IDOCMESS1 INDEX SY-TABIX.
ENDLOOP.
LOOP AT IT_IDOCMESS.
WRITE:/5 IT_IDOCMESS-TEXT, 80 IT_IDOCMESS-ERROR.
ENDLOOP.
ENDLOOP.
*// Here the code
CLEAR IT_IDOCMESS2.
REFRESH IT_IDOCMESS2.
LOOP AT IT_IDOCMESS1.
CLEAR V_TABIX.
V_TABIX =SY-TABIX.
MOVE: IT_IDOCMESS1-BASEWEEK TO IT_IDOCMESS2-BASEWEEK,
IT_IDOCMESS1-MESSAGE TO IT_IDOCMESS2-MESSAGE,
IT_IDOCMESS1-ERROR TO IT_IDOCMESS2-ERROR,
IT_IDOCMESS1-TEXT TO IT_IDOCMESS2-TEXT.
CASE IT_IDOCMESS1-WEEK.
WHEN 'WK1'.
IT_IDOCMESS2-WK1 = IT_IDOCMESS1-NO_OF_ERR.
MODIFY IT_IDOCMESS2 TRANSPORTING WK1
WHERE BASEWEEK= IT_IDOCMESS1-BASEWEEK AND
MESSAGE = IT_IDOCMESS1-MESSAGE AND
ERROR = IT_IDOCMESS1-ERROR AND
TEXT= IT_IDOCMESS1-TEXT.
WHEN 'WK2'.
IT_IDOCMESS2-WK2 = IT_IDOCMESS1-NO_OF_ERR.
MODIFY IT_IDOCMESS2 TRANSPORTING WK2
WHERE BASEWEEK= IT_IDOCMESS1-BASEWEEK AND
MESSAGE = IT_IDOCMESS1-MESSAGE AND
ERROR = IT_IDOCMESS1-ERROR AND
TEXT= IT_IDOCMESS1-TEXT.
WHEN 'WK3'.
IT_IDOCMESS2-WK3 = IT_IDOCMESS1-NO_OF_ERR.
MODIFY IT_IDOCMESS2 TRANSPORTING WK3
WHERE BASEWEEK= IT_IDOCMESS1-BASEWEEK AND
MESSAGE = IT_IDOCMESS1-MESSAGE AND
ERROR = IT_IDOCMESS1-ERROR AND
TEXT= IT_IDOCMESS1-TEXT.
WHEN 'WK4'.
IT_IDOCMESS2-WK4 = IT_IDOCMESS1-NO_OF_ERR.
MODIFY IT_IDOCMESS2 TRANSPORTING WK4
WHERE BASEWEEK = IT_IDOCMESS1-BASEWEEK AND
MESSAGE = IT_IDOCMESS1-MESSAGE AND
ERROR = IT_IDOCMESS1-ERROR AND
TEXT= IT_IDOCMESS1-TEXT.
WHEN 'WK5'.
IT_IDOCMESS2-WK5 = IT_IDOCMESS1-NO_OF_ERR.
MODIFY IT_IDOCMESS2 TRANSPORTING WK5
WHERE BASEWEEK = IT_IDOCMESS1-BASEWEEK AND
MESSAGE = IT_IDOCMESS1-MESSAGE AND
ERROR = IT_IDOCMESS1-ERROR AND
TEXT= IT_IDOCMESS1-TEXT.
ENDCASE.
ELSE.
CASE IT_IDOCMESS1-WEEK.
WHEN 'WK1'.
IT_IDOCMESS2-WK1 = IT_IDOCMESS1-NO_OF_ERR.
WHEN 'WK2'.
IT_IDOCMESS2-WK2 = IT_IDOCMESS1-NO_OF_ERR.
WHEN 'WK3'.
IT_IDOCMESS2-WK3 = IT_IDOCMESS1-NO_OF_ERR.
WHEN 'WK4'.
IT_IDOCMESS2-WK4 = IT_IDOCMESS1-NO_OF_ERR.
WHEN 'WK5'.
IT_IDOCMESS2-WK5 = IT_IDOCMESS1-NO_OF_ERR.
ENDCASE.
APPEND IT_IDOCMESS2.
CLEAR IT_IDOCMESS2.
ENDIF.
ENDLOOP.
CLEAR V_TABIX.
SORT IT_IDOCMESS2 BY BASEWEEK
MESSAGE
ERROR.
LOOP AT IT_IDOCMESS2.
V_TABIX = SY-TABIX.
V_TABIX = V_TABIX + 1.
READ TABLE IT_IDOCMESS2 INTO IT_IDOCMESS2_TEMP INDEX V_TABIX.
IF IT_IDOCMESS2-BASEWEEK =IT_IDOCMESS2_TEMP-BASEWEEK.
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.