Skip to Content
author's profile photo Former Member
Former Member

track changes in cdhdr and cdpos for unit of measure and per unit

Hi.

unit of measure kmein and per unit kpein are coming from konv table.

Now if the change occurs,where is the new valus will be sotored for them.

i want to diplay both the old and new v

Add a comment
10|10000 characters needed characters exceeded

Assigned Tags

Related questions

3 Answers

  • Posted on Dec 18, 2008 at 07:50 AM

    hi,

    check this program.

    RSVTPROT.

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Dec 18, 2008 at 07:53 AM

    Hi

    As you mentioned the values will be stored in CDHDR and CDPOS.

    get the data from CDHDR by passing the field and then from CDPOS

    Regards

    Shiva

    Add a comment
    10|10000 characters needed characters exceeded

    • Former Member

      agree that the changed value will b stored in the sdhdr and cdpos but the fields where this unit and per unit will be stored, i am unaware of it.

      Also,the old value which are coming from kmein and kpein from konv are not there in cdhdr and cdpos

      please guide accordingly.

  • author's profile photo Former Member
    Former Member
    Posted on Dec 18, 2008 at 08:00 AM

    Hi,

    The old values will be stored in CDHDR and CDPOS tables.

    See if this code helps to you. The report can execute 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.
    
    TABLES: DD04T,
    
            CDHDR,
    
            CDPOS,
    
            DD03L,
    
            DD41V,
    
            T685T,
    
            VBPA,
    
            TPART,
    
            KONVC,
    
            VBUK.
    
    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.
    
    FORM READHEADER.
    
      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.
    
      CASE SY-SUBRC.
    
        WHEN '0000'.
    
        WHEN '0001'.
    
          MESSAGE S311.
    
          LEAVE.
    
        WHEN '0002'.
    
          MESSAGE S311.
    
          LEAVE.
    
      ENDCASE.
    
    ENDFORM.
    
    FORM READPOS.
    
      LOOP AT ICDHDR.
    
        CHECK ICDHDR-UDATE
    
                            IN XUDATE.
    
        CHECK ICDHDR-USERNAME
    
                              IN XNAME.
    
        CALL FUNCTION 'CHANGEDOCUMENT_READ_POSITIONS'
    
             EXPORTING
    
                  CHANGENUMBER      = ICDHDR-CHANGENR
    
                  TABLEKEY          = CDPOS-TABKEY
    
                  TABLENAME         = CDPOS-TABNAME
    
             IMPORTING
    
                  HEADER            = CDHDR
    
             TABLES
    
                  EDITPOS           = ICDSHW
    
             EXCEPTIONS
    
                  NO_POSITION_FOUND = 1
    
                  OTHERS            = 2.
    
        CASE SY-SUBRC.
    
          WHEN '0000'.
    
            LOOP AT ICDSHW.
    
              CHECK ICDSHW-CHNGIND NE 'E'.
    
              CLEAR ITAB.
    
              MOVE-CORRESPONDING ICDHDR TO ITAB.
    
              MOVE-CORRESPONDING ICDSHW TO ITAB.
    
              CASE ITAB-TABNAME.
    
                WHEN 'KONVC'.
    
                  MOVE ICDHDR-OBJECTID TO ITAB-VBELN.
    
                  MOVE ICDSHW-TABKEY(6) TO ITAB-POSNR.
    
                WHEN OTHERS.
    
                  MOVE ICDSHW-TABKEY+3(10)  TO ITAB-VBELN.
    
                  MOVE ICDSHW-TABKEY+13(6)  TO ITAB-POSNR.
    
                  MOVE ICDSHW-TABKEY+19(4)  TO ITAB-ETENR.
    
              ENDCASE.
    
              MOVE '& %' TO ITAB-INDTEXT.
    
              APPEND ITAB.
    
              CLEAR ITAB.
    
            ENDLOOP.
    
          WHEN OTHERS.
    
            MESSAGE S311.
    
            LEAVE.
    
        ENDCASE.
    
      ENDLOOP.
    
    ENDFORM.
    
    TOP-OF-PAGE.
    
    WRITE:/ SY-DATUM,SY-UZEIT,
    
           50 'SALES ORDER CHANGE HISTORY',
    
          120 'Page', SY-PAGNO.
    
    WRITE: / SY-REPID,
    
             60 'SALES ORDERS STATISTICS'.
    
    SKIP.
    
    ULINE.
    
    IF SUDATE = 'X'.
    
      WRITE:/001 'Change Date',
    
             013 'Time',
    
             023 'User Name',
    
             037 'Sale Order',
    
             049 'Line',
    
             057 'Sch No',
    
             065 'Changes'.
    
    ELSEIF SOBID = 'X'.
    
      WRITE:/001 'Sale Order',
    
             013 'Line',
    
             021 'Sch No',
    
             029 'Change Date',
    
             041 'Time',
    
             051 'User Name',
    
             065 'Comment'.
    
    ELSE.
    
      WRITE:/001 'User Name',
    
             015 'Time',
    
             025 'Change Date',
    
             037 'Sale Order',
    
             049 'Line',
    
             057 'Sch No',
    
             065 'Changes'.
    
    ENDIF.
    
    ULINE.

    Add a comment
    10|10000 characters needed characters exceeded

Before answering

You should only submit an answer when you are proposing a solution to the poster's problem. If you want the poster to clarify the question or provide more information, please leave a comment instead, requesting additional details. When answering, please include specifics, such as step-by-step instructions, context for the solution, and links to useful resources. Also, please make sure that you answer complies with our Rules of Engagement.
You must be Logged in to submit an answer.

Up to 10 attachments (including images) can be used with a maximum of 1.0 MB each and 10.5 MB total.