on 08-04-2009 5:19 AM
Dear experts,
I have created a new form for my requirement inthat i need to print the values in my internal table also d layout should be in A4. How to do..? Plz help
regards
e arthi
Hi
First use OPEN_FORM Fm to Form the form
And USE . I_itemdata will contain your Internal Table information. as below
LOOP AT i_itemdata.
PERFORM write_form USING 'ELES' 'APPEND' 'MAIN'.
ENDLOOP.
CALL FUNCTION 'WRITE_FORM'
EXPORTING
element = ele
function = fun
TYPE = 'BODY'
window = win..
and in the Form in the MAIN WIndow use this ELEMENT "ELES"
/E ELES
/: &vline&,,&I_itemdata-sgtxt&,,&VLINE& &I_itemdata-date&&VLINE&
/: &I_itemdata-wrbtr&,,&vline&
***
Surya
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
I tried as u mentioned but only single item is appearing
Wat to do.. Help me
SELECT VBELN POSNR FROM VBAP INTO TABLE IT_VBAP
WHERE VBELN IN S_VBELN.
LOOP AT IT_VBAP.
************************************************************************
Execute the element "HELLO" in window MAIN
- Nothing happens if /E HELLO is not declared in MAIN
************************************************************************
CALL FUNCTION 'WRITE_FORM'
EXPORTING
ELEMENT = 'ITEM' "execute element /E ITEM
FUNCTION = 'APPEND'
TYPE = 'BODY' "normal output
WINDOW = 'MAIN' "to window MAIN
IMPORTING
PENDING_LINES =
EXCEPTIONS
ELEMENT = 1
FUNCTION = 2
TYPE = 3
UNOPENED = 4
UNSTARTED = 5
WINDOW = 6
BAD_PAGEFORMAT_FOR_PRINT = 7
OTHERS = 8.
ENDLOOP.
This is my code
Hi,
LOOP AT IT_VBAP.
CALL FUNCTION 'WRITE_FORM'
EXPORTING
ELEMENT = 'MAIN'
* FUNCTION = 'SET'
* TYPE = 'BODY'
WINDOW = 'MAIN'
* IMPORTING
* PENDING_LINES =
EXCEPTIONS
ELEMENT = 1
FUNCTION = 2
TYPE = 3
UNOPENED = 4
UNSTARTED = 5
WINDOW = 6
BAD_PAGEFORMAT_FOR_PRINT = 7
SPOOL_ERROR = 8
CODEPAGE = 9
OTHERS = 10
.
IF sy-subrc <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
ENDLOOP.
Please see if you have used the MAIN window. You gotto use the MAIN window to display multiple lines of data. Please write your /: &it_vbap-vbeln& in MAIN window. I dont think you are using the MAIN window here. Please write the code in the SAP script in the MAIN window. That will be available by default in the Script.
Hi,
Did you check if your window size was large enough to hold the data items?
Check in debug mode how many times the WRITE_FORM gets executed. If there are multiple rows in the internal table, then the LOOP will execute that many number of times. Please check on that.
Please check if your internal table is populated with multiple rows.
SELECT POSNR MATNR ARKTX UEPOS GRPOS
FROM VBAP
INTO CORRESPONDING FIELDS OF TABLE T_BODY
WHERE VBELN EQ P_VBELN.
CALL FUNCTION 'OPEN_FORM'
EXPORTING
FORM = 'ZSAPSCRIPTS'
EXCEPTIONS
CANCELED = 1
DEVICE = 2
FORM = 3
OPTIONS = 4
UNCLOSED = 5
MAIL_OPTIONS = 6
ARCHIVE_ERROR = 7
INVALID_FAX_NUMBER = 8
MORE_PARAMS_NEEDED_IN_BATCH = 9
SPOOL_ERROR = 10
CODEPAGE = 11
OTHERS = 12.
IF sy-subrc <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
LOOP AT T_BODY INTO WA_BODY.
CALL FUNCTION 'WRITE_FORM'
EXPORTING
ELEMENT = 'MAIN'
WINDOW = 'MAIN'
EXCEPTIONS
ELEMENT = 1
FUNCTION = 2
TYPE = 3
UNOPENED = 4
UNSTARTED = 5
WINDOW = 6
BAD_PAGEFORMAT_FOR_PRINT = 7
SPOOL_ERROR = 8
CODEPAGE = 9
OTHERS = 10.
IF sy-subrc <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
ENDLOOP.
CALL FUNCTION 'CLOSE_FORM'
EXCEPTIONS
UNOPENED = 1
BAD_PAGEFORMAT_FOR_PRINT = 2
SEND_ERROR = 3
SPOOL_ERROR = 4
CODEPAGE = 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.
Edited by: Nitwick on Aug 6, 2009 12:30 PM
REPORT YDEMO_HELLOWORLD .
----
TABLES: VBAP.
PARAMETERS: FORM LIKE RSSCF-TDFORM DEFAULT 'YDEMO_HELLOWORLD'.
----
*DATA DECLARATION
----
DATA : BEGIN OF IT_VBAP OCCURS 100,
VBELN LIKE VBAP-VBELN,
POSNR LIKE VBAP-POSNR,
END OF IT_VBAP.
----
*SELECTION SCREEN
----
SELECTION-SCREEN BEGIN OF BLOCK B1 WITH FRAME TITLE T1.
SELECT-OPTIONS : S_VBELN FOR VBAP-VBELN,
S_POSNR FOR VBAP-POSNR.
SELECTION-SCREEN END OF BLOCK B1.
START-OF-SELECTION.
************************************************************************
Open the SapScript Form with the "form" *
************************************************************************
CALL FUNCTION 'OPEN_FORM'
EXPORTING
APPLICATION = 'TX' " this is SapScript Appl
DEVICE = 'SCREEN' " allow output to printer
DIALOG = 'X' " printer dialog requested
FORM = 'YDEMO_HELLOWORLD'
LANGUAGE = SY-LANGU
OPTIONS = ' '
EXCEPTIONS
CANCELED = 1
DEVICE = 2
FORM = 3
OPTIONS = 4
UNCLOSED = 5
MAIL_OPTIONS = 6
OTHERS = 7.
SELECT VBELN POSNR FROM VBAP INTO TABLE IT_VBAP
WHERE VBELN IN S_VBELN.
LOOP AT IT_VBAP.
PERFORM WRITEFORM.
ENDLOOP.
PERFORM CLOSEFORM.
FORM WRITEFORM.
************************************************************************
Execute the element "HELLO" in window MAIN
- Nothing happens if /E HELLO is not declared in MAIN
************************************************************************
CALL FUNCTION 'WRITE_FORM'
EXPORTING
ELEMENT = 'ITEM' "execute element /E ITEM
FUNCTION = 'ADD'
TYPE = 'BODY' "normal output
WINDOW = 'MAIN' "to window MAIN
IMPORTING
PENDING_LINES =
EXCEPTIONS
ELEMENT = 1
FUNCTION = 2
TYPE = 3
UNOPENED = 4
UNSTARTED = 5
WINDOW = 6
BAD_PAGEFORMAT_FOR_PRINT = 7
OTHERS = 8.
ENDFORM.
FORM CLOSEFORM.
************************************************************************
Close the current SapScript Form
************************************************************************
CALL FUNCTION 'CLOSE_FORM'
EXCEPTIONS
UNOPENED = 1
BAD_PAGEFORMAT_FOR_PRINT = 2
OTHERS = 3.
ENDFORM.
Hi,
By OPEN_FORM function module we can call the form to report program and with WRITE_FORM we can print the internal table data, CLOSE_FORM we can close the form.
Here is a sample code:
CALL FUNCTION 'OPEN_FORM'
* EXPORTING
* APPLICATION = 'TX'
* ARCHIVE_INDEX =
* ARCHIVE_PARAMS =
* DEVICE = 'PRINTER'
* DIALOG = 'X'
* FORM = '<FORM NAME> '
* LANGUAGE = SY-LANGU
* OPTIONS =
* MAIL_SENDER =
* MAIL_RECIPIENT =
* MAIL_APPL_OBJECT =
* RAW_DATA_INTERFACE = '*'
* IMPORTING
* LANGUAGE =
* NEW_ARCHIVE_PARAMS =
* RESULT =
* EXCEPTIONS
* CANCELED = 1
* DEVICE = 2
* FORM = 3
* OPTIONS = 4
* UNCLOSED = 5
* MAIL_OPTIONS = 6
* ARCHIVE_ERROR = 7
* INVALID_FAX_NUMBER = 8
* MORE_PARAMS_NEEDED_IN_BATCH = 9
* SPOOL_ERROR = 10
* CODEPAGE = 11
* OTHERS = 12
.
IF sy-subrc <> 0.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
* WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
CALL FUNCTION 'WRITE_FORM'
* EXPORTING
* ELEMENT = '<PASS THE FIELDSTING>>'
* FUNCTION = 'SET'
* TYPE = 'BODY'
* WINDOW = 'WINDOW NAME
* IMPORTING
* PENDING_LINES =
* EXCEPTIONS
* ELEMENT = 1
* FUNCTION = 2
* TYPE = 3
* UNOPENED = 4
* UNSTARTED = 5
* WINDOW = 6
* BAD_PAGEFORMAT_FOR_PRINT = 7
* SPOOL_ERROR = 8
* CODEPAGE = 9
* OTHERS = 10
.
IF sy-subrc <> 0.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
* WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
Hope this helps you
Regards,
Rajani
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi,
You need to write a report program to fill in the form with internal table values.
In START-OF-SELECTION you select the data and
in END-OF-SELECTION you call the FMs
CALL FUNCTION 'OPEN_FORM'
CALL FUNCTION 'WRITE_FORM'
CALL FUNCTION 'CLOSE_FORM'
Thanks,
Sri.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi,
In the print program you need to give
/: for commands
/* for comments
/E for text element
= for extended line
to fetch value from internal table into the form you have to write
/: &internal_table_name-field_name&
to get a box in the form you can writ
/: box xpos'1.0'cm ypos '1.0'cm width '1.0'cm height '1' cm frame 10
Hope it helps you.
Thanks,
Sri.
User | Count |
---|---|
93 | |
10 | |
10 | |
9 | |
9 | |
7 | |
6 | |
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.