05-26-2011 6:08 AM
Hello Everyone,
Suppose there is a scenario, when 3 users are sharing same session and executing a program simultaneously.
In the program, the users are submitting a program to sap spool such that a spool no is generated.
and based on that spool no, the users read its log...
How will we identify that which spool no belongs to which particular session so that the the user will read its own loag and not the other person/'s log...
05-26-2011 7:07 AM
Hi Suruchi,
if you're submitting the reports within a Z program, you can try to get the spool number right after submitting:
SUBMIT (report)
TO SAP-SPOOL ... "and so on.
DATA: l_spool_c LIKE tsp01_sp0r-rqid_char.
GET PARAMETER ID 'SPI' FIELD l_spool_c.
" now l_spool_c contains the spool number
I hope it helps.
Kind regards,
Alvaro
05-26-2011 6:11 AM
Hi,
The program can be submitted as a job which has a unique job number and accordingly spool number will be generated which can read.
See code e.g below:
DATA: number TYPE tbtcjob-jobcount,
name TYPE tbtcjob-jobname VALUE 'JOB_TEST',
print_parameters TYPE pri_params.
...
CALL FUNCTION 'JOB_OPEN'
EXPORTING
jobname = name
IMPORTING
jobcount = number
EXCEPTIONS
cant_create_job = 1
invalid_job_data = 2
jobname_missing = 3
OTHERS = 4.
IF sy-subrc = 0.
SUBMIT submitable TO SAP-SPOOL
SPOOL PARAMETERS print_parameters
WITHOUT SPOOL DYNPRO
VIA JOB name NUMBER number
AND RETURN.
IF sy-subrc = 0.
CALL FUNCTION 'JOB_CLOSE'
EXPORTING
jobcount = number
jobname = name
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
OTHERS = 8.
IF sy-subrc <> 0.
...
ENDIF.
ENDIF.
ENDIF.
Hope it helps.
Regards,
Mansi.
05-26-2011 6:21 AM
Hey Thanks for quick Reply....
But my requirement is i cant submit the program as a Job.
because i am calling 3 programs in my Zprogram which are dependent on each other.
So i am calling 3 submit statements, each generating the spool number.
If i scheedule a job, then the other programs which are dependent on the first one wont be executed successfully.
Any other suggestion....
05-26-2011 6:22 AM
Each user can chech the same with 'Own spool requests' right ?Executed by their user id..
05-26-2011 6:24 AM
But the user id is same in all the cases.
The users are sharing sessions.
05-26-2011 6:29 AM
Go to sm37 and check the job is triggered there..if yes,go to push button -> step ..then you will be able top see all program names executed and corresponding spool numbers for each program.
05-26-2011 6:38 AM
I am not submitting my program as a job so no job is created in SM37.
05-26-2011 6:52 AM
Hi,
I don't think this is a valid scenario.. as the persons are sahring same user id , and in SAP one user id will have one first and last name(bname). so always get one user name only.
one more thing we can do, not sure how much it is helpful.
create a custom table with the following fields
userid,firstname, lastname, username. the custom table should be updated for all the users who will be executing the program.
so for same user id , the first name and last name is same but we can have multiple usernames.Once it is done.
also in the program selection screen have one more field as USER (give F4 help getting data from custom table) and every user should enter his / her name . Now while you submit to spool , add the USER to the submit program.
Regards,
Nagaraj
05-26-2011 7:07 AM
Hi Suruchi,
if you're submitting the reports within a Z program, you can try to get the spool number right after submitting:
SUBMIT (report)
TO SAP-SPOOL ... "and so on.
DATA: l_spool_c LIKE tsp01_sp0r-rqid_char.
GET PARAMETER ID 'SPI' FIELD l_spool_c.
" now l_spool_c contains the spool number
I hope it helps.
Kind regards,
Alvaro
05-26-2011 7:11 AM
Hi,
Try this one,
Once the user is executing the program just before the submit command store system time in some variable,
after the program creates a spool go to TSP01 table give the username and time of creation.
This will give them the spool req number pass this as a message or write this in output.
I think there will be slit difference in the time so that we can identify.
Or
Submit your program in background.
Check if 1st program is finished and successfull then run the other 1.
You can use FM 'BP_JOB_STATUS_GET" to get the status.
Thanks,
Anmol.
05-26-2011 10:18 AM
Thanks for all the replies.. My problem has been resolved
Edited by: Suruchi Razdan on May 26, 2011 11:18 AM
05-26-2011 10:54 AM
My 2 cents ...
Although you're have marked Alvaro's solution as "Correct", but i have some apprehensions about it! If there is a case where you've spool creation simultaneously in different user sessions, can you rely on the GET PARAMETER? Since SPA/GPA are valid across all the user sessions, i think this solution can be dicey.
On the other hand, since you're SUBMIT'ting the program as BG job, you can query the table TBTCP for the field LISTIDENT (which stores the spool id for the BG job step) using JOBNAME & JOBCOUNT.
Let me know your comments.
BR,
Suhas
PS: Since you're SUBMIT'ting only one program in the Job, you can ignore the field STEPCOUNT !
05-26-2011 10:59 AM
May be you r right that i shudnt use Get Parameter,
but i asked my seniors and they said its ok to use Get parameter
I cant create job. Yuo can say its a requirement
05-26-2011 11:06 AM
Hi Suruchi,
Suhas is correct and you won't get the desired result. Also even if you get the spool how will you know which user's spool.Are you giving the spool number in the output or checking SP01. as you have said the userid is shared.
Can you please let us know about this..
Regards,
Nagaraj
05-26-2011 11:19 AM
Actually as soon as the spool is generated i write statement
Get Parameter id SPI.....
whatever the spool number i get, i store it in my Ztable
and later on i can use it...
I dont know any other way...
Can you suggest me any alternative solution?
05-26-2011 11:25 AM
Hi,
that should be 'OK' if you are storing.in ztable.. What is the structre of the ztable?
Regards,
Nagaraj
05-26-2011 11:52 AM
Well it consists of spool numbers for each submit statement plus some job names.
Actually based n my reuirement i hav created it...
Edited by: Suruchi Razdan on May 26, 2011 12:52 PM