cancel
Showing results for 
Search instead for 
Did you mean: 

Run ALV in Background JOB (DUMP )

gulbin01
Explorer
0 Kudos

Hi,

"CNT_ERROR" error is returned in the job program.

Im trying to run a alv report in a scheduled JOB...!!

Many Thanks for any help..!!!!

How can I fix this.

MODULE status_0100 OUTPUT.
SET PF-STATUS 'GUI100'.
SET TITLEBAR 'TITLE100'.
IF gr_docking IS INITIAL.
PERFORM display_alv_report CHANGING gt_out gt_fieldcat gs_layout.
ELSE.
CALL METHOD gr_grid->refresh_table_display.
ENDIF.
ENDMODULE. " STATUS_0100 OUTPUT

FORM display_alv_report CHANGING pt_out
pt_fieldcat
ps_layout TYPE lvc_s_layo.
DATA:ls_sort TYPE lvc_s_sort,
lt_sort TYPE TABLE OF lvc_s_sort.

CREATE OBJECT gr_docking
EXPORTING
ratio = '95'.

CREATE OBJECT gr_grid
EXPORTING
i_parent = gr_docking.

gs_variant-report = sy-repid.

ps_layout-zebra = 'X'.
ps_layout-cwidth_opt = 'X'.
ps_layout-sel_mode = 'A'.

CALL METHOD gr_grid->set_table_for_first_display
EXPORTING
is_layout = ps_layout
is_variant = gs_variant
i_save = 'A'
CHANGING
it_fieldcatalog = pt_fieldcat
it_outtab = pt_out
it_sort = lt_sort.

CREATE OBJECT gr_event_receiver.
SET HANDLER gr_event_receiver->handle_user_command FOR gr_grid.
SET HANDLER gr_event_receiver->handle_double_click FOR gr_grid.
* SET HANDLER gr_event_receiver->handle_hotspot_click FOR gr_grid.
SET HANDLER gr_event_receiver->handle_toolbar FOR gr_grid.

CALL METHOD gr_grid->set_toolbar_interactive.

Sandra_Rossi
Active Contributor

Try with more parameters. A docking container must be linked to a dynpro:

 CREATE OBJECT gr_docking
      EXPORTING
        repid     = sy-repid
        dynnr     = sy-dynnr
        side      = cl_gui_docking_container=>dock_at_bottom
        ratio     = 95.

NB: I prefer using extension rather than ratio to define a size in number of pixels.

gulbin01
Explorer
0 Kudos

Hi Sandra,

Do you think I should use salv because alv doesn't run in the background?(salv-It works both in background and foreground modes.)What negative impact would my use of salv have on the report?

Sandra_Rossi
Active Contributor
0 Kudos

SALV, ALV grid and other ALV libraries are all ALV. SALV is a wrapper of several ALV technologies including ALV grid, when it's in background SALV in ALV grid mode is switching to ALV List.

You'd better ask a distinct question to know what "negative impact would my use of salv have on the report"...

gulbin01
Explorer
0 Kudos

If I use salv instead of alv in the program, do you think it will cause big problems when the program runs?

I haven't used salv before, so I don't have any information about the problems it will create or may create, unfortunately.

Finally, how can I rewrite the above code as salv?

Sandra_Rossi
Active Contributor
0 Kudos

The most important ALV grid features are available through SALV.

gulbin01
Explorer
0 Kudos

Hi Sandra,

I made a "GUI100" change in the code above.

I tried the change you suggested and was successful.

CREATE OBJECT gr_docking
      EXPORTING
        repid     = sy-repid
        dynnr     = sy-dynnr
        side      = cl_gui_docking_container=>dock_at_bottom
        ratio     = 95.

Thank you

Regards

Accepted Solutions (1)

Accepted Solutions (1)

abityildiz
Active Participant

Hello Gülbin,

Can you add exception on your codes and try again?

 CREATE OBJECT gr_docking
      EXPORTING      
        ratio     = 95 
      EXCEPTIONS
          cntl_error        = 1
          cntl_system_error = 2
          create_error      = 3
          lifetime_error    = 4
          lifetime_dynpro_dynpro_link = 5.
gulbin01
Explorer
0 Kudos

Hi Abit,

I made a "GUI100" change in the code above.

I tried the change you suggested and was successful.

Thank you

Regards

Answers (1)

Answers (1)

Clemenss
Active Contributor

The creation of a docking container needs at least a screen where to dock at. In Background, there is no screen. And there is nobody to handle any interactive events.

So what do you want? Just the creation of a printed list? If SY-BATCH = abap_true means creation of docking container is not possible, the grid object can be created without reference to container. set_table_for_first_display will convert the grid to list.

Regards, Clemens