cancel
Showing results for 
Search instead for 
Did you mean: 

JOB_OPEN, SUBMIT, JOB_CLOSE working only if debugging

Former Member

Hi,

I need to get the ID queue of a batch input (BI), but I cannot.. It's very strange, but that combination doesnt work properly.. I saw this code in a post, and I used it for my program. But I run and it doesnt work: it_apqi is empty (I need it to get ID queue of BI).

If I debug in line BDC_OBJECT_SELECT or previous, I see my BI in SM35, and with F6 key, I get it_bdcdata is filled with one line with info of my BI (ID queue inside). However, if I run directly program, or if I debug in line 'CLEAR quid' or after, and move on with F6 key, it_bdcdata is empty (but I can see BI is generated in SM35). Please help me, I'm desperated..

Thank you so much in advance,

Kind Regards,

Pedro

  CALL FUNCTION 'JOB_OPEN'
     EXPORTING
        jobgroup = ' '
        jobname  = jobname
        sdlstrtdt = sy-datum
     IMPORTING
        jobcount = jobcount.
 
  SUBMIT ZHREDSUTILR6000
       WITH SELECTION-TABLE seltab
       USING SELECTION-SCREEN 1000
       USING SELECTION-SET 'Z_ALTAS'
       WITH pnpbegda  EQ pn-begda     
       WITH s_ejerci EQ pn-begda(4)
       WITH ACDI EQ p_ejdir2
       WITH BAIN EQ p_ejbi2
    VIA JOB jobname NUMBER jobcount
    AND RETURN.
    "SUBMIT generates BI called 'ZHREDSR6000'
 
  CALL FUNCTION 'JOB_CLOSE'
    EXPORTING
      jobcount = jobcount
      jobname  = jobname.
   
  "getting ID queue of BI
  CALL FUNCTION 'BDC_OBJECT_SELECT'
      EXPORTING
        name      = 'ZHREDSR6000'
        datatype  = 'BDC'
        client    = sy-mandt
        date_from = sy-datum
      TABLES
        apqitab   = it_apqi.
    
  CLEAR qid.
  READ TABLE it_apqi INTO wa_apqi INDEX 1.
  qid = wa_apqi-qid.
  "getting content of BI
  CALL FUNCTION 'BDC_OBJECT_READ'
      EXPORTING
        queue_id         = qid
      TABLES
        dynprotab        = it_bdcdata
      EXCEPTIONS
        NOT_FOUND        = 1
        SYSTEM_FAILURE   = 2
        INVALID_DATATYPE = 3.
Sandra_Rossi
Active Contributor

Your question is a little confusing about which scenario you have tested, and which ones work or not :

  1. background job returns empty APQI
  2. dialog run returns correct APQI
  3. I don't understand your third scenario, I'm confused

One more thing : how many application servers do you have ? (SM51)

Former Member
0 Kudos

Hi Rossi,

Not completely sure about what means background job and dialog run, and I dont know TC SM51 (I'm abap programmer rookie), but in my report I need to submit report ZHREDSR6000 (because it generates a BI in SM35), and read that BI to get the info inside and show in ALV display result. So what is working and what not:

-If run report/code, it doesn't work.

-If run report with breakpoint in line 'CALL FUNCTION 'BDC_OBJECT_SELECT'' or previous, it works.

- If run report with breakpoint in line 'CLEAR qid' or later, it doesn't work.

If it Works, I mean it_apqi is with info of BI generated in SUBMIT previous statement. This BI also called ZHREDSR6000 is posible to check in SM35 in another window. It's really strange, it's first time I see something similar.. Tomorrow I'll check SM51, and try to find out more about BDC_OBJECT_SELECT, if I got any clue I'll post it.

Thanks, KR;

Pedro

Accepted Solutions (0)

Answers (3)

Answers (3)

raymond_giuseppi
Active Contributor

You should at least wait til the background job terminated before reading the results (e.g. on peak hours, even an immediate job may wait some time in queue)

(Look for FM similar to SHOW_JOBSTATE.)

armin_beil_2
Advisor
Advisor

If there is a difference in debugging or not debugging this could indicate a timing issue between parallel running processes.

To verify this you could try to add something like 'wait up to 10 seconds.' one line above the 'CALL FUNCTION 'BDC_OBJECT_SELECT' and check whether the program then works also without debugging. Maybe this function module 'BDC_OBJECT_SELECT' tries to operate on some results of the job and the results might be not yet available at that point in time but are available if you introduce some delay (e.g. by debugging).

You should also check the title in the debugger window to see whether it's an exclusive or non-exclusive debug session. Usually it should be exclusive; Non-exclusive mode might have some influence on the way the program runs in rare cases.

Best regards,
Armin

Edit: Waiting 10 seconds is not a solution proposal. I just recommended to do this in order to verify whether it's a timing issue or not.

Former Member
0 Kudos

Hi Armin, Raymond,

I tried and it works! It seems instruction JOB_CLOSE needs time to generate BI, and the code 'wait up to 10 seconds.' between JOB_CLOSE and BDC_OBJECT_SELECT allows to get the BI.
Later I tried with JOB_SHOWSTATE, and it's even more efficient, because it's inside a DO loop, and program waits only the necessary until BI is created.

Both of you, thanks a lot!


KR,
Pedro