工作生活与爱好

工作中的记录; 生活中的记忆; 业余爱好的记载。

2007-01-26

 

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.

*** End of Program

Comments: 发表评论



<< Home

Archives

1990年1月15日   2007年1月14日   2007年1月15日   2007年1月16日   2007年1月17日   2007年1月18日   2007年1月19日   2007年1月20日   2007年1月22日   2007年1月23日   2007年1月24日   2007年1月25日   2007年1月26日   2007年1月27日   2007年1月29日   2007年1月30日   2007年1月31日   2007年2月1日   2007年2月2日   2007年2月3日   2007年3月13日   2007年5月15日   2007年5月16日   2007年6月2日  

This page is powered by Blogger. Isn't yours?