07-12-2010 8:18 AM
Hi,
My requirement is to submit RSNAST00 program from my custom program and use the spool number generated in my program's spool. I have written the code like that:
SUBMIT RSNAST00 WITH S_KAPPL = 'V1'
WITH S_OBJKY = WA_ITAB-VBELN
WITH S_KSCHL = P_OUTPUT
EXPORTING LIST TO MEMORY AND RETURN.
now how can I get the generated spool number? Please help.
07-12-2010 9:12 AM
start your program as job with fm K_BATCH_REQUEST
and you'll get export-parameter TSP01-RQIDENT
hope that helps
Andreas
07-12-2010 9:32 AM
Alternatively, just after submiting the program you can extract latest spool no directly querying the table tsp01
data g_spool TYPE rspoid.
SUBMIT...
SELECT MAX( rqident ) INTO g_spool FROM tsp01
WHERE rqclient = sy-mandt
AND rqowner = sy-uname.
Regards
Marcin
07-12-2010 9:47 AM
Hi Marcin,
For once i beg to differ from you For me this is not a foolproof solution, i will SUBMIT RSNAST00 as a background job [VIA JOB|http://help.sap.com/abapdocu_70/en/ABAPSUBMIT_VIA_JOB.htm].
And then use table TBTCP to get the spool number using JOBNAME & JOBCOUNT.
Comments are welcome
BR,
Suhas
07-12-2010 9:57 AM
For me this is not a foolproof solution
I agree that meanwhile someone else can create new spool request, hence the latest entry would hold wrong spool no, however it is very unlikely to happen so.
Anyhow your solution allows not only to get correct spool no everytime, but also the user can match this no with certain job, thereby having the trace which program has generated the entry.
I like your solution more then mine
Regards
Marcin
07-12-2010 10:00 AM
Hi Marcin,
I would like to ask that along with the two parameters mentioned by you , do I need to pass the field RQ2NAME as a concatenation of program name(sy-repid) and sy-uname to retrieve the spool number or these parameters are sufficient?
If I need to pass, then what will be the value of program name? Will this be my custom program(sy-repid) or RSNAST00 as I need to get the spool number generated by RSNAST00?
07-12-2010 10:07 AM
Hi Marcin and Suhas,
I tried the method told by Suhas but since my program will also run in background , I don't know why but the jobs created by RSNAST00 (when run in batch) are not terminated...please help.
07-12-2010 10:15 AM
I don't think you need any additional parameters to get this spool no. I believe quering by owner and client provides far enough restrcition to spool no you really want. There should be not to many users logged with your name on this client at that time;)
So in fact you would need
DATA: gs_print_params TYPE pri_params.
CALL FUNCTION 'GET_PRINT_PARAMETERS'
EXPORTING
no_dialog = 'X'
IMPORTING
out_parameters = gs_print_params
valid = g_valid
EXCEPTIONS
archive_info_not_found = 1
invalid_print_params = 2
invalid_archive_params = 3
OTHERS = 4.
CHECK sy-subrc = 0.
SUBMIT RSNAST00 WITH S_KAPPL = 'V1'
WITH S_OBJKY = WA_ITAB-VBELN
WITH S_KSCHL = P_OUTPUT
SPOOL PARAMETERS gs_print_params
WITHOUT SPOOL DYNPRO AND RETURN.
SELECT MAX( rqident ) INTO g_spool FROM tsp01
WHERE rqclient = sy-mandt
AND rqowner = sy-uname.
Anyhow submiting VIA JOB (as suggested by Suhas)is probably more convenient way.
Regards
Marcin
07-12-2010 10:32 AM
>
> I don't know why but the jobs created by RSNAST00 (when run in batch) are not terminated.
Did you check the sample program given in SAP documentation ? What is the status of the RSNAST00 job ?
Can you post your code for analysis ?
BR,
Suhas
07-12-2010 10:57 AM
Hi Suhas,
The code written by me is:
IF p_test = 'X'.
LOOP AT i_itab INTO wa_itab.
WRITE : wa_itab-vbeln.
ENDLOOP.
WRITE: 'Test Run only, Output for the above Orders has not been processed'.
ELSE.
CALL FUNCTION 'JOB_OPEN'
EXPORTING
jobname = lv_jobname
IMPORTING
jobcount = lv_jobnumber
EXCEPTIONS
cant_create_job = 1
invalid_job_data = 2
jobname_missing = 3
OTHERS = 4.
IF sy-subrc 0.
ENDIF.
LOOP AT i_itab INTO wa_itab.
SUBMIT rsnast00 TO SAP-SPOOL
SPOOL PARAMETERS print_parameters
WITHOUT SPOOL DYNPRO
VIA JOB lv_jobname NUMBER lv_jobnumber
WITH nast-kappl = lc_appl
WITH nast-objky = wa_itab-vbeln
WITH nast-kschl = p_output
WITH nast-dsuf2 = 'ZTESTPROGRAM_OTC_SAMPLE_NEW'
AND RETURN.
IF sy-subrc = 0.
WRITE : p_output, wa_itab-erdat, wa_itab-kdgrp, wa_itab-vbeln.
WRITE : 'RSNAST00 ran successfully for the above RMA'.
ENDIF.
ENDLOOP.
CALL FUNCTION 'JOB_CLOSE'
EXPORTING
jobcount = lv_jobnumber
jobname = lv_jobname
strtimmed = 'X'
EXCEPTIONS
cant_start_immediate = 1
invalid_startdate = 2
jobname_missing = 3
job_close_failed = 4
job_nosteps = 5
job_notex = 6
lock_failed = 7
invalid_target = 8
OTHERS = 9.
IF sy-subrc 0.
ENDIF.
SELECT SINGLE status FROM tbtco
INTO v_status
WHERE jobname = lv_jobname
AND jobcount = lv_jobnumber.
IF sy-subrc = 0." AND v_status = 'F'.
WRITE: v_status.
ENDIF.
SELECT SINGLE listident FROM tbtcp
INTO v_spool
WHERE jobname = lv_jobname
AND jobcount = lv_jobnumber.
IF sy-subrc = 0.
WRITE: v_spool.
ENDIF.
07-12-2010 11:49 AM
Hi,
I am able to retrieve the spool number. Now I have to attach the spool generated by my program in a mail as an attachment and send to the user. How to achieve this functionality please suggest.
07-12-2010 12:07 PM
>
> I am able to retrieve the spool number. Now I have to attach the spool generated by my program in a mail as an attachment and send to the user. How to achieve this functionality please suggest.
FAQ. Search in SDN you can find many threads addressing this issue. BTW your original query is solved so close the thread & if possible provide some inputs. This will be helpful for future references.
Edited by: Suhas Saha on Jul 12, 2010 4:37 PM
07-14-2010 5:43 AM
Hi,
My requirement is I have to convert the spool generated by my program in PDF format and send as an attachment in mail.
This I have successfully achieved but the problem is I am getting the output in two separate pages of the PDF attachment. I want the data in one page only.
Please help me regarding this issue.