06-29-2009 5:32 PM
Hi All,
How to get the variant name for the report program when run in background? My requirement is to create an email attachement with the name 'variant.XLS', where variant = selection screen variant, when the report program is run in background. The system field SY-SLSET holds the variant name only when run online.
Any pointers to this will be highly appreciated.
Thanks and regards,
Nilesh.
06-29-2009 6:53 PM
Hi Jay,
Yes. This is the problem i am facing. Any inputs on this? What is the surity that it will work fine when a job is scheduled in SM36?
Below is the code i am using.
IF syst-slset IS NOT INITIAL.
lv_attachment = syst-slset.
ELSE.
lv_attachment = 'BUFF'.
ENDIF.
lw_objpack-transf_bin = gc_x.
lw_objpack-head_start = 1.
lw_objpack-head_num = 0.
lw_objpack-body_start = 1.
lw_objpack-body_num = lv_lines. "No of lines
lw_objpack-doc_type = 'XLS'.
lw_objpack-doc_size = lv_lines * 255. "Size of file.
lw_objpack-obj_descr = lv_attachment.
lw_objpack-obj_name = sy-uname.
APPEND lw_objpack TO li_objpack.
CLEAR lw_objpack.
Thanks and regards,
Nilesh.
Edited by: Nilesh Masurkar on Jun 29, 2009 7:56 PM
06-29-2009 5:38 PM
06-29-2009 5:41 PM
Hello Nilesh,
Please find the algo:
1. Call the FM: GET_JOB_RUNTIME_INFO to get the background job details.
2. Select data from TBTCP using these details:
DATA:
FP_EVENTID TYPE BTCEVENTID
FP_EVTPARM TYPE BTCEVTPARM
FP_ACTIVE TYPE BTCXPGFLAG
FP_JOBCNT TYPE BTCJOBCNT
FP_JOBNM TYPE BTCJOB
FP_STEPCNT TYPE BTCSTEPCNT.
CALL FUNCTION 'GET_JOB_RUNTIME_INFO'
IMPORTING
EVENTID = FP_EVENTID
EVENTPARM = FP_EVTPARM
EXTERNAL_PROGRAM_ACTIVE = FP_ACTIVE
JOBCOUNT = FP_JOBCNT
JOBNAME = FP_JOBNM
STEPCOUNT = FP_STEPCNT
EXCEPTIONS
NO_RUNTIME_INFO = 1
OTHERS = 2.
IF SY-SUBRC <> 0.
* Error calling FM: GET_JOB_RUNTIME_INFO
ENDIF.
DATA: FP_VARIANT TYPE BTCVARIANT.
SELECT JOBNAME JOBCOUNT STEPCOUNT VARIANT
FROM TBTCP
INTO TABLE L_IT_TBTCP
WHERE JOBNAME = FP_JOBNM
AND JOBCOUNT = FP_JOBCNT
AND STEPCOUNT = FP_STEPCNT.
IF SY-SUBRC = 0.
SORT L_IT_TBTCP BY JOBNM JOBCNT STEPCNT.
READ TABLE L_IT_TBTCP INTO L_WA_TBTCP INDEX 1.
IF SY-SUBRC = 0.
FP_VARIANT = L_WA_TBTCP-VARIANT.
ENDIF.
ENDIF.
Hope this helps.
BR,
Suhas
06-29-2009 5:43 PM
Hi Jay,
Thanks for your reply. When i go and debug the background job, it does not give me the variant name in sy-slset. The attachement generated is also not having the variant name. I am directly passing the variablt sy-slset to a character field and then passing it to the attachement name.
Can you please advise if i am doing this correctly?
Thanks and Regards,
nilesh.
06-29-2009 5:48 PM
Hello,
How did you debug the program?
You have to capture the active job by putting an inifinite loop stmt like this:
DATA:
V_VAR TYPE SYSLSET,
V1 TYPE I,
V2 TYPE I.
V1 = 1.
V2 = 2.
V_VAR = SY-SLSET.
DO.
IF V1 = V2.
EXIT.
ENDIF.
ENDDO.
Capture the active job using JDBG & then check the value in V_VAR.
BR,
Suhas
06-29-2009 6:08 PM
hmm strange...
REPORT zj_test LINE-COUNT 100.
PARAMETERS: p_file TYPE rlgrap-filename.
DATA: lv_string TYPE string,
lv_varname(25) TYPE c.
lv_varname = sy-slset.
CONCATENATE lv_varname '.xls' INTO lv_string.
WRITE: lv_string.
using this code if I say execute in background from selection screen out &*****.xls
but when I got to sm36 and schedule a job its working totally fine... test1.xls
06-29-2009 5:46 PM
Hi All,
The variant name is coming as '&0000000000347'.
Any pointers to this.
Thanks and regards,
Nilesh.
06-29-2009 5:47 PM
06-29-2009 5:59 PM
Hi Suhas,
The requriement is to create an XLS attachement with the same name as the variant. For this i am using the FM SO_NEW_DOCUMENT_ATT_SEND_API1 in the program. Now for creating the attachement i am passing the variable to sy-slset to a character variable and then using this character variable as the attachement name.
When i run the report online, the variable sy-slset shows the variable name correctly. But when i run the report in background, it shows it like '&0000000000347'. I checked the database table TBTCP for this and it also does not hold the variant name.
I hope it is clear now.
Please advise if any inputs.
Thanks and regards,
Nilesh.
06-29-2009 6:53 PM
Hi Jay,
Yes. This is the problem i am facing. Any inputs on this? What is the surity that it will work fine when a job is scheduled in SM36?
Below is the code i am using.
IF syst-slset IS NOT INITIAL.
lv_attachment = syst-slset.
ELSE.
lv_attachment = 'BUFF'.
ENDIF.
lw_objpack-transf_bin = gc_x.
lw_objpack-head_start = 1.
lw_objpack-head_num = 0.
lw_objpack-body_start = 1.
lw_objpack-body_num = lv_lines. "No of lines
lw_objpack-doc_type = 'XLS'.
lw_objpack-doc_size = lv_lines * 255. "Size of file.
lw_objpack-obj_descr = lv_attachment.
lw_objpack-obj_name = sy-uname.
APPEND lw_objpack TO li_objpack.
CLEAR lw_objpack.
Thanks and regards,
Nilesh.
Edited by: Nilesh Masurkar on Jun 29, 2009 7:56 PM
06-29-2009 7:03 PM
if you are surely scheduling a job using sm36 it will work...there is not doubt in it. But still to be in a safer side... when u find a & in the name then use some meaning full, name and replace that with the &*** value.
if lv_varname CA '& '.
lv_varname = sy-repid.
endif.
01-06-2024 2:42 AM
Hi ,
Save the variant only for background processing and try again. This will show your selected variant in sy-slset.
Thanks
Vasanth Panneerselvam
01-06-2024 1:14 PM
The problem of the OP in 2009 was different. SY-SLSET always contains the variant name (even if you don't define the variant for background processing), the actual OP issue was "when i run the report in background, it shows it like '&0000000000347'", and "if I say execute in background from selection screen out &*****.xls but when I got to sm36 and schedule a job its working totally fine... test1.xls", so the correct answer is to say that it's normal and to explain why it's normal (I won't answer because it's a very old question).