Skip to Content

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

write statement in report

Hi Experts

Can anyone let me know how to display the report with write statement

I am not getting the format according to my expectation it is displaying down eg

Eg I need

-


Contract Document Number

Date change old value new value user

-


Document No

04000600

Udate Text old value new value users

08/10/2007 xyz 100.00 110.00 xyz

08/10/2007 345 30/1/2007 08/10/2007 abc

-


04000700

Udate Text old value new value users

08/09/2007 xyz 100.00 110.00 xyz

08/09/2007 345 30/1/2007 08/10/2007 abc

Like the format as Above but my display is not comming correctly if you can see the programe below you will get an idea

REPORT ZCHGDOC.

TABLES: CDHDR,

CDPOS,

VBAK.

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

SELECTION-SCREEN END OF BLOCK DOCUMENT.

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' ORDER BY UDATE.

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.

.

&----


*& T O P - O F - P A G E *

&----


  • WRITE:/ 'UDATE:' ,SY-DATUM.

FORMAT COLOR 4 INTENSIFIED OFF.

WRITE:/2 'Doc No',

9 'Change (Header / Item)',

20 'OLD VALUE.',

55 'NEW VALUE',

88 'USER'.

&----


*& E N D - O F - P A G E *

&----


LOOP AT IT_CDHDR INTO WA.

WRITE: /(2) WA-OBJECTID,(10) WA-UDATE,(22) WA-CHANGENR,(35) WA-VALUE_NEW,(40) WA-VALUE_OLD,(48) WA-USERNAME.

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

ENDLOOP.

Please help me

regards

Piroz

Tags:
Former Member
Not what you were looking for? View more on this topic or Ask a question