‎2006 Sep 13 12:59 PM
Hi experts,
See the following pice of code.
The heading for main window is not displaying in all pages.
For example:
Mian window is like this:
Empno Empname Sal
1 a1 5000
So heading Empno,Empname and Sal are not printing in all pages of main window .Can any body tell me What may be the problem in the following code?
TABLES: BSEG,
BKPF,
BKORM,
SKAT.
&----
*& SELECT-OPTIONS
&----
SELECT-OPTIONS: RBUKRS FOR BKORM-BUKRS,
RBELNR FOR BKORM-BELNR,
RGJAHR FOR BKORM-GJAHR.
DATA : T_BSEG LIKE BSEG OCCURS 0 WITH HEADER LINE.
DATA : T_BKPF LIKE BKPF OCCURS 0 WITH HEADER LINE.
DATA : G_COUNT TYPE I.
START-OF-SELECTION.
PERFORM GET_DATA.
Open print job
CALL FUNCTION 'OPEN_FORM'
EXPORTING
DEVICE = 'PRINTER'
FORM = 'ZZ_FIGL_JOURNAL'
DIALOG = 'X'
EXCEPTIONS
CANCELED = 1
DEVICE = 2
FORM = 3
OPTIONS = 4
UNCLOSED = 5
OTHERS = 6.
Display Main heading details
LOOP AT T_BSEG.
G_COUNT = G_COUNT + 1.
IF G_COUNT = 1.
CALL FUNCTION 'WRITE_FORM'
EXPORTING
ELEMENT = 'ELEMENT' *** This is for Line Item header details
WINDOW = 'MAIN'
EXCEPTIONS
OTHERS = 1.
CALL FUNCTION 'WRITE_FORM'
EXPORTING
ELEMENT = 'LINE ITEM DATA' *** This is for Line Item details
WINDOW = 'MAIN'
EXCEPTIONS
OTHERS = 1.
else.
CALL FUNCTION 'WRITE_FORM'
EXPORTING
ELEMENT = 'LINE ITEM DATA'
WINDOW = 'MAIN'
EXCEPTIONS
OTHERS = 1.
ENDIF.
ENDLOOP.
Display Totals
*call function 'WRITE_FORM'
EXPORTING
element = 'TOT_PRICE'
window = 'MAIN'
EXCEPTIONS
others = 1.
*
CALL FUNCTION 'WRITE_FORM'
EXPORTING
WINDOW = 'WINDOW4'
EXCEPTIONS
OTHERS = 1.
close print job
CALL FUNCTION 'CLOSE_FORM'
EXCEPTIONS
OTHERS = 1.
EXIT.
&----
*& FORM GET_DATA
&----
FORM GET_DATA.
SELECT SINGLE * FROM BKPF INTO T_BKPF WHERE BUKRS IN RBUKRS
AND BELNR IN RBELNR
AND GJAHR IN RGJAHR.
IF sy-subrc = 0.
SELECT * FROM BSEG INTO TABLE T_BSEG WHERE BUKRS IN RBUKRS
AND BELNR IN RBELNR
AND GJAHR IN RGJAHR.
if sy-subrc = 0.
ENDIF.
endif.
‎2006 Sep 13 1:06 PM
Hello Ravi,
I think the problem is witht the GF_COUNT Only.
Check that in debug mode.
If useful reward.
Vasanth
‎2006 Sep 13 1:06 PM
Hello Ravi,
I think the problem is witht the GF_COUNT Only.
Check that in debug mode.
If useful reward.
Vasanth
‎2006 Sep 13 1:09 PM
Hi Ravi,
is it an option to define a constant (new) WINDOW for this header? I do not know how your document looks, but in some cases if the item lines are the last matters to be printed and the pages are all the same, you can also print the header of the table in a separate window.
Greetz,
Peter
‎2006 Sep 13 1:11 PM
Hi Ravi ,
Try passing additional import parameter TYPE = HEADER in the FM WRITE_FORM.
CALL FUNCTION 'WRITE_FORM'
EXPORTING
ELEMENT = 'ELEMENT' *** This is for Line Item header
TYPE = 'HEADER'
WINDOW = 'MAIN'
EXCEPTIONS
OTHERS = 1.
Regards
Srikanth M
‎2006 Sep 13 1:23 PM
Hello Ravi,
There are two ways to resolve it...
1.If you do not have any other windows etc to print on the first page as compared to the subsequent ones you can use the below.
--
Setting a Header Text in the Main Window: TOP
Use the TOP .. ENDTOP control command to specify lines of text, which are always to be output at the top of the main window. These text lines are also known as header texts. An example of the use of header texts in the case of a very long table covering several pages of output would be to ensure that the table heading information were repeated at the start of each new page of output.
Syntax:
/: TOP
:
:
/: ENDTOP
---
Solution 2.
2. U can approximately count the number of records it is going to print on the page and basically reset your G_Count to zero on reaching the same in the print program...lets say you wish to print 40 records in a page.
If g_count >= 40.
g_count = 0.
endif.
Message was edited by: Anurag Bankley
Message was edited by: Anurag Bankley