ABAP Source code to Mass Select
and Print Material Master Changed History
4.6x
REPORT ZMMCHGHISTORY NO STANDARD PAGE HEADING
LINE-SIZE 195 LINE-COUNT 60.
* Change doc listing
* Grouped into 3 chg types: 1. Part revision 2.
Price change 3. Others
TABLES:
CDHDR, CDPOS,
MARA, MAKT, MARD.
FIELD-GROUPS: HEADER.
DATA: BEGIN OF CHGDOC OCCURS 50.
INCLUDE STRUCTURE
CDRED.
DATA: END OF CHGDOC.
DATA:
CHGTYPE(1),
PLANT(4),
MATNR1 LIKE CHGDOC-OBJECTID.
SELECT-OPTIONS:
XMATNR FOR CDHDR-OBJECTID,
"Material
XUDATE FOR CDHDR-UDATE,
"Change Date
XUNAME FOR CDHDR-USERNAME,
"User Name
XTCODE FOR CDHDR-TCODE,
"Transaction Code
XWERKS FOR MARD-WERKS.
"Plants
SELECTION-SCREEN SKIP.
*Filter change type
SELECTION-SCREEN BEGIN OF BLOCK CHG0 WITH FRAME TITLE
TEXT-001.
PARAMETERS : XCHG1 AS CHECKBOX DEFAULT 'X',
XCHG2 AS CHECKBOX DEFAULT 'X',
XCHG3 AS CHECKBOX DEFAULT 'X'.
SELECTION-SCREEN END OF BLOCK CHG0.
START-OF-SELECTION.
INSERT:
CHGDOC-OBJECTID
"Material
CHGTYPE
"Change type
PLANT
CHGDOC-CHANGENR
CHGDOC-USERNAME
CHGDOC-UDATE
CHGDOC-TCODE
CHGDOC-TABNAME
CHGDOC-TABKEY
CHGDOC-CHNGIND
CHGDOC-FNAME
CHGDOC-FTEXT
CHGDOC-TEXTART
CHGDOC-OUTLEN
CHGDOC-F_OLD
CHGDOC-F_NEW
INTO HEADER.
SELECT * FROM MARA WHERE MATNR IN XMATNR.
MATNR1 = MARA-MATNR.
CALL FUNCTION 'CHANGEDOCUMENT_READ'
EXPORTING
* ARCHIVE_HANDLE
= 0
* CHANGENUMBER
= ' '
* DATE_OF_CHANGE
= '00000000'
OBJECTCLASS
= 'MATERIAL'
OBJECTID
= MATNR1
* TABLEKEY
= ' '
* TABLENAME
= ' '
* TIME_OF_CHANGE
= '000000'
* USERNAME
= ' '
* LOCAL_TIME
= ' '
TABLES
EDITPOS
= CHGDOC
EXCEPTIONS
NO_POSITION_FOUND
= 1
WRONG_ACCESS_TO_ARCHIVE = 2
TIME_ZONE_CONVERSION_ERROR = 3
OTHERS
= 4.
LOOP AT CHGDOC.
CHECK: CHGDOC-UDATE
IN XUDATE,
CHGDOC-USERNAME IN XUNAME,
CHGDOC-TCODE IN XTCODE.
* Chg type: 1. Part revision,
2. Price change, 3. Others
CASE CHGDOC-TCODE.
WHEN
'MM01' OR 'MM02' OR 'MM03'. CHGTYPE = '1'.
WHEN
'MR21'. CHGTYPE = '2'.
WHEN
OTHERS. CHGTYPE = '3'.
ENDCASE.
* Filter chg type
IF ( CHGTYPE = '1' AND
XCHG1 <> 'X' ) OR
( CHGTYPE
= '2' AND XCHG2 <> 'X' ) OR
( CHGTYPE
= '3' AND XCHG3 <> 'X' ).
CONTINUE.
ENDIF.
* Plant is a substring of tabkey
PLANT = CHGDOC-TABKEY+21(4).
IF NOT ( XWERKS IS INITIAL
) AND NOT ( PLANT IS INITIAL ).
CHECK
PLANT IN XWERKS.
ENDIF.
EXTRACT HEADER.
ENDLOOP.
ENDSELECT.
END-OF-SELECTION.
SORT.
LOOP.
* Material
AT NEW CHGDOC-OBJECTID.
SELECT SINGLE * FROM MAKT
WHERE MATNR = CHGDOC-OBJECTID.
FORMAT INTENSIFIED ON.
SKIP. SKIP.
WRITE:/' *** Material:',
(18) CHGDOC-OBJECTID, MAKT-MAKTX.
ENDAT.
* Change type
AT NEW CHGTYPE.
FORMAT INTENSIFIED ON.
SKIP.
CASE CHGTYPE.
WHEN
'1'. WRITE:/ ' ** Change type: PARTS REVISION'.
WHEN
'2'. WRITE:/ ' ** Change type: PRICE CHANGE'.
WHEN
'3'. WRITE:/ ' ** Change type: OTHERS'.
ENDCASE.
SKIP.
ENDAT.
SHIFT CHGDOC-F_OLD LEFT DELETING LEADING
SPACE.
SHIFT CHGDOC-F_NEW LEFT DELETING LEADING
SPACE.
FORMAT INTENSIFIED OFF.
WRITE:
/ PLANT
UNDER 'Plant',
(50) CHGDOC-FTEXT
UNDER 'Field',
(45) CHGDOC-F_OLD
UNDER 'Old value',
(45) CHGDOC-F_NEW
UNDER 'New value'.
AT NEW CHGDOC-CHANGENR.
FORMAT INTENSIFIED OFF.
WRITE:
CHGDOC-CHANGENR UNDER 'Change doc',
CHGDOC-TCODE UNDER 'Tcod',
CHGDOC-USERNAME UNDER 'User name ',
CHGDOC-UDATE UNDER 'Date
' DD/MM/YY.
ENDAT.
AT END OF CHGDOC-OBJECTID.
SKIP.
ULINE.
SKIP.
ENDAT.
ENDLOOP.
TOP-OF-PAGE.
WRITE: / SY-DATUM, SY-UZEIT,
50 'ABC PTE LTD',
100 'page', SY-PAGNO,
/ SY-REPID,
48 'Change Documents Report',
100 SY-UNAME.
SKIP.
ULINE.
WRITE:/3
'Change doc',
'Tcod',
'User name
',
'Date
',
'Plant',
(50) 'Field',
(45) 'Old value',
(45) 'New value'.
ULINE.
More Function Module
Functions / SAP
Script / ALV
Tables
Database Table
ABAP Books List
ABAP/4 Certification,
Programming, Smartforms, Sapscripts and Object Oriented Programming Books
Smart Forms
SAP Smartforms
ABAP Menu:
ABAP Example Hints
and Tips
Return to Index:-
SAP ABAP/4 Programming,
Basis Administration, Configuration Hints and Tips
(c) www.gotothings.com All material on this site is Copyright.
Every effort is made to ensure the content integrity.
Information used on this site is at your own risk.
All product names are trademarks of their respective
companies. The site www.gotothings.com is in no way affiliated with
SAP AG.
Any unauthorised copying or mirroring is prohibited.
|