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

Selection Screen within Function Group > Background Processing

Former Member
0 Likes
1,255

Hello,

I am using a function pool to decouple screens from the application model. I created a program (Type: Executable Program). Within "START-OF-SELECTION" I am calling a static "main" method of a local class. Within this method I am calling a function which calls a selection screen. The selection screen is declared in the top include of the function group.

My problem is, if doing it that way I am loosing the possibility to start the report in background by choosing "Program > Execute in Background" after filling the selection screen. Any ideas how to solve this problem?

Thanks

Daniel Koffler

  • START-OF-SELECTION --------------------------------------------------*

START-OF-SELECTION.

lcl_dw_export=>main( ).

XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

  • main ----------------------------------------------------------------*

METHOD main.

  • Call Selection Screen

CALL FUNCTION 'Z_DW_EXPORT_SELECTION'

IMPORTING

e_range_pspid = range_pspid

e_range_posid = range_posid

e_range_prart = range_prart

e_range_wrttp = range_wrttp

e_range_versn = range_versn

e_range_gjahr = range_gjahr

e_range_perbl = range_perbl

e_range_soskonti = range_soskonti

e_range_regio = range_regio

e_subrc = subrc.

XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

FUNCTION-POOL z_dw_export_screens. "MESSAGE-ID ..

  • Selection Screen

DATA: g_proj TYPE proj,

g_prps TYPE prps,

g_cosp TYPE cosp.

SELECTION-SCREEN BEGIN OF SCREEN 100 AS WINDOW TITLE text-002.

SELECTION-SCREEN BEGIN OF BLOCK b1 WITH FRAME TITLE text-003.

SELECT-OPTIONS s_pspid FOR g_proj-pspid OBLIGATORY.

SELECT-OPTIONS s_posid FOR g_prps-posid.

SELECT-OPTIONS s_prart FOR g_prps-prart DEFAULT '10' TO '99'.

SELECT-OPTIONS s_konti FOR g_prps-zzsoskonti.

SELECT-OPTIONS s_regio FOR g_prps-zzregio.

SELECTION-SCREEN END OF BLOCK b1.

SELECTION-SCREEN BEGIN OF BLOCK b2 WITH FRAME TITLE text-004.

SELECT-OPTIONS s_wrttp FOR g_cosp-wrttp OBLIGATORY.

SELECT-OPTIONS s_gjahr FOR g_cosp-gjahr OBLIGATORY.

SELECT-OPTIONS s_perbl FOR g_cosp-perbl DEFAULT 1 TO 12 NO-DISPLAY.

SELECT-OPTIONS s_versn FOR g_cosp-versn DEFAULT 0 OBLIGATORY.

SELECTION-SCREEN END OF BLOCK b2.

SELECTION-SCREEN END OF SCREEN 100.

XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

FUNCTION z_dw_export_selection.

*"----


""Local interface:

*" EXPORTING

*" REFERENCE(E_RANGE_PSPID) TYPE ZRANGE_PSPID

*" REFERENCE(E_RANGE_POSID) TYPE ZRANGE_POSID

*" REFERENCE(E_RANGE_PRART) TYPE ZRANGE_PRART

*" REFERENCE(E_RANGE_WRTTP) TYPE ZRANGE_CO_WRTTP

*" REFERENCE(E_RANGE_VERSN) TYPE ZRANGE_PSVERSN

*" REFERENCE(E_RANGE_GJAHR) TYPE ZRANGE_GJAHR

*" REFERENCE(E_RANGE_PERBL) TYPE ZRANGE_PERBL

*" REFERENCE(E_RANGE_SOSKONTI) TYPE ZRANGE_SOSKONTI

*" REFERENCE(E_RANGE_REGIO) TYPE ZRANGE_REGIO

*" REFERENCE(E_SUBRC) TYPE SYST-SUBRC

*"----


CALL SELECTION-SCREEN 100.

e_range_pspid = s_pspid[].

e_range_posid = s_posid[].

e_range_prart = s_prart[].

e_range_wrttp = s_wrttp[].

e_range_versn = s_versn[].

e_range_gjahr = s_gjahr[].

e_range_perbl = s_perbl[].

e_range_soskonti = s_konti[].

e_range_regio = s_regio[].

e_subrc = sy-subrc.

ENDFUNCTION.

1 ACCEPTED SOLUTION
Read only

naimesh_patel
Active Contributor
0 Likes
624

Make one wrapper program which SUBMITs your main program with job options.

You can use the FM JOB_OPEN and JOB_CLOSE to create a job.

Regards,

Naimesh Patel

3 REPLIES 3
Read only

naimesh_patel
Active Contributor
0 Likes
625

Make one wrapper program which SUBMITs your main program with job options.

You can use the FM JOB_OPEN and JOB_CLOSE to create a job.

Regards,

Naimesh Patel

Read only

0 Likes
624

Dear Naimesh Patel,

could you please give me a rough example?

The wrapper program needs it's own selection screen, does it?

Many thanks

Daniel Koffler

Read only

0 Likes
624

You can try like this:

When you run this program, it will automatically create a background job.

data: w_count like TBTCJOB-JOBCOUNT,
      w_class like TBTCJOB-JOBCLASS.
data: w_uname like TBTCJOB-AUTHCKNAM.

parameters:  w_name  like TBTCJOB-JOBNAME.
* the selection parameters which you need to pass to FM
parameters: fld1 type char10.

start-of-selection.

  w_name  = 'ZTEST_NP'.
  w_class = 'A'.

  CALL FUNCTION 'JOB_OPEN'
    EXPORTING
*     DELANFREP              = ' '
      JOBGROUP               = 'TEST'
      JOBNAME                = w_name
*     SDLSTRTDT              = NO_DATE  " < required start date
*     SDLSTRTTM              = NO_TIME
*      JOBCLASS               = w_class
    IMPORTING
      JOBCOUNT               = w_count
*   CHANGING
*     RET                    =
*   EXCEPTIONS
*     CANT_CREATE_JOB        = 1
*     INVALID_JOB_DATA       = 2
*     JOBNAME_MISSING        = 3
*     OTHERS                 = 4
            .
  IF SY-SUBRC <> 0.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
*         WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
  ENDIF.


  SUBMIT ztest_np1 with p_char = fld1  " << your program name with the parameters
                   VIA JOB w_name NUMBER w_count
                    AND RETURn.


  CALL FUNCTION 'JOB_CLOSE'
    EXPORTING
*     AT_OPMODE                         = ' '
*     AT_OPMODE_PERIODIC                = ' '
*     CALENDAR_ID                       = ' '
*     EVENT_ID                          = ' '
*     EVENT_PARAM                       = ' '
*     EVENT_PERIODIC                    = ' '
      JOBCOUNT                          = w_count
      JOBNAME                           = w_name
*     LASTSTRTDT                        = NO_DATE
*     LASTSTRTTM                        = NO_TIME
*     PRDDAYS                           = 0
*     PRDHOURS                          = 0
*     PRDMINS                           = 0
*     PRDMONTHS                         = 0
*     PRDWEEKS                          = 0
*     PREDJOB_CHECKSTAT                 = ' '
*     PRED_JOBCOUNT                     = ' '
*     PRED_JOBNAME                      = ' '
*     SDLSTRTDT                         = NO_DATE
*     SDLSTRTTM                         = NO_TIME
*     STARTDATE_RESTRICTION             = BTC_PROCESS_ALWAYS
      STRTIMMED                         = 'X'
*     TARGETSYSTEM                      = ' '
*     START_ON_WORKDAY_NOT_BEFORE       = SY-DATUM
*     START_ON_WORKDAY_NR               = 0
*     WORKDAY_COUNT_DIRECTION           = 0
*     RECIPIENT_OBJ                     =
*     TARGETSERVER                      = ' '
*     DONT_RELEASE                      = ' '
*     TARGETGROUP                       = ' '
*      DIRECT_START                      = 'X'
*   IMPORTING
*     JOB_WAS_RELEASED                  =
*   CHANGING
*     RET                               =
*   EXCEPTIONS
*     CANT_START_IMMEDIATE              = 1
*     INVALID_STARTDATE                 = 2
*     JOBNAME_MISSING                   = 3
*     JOB_CLOSE_FAILED                  = 4
*     JOB_NOSTEPS                       = 5
*     JOB_NOTEX                         = 6
*     LOCK_FAILED                       = 7
*     INVALID_TARGET                    = 8
*     OTHERS                            = 9
            .
  IF SY-SUBRC = 0.
    WRITE: 'Job is ready'.
  ENDIF.

Regards,

Naimesh Patel