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

Create Background Job after data saved in module

Former Member
0 Likes
1,148

Hello,

I have a program that has a start selection screen with material group, you enter your data, execute. When it has finished you get a ALV of sales order with items where you can make changes to dates and other details and save. I would like to add a save in background option. Is this possible? I assume it would be difficult because of the container.. it uses a bapi to save sale orders...

The employees run this job which takes a little while.. at the end of the day.. they go home and of course SAP has timed out. If they can run it in the background then no problem....

Thanks,

AJ

1 ACCEPTED SOLUTION
Read only

Sandeep_Panghal
Product and Topic Expert
Product and Topic Expert
0 Likes
1,068

You can schedule the jon in background , should not be a problem .

But you can not provide 'SAVE' button functionality in background as once jobn is submitted you will not see the ALV screen anymore.

What you can do is once changes are done save the date in another table and then schedule job with these entries.

Hello,

I have a program that has a start selection screen with material group, you enter your data, execute. When it has finished you get a ALV of sales order with items where you can make changes to dates and other details and save. I would like to add a save in background option. Is this possible? I assume it would be difficult because of the container.. it uses a bapi to save sale orders...

The employees run this job which takes a little while.. at the end of the day.. they go home and of course SAP has timed out. If they can run it in the background then no problem....

Thanks,

AJ

7 REPLIES 7
Read only

Former Member
0 Likes
1,068

Looking at the requirement there is a manual process involved. If you want to automate it then you need to have the values for the dates & other details which they save. If you have a logic to do that then you can simply add a step to Post the data (I think you mantioed that you have a BAPI) rather than displaying fields for Input. After posting you may display a report.

Hope this helps.

Bipin

Read only

Former Member
0 Likes
1,068

well, you can pass the data from the same to an other program and submit it in background.

Just create a job.

CALL FUNCTION 'JOB_OPEN'
       EXPORTING
            jobname          = gv_jobname
       IMPORTING
            jobcount         = gv_jobcount
       EXCEPTIONS
            cant_create_job  = 1
            invalid_job_data = 2
            jobname_missing  = 3
            OTHERS           = 4.
  IF sy-subrc <> 0.
*   no error required
  ENDIF.

submit your program with job name and job count.

CALL FUNCTION 'JOB_CLOSE'
       EXPORTING
            jobcount             = gv_jobcount
            jobname              = gv_jobname
            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.

Read only

0 Likes
1,068

What if I don't want to return to the program.. I cannot use the name and count..

Read only

0 Likes
1,068

Antonio,

As mentioned before, if you know what values that need to be updated then you just schedule the report in background.

Old Steps:

Get data

Display Data on ALV

Change data on ALV

Save/Post Data

New Steps:

Get Data into internal table.

Update the records (fields) with proper values.

Save/Post Data - BAPI

Display Data on ALV

Hope this helps.

Read only

0 Likes
1,068

Sorry not ALV, but it's a module or screen. Once you make changes theres a method called g_insdel->get_modified_rows. I am taking the modified rows and exporting to memory. I create a background job then, in the program that I submitting to, I am importing the table and saving with BAPI, etc.. once completed I am closing the job, but I get a return code of 5 or job_nosteps. There is where I am now. I should not have to use the JOB_SUBMIT fm once I am in the called program , correct?

Read only

Sandeep_Panghal
Product and Topic Expert
Product and Topic Expert
0 Likes
1,069

You can schedule the jon in background , should not be a problem .

But you can not provide 'SAVE' button functionality in background as once jobn is submitted you will not see the ALV screen anymore.

What you can do is once changes are done save the date in another table and then schedule job with these entries.

Read only

Former Member
0 Likes
1,068

to minimize execution time --->

1.u need to get orders whose details has been changed by the user, u can use method check_changed_data (or something like ).....

2.update ztable with all new changes of SO ... run BG job at the end of day.....notify users in case of any errors.

regards

Prabhu