Posted: Tue Sep 11, 2007 6:40 pm Post subject: Sales Order Changed History Display
Code:
* You can execute the report by :
* 1. Change Date
* 2. User Name
* 3. Sales Order Number
*
REPORT ZSDCHANGE LINE-SIZE 132 NO STANDARD PAGE HEADING
LINE-COUNT 065(001)
MESSAGE-ID VR.
DATA: BEGIN OF ICDHDR OCCURS 50.
INCLUDE STRUCTURE CDHDR.
DATA: END OF ICDHDR.
SELECT-OPTIONS: XUDATE FOR ICDHDR-UDATE,
XNAME FOR ICDHDR-USERNAME,
XVBELN FOR VBUK-VBELN.
SELECTION-SCREEN SKIP.
SELECTION-SCREEN BEGIN OF BLOCK BLK1 WITH FRAME TITLE TEXT-001.
PARAMETERS: SUDATE RADIOBUTTON GROUP R1,
SNAME RADIOBUTTON GROUP R1,
SOBID RADIOBUTTON GROUP R1.
SELECTION-SCREEN END OF BLOCK BLK1.
DATA: WFLAG,
WCHANGENR LIKE CDHDR-CHANGENR,
WUDATE LIKE CDHDR-UDATE,
WNAME LIKE CDHDR-USERNAME,
WVBELN LIKE VBUK-VBELN,
WDEC1 TYPE P DECIMALS 3,
WDEC2 TYPE P DECIMALS 3,
WDEC3 TYPE P DECIMALS 3,
WDEC4 TYPE P DECIMALS 3.
DATA: UTEXT(16) VALUE 'has been changed',
ITEXT(16) VALUE 'has been created',
DTEXT(16) VALUE 'has been deleted'.
DATA: BEGIN OF ICDSHW OCCURS 50.
INCLUDE STRUCTURE CDSHW.
DATA: END OF ICDSHW.
DATA: BEGIN OF ITAB OCCURS 10.
INCLUDE STRUCTURE CDSHW.
DATA: UDATE LIKE CDHDR-UDATE,
USERNAME LIKE CDHDR-USERNAME,
CHANGENR LIKE CDHDR-CHANGENR,
VBELN(10),
POSNR(6),
ETENR(4),
INDTEXT(200),
END OF ITAB.
SELECT * FROM VBUK WHERE VBELN IN XVBELN.
CLEAR CDHDR.
CLEAR CDPOS.
CDHDR-OBJECTCLAS = 'VERKBELEG'.
CDHDR-OBJECTID = VBUK-VBELN.
PERFORM READHEADER.
PERFORM READPOS.
LOOP AT ITAB.
CASE ITAB-TABNAME.
WHEN 'VBPA'.
IF ITAB-FNAME = 'KUNNR' OR
ITAB-FNAME = 'LIFNR' OR
ITAB-FNAME = 'PARNR' OR
ITAB-FNAME = 'PERNR' OR
ITAB-FNAME IS INITIAL.
MOVE ITAB-TABKEY TO VBPA.
SELECT SINGLE * FROM TPART WHERE SPRAS = SY-LANGU
AND PARVW = VBPA-PARVW.
IF SY-SUBRC = 0.
REPLACE '&' WITH TPART-VTEXT INTO ITAB-INDTEXT.
ENDIF.
ENDIF.
WHEN 'VBAP'.
IF ITAB-FNAME IS INITIAL.
REPLACE '&' WITH 'Item' INTO ITAB-INDTEXT.
ENDIF.
WHEN 'KONVC'.
MOVE ITAB-TABKEY TO KONVC.
SELECT SINGLE * FROM T685T WHERE SPRAS = SY-LANGU
AND KVEWE = 'A'
AND KAPPL = 'V'
AND KSCHL = KONVC-KSCHL.
IF SY-SUBRC = 0.
REPLACE '&' WITH T685T-VTEXT INTO ITAB-INDTEXT.
ENDIF.
ENDCASE.
IF ITAB-INDTEXT(1) EQ '&'.
REPLACE '&' WITH ITAB-FTEXT(40) INTO ITAB-INDTEXT.
ENDIF.
IF ITAB-CHNGIND = 'I'.
REPLACE '%' WITH ITEXT INTO ITAB-INDTEXT.
ELSEIF ITAB-CHNGIND = 'U'.
REPLACE '%' WITH UTEXT INTO ITAB-INDTEXT.
ELSE.
REPLACE '%' WITH DTEXT INTO ITAB-INDTEXT.
ENDIF.
CONDENSE ITAB-INDTEXT.
MODIFY ITAB.
ENDLOOP.
ENDSELECT.
IF SUDATE = 'X'.
SORT ITAB BY UDATE VBELN POSNR ETENR.
ELSEIF SOBID = 'X'.
SORT ITAB BY VBELN POSNR ETENR UDATE.
ELSE.
SORT ITAB BY USERNAME VBELN POSNR ETENR UDATE.
ENDIF.
LOOP AT ITAB.
CLEAR WFLAG.
IF SUDATE = 'X'.
IF WUDATE NE ITAB-UDATE.
SKIP.
WRITE:/001 ITAB-UDATE,
023 ITAB-USERNAME,
037(10) ITAB-VBELN.
WFLAG = 'X'.
WUDATE = ITAB-UDATE.
WCHANGENR = ITAB-CHANGENR.
ENDIF.
ELSEIF SOBID NE 'X'.
IF WVBELN NE ITAB-VBELN.
SKIP.
WRITE:/001 ITAB-VBELN.
WVBELN = ITAB-VBELN.
ENDIF.
ELSE.
IF WNAME NE ITAB-USERNAME.
SKIP.
WRITE:/001 ITAB-USERNAME.
WNAME = ITAB-USERNAME.
ENDIF.
ENDIF.
IF WCHANGENR NE ITAB-CHANGENR.
WRITE:/023 ITAB-USERNAME,
037(10) ITAB-VBELN.
WFLAG = 'X'.
WCHANGENR = ITAB-CHANGENR.
ENDIF.
IF WFLAG = 'X'.
WRITE: 013 ITAB-CHNGIND,
049 ITAB-POSNR,
057 ITAB-ETENR,
065 ITAB-INDTEXT(60).
ELSE.
WRITE: /013 ITAB-CHNGIND,
049 ITAB-POSNR,
057 ITAB-ETENR,
065 ITAB-INDTEXT(60).
ENDIF.
WRITE:/065 ITAB-F_OLD.
WRITE:/065 ITAB-F_NEW.
ENDLOOP.
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.