Skip to Content
-1
Former Member
Jun 28, 2017 at 05:11 PM

JOB_OPEN, SUBMIT, JOB_CLOSE working only if debugging

319 Views Last edit Jun 28, 2017 at 05:57 PM 6 rev

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.