‎2006 Sep 21 1:52 PM
Hi,
I am woking with CC02 transaction and in the user-exit i need to run a zreport in the background and need to pass a parameter to that, what is the best way to do it.
thanks& Regards.
Syed
‎2006 Sep 21 1:55 PM
Hi ,
You can export the value to database INDX and import in the program.
Ex:
TABLES INDX.
TYPES: BEGIN OF ITAB3_TYPE,
CONT(4),
END OF ITAB3_TYPE.
DATA: INDXKEY LIKE INDX-SRTFD VALUE 'KEYVALUE',
F1(4), F2 TYPE P,
ITAB3 TYPE STANDARD TABLE OF ITAB3_TYPE WITH NON-
UNIQUE DEFAULT KEY INITIAL SIZE 2,
WA_INDX TYPE INDX.
Fill the data fields before CLUSTR
before the actual export
INDX-AEDAT = SY-DATUM.
INDX-USERA = SY-UNAME.
Export der Daten.
EXPORT F1 FROM F1
F2 FROM F2
ITAB3 FROM ITAB3
TO DATABASE INDX(ST) FROM WA_INDX ID INDXKEY.
Hope this helps.
Message was edited by: Imtiaz Ahmed
‎2006 Sep 21 1:55 PM
Hi ,
You can export the value to database INDX and import in the program.
Ex:
TABLES INDX.
TYPES: BEGIN OF ITAB3_TYPE,
CONT(4),
END OF ITAB3_TYPE.
DATA: INDXKEY LIKE INDX-SRTFD VALUE 'KEYVALUE',
F1(4), F2 TYPE P,
ITAB3 TYPE STANDARD TABLE OF ITAB3_TYPE WITH NON-
UNIQUE DEFAULT KEY INITIAL SIZE 2,
WA_INDX TYPE INDX.
Fill the data fields before CLUSTR
before the actual export
INDX-AEDAT = SY-DATUM.
INDX-USERA = SY-UNAME.
Export der Daten.
EXPORT F1 FROM F1
F2 FROM F2
ITAB3 FROM ITAB3
TO DATABASE INDX(ST) FROM WA_INDX ID INDXKEY.
Hope this helps.
Message was edited by: Imtiaz Ahmed
‎2006 Sep 21 1:56 PM
Syed,
See the below code for submiting report in background.
*Submit report as job(i.e. in background)
data: jobname like tbtcjob-jobname value
' TRANSFER TRANSLATION'.
data: jobcount like tbtcjob-jobcount,
host like msxxlist-host.
data: begin of starttime.
include structure tbtcstrt.
data: end of starttime.
data: starttimeimmediate like btch0000-char1.
* Job open
call function 'JOB_OPEN'
exporting
delanfrep = ' '
jobgroup = ' '
jobname = jobname
sdlstrtdt = sy-datum
sdlstrttm = sy-uzeit
importing
jobcount = jobcount
exceptions
cant_create_job = 01
invalid_job_data = 02
jobname_missing = 03.
if sy-subrc ne 0.
"error processing
endif.
* Insert process into job
SUBMIT zreport and return
with p_param1 = 'value'
with p_param2 = 'value'
user sy-uname
via job jobname
number jobcount.
if sy-subrc > 0.
"error processing
endif.
* Close job
starttime-sdlstrtdt = sy-datum + 1.
starttime-sdlstrttm = '220000'.
call function 'JOB_CLOSE'
exporting
event_id = starttime-eventid
event_param = starttime-eventparm
event_periodic = starttime-periodic
jobcount = jobcount
jobname = jobname
laststrtdt = starttime-laststrtdt
laststrttm = starttime-laststrttm
prddays = 1
prdhours = 0
prdmins = 0
prdmonths = 0
prdweeks = 0
sdlstrtdt = starttime-sdlstrtdt
sdlstrttm = starttime-sdlstrttm
strtimmed = starttimeimmediate
targetsystem = host
exceptions
cant_start_immediate = 01
invalid_startdate = 02
jobname_missing = 03
job_close_failed = 04
job_nosteps = 05
job_notex = 06
lock_failed = 07
others = 99.
if sy-subrc eq 0.
"error processing
endif.
I have a report which sents emails in background(http://www.sap-img.com/abap/sending-mail-with-attachment-report-in-background.htm).
I believe similar way you could <b>SUBMIT</b> a report in background from your user exit.
Hope this helps you.
~thomas.
‎2006 Sep 21 1:58 PM
you can pass to the selection screen parameters and select-options as well.
loop at itab.
r_matnr-low = itab-matnr.
append r_matnr.
clear r_matnr.
endloop.
submit zrept with s_matnr in r_matnr.
Regards,
Ravi
‎2006 Sep 21 2:05 PM
Hi,
Yes you could do it the way mentioned in above post or else You could create a event periodic job in SM36 and raise the event from user exit using the Function module <b>BP_EVENT_RAISE</b>. This will trigger the job with your program, you can import the parameter exported from user exit in your program.
Hope this helps.
‎2006 Sep 21 3:25 PM
Hi,
If i have to call a transaction in the user-exit and run that in the background.
Thanks& Regards
Syed
‎2006 Sep 21 3:28 PM
Hi,
If it is a report transaction then you can capture the report name from Se93 and do it the same way as mentioned in previous posts. But i'm afraid you will not be able to execute a transaction in background.
Hope this helps.