‎2006 Feb 09 3:59 AM
HI,
We Have this following Requirement.
1. Write a Z program that will submit a main ABAP Program multiple times.
2. Modify IF program to check table which is locked. Confirm if all runs for main ABAP Program are successful.
3. Create facility to modify ZINTF_CHECK table via sm30.
Can somebody throw some insights and ideas on it.
Thanks in advance.
Raj.
‎2006 Feb 09 4:02 AM
‎2006 Feb 09 4:02 AM
‎2006 Feb 09 4:05 AM
Kishan,
Your link doesnt work. Please check it again,
Thanks,
Raj.
‎2006 Feb 09 4:06 AM
Hi!
I found an example program description (copyright SAP), which looks being able to start new tasks immediately after a session is available again.
It's displayed in two columns: left with code, right with explanation - but here everything is places after each other. If it sounds more ABAP than English, then it's a new line...
Required Data
Input parameters:
PARAMETERS MAX_PROC_NUM type i.
Limits the maximum number of
parallel jobs. Alternatively, the
system uses as many jobs as can be
started in the system.
PARAMETERS SERV_GROUP type rfcgr.
Name of the server group that is to be
used (required entry for parallel
processing)
PARAMETERS TIMEOUT type I
Maximum waiting time after last package
sent
Further data
DATA STARTED type i value 0.
Counter for jobs started so far
DATA RETURNED type i value 0.
Counter for jobs finished so far
DATA RUNNING type i value 0.
Counter for jobs currently running
DATA PROC_NUM_LIMIT type i.
Current maximum value for the number of
jobs running in parallel
DATA NUM_LINES type i.
Number of work items in worklist
DATA TAB_IDX type i.
Table index of current package
DATA RESULT like sy-subrc.
Return value of aRFC
DATA WORK_ITEMS like standard table
of ???? occurs 0.
Internal table of worklist; the data
type naturally depends on the task in
question.
DATA WA_PACKET like ????.
Work area for data of the current work
item; same data type as WORK_ITEMS
DATA TASKNAME(8).
Variable for a unique name for identifying the started job and thus the processed work item. This is needed if the job returns results data. A simple option is the table index TAB_IDX of the package.
Initialization
IF MAX_PROC_NUM <= 1.
......
ENDIF.
Maybe incorrect entry; possible program
reactions:
1) Use of the maximum number of parallel jobs in the system
2) Re-display selection screen with error message
3) End program with error message
4) At a value of 1, sequential instead
of parallel processing (makes sense for
tests, for example)
SELECT * FROM .... into TABLE
WORK_ITEMS WHERE...
Fill internal table WORK_ITEMS with
required worklist data
Note: This table must not become too
large (memory required!). If necessary,
only key information needs to be read,
or the data can be read in smaller
packages.
DESCRIBE TABLE WORK_ITEMS LINES
NUM_LINES.
Determine the size of the worklist in
table WORK_ITEMS. If the table is empty, nothing needs to be done.
TAB_IDX = 1.
CLEAR STARTED.
CLEAR RETURNED.
PROC_NUM_LIMIT = MAX_PROC_NUM.
Initialize variables that control flow.
Limit for the number of parallel jobs is currently the transferred value. This can be changed at runtime.
CALL FUNCTION SPBT_INITALIZE
EXPORTING GROUP_NAME=SERV_GROUP
Initialization of server group
Processing the Worklist in a Loop
WHILE TAB_IDX <= NUM_LINES.
Loop on complete worklist table
RUNNING = STARTED - RETURNED
IF RUNNING >= PROC_NUM_LIMIT.
WAIT UNTIL RUNNING < PROC_NUM_LIMIT.
ENDIF.
Check whether the maximum number of parallel jobs has already been reached.
If so, wait until one has finished
PROC_NUM_LIMIT = MAX_PROC_NUM.
A new job can now be started. Program tries (again) to use the maximum number of jobs.
READ TABLE WORK_ITEMS INDEX TAB_IDX INTO WA_PACKET.
Read next work item from internal table with worklist in work area.
TASKNAME = TAB_IDX.
Define a unique name for the next job (if necessary). The table index of the work item can be used for this, for example.
CALL FUNCTION MY_PROCESSING_FUNCTION'
STARTING NEW TASK TASKNAME
DESTINATION IN GROUP SERV_GROUP
PERFORMING COME_BACK ON END OF TASK
EXPORTING ....
TABLES ...
EXCEPTIONS
RESOURCE_FAILURE = 1
SYSTEM_FAILURE = 2
COMMUNICATION_FAILURE = 3
OTHERS = 4.
RESULT = SY-SUBRC.
Start function module for processing as aRFC in server group SERV_GROUP. When aRFC finishes, form routine COME_BACK is activated.
It is important to record
any system errors at the start of the aRFC, in particular, the exception RESOURCE_FAILURE. The return value is stored in RESULT and then evaluated.
CASE RESULT.
Evaluation of return code.
WHEN 0.
STARTED = STARTED + 1.
RUNNING = RUNNING + 1.
TAB_IDX = TAB_IDX + 1.
Start of aRFC was successful Update control variables and go on to next work item
Note: At this point, useful trace information can be collected for
subsequent analysis and tuning
WHEN 1.
IF RUNNING = 0.
................
ENDIF.
PROC_NUM_LIMIT = RUNNING.
Resource problem; this must only be a temporary situation Make note in Trace File if necessary The program waits until one of the jobs that is still running returns and tries to start the job later. The value for the maximum
number of jobs running is temporarily reduced to the number of jobs currently running. If no job is running, the problem is with the load distribution Terminate program with error message if necessary
WHEN OTHERS.
.....
Greater problem in RFC communication. Possible reactions:
1)Terminate program with error message
2)Use local instance only
3)Only use sequential processing in this process
ENDCASE
ENDWHILE. " TAB_IDX
Final Processing
WAIT UNTIL RUNNING = 0.
The job for the last work item has now been started. However, processing of this package is not yet finished. Wait until all the jobs that were started have finished. This may be necessary for a follow-on process. In addition, if you do not do this,
COME_BACK will no longer find the context. The waiting time can be restricted as in some cases the end of
a job is not confirmed (e.g. termination of the process at operating system level).
......
All work items have been processed.
Final tasks, such as writing of a log
file, can be carried out, and the
program then finishes.
COME_BACK Routine
FORM COME_BACK USING NAME.
When a job ends, form COME_BACK is
activated.
NAME identifies the job. The system
gives the variable the name that was
defined at the start via ....STARTING
NEW TASK TASKNAME... .
RETURNED = RETURNED + 1.
RUNNING = RUNNING - 1.
Update of controlling variables.
RECEIVE RESULTS FROM FUNCTION
'MY_PROCESSING_FUNCTION'
IMPORTING ...
TABLES ...
EXCEPTIONS
COMMUNICATION_FAILURE = 1
SYSTEM_FAILURE = 2
OTHERS = 3.
....
ENDFORM.
If necessary, results data can be read
and evaluated. As at the start,
communication problems must be taken
into account.