on 05-04-2010 12:44 PM
Hi all,
I am trying to print an output (derived from sap script) directly from program to spool and then fetch the spool request and download it to PDF. This should happen automatically when the end user executes the program by giving required inputs. Can any one guide me on this ?
Rgds,
Praveen
Hi all,
I got the problem solved. Thanks for all who replied and supported me. This is how i solved it. This is not the full code. I am not giving declaration part here. But this is the main blocks which is going to work.
Data: purdocno TYPE string,
v_len_in TYPE i.
PERFORM open_from.
LOOP AT it_itab.
ON CHANGE OF it_itab-ebeln.
PERFORM start_form.
PERFORM write_form.
PERFORM end_form.
END ON.
ENDLOOP.
PERFORM close_form.
PERFORM convpdf.
FORM convpdf.
CALL FUNCTION 'CONVERT_OTF'
EXPORTING
format = 'PDF'
* MAX_LINEWIDTH = 132
* ARCHIVE_INDEX = ' '
* COPYNUMBER = 0
* ASCII_BIDI_VIS2LOG = ' '
PDF_DELETE_OTFTAB = 'X'
IMPORTING
BIN_FILESIZE = v_len_in
* BIN_FILE =
TABLES
otf = i_otf
lines = i_pdf
EXCEPTIONS
ERR_MAX_LINEWIDTH = 1
ERR_FORMAT = 2
ERR_CONV_NOT_POSSIBLE = 3
ERR_BAD_OTF = 4
OTHERS = 5.
purdocno = s_ebeln+3(10).
concatenate 'c:\' purdocno '.pdf' INTO purdocno.
CALL FUNCTION 'GUI_DOWNLOAD'
EXPORTING
* BIN_FILESIZE =
filename = purdocno
FILETYPE = 'BIN' " important
* IMPORTING
* FILELENGTH =
tables
data_tab = i_pdf
EXCEPTIONS
FILE_WRITE_ERROR = 1
NO_BATCH = 2
GUI_REFUSE_FILETRANSFER = 3
INVALID_TYPE = 4
NO_AUTHORITY = 5
UNKNOWN_ERROR = 6
HEADER_NOT_ALLOWED = 7
SEPARATOR_NOT_ALLOWED = 8
FILESIZE_NOT_ALLOWED = 9
HEADER_TOO_LONG = 10
DP_ERROR_CREATE = 11
DP_ERROR_SEND = 12
DP_ERROR_WRITE = 13
UNKNOWN_DP_ERROR = 14
ACCESS_DENIED = 15
DP_OUT_OF_MEMORY = 16
DISK_FULL = 17
DP_TIMEOUT = 18
FILE_NOT_FOUND = 19
DATAPROVIDER_EXCEPTION = 20
CONTROL_FLUSH_ERROR = 21
OTHERS = 22.
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.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
1. Is this an independent driver program or configured in NACE?
2. Where are you storing the downloaded forms?
I think there is no requirement to create a spool. The sap script can be converted to OTF supressing print preview and the OTF can be converted to PDF directly.
Check this link.........
http://wiki.sdn.sap.com/wiki/display/Snippets/DownloadSAPScriptoutputtoPDF+file.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Praveen,
I also faced a similar requirement.
Go step by step as below:-
Declare Data.
DATA: i_otf LIKE itcoo OCCURS 100 WITH HEADER LINE,
i_pdf LIKE tline OCCURS 100 WITH HEADER LINE,
i_opt like itcpo occurs 0 with header line. " important
i_opt-TDGETOTF = 'X'.
append i_opt.
Open your SCRIPT
CALL FUNCTION 'OPEN_FORM'
EXPORTING
APPLICATION = 'TX'
FORM = 'FORM NAME'
LANGUAGE = SY-LANGU
OPTIONS = i_opt " important
Write form
CALL FUNCTION 'WRITE_FORM'
EXPORTING
ELEMENT = 'TEXT'
FUNCTION = 'SET'
TYPE = 'BODY'
WINDOW = 'HEADER'
Close form
CALL FUNCTION 'CLOSE_FORM'
IMPORTING
RESULT =
RDI_RESULT =
TABLES
OTFDATA = i_otf " important
Then convert it to PDF using Convert_OTF
CALL FUNCTION 'CONVERT_OTF'
EXPORTING
format = 'PDF'
MAX_LINEWIDTH = 132
ARCHIVE_INDEX = ' '
COPYNUMBER = 0
ASCII_BIDI_VIS2LOG = ' '
PDF_DELETE_OTFTAB = ' '
IMPORTING
BIN_FILESIZE =
BIN_FILE =
TABLES
otf = i_otf
lines = i_pdf
Now use GUI_DOWNLOAD FM to downland the PDF
CALL FUNCTION 'GUI_DOWNLOAD'
EXPORTING
BIN_FILESIZE =
filename = 'c:\test_pdf.pdf'
FILETYPE = 'BIN' " important
tables
data_tab = i_pdf " as in above FM
Hope it helps.
Revert if you want further help.
Thanks,
Daya
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi daya mishra,
I have worked out your solution but of with no sucess. I am getting "Spool request Number contains no ABAP list data" error.
@ Satyajit --->
1. I dont know ABAP in depth. So i am unable to answer your question
2. I need to download it to my local drive with the provided document number as the filename (say C:\PDF\docno.pdf)
The link you provided is not working.
Regards,
praveen
Hi Satyajit,
Yep. The link is working... I applied the same theory. But I am getting "Unable to interpret "*796" as a number" error pointing to in CONVERT_OTF function module.
When I debug and saw, it is the error at the following IF block.
IF BIN_FILESIZE < 0 or subrc <> 0.
RAISE ERR_CONV_NOT_POSSIBLE. "unable to convert to PDF
ENDIF.
Regards,
Praveen
User | Count |
---|---|
101 | |
13 | |
13 | |
11 | |
11 | |
7 | |
6 | |
5 | |
4 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.