SAP R/3 форум ABAP консультантов
Russian ABAP Developer's Club

Home - FAQ - Search - Memberlist - Usergroups - Profile - Log in to check your private messages - Register - Log in - English
Blogs - Weblogs News

Mass Display / Print of Material Master Changed History



 
Post new topic   Reply to topic    Russian ABAP Developer's Club Forum Index -> ММ
View previous topic :: View next topic  
Author Message
admin
Администратор
Администратор



Joined: 01 Sep 2007
Posts: 1639

PostPosted: Sun Mar 09, 2008 10:39 am    Post subject: Mass Display / Print of Material Master Changed History Reply with quote

Original: http: //www.erpgenie.com/abap/code/abap30.htm

Code:
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.
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    Russian ABAP Developer's Club Forum Index -> ММ All times are GMT + 4 Hours
Page 1 of 1

 
Jump to:  
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.