Job submit
Hi all,
i am trying to submit a oracle job using the following code but i am getting the oracle error PLS-00103. when i put this sql statement in a textfile and run it with a batchfile it goes well. can anybody give me some advise.
Imports Oracle.DataAccess.Client
Public Class Form1
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim cn As New OracleConnection("Data Source=test;" & "User Id=myusername;" & "Password=mypassword;")
Try
Dim sql As String = ("declare " & _
"jobnr number(10); " & _
"instnr number(10); " & _
"begin" & _
"select instance_number into instnr from v$instance;" & _
"dbms_job.submit(jobnr,'insert into system.job_logging(''system'',sysdate,''22:00'',''select name from v$database;'');'," & _
"trunc(sysdate+1)+(22+00/60)/24," & _
"'trunc(least(next_day(sysdate,''TUESDAY''),next_day(sysdate,''WEDNESDAY''),next_day(sysdate,''THURSDAY''),next_day(sysdate,''FRIDAY''),next_day(sysdate,''SATURDAY'')))+(22+00/60)/24',true,instnr);" & _
"commit;" & _
"end;")
Dim cmd As New OracleCommand(sql, cn)
cmd.Connection.Open()
Dim result As String = cmd.ExecuteNonQuery()
cmd.Connection.Close()
If result = 0 Then
MessageBox.Show("no job submitted")
Else
MessageBox.Show("succesfully submitted job")
End If
Catch ex As Exception
MessageBox.Show("error' " & ex.Message)
If cn.State = ConnectionState.Open Then
cn.Close()
End If
End Try
End Sub
End Class
kind regards,
bryan
Hi,
i checked the code again and removed the "(" befor begin and at the end. here is the code again. I ran the code with sqlplus again offcourse without the " and the & or + _ around the code, because this is vb, against the datasource and the plsql procedure succeeded. when i run this code in vb i keep getting the following error:
ora-6550: line 1, column 74:
pls-00103: encountered the symbol "INTO" when expecting one of the following:
:= .(@ % ; not null range default character.
i hope you can help me out with this problem.
Imports Oracle.DataAccess.Client
Public Class Form1
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim cn As New OracleConnection("Data Source=test;" & "User Id=myusername;" & "Password=mypassword;")
Try
Dim sql As String = "declare " + _
"jobnr number(10); " + _
"instnr number(10); " + _
"begin" + _
"select instance_number into instnr from v$instance;" + _
"dbms_job.submit(jobnr,'insert into system.job_logging(''system'',sysdate,''22:00'',''select name from v$database;'');'," + _
"trunc(sysdate+1)+(22+00/60)/24," + _
"'trunc(least(next_day(sysdate,''TUESDAY''),next_day(sysdate,''WEDNESDAY''),next_day(sysdate,''THURSDAY''),next_day(sysdate,''FRIDAY''),next_day(sysdate,''SATURDAY'')))+(22+00/60)/24'," + _
"true," + _
"instnr" + _
");" + _
"commit;" + _
"end;" + _
Dim cmd As New OracleCommand(sql, cn)
cmd.Connection.Open()
Dim result As String = cmd.ExecuteNonQuery()
cmd.Connection.Close()
If result = 0 Then
MessageBox.Show("no job submitted")
Else
MessageBox.Show("succesfully submitted job")
End If
Catch ex As Exception
MessageBox.Show("error' " & ex.Message)
If cn.State = ConnectionState.Open Then
cn.Close()
End If
End Try
End Sub
End Class
kind regards,
bryan
Similar Messages
-
Hi ,
I am trying to write code for open job , submit & close job.
I need to send 4 fields as parameters from program1 to the BGprogram.
Anyone please tell me the syntax for submit.I cun't find any syntax for this.
Thanks in advance,..Create new job
CONCATENATE lc_job_prefix l_pr_count
INTO l_job_name SEPARATED BY '_'
CALL FUNCTION 'JOB_OPEN'
EXPORTING
jobname = l_job_name
IMPORTING
jobcount = l_job_count
EXCEPTIONS
cant_create_job = 1
invalid_job_data = 2
jobname_missing = 3
OTHERS = 4
IF sy-subrc <> 0.
....Error creating job
IF NOT sy-msgid IS INITIAL.
MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ELSE.
MESSAGE s000(zz) WITH
'Failed to create job'(021)
l_job_name
ENDIF.
ELSE.
....Submit job {
MESSAGE s000(zz) WITH
'Creating job'(022) l_job_name l_job_count '...'
INTO l_msgtx
PERFORM show_progress USING l_msgtx 0 1.
IF v_sort = 'X'.
SUBMIT (sy-cprog)
WITH s_pernr BETWEEN l_pernr_min AND l_pernr_max
WITH s_g_ctrl IN r_cs_ctrl
WITH s_g_land IN r_cs_land
WITH s_g_gs IN r_cs_gs
VIA JOB l_job_name NUMBER l_job_count
TO SAP-SPOOL SPOOL PARAMETERS l_print_parm
ARCHIVE PARAMETERS l_archive
WITHOUT SPOOL DYNPRO
AND RETURN
ELSE.
SUBMIT (sy-cprog)
WITH s_pernr BETWEEN l_pernr_min AND l_pernr_max
WITH s_g_lub IN r_cs_lub
WITH s_g_pro IN r_cs_pro
WITH s_g_pub IN r_cs_pub
VIA JOB l_job_name NUMBER l_job_count
TO SAP-SPOOL SPOOL PARAMETERS l_print_parm
ARCHIVE PARAMETERS l_archive
WITHOUT SPOOL DYNPRO
AND RETURN
ENDIF.
....Start immediately
CALL FUNCTION 'JOB_CLOSE'
EXPORTING
jobcount = l_job_count
jobname = l_job_name
strtimmed = true
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.
IF NOT sy-msgid IS INITIAL.
MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ELSE.
MESSAGE s000(zz) WITH
'Error releasing job'(023)
l_job_name
l_job_count
ENDIF.
ELSE.
MESSAGE s000(zz) WITH
'Job released'(024) l_job_name l_job_count
INTO l_msgtx
PERFORM show_progress USING l_msgtx 0 1.
ENDIF.
....} Submit job
ENDIF.
..Increment process count
ADD 1 TO l_pr_count.
ENDDO.
MESSAGE s000(zz) WITH l_pr_count 'job(s) created.'(025). -
Guys,
simply,
i want to create temp_undo ( done ) and i want to do the following
create or replace procedure temp_undo_procedures
is
CURSOR c is select a.name, b.status from V$rollname a, v$rollstat b
where a.name IN (select segment_name from dba_segments where tablespace_name ='TEMP_UNDO')
AND a.usn=b.usn;
v_name1 v$rollname.name%type;
v_status1 v$rollstat.STATUS%type;
test1 varchar2(50);
v_job_number number;
begin
open c;
if c%notfound then
test1 := 'good';
Dbms_Output.put_line(test1);
-- drop the tablespace.
execute immediate 'drop tablespace temp_undo';
select job INTO v_job_number from dba_jobs WHERE WHAT LIKE 'temp_undo_procedures';
execute immediate dbms_job.broken(v_job_number,true);_ ==>i think this is error statement because i want to v_job_number come from the select statment and broke the job number that retrieve from select statment,
end if;
loop
fetch c into v_name1, v_status1;
exit when c%notfound;
Dbms_Output.put_line(v_name1 || ' ' || v_status1);
end loop;
close c;
end;
VARIABLE v_jobnum1 NUMBER;
BEGIN
dbms_job.submit(:v_jobnum1,
*'temp_undo_procedures', ==> also here i think this is error as well, coz i want to run this procedure every 5 min.*
trunc(sysdate,'MI')+1/288,
*'sysdate + (1/288)'*
commit;
END;
plz help and add suggestionCan you try this?
create or replace procedure temp_undo_procedures
is
CURSOR c
is
select a.name,
b.status
from V$rollname a, v$rollstat b
where a.name IN (
select segment_name
from dba_segments
where tablespace_name ='TEMP_UNDO'
AND a.usn=b.usn;
v_name1 v$rollname.name%type;
v_status1 v$rollstat.STATUS%type;
test1 varchar2(50);
v_job_number number;
begin
open c;
loop
fetch c into v_name1, v_status1;
exit when c%notfound;
if c%notfound then
test1 := 'good';
Dbms_Output.put_line(test1);
-- drop the tablespace.
execute immediate 'drop tablespace temp_undo';
select job
INTO v_job_number
from dba_jobs
WHERE WHAT LIKE 'temp_undo_procedures';
execute immediate dbms_job.broken(v_job_number,true); -- ==>i think this is error statement because i want to v_job_number come from the select statment and broke the job number that retrieve from select statment,
end if;
Dbms_Output.put_line(v_name1 || ' ' || v_status1);
end loop;
close c;
end;N.B.: Not Tested....
Regards.
Satyaki De -
Hi!
I have this code:
SELECT SINGLE PROCPROG JOBNAME
INTO (lv_procprog, lv_jobname)
FROM ZGL_MPF_CONFIG
WHERE interfacename = INTERFACENAME.
CALL FUNCTION 'JOB_OPEN'
EXPORTING
jobname = lv_jobname
IMPORTING
JOBCOUNT = lv_jobcount.
SUBMIT (lv_procprog)
USER SY-UNAME
VIA JOB lv_jobname
NUMBER lv_jobcount
WITH PATH EQ 'C:\DOWNLOAD2.TXT'
AND RETURN.
CALL FUNCTION 'JOB_CLOSE'
EXPORTING
jobcount = lv_jobcount
jobname = lv_jobname
STRTIMMED = 'X'
The program dump in SUBMIT (lv_procprog) line. SAP tells z_interface (procprog value) doesn't exist but it is a FM that exists and is actived. Do you see any mistake? z_interface receive a path where write a file.
ThxHi,
1. What u can do list.
Get all the variant of the standard report and
data: variant(14).
variant = 'VARIANT1'. " Based on ur condition change the value to the variable
SUBMIT REPORT01
VIA SELECTION-SCREEN
USING SELECTION-SET VARIANT "Check here
USING SELECTION-SETS OF PROGRAM 'REPORT00'
AND RETURN.
2 .Use the fm: RS_VARIANT_CONTENTS to get the values of the different values in the screen.
move those values to screen fields in the INITIALIZATION event
<b>Reward points</b>
Regards -
Code to write syntax for JOB submit ( Please answer ASAP)
Hi,
I need sytax to submit a job
Right now I am using this code to send 4 parameters.
I need to send these 4 in a structure.
submit Ztestjob USER sy-uname
via job p_jobnm
number p_jobcount
with afko-rsnum eq afko-rsnum
with aufnr_d eq aufnr_d
with sernr_d eq sernr_d
with p_lmnga eq p_lmnga
AND RETURN.
So I have to pass a structure of values into the BGprogram through a submit and do a couple of loops in the BGPROGRAM.
I need the syntax for submit .
I also need to know how to catch the structure with values in the BGPROGRAM.
Anyone please answer ASAP
Message was edited by:
ramana peddu
Message was edited by:
ramana pedduHi,
<u>SUBMIT</u>
Calls an executable program of type 1.
Syntax
SUBMIT <rep> [AND RETURN] [VIA SELECTION-SCREEN]
[USING SELECTION-SET <var>]
[WITH <sel> <criterion>]
[WITH FREE SELECTIONS <freesel>]
[WITH SELECTION-TABLE <rspar>]
[LINE-SIZE <width>]
[LINE-COUNT <length>].
Calls the program <rep>. If you omit the AND RETURN addition, the current program is terminated. Otherwise, the data from the current program is retained, and processing returns to the calling program when <rep> has finished running. The other additions control the selection screen and set attributes of the default list in the called program.
Regards,
Bhaskar -
Pass structure of values for Job submit
Hi,
I need sytax to submit a job
Right now I am using this code to send 4 parameters.
I need to send these 4 in a structure.
<b>submit Ztestjob USER sy-uname
via job p_jobnm
number p_jobcount
with afko-rsnum eq afko-rsnum
with aufnr_d eq aufnr_d
with sernr_d eq sernr_d
with p_lmnga eq p_lmnga
AND RETURN.</b>
So I have to pass a structure of values into the BGprogram through a submit and do a couple of loops in the BGPROGRAM.
I need the syntax for submit .
I also need to know how to catch the structure with values in the BGPROGRAM.
Anyone please answer ASAP
Message was edited by:
ramana peddu
Message was edited by:
ramana peddu
Message was edited by:
ramana peddu
Message was edited by:
ramana pedduHi,
If want to pass an internal table...
Then create a dummy select-options...
And then pass the values in the select-options..
Then in the submitted program you can use the select-options internal table..
Thanks,
Naren -
Authentication error on Job submit from EM (VNI 2015)
we have oracle 8.1.7 on windows 2000 advance server recently updated with patch 8.1.7.2.1 and 8.1.7.2.5.
Here is my SQLnet.ora file:
NAMES.DEFAULT_DOMAIN = hq.xxx.net
SQLNET.AUTHENTICATION_SERVICES= (NTS)
NAMES.DIRECTORY_PATH= (TNSNAMES, ONAMES, HOSTNAME)
My question is :
Why am i getting following errors? And where can i find the dll's that are missing from the below trace file.
I also tried commenting SQLNET.AUTHENTICATION_SERVICES line in sqlnet.ora file but i still getting same error.
Please somebody help me.
Here are the lines from dbsnmp.trc file:
[01-APR-2003 10:45:52] nau_fad: The following authentication adapter dll does not exist: orangss8.dll
[01-APR-2003 10:45:52] nau_fad: exit
[01-APR-2003 10:45:52] nau_fad: entry
[01-APR-2003 10:45:52] nau_fad: The following authentication adapter dll does not exist: oranidx8.dll
[01-APR-2003 10:45:52] nau_fad: exit
[01-APR-2003 10:45:52] nau_fad: entry
[01-APR-2003 10:45:52] nau_fad: exit
[01-APR-2003 10:45:52] nau_fad: entry
[01-APR-2003 10:45:52] nau_fad: exit
[01-APR-2003 10:45:52] nau_fad: entry
[01-APR-2003 10:45:52] nau_fad: exit
[01-APR-2003 10:45:52] nau_fad: entry
[01-APR-2003 10:45:52] nau_fad: The following authentication adapter dll does not exist: oranoss8.dll
[01-APR-2003 10:45:52] nau_fad: exit
[01-APR-2003 10:45:52] nau_fad: entry
[01-APR-2003 10:45:52] snmiloq_LockOutgoingQueues: Thread 000006a4 locking
Thank you
UmeshThe machine was in an NT domain. It had been upgraded to 2000 from NT. I don't think the effective setting stuff for the log on as batch permission was causing us problems until we upgraded (presumably the log on as batch isn't chained down until 2K) - hence I thought I'd suggest it to you, sorry it hasn't helped!
Do let me know when you've figured out the problem as I dare say I'll come across it sooner or later!
Regards
Jason.
<BLOCKQUOTE><font size="1" face="Verdana, Arial">quote:</font><HR>Originally posted by struggling:
thanks Jason. I verified that the effective setting is checked for the accounts I'm trying to use, and I made sure I'm not specifying the domain before the user name (i.e. using local users). this machine is not in a Win 2000 domain (aka active directory) however, was the machine you used in an NT 4 domain or a Win 2000 one? I'm thinking the active directory stuff is what's getting in my way.
<HR></BLOCKQUOTE>
null -
Problems creating background job for program (job open, submit and close)
Hi gurus,
im trying to start a background job using the FM BP_START_DATE_EDITOR to show the start date to the job or if it's imediate. this FM it's working fine, after call it im opening a job, submiting it and call the job close FM and the job close FM creates me the job.
The problem it's when i go to the sm37 to see the job status the job has been canceled, and the job log says that i have to give a start date to the job.
What i dont understand it's either the job is imediate or i choose a date to start the job always gives me this error...
Below goes my code,
any ideas will be rewarded
CLEAR: stdt_modify_type, stdt_output.
CALL FUNCTION 'BP_START_DATE_EDITOR'
EXPORTING
stdt_dialog = 'Y'
stdt_input = stdt_input
stdt_opcode = 14
IMPORTING
stdt_modify_type = stdt_modify_type
stdt_output = stdt_output
EXCEPTIONS
fcal_id_not_defined = 1
incomplete_last_startdate = 2
incomplete_startdate = 3
invalid_dialog_type = 4
invalid_eventid = 5
invalid_opcode = 6
invalid_opmode_name = 7
invalid_periodbehaviour = 8
invalid_predecessor_jobname = 9
last_startdate_in_the_past = 10
no_period_data_given = 11
no_startdate_given = 12
period_and_predjob_no_way = 13
period_too_small_for_limit = 14
predecessor_jobname_not_unique = 15
startdate_interval_too_large = 16
startdate_in_the_past = 17
startdate_is_a_holiday = 18
startdate_out_of_fcal_range = 19
stdt_before_holiday_in_past = 20
unknown_fcal_error_occured = 21
no_workday_nr_given = 22
invalid_workday_countdir = 23
invalid_workday_nr = 24
notbefore_stdt_missing = 25
workday_starttime_missing = 26
no_eventid_given = 27
OTHERS = 28.
IF sy-subrc <> 0.
MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
MOVE 'X' TO gv_flag.
ENDIF.
DATA jobname LIKE tbtcjob-jobname.
DATA jobcount LIKE tbtcjob-jobcount.
DATA job_release LIKE btch0000-char1.
DATA job_imediate TYPE c.
CLEAR: jobname, jobcount, job_release.
CONCATENATE 'MAPAEXEC' sy-uname sy-datum
INTO jobname SEPARATED BY space.
CALL FUNCTION 'JOB_OPEN'
EXPORTING
jobname = jobname
IMPORTING
jobcount = jobcount
EXCEPTIONS
cant_create_job = 1
invalid_job_data = 2
jobname_missing = 3
OTHERS = 4.
IF sy-subrc <> 0.
MESSAGE i003(zmapas).
EXIT.
ENDIF.
SUBMIT z_mapa_execucao_orcamental
VIA JOB jobname NUMBER jobcount
WITH ano EQ ano
WITH so_perio IN so_perio
WITH so_date IN so_date
WITH so_org EQ so_org
WITH so_num IN so_num
AND RETURN.
IF stdt_output-startdttyp EQ 'I'.
CLEAR job_imediate.
job_imediate = 'X'.
ENDIF.
CALL FUNCTION 'JOB_CLOSE'
EXPORTING
calendar_id = stdt_output-calendarid
event_id = stdt_output-eventid
event_param = stdt_output-eventparm
event_periodic = stdt_output-periodic "?
jobcount = jobcount
jobname = jobname
laststrtdt = stdt_output-laststrtdt
laststrttm = stdt_output-laststrttm
prddays = stdt_output-prddays "??
prdhours = stdt_output-prdhours "?
prdmins = stdt_output-prdmins "??
prdmonths = stdt_output-prdmonths
prdweeks = stdt_output-prdweeks "?
predjob_checkstat = stdt_output-checkstat
pred_jobcount = stdt_output-predjobcnt
pred_jobname = stdt_output-predjob
sdlstrtdt = stdt_output-sdlstrtdt
sdlstrttm = stdt_output-sdlstrttm
strtimmed = job_imediate
targetsystem = stdt_output-instname
start_on_workday_not_before = stdt_output-notbefore
start_on_workday_nr = stdt_output-wdayno
workday_count_direction = stdt_output-wdaycdir
IMPORTING
job_was_released = job_release
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.
MESSAGE i003(zmapas).
EXIT.
ELSE.
MESSAGE i004(zmapas) WITH jobname.
ENDIF.
Thanks in advance,
Best Regards
João MartinsHello João.
In debug mode, check the value of variables you passed to parameters sdlstrtdt and sdlstrttm.
As aditional info, I usually achieve your goal without FM BP_START_DATE_EDITOR.
Check this code:
CALL FUNCTION 'JOB_OPEN'
EXPORTING
jobname = w_jobname
IMPORTING
jobcount = w_jobcount
EXCEPTIONS
cant_create_job = 1
invalid_job_data = 2
jobname_missing = 3
OTHERS = 4.
CHECK sy-subrc = 0.
CLEAR seltab_wa.
MOVE: t_jobs-param TO seltab_wa-selname,
t_processar-line+34 TO seltab_wa-low.
APPEND seltab_wa TO seltab.
seltab_wa-selname = 'P_LOJA'.
seltab_wa-low = t_processar-ficheiro+7(4).
APPEND seltab_wa TO seltab.
*** Submete o programa para o JOB
SUBMIT (t_jobs-repid)
WITH SELECTION-TABLE seltab
USER sy-uname
VIA JOB w_jobname NUMBER w_jobcount
AND RETURN.
*** Encerra o JOB
l_hora = sy-uzeit.
ADD 60 TO l_hora.
CALL FUNCTION 'JOB_CLOSE'
EXPORTING
jobcount = w_jobcount
jobname = w_jobname
sdlstrtdt = sy-datum
sdlstrttm = l_hora
targetserver = w_servidor
IMPORTING
job_was_released = l_liberado
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.
Regards.
Valter Oliveira. -
SUBMIT program VIA JOB and SET/GET parameter
Hi All
I need to pass the content of a variable from the program 'A' to program 'B'.
Program A uses JOB_OPEN , SUBMIT program VIA JOB jobname NUMBER jobnumber AND return, JOB_CLOSE.
I tried to use import/export memory but it didn't work. Then I am trying to use set/get parameters but it also did not work.
Program A is going to run in any server and program B will run in the central instance (it is determined in the FM JOB_CLOSE, parameter target_server).
Program does not have selection-screen.
Is it possible use set/get parameter with submit via job?
Could you please advise?
Thanks in advance.
João GaiaHere a simple code
*Submit report as job(i.e. in background)
data: jobname like tbtcjob-jobname value
'TRANSFER DATA'.
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 value 'X'.
* 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.
Then... for import/export of a variable, you can use Import Memory and Export Memory function.
Like this:
REPORT A:
IF NOT it_dlist_out IS INITIAL.
EXPORT it_dlist_out TO MEMORY ID 'TEST1234'.
ELSE.
* Clearing memory
FREE MEMORY ID 'TEST1234'.
ENDIF.
REPORT B:
IMPORT it_dlist_out TO lt_dlist_out FROM MEMORY ID 'TEST1234'.
Edited by: spantaleoni on Jan 11, 2011 3:21 PM
Edited by: spantaleoni on Jan 11, 2011 3:23 PM -
Submit program in background job
Hi all.
Somehow I'm not able of using the following source code within a program executed within a scheduled job:
SUBMIT RFEBKA00 USING SELECTION-SET 'VAR1'.
The above program is the transaction FF_5.
Does any onetry to code in the below mentioned ...
use BATCH = 'X' option.
submit rfebka00 USING SELECTION-SET 'VAR1'
with batch = 'X' AND RETURN -
Pessoal,
Boa tarde!
está e a minha 1° vez aqui no forum, e gostaria da ajuda de vocês.
Trabalho no módulo PP e estou tendo um problema com um job.
Aqui na empresa, trabalhamos com Mensagens de Processo. Temos um Job chamado: Z_Send_Process_Mesage_02 que fica enviando as mensagens de processo. O mesmo está configurado para rodar de 5 em 5 minutos. Quando este tempo estoura, o job seguinte acaba sendo cancelado. No log, ele informa que o job anterior ainda erstá em execução. Ao cancelar o job, um email é disparado para outra equipe, e com isso, acaba gerando uma analise desnecessária.
O Abap daqui da empresa, criou um programa que trabalha em paralelo com este job, para que se houver um atraso e o job seguinte tentar executar, ele irá dar como concluido e irá gerar um log informando que o processo está em andamento. só que o problema ainda continua. O processo está sendo cancelado.
Estou postando o código Abap do programa criado:
*& Report ZATUALIZAJOB
REPORT ZATUALIZAJOB.
**TYPES: BEGIN OF ls_jobstate_type,
** aborted TYPE tbtcv-abort,
** finished TYPE tbtcv-fin,
** preliminary TYPE tbtcv-prelim,
** ready TYPE tbtcv-ready,
** running TYPE tbtcv-run,
** scheduled TYPE tbtcv-sched,
** END OF ls_jobstate_type.
DATA:
* ls_jobstate TYPE ls_jobstate_type,
t_ZTBJOB TYPE TABLE OF ZTBJOB WITH HEADER LINE,
v_status type c,
V_JA_EXECUTANDO type c.
DATA: seltab type table of rsparams,
seltab_wa like line of seltab.
*** ZIT_JOB_DETAILS type /OSP/TT_REPORT_JOB_LIST,
*** ES_JOB_DETAILS type /OSP/S_REPORT_JOB_LIST.
*data: newstate like msqexport-retcode.
parameters: plant LIKE comh-werk OBLIGATORY VALUE CHECK.
SELECT * INTO table t_ZTBJOB FROM ZTBJOB WHERE jobname = 'Z_SEND_PROCESS_MESSAGES_WA' or jobname = 'Z_SEND_PROCESS_MESSAGES_02'.
**SELECT * INTO t_TBTCO FROM TBTCO WHERE jobname = 'Z_SEND_PROCESS_MESSAGES_WA' or jobname = 'Z_SEND_PROCESS_MESSAGES_02'. ENDSELECT.
WRITE:/ SY-SUBRC.
IF SY-SUBRC IS INITIAL.
write:/ 'Job já está em execução!'.
exit.
else.
CLEAR: t_ZTBJOB ,t_ZTBJOB[].
t_ZTBJOB-jobname = 'Z_SEND_PROCESS_MESSAGES_WA'.
INSERT ZTBJOB from t_ZTBJOB.
** commit WORK.
ENDIF.
***LOOP AT t_TBTCO.
*** CALL FUNCTION 'BDL_READ_JOB_STATUS'
*** EXPORTING
*** JOBNAME = t_TBTCO-jobname
*** JOBNUMBER = t_TBTCO-jobcount
*** SESSIONNR = '0000000000'
*** EXTENSION = '000'
*** IMPORTING
**** JOBNAME_OUT =
**** JOBNUMBER_OUT =
*** JOBSTATUS = v_status
*** EXCEPTIONS
*** JOB_NOT_FOUND = 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.
*** ELSEIF SY-SUBRC IS INITIAL.
*** IF V_STATUS = 'R'.
*** V_JA_EXECUTANDO = 'X'.
*** EXIT.
*** ENDIF.
*** ENDIF.
***ENDLOOP.
***IF V_JA_EXECUTANDO IS NOT INITIAL.
*** write:/ 'Job já está em execução!'.
***else.
data: jobname like tbtcjob-jobname value
'Z_SEND_PROCESS_MESSAGES_02'.
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 value 'X'.
* 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 RCOCB004 USING SELECTION-SET 'SAP&MESS_PLANT' user sy-uname VIA JOB jobname NUMBER jobcount AND RETURN.
**** BREAK-POINT.
if sy-subrc > 0.
"error processing
** IMPLEMENTADO EM UMA ENHANCEMENT DENTRO DO PROGRAMA RCOCB004
**else.
** DELETE FROM ZTBJOB WHERE jobname = 'Z_SEND_PROCESS_MESSAGES_WA'.
** commit WORK.
endif.
* Close job
starttime-sdlstrtdt = sy-datum + 1.
starttime-sdlstrttm = '220000'.
call function 'JOB_CLOSE'
EXPORTING
jobcount = jobcount
jobname = jobname
strtimmed = starttimeimmediate
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.
Vocês poderiam me auxiliar nesta questão?
Agradeço a ajuda de todos.
Att,
Renato Rosario
Edited by: Fernando Ros on May 7, 2011 9:06 PM ajustando visualOlá Renato,
quanto à performance do job, vc pode verificar os runtimes na SE30, se o maior runtime é em ABAP ou banco.
Quanto ao cancelamento, por favor coloque aqui o log gerado pelo mesno, que pode ser entrontrado na SM37. Aliás, já poste o conteúdo do dev_w* do work process que o job rodou, para ver os detalhes do erro.
Desse modo, podermos ajudá-lo melhor ainda
Abrassssosssssss,
Tomas Black -
Job Scheduling using job_close
Hi gurus,
im trying to scheduke several jobs using the FM Job close, but the jobs are running paralel..
The first job its' schedule with a start date or imediate, and the letf ones are schedule to start after his precessor finish, but once i run the programa 4 jobs start running ...
Can any one help me on this?
Below goes my code...
DO njobs TIMES.
**Nome de Job
CLEAR: jobname, jobcount, job_release.
CLEAR: job_imediate, str_job.
ADD 1 TO ind_job.
WRITE ind_job TO str_job.
CONCATENATE 'EXECORC' sy-uname sy-uzeit str_job
INTO jobname SEPARATED BY '-'.
CALL FUNCTION 'JOB_OPEN'
EXPORTING
jobname = jobname
IMPORTING
jobcount = jobcount
EXCEPTIONS
cant_create_job = 1
invalid_job_data = 2
jobname_missing = 3
OTHERS = 4.
IF sy-subrc <> 0.
MESSAGE i003(zmapas).
EXIT.
ENDIF.
IF gv_global EQ 'X'.
**Submit job
SUBMIT z_mapa_execucao_orcamental
VIA JOB jobname NUMBER jobcount
WITH ano EQ ano
WITH so_perio IN so_perio
WITH so_date IN so_date
WITH so_org EQ so_org
WITH so_num IN so_num
AND RETURN.
ELSE.
***Limites
CLEAR: upper_bound, lower_bound.
upper_bound = njobs * ind_job.
lower_bound = upper_bound - njobs + 1.
CLEAR so_num.
REFRESH so_num.
LOOP AT tab_prog FROM lower_bound TO upper_bound.
so_num-sign = 'I'.
so_num-option = 'EQ'.
so_num-low = tab_prog-zlinha.
APPEND so_num.
ENDLOOP.
SUBMIT z_mapa_execucao_orcamental
VIA JOB jobname NUMBER jobcount
WITH ano EQ ano
WITH so_perio IN so_perio
WITH so_date IN so_date
WITH so_org EQ so_org
WITH so_num IN so_num
AND RETURN.
ENDIF.
IF ind_job EQ 1.
IF stdt_output-startdttyp EQ 'I'.
job_imediate = 'X'.
ENDIF.
CALL FUNCTION 'JOB_CLOSE'
EXPORTING
jobcount = jobcount
jobname = jobname
sdlstrtdt = stdt_output-sdlstrtdt
sdlstrttm = stdt_output-sdlstrttm
strtimmed = job_imediate
IMPORTING
job_was_released = job_release
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.
MESSAGE i003(zmapas).
EXIT.
ELSE.
CLEAR: predjob, predjobcount, stdt_output.
predjob = jobname.
predjobcount = jobcount.
MESSAGE s004(zmapas) WITH jobname.
ENDIF.
ELSE.
CALL FUNCTION 'JOB_CLOSE'
EXPORTING
jobcount = jobcount
jobname = jobname
* predjob_checkstat = 'X'
pred_jobcount = predjobcount
pred_jobname = predjob
* strtimmed = 'X'
IMPORTING
job_was_released = job_release
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.
MESSAGE i003(zmapas).
EXIT.
ELSE.
CLEAR: predjob, predjobcount, stdt_output.
predjob = jobname.
predjobcount = jobcount.
MESSAGE s004(zmapas) WITH jobname.
ENDIF.
ENDIF.
Thanks in Advance,
Best Regards,
João MartinsHello.
First of all, parameter predjob_checkstat makes the second job to start only if the previous one ends without error. Probably this solves your problem at all ... the second waits to the end of the first to see if it ended with error or not.
I was analysing your problem. Parameter strtimmed can only be set in the first JOB_CLOSE. All the others cannot have this parameter set to 'X' if you want them to wait for the end of the previous ones.
So, try predjob_checkstat = 'X' and strtimmed = space.
Also, I have one example that is working:
*** Escalona um JOB para cada ficheiro encontrado.
LOOP AT t_processar.
CLEAR: w_jobcount, w_jobname, l_liberado.
ADD 1 TO l_conta.
MOVE l_conta TO l_conta2.
CONDENSE l_conta2.
CONCATENATE t_jobs-jobname l_conta2 INTO w_jobname.
CALL FUNCTION 'JOB_OPEN'
EXPORTING
jobname = w_jobname
IMPORTING
jobcount = w_jobcount
EXCEPTIONS
cant_create_job = 1
invalid_job_data = 2
jobname_missing = 3
OTHERS = 4.
*** Criou-se o JOB com sucesso
IF sy-subrc = 0.
CLEAR seltab_wa.
*** Monta o parâmetro
MOVE: t_jobs-param TO seltab_wa-selname,
t_processar-line+34 TO seltab_wa-low.
APPEND seltab_wa TO seltab.
seltab_wa-selname = 'P_LOJA'.
seltab_wa-low = t_processar-ficheiro+7(4).
APPEND seltab_wa TO seltab.
*** Submete o programa para o JOB
SUBMIT (t_jobs-repid)
WITH SELECTION-TABLE seltab
USER sy-uname
VIA JOB w_jobname NUMBER w_jobcount
AND RETURN.
*** Encerra o JOB
IF l_conta EQ 1.
l_hora = sy-uzeit.
ADD 120 TO l_hora.
CALL FUNCTION 'JOB_CLOSE'
EXPORTING
jobcount = w_jobcount
jobname = w_jobname
sdlstrtdt = sy-datum
sdlstrttm = l_hora
targetserver = w_servidor
IMPORTING
job_was_released = l_liberado
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.
ELSE.
CALL FUNCTION 'JOB_CLOSE'
EXPORTING
jobcount = w_jobcount
jobname = w_jobname
predjob_checkstat = 'X'
pred_jobcount = w_jobcount2
pred_jobname = w_jobname2
targetserver = w_servidor
IMPORTING
job_was_released = l_liberado
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.
ENDIF. "l_conta eq ...
ENDIF. "sy-subrc = 0 do JOB-OPEN
w_jobname2 = w_jobname.
w_jobcount2 = w_jobcount.
PERFORM f_limpa_param.
ENDLOOP. "at t_processar
Regards.
Valter Oliveira. -
How can i schedule jobs daily by using fm's
hi all,
am using open job ,submit job,close job fm's to schedule back ground jobs,
want to schedule it daily which parameter i need to pass in close_job for daily job schedulingyou can get the clear documentation by using ABAPDOCU transaction.
Regards
Mani. -
Background job scheduling problem
Hai..Can anyone check the below program and correct it.
I am unable to see the output in SP01 (SPOOL REQUEST)
MY PROGRAM:-
REPORT zh_test4.
TABLES : mara, TBTCO.
DATA : BEGIN OF itab OCCURS 0,
matnr LIKE mara-matnr,
END OF itab.
****background data declarations
data : job_name like TBTCO-JOBNAME.
data : job_num like TBTCO-JOBCOUNT,
rep like sy-repid.
***selection screen
PARAMETERS : p_matnr LIKE mara-matnr default '1500-610'.
SELECT matnr FROM mara INTO TABLE itab WHERE matnr EQ p_matnr.
job_name = 'HARI'.
CALL FUNCTION 'JOB_OPEN'
EXPORTING
DELANFREP = ' '
JOBGROUP = ' '
jobname = job_name
SDLSTRTDT = NO_DATE
SDLSTRTTM = NO_TIME
IMPORTING
jobcount = job_num
EXCEPTIONS
CANT_CREATE_JOB = 1
INVALID_JOB_DATA = 2
JOBNAME_MISSING = 3
OTHERS = 4
IF sy-subrc <> 0.
write :/ ' Job opening problem'.
else.
write :/ 'Job succesfully opened', sy-subrc.
ENDIF.
MOVE SY-UNAME TO TBTCO-AUTHCKNAM.
rep = sy-repid.
job_name = 'HARI'.
CALL FUNCTION 'JOB_SUBMIT'
EXPORTING
ARCPARAMS =
authcknam = SY-UNAME
jobcount = job_num
jobname = job_name
LANGUAGE = SY-LANGU
PRIPARAMS = ' '
REPORT = 'ZH_TEST4'
VARIANT = 'VAR'
IMPORTING
STEP_NUMBER =
EXCEPTIONS
BAD_PRIPARAMS = 1
BAD_XPGFLAGS = 2
INVALID_JOBDATA = 3
JOBNAME_MISSING = 4
JOB_NOTEX = 5
JOB_SUBMIT_FAILED = 6
LOCK_FAILED = 7
PROGRAM_MISSING = 8
PROG_ABAP_AND_EXTPG_SET = 9
OTHERS = 10
IF sy-subrc <> 0.
WRITE :/ 'JOB SUBMIT PROBLEM',
job_name,
job_num,
rep,
sy-subrc.
else.
write :/ 'Job succesfully submitted in background', sy-subrc.
ENDIF.
CALL FUNCTION 'JOB_CLOSE'
EXPORTING
jobcount = job_num
jobname = job_name
LASTSTRTDT = NO_DATE
LASTSTRTTM = NO_TIME
PRDDAYS = 0
PRDHOURS = 0
PRDMINS = 0
PRDMONTHS = 0
PRDWEEKS = 0
PREDJOB_CHECKSTAT = ' '
PRED_JOBCOUNT = ' '
PRED_JOBNAME = ' '
SDLSTRTDT = datum
SDLSTRTTM = uzeit
STARTDATE_RESTRICTION = BTC_PROCESS_ALWAYS
STRTIMMED = 'X'
TARGETSYSTEM = ' '
START_ON_WORKDAY_NOT_BEFORE = SY-DATUM
START_ON_WORKDAY_NR = 0
WORKDAY_COUNT_DIRECTION = 0
RECIPIENT_OBJ =
TARGETSERVER = ' '
DONT_RELEASE = ' '
TARGETGROUP = ' '
IMPORTING
JOB_WAS_RELEASED = '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.
write :/ 'Unable to close the Job', rep, sy-subrc.
else.
write :/ 'Succesfully closed the job', sy-subrc.
ENDIF.Here is an example, slightly different from your version.
REPORT ztest.
PARAMETERS: p_vbeln LIKE vbak-vbeln,
p_bkrun NO-DISPLAY.
DATA: ls_vbak LIKE vbak.
DATA: v_answer,
v_jobcount LIKE tbtcjob-jobcount.
IF p_bkrun IS INITIAL.
*-- not background processing
CALL FUNCTION 'POPUP_TO_CONFIRM_STEP'
EXPORTING
textline1 = 'This may time out.'
textline2 = 'Do you want to run in background?'
titel = 'Warning!!!'
cancel_display = space
IMPORTING
answer = v_answer.
IF v_answer = 'J'.
*-- run in the background
CALL FUNCTION 'JOB_OPEN'
EXPORTING
jobname = 'ZTEST'
IMPORTING
jobcount = v_jobcount
EXCEPTIONS
cant_create_job = 1
invalid_job_data = 2
jobname_missing = 3
OTHERS = 4.
IF sy-subrc <> 0.
MESSAGE ID sy-msgid TYPE 'E' NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
EXIT.
ENDIF.
*-- submit the program in the background
SUBMIT ztest
WITH p_bkrun = 'X'
WITH p_vbeln = p_vbeln
USER sy-uname
VIA JOB 'ZTEST' NUMBER v_jobcount AND RETURN.
*-- close the job
CALL FUNCTION 'JOB_CLOSE'
EXPORTING
jobcount = v_jobcount
jobname = 'ZTEST'
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.
MESSAGE ID sy-msgid TYPE 'W' NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ENDIF.
EXIT.
ELSE.
CLEAR v_answer.
ENDIF.
ENDIF.
CHECK v_answer IS INITIAL.
SELECT SINGLE * FROM vbak
INTO ls_vbak
WHERE vbeln = p_vbeln.
IF sy-subrc <> 0.
WRITE:/ 'Invalid Order Id.'.
ENDIF.
END-OF-SELECTION.
CHECK v_answer IS INITIAL.
IF p_bkrun IS INITIAL.
WRITE:/ 'Here is the result running the program in foreground.'.
ELSE.
WRITE:/ 'Here is the result running the program in background.'.
ENDIF.
WRITE:/ ls_vbak-vbeln,
ls_vbak-vkorg. -
Background Job is not creating the List ID
Hello Experts,
I am scheduling a program as a Background Job. When I go and check the tables TBTCP & TBTCO, I see the List ID field (TBTCP-LISTIDENT or TBTCO-LISTIDENT) value as 0 .
Hence I am not able to get the Spool ID for this List.
Can anybody please let me know what is the problem?
Thanks a lot.Hi,
See, if this piece of code can help you.
data: sdate type sy-datum,
stime type sy-uzeit,
l_valid,
ls_params like pri_params,
l_jobcount like tbtcjob-jobcount,
l_jobname like tbtcjob-jobname.
start-of-selection.
Get Print Parameters
call function 'GET_PRINT_PARAMETERS'
exporting
no_dialog = 'X'
importing
valid = l_valid
out_parameters = ls_params.
Open Job
l_jobname = 'THIS_JOB'.
call function 'JOB_OPEN'
exporting
jobname = l_jobname
importing
jobcount = l_jobcount.
Submit report to job
submit <your_program_name
via job l_jobname
number l_jobcount
to sap-spool without spool dynpro
spool parameters ls_params
and return.
Kick job off 10 seconds from now.
sdate = sy-datum.
stime = sy-uzeit + 10.
Schedule and close job.
call function 'JOB_CLOSE'
exporting
jobcount = l_jobcount
jobname = l_jobname
sdlstrtdt = sdate
sdlstrttm = stime.
<REMOVED BY MODERATOR>
Edited by: Alvaro Tejada Galindo on Mar 3, 2008 11:09 AM
Maybe you are looking for
-
"Restrictions Do Not Allow Explicit Content"???
Downloaded a few podcasts yesterday. Listened to one of them on the ride home last night (from my iPhone, after syncing). Tried to pick up where I left off this morning, and these particular podcasts are "grayed out" and, when tapped, say "Content
-
Application interface blanks out....
Hi I've written a rather large Java program. I've never been very interested in the GUI side of things, but as a consequence of people complaining that my GUI was non-intuitive I've had to redo it. Anyway, I've just recently noticed that when the bac
-
Premiere Elements 12 Running Slow
Hi, I recently purchased this program and installed it on my MacBook Pro 13.3" Late 2013, 2.4 GHz Dual Core i5 Processor, 8 GB 1600 MHz DDR3 RAM, Intel Iris 1024 MB Video Card, 256 GB Sold State Drive, and I have the external USB SuperDrive for DVD b
-
Short cut for Radio buttons (using Ctrl+ key)
How can I select deselect Radio buttons using Ctrl + keys. I know that setMnemonic can be used to access using Alt + key. But I want to use Ctrl also. Please suggest the solution. How can I select using only single key?
-
Who can give me all the name of system table or organization table in sap?
Who can give me all the name of system table or organization table in sap? such as the table stores the client,company code ,plant,transaction code ,sap menu,purchase organization along with the relation between organizations such as the relation bet