10-22-2007 3:51 AM
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.
10-22-2007 7:34 AM
plant (werks) stand in cdpos-tabkey
( try, coz I don't know the offset for 'VERKBELEG')
A.
10-22-2007 7:34 AM
plant (werks) stand in cdpos-tabkey
( try, coz I don't know the offset for 'VERKBELEG')
A.
10-22-2007 7:45 AM
Hi, you will get plant code from t001w table.
and onemore thing is in your code you have declared internal tables under end-of-selection. u have to declare those before start-of-selection. and you have written select query under end-of-selection. that is also wrong. you plz write that query under start-of-selection.
i dont' understand your complete requirement, if you want to add ranges for any variables you can go for select-options statement, or u can declare with ranges statement. but if you use ranges statement u can't see the selection screen while execution.
if u r declared any variable with select-options statement, even though u r not given any value in the selection screen it will fetch all the records available for that variable through select query if that select query is based on this variable condition.
i think this will help you.
if it will helps you plz give reward points.
Thanks ,
Venkat N