on 08-25-2008 2:53 AM
Hi gurus,
I have a list of items to print out in SAPScript but I can implement it. I've searched this forum for over a day and I can't find the correct answer. I post my code here. Hope you can help me. Thanks in advance.
__P/S:__ I found that someone here solved this by using index. Can you tell me how to implement it?
DATA: BEGIN OF ITAB OCCURS 0,
Elements here
END OF ITAB.
DATA: BEGIN OF XTAB OCCURS 0,
Elements here
END OF XTAB.
DATA: WA_XTAB LIKE XTAB.
DATA: ZOPTIONS LIKE ITCPO OCCURS 0 WITH HEADER LINE.
DATA: ZPAGE TYPE I.
START-OF-SELECTION.
PERFORM PREPARE.
PERFORM FORM_OPEN.
PERFORM FORM_WRITE.
PERFORM FORM_CLOSE.
FORM PREPARE.
Add data to itab & xtab.
ENDFORM.
FORM FORM_OPEN.
CLEAR : ZOPTIONS.
ZOPTIONS-TDDEST = 'LOCLSVC'.
ST_OPTIONS-TDPRINTER =
ZOPTIONS-TDPREVIEW = 'X'.
ZOPTIONS-TDIMMED = 'X'.
ZOPTIONS-TDDELETE = 'X'.
ZOPTIONS-TDPROGRAM = SY-REPID.
ZOPTIONS-TDTELELAND = 'VN'.
CALL FUNCTION 'OPEN_FORM'
EXPORTING
DEVICE = 'PRINTER'
FORM = 'ZF_CC_CI'
LANGUAGE = SY-LANGU
OPTIONS = ZOPTIONS
EXCEPTIONS
CANCELED = 1
DEVICE = 2
FORM = 3
OPTIONS = 4
UNCLOSED = 5.
IF SY-SUBRC <> 0.
MESSAGE E001 WITH 'Output was cancelled'
'by the user.'.
LEAVE LIST-PROCESSING.
ENDIF.
ENDFORM. " FORM_OPEN
FORM FORM_WRITE.
CLEAR ZPAGE.
LOOP AT ITAB.
ZPAGE = ZPAGE + 1.
PERFORM FORM_START.
PERFORM WRITE_TITLE.
PERFORM END_FORM.
ENDLOOP.
ENDFORM.
FORM FORM_START.
CALL FUNCTION 'START_FORM'
EXPORTING
FORM = 'ZF_CC_CI'
LANGUAGE = SY-LANGU
PROGRAM = SY-REPID
EXCEPTIONS
FORM = 1
FORMAT = 2
UNENDED = 3
UNOPENED = 4
UNUSED = 5
OTHERS = 6.
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.
FORM WRITE_TITLE.
DATA: NCOUNT TYPE I,
NI TYPE I.
NI = 1.
DESCRIBE TABLE XTAB LINES NCOUNT.
DO NCOUNT TIMES.
CLEAR WA_XTAB.
READ TABLE XTAB INTO WA_XTAB INDEX NI .
CALL FUNCTION 'WRITE_FORM'
EXPORTING
ELEMENT = 'ITEM'
TYPE = 'BODY'
WINDOW = 'ITEM'.
NI = NI + 1.
ENDDO.
ENDFORM. " WRITE_TITLE
FORM END_FORM.
CALL FUNCTION 'END_FORM'
EXCEPTIONS
UNOPENED = 1
BAD_PAGEFORMAT_FOR_PRINT = 2
SPOOL_ERROR = 3
OTHERS = 4.
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. " END_FORM
FORM FORM_CLOSE.
CALL FUNCTION 'CLOSE_FORM'
EXCEPTIONS
UNOPENED = 1
BAD_PAGEFORMAT_FOR_PRINT = 2
SEND_ERROR = 3
OTHERS = 4.
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. " FORM_CLOSE
I solved this by set this element to MAIN window. But if the data is too long, how to print it continously to the next page? And if I have 2 list to print in a form, how to implement it?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Le Khanh Vinh ...
In Script have You declare Two pages... Let say there is Two pages with names like ..FIRST and Second.
In Standard Attributes of First Page give Next Page as Second.
and for Second Page Standard Attributes give Next Page as Second only.. This will resolve for more Line Items thats it..
Any Info need plz do reply ..
Regards,
Sg
Hi Le Khanh Vinh,
WELCOME TO SDN!!!
As said by Sriram, specify the next page attibute. In Pages you can find the Standard attributes block, there in the Next Page field give First page name itself.
then the data over flows automatically if the first page main window is filled .
Best regards,
raam
Thanks all of you. Hope support from you for future questions!!
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
84 | |
23 | |
11 | |
9 | |
8 | |
5 | |
5 | |
5 | |
5 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.