Generate spool request and PDF
Hello Friends,
I have the below requirement in Scripts.
I need to generate spool request and also download the form as pdf simultaneously.
I can able to generate spool request and able to download as PDF separately, but I want to do both in a single open_form is it possible?
Regards.
Krishna.
Copy and Paste following code in a Z program type executable:
REPORT ZRSTXPDFT4 LINE-SIZE 80.
Read spool job contents (OTF or ABAP list) and convert
to PDF, download PDF
B20K8A0IKH replace WS_DOWNLOAD with GUI_DOWNLOAD
SELECTION-SCREEN BEGIN OF BLOCK B WITH FRAME TITLE TEXT-015.
SELECTION-SCREEN SKIP.
PARAMETERS:
SPOOLNO LIKE TSP01-RQIDENT.
SELECTION-SCREEN SKIP.
PARAMETERS : DOWNLOAD AS CHECKBOX DEFAULT 'X',
P_FILE LIKE RLGRAP-FILENAME DEFAULT 'C:\temp\file.pdf' NO-DISPLAY."#EC NOTEXT
SELECTION-SCREEN END OF BLOCK B.
DATA OTF LIKE ITCOO OCCURS 100 WITH HEADER LINE.
DATA CANCEL.
DATA PDF LIKE TLINE OCCURS 100 WITH HEADER LINE.
DATA DOCTAB LIKE DOCS OCCURS 1 WITH HEADER LINE.
DATA: NUMBYTES TYPE I,
ARC_IDX LIKE TOA_DARA,
PDFSPOOLID LIKE TSP01-RQIDENT,
JOBNAME LIKE TBTCJOB-JOBNAME,
JOBCOUNT LIKE TBTCJOB-JOBCOUNT,
IS_OTF.
DATA: CLIENT LIKE TST01-DCLIENT,
NAME LIKE TST01-DNAME,
OBJTYPE LIKE RSTSTYPE-TYPE,
TYPE LIKE RSTSTYPE-TYPE.
TABLES: TSP01.
DATA : RETFIELD TYPE DFIES-FIELDNAME.
DATA : SPOOL TYPE HELP_INFO-DYNPROFLD.
DATA : BEGIN OF ITAB OCCURS 0,
SPOOL TYPE TSP01-RQIDENT,
END OF ITAB.
AT SELECTION-SCREEN ON VALUE-REQUEST FOR SPOOLNO.
RETFIELD = SPOOLNO.
SPOOL = 'SPOOLNO'.
SELECT RQIDENT FROM TSP01 INTO TABLE ITAB."#EC CI_NOWHERE
CALL FUNCTION 'F4IF_INT_TABLE_VALUE_REQUEST'
EXPORTING
DDIC_STRUCTURE = ' '
RETFIELD = RETFIELD
PVALKEY = ' '
DYNPPROG = SY-REPID
DYNPNR = SY-DYNNR
DYNPROFIELD = SPOOL
STEPL = 0
WINDOW_TITLE =
VALUE = ' '
VALUE_ORG = 'S'
MULTIPLE_CHOICE = ' '
DISPLAY = ' '
CALLBACK_PROGRAM = SY-CPROG
CALLBACK_FORM = ' '
MARK_TAB =
IMPORTING
USER_RESET =
TABLES
VALUE_TAB = ITAB[]
FIELD_TAB =
RETURN_TAB =
DYNPFLD_MAPPING =
EXCEPTIONS
PARAMETER_ERROR = 1
NO_VALUES_FOUND = 2
OTHERS = 3
IF SY-SUBRC <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
START-OF-SELECTION.
SELECT SINGLE * FROM TSP01 WHERE RQIDENT = SPOOLNO.
IF SY-SUBRC <> 0.
PERFORM BD_TEXTBOX_ERR(RSTXPDFT) USING 80
'Spoolauftrag existiert nicht'(003).
EXIT.
ENDIF.
CLIENT = TSP01-RQCLIENT.
NAME = TSP01-RQO1NAME.
CALL FUNCTION 'RSTS_GET_ATTRIBUTES'
EXPORTING
AUTHORITY = 'SP01'
CLIENT = CLIENT
NAME = NAME
PART = 1
IMPORTING
CHARCO =
CREATER =
CREDATE =
DELDATE =
MAX_CREDATE =
MAX_DELDATE =
NON_UNIQ =
NOOF_PARTS =
RECTYP =
SIZE =
STOTYP =
TYPE = TYPE
OBJTYPE = OBJTYPE
EXCEPTIONS
FB_ERROR = 1
FB_RSTS_OTHER = 2
NO_OBJECT = 3
NO_PERMISSION = 4.
IF OBJTYPE(3) = 'OTF'.
IS_OTF = 'X'.
ELSE.
IS_OTF = SPACE.
ENDIF.
IF IS_OTF = 'X'.
CALL FUNCTION 'CONVERT_OTFSPOOLJOB_2_PDF'
EXPORTING
SRC_SPOOLID = SPOOLNO
NO_DIALOG = ' '
DST_DEVICE =
PDF_DESTINATION =
IMPORTING
PDF_BYTECOUNT = NUMBYTES
PDF_SPOOLID = PDFSPOOLID
OTF_PAGECOUNT =
BTC_JOBNAME = JOBNAME
BTC_JOBCOUNT = JOBCOUNT
TABLES
PDF = PDF
EXCEPTIONS
ERR_NO_OTF_SPOOLJOB = 1
ERR_NO_SPOOLJOB = 2
ERR_NO_PERMISSION = 3
ERR_CONV_NOT_POSSIBLE = 4
ERR_BAD_DSTDEVICE = 5
USER_CANCELLED = 6
ERR_SPOOLERROR = 7
ERR_TEMSEERROR = 8
ERR_BTCJOB_OPEN_FAILED = 9
ERR_BTCJOB_SUBMIT_FAILED = 10
ERR_BTCJOB_CLOSE_FAILED = 11.
CASE SY-SUBRC.
WHEN 0.
PERFORM BD_TEXTBOX_MSG(RSTXPDFT) USING 80
'Funktion CONVERT_OTFSPOOLJOB_2_PDF erfolgreich'(001).
WHEN 1.
PERFORM BD_TEXTBOX_ERR(RSTXPDFT) USING 80
'Kein OTF- und kein ABAP-Spoolauftrag'(002).
EXIT.
WHEN 2.
PERFORM BD_TEXTBOX_ERR(RSTXPDFT) USING 80
'Spoolauftrag existiert nicht'(003).
EXIT.
WHEN 3.
PERFORM BD_TEXTBOX_ERR(RSTXPDFT) USING 80
'Keine Berechtigung zum Lesen Spoolauftrag'(004).
EXIT.
WHEN OTHERS.
PERFORM BD_TEXTBOX_ERR(RSTXPDFT) USING 80
'Fehler bei Funktion CONVERT_OTFSPOOLJOB_2_PDF'(005).
EXIT.
ENDCASE.
ELSE.
CALL FUNCTION 'CONVERT_ABAPSPOOLJOB_2_PDF'
EXPORTING
SRC_SPOOLID = SPOOLNO
NO_DIALOG = ' '
DST_DEVICE =
PDF_DESTINATION =
IMPORTING
PDF_BYTECOUNT = NUMBYTES
PDF_SPOOLID = PDFSPOOLID
LIST_PAGECOUNT =
BTC_JOBNAME = JOBNAME
BTC_JOBCOUNT = JOBCOUNT
TABLES
PDF = PDF
EXCEPTIONS
ERR_NO_ABAP_SPOOLJOB = 1
ERR_NO_SPOOLJOB = 2
ERR_NO_PERMISSION = 3
ERR_CONV_NOT_POSSIBLE = 4
ERR_BAD_DESTDEVICE = 5
USER_CANCELLED = 6
ERR_SPOOLERROR = 7
ERR_TEMSEERROR = 8
ERR_BTCJOB_OPEN_FAILED = 9
ERR_BTCJOB_SUBMIT_FAILED = 10
ERR_BTCJOB_CLOSE_FAILED = 11.
CASE SY-SUBRC.
WHEN 0.
PERFORM BD_TEXTBOX_MSG(RSTXPDFT) USING 80
'Funktion CONVERT_ABAPSPOOLJOB_2_PDF erfolgreich'(006).
WHEN 1.
PERFORM BD_TEXTBOX_ERR(RSTXPDFT) USING 80
'Kein OTF- und kein ABAP-Spoolauftrag'(002).
EXIT.
WHEN 2.
PERFORM BD_TEXTBOX_ERR(RSTXPDFT) USING 80
'Spoolauftrag existiert nicht'(003).
EXIT.
WHEN 3.
PERFORM BD_TEXTBOX_ERR(RSTXPDFT) USING 80
'Keine Berechtigung zum Lesen Spoolauftrag'(004).
EXIT.
WHEN OTHERS.
PERFORM BD_TEXTBOX_ERR(RSTXPDFT) USING 80
'Fehler bei Funktion CONVERT_ABAPSPOOLJOB_2_PDF'(007).
EXIT.
ENDCASE.
ENDIF.
download PDF file ***********
CHECK DOWNLOAD = 'X'.
IF NOT ( JOBNAME IS INITIAL ).
PERFORM BD_TEXTBOX_VAR2_MSG(RSTXPDFT) USING 80
'Konvertierung per Hintergrundjob'(008)
JOBNAME
JOBCOUNT.
EXIT.
ENDIF.
PERFORM DOWNLOAD_W_EXT(RSTXPDFT) TABLES PDF
USING P_FILE
'.pdf'
'BIN'
NUMBYTES
CANCEL.
IF CANCEL = SPACE.
DATA: S(80).
S = NUMBYTES. CONDENSE S.
CONCATENATE S 'Bytes heruntergeladen in Datei'(009)
INTO S SEPARATED BY SPACE.
PERFORM BD_TEXTBOX_VAR1_MSG(RSTXPDFT) USING 80
S
P_FILE.
ENDIF.
Regards,
Jeet K Bhatt
Similar Messages
-
Convert Spool request to PDF and send as e-mail
Hi all,
Can any one please provide me a sample code for converting spool request to pdf?
Thanks in advance,
Suneela.HI,
Try this
Hi all,
Can any one please provide me a sample code for converting spool request to pdf?
*& Report ZSPOOLTOPDF *
*& Converts spool request into PDF document and emails it to *
*& recipicant. *
*& Execution *
*& This program must be run as a background job in-order for the write *
*& commands to create a Spool request rather than be displayed on *
*& screen *
REPORT zspooltopdf.
PARAMETER: p_email1 LIKE somlreci1-receiver
DEFAULT '[email protected]',
p_sender LIKE somlreci1-receiver
DEFAULT '[email protected]',
p_delspl AS CHECKBOX.
*DATA DECLARATION
DATA: gd_recsize TYPE i.
Spool IDs
TYPES: BEGIN OF t_tbtcp.
INCLUDE STRUCTURE tbtcp.
TYPES: END OF t_tbtcp.
DATA: it_tbtcp TYPE STANDARD TABLE OF t_tbtcp INITIAL SIZE 0,
wa_tbtcp TYPE t_tbtcp.
Job Runtime Parameters
DATA: gd_eventid LIKE tbtcm-eventid,
gd_eventparm LIKE tbtcm-eventparm,
gd_external_program_active LIKE tbtcm-xpgactive,
gd_jobcount LIKE tbtcm-jobcount,
gd_jobname LIKE tbtcm-jobname,
gd_stepcount LIKE tbtcm-stepcount,
gd_error TYPE sy-subrc,
gd_reciever TYPE sy-subrc.
DATA: w_recsize TYPE i.
DATA: gd_subject LIKE sodocchgi1-obj_descr,
it_mess_bod LIKE solisti1 OCCURS 0 WITH HEADER LINE,
it_mess_att LIKE solisti1 OCCURS 0 WITH HEADER LINE,
gd_sender_type LIKE soextreci1-adr_typ,
gd_attachment_desc TYPE so_obj_nam,
gd_attachment_name TYPE so_obj_des.
Spool to PDF conversions
DATA: gd_spool_nr LIKE tsp01-rqident,
gd_destination LIKE rlgrap-filename,
gd_bytecount LIKE tst01-dsize,
gd_buffer TYPE string.
Binary store for PDF
DATA: BEGIN OF it_pdf_output OCCURS 0.
INCLUDE STRUCTURE tline.
DATA: END OF it_pdf_output.
CONSTANTS: c_dev LIKE sy-sysid VALUE 'DEV',
c_no(1) TYPE c VALUE ' ',
c_device(4) TYPE c VALUE 'LOCL'.
*START-OF-SELECTION.
START-OF-SELECTION.
Write statement to represent report output. Spool request is created
if write statement is executed in background. This could also be an
ALV grid which would be converted to PDF without any extra effort
WRITE 'Hello World'.
new-page.
commit work.
new-page print off.
IF sy-batch EQ 'X'.
PERFORM get_job_details.
PERFORM obtain_spool_id.
Alternative way could be to submit another program and store spool
id into memory, will be stored in sy-spono.
*submit ZSPOOLTOPDF2
to sap-spool
spool parameters %_print
archive parameters %_print
without spool dynpro
and return.
Get spool id from program called above
IMPORT w_spool_nr FROM MEMORY ID 'SPOOLTOPDF'.
PERFORM convert_spool_to_pdf.
PERFORM process_email.
if p_delspl EQ 'X'.
PERFORM delete_spool.
endif.
IF sy-sysid = c_dev.
wait up to 5 seconds.
SUBMIT rsconn01 WITH mode = 'INT'
WITH output = 'X'
AND RETURN.
ENDIF.
ELSE.
SKIP.
WRITE:/ 'Program must be executed in background in-order for spool',
'request to be created.'.
ENDIF.
FORM obtain_spool_id *
FORM obtain_spool_id.
CHECK NOT ( gd_jobname IS INITIAL ).
CHECK NOT ( gd_jobcount IS INITIAL ).
SELECT * FROM tbtcp
INTO TABLE it_tbtcp
WHERE jobname = gd_jobname
AND jobcount = gd_jobcount
AND stepcount = gd_stepcount
AND listident <> '0000000000'
ORDER BY jobname
jobcount
stepcount.
READ TABLE it_tbtcp INTO wa_tbtcp INDEX 1.
IF sy-subrc = 0.
message s004(zdd) with gd_spool_nr.
gd_spool_nr = wa_tbtcp-listident.
MESSAGE s004(zdd) WITH gd_spool_nr.
ELSE.
MESSAGE s005(zdd).
ENDIF.
ENDFORM.
FORM get_job_details *
FORM get_job_details.
Get current job details
CALL FUNCTION 'GET_JOB_RUNTIME_INFO'
IMPORTING
eventid = gd_eventid
eventparm = gd_eventparm
external_program_active = gd_external_program_active
jobcount = gd_jobcount
jobname = gd_jobname
stepcount = gd_stepcount
EXCEPTIONS
no_runtime_info = 1
OTHERS = 2.
ENDFORM.
FORM convert_spool_to_pdf *
FORM convert_spool_to_pdf.
CALL FUNCTION 'CONVERT_ABAPSPOOLJOB_2_PDF'
EXPORTING
src_spoolid = gd_spool_nr
no_dialog = c_no
dst_device = c_device
IMPORTING
pdf_bytecount = gd_bytecount
TABLES
pdf = it_pdf_output
EXCEPTIONS
err_no_abap_spooljob = 1
err_no_spooljob = 2
err_no_permission = 3
err_conv_not_possible = 4
err_bad_destdevice = 5
user_cancelled = 6
err_spoolerror = 7
err_temseerror = 8
err_btcjob_open_failed = 9
err_btcjob_submit_failed = 10
err_btcjob_close_failed = 11
OTHERS = 12.
CHECK sy-subrc = 0.
Transfer the 132-long strings to 255-long strings
LOOP AT it_pdf_output.
TRANSLATE it_pdf_output USING ' ~'.
CONCATENATE gd_buffer it_pdf_output INTO gd_buffer.
ENDLOOP.
TRANSLATE gd_buffer USING '~ '.
DO.
it_mess_att = gd_buffer.
APPEND it_mess_att.
SHIFT gd_buffer LEFT BY 255 PLACES.
IF gd_buffer IS INITIAL.
EXIT.
ENDIF.
ENDDO.
ENDFORM.
FORM process_email *
FORM process_email.
DESCRIBE TABLE it_mess_att LINES gd_recsize.
CHECK gd_recsize > 0.
PERFORM send_email USING p_email1.
perform send_email using p_email2.
ENDFORM.
FORM send_email *
--> p_email *
FORM send_email USING p_email.
CHECK NOT ( p_email IS INITIAL ).
REFRESH it_mess_bod.
Default subject matter
gd_subject = 'Subject'.
gd_attachment_desc = 'Attachname'.
CONCATENATE 'attach_name' ' ' INTO gd_attachment_name.
it_mess_bod = 'Message Body text, line 1'.
APPEND it_mess_bod.
it_mess_bod = 'Message Body text, line 2...'.
APPEND it_mess_bod.
If no sender specified - default blank
IF p_sender EQ space.
gd_sender_type = space.
ELSE.
gd_sender_type = 'INT'.
ENDIF.
Send file by email as .xls speadsheet
PERFORM send_file_as_email_attachment
tables it_mess_bod
it_mess_att
using p_email
'Example .xls documnet attachment'
'PDF'
gd_attachment_name
gd_attachment_desc
p_sender
gd_sender_type
changing gd_error
gd_reciever.
ENDFORM.
FORM delete_spool *
FORM delete_spool.
DATA: ld_spool_nr TYPE tsp01_sp0r-rqid_char.
ld_spool_nr = gd_spool_nr.
CHECK p_delspl <> c_no.
CALL FUNCTION 'RSPO_R_RDELETE_SPOOLREQ'
EXPORTING
spoolid = ld_spool_nr.
ENDFORM.
*& Form SEND_FILE_AS_EMAIL_ATTACHMENT
Send email
FORM send_file_as_email_attachment tables it_message
it_attach
using p_email
p_mtitle
p_format
p_filename
p_attdescription
p_sender_address
p_sender_addres_type
changing p_error
p_reciever.
DATA: ld_error TYPE sy-subrc,
ld_reciever TYPE sy-subrc,
ld_mtitle LIKE sodocchgi1-obj_descr,
ld_email LIKE somlreci1-receiver,
ld_format TYPE so_obj_tp ,
ld_attdescription TYPE so_obj_nam ,
ld_attfilename TYPE so_obj_des ,
ld_sender_address LIKE soextreci1-receiver,
ld_sender_address_type LIKE soextreci1-adr_typ,
ld_receiver LIKE sy-subrc.
data: t_packing_list like sopcklsti1 occurs 0 with header line,
t_contents like solisti1 occurs 0 with header line,
t_receivers like somlreci1 occurs 0 with header line,
t_attachment like solisti1 occurs 0 with header line,
t_object_header like solisti1 occurs 0 with header line,
w_cnt type i,
w_sent_all(1) type c,
w_doc_data like sodocchgi1.
ld_email = p_email.
ld_mtitle = p_mtitle.
ld_format = p_format.
ld_attdescription = p_attdescription.
ld_attfilename = p_filename.
ld_sender_address = p_sender_address.
ld_sender_address_type = p_sender_addres_type.
Fill the document data.
w_doc_data-doc_size = 1.
Populate the subject/generic message attributes
w_doc_data-obj_langu = sy-langu.
w_doc_data-obj_name = 'SAPRPT'.
w_doc_data-obj_descr = ld_mtitle .
w_doc_data-sensitivty = 'F'.
Fill the document data and get size of attachment
CLEAR w_doc_data.
READ TABLE it_attach INDEX w_cnt.
w_doc_data-doc_size =
( w_cnt - 1 ) * 255 + STRLEN( it_attach ).
w_doc_data-obj_langu = sy-langu.
w_doc_data-obj_name = 'SAPRPT'.
w_doc_data-obj_descr = ld_mtitle.
w_doc_data-sensitivty = 'F'.
CLEAR t_attachment.
REFRESH t_attachment.
t_attachment[] = it_attach[].
Describe the body of the message
CLEAR t_packing_list.
REFRESH t_packing_list.
t_packing_list-transf_bin = space.
t_packing_list-head_start = 1.
t_packing_list-head_num = 0.
t_packing_list-body_start = 1.
DESCRIBE TABLE it_message LINES t_packing_list-body_num.
t_packing_list-doc_type = 'RAW'.
APPEND t_packing_list.
Create attachment notification
t_packing_list-transf_bin = 'X'.
t_packing_list-head_start = 1.
t_packing_list-head_num = 1.
t_packing_list-body_start = 1.
DESCRIBE TABLE t_attachment LINES t_packing_list-body_num.
t_packing_list-doc_type = ld_format.
t_packing_list-obj_descr = ld_attdescription.
t_packing_list-obj_name = ld_attfilename.
t_packing_list-doc_size = t_packing_list-body_num * 255.
APPEND t_packing_list.
Add the recipients email address
CLEAR t_receivers.
REFRESH t_receivers.
t_receivers-receiver = ld_email.
t_receivers-rec_type = 'U'.
t_receivers-com_type = 'INT'.
t_receivers-notif_del = 'X'.
t_receivers-notif_ndel = 'X'.
APPEND t_receivers.
CALL FUNCTION 'SO_DOCUMENT_SEND_API1'
EXPORTING
document_data = w_doc_data
put_in_outbox = 'X'
sender_address = ld_sender_address
sender_address_type = ld_sender_address_type
commit_work = 'X'
IMPORTING
sent_to_all = w_sent_all
TABLES
packing_list = t_packing_list
contents_bin = t_attachment
contents_txt = it_message
receivers = t_receivers
EXCEPTIONS
too_many_receivers = 1
document_not_sent = 2
document_type_not_exist = 3
operation_no_authorization = 4
parameter_error = 5
x_error = 6
enqueue_error = 7
OTHERS = 8.
Populate zerror return code
ld_error = sy-subrc.
Populate zreceiver return code
LOOP AT t_receivers.
ld_receiver = t_receivers-retrn_code.
ENDLOOP.
ENDFORM.
Reward points if found helpfull....
Venkoji. -
Is there any FM to generate spool request for error log of a background job
Hi,
I am going to create a program to create deliveries and do PGI. This program will be assigned to periodic background job.Now whatever errors are generated in program i have to send the error log to spool request.Is there any FM for generating spool request with this error log or how can this be done? Kindly provide sample code if possible.
Thanks.
Nimish Dongare.Hi Nimish,
How are you doing, This is Shreekant working as ABAP developer, I sow your post in sdn forum, I have a similar requirement like I am changing the delivery taking some data from a flat file which is coming from other system and do PGI. If any error occurs during this process I need to capture it and present it as a report or create log file.. whichever is easier.
Please can u help me how did u achieved this functionality for your requirement?.. pls. can u share some details.
If u don mind, can u give me ur email id to communicate.
Thanks,
Shreekant -
Converting the spool request to PDF format
Dear All ,
I am using RSTXPDF4 to convert a spool request to PDF format , when I execute this program by giving the spool number and dstdevic as Local , its giving the message as " Spool request XXXXX with PDF data created ".
But the problem is when I open this spool request its printing the Junk characters ..!!!
What could be the problem ?
Please give me the solution for this...
Thanks in advance.Hi Prem ,
I have checked the tranx SCOT there I have found the following settings..
Output Dev Type USE
format
PCL HPLJIIID Not Yet Used in Node Maintenance
PDF PDF1 Already Used in Node Maintenance
PS POST2 Not Yet Used in Node Maintenance
TXT ASCIIPRI Already Used in Node Maintenance
Is this OK ...or am I need to do any changes in the settings...??
One more thing when I tries to give this PDF1 Dev type in my RSTXPDF4 input parameters its not taking !!!
Please help... -
Converting spool request into PDF forms
Hi gurus
i am working on upgrade project from 4.6C to ECC 6.0. Business had the functionality developed in 4.6C to " Convert the spool request into PDF forms and can be downloaded into local PC".
Moving to ECC 6.0, is there any standard functionality available in ECC 6.0 to "Convert spool request to PDF forms and download"?
Any help towards this is appreciable.
Thanks
AleemHello,
Yes. The program is RSTXPDFT4.
Sourabh -
How to convert spool request to pdf format (to send mail) - SAP 3.1H
Hi,
I am working in 3.1H version. How to convert spool request into pdf cormat to send a mail?. Spool request is in TEXT format.
regards,
sundaram J.Hi sundaram,
1. I suppose u know how to send
mail with attachment.
2. If that is the case,
then no need to do anything.
3. Bcos
There is setting in SCOT,
for INTERNET
ABAP List ---> PDF
Raw TEXT -
PDF
(Your basis team will help u)
4. text data will get automatically converted
to pdf and get mailed.
regards,
amit m. -
Hi Experts,
My rquirement is to generate spool request without getting the output displayed on the screen.
<fs_outtab> is the dynamic internal table containing data. It will have several fields.
I want to send this data to spool so that it can be seen when the background job runs.
But I do not want the output to be displayed on the screen.
<< Removed >> Please don't forward links as it cannot be opened in my system.
Thanks.
Edited by: Rob Burbank on Jun 25, 2010 11:17 AMSee try to make an alv grid diaplay program for the internal table.( like this)
form fill_catalogue .
wa_fieldcatalog-fieldname = 'WERKS'.
wa_fieldcatalog-seltext_m = 'Plant'.
wa_fieldcatalog-tabname = 'IT_FINAL'.
wa_fieldcatalog-emphasize = 'X'.
append wa_fieldcatalog to fieldcatalog.
clear wa_fieldcatalog.
wa_fieldcatalog-fieldname = 'LGORT'.
wa_fieldcatalog-seltext_m = 'St.Loc'.
wa_fieldcatalog-tabname = 'IT_FINAL'.
wa_fieldcatalog-emphasize = 'X'.
append wa_fieldcatalog to fieldcatalog.
clear wa_fieldcatalog.
wa_fieldcatalog-fieldname = 'SHKZG'.
wa_fieldcatalog-seltext_m = 'Iss/Rec'.
wa_fieldcatalog-tabname = 'IT_FINAL'.
wa_fieldcatalog-emphasize = 'X'.
append wa_fieldcatalog to fieldcatalog.
clear wa_fieldcatalog.
wa_fieldcatalog-fieldname = 'BUDAT'.
wa_fieldcatalog-seltext_m = 'Posting Date'.
wa_fieldcatalog-tabname = 'IT_FINAL'.
wa_fieldcatalog-emphasize = 'X'.
append wa_fieldcatalog to fieldcatalog.
clear wa_fieldcatalog.
wa_fieldcatalog-fieldname = 'CHALAN'.
wa_fieldcatalog-seltext_m = 'Document No'.
wa_fieldcatalog-tabname = 'IT_FINAL'.
wa_fieldcatalog-emphasize = 'X'.
append wa_fieldcatalog to fieldcatalog.
clear wa_fieldcatalog.
wa_fieldcatalog-fieldname = 'BOLNR'.
wa_fieldcatalog-seltext_m = 'Bill of Lading'.
wa_fieldcatalog-tabname = 'IT_FINAL'.
wa_fieldcatalog-emphasize = 'X'.
append wa_fieldcatalog to fieldcatalog.
clear wa_fieldcatalog.
wa_fieldcatalog-fieldname = 'BRGEW'.
wa_fieldcatalog-seltext_m = 'Gross Wt.'.
wa_fieldcatalog-tabname = 'IT_FINAL'.
wa_fieldcatalog-emphasize = 'X'.
append wa_fieldcatalog to fieldcatalog.
clear wa_fieldcatalog.
wa_fieldcatalog-fieldname = 'NTGEW_CH'.
wa_fieldcatalog-seltext_m = 'Net Chargeable Wt.'.
wa_fieldcatalog-tabname = 'IT_FINAL'.
wa_fieldcatalog-emphasize = 'X'.
append wa_fieldcatalog to fieldcatalog.
clear wa_fieldcatalog.
wa_fieldcatalog-fieldname = 'SHIP_PARTY'.
wa_fieldcatalog-seltext_m = 'Customer/Vendor/Plant'.
wa_fieldcatalog-tabname = 'IT_FINAL'.
wa_fieldcatalog-emphasize = 'X'.
append wa_fieldcatalog to fieldcatalog.
clear wa_fieldcatalog.
wa_fieldcatalog-fieldname = 'SAL_GRP'.
wa_fieldcatalog-seltext_m = 'Sales Group'.
wa_fieldcatalog-tabname = 'IT_FINAL'.
wa_fieldcatalog-emphasize = 'X'.
append wa_fieldcatalog to fieldcatalog.
clear wa_fieldcatalog.
endform. "fill_catalogue
*& Form display
text
form display .
call function 'REUSE_ALV_GRID_DISPLAY'
exporting
i_callback_program = sy-repid
it_fieldcat = fieldcatalog[]
tables
t_outtab = it_final
exceptions
program_error = 1
others = 2.
Then you must be accepting some parameters fromthe screen. just take the values from the selection screen
press F9, and proceed as your requirement is.
endform. "display -
Long time for generating spool request for smartforms
Hi,
I'm have designed a smartforms for printing a Receipt form. It takes about 1 minute for generating spool request after pressing the PRINT button in PRODUCTION Server only.
The Code i used is below
CALL FUNCTION lv_fname
EXPORTING
p_belnr = p_belnr
p_bukrs = p_bukrs
p_gjahr = p_gjahr
EXCEPTIONS
formatting_error = 1
internal_error = 2
send_error = 3
user_canceled = 4
OTHERS = 5
IF sy-subrc <> 0.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
* WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
Please help me out to sort this issue.
Thanks,
Ramesh
Edited by: Rameshkumar Raamasamy on Mar 4, 2012 6:21 AMHi Rameshkumar,
you may look at the code sections of your smartform: If you have a lot more data in production than you have in development, it is especially important to use a fully specified primary key for any SELECTs.
You may also ask your basis people to check if any performance warnings have been recorded with database system. This happens quite frequently that growing database tables cause problems when table spaces are not properly assigned or table sizes are not maintained adequately.
Regards
Clemens -
How To Generate Spool request for a SAP-Script form
How To Generate Spool request for a SAP-Script form
Hai Rahaman,
After getting the print preview of the SCRIPT.
Click On PRINT.
Buttom of the page one spool request will be generated by system.
Go to SP01.
You Can Find SPOOL Reqest Number.
Regards.
Eshwar. -
Urgent: Generate spool request no.
Hi gurus,
I have to develop a report which has a pop up box for selection criteria based on which the records are displayed. The list has button 'send' which when clicked the output should be converted to an pdf and mailed.I know how to convert the output to pdf and mailing .
My problem is since the list is dispalyed(report not executed in background) its not generating a spool request no.and therefore i cannot proceed further.How do I generate a spool no??
Is there anyway in which i create a spool no and then asssign it to that list output??or any alternate method??
Kindly help.
Helpful solutions will be rewarded graciously!!!
Regards,
Niky.Hei,
this will also work in the same way,
suppose i_mara have five fields.
Ex:
Types: begin of t_mara,
matnr type matnr,
meins type meins,
maktl type maktl,
ERSDA type ERSDA,
ername type ername,
end of t_mara.
data: i_mara type table of t_mara,
wa_mara like line of i_mara.
DATA: v_dest LIKE tsp01-rqdest,
v_handle LIKE sy-tabix,
v_spool_id LIKE tsp01-rqident,
v_rc TYPE c,
v_errmessage(100) TYPE c,
v_text(70) TYPE c.
START-OF-SELECTION.
SELECT matnr FROM mara INTO TABLE i_mara.
CALL FUNCTION 'RSPO_OPEN_SPOOLREQUEST'
EXPORTING
dest = 'LOCL'
* LAYOUT =
* NAME =
* SUFFIX1 =
* SUFFIX2 =
* COPIES =
* PRIO =
* IMMEDIATE_PRINT =
* AUTO_DELETE =
* TITLELINE =
* RECEIVER =
* DIVISION =
* AUTHORITY =
* POSNAME =
* ACTTIME =
* LIFETIME = '8'
* APPEND =
* COVERPAGE =
* CODEPAGE =
* DOCTYPE =
IMPORTING
handle = v_handle
spoolid = gd_spool_nr
rc = v_rc
errmessage = v_errmessage.
LOOP AT i_mara into wa_mara.
CONCATENATE i_mara-matnr i_mara-meins i_mara-maktl
i_mara-ERSDA i_mara-ERname INTO v_text SEPARATED BY space.
CALL FUNCTION 'RSPO_WRITE_SPOOLREQUEST'
EXPORTING
handle = v_handle
text = v_text
* LENGTH =
* CODEPAGE =
* TRUNCATE =
IMPORTING
rc = v_rc
errmessage = v_errmessage
EXCEPTIONS
handle_not_valid = 1
OTHERS = 2.
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 'RSPO_CLOSE_SPOOLREQUEST'
EXPORTING
handle = v_handle
IMPORTING
rc = v_rc
errmessage = v_errmessage
EXCEPTIONS
handle_not_valid = 1
OTHERS = 2.
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 'CONVERT_ABAPSPOOLJOB_2_PDF'
EXPORTING
src_spoolid = gd_spool_nr
no_dialog = c_no
dst_device = c_device
IMPORTING
pdf_bytecount = gd_bytecount
TABLES
pdf = it_pdf_output
EXCEPTIONS
err_no_abap_spooljob = 1
err_no_spooljob = 2
err_no_permission = 3
err_conv_not_possible = 4
err_bad_destdevice = 5
user_cancelled = 6
err_spoolerror = 7
err_temseerror = 8
err_btcjob_open_failed = 9
err_btcjob_submit_failed = 10
err_btcjob_close_failed = 11
OTHERS = 12.
CHECK sy-subrc = 0. -
Problem in converting Spool Request into PDF format
Hi,
I am facing problem to convert spool request (which store output of sap script) in to PDF format. Actually I have converted it with function module 'CONVERT_OTFSPOOLJOB_2_PDF' and it is working properly but the problem occurs where the BOLD fonts are used. I am unable to see the Text/Address where i have used Bold Font in script (PDF FORMAT). Even though in (SPO1) spool request shows every thing perfectly (along with Bold Font). It will great if you could suggest me something.
Thanks,
PradeepHi Pradeep,
Use ,
Closing the Sapscript, we save data (OTF) in a table
CALL FUNCTION 'CLOSE_FORM'
TABLES
otfdata = t_otfdata
EXCEPTIONS
unopened = 1
bad_pageformat_for_print = 2
send_error = 3
spool_error = 4
OTHERS = 5.
DATA: BEGIN OF t_otfdata2 OCCURS 0.
INCLUDE STRUCTURE solisti1.
DATA: END OF t_otfdata2.
Move OTF data to another table with lenght 255
LOOP AT t_otfdata.
CONCATENATE t_otfdata-tdprintcom t_otfdata-tdprintpar INTO t_otfdata2.
APPEND t_otfdata2.
ENDLOOP.
Convert OTF format to PDF
CALL FUNCTION 'SX_OBJECT_CONVERT_OTF_PDF'
EXPORTING
format_src = 'OTF'
format_dst = 'PDF'
devtype = 'PRINTER'
FUNCPARA =
len_in = len_in
IMPORTING
len_out = len_out
TABLES
content_in = t_otfdata2
content_out = t_pdfdata
EXCEPTIONS
err_conv_failed = 1
OTHERS = 2.
Have a look at Progs. RSTXPDF4 and RSTXPDFT2 for converting the Spool to PDF.
Regards,
Raj
Message was edited by: Rajasekhar Dinavahi
Message was edited by: Rajasekhar Dinavahi -
How to view spool request under pdf preview
Hello ,
We have ECC systems which was recently upgraded to ECC 6 ehp7
We see in SP01 tcode , that we have an option to view the spool requests documents in PDF PREVIEW
I wanted to know the steps to configure PDF PREVIEW and its requirements, as of now if we try to click on PDF PREVIEW we get :
Note : PDF PREVIEW button is already active in SP01
Thanks
ShradhaHello Shradha,
this error message typically appears when the browser can not connect to the PDF.
The reason is that the PDF preview will be made available via the HTTP protocol. If this error message appears, that means the browser is hindered by the firewall, proxies, etc.
Unfortunately this means a network problem.
If you use load balancing, a possible problem is described in SAP Note #1714501 - "SSF: Issue with PDF Preview": an error has been fixed which has caused the browser to contact a wrong Application Server.
However, if this Note has been implemented and the problem still appears, you can try to display the PDF in not-inplace display (although I am not sure this will solve the initial issue).
You can set the not-indplace display in Internet Explorer: select menu "Manage Add-ons", then select on the left side of the popup instead of "Currently loaded add-ons" the "All add-ons". Now "Adobe PDF Reader" will appear in the list. Disable this add-on, then try again in SP01.
I am not sure whether this can bypass the initial problem, but if not: sorry, the network needs to be checked why it hinders the connection from the browser to the Application Server.
Best regards,
Laszlo -
What r spool requests and procedure of configuring printer in SAP
Hello Experts,
i hv one question? wt r spools and wt are spool requests ? what are they used for? also i need a step wise step procedure for configuring printer in SAP . My email id is [email protected] . Requested to revert at earliest as this is very urgent.
points guaranteed.
regards,
Somyahi
whenevr u print ur output , spoll no. will be generated.
Go to TCode Sp01/SP02 and give the spool No. which u generated and there u can find ur spool with outputlist,
The basic transaction to set an printer within an SAP system is SPAD.
I would recommend you to access the online SAP help at the following URL where you will find detailed information on how to set printers :
http://help.sap.com/saphelp_46c/helpdata/en/d9/4aa45b51ea11d189570000e829fbbd/frameset.htm
regards
ajai -
Generate spool request from an invoice
Hi,
I'd like to know is there any function module to generate an spool request from an invoice document generate previously by VF01 (VF04) SAP transaction code.
I'd like to generate on demand a spool request over an invoice previously generated by SAP
Anyone knows if it is possible?
ThanksThe billing process included the spool generation runs perfectly by stantard SAP funciontality.
But I'd like to generate a spool request whenever I want for an invoice previously generated and printed.
You know that for space requirements the spool request are deleted periodically, but I want to generate a spool request for an invoice, which spool request was generated and deleted. This behaviouir is reclaimed for a system process so, it's not possible to regenerated the spool request using the funcionality incluided in SAP by VF02, VF31 transactions code.
I need a function module or something like that, so import and invoice document number and export and spool request.
Thanks in advance, -
Saving spool request in PDF format using background job
Hi,
We have some important jobs which create spool requests. My requirement is to save those spool requests either on front end or on application server in pdf format. I tried with program RSTXPDF4 but i can save those files only when pdf conversion is done online and I want it to run in background as some of the spool request have more then 3000 pages and also i'm not looking for ABAP development.
It is fine with me to save it in text format but some of the spool request have around 3000 pages and i cannot save the whole request in one shot using option system->list->save->local file
It is appreciated if someone has any alternative for the above one.
Regards,
ChaitanyaHi,
Just check Is it solve your purpose... When you are creating background jobs mention your email / user id as spool list recipient...
I think you will recv. the spool output in the mailbox in pdf
Edited by: Mrinal Das on Jan 3, 2011 2:37 PM
Maybe you are looking for
-
Adding a new field to a segment
Hi, I need to add a field(unit price) to the segment(SDPI0D01_Z940EXT1). How do I do this. Please help me. Thanks Veni.
-
How to assign a whole internal table to field symbol
Can anyone explain me that , can we assign the whole internal table to a field symbol .If yes please explain with some simple example by assigning an internal tabl data to a field symbol and how to loop on to that field symbol to write the data from
-
Imac intel 2 core duo running at 117 Fº. Is this healthy?
my imac intel 2 core duo running at 117 Fº. Is this healthy? The fan speeds are ODD: 998 CPU: 1198 HDD: 1199.
-
Creating a custom or random sort order
I would like to be able to drag and drop my images in any given order, and then rename them sequentially. This is useful for creating albums, etc. Will Lightroom enable me to do this? If so, HOW? I have not seen this topic, nor does it appear possibl
-
Sold iMac-Wiped HD-Reinstall Question
Bought a new iRetina 27" and am selling my old 22" iMac. I've zero wiped the HD and have reinstalled Yosemite and have reached the point where the setup process is pick the country. I'm thinking I should power down here and leave the rest for the n