05-30-2007 11:35 AM
Hi All,
I have used the following code to create the Header and Footer Areas for ALV Report.
CLEAR: FS_EVENTCAT.
FS_EVENTCAT-NAME = 'TOP_OF_PAGE'.
FS_EVENTCAT-FORM = 'build_comment'.
APPEND FS_EVENTCAT TO GT_EVENTS.
CLEAR: FS_EVENTCAT.
FS_EVENTCAT-NAME = 'END_OF_LIST'.
FS_EVENTCAT-FORM = 'F_WRITE_SUMMARY'.
APPEND FS_EVENTCAT TO GT_EVENTS.
Now the space is available for both Header and Footer...
But i would like to display the Text in Header and Footer areas...
How to insert the Texts....????
Can you help me please.....???
Regards
Pavan
05-30-2007 11:39 AM
FORM top_of_page.
standard report page heading
DATA: lv_coco_pos TYPE i, "CurPos of 'Company confidential'
lv_title_pos TYPE i, "CurPos of report title
lv_title(70) TYPE c, "Truncated report title
lv_page_pos TYPE i, "CurPos of page number
lv_date_pos TYPE i, "CurPos of date and time
lv_page_no(10) TYPE c,
lv_date(25) TYPE c,
lv_time(20) TYPE c,
lv_page(10) TYPE c.
We may need to truncate title if the line size is < 81.
IF sy-linsz < 81.
lv_title = sy-title+0(50).
ELSE.
lv_title = sy-title.
ENDIF.
Decide on positioning of text depending on width of page
lv_title_pos = ( sy-linsz / 2 ) - ( STRLEN( lv_title ) / 2 ).
lv_coco_pos = sy-linsz - 20.
FORMAT COLOR COL_HEADING INTENSIFIED ON.
WRITE: / 'ABC'
AT lv_title_pos lv_title,
AT lv_coco_pos 'Company Confidential'.
Setup data correctly in the correct format for the display fields.
lv_page = sy-pagno.
SHIFT lv_page LEFT DELETING LEADING ' '.
CONCATENATE sy-datum6(2) sy-datum4(2) sy-datum+0(4)
INTO lv_date SEPARATED BY '.'.
CONCATENATE sy-uzeit0(2) ':' sy-uzeit2(2) INTO lv_time.
CONCATENATE lv_date lv_time INTO lv_date SEPARATED BY ' '.
CONCATENATE 'Page' lv_page INTO lv_page_no SEPARATED BY ' '.
Decide on positioning of text depending on width of page.
lv_page_pos = sy-linsz - ( STRLEN( lv_page_no ) ).
WRITE: / lv_date,
AT lv_page_pos lv_page_no.
ULINE.
ENDFORM. " TOP_OF_PAGE
----
FORM END_OF_PAGE *
----
Subroutine attached as callback form to ABAP List Viewer *
----
FORM end_of_page.
ENDFORM. " END_OF_PAGE
you can use it like this.
and beside this you can also use REUSE ALV COMMENTRY WRITE
regards,
ruchika
reward point if useful
05-30-2007 11:37 AM
Hi
Check this Standard program.It will help you.
<b>BCALV_GRID_VERIFY</b>
Check this link -
http://www.sap-img.com/abap/test-alv-display-with-header-footer.htm
http://www.sap-img.com/fu037.htm
http://www.sap-img.com/abap-function.htm
Regards,
Sree
Message was edited by:
sree ram
05-30-2007 11:39 AM
Hi
There is a FM Reuse_alv_commentary_write(check it once again_.
May be this will be helpful.
Thanks
05-30-2007 11:39 AM
FORM top_of_page.
standard report page heading
DATA: lv_coco_pos TYPE i, "CurPos of 'Company confidential'
lv_title_pos TYPE i, "CurPos of report title
lv_title(70) TYPE c, "Truncated report title
lv_page_pos TYPE i, "CurPos of page number
lv_date_pos TYPE i, "CurPos of date and time
lv_page_no(10) TYPE c,
lv_date(25) TYPE c,
lv_time(20) TYPE c,
lv_page(10) TYPE c.
We may need to truncate title if the line size is < 81.
IF sy-linsz < 81.
lv_title = sy-title+0(50).
ELSE.
lv_title = sy-title.
ENDIF.
Decide on positioning of text depending on width of page
lv_title_pos = ( sy-linsz / 2 ) - ( STRLEN( lv_title ) / 2 ).
lv_coco_pos = sy-linsz - 20.
FORMAT COLOR COL_HEADING INTENSIFIED ON.
WRITE: / 'ABC'
AT lv_title_pos lv_title,
AT lv_coco_pos 'Company Confidential'.
Setup data correctly in the correct format for the display fields.
lv_page = sy-pagno.
SHIFT lv_page LEFT DELETING LEADING ' '.
CONCATENATE sy-datum6(2) sy-datum4(2) sy-datum+0(4)
INTO lv_date SEPARATED BY '.'.
CONCATENATE sy-uzeit0(2) ':' sy-uzeit2(2) INTO lv_time.
CONCATENATE lv_date lv_time INTO lv_date SEPARATED BY ' '.
CONCATENATE 'Page' lv_page INTO lv_page_no SEPARATED BY ' '.
Decide on positioning of text depending on width of page.
lv_page_pos = sy-linsz - ( STRLEN( lv_page_no ) ).
WRITE: / lv_date,
AT lv_page_pos lv_page_no.
ULINE.
ENDFORM. " TOP_OF_PAGE
----
FORM END_OF_PAGE *
----
Subroutine attached as callback form to ABAP List Viewer *
----
FORM end_of_page.
ENDFORM. " END_OF_PAGE
you can use it like this.
and beside this you can also use REUSE ALV COMMENTRY WRITE
regards,
ruchika
reward point if useful
05-30-2007 11:40 AM
just write FORM for them
CLEAR: FS_EVENTCAT.
FS_EVENTCAT-NAME = 'TOP_OF_PAGE'.
FS_EVENTCAT-FORM = 'BUILD_COMMENT'.
APPEND FS_EVENTCAT TO GT_EVENTS.
CLEAR: FS_EVENTCAT.
FS_EVENTCAT-NAME = 'END_OF_LIST'.
FS_EVENTCAT-FORM = 'F_WRITE_SUMMARY'.
APPEND FS_EVENTCAT TO GT_EVENTS.
FORM BUILD_COMMENT.
WRITE : / I AM HEADER'.
ENDFORM.
FORM F_WRITE_SUMMARY .
write:/ 'Welcome to XYZ Limited'.
write:/ 'This is a test program to display Report in ALV Format'.
ENDFORM.
05-30-2007 11:42 AM
Hi Pavan,
If you would like to do using GRID , chk my blog
/people/community.user/blog/2007/05/07/alignment-of-data-in-top-of-page-in-alv-grid
05-30-2007 11:44 AM
Hello Pavan,
form END_OF_LIST.
data: listwidth type i,
ld_pagepos(10) type c,
ld_page(10) type c.
skip.
write:/40 'Page:', sy-pagno .
endform.
you have to create a form in which you can write whatever u want to display
Regards,
Neelambari
05-30-2007 11:58 AM
Hi,
Try with following example program:
REPORT ZRJR02 .
*Table declaration.
TABLES:ZEMP_MST,ZDEPT_MST,ZDESG_MST,ZSL_TXN.
*Varriable declaration.
TYPE-POOLS SLIS.
DATA : POS TYPE I.
DATA REPID LIKE SY-REPID.
DATA : F1 TYPE SLIS_T_FIELDCAT_ALV,
F2 TYPE SLIS_FIELDCAT_ALV,
L_LAYOUT TYPE SLIS_LAYOUT_ALV.
DATA L_POS TYPE I VALUE 1. "position of the column
DATA GT_FIELDCAT TYPE SLIS_T_FIELDCAT_ALV.
*DATA GT_SORT TYPE SLIS_T_SORTINFO_ALV.
data: GT_EVENTS TYPE SLIS_T_EVENT,
FS_EVENTCAT LIKE LINE OF GT_EVENTs.
*Internal table declaration.
*DATA BEGIN OF IT_SORT OCCURS 5.
INCLUDE TYPE SLIS_SORTINFO_ALV.
*DATA END OF IT_SORT.
DATA:BEGIN OF ITAB OCCURS 0,
ZEMPNO LIKE ZEMP_MST-ZEMPNO,
ZEMPNAME LIKE ZEMP_MST-ZEMPNAME,
ZDEPTCD LIKE ZEMP_MST-ZDEPTCD,
ZDEPTNAME LIKE ZDEPT_MST-ZDEPTNAME,
ZDESGCD LIKE ZEMP_MST-ZDESGCD,
ZDESGNAME LIKE ZDESG_MST-ZDESGNAME,
END OF ITAB.
REFRESH ITAB.CLEAR ITAB.
START-OF-SELECTION.
SELECT AZEMPNO AZEMPNAME AZDEPTCD BZDEPTNAME AZDESGCD CZDESGNAME
FROM ZEMP_MST AS A
INNER JOIN ZDEPT_MST AS B
ON AZDEPTCD EQ BZDEPTCD
INNER JOIN ZDESG_MST AS C
ON AZDESGCD EQ CZDESGCD
INTO CORRESPONDING FIELDS OF TABLE ITAB.
IF SY-SUBRC <> 0.
MESSAGE E899(M3) WITH 'No records'.
ENDIF.
perform f_build_eventcat.
PERFORM LAYOUT.
END-OF-SELECTION.
&----
*& Form LAYOUT
&----
FORM LAYOUT .
PERFORM FCAT USING 'ZEMPNO' 'ITAB' '' 'Emp.No.' 'ZEMPNO' 'ZEMP_MST' ''.
PERFORM FCAT USING 'ZEMPNAME' 'ITAB' '' 'Emp. Name' 'ZEMPNAME' 'ZEMP_MST' ''.
PERFORM FCAT USING 'ZDEPTCD' 'ITAB' '' 'Dept.Code' 'ZDEPTCD' 'ZEMP_MST' ''.
PERFORM FCAT USING 'ZDEPTNAME' 'ITAB' '' 'Dept.Name' 'ZDEPTNAME' 'ZDEPT_MST' ''.
PERFORM FCAT USING 'ZDESGCD' 'ITAB' '' 'Desg.Code' 'ZDESGCD' 'ZEMP_MST' ''.
PERFORM FCAT USING 'ZDESGNAME' 'ITAB' '' 'Desg.Name' 'ZDESGNAME' 'ZDESG_MST' ''.
PERFORM LSORT USING 'ZEMPNO' 'IDATA' ''.
PERFORM LSORT USING 'ZEMPNAME' 'IDATA' ''.
MOVE IT_SORT[] TO GT_SORT[].
REPID = SY-REPID.
CALL FUNCTION 'REUSE_ALV_LIST_DISPLAY'
EXPORTING
I_CALLBACK_PROGRAM = REPID
IT_FIELDCAT = F1
IT_SORT = GT_SORT
I_SAVE = 'X'
IT_EVENTS = GT_EVENTS[]
TABLES
T_OUTTAB = ITAB.
IF SY-SUBRC <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
ENDFORM. " LAYOUT
&----
*& Form FCAT
&----
FORM FCAT USING P_FIELD P_TABLE P_SUM P_TEXT P_RFIELD P_RTABLE P_DISP.
ADD 1 TO POS.
F2-COL_POS = POS.
F2-FIELDNAME = P_FIELD.
F2-TABNAME = P_TABLE.
F2-SELTEXT_L = P_TEXT.
F2-REF_FIELDNAME = P_RFIELD.
F2-REF_TABNAME = P_RTABLE.
F2-DO_SUM = P_SUM.
F2-NO_OUT = P_DISP.
APPEND F2 TO F1.
CLEAR F2.
ENDFORM. " FCAT
&----
*& Form LSORT
&----
*FORM LSORT USING P_FIELD P_TABLE P_UP.
ADD 1 TO L_POS.
IT_SORT-SPOS = L_POS.
IT_SORT-FIELDNAME = P_FIELD.
IT_SORT-TABNAME = P_TABLE.
IT_SORT-UP = P_UP.
APPEND IT_SORT.
*ENDFORM. " LSORT
*----
FORM F_BUILD_EVENTCAT .
CLEAR: GT_EVENTS. REFRESH: GT_EVENTS.
CLEAR: FS_EVENTCAT.
FS_EVENTCAT-NAME = 'TOP_OF_PAGE'.
FS_EVENTCAT-FORM = 'F_REPORT_HEADER_ALV'.
APPEND FS_EVENTCAT TO GT_EVENTS.
CLEAR: FS_EVENTCAT.
FS_EVENTCAT-NAME = 'END_OF_LIST'.
FS_EVENTCAT-FORM = 'F_WRITE_SUMMARY'.
APPEND FS_EVENTCAT TO GT_EVENTS.
ENDFORM. " F_BUILD_EVENTCAT
FORM F_REPORT_HEADER_ALV.
CALL FUNCTION 'Z_YHEAD_PRINT'
EXPORTING
TITLE1 = 'XYZ Limited'
TITLE2 = 'Employee Master'
TITLE3 = 'Created on '
COLOR = 'X'
.
ENDFORM.
&----
*& Form F_WRITE_SUMMARY
&----
Write summary before exit
----
FORM F_WRITE_SUMMARY .
write:/ 'Welcome to XYZ Limited'.
write:/ 'This is a test program to display Report in ALV Format'.
ENDFORM.
Regards,
Bhaskar