I am starting some job using the events and obtaining the qid of the job during runtime but sometimes the qid being obained is wrong and hence not the right job being started.
The query/Logic to obtain the Qid is as follows.
SELECT * INTO TABLE lt_qid
WHERE groupid = gc_jobname AND
creator = sy-uname AND
credate = sy-datum.
SORT lt_qid DESCENDING BY cretime.
LOOP AT lt_qid INTO ls_qid.
IF ls_qid-qstate IS INITIAL.
lv_qid = ls_qid-qid.
Here i am considering that the job which is newly created is having the status as Initial and hence taking that for further processing.
sometimes this logic is getting me the qid of the previous job which is already finished and having the status as Finsihed (F).
Any Hints please !