Job id to session id
RW_SERVER_QUEUE has job id as a column. How would I go about determining the database session that's running that job?
? to use
CREATE OR REPLACE PROCEDURE ASIDENTL(
P_NAME VARCHAR2 ,
P_ACTION VARCHAR2 )
IS
-- @(#) klema 99/06/22 init
/* Hint
/rdbms/rdbms/admin/dbmsutil.sql
REQUIRED
as sys
grant select on sys.v_$session to public;
kot <user>
begin
sys.dbms_application_info.set_module( P_NAME, P_ACTION);
end asidentl;
create or replace
function asisrunl(
P_NAME in varchar2
, P_ACTION in varchar2 := null
) return number is
-- @(#) 14/09/99 KlemA add opti P_ACTION
-- @(#) 7/28/99 KlemA
lErr number;
begin
select count(*) into lErr
from sys.v_$session
where module = P_NAME
and AUDSID <> userenv('SESSIONID')
and nvl( action, '!2') = nvl( P_ACTION, nvl( action, '!2'))
return( lErr);
exception when no_data_found then
return( 0);
end asisrunl;
show err
in pl/sql -code or C/OCI/PRO-C
example:
proc a()
is
asidentl( 'RunProc', to_char( P_ID));
end;
chk whith
select module, action from sys.v_$session;
null
Similar Messages
-
Running Chain Job in Restricted Session
I have my normal jobs running is Restricted Session
DBMS_SCHEDULER.SET_ATTRIBUTE('job_name', 'ALLOW_RUNS_IN_RESTRICTED_MODE', TRUE);
I did the same for my chain job. The chain job starts but the first step doesn't start until out of restricted session.
I get this if I try to set_attribute on a program
ORA-27469: ALLOW_RUNS_IN_RESTRICTED_MODE is not a valid program attribute
ORA-06512: at "SYS.DBMS_ISCHED", line 4436
ORA-06512: at "SYS.DBMS_SCHEDULER", line 2925
Is there some way to run the steps of a chain in restricted session?
11gR2Greg Here is an example I created for you. It is very close to what I am doing and I was able to duplicate the problem with it.
-- replace sch_util.send_mail() with your own PL SQL code.
DECLARE
v_job_name VARCHAR2(32) := 'example_job';
v_chain_name VARCHAR2(32) := 'example_chain';
BEGIN
--drop chain and job
BEGIN
DBMS_SCHEDULER.DROP_CHAIN(v_chain_name,TRUE);
EXCEPTION WHEN OTHERS THEN
DBMS_OUTPUT.PUT_LINE('Error DROP_CHAIN ' || v_chain_name);
END;
BEGIN
DBMS_SCHEDULER.DROP_JOB(v_job_name, TRUE);
EXCEPTION WHEN OTHERS THEN
DBMS_OUTPUT.PUT_LINE('Error DROP_JOB ' || v_job_name);
END;
--create all the programs for chain
DECLARE
v_pl_sql VARCHAR2(4000) := 'BEGIN sch_util.send_email(''example chain step 1'', ''Hellow world 1''); END;';
v_prog_name VARCHAR2(32) := 'example_1_prog';
BEGIN
--drop program
BEGIN
DBMS_SCHEDULER.DROP_PROGRAM(v_prog_name);
EXCEPTION WHEN OTHERS THEN
DBMS_OUTPUT.PUT_LINE('Error DROP_PROGRAM ' || v_prog_name);
END;
--create program
DBMS_SCHEDULER.CREATE_PROGRAM (
program_name => v_prog_name,
program_action => v_pl_sql,
program_type => 'PLSQL_BLOCK',
enabled => TRUE,
number_of_arguments => 0,
comments => 'example chain step 1');
DBMS_SCHEDULER.SET_ATTRIBUTE (
name => v_prog_name,
attribute => 'max_run_duration',
value => interval '240' minute );
END;
DECLARE
v_pl_sql VARCHAR2(4000) := 'BEGIN sch_util.send_email(''example chain step 2'', ''Hello world 2''); END;';
v_prog_name VARCHAR2(32) := 'example_2_prog';
BEGIN
--drop program
BEGIN
DBMS_SCHEDULER.DROP_PROGRAM(v_prog_name);
EXCEPTION WHEN OTHERS THEN
DBMS_OUTPUT.PUT_LINE('Error DROP_PROGRAM ' || v_prog_name);
END;
--create program
DBMS_SCHEDULER.CREATE_PROGRAM (
program_name => v_prog_name,
program_action => v_pl_sql,
program_type => 'PLSQL_BLOCK',
enabled => TRUE,
number_of_arguments => 0,
comments => 'example chain step 1');
DBMS_SCHEDULER.SET_ATTRIBUTE (
name => v_prog_name,
attribute => 'max_run_duration',
value => interval '240' minute );
END;
-----------------------------Start Chain Definition -----------------------------------
DBMS_SCHEDULER.CREATE_CHAIN (
chain_name => v_chain_name,
comments => 'Example chain!');
--- define steps for this chain.
DBMS_SCHEDULER.DEFINE_CHAIN_STEP(v_chain_name, 'example_step1', 'example_1_prog');
DBMS_SCHEDULER.DEFINE_CHAIN_STEP(v_chain_name, 'example_step2', 'example_2_prog');
-- define corresponding rules for the chain.
DBMS_SCHEDULER.DEFINE_CHAIN_RULE(v_chain_name, 'TRUE', 'START example_step1');
DBMS_SCHEDULER.DEFINE_CHAIN_RULE(v_chain_name, 'example_step1 SUCCEEDED', 'START example_step2');
DBMS_SCHEDULER.DEFINE_CHAIN_RULE(v_chain_name, 'example_step2 COMPLETED', 'END');
-- enable the chain
DBMS_SCHEDULER.ENABLE(v_chain_name);
--- create a chain job to start the chain
DBMS_SCHEDULER.CREATE_JOB (
job_name => v_job_name,
job_type => 'CHAIN',
job_action => v_chain_name,
start_date => '6-AUG-2014 9.35.00 AM AMERICA/CHICAGO',
enabled => FALSE);
DBMS_SCHEDULER.SET_ATTRIBUTE(v_job_name , 'max_run_duration' , interval '4' hour);
DBMS_SCHEDULER.SET_ATTRIBUTE(v_job_name, 'raise_events',DBMS_SCHEDULER.JOB_FAILED);
DBMS_SCHEDULER.SET_ATTRIBUTE(v_job_name, 'ALLOW_RUNS_IN_RESTRICTED_MODE', TRUE);
DBMS_SCHEDULER.ENABLE(v_job_name);
END; -
How to run a job in 1 session only?
Hi,
although I searched the forum and found some proposals close to my issue, I would like to ask just in case to be sure I have correct answer:
[Q] I have a program (with attached transaction code) which usualy runs as a task in background job, but may be started in foreground also. What I need is to prevent possiblity to start it in two paralel sessions (as per server context, not per frontend).
Is it possible and what is the proper way to do that?
Many thanks in advance.
Regards,
Ivaylo MutafchievYes, I believe that this is achieved by placing a lock on the program name during execution. Here is a sample.
report zrich_0001 .
call function 'ENQUEUE_E_TRDIR'
exporting
* MODE_TRDIR = 'X'
name = sy-repid
* X_NAME = ' '
* _SCOPE = '2'
* _WAIT = ' '
* _COLLECT = ' '
* EXCEPTIONS
* FOREIGN_LOCK = 1
* SYSTEM_FAILURE = 2
* OTHERS = 3
if sy-subrc <> 0.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
* WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
endif.
check sy-subrc = 0.
Regards,
Rich Heilman -
Any difference btw session & job logs
Hi All,
Happy new year wishes to all.
I have requirement to update the work order confirmations from the custom table details. It would be scheduled job which runs everynight. I will develop a report for above requirement.
Initially thought to use session method (BDC) and to execute session immediately using program RSBDCSUB in the report ( which would be scheduled as background job).
But I have found a standard BAPI which satisfies the requirement. Now I will run the report as background job
directly with session method ( As I am using BAPI ).
My end user is particular on having a detailed log ( similar to session log ).
Is that detailed log can be obtained from background job? If not, let me know how we can achieve the same.
Let me know if I am not clear... or need any clarifications.
Thanks in advance.
From
Reddy.HI,
Do the recording for the Tcode for which you are uploading the data and write the BDC code using
FM BDC_OPEN BDC_INSERT & BDC_CLOSE.
My suggestion would be you can use the CALL TRANSACTION to upload the and create the BDC SESSION for the error records and even you can right the error records with the error messages to the list/ Download to application server.
For ref check the program
*& Report ZPPUUT01_INFTY0050
REPORT zppuut01_infty0050 MESSAGE-ID pn NO STANDARD PAGE HEADING
LINE-SIZE 132
LINE-COUNT 65.
*eject
* includes
* tables
* infotypes
* types
TYPES: BEGIN OF t_input, "Input File
pernr TYPE p0001-pernr, "SAP ID/Personnel Number
pnalt TYPE p0032-pnalt, "Employee Number
begda TYPE p0050-begda, "Start Date
endda TYPE p0050-endda, "End Date
zausw TYPE dzausw, "Time recording ID number
END OF t_input,
BEGIN OF t_error. "Error/Output table
INCLUDE TYPE t_input.
TYPES: errmsg(100) TYPE c, "Reason for rejection Error Message
END OF t_error.
*Batch input: New table field structure
TYPES: BEGIN OF t_bdc_data .
INCLUDE STRUCTURE bdcdata.
TYPES: END OF t_bdc_data.
*To collect error messages in the SAP System
TYPES: BEGIN OF t_msg_tab .
INCLUDE STRUCTURE bdcmsgcoll.
TYPES: END OF t_msg_tab.
* internal tables
DATA: i_input TYPE STANDARD TABLE OF t_input,
e_error TYPE STANDARD TABLE OF t_error,
i_bdc_data TYPE STANDARD TABLE OF t_bdc_data,
i_msg_tab TYPE STANDARD TABLE OF t_msg_tab.
* work areas
DATA: i_input_line LIKE LINE OF i_input,
e_error_line LIKE LINE OF e_error,
i_bdc_data_line LIKE LINE OF i_bdc_data,
i_msg_tab_line LIKE LINE OF i_msg_tab.
* field symbols
* internal data fields
DATA: g_success_cnt TYPE i, "Number of success records
g_error_cnt TYPE i, "Number of error records
g_bdc_cnt TYPE i. "Count of bdc records
DATA: g_start_date TYPE sy-datum, "Program run date
g_start_time TYPE sy-uzeit. "Program run time
DATA: g_pernr TYPE p0001-pernr. "Personnel Number
CONSTANTS: c_y TYPE c VALUE 'Y',
c_n TYPE c VALUE 'N',
c_e TYPE c VALUE 'E',
c_a TYPE c VALUE 'A',
c_x TYPE c VALUE 'X',
c_bdcnam TYPE apqi-groupid VALUE sy-repid,
c_pa30 TYPE tstc-tcode VALUE 'PA30'.
* Parameters and Selection Options
SELECTION-SCREEN BEGIN OF BLOCK b1 WITH FRAME TITLE text-s01.
SELECTION-SCREEN BEGIN OF BLOCK b2 WITH FRAME TITLE text-s02.
SELECTION-SCREEN BEGIN OF LINE.
SELECTION-SCREEN COMMENT 1(33) text-s04.
PARAMETERS: p_floc TYPE pp0c-test DEFAULT c_x. "Input File location
SELECTION-SCREEN COMMENT 38(15) text-s05.
SELECTION-SCREEN END OF LINE.
SELECTION-SCREEN BEGIN OF LINE.
SELECTION-SCREEN COMMENT 1(33) text-s06.
PARAMETERS: p_ifile TYPE rlgrap-filename OBLIGATORY. "Input file name
SELECTION-SCREEN END OF LINE.
SELECTION-SCREEN BEGIN OF LINE.
SELECTION-SCREEN COMMENT 1(33) text-s07.
PARAMETERS: p_efloc TYPE pp0c-test DEFAULT c_x. "Error File location
SELECTION-SCREEN COMMENT 38(15) text-s05.
SELECTION-SCREEN END OF LINE.
SELECTION-SCREEN BEGIN OF LINE.
SELECTION-SCREEN COMMENT 1(33) text-s08.
PARAMETERS: p_efile TYPE rlgrap-filename OBLIGATORY. "Error file name
SELECTION-SCREEN END OF LINE.
SELECTION-SCREEN END OF BLOCK b2.
SELECTION-SCREEN BEGIN OF BLOCK b3 WITH FRAME TITLE text-s09.
PARAMETERS: p_test TYPE c DEFAULT c_y, "Test run
p_ctran TYPE c DEFAULT c_y, "Call Transaction / BDC
p_mode TYPE c DEFAULT c_n NO-DISPLAY.
SELECTION-SCREEN END OF BLOCK b3.
SELECTION-SCREEN END OF BLOCK b1.
*eject
* Initialization
INITIALIZATION.
* Security check
AUTHORITY-CHECK OBJECT 'S_TCODE' ID 'TCD' FIELD 'ZPPUTU0050'.
IF sy-subrc > 0.
MESSAGE e172(pg) WITH 'ZPPUTU0050'.
ENDIF.
g_start_date = sy-datum.
g_start_time = sy-uzeit.
* The dataset name is defaulted here, but the variant can change this
CONCATENATE '/nfsdata3/' sy-sysid '/90373/' sy-repid+0(8) '.'
'INPUT' INTO p_ifile.
CONCATENATE '/nfsdata3/' sy-sysid '/90373/' sy-repid+0(8) '.'
'ERROR' INTO p_efile.
*eject
* at selection screen
AT SELECTION-SCREEN.
AT SELECTION-SCREEN ON VALUE-REQUEST FOR p_ifile.
PERFORM get_filename_on_f4 USING p_ifile.
* IF p_ifile IS NOT INITIAL.
* MOVE p_ifile TO p_efile.
* REPLACE '.txt' IN p_efile WITH space.
* CONDENSE p_efile.
* WRITE sy-uzeit TO g_time_stamp.
* CONCATENATE p_efile 'log' sy-datum sy-uzeit INTO p_efile
* SEPARATED BY '_'.
* CONCATENATE p_efile '.txt' INTO p_efile.
* CALL SCREEN 1000.
* ENDIF.
AT SELECTION-SCREEN ON VALUE-REQUEST FOR p_efile.
PERFORM get_filename_on_f4 USING p_efile.
*eject
* Event top of page
TOP-OF-PAGE.
* To print header data
PERFORM print_hdrs.
*eject
* event Start of Selection
START-OF-SELECTION.
* Fetch file data into internal table
PERFORM get_filedata TABLES i_input USING p_ifile.
* Process file data
PERFORM process_data.
*eject
*EVENT End-of selection
END-OF-SELECTION.
* Close BDC session if it is opened
IF g_bdc_cnt GE 1.
PERFORM close_group.
ENDIF.
* Write error file
PERFORM write_file TABLES e_error USING p_efile.
* Program run statistics
PERFORM eoj_notes.
*eject
*EVENT End-of page
END-OF-PAGE.
*eject
** forms
*& Form get_filename_on_f4
* To display help for selection of file
* -->P_FILENAME File name
FORM get_filename_on_f4 USING p_filename TYPE rlgrap-filename.
CALL FUNCTION 'KD_GET_FILENAME_ON_F4'
EXPORTING
static = ' '
CHANGING
file_name = p_filename
EXCEPTIONS
mask_too_long = 1
OTHERS = 2.
IF sy-subrc <> 0.
MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ENDIF.
ENDFORM. " get_filename_on_f4
*& Form print_hdrs
* To print header data
FORM print_hdrs.
CALL FUNCTION 'Z_SSV_REPORT_HEADER_FUNCTION'
EXPORTING
text1 = sy-title.
WRITE : sy-uline.
SKIP.
ENDFORM. " print_hdrs
*& Form get_filedata
* To fetch file data into internal table
* -->P_INPUT Internal table to store the file data
* -->P_IFILE File name
FORM get_filedata TABLES p_input
USING p_ifile TYPE rlgrap-filename.
IF p_floc EQ 'X'. "File from SAP server
DATA l_return TYPE bapireturn1.
CALL FUNCTION 'Z_READ_DATASET'
EXPORTING
filename = p_ifile
IMPORTING
return = l_return
TABLES
datatab = p_input
EXCEPTIONS
open_dataset_failed = 1
auth_failed = 2
close_dataset_failed = 3
OTHERS = 4.
IF sy-subrc <> 0.
MESSAGE e016(pn) WITH l_return-message_v1 l_return-message_v2
l_return-message_v3 l_return-message_v4.
ELSE.
MESSAGE s016(pn) WITH l_return-message_v1 l_return-message_v2
l_return-message_v3 l_return-message_v4.
ENDIF.
ELSE. "File from Windows
DATA l_filename TYPE string.
MOVE p_ifile TO l_filename.
CALL FUNCTION 'GUI_UPLOAD'
EXPORTING
filename = l_filename
filetype = 'ASC'
has_field_separator = c_x
TABLES
data_tab = p_input
EXCEPTIONS
file_open_error = 1
file_read_error = 2
no_batch = 3
gui_refuse_filetransfer = 4
invalid_type = 5
no_authority = 6
unknown_error = 7
bad_data_format = 8
header_not_allowed = 9
separator_not_allowed = 10
header_too_long = 11
unknown_dp_error = 12
access_denied = 13
dp_out_of_memory = 14
disk_full = 15
dp_timeout = 16
OTHERS = 17.
IF sy-subrc <> 0.
MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ENDIF.
ENDIF.
ENDFORM. " get_filedata
*& Form process_data
* To process the file data
FORM process_data.
LOOP AT i_input INTO i_input_line.
IF i_input_line-pernr IS INITIAL AND
i_input_line-pnalt IS INITIAL.
MOVE 'No value found in SAP ID or Employee number field'(e01)
TO e_error_line-errmsg.
PERFORM append_error_rec.
CONTINUE.
ENDIF.
CLEAR: g_pernr.
IF i_input_line-pnalt IS NOT INITIAL.
PERFORM get_0032_pernr.
IF g_pernr IS INITIAL.
IF i_input_line-pernr IS NOT INITIAL.
MOVE i_input_line-pernr TO g_pernr.
ELSE.
MOVE 'Employee number does not exist'(e02)
TO e_error_line-errmsg.
PERFORM append_error_rec.
CONTINUE.
ENDIF.
ENDIF.
ELSE.
MOVE i_input_line-pernr TO g_pernr.
ENDIF.
PERFORM create_0050_record USING '=INS'.
** Initialize HR buffer
* CALL FUNCTION 'HR_INITIALIZE_BUFFER'
* EXPORTING
* pernr = g_pernr.
ENDLOOP.
ENDFORM. " process_data
*& Form GET_0032_PERNR
* Get PERNR from employee number in IT0032
FORM get_0032_pernr.
SELECT SINGLE pernr FROM pa0032
INTO g_pernr
WHERE pnalt EQ i_input_line-pnalt. "#EC *
* endda GE sy-datum.
IF sy-subrc NE 0.
MOVE 'Employee number does not exist'(e02) TO e_error_line-errmsg.
PERFORM append_error_rec.
ENDIF.
ENDFORM. " GET_0032_PERNR
*& Form create_0050_record
* To create IT0050 records
* --> P_MODE '=MOD' or "=INS"
FORM create_0050_record USING p_mode TYPE any.
* Build infotype data for BDC session
PERFORM build_bdc_infotype USING p_mode.
IF p_ctran = c_y.
* Build Call Transaction
PERFORM build_call_transaction.
ELSE.
* Build BDC session.
PERFORM build_bdc_session.
ENDIF.
ENDFORM. " create_0050_record
*& Form build_bdc_infotype
* To build the infotype data
* --> P_MODE '=MOD' or "=INS"
FORM build_bdc_infotype USING p_mode TYPE any.
DATA: l_begda TYPE char10,
l_endda TYPE char10.
REFRESH i_bdc_data.
PERFORM bdc_dynpro USING 'SAPMP50A' '1000'.
WRITE i_input_line-begda TO l_begda.
WRITE i_input_line-endda TO l_endda.
PERFORM bdc_field USING:'RP50G-PERNR' g_pernr,
'RP50G-CHOIC' '0050',
'RP50G-BEGDA' l_begda,
'RP50G-ENDDA' l_endda,
'BDC_OKCODE' p_mode.
PERFORM bdc_dynpro USING 'MP005000' '2000'.
PERFORM bdc_field USING:'P0050-ZAUSW' i_input_line-zausw.
PERFORM bdc_field USING:'P0050-PMBDE' '40'.
PERFORM bdc_field USING:'P0050-BDEGR' '001'.
PERFORM bdc_field USING:'P0050-GRAWG' '001'.
PERFORM bdc_field USING:'P0050-GRELG' '001'.
PERFORM bdc_field USING:'BDC_OKCODE' '/00'.
IF p_test EQ c_y.
PERFORM bdc_dynpro USING 'MP005000' '2000'.
PERFORM bdc_field USING 'BDC_OKCODE' '/EBCK'.
PERFORM bdc_dynpro USING 'SAPLSPO1' '0200'.
PERFORM bdc_field USING 'BDC_OKCODE' '=YES'.
ELSE.
PERFORM bdc_dynpro USING 'MP005000' '2000'.
PERFORM bdc_field USING 'BDC_OKCODE' '=UPD'.
ENDIF.
PERFORM bdc_dynpro USING 'SAPMP50A' '1000'.
PERFORM bdc_field USING 'BDC_OKCODE' '=BACK'.
ENDFORM. " build_bdc_infotype
*& Form bdc_dynpro
* To build bdc data(Program name and screen number)
FORM bdc_dynpro USING p_program TYPE any
p_dynpro TYPE any.
i_bdc_data_line-program = p_program.
i_bdc_data_line-dynpro = p_dynpro.
i_bdc_data_line-dynbegin = c_x.
APPEND i_bdc_data_line TO i_bdc_data.
CLEAR i_bdc_data_line.
ENDFORM. " bdc_dynpro
*& Form bdc_field
* To build bdc data(Field name and BDC field value)
* -->P_FNAM Field name
* -->P_FVAL BDC field value
FORM bdc_field USING p_fnam TYPE any
p_fval TYPE any.
i_bdc_data_line-fnam = p_fnam.
i_bdc_data_line-fval = p_fval.
APPEND i_bdc_data_line TO i_bdc_data.
CLEAR i_bdc_data_line.
ENDFORM. " bdc_field
*& Form build_bdc_session
* To build BDC session
FORM build_bdc_session.
* Add BDC error count
ADD 1 TO g_bdc_cnt.
IF g_bdc_cnt EQ 1.
PERFORM open_group.
ENDIF.
CALL FUNCTION 'BDC_INSERT'
EXPORTING
tcode = c_pa30
TABLES
dynprotab = i_bdc_data.
ENDFORM. " build_bdc_session
*& Form open_group
* To Open batch input session for adding transactions
FORM open_group.
CALL FUNCTION 'BDC_OPEN_GROUP'
EXPORTING
client = sy-mandt
group = c_bdcnam
user = sy-uname
keep = c_x.
ENDFORM. " open_group
*& Form close_group
* To Close batch input session
FORM close_group.
CALL FUNCTION 'BDC_CLOSE_GROUP'.
ENDFORM. " close_group
*& Form build_call_transaction
* To call the transaction PP02
* -->P_PERNR Personnel Number
FORM build_call_transaction.
DATA: l_errormsg TYPE t_error-errmsg. "Error Message
REFRESH i_msg_tab.
CALL TRANSACTION c_pa30 USING i_bdc_data MODE p_mode
MESSAGES INTO i_msg_tab.
IF sy-subrc NE 0.
* Process as error if message type is E or A. if it is type S, it is
* only an error if it is 347, 348, 344"No batch input data for screen
LOOP AT i_msg_tab INTO i_msg_tab_line
WHERE msgtyp = c_e OR msgtyp = c_a
OR ( msgtyp = 'S' AND msgid = '00' AND msgnr = '347' )
OR ( msgtyp = 'S' AND msgid = '00' AND msgnr = '348' )
OR ( msgtyp = 'S' AND msgid = '00' AND msgnr = '344' ).
CALL FUNCTION 'MASS_MESSAGE_GET'
EXPORTING
sprsl = sy-langu
arbgb = i_msg_tab_line-msgid
msgnr = i_msg_tab_line-msgnr
msgv1 = i_msg_tab_line-msgv1
msgv2 = i_msg_tab_line-msgv2
msgv3 = i_msg_tab_line-msgv3
msgv4 = i_msg_tab_line-msgv4
IMPORTING
msgtext = l_errormsg
EXCEPTIONS
message_not_found = 1
OTHERS = 2.
IF sy-subrc <> 0. "#EC NEEDED
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
* WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
MOVE l_errormsg TO e_error_line-errmsg.
PERFORM append_error_rec.
PERFORM build_bdc_session.
EXIT.
ENDLOOP.
ELSE.
ADD 1 TO g_success_cnt.
ENDIF.
ENDFORM. " build_call_transaction
*& Form append_error_rec
* Append error record to error internal table
FORM append_error_rec.
MOVE-CORRESPONDING i_input_line TO e_error_line.
APPEND e_error_line TO e_error.
ADD 1 TO g_error_cnt.
ENDFORM. " append_error_rec
*& Form eoj_notes
* Write the End of Job Notes
FORM eoj_notes.
DATA: l_cnt_str TYPE string,
l_transac_cnt TYPE i.
CONSTANTS: lc_colon(2) VALUE ': '.
WRITE:/2'Start of Job'(h01), 57 lc_colon, 60 g_start_date,
g_start_time.
SKIP.
* According to test run / update run, heading changes
IF p_test = c_y.
WRITE: /8 'This is test run.'(h02).
ELSE.
WRITE: /8 'This is update run.'(h03).
ENDIF.
SKIP.
DESCRIBE TABLE i_input LINES l_transac_cnt.
CLEAR l_cnt_str.
MOVE l_transac_cnt TO l_cnt_str.
CONDENSE l_cnt_str NO-GAPS.
WRITE:/2'Number of input records'(h05),
57 lc_colon, 60 l_cnt_str.
CLEAR l_transac_cnt.
CLEAR l_cnt_str.
MOVE g_success_cnt TO l_cnt_str.
CONDENSE l_cnt_str NO-GAPS.
WRITE:/2'Number of success records'(h06), 57 lc_colon, 60 l_cnt_str.
CLEAR l_cnt_str.
MOVE g_error_cnt TO l_cnt_str.
CONDENSE l_cnt_str NO-GAPS.
WRITE:/2'Number of error records'(h07), 57 lc_colon, 60 l_cnt_str.
* If Call transaction is used then display number of call transaction
* attempted and call transaction with errors
IF p_ctran EQ c_y.
l_transac_cnt = g_bdc_cnt + g_success_cnt.
CLEAR l_cnt_str.
MOVE l_transac_cnt TO l_cnt_str.
CONDENSE l_cnt_str NO-GAPS.
WRITE:/2 'Total Call transaction attempted'(h08), 57 lc_colon,
60 l_cnt_str.
CLEAR l_cnt_str.
MOVE g_bdc_cnt TO l_cnt_str.
CONDENSE l_cnt_str NO-GAPS.
WRITE:/2 'Total Call transaction with errors'(h09), 57 lc_colon,
60 l_cnt_str.
ENDIF.
* If there is any error occured during call transaction then display
* number of BDC session created and name of the BDC session
* If BDC session is used then display number of BDC session records
* and name of the BDC session
IF g_bdc_cnt GT 0.
CLEAR l_cnt_str.
MOVE g_bdc_cnt TO l_cnt_str.
CONDENSE l_cnt_str NO-GAPS.
WRITE:/2 'Total no of BDC session records'(h10), 57 lc_colon,
60 l_cnt_str.
SKIP.
WRITE:/2 'BDC session name'(h11), c_bdcnam,
'is created for errors.'(h12).
WRITE:/2
'Please process the BDC session through SM35 transaction.'(h13).
ENDIF.
SKIP.
GET TIME.
WRITE:/2 'End of Job'(h14), 57 lc_colon, 60 sy-datum, sy-uzeit.
SKIP.
ULINE.
IF e_error[] IS NOT INITIAL.
NEW-PAGE.
WRITE:/2 'Error Records:'(h04),
/2 '=============='.
WRITE:/2 'SAPID'(h15), 12 'Employee Number'(h16),
29 'Start Date'(h17), 41 'End Date'(h18),
53 'Time recording ID number'(h19),
79 'Error Message'(h20).
ULINE.
LOOP AT e_error INTO e_error_line.
WRITE: /2 e_error_line-pernr, 12 e_error_line-pnalt,
29 e_error_line-begda, 41 e_error_line-endda,
53 e_error_line-zausw, 79 e_error_line-errmsg.
ENDLOOP.
ULINE.
ENDIF.
IF g_error_cnt EQ 0.
MESSAGE s016(pn) WITH
'Records successfully processed without any errors.'(e03).
ELSE.
MESSAGE s016(pn) WITH
'Records processed with errors.'(e04)
' Please refer the log file.'(e05).
ENDIF.
ENDFORM. " eoj_notes
*& Form write_file
* To write output/error file
* --> P_INPUT Input internal table
* --> P_FILE File Name
FORM write_file TABLES p_input USING p_file TYPE any.
IF p_efloc EQ 'X'. "File from SAP server
DATA l_return TYPE bapireturn1.
CALL FUNCTION 'Z_WRITE_TO_DATASET'
EXPORTING
filename = p_file
IMPORTING
return = l_return
TABLES
datatab = p_input
EXCEPTIONS
open_dataset_failed = 1
write_error = 2
auth_failed = 3
close_dataset_failed = 4
OTHERS = 5.
IF sy-subrc <> 0.
MESSAGE e016(pn) WITH l_return-message_v1 l_return-message_v2
l_return-message_v3 l_return-message_v4.
ELSE.
MESSAGE s016(pn) WITH l_return-message_v1 l_return-message_v2
l_return-message_v3 l_return-message_v4.
ENDIF.
ELSE. "File from Windows
DATA l_filename TYPE string.
MOVE p_file TO l_filename.
CALL FUNCTION 'GUI_DOWNLOAD'
EXPORTING
* BIN_FILESIZE =
filename = l_filename
filetype = 'ASC'
write_field_separator = c_x
TABLES
data_tab = p_input
EXCEPTIONS
file_write_error = 1
no_batch = 2
gui_refuse_filetransfer = 3
invalid_type = 4
no_authority = 5
unknown_error = 6
header_not_allowed = 7
separator_not_allowed = 8
filesize_not_allowed = 9
header_too_long = 10
dp_error_create = 11
dp_error_send = 12
dp_error_write = 13
unknown_dp_error = 14
access_denied = 15
dp_out_of_memory = 16
disk_full = 17
dp_timeout = 18
file_not_found = 19
dataprovider_exception = 20
control_flush_error = 21
OTHERS = 22.
IF sy-subrc <> 0.
MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ENDIF.
ENDIF.
ENDFORM. " write_file -
DBMS_DATAPUMP; how to get the log file of a job?
Hi
I want the user to be able to see the logfile of his job from another session.
this is my procedure
create or replace procedure get_job_log (p_job_name IN varchar2 )
is
hdl_job number;
l_job_state VARCHAR2 (20);
l_status sys.ku$_Status1010;
l_job_status sys.ku$_JobStatus1010;
l_job_logentry sys.ku$_LogEntry1010;
l_job_logline sys.ku$_LogLine1010;
begin
hdl_job := DBMS_DATAPUMP.ATTACH(
job_name => p_job_name
,job_owner => 'CLONE_USER'
DBMS_DATAPUMP.GET_STATUS(
handle => hdl_job
,mask => dbms_datapump.ku$_status_job_error + dbms_datapump.ku$_status_job_status + dbms_datapump.ku$_status_wip
--,timeout => 15
,job_state =>l_job_state
,status =>l_status);
l_job_logentry:=l_status.wip ;
for x in l_job_logentry.first .. l_job_logentry.last loop
dbms_output.put_line (l_job_logentry(x).LogText) ;
end loop;
dbms_datapump.detach(hdl_job);
end;
/when I run it for the first time, it works... kindof...
but my problem is that if I try running it again I get:
ORA-31626: job does not exist
ORA-06512: at "SYS.DBMS_SYS_ERROR", line 79
ORA-06512: at "SYS.DBMS_DATAPUMP", line 902
ORA-06512: at "SYS.DBMS_DATAPUMP", line 3407
if I close sqlplus session , open new one and run - it works. So what is the issue here? Is detach not enough? What else should I do?
my version is 11.1.0.6
UPDATE.
Looks like the above is not true. It doesn't error if it runs to the end of code... The problem seems to happen only when exception occures and .detach is not called. So this is not an issue anymore.
But I still don't get a decent performance from the .get_status function. Sometimes it just hangs and errors on timeout.
Still the question is: How can I get the LOG of the session using DBMS_DATAPUMP from another session and output it on the screen?...
Edited by: Andrei Kübar on Dec 23, 2011 12:44 PM
Edited by: Andrei Kübar on Dec 23, 2011 12:57 PMI believe I found a solution
I am now running the above code only 1 time but in a loop and inserting output into a table, so that user can query the table and see where the job is
here's the code I'm using (partially copied from http://psoug.org/reference/dbms_datapump.html)
l_job_state:='UNDEFINED';
while (l_job_state != 'COMPLETED') and (l_job_state != 'STOPPED') loop
DBMS_DATAPUMP.GET_STATUS(
handle => hdl_job
,mask => dbms_datapump.ku$_status_job_error + dbms_datapump.ku$_status_job_status + dbms_datapump.ku$_status_wip
--,timeout => 15
,job_state =>l_job_state
,status =>l_status);
if (bitand(l_status.mask,dbms_datapump.ku$_status_wip) != 0) then
l_job_logentry:=l_status.wip ;
if (l_job_logentry is not null) then
for x in l_job_logentry.first .. l_job_logentry.last loop
--dbms_output.put_line (l_job_logentry(x).LogText ) ;
writelog (l_job_logentry(x).LogText );
end loop;
end if;
end if;
if (bitand(l_status.mask,dbms_datapump.ku$_status_job_error) != 0) then
l_job_error :=l_status.error ;
if (l_job_error is not null) then
for x in l_job_error.first .. l_job_error.last loop
dbms_output.put_line (l_job_error(x).LogText) ;
writelog('Error: '|| l_job_error(x).LogText) ;
end loop;
end if;
end if;
--dbms_output.put_line ('Current job state: '||l_job_state);
writelog ('Current job state: '||l_job_state);
end loop;thanks all for your help -
Is it possible to restart jobs defined using BMV0 with these errors?
Hi All,
I have got this direct input job defined in BMV0 and scheduled as an event related periodic job. The job gets restarted when the errors are 'system_cancelled' , 'Dataset cant open' etc., but when the job errors are 'Session cant be protected', 'error due system shutdown',the job is not getting restarted and its giving a message 'A job with the same name has not yet ended'.this message is getting displayed when the job gets cancelled....If I check in SM37 , its cancelled and the error in the job log is 'error due to system shutdown' or 'session cant be protected'.
So Is it possible for this periodic job to get triggered even when the latter set of errors occur?
When the event triggers agin, the job gets restarted if the error is 'system_cancelled' but if they are the above set of errors, the job gets cancelled again and the message in the job log of sm37 is a job with the same name has not yet ended.
Message was edited by: Sushma AnupravaHi i have same problem as u mentioned as below.
I have got this direct input job defined in BMV0 and scheduled as an event related periodic job. The job gets restarted when the errors are 'system_cancelled' , 'Dataset cant open' etc., but when the job errors are 'Session cant be protected', 'error due system shutdown',the job is not getting restarted and its giving a message 'A job with the same name has not yet ended'.this message is getting displayed when the job gets cancelled....If I check in SM37 , its cancelled and the error in the job log is 'error due to system shutdown' or 'session cant be protected'.
So Is it possible for this periodic job to get triggered even when the latter set of errors occur?
When the event triggers agin, the job gets restarted if the error is 'system_cancelled' but if they are the above set of errors, the job gets cancelled again and the message in the job log of sm37 is a job with the same name has not yet ended.
Did you get this resolved ? is so plz let me know.
Thanks in advance ! -
Schedule a job using dbms_job package
SQL to schedule a job using DBMS_JOB.
variable jobno number;
variable status number;
begin
dbms_job.submit(:jobno, 'x(:status);', trunc(sysdate)+8/24,
'trunc(sysdate)+1+8/24', null);
commit;
end;
It fails and returns the following error ...
ORA-01008: not all variables bound
Is it possible to schedule a job to run a procedure with "IN OUT" parameter? I would appreciate any assistance.
Proc runs if I execute it from command mode and there are no issues.You cannot pass parameters back from a job-- Oracle spawns a separate session to run your job, so that session would receive any OUT parameters and end immediately after the job finishes. Even if Oracle let you do this, you would lose the OUT value as soon as the job ended.
If you want a job to return a status, you can-
1) Store the status in a table
2) Queue a status message in an Oracle Advanced Queue
3) Use dbms_alert to alert another process
Justin
Distributed Database Consulting, Inc.
http://www.ddbcinc.com/askDDBC -
How to run a background job with the cloud_scheduler package
Hi,
Is the cloud_scheduler package able to run background jobs as documented? When you try to run a job in another session using:
cloud_scheduler.run_job(job_name=>'MYJOB', use_current_session=>false);
The call fails with:
ORA-20002: Cannot run job MYJOB. Adhoc background execution is disallowed. Please enable the job instead.
If you try to use cloud_scheduler.enable to run the job then the job does not run when scheduled.
Rod WestHi Rod,
Yes, I believe so. Here's a test case that I just ran successfully from SQL Workshop in my database trial service:
create table myjob_test (aa timestamp with time zone);
begin
cloud_scheduler.create_job (
job_name => 'MYJOB',
job_type => 'PLSQL_BLOCK',
job_action => 'begin insert into myjob_test values (systimestamp); commit; end;',
repeat_interval => 'freq=minutely; interval=3' );
end;
begin
cloud_scheduler.enable ( name => 'MYJOB' );
end;
select job_name, state, run_count, failure_count, last_start_date, next_run_date, systimestamp from sys.user_scheduler_jobs;
select * from myjob_test order by aa;Is the next_run_date in the past for your job? If it is, try disabling/enabling the job to "reinitialize" the job's schedule.
-- Vlad -
How to run the Batch input session(SM35) in background thru Report program
Hi Experts,
I am working in one modification report requirement ,the report is Mass upload will update and run the file via batch input session. The client requirement is to implement the report execution in background mode , the batch input session will process automatically (ie. the job runs the batch input session in background and process the session ends).
Currently, the report calls SM35 to write a batch input session and the user manually selects the session and record the transactions.
Once the Transaction enters and the selection-screen inputs are given, then the transaction executed in background mode and all the above batch input process to be implemented.
Please advise and guide me, how to proceed.
I need your guidance to proceed via Call transaction using bdcdata statement, if it can be achieved the requirement.
Thanks & Regards
San.Hi Arabind Prasad,
Thanks for your inputs.
I know the process of the report Execution in background and job steps.
I want the inputs for how to upload thru Batch input session in background job and the session should also processed automatically
Currently the report logic declared like call transaction 'SM35' and skip first screen.Once the report (tcode) executed (not in background) It writes one session in SM35. The user should select the session and process the transaction manually.
The new requirement is, if the report (tcode) executes in background mode...what and how the batch input session should be declared and how it process automatically (like you said mode 'N').
Hope I am clear in my query.
Please advise.
Regards
San.
Edited by: San Learner on Mar 1, 2011 7:16 PM -
Batch inputs sessions got deleted
Dear All,
We have a major issue on our SAP Production server. We have executed the report RSBDCTL2 as a background job RSBDCTL2_300 on 29th May 2010 with delete option. This has deleted all the batch input sessions that were existing in SAP Production server. It has impacted severly our monthly closing.
We have also executed the report RSBDCREO which have deleted the logs of these sessinos as well.
We want restore all those sessions on priority. Please, suggest immediate work around. (Apart from restoring the backup)
Thanks and Regards,
KedarRishi,
RSBDCTL2 jobs deletes the sessions that exists in SM35. Rescheduling the jobs wont help. Also restore is not the right option as we might have to restore the backup of 28th May i.e. 4 days old.
Is there any other option or report that can restore these sessions?
Thanks and Regards,
Kedar -
Which query is the job running ?
Dear all,
Normally when you want to see the currently running query by a session, you can just query the V$Session table and get the SQL_ID of a particular session. Then use SQL_ID to query V$SQL.
However when a PL/SQL procedure is submitted via a job. You can see in the V$Session that the job runs as a dedicated server session and the SQL_ID is always null. Although I do see always that the session waits for "DB sequential file read". So it means that some query might be getting executed.
How can I see which query is being run by the job (dedicated server session)?
Version : 10.1.0.5
Thanks in advanceYou can try :-
SELECT sql_id,sql_text FROM v$open_cursor WHERE sid = :1
http://www.ContractOracle.com -
Hi,
I customize the page of login with one application made in Struts. This application is layer that searchs some data in database, as number of the emp, center of cost and places in session. But as the Portal creates one session, i not obtains to pass these data for portlets. How I can make for one application external to pass these data for inside of the Portal and get data of the session?
thanks,
Marcio MestiHi Alexander,
I have solved my problem. To send report to Solution Manager, you have to run few jobs in SDCCN of Satellite system. Procedure is as follows:
Create Refresh Sessions Destinations job and set its destination as RFC back destination to solution Manager and run this job daily. By default, it will be periodically scheduled to weekly. Change its schedule in Tcode SM37.
Upon Completion of above job, create Refresh Sessions job and run it manually.
Upon Completion of above job, create Maintenance Package job and run it manually.
In all of the above jobs, you will find set or have to set destination as RFC back destination to Solution Manager.
Hope this will solve your problem.
In case of any problem please revert back.
Thanks and Regards,
Naresh.
Message was edited by:
naresh dodeja -
Can't kill session 11g WINDOWS 2008
Hoping someone might be able to tell me how to kill a job that doesn't want to die:)
We had network maintenance over the weekend that interupted the connection between our app server and database. It caused a bunch of jobs to get stuck. I could kill all but one job. The last job seems to be busy reading but the session info doesn't show any sql.
BOTH OF THE COMMANDS BELOW RETURN ERROR: "ora-00030:user session id doesn't not exist" and session info continues to say "active">
ALTER SYSTEM KILL SESSION '8,46534' immediate;
alter system disconnect session '008,46534' post_transaction;
Any idea what else I can do to kill this job? Booting the database is not a possiblities.
Thanks!
Kathieyou are trying to kill a job, not a session, right?
check this:
http://levicorp.com/2009/05/22/how-to-kill-the-running-job/
http://www.pythian.com/blog/killing-an-oracle-job-dead/ -
PowerShell - Start-Job - Synchronised Array list
Hi all,
I am trying to write a script using start-job against a list of machines. The script is to query a target machine event log using get-winevent cmdlet. I supply the whole code that queries the eventlog in a scriptblock. In order to capture the output (one
psobject for each of the scriptblock jobs) I am trying to use a synchronised arraylist. I do not know the full details of how to use the synchronised arraylist but I have put together the below script (by referring to some of the online articles). But the
script does not work as intended. The individual scriptblocks do not seem to be referring to the global arraylist variable while appending the results.
Would any of you be able to shed any light on it?
Please note, the script without the PowerShell Jobs works fine(that is linear execution which is really time-consuming). Also, even with using psJobs, the script works when I try to dump the result of each job into a csv from within the job itself. But I
want to avoid this situation because due to the asynchronous execution there might be contention for the csv by more than one jobs at the same time. Hence I want to use the synchronised array list.
$InputCSV = "$(Split-Path $SCRIPT:MyInvocation.MyCommand.Path -parent)\backupexec.csv"
$OutputCSV = "$(Split-Path $SCRIPT:MyInvocation.MyCommand.Path -parent)\Reports\BackupExec_Output_$(Get-Date -format "ddMMyyyy")_$((Get-Date).DayOfWeek).csv"
$OutputArray = [System.Collections.ArrayList]::Synchronized((New-Object System.Collections.ArrayList))
$counter=1
$jobs=@{};
$jobcounter=0;
Import-CSV $InputCSV | ForEach {
$Comp_Name=$_.ServerName;
$Counter+=1;
$Scriptblock={
Try {
$IsthereAnyResult= @()
$IsthereAnyResult= Get-WinEvent -ComputerName $Using:Comp_Name -ErrorAction SilentlyContinue -FilterHashTable @{LogName='application';ProviderName='Backup Exec';ID=57755; StartTime=(Get-Date).AddDays(-1)}
$props = @{
"Server Name" = ($event.MachineName -split '\.')[0];
"Event ID" = $event.ID;
"Time Logged" = $event.TimeCreated;
"Backup Result" = Switch ($event.ID) { '57755' {"Success - Skipped"}
'34113' {"Failed"}
'34112' {"Success"} };
"Message" = $event.Properties[0].value -replace '\n' -replace '\r';
$OutputArray += New-Object PSObject -Property $props
} #end try get-winevent
Catch { } #end Catch
} #end scriptblock
$jobs[$jobcounter]= Start-job -name $("Job_$jobcounter") -ScriptBlock $Scriptblock
$jobcounter+=1;
While((Get-Job -State 'Running').Count -ge 10) {
Start-Sleep -Milliseconds 10
} # end main foreach
Get-Job | Wait-Job
$OutputArray | Select-Object "Server Name","Event ID","Time Logged","Backup Result","Message" | Export-CSV -force -Path $OutputCSV -NoTypeInformation -AppendHow about this?
I use wmi win32_ntlogevent which i prefer .. Timeservice is just for example ...
Change the scriptblock to your needs and report the result :]
Param ([int]$BatchSize=2)
#list of servers
[array]$source = (get-adcomputer -filter {name -like "server*"}) |select -expandproperty dnshostname
$blok = {
get-wmiobject Win32_NTLogEvent -Filter "(Logfile='System') and (SourceName = 'Microsoft-Windows-Time-Service')" |select -first 10 |select __server,@{n="EventCode";e={switch($_.EventCode){37{"37 - Receiving"}35{"35 - Synchronizing"}129{"129 - NTP Fail"}default{"Other EventCode"}}}},@{n="Date";e={$_.ConvertToDateTime($_.TimeGenerated)}},message
$elapsedTime = [system.diagnostics.stopwatch]::StartNew()
$result = @()
$itemCount = 0
## checking running jobs
if (get-job|? {$_.name -like "Script*"}){
write-host "ERROR: There are pending background jobs in this session:" -back red -fore white
get-job |? {$_.name -like "Script*"} | out-host
write-host "REQUIRED ACTION: Remove the jobs and restart this script" -back black -fore yellow
$yn = read-host "Automatically remove jobs now?"
if ($yn -eq "y"){
get-job|? {$_.name -like "Script*"}|% {remove-job $_}
write-host "jobs have been removed; please restart the script" -back black -fore green
exit
$i = 0
$itemCount = $source.count
Write-Host "Script will run against $itemcount servers!"
## Script start time mark
write-host "Script started at $(get-date -uFormat "%Y/%m/%d %H:%M:%S")".padright(60) -back darkgreen -fore white
write-host " (contains $itemCount unique entries)" -back black -fore green
$activeJobCount = 0
$totalJobCount = 0
write-host "Submitting background jobs..." -back black -fore yellow
for ($i=0; $i -lt $itemCount;$i += $batchSize){
$activeJobCount += 1; $totalJobCount += 1; $HostList = @()
$HostList += $source |select -skip $i -first $batchsize
$j = invoke-command -computername $Hostlist -scriptblock $blok -asjob
$j.name = "Script`:$totalJobCount`:$($i+1)`:$($getHostList.count)"
write-host "+" -back black -fore cyan -nonewline
write-host "`n$totaljobCount jobs submitted, checking for completed jobs..." -back black -fore yellow
while (get-job |? {$_.name -like "Script*"}){
foreach ($j in get-job | ? {$_.name -like "Script*"}){
$temp = @()
if ($j.state -eq "completed"){
$temp = @()
$temp += receive-job $j
$result += $temp
remove-job $j
$ActiveJobCount -= 1
write-host "-" -back black -fore cyan -nonewline
elseif ($j.state -eq "failed"){
$temp = $j.name.split(":")
if ($temp[1] -eq "R"){
$temp = @()
$temp += receive-job $j
$result += $temp
remove-job $j
$ActiveJobCount -= 1
write-host "-" -back black -fore cyan -nonewline
else{
write-host "`nFailure detected in job: $($j.name)" -back black -fore red
$temp = @()
$temp += receive-job $j
$result += $temp
remove-job $j
$ActiveJobCount -= 1
if ($result.count -lt $itemCount){
sleep 3
write-host " "
write-host "Script finished at $(get-date -uFormat "%Y/%m/%d %H:%M:%S")".padright(60) -back darkgreen -fore white
write-host (" Elapsed Time : {0}" -f $($ElapsedTime.Elapsed.ToString())) -back black -fore green
$result |select __server,eventcode,Date,message |ft -auto
write-host " Script completed all requested operations at $(get-date -uFormat "%Y/%m/%d %H:%M:%S")".padright(60) -back darkgreen -fore white
write-host (" Elapsed Time : {0}" -f $($ElapsedTime.Elapsed.ToString())) -back black -fore green -
ST12 performance tuning background job
I would like to trace a program which will run about 3 hours. In ST12, I cannot run the program in "current mode" since the execution time is too long. How can I still use ST12 to trace the program execution when the program execute is submitted as background? Pls advise the detail configuration needed in ST12.
Thanks very much for your help!
PS: I tried to use "trace for" user instead of "current mode", and set the tasktype to "BT", when I press "start trace" and start the program background job in another session, seems nothing can be traced...
Edited by: Wing Yin, Anthony TANG on Aug 7, 2009 6:10 AMHi,
did you set up the trace on the same server where you background job was running?
3 hours is quite long... not possible to trace the whole execution.
With ST12 / SE30 (ABAP Trace) you can trace at maximum 4293 seconds. For ST05 i don't know no other limit then file size.
However you should not take such big traces.
Start with analyzing the STAD record in order to understand where the time is spent (CPU time, DB time, RFC + CPIC time, ...).
For CPU time you can continue with ST12 / SE30, for DB time you need ST05 and for RFC + CPIC time you can check the RFC Subrecords in STAD to see the 5 most expensive RFC calls (destination and FM).
In case of DB time a SQL Cache reset before the job execution and a delta analysis after the execution could help as
well if there is not too much other DB load on the system.
You can take some samples with traces. Start n traces with a few minutes duration and check the results agains STAD (overview). E.g. if according to STAD most of the time is spent in DB time but your sample trace shows mostly CPU time,
your sample is probably not a a good sample (not showing you a part where most of your time is spent).
Other than that, if your Batch Job is your program, you cann add some mesages to the job log to narrow down what part
of the programm consumes time (data selection, data processing, ...) . Another option is to evaluate if you can reduce the
processed data volume to take a trace in order to find out expensive parts of the program. This of course can change the
execution (e.g. of SQL statements) significantly.
You see analyzing long running batch processes could be a challenge
Kind regards,
Hermann
Maybe you are looking for
-
Oracle-xe-universal / debian lenny / ORA-12514
Hi, I have the following situation here: listener.ora: SID_LIST_LISTENER = (SID_LIST = (SID_DESC = (SID_NAME = PLSExtProc) (ORACLE_HOME = /usr/lib/oracle/xe/app/oracle/product/10.2.0/server) (PROGRAM = extproc) LISTENER = (DESCRIPTION_LIST = (DESCRIP
-
When we load an image online - the image is skewed or stretched and its quality is bad. The type of image is gif because we need transparancy. Pls help for a better quality of the image inspite of changing its size.
-
Help!! Muse is not responding after recent update.
Muse application is not responding...I tried to uninstall and install again...still same. Please help!!! Thanks
-
No computers are shown on my WSUS console
Windows 2012. The updates are showing but no computers. I have setup the gpo policies as per instructions. Not using client-side targeting. Initially and before my time there was a WSUS server on 2008 r2 but it would not pickup any WIN 8 workstations
-
Secuirty Implementation project--subteams?
I would like to know what teams are involved to carry out a SAP Security Implementation project. i.e I am aware of team involved in Role Built,team of functional consultants,,,etc,,can anybody tell me in detail about type of human resource invo