02-15-2006 1:46 AM
How can I run the session automatically in background after creating it in SM35. I want to eliminate my users from going to SM35 and execute the session after uploading the data.
02-15-2006 1:59 AM
Hello Adriyan,
You can schedule the execution of BDC session using the program RSBDCSUB.
Thanks,
Venu
Message was edited by: Venu Cherupillil
Message was edited by: Venu Cherupillil
02-15-2006 2:04 AM
That is the problem. I have users that need to upload data and they are not techie guys. So our best solution is to run the session that we created automatically without the hassle of going to SM35 or scheduling the session.
02-15-2006 2:04 AM
02-15-2006 2:15 AM
How can I find the queue id once i created the session in abap.
Is it possible to incorporate or include RSBDCBTC in the program?
02-15-2006 2:34 AM
0. I think the other program(RSBTCSUB)is even better and you can create job for that too.
1. you can select from apqi with something like:
SELECT * FROM *APQI UP TO 1 ROWS
WHERE MANDANT = SY-MANDT
AND GROUPID = ???
and credate = sy-datum
AND QSTATE = 'R'.
2. you can create a job and submit a job, eg:
----
FORM schedule_next_bdc
----
Schedules a job to release a specific BDC session. *
----
FORM SCHEDULE_NEXT_BDC.
DATA: L_JOB_NAME LIKE G_JOB_NAME,
l_job_num LIKE TBTCJOB-JOBCOUNT.
MOVE APQI-GROUPID TO L_JOB_NAME.
CALL FUNCTION 'JOB_OPEN'
EXPORTING
JOBNAME = L_JOB_NAME
IMPORTING
JOBCOUNT = l_JOB_NUM
EXCEPTIONS
CANT_CREATE_JOB = 1
INVALID_JOB_DATA = 2
JOBNAME_MISSING = 3
OTHERS = 4.
IF SY-SUBRC NE 0.
PERFORM JOB_DELETE USING L_JOB_NAME l_JOB_NUM.
MESSAGE E999 WITH 'Job open failed - return code is: ' SY-SUBRC.
ELSE.
MESSAGE S999 WITH 'Job Name/Number for BDC session:'
L_JOB_NAME
l_JOB_NUM.
MESSAGE S999 WITH '...Queue ID:' APQI-QID.
ENDIF.
SUBMIT RSBDCBTC AND RETURN
WITH QUEUE-ID = APQI-QID
USER SY-UNAME
VIA JOB L_JOB_NAME NUMBER l_JOB_NUM.
IF SY-SUBRC NE 0.
PERFORM JOB_DELETE USING L_JOB_NAME l_JOB_NUM.
MESSAGE E999 WITH '...Abap submission to job failed. Abap='
SY-REPID 'RC=' SY-SUBRC.
ENDIF.
CALL FUNCTION 'JOB_CLOSE'
EXPORTING
JOBCOUNT = l_JOB_NUM
JOBNAME = L_JOB_NAME
STRTIMMED = 'X'
IMPORTING
JOB_WAS_RELEASED = G_JOB_RELEASED
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.
IF SY-SUBRC NE 0.
PERFORM JOB_DELETE USING L_JOB_NAME l_JOB_NUM.
MESSAGE E999 WITH '...Job closure failure. Return code='
SY-SUBRC.
ELSE.
MESSAGE S999 WITH '...Job scheduled OK. Name/Number:'
L_JOB_NAME
l_JOB_NUM.
ENDIF.
ENDFORM.
02-15-2006 3:03 AM
Instead if you want to run it immediately you can use CALL TRANSACTION method.
02-15-2006 3:54 AM
Adrian - you can submit RSBDCSUB from the program that creates the batch input session:
* Actuals
PERFORM open_batch_session USING p_sessa.
LOOP AT itab
WHERE NOT tot_inc IS initial.
itab-adj = itab-adj * -1.
CONCATENATE itab-fund '/' itab-cfc INTO zuonr.
PERFORM fill_bdc_header.
PERFORM fill_bdc_lines.
PERFORM post_entries.
PERFORM insert_batch_session USING 'FB01'.
itab-adj = itab-adj * -1.
ENDLOOP.
PERFORM close_batch_session.
perform start_batch_session using p_sessa.
FORM start_batch_session USING session_name.
COMMIT WORK.
SUBMIT rsbdcsub USING SELECTION-SET session_name AND RETURN.
ENDFORM. " START_BATCH_SESSION
Rob
Edited by: Rob Burbank on Jan 6, 2011 1:32 PM