Posted: Sun Oct 14, 2007 9:20 pm Post subject: Inbound IDOC Status Report for Sales Orders
Requirement:
Sales Orders are being created through inbound IDocs using FM 'EDI_DATA_INCOMING'. Now a Report is required to check the status of these Inbound IDocs along with Sales Orders generated against customer Purchase Orders.
Processing:
The report selects, 'ORDERS' IDoc numbers & status, generated between given time range, from table EDIDC. Further, it calls Function Module 'IDOC_READ_COMPLETELY' to get the IDoc details. Then required information is extracted by reading relevant field data of IDoc segments.
Code:
REPORT Z_EDI_FILE_LOAD_STATUS_REPORT .
*-----------------------------------------------------------------------
* Staus Report for Inbound IDOCs ( Sales Orders )
*-----------------------------------------------------------------------
* Program : Z_EDI_FILE_LOAD_STATUS_REPORT
* Presented By : www.rmtiwari.com
*-----------------------------------------------------------------------
TABLES : EDIDC.
*-----------------------------------------------------------------------
* ALV stuff
TYPE-POOLS: SLIS.
DATA: GT_FIELDCAT TYPE SLIS_T_FIELDCAT_ALV,
GS_LAYOUT TYPE SLIS_LAYOUT_ALV,
GT_SORT TYPE SLIS_T_SORTINFO_ALV,
GT_LIST_TOP_OF_PAGE TYPE SLIS_T_LISTHEADER.
DATA : BEGIN OF T_REPORT OCCURS 0,
IDOC_NO TYPE EDI_DOCNUM,
IDOC_DATE TYPE SY-DATUM,
IDOC_TIME TYPE SY-UZEIT,
SORDER_NO TYPE VBELN,
STP_NO TYPE KNA1-KUNNR,
STP_NAME(35) TYPE C,
STP_PHONE(12) TYPE C,
PO_NO(15) TYPE C,
STATUS TYPE C,
S_TEXT(70) TYPE C,
ERROR(70) TYPE C,
END OF T_REPORT.
selection-screen begin of block date with frame title TEXT-S01.
select-options: UDATE for EDIDC-UPDDAT
default SY-datum obligatory, "Changed On
UTIME for EDIDC-UPDTIM . "Changed Time
*&---------------------------------------------------------------------*
*& Form alv_grid
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* < -- p2 text
*----------------------------------------------------------------------*
FORM ALV_GRID.
IF GT_FIELDCAT[] IS INITIAL.
PERFORM FIELDCAT_INIT.
PERFORM LAYOUT_INIT.
PERFORM SORT_INIT.
ENDIF.
PERFORM GRID_DISPLAY.
ENDFORM. "alv_grid
*&---------------------------------------------------------------------*
*& Form layout_init
*&---------------------------------------------------------------------*
ENDFORM. " layout_init
*&---------------------------------------------------------------------*
*& Form fieldcat_init
*&---------------------------------------------------------------------*
FORM FIELDCAT_INIT.
DATA: LS_FIELDCAT TYPE SLIS_FIELDCAT_ALV.
CLEAR LS_FIELDCAT.
LS_FIELDCAT-FIELDNAME = 'IDOC_NO'.
LS_FIELDCAT-KEY = 'X'.
LS_FIELDCAT-REPTEXT_DDIC = 'IDOC'.
LS_FIELDCAT-OUTPUTLEN = 10.
* Fix for ALV print bug, which puts 'N/A' over last digit
* Set inttype to 'N' to stop corruption of printed ALV cell.
LS_FIELDCAT-INTTYPE = 'N'.
APPEND LS_FIELDCAT TO GT_FIELDCAT.
*&---------------------------------------------------------------------*
*& Form sort_init
*&---------------------------------------------------------------------*
FORM SORT_INIT.
DATA: LS_SORT TYPE SLIS_SORTINFO_ALV.
*
CLEAR LS_SORT.
LS_SORT-FIELDNAME = 'IDOC_DATE'.
LS_SORT-SPOS = 1.
LS_SORT-UP = 'X'.
APPEND LS_SORT TO GT_SORT.
ENDFORM. "grid_display
*&---------------------------------------------------------------------*
*& Form COMMENT_BUILD
*&---------------------------------------------------------------------*
* Processing of listheader
*----------------------------------------------------------------------*
FORM COMMENT_BUILD USING P_FK_LIST_TOP_OF_PAGE TYPE SLIS_T_LISTHEADER.
DATA: LS_LINE TYPE SLIS_LISTHEADER.
REFRESH P_FK_LIST_TOP_OF_PAGE.
* List Heading : Typ H
CLEAR LS_LINE.
LS_LINE-TYP = 'H'.
LS_LINE-INFO = 'Sales Order Interface: Z_EDI_FILE_LOAD'.
APPEND LS_LINE TO P_FK_LIST_TOP_OF_PAGE.
* List : Typ S
clear LS_LINE.
LS_LINE-typ = 'S'.
LS_LINE-key = 'Date Range:'.
LS_LINE-info = UDATE-low.
if not UDATE-high is initial.
write ' To ' to LS_LINE-info+30.
LS_LINE-info+36 = UDATE-high.
endif.
APPEND LS_LINE TO P_FK_LIST_TOP_OF_PAGE.
ENDFORM. " COMMENT_BUILD
*---------------------------------------------------------------------*
* FORM TOP_OF_PAGE *
*---------------------------------------------------------------------*
* Ereigniss TOP_OF_PAGE *
* event TOP_OF_PAGE
*---------------------------------------------------------------------*
FORM TOP_OF_PAGE.
PERFORM COMMENT_BUILD USING gt_LIST_TOP_OF_PAGE[].
CALL FUNCTION 'REUSE_ALV_COMMENTARY_WRITE'
EXPORTING
IT_LIST_COMMENTARY = GT_LIST_TOP_OF_PAGE.
ENDFORM. "TOP_OF_PAGE
*&---------------------------------------------------------------------*
*& Form show_status_report
*&---------------------------------------------------------------------*
FORM SHOW_STATUS_REPORT .
* Report to show status.
DATA: BEGIN OF T_TEDS2 OCCURS 0.
INCLUDE STRUCTURE TEDS2.
DATA: END OF T_TEDS2.
DATA: BEGIN OF T_IDOC_CONTROL_TMP OCCURS 0.
INCLUDE STRUCTURE EDIDC.
DATA: END OF T_IDOC_CONTROL_TMP.
CONSTANTS: C_STATUS_IN_IDOC_POSTED LIKE EDIDC-STATUS VALUE '53'.
DATA : T_EDIDS TYPE STANDARD TABLE OF EDIDS WITH HEADER LINE.
DATA : T_EDIDD TYPE STANDARD TABLE OF EDIDD WITH HEADER LINE.
DATA : GV_PARTNER_SEG TYPE E1EDKA1,
GV_PO_REF_SEG TYPE E2EDK02.
* Get text for status values
SELECT * FROM TEDS2 INTO TABLE T_TEDS2 WHERE LANGUA = SY-LANGU.
* Read the IDoc's status after processing
SELECT * FROM EDIDC
INTO TABLE T_IDOC_CONTROL_TMP
WHERE UPDDAT IN UDATE
AND UPDTIM IN UTIME
AND MESTYP = 'ORDERS'.
LOOP AT T_IDOC_CONTROL_TMP.
* IDoc has been processed, since control record changed.
READ TABLE T_TEDS2 WITH KEY STATUS = T_IDOC_CONTROL_TMP-STATUS.
T_REPORT-IDOC_NO = T_IDOC_CONTROL_TMP-DOCNUM.
T_REPORT-IDOC_DATE = T_IDOC_CONTROL_TMP-CREDAT.
T_REPORT-IDOC_TIME = T_IDOC_CONTROL_TMP-CRETIM.
T_REPORT-S_TEXT = T_TEDS2-DESCRP.
IF T_IDOC_CONTROL_TMP-STATUS = C_STATUS_IN_IDOC_POSTED.
* ok status
T_REPORT-STATUS = 'S'.
ELSE.
* error status
T_REPORT-STATUS = 'E'.
ENDIF.
* Get Error status
READ TABLE T_EDIDS WITH KEY STATUS = T_IDOC_CONTROL_TMP-STATUS.
IF SY-SUBRC EQ 0.
REPLACE FIRST OCCURRENCE OF '&1' IN T_EDIDS-STATXT
WITH T_EDIDS-STAPA1.
REPLACE FIRST OCCURRENCE OF '&2' IN T_EDIDS-STATXT
WITH T_EDIDS-STAPA2.
REPLACE FIRST OCCURRENCE OF '&3' IN T_EDIDS-STATXT
WITH T_EDIDS-STAPA3.
REPLACE FIRST OCCURRENCE OF '&4' IN T_EDIDS-STATXT
WITH T_EDIDS-STAPA4.
REPLACE FIRST OCCURRENCE OF '&' IN T_EDIDS-STATXT
WITH T_EDIDS-STAPA1.
REPLACE FIRST OCCURRENCE OF '&' IN T_EDIDS-STATXT
WITH T_EDIDS-STAPA2.
REPLACE FIRST OCCURRENCE OF '&' IN T_EDIDS-STATXT
WITH T_EDIDS-STAPA3.
REPLACE FIRST OCCURRENCE OF '&' IN T_EDIDS-STATXT
WITH T_EDIDS-STAPA4.
T_REPORT-ERROR = T_EDIDS-STATXT.
ENDIF.
LOOP AT T_EDIDD.
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 cannot 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.