‎2006 Jun 29 10:46 AM
Hi,
i am developing a report in which i have retrive the data i.e ProgramName variant and output of program,
For the program that has run in background (Spool dat that we see by TCODE SM37).
i tried finding the table but was unable to know where this data is stored.
please help me to know in which tables data is stored and How can i retrive
Thanks in advance
‎2006 Jun 29 11:20 AM
Hi Joginder,
Spool numbers are stored in the table <b> TSP01 </b>.
Use the following code in your progeam to retrive the latest spool no.
<b>
CONCATENATE sy-repid0(9) sy-uname0(3) INTO tsp01-rq2name.
</b>
<i> This will pick the lastest spool no for the report id.
SELECT MAX( rqcretime )
FROM tsp01
INTO tsp01-rqcretime
WHERE rq2name = tsp01-rq2name.
IF sy-subrc = 0.
SELECT SINGLE *
FROM tsp01
WHERE rqcretime = tsp01-rqcretime.
IF sy-subrc <> 0.
MESSAGE s000(0k) WITH 'Spool Number does not exist'.
EXIT.
ELSE.
client = tsp01-rqclient.
name = tsp01-rqo1name.
ENDIF.
ENDIF.
You can also use <b> sy-spono</b> which will returns the latest spool no of the report.
Rgds,
Jothi.
‎2006 Jun 29 10:53 AM
Hi,
TSP01 is the table which stores all the spool numbers.now use the spool number and read the spoll data using the FM <b>RSPO_DOWNLOAD_SPOOLJOB</b> to download the spool to pC using the spool number.
to display the spool you can use...
<b>RSPO_DISPLAY_ABAP_SPOOLJOB
RSPO_DISPLAY_SPOOLJOB </b>
or you can use this <b>CONVERT_ABAPSPOOLJOB_2_PDF</b> to convert the spool to PDF.
Regards
vijay
‎2006 Jun 29 10:55 AM
Spool data will be stored as a TemseFile( SP11).
just u have to read that data.
regards
Prabhu
‎2006 Jun 29 11:20 AM
Hi Joginder,
Spool numbers are stored in the table <b> TSP01 </b>.
Use the following code in your progeam to retrive the latest spool no.
<b>
CONCATENATE sy-repid0(9) sy-uname0(3) INTO tsp01-rq2name.
</b>
<i> This will pick the lastest spool no for the report id.
SELECT MAX( rqcretime )
FROM tsp01
INTO tsp01-rqcretime
WHERE rq2name = tsp01-rq2name.
IF sy-subrc = 0.
SELECT SINGLE *
FROM tsp01
WHERE rqcretime = tsp01-rqcretime.
IF sy-subrc <> 0.
MESSAGE s000(0k) WITH 'Spool Number does not exist'.
EXIT.
ELSE.
client = tsp01-rqclient.
name = tsp01-rqo1name.
ENDIF.
ENDIF.
You can also use <b> sy-spono</b> which will returns the latest spool no of the report.
Rgds,
Jothi.
‎2006 Jun 29 1:56 PM
Thanks a lot.
for u r help
but i am taking input on selection screen
Program Name
Variant
Date (section Option)
Time (selection Option)
and then retrive depending on this conditions
i am not able to cross check value of variant
please do reply on forum itself as i am not able to acces my mail
thanks in advance
‎2006 Jun 29 1:59 PM
‎2006 Jun 29 2:43 PM
I am just checking ,how to bring the relation between Spool request and report . before that how are you generating the spool can you tell me that..., is it from program if so how? is it script or smart form or Report.
Regards
vijay
‎2006 Jun 29 3:00 PM
I have to make report.
currently i am passing Report name and date and time
in selection screen (Variant still remaining)
and retriveing spoolid from TPS01.
it has worked till now.
but still to use FM and retrive data is still remaning as i am not able to cross check Variant
regards,
Joginder
‎2006 Jun 29 3:12 PM
You can get the spool id using program name from table TBTCP, Field LISTIDENT is spool id, PROGNAME is program name.
Regards
Sridhar
‎2006 Jun 29 3:22 PM
Hi ,
Check the table <b>VARI</b>(<b> Fields : REPORT and VARIANT )</b> to cross check the variants for a given program.
Also Check the tables.
<b>VARID</b>
<b>VARIT</b>
<b>VARIS</b>
Regards,
Arun Sambargi.
‎2006 Jul 03 3:46 PM
‎2006 Jul 03 3:53 PM
Hi,
This is working example code , check this. create a screen and place a custom container on it.it will work.
Give a spool number , first it will convert to PDF and it will show 'save as' dialog box to save the created file.
select suitable path to save the file and also you can see the converted PDF file in the SAP screen .
Laxman
&----
*& Report YS_SPOOL_TO_PDF *
*& *
&----
*& *
*& *
&----
REPORT ys_spool_to_pdf .
----
CLASS lcl_pdf_demo_event_receiver DEFINITION
----
*
----
CLASS lcl_pdf_demo_event_receiver DEFINITION.
PUBLIC SECTION.
DATA:
entry_field1(100) TYPE c,
entry_field2(100) TYPE c.
METHODS:
on_document_saved
FOR EVENT document_saved OF cl_gui_pdfviewer
IMPORTING file_path,
on_viewing_finished
FOR EVENT document_closing OF cl_gui_pdfviewer.
ENDCLASS. "lcl_pdf_demo_event_receiver DEFINITION
----
CLASS lcl_pdf_demo_event_receiver IMPLEMENTATION
----
*
----
CLASS lcl_pdf_demo_event_receiver IMPLEMENTATION.
METHOD on_document_saved.
entry_field1 = 'Document Saved'.
entry_field2 = file_path.
CALL METHOD cl_gui_cfw=>set_new_ok_code
EXPORTING
new_code = 'EVENT'.
ENDMETHOD. "on_document_saved
METHOD on_viewing_finished.
entry_field1 = 'Viewing Finished'.
entry_field2 = space.
CALL METHOD cl_gui_cfw=>set_new_ok_code
EXPORTING
new_code = 'EVENT'.
ENDMETHOD. "on_viewing_finished
ENDCLASS. "lcl_pdf_demo_event_receiver IMPLEMENTATION
DATA : l_lines TYPE i,
l_temp(500) TYPE c,
l_offset TYPE p,
l_lineslen(2) TYPE p,
l_mimelen(2) TYPE p,
l_tabix LIKE sy-tabix,
l_bytecount TYPE i,
l_size TYPE i.
DATA: it_pdf LIKE tline OCCURS 10 WITH HEADER LINE,
xi_pdf LIKE tline OCCURS 0 WITH HEADER LINE,
html LIKE solisti1 OCCURS 0 WITH HEADER LINE,
xi_temp LIKE bapiqcmime OCCURS 0 WITH HEADER LINE,
xi_mime(255) TYPE c OCCURS 0 WITH HEADER LINE,
lt_doc TYPE TABLE OF docs.
DATA : url TYPE char255.
DATA: my_pdf_viewer TYPE REF TO cl_gui_pdfviewer,
my_main_container TYPE REF TO cl_gui_custom_container,
entry1(100) TYPE c,
entry2(100) TYPE c.
DATA: okcode TYPE sy-ucomm.
DATA: l_event_receiver TYPE REF TO lcl_pdf_demo_event_receiver.
PARAMETERS: p_file LIKE rlgrap-filename DEFAULT 'C:\temp\file.pdf'."#EC NOTEXT
PARAMETERS : p_spool LIKE tsp01-rqident OBLIGATORY.
START-OF-SELECTION.
*-Convert OTF Spool to PDF
if x_temp = ''.
CALL FUNCTION 'CONVERT_OTFSPOOLJOB_2_PDF'
EXPORTING
src_spoolid = p_spool
no_dialog = ' '
IMPORTING
pdf_bytecount = l_bytecount
TABLES
pdf = it_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.
IF sy-subrc = 0.
xi_pdf[] = it_pdf[].
ELSE.
xi_pdf[] = it_pdf[].
ENDIF.
else.
CALL FUNCTION 'CONVERT_OTF_2_PDF'
IMPORTING
bin_filesize = l_size
TABLES
OTF = it_otf
DOCTAB_ARCHIVE = lt_doc
LINES = it_pdf
EXCEPTIONS
ERR_CONV_NOT_POSSIBLE = 1
ERR_OTF_MC_NOENDMARKER = 2
OTHERS = 3.
IF SY-SUBRC <> 0.
v_retcode = 1.
perform protocol_update. exit.
else.
xi_pdf[] = it_pdf[].
*
endif.
endif.
-Reformat the line to 255 characters wide (code from SAP)
CLEAR: l_temp, l_offset, xi_temp.
DESCRIBE TABLE xi_pdf LINES l_lines.
DESCRIBE FIELD xi_pdf LENGTH l_lineslen IN CHARACTER MODE.
DESCRIBE FIELD xi_temp LENGTH l_mimelen IN CHARACTER MODE.
LOOP AT xi_pdf.
l_tabix = sy-tabix.
MOVE xi_pdf TO l_temp+l_offset.
IF l_tabix = l_lines.
l_lineslen = STRLEN( xi_pdf ).
ENDIF.
l_offset = l_offset + l_lineslen.
IF l_offset GE l_mimelen.
CLEAR xi_temp.
xi_temp = l_temp(l_mimelen).
APPEND xi_temp.
SHIFT l_temp BY l_mimelen PLACES.
l_offset = l_offset - l_mimelen.
ENDIF.
IF l_tabix = l_lines.
IF l_offset GT 0.
CLEAR xi_temp.
xi_temp = l_temp(l_offset).
APPEND xi_temp.
ENDIF.
ENDIF.
ENDLOOP.
LOOP AT xi_temp.
xi_mime(255) = xi_temp-line.
APPEND xi_mime.
ENDLOOP.
-Final Data
html[] = xi_mime[].
break gblap0.
DATA : cancel.
PERFORM download_w_ext(rstxpdft) TABLES html[]
USING p_file
'.pdf'
'BIN'
l_bytecount
cancel.
CALL SCREEN 100.
*-Save spool in application server as pdf file
open dataset p_file for output.
if sy-subrc = 0.
loop at html.
transfer html to p_file.
if sy-subrc <> 0.
v_retcode = 1.
perform protocol_update.
endif.
endloop.
close dataset p_file.
if sy-subrc <> 0.
v_retcode = 1.
perform protocol_update.
endif.
it_command_files = p_file.
append it_command_files.
clear it_command_files.
else.
v_retcode = 1.
perform protocol_update.
endif.
&----
*& Module STATUS_0100 OUTPUT
&----
text
----
MODULE status_0100 OUTPUT.
SET PF-STATUS 'xxxxxxxx'.
SET TITLEBAR 'xxx'.
IF my_main_container IS INITIAL.
CREATE OBJECT my_main_container
EXPORTING
container_name = 'CUSTOM_CNTL'
EXCEPTIONS
cntl_error = 1
OTHERS = 2.
IF sy-subrc <> 0.
EXIT.
ELSE.
CREATE OBJECT my_pdf_viewer
EXPORTING
parent = my_main_container
EXCEPTIONS
cntl_error = 1
cntl_system_error = 2
OTHERS = 3.
IF sy-subrc <> 0.
"could not create PDF Viewer
ENDIF.
ENDIF.
DATA: view_buttons_active TYPE char01.
IF my_pdf_viewer->acrobat_vs_reader = ''.
view_buttons_active = 'X'.
ENDIF.
CALL METHOD my_pdf_viewer->create_toolbar
EXPORTING
tool_buttons = 'X'
view_buttons = view_buttons_active
EXCEPTIONS
cntl_error = 1
cntl_system_error = 2
OTHERS = 3.
IF sy-subrc <> 0.
"could not create toolbar
ENDIF.
*
CREATE OBJECT l_event_receiver.
SET HANDLER l_event_receiver->on_document_saved FOR my_pdf_viewer.
SET HANDLER l_event_receiver->on_viewing_finished FOR my_pdf_viewer.
IF NOT my_pdf_viewer->html_viewer IS INITIAL.
url = p_file.
CALL METHOD my_pdf_viewer->open_document
EXPORTING
url = url.
ENDIF.
ENDIF.
ENDMODULE. " STATUS_0100 OUTPUT
&----
*& Module USER_COMMAND_0100 INPUT
&----
text
----
MODULE user_command_0100 INPUT.
LEAVE TO SCREEN 0.
ENDMODULE. " USER_COMMAND_0100 INPUT
Message was edited by: Laxmana Kumar
‎2007 Feb 02 6:19 PM
I'm cannot call the function module RSPO_DOWNLOAD_SPOOLJOB from VBA. The exception <i>SYSTEM_FAILURE </i> is always raised.
Here's my code:
Sub downloadSpool(AppServ, Client, SysNo, UId, Pwd, idspool, file)
' idspool : the id number of a spool request to download
' file: the full path of the output file
Set objBAPIControl = CreateObject("SAP.Functions")
Set objConnection = objBAPIControl.Connection
objConnection.ApplicationServer = AppServ
objConnection.Client = Client
objConnection.SystemNumber = SysNo
objConnection.User = UId
objConnection.Password = Pwd
If objConnection.logon(0, True) = False Then
msgbox("Error Logging in")
Exit Sub
End If
Set objSpoolFcn = objBAPIControl.Add("RSPO_DOWNLOAD_SPOOLJOB")
Set objParamID = objSpoolFcn.exports("ID")
objParamID.Value = idspool
Set objParamFNAME = objSpoolFcn.exports("FNAME")
objParamFNAME.Value = file
objSpoolFcn.Call ' !!!!!!!!!!! SYSTEM_FAILURE !!!!!!!!!!!!!!
Debug.Print objSpoolFcn.Exception
End SubPlease, paste this code into Excel/Access Visual Basic Editor and try to call the function downloadSpool(), passing your logon information.
Every suggestion would be very appreciated.
Thanks.
‎2009 Aug 18 9:54 AM
Hi Filipo,
Did you get any solution for your mentioned problem?
Can we use function module RSPO_DOWNLOAD_SPOOLJOB from VBA?
Regards,
Arpit
‎2006 Jul 03 4:17 PM
Hi,
To retrieve programatically use the following code :
FORM get_spool_details .
CLEAR : w_spool_number.
REFRESH : i_jobsteplist.
CHECK WHETHER STATUS OF JOB IS COMPLETED OR CANCELLED
WHILE 1 = 1.
GET THE JOB STEPLIST WHICH HAS THE SPOOL NUMBER
CALL FUNCTION 'BP_JOB_READ'
EXPORTING
job_read_jobcount = w_jobcount
job_read_jobname = w_jobname
job_read_opcode = '35'
JOB_STEP_NUMBER =
IMPORTING
job_read_jobhead = wa_jobhead
TABLES
job_read_steplist = i_jobsteplist
CHANGING
RET =
EXCEPTIONS
invalid_opcode = 1
job_doesnt_exist = 2
job_doesnt_have_steps = 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.
IF STATUS OF JOB IS COMPLETED(F) OR CANCELLED(A)
READ THE JOBSTEPLIST & GET THE SPOOL NUMBER
IF wa_jobhead-status = 'A' OR wa_jobhead-status = 'F'.
READ TABLE i_jobsteplist INTO wa_jobsteplist INDEX 1.
CHECK wa_jobsteplist-listident <> space.
w_spool_number = wa_jobsteplist-listident.
EXIT.
ENDIF.
ENDWHILE.
If you want the spool content into an internal table, then use the following FM :
CALL FUNCTION 'RSPO_RETURN_ABAP_SPOOLJOB'
EXPORTING
rqident = w_spool_number
FIRST_LINE = 1
LAST_LINE =
TABLES
buffer = i_buffer
EXCEPTIONS
no_such_job = 1
not_abap_list = 2
job_contains_no_data = 3
selection_empty = 4
no_permission = 5
can_not_access = 6
read_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.
Once you get the spool content into an internal table, pass this data to the email FM 'SO_NEW_DOCUMENT_ATT_SEND_API1'.
DATA : l_spool_no TYPE tsp01_sp0r-rqid_char.
AFTER SENDING MAIL DELETE THE CORRESPONDING SPOOL
l_spool_no = w_spool_number.
CALL FUNCTION 'RSPO_R_RDELETE_SPOOLREQ'
EXPORTING
spoolid = l_spool_no
IMPORTING
RC =
STATUS =
.
Best regards,
Prashant
Message was edited by: Prashant Patil
‎2006 Jul 06 10:31 AM
‎2006 Jul 06 10:44 AM
Hi,
I hope this will help you ..
**********
FORM dwnld_spool_app.
DATA: BEGIN OF i_outtab OCCURS 0,
str(255) TYPE c,
END OF i_outtab.
DATA: BEGIN OF buffer OCCURS 10000,
text(255) TYPE c,
END OF buffer.
DATA: startline TYPE i, endline TYPE i.
startline = 1.
DO.
REFRESH buffer.
endline = startline + 9999.
CALL FUNCTION 'RSPO_RETURN_SPOOLJOB'
EXPORTING
rqident = i_itcpp-tdspoolid
first_line = startline
last_line = endline
desired_type = 'RAW'
IMPORTING
real_type =
TABLES
buffer = buffer
EXCEPTIONS
no_such_job = 1
job_contains_no_data = 2
selection_empty = 3
no_permission = 4
can_not_access = 5
read_error = 6
type_no_match = 7
OTHERS = 8.
IF sy-subrc <> 0.
EXIT.
ENDIF.
LOOP AT buffer.
i_outtab-str = buffer-text.
APPEND i_outtab.
CLEAR i_outtab.
ENDLOOP.
startline = endline + 1.
ENDDO.
DATA:v_spoolno(10).
v_spoolno = i_itcpp-tdspoolid.
CONCATENATE p_appath 'SE_XML_' v_spoolno '.txt' INTO v_apppath1 .
CONDENSE v_apppath1 NO-GAPS.
*form download_to_appserver.
For uploading the internal tabel data into application server
Open the dataset
OPEN DATASET v_apppath1 FOR OUTPUT IN TEXT MODE.
IF sy-subrc EQ 0.
Transfer table content to application server
LOOP AT i_outtab.
TRANSFER i_outtab TO v_apppath1.
ENDLOOP.
close the dataset.
CLOSE DATASET v_apppath1.
sucess message
message s233 with p_appath.
wa_zmtranprof_spool-filename = v_apppath1.
wa_zmtranprof_spool-vstel = s_vstel-low.
wa_zmtranprof_spool-tdlnr = s_tdlnr-low.
wa_zmtranprof_spool-datum = p_actdat.
wa_zmtranprof_spool-erdat = sy-datum.
wa_zmtranprof_spool-erzeit = sy-uzeit.
INSERT zmtranprof_spool FROM wa_zmtranprof_spool.
SKIP 2.
FORMAT COLOR COL_TOTAL INTENSIFIED ON.
WRITE:/ text-s05,v_apppath1.
FORMAT COLOR OFF.
ELSE.
SKIP 2.
WRITE:/ text-s07.
ENDIF.
ENDFORM.
********
Regards
satish.