2010 Apr 29 5:14 PM
Dear All,
i have a program whose flow is like this
Begin.
1.get data from idoc.
2.create contract.
3. job open
4.job submit.
jobname= job name
program name = ABAP program ZUPDATE_CONTRACT( code to fetch the created contract(step2) & updating one field in contract)
5.job close.
End.Now, i want to reach the ABAP program ZUPDATE_CONTRACT .
I have already placed brkpoint there.
But it is not hit during execution.
and the field that i want to update also does not get updated.
Later if i execute the program zupdate_contract seperately, the field gets updated.
What could be the issue here.
Should i give a time gap between the contract creation and updation of the field?
Please guide.
Regs,
SuryaD.
2010 Apr 30 9:07 AM
Hi Surya,
If you want to debug a program running in background (and your second program is doing this) you have to "catch" that program's process in order to debug it. You can do this from the job overview or from the process overview (SM50/SM51).
As the other posters already pointed out must be sure the program flow did not already pass the code you want to debug. One way to achieve this is to add an additional wait to the program's code and catch the program fast enough.
Another way is to add a "breakable infinite loop" to the code like this:
data: break type char01.
message 'Break-point reached' type 'I'.
commit work.
loop.
if break = 'X'.
exit.
endif.
endloop.
... the code you actally want to debugThe message and the commit work is there in order to write a message into the job log. So once the message is shown in the job log you know the program is ready for debugging. Catch the job. in the debugger change the value of 'break' into 'X' and go on with single steps debugging the program just as usual.
Hope that helps,
Gerd
2010 Apr 29 5:20 PM
Hi SUrya,
Yes there should be some time gap tbetween creation and updating the same contract.
If you want to debug the program please put External debugging point nor break point.
Thanks
Naresh
2010 Apr 29 5:28 PM
Hi,
You are creating new batch job from your program which will be run in a seperate work process. System wont stop when you run the first program. Did you check the status of the job
created by your program? You can debug the batch job from SM37 and see what went wrong.(If job is finished/cancelled).
Debug from SM66 if the job is active.
Thanks,
Vinod.
2010 Apr 29 5:39 PM
Thanks for your response.
For your further information, please note that the ,
first program is for the inbound idoc that creates the "contract" .
second program sets/updates the field in the contract.
But what we are referring here as first and second program all these appear to be in same code.(program)
when i am debugging, i have seen that even before i reach the FM " job_open", i see that the contract is already created.
It is all in one place.
How will i know that these 2 executions are different entities.
please helpe me understand
Regs,
SuryaD.
2010 Apr 29 6:06 PM
Hi Surya,
Here you go...
SAP system has different type of work processes(Concept is Similar to servlets in JAVA).
eg: Dialog work process takes care of dialog programs executed in the system.
Background process does execution of batch jobs etc.
In your case, you are creating a seperate batch job. So once the job is created it runs indipendently of your current program. You can check this in debug mode.
You are able to see the correct results in debug mode because you have delay during debugging. Introduce wait time of say 5 seconds in your job program so that you have enough time for the data to be commited to database. This is very common issue when you try to create and change the document in the same execution.
If you still have the problem, create a function module of type update module, place job creation code in that FM and call that FM in UPDATE TASK mode. This will make sure that your job is created only after the contract data is commited to database as update modules are executed after the transaction COMMIT.
Hope you have got some idea.
Thanks,
Vinod.
2010 Apr 30 8:45 AM
Hi Vinod,
thanks for your time in helping me understand.
I debugged the code and on execution of the FM "JOB_SUBMIT", i get the error "Invalid_jobdata".
so the program is not taking me inside the code of the ABAP PROGRAM '/DS1/HM_CR_SCMI200_CON_REL'""
the code is like this.
CALL FUNCTION 'JOB_SUBMIT'
EXPORTING
authcknam = 'B_STIREL'
jobcount = l_num
jobname = '/DS1/HM_CR_SCMI200_CON_REL'
report = '/DS1/HM_CR_SCMI200_CON_REL'
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.
Here sy-subrc value = 3 for me.
whats the reason for this error.
Is this got something to do with the authcheck that is being passed?
Or is it got something to do with the variant that i have not passed?
please guide.
Regs,
Suryad.
Edited by: SuryaD on Apr 30, 2010 1:17 PM
Edited by: SuryaD on Apr 30, 2010 1:20 PM
2010 Apr 30 10:46 AM
Hi,
I am not sure but I think FM JOB_SUBMIT raises its exceptions using MESSAGE ... RAISING. So while debugging it might be worth a try to have a look at the SY-MSGxx variables once you come across the exception. Maybe the error message (if it is actually there as I hope) might give you an idea of what was wrong.
Regards,
Gerd Rother
2010 Apr 30 2:25 PM
Hi,
I can't find the program /DS1/HM_CR_SCMI200_CON_REL in my system. It looks like you are missing in supplying the mandatory selection screen values. You can try in below way.
clear w_job_cnt.
call function 'JOB_OPEN'
exporting
jobname = c_jobname "Your job name
importing
jobcount = w_job_cnt "Áfter execution You will get Job count here
exceptions
cant_create_job = 1
invalid_job_data = 2
jobname_missing = 3
others = 4.
if sy-subrc <> 0.
message e001(00) with 'Ërror in Job open'.
endif.
submit (c_program) "Your program name
USING SELECTION-SET "variant name"
user sy-uname
via job c_jobname
number w_job_cnt
and return.
"Check various additions of SUBMIT as per your requirement.
call function 'JOB_CLOSE'
exporting
jobcount = w_job_cnt
jobname = c_jobname
strtimmed = c_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.
Thanks,
Vinod.
2010 Apr 30 9:07 AM
Hi Surya,
If you want to debug a program running in background (and your second program is doing this) you have to "catch" that program's process in order to debug it. You can do this from the job overview or from the process overview (SM50/SM51).
As the other posters already pointed out must be sure the program flow did not already pass the code you want to debug. One way to achieve this is to add an additional wait to the program's code and catch the program fast enough.
Another way is to add a "breakable infinite loop" to the code like this:
data: break type char01.
message 'Break-point reached' type 'I'.
commit work.
loop.
if break = 'X'.
exit.
endif.
endloop.
... the code you actally want to debugThe message and the commit work is there in order to write a message into the job log. So once the message is shown in the job log you know the program is ready for debugging. Catch the job. in the debugger change the value of 'break' into 'X' and go on with single steps debugging the program just as usual.
Hope that helps,
Gerd
2010 Apr 30 9:48 AM
Any furhter inputs SDNers for the reason as to why we get the error "Invalid_jobdata"upon execution of the FM job_submit.
Regards,
SuryaD.
2010 Apr 30 2:38 PM
Hi Surya,
If your executing this in background there could be a problem with dynamic Varient creation
Please check your variant.
If it is problem with your dynaic varient creation check below steps.
1. First maintain a variable with values in table TVARV. This can be done from transaction STVARV. Later this variable needs to be assigned to the variant.
2. Next create the dynamic variant by pressing the SAVE button on the selection screen.
3. In the next screen (ABAP: Save as Variant) enter Variant name, description, set the u2018Selection variableu2019 (L) radio button and press u2018Selection variableu2019 push button.
4. In the next screen check that green traffic light is on under column T (T: Table variable from TVARV).
5. Now from the popup select the variable name created in Step1 and save the variant.
regards
Naresh
2010 May 01 6:31 PM
Hi All,
Thanks for your input.
to answer Naresh's statement " if you're executing this in background there could be a problem with dynamic Varient creation"
Please note that the program that i have does not have any variant.
the program does not have a selection screen so does not have variant.
I guess my query now is deviating from the subject title.
So i will close this thread and open a new one.
thanks for your inputs.
Regs,
SuryaD.