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

ALV with objects in background

danielpalacios3
Explorer
0 Likes
1,879

Hi

Can I run a program that displays an ALV using objects in background? How?

Regards

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
1,374

Hi,

We can run alv grid in background.If we implement with

classes.Without class grid act as a list in background.

ALV Grid implemented based on class cl_gui_alv_grid CAN BE run in background. You have to use docking container.

*=======================================================================

  • ALV Definition

*=======================================================================

************************************************************************

  • Predefine a local class for event handling to allow the

  • declaration of a reference variable before the class is defined.

CLASS lcl_event_receiver DEFINITION DEFERRED.

************************************************************************

DATA: gv_ok_code LIKE sy-ucomm,

gv_container_main TYPE scrfname VALUE 'CONTAINER_M',

gro_grid TYPE REF TO cl_gui_alv_grid,

gro_custom_container TYPE REF TO cl_gui_custom_container,

gro_doc_container TYPE REF TO cl_gui_docking_container,

gro_event_receiver TYPE REF TO lcl_event_receiver,

git_fieldcat TYPE lvc_t_fcat,

gwa_layout TYPE lvc_s_layo,

gwa_variant TYPE disvariant.

*=======================================================================

...

&----


*& Module status_0100 OUTPUT

&----


MODULE status_0100 OUTPUT.

SET PF-STATUS 'MAIN100'.

SET TITLEBAR 'TB100' WITH p_udatel p_udateh.

IF gro_custom_container IS INITIAL.

*\ For background processing

IF cl_gui_alv_grid=>offline( ) IS INITIAL.

CREATE OBJECT gro_custom_container

EXPORTING container_name = gv_container_main.

CREATE OBJECT gro_grid

EXPORTING i_parent = gro_custom_container.

ELSE.

  • If it is in background:

CREATE OBJECT gro_grid

EXPORTING i_parent = gro_doc_container.

ENDIF.

*// For background processing

CALL METHOD gro_grid->set_table_for_first_display

EXPORTING

i_structure_name = 'GIT_ALVOUTTAB'

is_layout = gwa_layout

is_variant = gwa_variant

i_save = 'A'

CHANGING

it_outtab = git_alvouttab

it_fieldcatalog = git_fieldcat.

CREATE OBJECT gro_event_receiver.

SET HANDLER gro_event_receiver->handle_hotspot_click FOR gro_grid.

ELSE.

CALL METHOD gro_grid->refresh_table_display

EXPORTING i_soft_refresh = c_flagged.

ENDIF.

ENDMODULE. " status_0100 OUTPUT

Regards,

Naveen.

7 REPLIES 7
Read only

Former Member
0 Likes
1,374

Hello Daniel,

Yes ,It can be run in Background

Refer below link for the this concept.

Best regards,

Brijesh

Read only

Former Member
0 Likes
1,374

Hi Daniel,

check below links

Regards,

Nikunj

Read only

0 Likes
1,374

Thanks for your replies

I have checked posts you've write. I have use the code on my program, but when I run it in background the job is canceled with this error: OBJECTS_NOT_CHARLIKE. The error is on set_table_for_first_display method

I think I have used the code on the right way. Here I put my code:

DATA: grid1 TYPE REF TO cl_gui_alv_grid,

custom_container1 TYPE REF TO cl_gui_custom_container,

or_doc TYPE REF TO cl_gui_docking_container.

[...]

IF custom_container1 IS INITIAL.

IF cl_gui_alv_grid=>offline( ) IS INITIAL.

  • create a custom container control for our ALV Control

CREATE OBJECT custom_container1

EXPORTING

container_name = 'CONTAINER1001'.

  • create an instance of alv control

CREATE OBJECT grid1

EXPORTING

i_parent = custom_container1.

ELSE.

  • create an instance of alv control

CREATE OBJECT grid1

EXPORTING

i_parent = or_doc.

ENDIF.

PERFORM catalogo_campos. "Here I fill fieldcatalog table wt_fieldcatalog

PERFORM definir_layout. "Here I fill layout structure wt_layout

CALL METHOD grid1->set_table_for_first_display

EXPORTING

is_layout = wt_layout

CHANGING

it_outtab = wt_listado[]

it_fieldcatalog = wt_fieldcatalog.

ENDIF.

Thanks and regards

Dani

Read only

0 Likes
1,374

Hi

Anybody knows anything about my last reply? I still cannot run my ALV program in background? Any idea?

Thanks and regards

Dani

Read only

0 Likes
1,374

Hey Daniel,

This is late reply, I think what I know I should tell you.

ALV report cannot work in Background. I mean you cant use the ALV functionality in the background.

Actually GUI is not working in background. So ALV gives such error.

So don't write logic to create custome control(If it is in background)

Do you want to check my code whic is working

  • Create the controls the first time through

if gv_controls_created is initial

and sy-batch <> 'X'.

PERFORM create_controls.

endif.

  • Create the ALV grid for the data section

if gr_alvgrid is initial.

PERFORM create_grid.

else.

PERFORM refresh_alv_display.

endif.

FORM create_controls .

  • Creating custom container instance

CREATE OBJECT gr_container

EXPORTING

CONTAINER_NAME = c_custom_control_name.

  • Create object for selection screen input display

CREATE OBJECT gr_dyndoc_id

EXPORTING

style = 'ALV_GRID'.

  • Create splitter for primary container

create object gr_splitter

exporting

parent = gr_container

rows = 2

columns = 1.

  • Row 1 = Selection screen parameter

call method gr_splitter->get_container

exporting

row = 1

column = 1

receiving

container = gr_parent_top.

  • Row 2 = Data output

call method gr_splitter->get_container

exporting

row = 2

column = 1

receiving

container = gr_parent_grid.

  • Set the row height of 1st container.

call method gr_splitter->set_row_height

exporting

id = 1

height = 1.

gv_controls_created = 'X'.

ENDFORM. " create_controls

FORM create_grid .

DATA: lwa_disvariant TYPE disvariant.

  • Create ALV Grid instance

create object gr_alvgrid

EXPORTING

I_PARENT = gr_parent_grid.

  • Create obj_handler object (of TYPE local class)

CREATE OBJECT gr_obj_handler.

SET HANDLER gr_obj_handler->top_of_page FOR gr_alvgrid.

SET HANDLER gr_obj_handler->print_top_of_page FOR gr_alvgrid.

SET HANDLER gr_obj_handler->handle_hotspot_click FOR gr_alvgrid.

lwa_disvariant-report = sy-repid.

lwa_disvariant-variant = p_vari.

call method gr_alvgrid->set_table_for_first_display

exporting

is_variant = lwa_disvariant

i_save = yc_charx

i_default = yc_charx

changing

it_outtab = gt_order_data[]

it_fieldcatalog = gt_fieldcat

it_sort = gt_sort

exceptions

invalid_parameter_combination = 1

program_error = 2

too_many_lines = 3

others = 4.

        • Generate header for screen display

CALL METHOD gr_alvgrid->list_processing_events

EXPORTING

i_event_name = 'TOP_OF_PAGE'

i_dyndoc_id = gr_dyndoc_id.

ENDFORM. " create_grid

Read only

Former Member
0 Likes
1,375

Hi,

We can run alv grid in background.If we implement with

classes.Without class grid act as a list in background.

ALV Grid implemented based on class cl_gui_alv_grid CAN BE run in background. You have to use docking container.

*=======================================================================

  • ALV Definition

*=======================================================================

************************************************************************

  • Predefine a local class for event handling to allow the

  • declaration of a reference variable before the class is defined.

CLASS lcl_event_receiver DEFINITION DEFERRED.

************************************************************************

DATA: gv_ok_code LIKE sy-ucomm,

gv_container_main TYPE scrfname VALUE 'CONTAINER_M',

gro_grid TYPE REF TO cl_gui_alv_grid,

gro_custom_container TYPE REF TO cl_gui_custom_container,

gro_doc_container TYPE REF TO cl_gui_docking_container,

gro_event_receiver TYPE REF TO lcl_event_receiver,

git_fieldcat TYPE lvc_t_fcat,

gwa_layout TYPE lvc_s_layo,

gwa_variant TYPE disvariant.

*=======================================================================

...

&----


*& Module status_0100 OUTPUT

&----


MODULE status_0100 OUTPUT.

SET PF-STATUS 'MAIN100'.

SET TITLEBAR 'TB100' WITH p_udatel p_udateh.

IF gro_custom_container IS INITIAL.

*\ For background processing

IF cl_gui_alv_grid=>offline( ) IS INITIAL.

CREATE OBJECT gro_custom_container

EXPORTING container_name = gv_container_main.

CREATE OBJECT gro_grid

EXPORTING i_parent = gro_custom_container.

ELSE.

  • If it is in background:

CREATE OBJECT gro_grid

EXPORTING i_parent = gro_doc_container.

ENDIF.

*// For background processing

CALL METHOD gro_grid->set_table_for_first_display

EXPORTING

i_structure_name = 'GIT_ALVOUTTAB'

is_layout = gwa_layout

is_variant = gwa_variant

i_save = 'A'

CHANGING

it_outtab = git_alvouttab

it_fieldcatalog = git_fieldcat.

CREATE OBJECT gro_event_receiver.

SET HANDLER gro_event_receiver->handle_hotspot_click FOR gro_grid.

ELSE.

CALL METHOD gro_grid->refresh_table_display

EXPORTING i_soft_refresh = c_flagged.

ENDIF.

ENDMODULE. " status_0100 OUTPUT

Regards,

Naveen.

Read only

0 Likes
1,374

Thanks for your replies, but my problem was solved few days ago.

Regards