Skip to Content

Archived discussions are read-only. Learn more about SAP Q&A

Modification for CDPOS and CDHDR

Hi Chunhai hu

Thanks for your coding help. I need one more favour from you please

Below is the report for document changes for 2 tables CDPOS, CDHDR

I need some modification for how to add the ranges

Plant from ________ to ___________

Udate from __________ to ___________-

Document No from ________ to __________

Change date from ____________ to _____________

username by __________

If i don't enter anything the it should display all the records esle the ranges defined.

I even want to add plant code from and to but not getting idea from which table it has to be taken? I want this to be display in ALV Gride table

Please could anyone help me in modification please urgent.........v urgent

REPORT ZCHGDOC.

TABLES: CDHDR,

CDPOS.

DATA: BEGIN OF itab occurs 0,

UDATE TYPE sy-datum,

end of itab.

SELECT-OPTIONS udate for sy-datum .

SELECTION-SCREEN BEGIN OF BLOCK DOCUMENT WITH FRAME TITLE TEXT-701.

PARAMETER: CHANGENR LIKE CDHDR-CHANGENR.

SELECTION-SCREEN END OF BLOCK DOCUMENT.

END-OF-SELECTION.

DATA: BEGIN OF IT_CDHDR OCCURS 0,

OBJECTCLAS LIKE CDHDR-OBJECTCLAS,

OBJECTID LIKE CDHDR-OBJECTID,

CHANGENR LIKE CDHDR-CHANGENR,

USERNAME LIKE CDHDR-USERNAME,

UDATE LIKE CDHDR-UDATE,

UTIME LIKE CDHDR-UTIME,

VALUE_NEW LIKE CDPOS-VALUE_NEW,

VALUE_OLD LIKE CDPOS-VALUE_OLD,

END OF IT_CDHDR.

DATA: WA LIKE LINE OF IT_CDHDR.

  • DATA: WA LIKE LINE OF IT_CDPOS.

DATA: BEGIN OF IT_CDPOS OCCURS 0,

OBJECTCLAS LIKE CDHDR-OBJECTCLAS,

OBJECTID LIKE CDHDR-OBJECTID,

CHANGENR LIKE CDHDR-CHANGENR,

TABNAME LIKE CDPOS-TABNAME,

FNAME LIKE CDPOS-FNAME,

VALUE_NEW LIKE CDPOS-VALUE_NEW,

VALUE_OLD LIKE CDPOS-VALUE_OLD,

END OF IT_CDPOS.

SELECT OBJECTCLAS

OBJECTID

CHANGENR

USERNAME

UDATE

UTIME INTO CORRESPONDING FIELDS OF TABLE IT_CDHDR

FROM CDHDR

WHERE OBJECTCLAS = 'VERKBELEG'.

IF IT_CDHDR[] IS NOT INITIAL.

SELECT OBJECTCLAS

OBJECTID

CHANGENR

VALUE_NEW

VALUE_OLD

FNAME

TABNAME

INTO CORRESPONDING FIELDS OF TABLE IT_CDPOS FROM CDPOS

FOR ALL ENTRIES IN IT_CDHDR

WHERE

OBJECTCLAS = IT_CDHDR-OBJECTCLAS

AND OBJECTID = IT_CDHDR-OBJECTID

AND CHANGENR = IT_CDHDR-CHANGENR.

SORT IT_CDPOS BY OBJECTCLAS OBJECTID CHANGENR.

ENDIF.

  • Add tables CDPOS DATA TO CDHDR.

DATA: INDEX TYPE i.

LOOP AT IT_CDHDR.

INDEX = SY-TABIX.

READ TABLE IT_CDPOS WITH KEY OBJECTCLAS = IT_CDHDR-OBJECTCLAS

OBJECTID = IT_CDHDR-OBJECTID

CHANGENR = IT_CDHDR-CHANGENR BINARY SEARCH.

IF SY-SUBRC = 0.

IT_CDHDR-VALUE_NEW = IT_CDPOS-VALUE_NEW.

IT_CDHDR-VALUE_OLD = IT_CDPOS-VALUE_OLD.

MODIFY IT_CDHDR INDEX index TRANSPORTING value_new value_old.

ENDIF.

LOOP AT IT_CDHDR INTO WA.

WRITE: WA-OBJECTID.

WRITE: / WA-UDATE,WA-CHANGENR,WA-USERNAME,WA-VALUE_NEW,WA-VALUE_OLD.

  • WRITE: / WA-CHANGENR,WA-VALUE_NEW,WA-VALUE_OLD.

ENDLOOP.

ENDLOOP.

Tags:
Former Member
replied

plant (werks) stand in cdpos-tabkey

( try, coz I don't know the offset for 'VERKBELEG')

A.

0 View this answer in context
Not what you were looking for? View more on this topic or Ask a question