on 06-28-2017 6:11 PM
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.
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.)
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
69 | |
14 | |
8 | |
5 | |
5 | |
5 | |
5 | |
4 | |
3 | |
3 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.