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

Display Material Master changes occured in a period



 
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: 1640

PostPosted: Sat Jan 19, 2008 11:07 pm    Post subject: Display Material Master changes occured in a period Reply with quote

Code:
REPORT  ztrace_material.

TABLES: mara,
        cdhdr,
        cdpos.

SELECT-OPTIONS: period     FOR cdhdr-udate,
                name       FOR cdhdr-username,
                material   FOR mara-matnr.

DATA: wchangenr LIKE cdhdr-changenr.

DATA: wtext(80) TYPE c.

DATA : BEGIN OF t_mara OCCURS 0,
       matnr LIKE mara-matnr,
       END OF t_mara.

DATA: BEGIN OF icdhdr OCCURS 50.
        INCLUDE STRUCTURE cdhdr.
DATA: END OF icdhdr.

DATA: BEGIN OF icdshw OCCURS 50.
        INCLUDE STRUCTURE cdshw.
DATA: END OF icdshw.

DATA :  w_matnr LIKE mara-matnr.

DATA: BEGIN OF itab OCCURS 50,
      matnr  LIKE mara-matnr,
      changenr LIKE cdhdr-changenr,
      udate    LIKE cdhdr-udate,
      utime    LIKE cdhdr-utime,
      username LIKE cdhdr-username,
      chngind  LIKE cdshw-chngind,
      ftext    LIKE cdshw-ftext,
      outlen   LIKE cdshw-outlen,
      f_old    LIKE cdshw-f_old,
      f_new    LIKE cdshw-f_new,
      END OF itab.

FIELD-SYMBOLS: <value_old>, <value_new>.

SELECT matnr
      INTO TABLE t_mara
      FROM mara WHERE matnr IN material.

clear t_mara.
LOOP AT t_mara.
* Get Changes
  PERFORM changedocument_read.
ENDLOOP.


LOOP AT itab.
  CLEAR: wtext, w_matnr.
  CASE itab-chngind.
    WHEN 'U'.
      wtext(50) = 'Updated field'.
      wtext+51  = itab-ftext.
      CONDENSE wtext.
    WHEN 'D'.
      wtext = text-021.
    WHEN 'E'.
      wtext(5) = itab-ftext.
      wtext+51 = ' text : E'.
      CONDENSE wtext.
    WHEN 'I'.
      wtext = ' text : I'.
  ENDCASE.
  RESERVE 5 LINES.
  IF wchangenr NE itab-changenr.
    wchangenr = itab-changenr.
    w_matnr = itab-matnr.
    WRITE:/ itab-udate    UNDER 'Change Date',
            itab-utime    UNDER 'Time',
            itab-username UNDER 'User Name',
            itab-matnr    UNDER 'Material No',
            wtext         UNDER 'Changes'.
  ELSEIF itab-matnr NE w_matnr.
    WRITE:/ wtext         UNDER 'Changes'.

  ENDIF.

  CASE itab-chngind.
    WHEN 'U'.
      ASSIGN itab-f_old(itab-outlen) TO <value_old>.
      ASSIGN itab-f_new(itab-outlen) TO <value_new>.
      WRITE: / text-023  UNDER 'Changes',
               <value_old>.
      WRITE: / text-024 UNDER 'Changes',
               <value_new>.
    WHEN 'E'.
      ASSIGN itab-f_old(itab-outlen) TO <value_old>.
      WRITE: text-023 UNDER 'Changes',
             <value_old>.
  ENDCASE.
  SKIP.
ENDLOOP.


TOP-OF-PAGE.
  WRITE: / sy-repid,
           50 'Material Changes'.
Skip to line 4.

  ULINE.
  WRITE:/01 'Change Date',
         15 'Time',
         30 'User Name',
         45 'Material No',
         70 'Changes'.
  ULINE.

*&--------------------------------------------------------------------*
*&      Form  CHANGEDOCUMENT_READ
*&--------------------------------------------------------------------*
*       text
*---------------------------------------------------------------------*
FORM changedocument_read.
  CLEAR cdhdr.
  CLEAR cdpos.
  cdhdr-objectclas = 'MATERIAL'.
  cdhdr-objectid   = t_mara-matnr.

  CALL FUNCTION 'CHANGEDOCUMENT_READ_HEADERS'
    EXPORTING
      date_of_change    = cdhdr-udate
      objectclass       = cdhdr-objectclas
      objectid          = cdhdr-objectid
      time_of_change    = cdhdr-utime
      username          = cdhdr-username
    TABLES
      i_cdhdr           = icdhdr
    EXCEPTIONS
      no_position_found = 1
      OTHERS            = 2.

  CHECK sy-subrc EQ 0.
  DELETE icdhdr WHERE change_ind EQ 'I'.
  CHECK NOT icdhdr[] IS INITIAL.
  LOOP AT icdhdr.
    CHECK icdhdr-udate IN period.
    CHECK icdhdr-username IN name.
    CALL FUNCTION 'CHANGEDOCUMENT_READ_POSITIONS'
      EXPORTING
        changenumber      = icdhdr-changenr
      IMPORTING
        header            = cdhdr
      TABLES
        editpos           = icdshw
      EXCEPTIONS
        no_position_found = 1
        OTHERS            = 2.
    CHECK sy-subrc EQ 0.
    LOOP AT icdshw.
      CHECK icdshw-text_case EQ space.
      MOVE-CORRESPONDING icdshw TO itab.
      MOVE-CORRESPONDING icdhdr TO itab.
      MOVE icdshw-tabkey+3 TO itab-matnr.
      APPEND itab.
    ENDLOOP.
  ENDLOOP.
ENDFORM.                    "CHANGEDOCUMENT_READ
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.