Problem Submit Via Job in BADI
Hello All
I am using SUBMIT VIA JOB in BADI "work order update" and but no job is created....also sy-subrc is 0.
Here is the code
call function 'JOB_OPEN'
exporting
jobname = name
importing
jobcount = number
exceptions
cant_create_job = 1
invalid_job_data = 2
jobname_missing = 3
others = 4.
if sy-subrc = 0.
submit z_idoc_create_process_order and return
via job name number number
with p_aufnr = it_header1-aufnr
with p_werks = it_header1-werks
with p_autyp = c_autyp
with p_auart = it_header1-auart
with p_dispo = it_header1-dispo
with p_opt = c_opt
with p_mestyp = c_mestyp.
if sy-subrc = 0.
call function 'JOB_CLOSE'
exporting
jobcount = number
jobname = name
strtimmed = 'X'
exceptions
cant_start_immediate = 1
invalid_startdate = 2
jobname_missing = 3
job_close_failed = 4
job_nosteps = 5
job_notex = 6
lock_failed = 7
others = 8.
if sy-subrc <> 0.
endif.
Any reason why job is not created?
Thanks in advance.
regads
VInit
Hi guys,
I tried this
SUBMIT z_idoc_create_process_order USER creator using selection-set lv_variant TO SAP-SPOOL
SPOOL PARAMETERS print_parameters
WITHOUT SPOOL DYNPRO
WITH p_aufnr EQ it_header1-aufnr
WITH p_werks EQ it_header1-werks
WITH p_autyp EQ c_autyp
WITH p_auart EQ it_header1-auart
WITH p_dispo EQ it_header1-dispo
WITH p_opt EQ c_opt
WITH p_mestyp EQ c_mestyp
VIA JOB name NUMBER number
AND RETURN.
Now the job is getting created but my Variant has no values
How to pass values to variant? below values are not getting tranferred.
WITH p_aufnr EQ it_header1-aufnr
WITH p_werks EQ it_header1-werks
WITH p_autyp EQ c_autyp
WITH p_auart EQ it_header1-auart
WITH p_dispo EQ it_header1-dispo
WITH p_opt EQ c_opt
WITH p_mestyp EQ c_mestyp
Similar Messages
-
Submit via Job- problem in code
I need to convert the PR to PO automatically, we can do this by me59n, so iam scheduling the job for the me59n program. here iam using Badi's, iam getting the PR, plant, vendor from IM_Eban from the method of Badi, reading this in internal table, zeban. now when the execute the transaction(va01) and saving, PR shouls be converted to PO. i would like to have guys look into the code, and pl correct this.
method IF_EX_ME_REQ_POSTED~POSTED .
DATA: ACTUAL_JOBNAME type tbtcjob-JOBNAME value 'Z_TEST2',
JOBCOUNT type tbtcjob-JOBCOUNT,
MSG(60) TYPE C,
STIME TYPE SY-UZEIT.
DATA: ZEBAN TYPE UEBAN.
DATA: P_BANFN(10) TYPE N.
read table IM_EBAN into Zeban index 1.
*Open the Job
CALL FUNCTION 'JOB_OPEN' " OPENING JOB
EXPORTING
JOBNAME = ACTUAL_JOBNAME " JOB NAME
IMPORTING
JOBCOUNT = JOBCOUNT.
DATA SELTAB type table of RSPARAMS.
data : sel_wa type rsparams.
Populate internal table.
MOVE: 'S_EKGRP' TO SEL_wa-SELNAME,
'I' TO SEL_WA-SIGN,
'EQ' TO SEL_WA-OPTION,
'S' TO SEL_wa-KIND,
Zeban-ekgrp TO sel_wa-LOW.
APPEND sel_wa to SELTAB.
CLEAR SEL_WA.
MOVE: 'S_FLIEF' TO SEL_wa-SELNAME,
'I' TO SEL_WA-SIGN,
'EQ' TO SEL_WA-OPTION,
'S' TO SEL_wa-KIND,
Zeban-flief TO sel_wa-LOW.
APPEND sel_wa to SELTAB.
CLEAR SEL_WA.
MOVE: 'S_WERKS' TO SEL_wa-SELNAME,
'I' TO SEL_WA-SIGN,
'EQ' TO SEL_WA-OPTION,
'S' TO SEL_wa-KIND,
Zeban-werks TO sel_wa-LOW.
APPEND sel_wa to SELTAB.
CLEAR SEL_WA.
MOVE: 'P_GBANFN' TO SEL_WA-SELNAME,
'P' TO SEL_WA-KIND,
'X' TO SEL_WA-LOW.
APPEND SEL_WA TO SELTAB.
CLEAR SEL_WA.
MOVE: ZEBAN-BANFN TO P_BANFN.
MOVE: 'S_BANFN' TO SEL_WA-SELNAME,
'I' TO SEL_WA-SIGN,
'EQ' TO SEL_WA-OPTION,
'S' TO SEL_WA-KIND,
P_BanfN TO SEL_WA-LOW,
SPACE TO SEL_WA-HIGH.
APPEND SEL_WA TO SELTAB.
CLEAR SEL_WA.
MOVE: 'P_VRTYPK' TO SEL_WA-SELNAME,
'P' TO SEL_WA-KIND,
'X' TO SEL_WA-LOW.
APPEND SEL_WA TO SELTAB.
SUBMIT RM06BB30 VIA JOB ACTUAL_JOBNAME
NUMBER JOBCOUNT
TO SAP-SPOOL DESTINATION 'NULL'
WITHOUT SPOOL DYNPRO
WITH SELECTION-TABLE SELTAB
AND RETURN.
STIME = SY-UZEIT + 900.
*Schedule the job after 15 min and Close the job.
CALL FUNCTION 'JOB_CLOSE' " CLOSING JOB
EXPORTING
JOBNAME = ACTUAL_JOBNAME
JOBCOUNT = JOBCOUNT
STRTIMMED = 'X'
TARGETSYSTEM = SY-HOST.
LASTSTRTTM = STIME.
endmethod.Hi,
Could you please let us know, what is the error you are getting.
Best regards,
Prashant -
Hello everyone,
I have a problem with the submit statement. I am submitting a report in the background so it won't show popup messages. The problem is that the popup messages are still displayed. When I debug, the report gets executed immediately at the submit statement, and possibly also afterwards in the background.
There are a few similar threads here, but none seem to have a solution. Here is my code:
CONCATENATE 'Create_material_' i_stockid INTO v_jobname .
CALL FUNCTION 'JOB_OPEN'
EXPORTING
DELANFREP = ' '
JOBGROUP = ' '
jobname = v_jobname
SDLSTRTDT = NO_DATE
SDLSTRTTM = NO_TIME
JOBCLASS =
IMPORTING
jobcount = v_jobcount
CHANGING
RET =
EXCEPTIONS
cant_create_job = 1
invalid_job_data = 2
jobname_missing = 3
OTHERS = 4
IF sy-subrc <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
SUBMIT zfl046_mm_flex_stock_matact AND RETURN
USER sy-uname
WITH pa_stid = i_stockid
VIA JOB v_jobname
NUMBER v_jobcount
TO SAP-SPOOL KEEP IN SPOOL 'X'
WITHOUT SPOOL DYNPRO.
CALL FUNCTION 'JOB_CLOSE'
EXPORTING
jobname = v_jobname
jobcount = v_jobcount
strtimmed = 'X'
IMPORTING
job_was_released = v_job_released
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 = 99.
IF sy-subrc <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
Any ideas why the popups still show, or why it executes the submit in the foreground?
Thanks for everything that might help
Message was edited by: Vandersteen Jorg
Message was edited by: Vandersteen JorgI've tried your suggestions, but it does not seem to help.
This is my code now:
DATA: v_jobcount TYPE tbtcjob-jobcount,
v_jobname TYPE tbtcjob-jobname,
v_job_released TYPE btch0000-char1,
g_print_params LIKE pri_params,
g_valid_flag.
CONCATENATE 'Create_material_' i_stockid INTO v_jobname .
CALL FUNCTION 'GET_PRINT_PARAMETERS'
EXPORTING
archive_mode = '1'
mode = 'BATCH'
report = 'ZFL046_MM_FLEX_STOCK_MATACT'
no_dialog = 'X'
IMPORTING
out_parameters = g_print_params
valid = g_valid_flag.
CALL FUNCTION 'JOB_OPEN'
EXPORTING
DELANFREP = ' '
JOBGROUP = ' '
jobname = v_jobname
SDLSTRTDT = NO_DATE
SDLSTRTTM = NO_TIME
JOBCLASS =
IMPORTING
jobcount = v_jobcount
CHANGING
RET =
EXCEPTIONS
cant_create_job = 1
invalid_job_data = 2
jobname_missing = 3
OTHERS = 4
IF sy-subrc <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
SUBMIT ZFL046_MM_FLEX_STOCK_MATACT
TO SAP-SPOOL SPOOL PARAMETERS g_print_params
WITHOUT SPOOL DYNPRO
USER sy-uname
WITH pa_stid = i_stockid
VIA JOB v_jobname
NUMBER v_jobcount
AND RETURN.
CALL FUNCTION 'JOB_CLOSE'
EXPORTING
jobname = v_jobname
jobcount = v_jobcount
strtimmed = 'X'
IMPORTING
job_was_released = v_job_released
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 = 99.
IF sy-subrc <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF. -
I have an ABAP wrapper program that generates a job with multiple steps using JOB_OPEN, SUBMIT...VIA JOB and JOB_CLOSE. The generated job will have multiple steps and each step can have an error message. How do I code SUBMIT statement to allow processing of subsequent steps even if error or do I have to use JOB_SUBMIT and then what setting would I then use for that scenario?
I think it will not be possible to continue to the next step in a multi-step job if the previous one has ended in error.
If you need this, you shall probably define these as independent jobs. -
SUBMIT VIA JOB MESSAGE TYPE 'E'
Hi!
Please help me, I can't use submit via background job, because he can't handle message errors of type 'E'. When this kind of message occurs, all background processing stops and I get a report screen with this message in the status bar.
Is there any solution?Let me understand this. You have a program A from which you submit a program B in the background and if in program B an error is raised, your program A execution stops. Is this true?
Did you do a job close in your code. Here is a sample program ZTEST1 that submits another program ZTEST2 in the background. If there is an error message thrown out in ZTEST2, the job submitted is cancelled, with the job log showing the error message. The processing of ZTEST1 continues even after that.
I don't know why yours is not. Please let us know.
<u>Program ZTEST1</u>
REPORT ztest1 .
PARAMETERS: p_matnr1 LIKE mara-matnr.
DATA: v_jobcount LIKE tbtcjob-jobcount,
v_jobname LIKE tbtcjob-jobname.
START-OF-SELECTION.
v_jobname = 'TESTJOB'.
*-- open the job
CALL FUNCTION 'JOB_OPEN'
EXPORTING
jobname = v_jobname
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 sy-msgty NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ENDIF.
*-- submit the report
SUBMIT ztest2 WITH p_matnr2 = p_matnr1
USER sy-uname VIA JOB v_jobname
NUMBER v_jobcount AND RETURN.
*-- close the job
CALL FUNCTION 'JOB_CLOSE'
EXPORTING
jobcount = v_jobcount
jobname = v_jobname
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 sy-msgty NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ENDIF.
WRITE:/ 'Job submitted successfully.'.
<u>Program ZTEST2</u>
REPORT ztest2 MESSAGE-ID zz.
PARAMETERS: p_matnr2 LIKE mara-matnr.
DATA: itab LIKE mara OCCURS 0 WITH HEADER LINE.
START-OF-SELECTION.
SELECT * INTO TABLE itab FROM mara
WHERE matnr = p_matnr2.
IF sy-subrc <> 0.
MESSAGE e000 WITH 'Invalid material number'.
ENDIF.
LOOP AT itab.
WRITE:/ itab-matnr.
ENDLOOP. -
Hello all
I m creating a program to delete old entries from tables.This can be done
1. Foreground
2. Background
I have created 2 reports
Report A - MAin report
Report B -has the following stmts
REPORT b.
DATA: i_JOBCOUNT LIKE TBTCJOB-JOBCOUNT,
i _JOBNAME LIKE TBTCJOB-JOBNAME .
SUBMIT A AND RETURN
USER SY-UNAME
VIA JOB I_JOBNAME NUMBER I_JOBCOUNT
In the background option of report A I have used
job_open with jobname as Report A.
Submit B
user sy-uname
via jobname jobnumber
and return.
Job_close
with jobname, jobnumbr and start immediately = 'x'.
Now when I execute this pgm with foreground option,
I get the records deleted from the table
but the same does not happen in background option.
kindly guide me.
Thanks
TharaniHi
Why don't you run the report A directly in background mode?
Anyway your report should be:
va_jobname = <REPORT B>
CALL FUNCTION 'JOB_OPEN'
EXPORTING
JOBNAME = VA_JOBNAME
IMPORTING
JOBCOUNT = VN_JOBCOUNT
EXCEPTIONS
CANT_CREATE_JOB = 1
INVALID_JOB_DATA = 2
JOBNAME_MISSING = 3
OTHERS = 4.
IF SY-SUBRC = 0.
SUBMIT <REPORT A> USER SY-UNAME
VIA JOB VA_JOBNAME NUMBER VN_JOBCOUNT
AND RETURN.
CALL FUNCTION 'JOB_CLOSE'
EXPORTING
JOBCOUNT = VN_JOBCOUNT
JOBNAME = VA_JOBNAME
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 NE 0.
MESSAGE E999 WITH TEXT-E05.
ENDIF.
ENDIF.
Max -
Problem submitting RFEBKA00 via Job
Hi experts
I have a requirement to create a Z program to upload 3 different files by using RFEBKA00.
For this purpouse, I have created a Z program which creates 3 Z jobs (ZA, ZB, ZC one per file) using JOB_OPEN / SUBMIT program VIA JOB / JOB_CLOSE.
Once every job is finished, I need to read logs using BP_JOBLOG_READ,and if there are no errors, move files to other folder.
My questions are:
1.- When using JOB_OPEN and SUBMIT VIA JOB name NUMBER n, as far as I know n is the number returned by jobcount parameter from JOB_OPEN and should be the same for both jobs (the Zjob created by JOB_OPEN and the one created by program RFEBKA00).When I debbug the program, it is OK, but when accessing table TBTCO sometimes there are 2 different jobcounts. Seems that jobcount is created based on sy-uzeit and sometimes there is some delay between JOB_OPEN and SUBMIT. Is there any way to ensure both jobs have the same jobcount?.
2.- As I need to read the log for each file, and because of the fact that the job created by submitting RFEBKA00 has always the same name, if the answer to my first question is NO, how can I link each of my Z jobs with its corresponding RFEBKA00 job?.
Many thanks in advance for your answers.
BR,
Carlos.Hi Thomas
Thanks for your answer.
For your first question, there is not BD key problem beacuse of my job is ZJOB and the one created when doing submit via job is RFEBKA00-EXTR.CTA.EL. (standard job) have different names.
But job number should be the same, because I'm using JOB_OPEN (which return the job number in parameter jobcount) and SUBMIT VIA JOB .
For the second question, and based on SAP documentation about SUBMIT , when submitting a program vía job, the submitted program is executed as a background task, which means creating a new job, so the answers is yes, the standard program schedules a new job. -
Problem in submiting standard program via job
Hi Experts ,
I have developed programs for creating and posting return lots and payment lots for multiple incoming files. For this i have submited standard program of FPB3 and FPB5 transaction . What happened is , if the child program fails due to some reason for one file , it is not coming back to the mother program and as a result other files remain unprocessed . So for this i tried with submiting the child program Via job so that if child program fails , only that job will fail and the mother program will not fail , so rest files will be processed .
But the problem is the child program (standard program of FPB3/FPB5 ) is not working by this i.e. the lots are not getting created adn.
Awaiting for any respone .Hi,
If you are using Submit via Job, you need to use JOB_OPEN and JOB_CLOSE FM's.
JOB_OPEN : Create a new job and return you the job number which you use in Submit
JOB_CLOSE: Will set the release conditions of the job.
Example:
DATA: number TYPE tbtcjob-jobcount,
name TYPE tbtcjob-jobname VALUE 'JOB_TEST',
print_parameters TYPE pri_params.
CALL FUNCTION 'JOB_OPEN'
EXPORTING
jobname = name
IMPORTING
jobcount = number
EXCEPTIONS
cant_create_job = 1
invalid_job_data = 2
jobname_missing = 3
OTHERS = 4.
IF sy-subrc = 0.
SUBMIT submitable TO SAP-SPOOL
SPOOL PARAMETERS print_parameters
WITHOUT SPOOL DYNPRO
VIA JOB name NUMBER number
AND RETURN.
IF sy-subrc = 0.
CALL FUNCTION 'JOB_CLOSE'
EXPORTING
jobcount = number
jobname = name
strtimmed = 'X'
EXCEPTIONS
cant_start_immediate = 1
invalid_startdate = 2
jobname_missing = 3
job_close_failed = 4
job_nosteps = 5
job_notex = 6
lock_failed = 7
OTHERS = 8.
IF sy-subrc <> 0.
ENDIF.
ENDIF.
ENDIF.
Regards,
Jovito -
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 -
Problem in creating job via submit
sap 4.7
i am opening/scheduling job from other program/job
And from some reason i get two jobs with the same name.
One is working good, and the other one is stay in schedule.
My problem is , why i active two jobs and not only one ?
And why one (that I donu2019t want and need it at all ) is stay as "schedule" ?
this is my code
CONCATENATE EVT_ID JOBCOUNT INTO JOBNAME
SEPARATED BY SPACE.
LCL_TIME = SY-UZEIT + 1000 . " + 15 minute
CALL FUNCTION 'JOB_OPEN'
EXPORTING
JOBNAME = JOBNAME
IMPORTING
JOBCOUNT = JOBCOUNT. " AND RETURN
CALL FUNCTION 'JOB_OPEN'
EXPORTING
JOBNAME = JOBNAME
DELANFREP = SPACE
IMPORTING
JOBCOUNT = JOBCOUNT
EXCEPTIONS
CANT_CREATE_JOB = 1
INVALID_JOB_DATA = 2
JOBNAME_MISSING = 3
OTHERS = 4.
if sy-subrc <> 0 .
MESSAGE I099 WITH 'cant craete job' .
endif.
SUBMIT YITF_MOVE_TO_BCKP
VIA JOB JOBNAME NUMBER JOBCOUNT
TO SAP-SPOOL IMMEDIATELY ' '
DESTINATION 'LOCL'
KEEP IN SPOOL 'X'
WITHOUT SPOOL DYNPRO
WITH EVT_PARM = EVT_PARM
AND RETURN.
CALL FUNCTION 'JOB_CLOSE'
EXPORTING
JOBCOUNT = JOBCOUNT
JOBNAME = JOBNAME
SDLSTRTDT = SY-DATUM "i_strtdt
SDLSTRTTM = LCL_TIME
STRTIMMED = 'X'
this is the status in sm37
YITF_MFHBHY_LOAD 03304501 LEGACY Scheduled
YITF_MFHBHY_LOAD 03304501 LEGACY Complete 04.03.2009 03:49:05Hi use this Code to fix the issue...
DATA : v_jobhead LIKE tbtcjob.
DATA : v_jobcount LIKE tbtcjob-jobcount.
DATA : v_eventparm LIKE tbtcjob-eventparm.
DATA : v_flg_released TYPE c.
DATA: e_error.
DATA: running LIKE tbtcv-run.
TYPES: esp1_boolean LIKE boole-boole.
CONSTANTS: esp1_false TYPE esp1_boolean VALUE ' ',
esp1_true TYPE esp1_boolean VALUE 'X'.
CONSTANTS: true TYPE boolean VALUE esp1_true,
false TYPE boolean VALUE esp1_false.
PARAMETERS: v_jobnam LIKE tbtcjob-jobname,
v_report LIKE sy-repid,
v_varian LIKE raldb-variant,
v_uname LIKE sy-uname.
START-OF-SELECTION.
* add the new job
CALL FUNCTION 'JOB_OPEN'
EXPORTING
* delanfrep = 'X'
jobname = v_jobnam
IMPORTING
jobcount = v_jobcount
EXCEPTIONS
cant_create_job = 1
invalid_job_data = 2
jobname_missing = 3
OTHERS = 4.
IF sy-subrc 0.
e_error = true.
ELSE.
CALL FUNCTION 'JOB_SUBMIT' " or you can use SUBMIT statement as well.
EXPORTING
authcknam = v_uname
jobcount = v_jobcount
jobname = v_jobnam
report = v_report
variant = v_varian
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.
e_error = true.
ELSE.
CALL FUNCTION 'JOB_CLOSE'
EXPORTING
* EVENT_ID = IC_WWI_WORKPROCESS_EVENT
* EVENT_PARAM = V_EVENTPARM
* EVENT_PERIODIC = 'X'
jobcount = v_jobcount
jobname = v_jobnam
strtimmed = 'X'
IMPORTING
job_was_released = v_flg_released
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.
e_error = true.
ELSE.
DO.
CALL FUNCTION 'SHOW_JOBSTATE'
EXPORTING
jobcount = v_jobcount
jobname = v_jobnam
* IMPORTING
* ABORTED =
* FINISHED =
* PRELIMINARY =
* READY =
* running =
* SCHEDULED =
EXCEPTIONS
jobcount_missing = 1
jobname_missing = 2
job_notex = 3
OTHERS = 4.
IF sy-subrc 0.
e_error = true.
MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ENDIF.
IF running = space.
EXIT.
ENDIF.
ENDDO.
ENDIF.
ENDIF.
ENDIF. -
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. -
JOB_OPEN, SUBMIT REPORT VIA JOB, JOB_CLOSE, How to get result?
Hi Friends,
I am calling reports using jobs as calling job_open, submit report via job.., and job_close. But I want to the output/result of the report. How can I do this?
Thanks.Hello nkara,
Welcome to SDN!!!
Check this thread:
background grid
REgards,
Vasanth -
Submit a transaction O4B1 via job and the result as an attachment Excel
Hi, I'm executing a program in background via job to get back the result of a report as an attachment XLS on mail. the result of my program give me just title of Excel columns , but when i execute it manually , the result is perfect.
my code is : ******************************FORM MAIL******************************* FORM mail. CONCATENATE 'Expédition' 'TExp' 'PtOT' 'Crée' 'Crée le' 'St.' 'Déb. chargt' 'Désignation' 'Div.' 'Doc. vente' 'Réceptionnaire' 'Nom1' 'Nom2' 'Volume' 'UQ' INTO it_mess_att SEPARATED BY con_tab. CONCATENATE con_cret it_mess_att INTO it_mess_att. APPEND it_mess_att. CONCATENATE SPACE SPACE INTO it_mess_att SEPARATED BY con_tab. CONCATENATE con_cret it_mess_att INTO it_mess_att. APPEND it_mess_att. *CLEAR it_mess_att. LOOP AT it_tab into wa_tab. *VAL = it_tab-ZQTEMAX. CONCATENATE wa_tab-SHNUMBER wa_tab-SHTYPE wa_tab-TPLST wa_tab-CRE_NAME wa_tab-CRE_DATE wa_tab-OIG_SSTSF wa_tab-LOAD_STDTA wa_tab-VMODE_TEXT wa_tab-WERKS wa_tab-VBELN wa_tab-KUNNR wa_tab-NAME1 wa_tab-CARRIER_DE wa_tab-WGT_UOM INTO it_mess_att SEPARATED BY con_tab. CONCATENATE con_cret it_mess_att INTO it_mess_att. APPEND it_mess_att. *CLEAR it_mess_att. ENDLOOP. ENDFORM. *************************FORM SEND_MAIL******************************* FORM send_mail . DATA: send_request TYPE REF TO cl_bcs, document TYPE REF TO cl_document_bcs, recipient TYPE REF TO cl_cam_address_bcs, bcs_exception TYPE REF TO cx_bcs, sent_to_all TYPE os_boolean, lt_fields TYPE TABLE OF w3fields, lt_html TYPE TABLE OF w3html. DATA: ld_error TYPE sy-subrc, ld_reciever TYPE sy-subrc, ld_mtitle LIKE sodocchgi1-obj_descr, ld_email LIKE somlreci1-receiver, ld_format TYPE so_obj_tp , ld_attdescription TYPE sopcklsti1-obj_descr, ld_attfilename TYPE so_obj_des , ld_sender_address LIKE soextreci1-receiver, ld_sender_address_type LIKE soextreci1-adr_typ, ld_receiver LIKE sy-subrc. DATA: t_packing_list LIKE sopcklsti1 OCCURS 0 WITH HEADER LINE, t_contents LIKE solisti1 OCCURS 0 WITH HEADER LINE, t_receivers LIKE somlreci1 OCCURS 0 WITH HEADER LINE, t_attachment LIKE solisti1 OCCURS 0 WITH HEADER LINE, t_object_header LIKE solisti1 OCCURS 0 WITH HEADER LINE, w_cnt TYPE i, w_sent_all(1) TYPE c, w_doc_data LIKE sodocchgi1. *MOVE p_email TO mailid. ***************ADD ADRESS MAIL************** p_email1-RECEIVER = mail . append p_email1. ********************************************* ld_email = mail. ld_mtitle = gd_attachment_desc. ld_format = 'XLS'. * ld_attdescription = gd_attachment_desc. ld_attdescription = 'Liste expéditions PN'. CONCATENATE ld_attdescription '.XLS' INTO ld_attfilename. * ld_attfilename = p_filename. ld_sender_address = w_sender. ld_sender_address_type = 'INT'. * Fill the document data. w_doc_data-doc_size = 1. * Populate the subject/generic message attributes w_doc_data-obj_langu = sy-langu. w_doc_data-obj_name = 'SAPRPT'. w_doc_data-obj_descr = ld_mtitle . w_doc_data-sensitivty = 'F'. * Fill the document data and get size of attachment CLEAR w_doc_data. READ TABLE it_mess_att INDEX 1. w_doc_data-doc_size = ( w_cnt - 1 ) * 255 + STRLEN( it_mess_att ). w_doc_data-obj_langu = sy-langu. w_doc_data-obj_name = 'SAPRPT'. w_doc_data-obj_descr = gd_attachment_desc. w_doc_data-sensitivty = 'F'. CLEAR t_attachment. REFRESH t_attachment. * t_attachment[] = it_attach[] . * Describe the body of the message clear t_packing_list. REFRESH t_packing_list. t_packing_list-transf_bin = space. t_packing_list-head_start = 1. t_packing_list-head_num = 0. t_packing_list-body_start = 1. DESCRIBE TABLE it_mess_bod LINES t_packing_list-body_num. t_packing_list-doc_type = 'RAW'. APPEND t_packing_list. * Create attachment notification t_packing_list-transf_bin = 'X'. t_packing_list-head_start = 1. t_packing_list-head_num = 1. t_packing_list-body_start = 1. DESCRIBE TABLE it_mess_att LINES t_packing_list-body_num. t_packing_list-doc_type = ld_format. t_packing_list-obj_descr = ld_attdescription. t_packing_list-obj_name = ld_attfilename. t_packing_list-doc_size = t_packing_list-body_num * 255. APPEND t_packing_list. * Add the recipients email address CLEAR t_receivers. REFRESH t_receivers. loop at p_email1. t_receivers-receiver = p_email1-receiver. t_receivers-rec_type = 'U'. t_receivers-com_type = 'INT'. t_receivers-notif_del = 'X'. t_receivers-notif_ndel = 'X'. APPEND t_receivers. endloop. CALL FUNCTION 'SO_DOCUMENT_SEND_API1' EXPORTING document_data = w_doc_data put_in_outbox = 'X' sender_address = ld_sender_address sender_address_type = ld_sender_address_type commit_work = 'X' IMPORTING sent_to_all = w_sent_all TABLES packing_list = t_packing_list contents_bin = it_mess_att contents_txt = it_mess_bod receivers = t_receivers EXCEPTIONS too_many_receivers = 1 document_not_sent = 2 document_type_not_exist = 3 operation_no_authorization = 4 parameter_error = 5 x_error = 6 enqueue_error = 7 OTHERS = 8. * Populate zerror return code ld_error = sy-subrc. * Populate zreceiver return code LOOP AT t_receivers. ld_receiver = t_receivers-retrn_code. ENDLOOP. WAIT UP TO 5 SECONDS. SUBMIT rsconn01 WITH mode = 'INT' WITH output = 'X' AND RETURN. ENDFORM. " send_mailgood answer
-
Problem in Submit via selection screen statement
Dear Experts,
I have designed selection screen and a dialog screen 100. I am passing the selection screen values to dialog screen using Selection screen via selection screen statement. When i tried to change the values in dialog screen, it is not allowing me to do so and the values are not refreshed.
I have searched the SDN Forum, but not able to find the suitable thread.
Regards,
Ramesh Manoharan
Edited by: ramesh.manoharan on Mar 17, 2010 1:03 PMHi,
I have used the below statement to pass values the values from selection screen to dialog screen (Created as an Executable program)
Submit <pgm> via selection screen
with ...... .
Dialog screen is created as an executable program where i have created two subscreen area and populating the Selection Screen as subscreen by using the below statement:
selection-screen begin of screen <subscreen no.> as subscreen.
selection-screen end of screen <subscreen no.>.
The problem i am facing is that the values of selection screen are getting populated in the dialog screen. But when i tried to change the input values in the dialog selection screen. I am unable to do that and it is not showing the new entered values. Only the previous values are shown (got from selection screen from Submit via selection screen statement).
Kindly let me know where i am going wrong ? Kindly help me to overcome the problem .
Regards,
Ramesh Manoharan -
Hi,
I have problems when creating a job that is supposed to be run once in background. I use the common steps as described below. My problem is that the report is executed twice.
- First it is executed synchronously when the job is created
- Then it is executed in the normal job step as I want it to do
I don't want it to be executed the first time because it creates data!!!
Code:
CALL FUNCTION 'JOB_OPEN'
EXPORTING
jobname = w_jobid
IMPORTING
jobcount = w_jobnr
sdlstrtdt = sy-datum
sdlstrttm = sy-uzeit.
SUBMIT (p_prog)
WITH p_idocnr = p_idocno
USER p_user
VIA JOB w_jobid
NUMBER w_jobnr
AND RETURN.
CALL FUNCTION 'JOB_CLOSE'
EXPORTING
jobcount = w_jobnr
jobname = w_jobid
strtimmed = 'X'
IMPORTING
job_was_released = w_jobrel.
Does anyone have a clue of what I should do to prevent this?
// Regards HansHi again,
1. U are right.
2. It will happen if we use SUBMIT.
3. As per the help documentation,
it will run the program in separate session,
( as soon as submit statement comes)
4. and run the INITIALIZATION event.
The VIA JOB addition also loads the program accessed in a separate internal mode when the SUBMIT statement is executed and the system performs all the steps specified before START-OF-SELECTION. This means the events LOAD-OF-PROGRAM and INITIALIZATION are triggered and selection screen processing is performed. If the selection screen is not processed in the background when VIA SELECTION-SCREEN is specified, the user of the calling program can eidit it and schedule the program accessed in the background request using the function Place in Job. If the user cancels selection screen processing, the program is not scheduled in the background job. In both cases, execution of the program executed is completed after selection screen processing and the system returns to the calling program due to the AND RETURN statement.
regards,
amit m.
Maybe you are looking for
-
So at my work I have been trying to get my mac to connect to our server. There are a couple macs on campus and non of us can get on. I know that me and at least one more of these computers are running 10.3.9. I thought that I had read that Mac had is
-
How to import a album with multiple artists in the one album?
How do I import a album with multiple artists as the one album. Everytime I try to do this it does not collate it into one album, the other artists come up seperatley, also if this is possible can you set so that it works automatically everytime? Ho
-
Running Reports in RAR formely known as Compliance Calibrator
Hello, I am hoping that someone can assist me with trying to run a report that will give me a total count on these two criteria: But, can I get the Active Rules only: 1. by Risk Level 2. by Process Thanks, Valarie Sanders
-
Dear Gurus. I have crearted Import asset Purchase order then we have made finanvial entry and creating good receipt and post Part 1 Entry. Now I want to Post Part 2 entry using J1iex but when I Simulate I have got wrong value in RG23c AED. value com
-
Using win7 and IE I am unable to successfully download an interactive document for completion online
I use Window 7 and Internet Explorer and Acrobat XI to download an eletter for completion on line. The down is completed but the Acrobat window remains grey and no content is displayed and the window freezes.