‎2010 Nov 02 6:45 AM
Hi
I need to submit a program to spool in a loop (ex - may be program is sbumitted 5 times).
For each run a spool will be generated, it may the case that for one iteration spool is not generated,
is there anything by which i can get the spool no for each successful run.
Regards
Manu
‎2010 Nov 02 6:50 AM
‎2010 Nov 02 7:00 AM
‎2010 Nov 02 6:57 AM
Hi,
Get the latest spool no generated from table based on the user name.
For Ex:
SUBMIT (save_progn) TO SAP-SPOOL
SPOOL PARAMETERS print_parameters
WITHOUT SPOOL DYNPRO AND RETURN
USING SELECTION-SET save_varia
WITH ...
DO 10 TIMES.
SELECT rqident INTO TABLE lt_spool
FROM tsp01 WHERE
rq0name = 'OITE1'
AND rqowner = sy-uname
AND rqdoctype = 'OTF'.
WAIT UP TO 1 SECONDS.
ENDDO.
Regards,
Srini.
‎2010 Nov 02 7:57 AM
As I am submitting program to spool in loop.
So for ex if for 3rd iteration, spool is not generated, still from table tsp01, i will get the last spool id which was successful, which will not solve my purpose.
Regards
Manu
‎2010 Nov 02 8:24 AM
I am submitting a program in loop, so for ex one of the iteration if spool does not get generated
still from table tsp01- last spool no will be read, which will not solve my purpose
‎2010 Nov 02 8:31 AM
Hi
If you check the table tsp01 after submitting the program u should find out the last spool created, now if the last spool selected is the same of previous loop it'll means no spool is been created.
Max
‎2010 Nov 02 8:39 AM
Hi,
Call the below FM to get the print parameters .. this will be called for every entry in the loop ....
CALL FUNCTION 'GET_PRINT_PARAMETERS'
EXPORTING
destination = 'LP01'
*list_name = 'ZTEST_TEST' <-- U can change this name every time and read in the table TSP01 with RQ2NAME*
list_text = 'SPOOL1' <--- or change this name every time and read TSP01 with RQTITLE
immediately = 'X'
release = 'X'
new_list_id = 'X'
line_size = 200
line_count = 65
layout = 'X_65_200'
sap_cover_page = 'X'
receiver = 'SAP*'
no_dialog = 'X'
IMPORTING
out_parameters = print_parameters
valid = valid_flag.
and then call the below ...
SUBMIT (save_progn) TO SAP-SPOOL
SPOOL PARAMETERS print_parameters
WITHOUT SPOOL DYNPRO AND RETURN
USING SELECTION-SET save_varia
WITH ... ............. (your parameters )
DO 10 TIMES.
SELECT rqident INTO TABLE lt_spool
FROM tsp01 WHERE
rq0name = 'OITE1'
AND RQ2NAME = 'ZTEST_TEST'
AND RQTITLE = 'SPOOL1'.
AND rqowner = sy-uname
AND rqdoctype = 'OTF'.
WAIT UP TO 1 SECONDS.
ENDDO.
Regards,
Srini.
‎2010 Nov 02 9:23 AM
Hi Sree
Thanks for the reply. i just had one doubt. the title can be anything correspondiong to which
its spool id can be fetched.
Regards
Manu
‎2010 Nov 02 10:15 AM
Hi Srini
This is not working for me, entry in table tsp01 is not being saved with this list_name or text,m please help
data: prog(50) type c,
lt_spool type RSPOID,
lv_valid type c,
print_parameters type PRI_PARAMS.
prog = 'ZTST2'.
CALL FUNCTION 'GET_PRINT_PARAMETERS'
EXPORTING
ARCHIVE_ID = C_CHAR_UNKNOWN
ARCHIVE_INFO = C_CHAR_UNKNOWN
ARCHIVE_MODE = C_CHAR_UNKNOWN
ARCHIVE_TEXT = C_CHAR_UNKNOWN
AR_OBJECT = C_CHAR_UNKNOWN
ARCHIVE_REPORT = C_CHAR_UNKNOWN
AUTHORITY = C_CHAR_UNKNOWN
COPIES = C_NUM3_UNKNOWN
COVER_PAGE = C_CHAR_UNKNOWN
DATA_SET = C_CHAR_UNKNOWN
DEPARTMENT = C_CHAR_UNKNOWN
DESTINATION = 'LP01'
EXPIRATION = C_NUM1_UNKNOWN
IMMEDIATELY = 'X'
IN_ARCHIVE_PARAMETERS = ' '
IN_PARAMETERS = ' '
LAYOUT = C_CHAR_UNKNOWN
LINE_COUNT = C_INT_UNKNOWN
LINE_SIZE = C_INT_UNKNOWN
LIST_NAME = 'ZTESTT'
LIST_TEXT = 'ZTESTT'
MODE = ' '
NEW_LIST_ID = 'X'
PROTECT_LIST = C_CHAR_UNKNOWN
NO_DIALOG = 'X'
RECEIVER = 'SAP*'
RELEASE = 'X'
REPORT = C_CHAR_UNKNOWN
SAP_COVER_PAGE = 'X'
HOST_COVER_PAGE = C_CHAR_UNKNOWN
PRIORITY = C_NUM1_UNKNOWN
SAP_OBJECT = C_CHAR_UNKNOWN
TYPE = C_CHAR_UNKNOWN
USER = SY-UNAME
USE_OLD_LAYOUT = ' '
UC_DISPLAY_MODE = C_CHAR_UNKNOWN
DRAFT = C_CHAR_UNKNOWN
ABAP_LIST = ' '
USE_ARCHIVENAME_DEF = ' '
DEFAULT_SPOOL_SIZE = C_CHAR_UNKNOWN
WITH_STRUCTURE = C_CHAR_UNKNOWN
SUPPRESS_SHADING = C_CHAR_UNKNOWN
PO_FAX_STORE = ' '
NO_FRAMES = C_CHAR_UNKNOWN
IMPORTING
OUT_ARCHIVE_PARAMETERS =
OUT_PARAMETERS = print_parameters
VALID = lv_valid
VALID_FOR_SPOOL_CREATION =
EXCEPTIONS
ARCHIVE_INFO_NOT_FOUND = 1
INVALID_PRINT_PARAMS = 2
INVALID_ARCHIVE_PARAMS = 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.
submit (prog) to sap-spool WITHOUT SPOOL DYNPRO and return.
SELECT single rqident INTO lt_spool
FROM tsp01 WHERE
*rq0name = 'OITE1'
RQ2NAME = 'ZTESTT'
and RQTITLE = 'ZTESTT'
AND rqowner = sy-uname.
*AND rqdoctype = 'OTF'.
‎2010 Nov 02 10:26 AM
Hi,
Code looks good but ... need to change the way submit is used...
submit (prog) to sap-spool WITHOUT SPOOL DYNPRO and return.
Need to use the spool parameters ...
SUBMIT (PROG) TO SAP-SPOOL
SPOOL PARAMETERS PRINT_PARAMETERS
WITHOUT SPOOL DYNPRO AND RETURN.
Regards,
Srini.
‎2010 Nov 02 2:46 PM
Hi Srini,
thanks for the reply. Can you please help me in sending the pdf spool output as an attachment, this is the code, but when i try to open the attachement - error is given - file is damaged could not be repared.
CALL FUNCTION 'CONVERT_ABAPSPOOLJOB_2_PDF'
EXPORTING
SRC_SPOOLID = lt_spool
IMPORTING
PDF_BYTECOUNT = PDF_FILESIZE
TABLES
PDF = PDF_OUTPUT.
CHECK sy-subrc = 0.
Transfer the 132-long strings to 255-long strings
LOOP AT PDF_OUTPUT.
TRANSLATE PDF_OUTPUT USING ' ~'.
CONCATENATE gd_buffer 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.
**********************
Refresh: i_reclist,
i_objtxt,
i_objbin,
i_objpack.
clear w_objhead.
i_objbin[] = it_mess_att[].
DESCRIBE TABLE it_mess_att LINES v_lines_bin.
Object with main text of the mail.
i_objtxt = 'Find attached the output of the smart form.'.
APPEND i_objtxt.
i_objtxt = 'Regards,'.
APPEND i_objtxt.
i_objtxt = 'J.Jayanthi'.
APPEND i_objtxt.
DESCRIBE TABLE i_objtxt LINES v_lines_txt.
Document information.
w_doc_chng-obj_name = 'Smartform'.
w_doc_chng-expiry_dat = sy-datum + 10.
w_doc_chng-obj_descr = 'Smart form output'.
w_doc_chng-sensitivty = 'F'. "Functional object
w_doc_chng-doc_size = v_lines_txt * 255.
Pack to main body as RAW.
Obj. to be transported not in binary form
CLEAR i_objpack-transf_bin.
Start line of object header in transport packet
i_objpack-head_start = 1.
Number of lines of an object header in object packet
i_objpack-head_num = 0.
Start line of object contents in an object packet
i_objpack-body_start = 1.
Number of lines of the object contents in an object packet
i_objpack-body_num = v_lines_txt.
Code for document class
i_objpack-doc_type = 'RAW'.
APPEND i_objpack.
Packing as PDF.
i_objpack-transf_bin = 'X'.
i_objpack-head_start = 1.
i_objpack-head_num = 1.
i_objpack-body_start = 1.
i_objpack-body_num = v_lines_bin.
i_objpack-doc_type = 'PDF'.
i_objpack-obj_name = 'Smartform'.
CONCATENATE 'Smartform_output' '.pdf'
INTO i_objpack-obj_descr.
i_objpack-doc_size = v_lines_bin * 255.
APPEND i_objpack.
Document information.
CLEAR i_reclist.
e-mail receivers.
i_reclist-receiver = '089837'.
i_reclist-express = 'X'.
*i_reclist-rec_type = 'U'. "Internet address
i_reclist-rec_type = 'B'.
APPEND i_reclist.
Sending mail.
data: w_sent_all(1) type c,
ld_sender_address LIKE soextreci1-receiver.
LD_SENDER_ADDRESS = SY-UNAME.
CALL FUNCTION 'SO_DOCUMENT_SEND_API1'
EXPORTING
DOCUMENT_DATA = w_doc_chng
PUT_IN_OUTBOX = 'X'
SENDER_ADDRESS = ld_sender_address
SENDER_ADDRESS_TYPE = 'B'
COMMIT_WORK = 'X'
IMPORTING
SENT_TO_ALL = w_sent_all
NEW_OBJECT_ID =
SENDER_ID =
TABLES
PACKING_LIST = i_objpack
OBJECT_HEADER = w_objhead
CONTENTS_BIN = i_objbin
CONTENTS_TXT = i_objtxt
CONTENTS_HEX =
OBJECT_PARA =
OBJECT_PARB =
RECEIVERS = i_reclist
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
.
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 'SO_NEW_DOCUMENT_ATT_SEND_API1'
*EXPORTING
*document_data = w_doc_chng
*put_in_outbox = 'X'
*TABLES
*packing_list = i_objpack
*object_header = w_objhead
*contents_bin = i_objbin
*contents_txt = i_objtxt
*receivers = i_reclist
*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.
*
*IF sy-subrc <> 0.
*MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
*WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
*ENDIF.
‎2010 Nov 08 6:58 AM
Hi Srini
I am able to fetch the spool no from tsp01 if spool is not generated from driver program of adobe form.
But when i am trying this with adobe form, i am not able to set the title of the spool.
Spool is getting generated but not with the title i give.
Regards
Manu
‎2010 Nov 08 10:47 AM
Hi,
Please write the below to write spool data to App. server ....
*First , get the spool number ....
DO 10 TIMES.
SELECT rqident INTO TABLE lt_spool
FROM tsp01 WHERE
rq0name = 'OITE1'
AND rqowner = sy-uname
AND rqdoctype = 'OTF'.
WAIT UP TO 1 SECONDS.
ENDDO.
SORT lt_spool BY rqident DESCENDING.
DELETE ADJACENT DUPLICATES FROM lt_spool COMPARING rqident .
READ TABLE lt_spool INTO wa_spool INDEX 1.
IF sy-subrc = 0.
CLEAR : it_final_pdf[] , it_final_pdf.
CALL FUNCTION 'CONVERT_OTFSPOOLJOB_2_PDF'
EXPORTING
src_spoolid = wa_spool-rqident
TABLES
pdf = it_final_pdf.
CLEAR lv_file.
CONCATENATE '/tmp/' 'Myown.pdf' INTO lv_file.
OPEN DATASET lv_file FOR OUTPUT IN BINARY MODE.
IF sy-subrc = 0.
LOOP AT it_final_pdf INTO wa_final_pdf.
TRANSFER wa_final_pdf TO lv_file.
ENDLOOP.
CLOSE DATASET lv_file.
ENDIF.
Regards,
Srini.
‎2010 Nov 08 11:20 AM
Hi Srini,
THanks for the reply. I am able to do with smartforms, but now i want to write spool which is already in pdf format (no need to convert to pdf) to application server. Can you please help me with this.
Regards
Manu
‎2010 Nov 08 12:09 PM
Hi,
use this FM to read spool data ...
RSPO_RETURN_ABAP_SPOOLJOB_RAW
and pass this data to app server ...
Regards,
Srini.
‎2010 Nov 08 1:02 PM
Hi Srini,
Thanks for the reply but i have to write data(already in pdf format) in pdf format to app server so that by t-code cg3y it may be leter downloaded to desktop.
This FM has buffer of type ANY. Please let me know if i am clear.
Regards
Manu
‎2010 Nov 09 5:18 AM
Hi,
You can use FM : RSPO_RETURN_SPOOLJOB and write the o/p to app server.
Regards,
Srini.
‎2010 Nov 09 5:24 AM
Hi Srini,
I have used that but not able to read the pdf spool.
Also the table which this FM returns does not have any type so i am not sure if we can read the pdf format using this FM.
Just FYI - The FM which converts OTF to PDF returns us the PDf format in table of type TLINE.
Regards
Manu