Application Development and Automation Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

How to handle errors encountered by SUBMIT statement

Former Member
0 Likes
5,117

Hi Sap Gurus,

I have written a Z program in which I called a standard report program with selection screen using SUBMIT <report program> using ....... and return in a loop and endloop.

As long as error was not encountered it executed ok.

When I ran my Z program in foreground which inturn calls a report program in a loop using SUBMIT keyword, for the first iteration of the loop itself an error was encountered and it is not going through another iterations and after hitting enter in the error screen, then only it is passing through other iterations and executing the report program(called program) from the calling program.

So, is there any way where I can handle/catch error which was encountered in the other program(called program) from the calling program and correct it. Also the SUBMIT statement wont return any sy-subrc to check whether the call is successful or not.

Your kind help will be appreciated.

Kalikonda.

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
1,915

Hi

See like you said you encountered with the error in the called program, and you said you cant able to catch error in the called program. asn alos your SUBMIT is in a loop.

If possible mail the code..

Because I would like to know whether, It's a Static error or it's a dynamic one...

If you want to capture the return code of called program to calling Program.. it's possible..

If your case , The Iteration has to be completed irrespective of the error of previous iteration.

you can do...

Regards

7 REPLIES 7
Read only

Former Member
0 Likes
1,916

Hi

See like you said you encountered with the error in the called program, and you said you cant able to catch error in the called program. asn alos your SUBMIT is in a loop.

If possible mail the code..

Because I would like to know whether, It's a Static error or it's a dynamic one...

If you want to capture the return code of called program to calling Program.. it's possible..

If your case , The Iteration has to be completed irrespective of the error of previous iteration.

you can do...

Regards

Read only

0 Likes
1,915

Thanks for you answer i.e. prompt answer.

Here is the code I am using.

LOOP AT it_plan_p.

CLEAR : pm_snp.

CONCATENATE it_plan_p-plannr '_SNP' INTO pm_snp.

SUBMIT /sapapo/ppm_conv_ppds_to_snp WITH pm_ppds = it_plan_p-plannr

WITH pm_snp = pm_snp

WITH x_flag = 'X'

USING SELECTION-SCREEN 1000 AND RETURN

EXPORTING LIST TO MEMORY.

ENDLOOP.

and yes you are right that I want to proceed with further iterations even if one iterations got error,

but at the same time I have to catch the error and maintain the log for it.

Can it be possible.

Thanks once again for your answer and also appreciate your response.

kalikonda.

Read only

0 Likes
1,915

Sorry I am not using the text 'EXPORTING LIST TO MEMORY' in the submit command.

by mistake I put that for testing purpose only.

Please ignore the text 'EXPORTING LIST TO MEMORY'

Thanks,

kalikonda

Read only

0 Likes
1,915

hi,

Include 'EXPORTING LIST TO MEMORY' in your code. For error records spool won't have any data. Anyway with the inclusion 'EXPORTING LIST TO MEMORY' you are exporting the spool data to the memory. Retrieve the data from memory using 'LIST_FROM_MEMORY' function module and store it in a some text variable and check the length of text variable. if it is zero means processed record is error record, store all those records some internal table and maintain that internal table as log.

<REMOVED BY MODERATOR>

Edited by: Alvaro Tejada Galindo on Jun 9, 2008 6:30 PM

Read only

0 Likes
1,915

Subas,

I tried with the text ''EXPORTING LIST TO MEMORY' ' in submit statement but still it is not working.

Is there any way where I can use transaction code in the loop and catch the errors and display them later on?

Kindly,

kalikonda

Read only

Former Member
0 Likes
1,915

Hi kalikonda kalikonda,

There is one way..

Have a look on Submit with JOB options...

See the documentation below...

SUBMIT - job_options

Syntax

... [USER user] VIA JOB job NUMBER n... .

Effect

This addition schedules the execution of the program accessed as a background task with the number n in the background request job. The number n for a background request job is supplied by function module JOB_OPEN in function group BTCH. The full program is not processed directly but in background processing, according to the parameters specified for the background request. You can use the optional addition USER to specify a user ID user of the type sy-uname, which is used to execute the background task. The addition VIA JOB can only be used together with the addition AND RETURN.

The VIA JOB addition also loads the program accessed in a separate internal mode when the SUBMIT statement is executed and the system performs all the steps specified before START-OF-SELECTION. This means the events LOAD-OF-PROGRAM and INITIALIZATION are triggered and selection screen processing is performed. If the selection screen is not processed in the background when VIA SELECTION-SCREEN is specified, the user of the calling program can eidit it and schedule the program accessed in the background request using the function Place in Job. If the user cancels selection screen processing, the program is not scheduled in the background job. In both cases, execution of the program executed is completed after selection screen processing and the system returns to the calling program due to the AND RETURN addition.

When the program is scheduled in the background task, the selections specified by the user or in the additions for filling the selection screen are stored in an internal variant. When the program is executed in the background request, it is processed fully but the selection screen is processed in the background. The system triggers all events, including that for selection screen processing. The variant stored internally is transferred to the selection screen between the INITIALIZATION and AT SELECTION SCREEN OUTPUT events.

If a basic list is created in the program accessed, you should create a spool request with explicit print parameters by specifying TO SAP-SPOOL. Otherwise the VIA JOB addition implicitly creates a spool request that derives its print parameters from standard values, some of which are taken from the user defaults, and which are not necessarily consistent.

System fields

sy-subrc Meaning

0 Background task scheduled successfully.

4 Scheduling cancelled by user on the selection screen.

8 Error during scheduling, i.e. when accessing JOB_SUBMIT internally.

12 Error in internal number assignment.

Note

You can create and monitor background jobs by choosing the menu path System - Services - Jobs. In addition to JOB_OPEN, the function modules JOB_CLOSE and JOB_SUBMIT can also be used in the ABAP program. JOB_CLOSE closes creation of a background request. Like the SUBMIT statement, JOB_SUBMIT schedules an ABAP program as a background task in a background request. JOB_SUBMIT provides more control options for background processing but must receive the input values for the selection screen in an existing variant. The SUBMIT statement creates this variant and accesses JOB_SUBMIT internally.

Example

Scheduling a submitable program as a background task with the number number in a background request name. After scheduling, the background task is completed by function module JOB_CLOSE and released immediately providing the user has the relevant authorization.

DATA: number           TYPE tbtcjob-jobcount, 
      name             TYPE tbtcjob-jobname VALUE 'JOB_TEST', 
      print_parameters TYPE pri_params. 

... 

CALL FUNCTION 'JOB_OPEN' 
  EXPORTING 
    jobname          = name 
  IMPORTING 
    jobcount         = number 
  EXCEPTIONS 
    cant_create_job  = 1 
    invalid_job_data = 2 
    jobname_missing  = 3 
    OTHERS           = 4. 
IF sy-subrc = 0. 
  SUBMIT submitable TO SAP-SPOOL 
                    SPOOL PARAMETERS print_parameters 
                    WITHOUT SPOOL DYNPRO 
                    VIA JOB name NUMBER number 
                    AND RETURN. 
  IF sy-subrc = 0. 
    CALL FUNCTION 'JOB_CLOSE' 
      EXPORTING 
        jobcount             = number 
        jobname              = name 
        strtimmed            = 'X' 
      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 <> 0. 
      ... 
    ENDIF. 
  ENDIF. 
ENDIF.

Also have look on below thread

Hope it will solve your problem..

<REMOVED BY MODERATOR>

Thanks & Regards

ilesh 24x7

Edited by: Alvaro Tejada Galindo on Jun 9, 2008 6:30 PM

Read only

Former Member
0 Likes
1,915

I have used Call transaction method to solve this issue.

Thanks.