10-22-2007 4:18 AM
Hi Experts
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 5:29 AM
Check this sample program to display data using ALV Grid
Simply copy & execute this program in your system.
You will know how to develop a ALV Grid.
TYPE-POOLS: slis.
DATA: t_fieldcatalog TYPE slis_t_fieldcat_alv.
DATA: s_fieldcatalog TYPE slis_fieldcat_alv.
DATA: s_layout TYPE slis_layout_alv.
DATA: BEGIN OF itab OCCURS 0,
icon TYPE icon-id,
vbeln TYPE vbeln,
kunnr TYPE kunnr,
erdat TYPE erdat,
box TYPE c,
END OF itab.
DATA: v_repid TYPE syrepid.
START-OF-SELECTION.
* Get the data.
SELECT vbeln kunnr erdat UP TO 100 ROWS
FROM vbak
INTO CORRESPONDING FIELDS OF TABLE itab.
IF sy-subrc <> 0.
MESSAGE s208(00) WITH 'No data found'.
LEAVE LIST-PROCESSING.
ENDIF.
* Modify the record with red light.
itab-icon = '@0A@'.
MODIFY itab TRANSPORTING icon WHERE NOT vbeln IS initial.
v_repid = sy-repid.
* Get the field catalog.
CLEAR: s_fieldcatalog.
s_fieldcatalog-col_pos = '1'.
s_fieldcatalog-fieldname = 'ICON'.
s_fieldcatalog-tabname = 'ITAB'.
s_fieldcatalog-seltext_l = 'Status'.
s_fieldcatalog-icon = 'X'.
APPEND s_fieldcatalog TO t_fieldcatalog.
CLEAR: s_fieldcatalog.
s_fieldcatalog-col_pos = '2'.
s_fieldcatalog-fieldname = 'VBELN'.
s_fieldcatalog-tabname = 'ITAB'.
s_fieldcatalog-rollname = 'VBELN'.
APPEND s_fieldcatalog TO t_fieldcatalog.
CLEAR: s_fieldcatalog.
s_fieldcatalog-col_pos = '3'.
s_fieldcatalog-fieldname = 'KUNNR'.
s_fieldcatalog-tabname = 'ITAB'.
s_fieldcatalog-rollname = 'KUNNR'.
APPEND s_fieldcatalog TO t_fieldcatalog.
CLEAR: s_fieldcatalog.
s_fieldcatalog-col_pos = '4'.
s_fieldcatalog-fieldname = 'ERDAT'.
s_fieldcatalog-tabname = 'ITAB'.
s_fieldcatalog-rollname = 'ERDAT'.
APPEND s_fieldcatalog TO t_fieldcatalog.
* Set the layout.
s_layout-box_fieldname = 'BOX'.
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
i_callback_program = v_repid
is_layout = s_layout
it_fieldcat = t_fieldcatalog[]
TABLES
t_outtab = itab.
Regards
Gopi
10-22-2007 5:36 AM
Hi Gopi
Thanks But how can do modification for my code and add alv gride to my above program
can you help please it is urgent
regards
Piroz
10-22-2007 5:49 AM
Have you tried executing the sample code which i gave.
Ok its like this ...
In you case the internal table containing the data is IT_CDHDR,in my case it is itab.
Now you need to fill the field catalog just as i did
Fieldcatalog fills in the fields that should be displayed(lets say layout of ALV output.
* Get the field catalog.
CLEAR: s_fieldcatalog.
s_fieldcatalog-col_pos = '1'.
s_fieldcatalog-fieldname = 'ICON'.
s_fieldcatalog-tabname = 'ITAB'.
s_fieldcatalog-seltext_l = 'Status'.
s_fieldcatalog-icon = 'X'.
APPEND s_fieldcatalog TO t_fieldcatalog.
CLEAR: s_fieldcatalog.
s_fieldcatalog-col_pos = '2'.
s_fieldcatalog-fieldname = 'VBELN'.
s_fieldcatalog-tabname = 'ITAB'.
s_fieldcatalog-rollname = 'VBELN'.
APPEND s_fieldcatalog TO t_fieldcatalog.
CLEAR: s_fieldcatalog.
s_fieldcatalog-col_pos = '3'.
s_fieldcatalog-fieldname = 'KUNNR'.
s_fieldcatalog-tabname = 'ITAB'.
s_fieldcatalog-rollname = 'KUNNR'.
APPEND s_fieldcatalog TO t_fieldcatalog.
CLEAR: s_fieldcatalog.
s_fieldcatalog-col_pos = '4'.
s_fieldcatalog-fieldname = 'ERDAT'.
s_fieldcatalog-tabname = 'ITAB'.
s_fieldcatalog-rollname = 'ERDAT'.
APPEND s_fieldcatalog TO t_fieldcatalog.
Instead of the fields ICON, VBELN ,KUNNR, ERDAT just give in the field names in your internal table IT_CDHDR.
And give in the tabname as CDHDR in Quotes 'CDHDR' and append the field catalog.
Now just pass the
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
i_callback_program = v_repid " v_repid is the report name of your program.
it_fieldcat = t_fieldcatalog[] " fieldcatalog name
TABLES
t_outtab = IT_CDHDR." internal table containing output data
Only thing which you need to do is replace teh fields with your fields from the table IT_CDHDR.
Regards
Gopi
10-22-2007 6:07 AM
hi,
well is IT_CDHDR your final output internal table?? (i.e. does it hold the final values that you want to display)
if so then u can easily call the following function maodule inorder to reuse alv grid... with this you <b>dont</b> need to create any object or any unnecessary things..
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
i_callback_program =
is_layout =
it_fieldcat =
TABLES
<b> t_outtab = IT_CDHDR.</b>
Hope this helps!!
regards,
sagar.