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

Background processing in alv reports

Former Member
0 Likes
955

Hi all,

I am writing an alv report not using oops concepts.

I want to execute this report in background also.

So can you help me out in this.Is there any method to follow.

Please let me know.

Regards,

Priya.

6 REPLIES 6
Read only

Former Member
0 Likes
770

Hi Priya,

ALV report cannot work in Background. I mean you cant use the ALV functionality in the background. If you use the ALV program you will get the data in the background program in columns

CHeers

VJ

Read only

Former Member
0 Likes
770

Create a Empty screen 100. and don't place any custom Control on that.

and follow the same approach using DOCKING_CONTAINER. and Run it in the Background, It will not give any Dump or error.

REPORT  ztest_oo_a.
 
DATA: it_vbak TYPE vbak_t.
DATA: dock TYPE REF TO cl_gui_docking_container,
      it_fcat TYPE lvc_t_fcat,
      wa_fcat TYPE lvc_s_fcat,
 
      grid TYPE REF TO cl_gui_alv_grid.
 
*----------------------------------------------------------------------*
*       CLASS lcl_handler DEFINITION
*----------------------------------------------------------------------*
*
*----------------------------------------------------------------------*
CLASS lcl_handler DEFINITION.
  PUBLIC SECTION.
    METHODS:  hotspot_click FOR EVENT hotspot_click OF cl_gui_alv_grid
    IMPORTING e_row_id e_column_id es_row_no.
 
ENDCLASS.                    "lcl_handler DEFINITION
 
 
*----------------------------------------------------------------------*
*       CLASS lcl_handler IMPLEMENTATION
*----------------------------------------------------------------------*
*
*----------------------------------------------------------------------*
CLASS lcl_handler IMPLEMENTATION.
 
  METHOD hotspot_click.
    DATA:    row TYPE lvc_s_roid,
        wa_vbak TYPE vbak.
    row = es_row_no.
    READ TABLE it_vbak INTO wa_vbak INDEX row-row_id.
 
    SET PARAMETER ID 'AUN' FIELD wa_vbak-vbeln.
    CALL TRANSACTION 'VA03' AND SKIP FIRST SCREEN.
 
  ENDMETHOD.                    "HOTSPOT_CLICK
 
ENDCLASS.                    "lcl_handler IMPLEMENTATION
 
 
START-OF-SELECTION.
 
  DATA: obj TYPE REF TO  lcl_handler.
  CREATE OBJECT obj.
  SELECT *
    FROM vbak
    INTO TABLE it_vbak
    UP TO 20 ROWS.
 
  CALL SCREEN 100.
 
 
*&---------------------------------------------------------------------*
*&      Module  STATUS_0100  OUTPUT
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
MODULE status_0100 OUTPUT.
  SET PF-STATUS 'SATR'.
 
 
  CREATE OBJECT dock
    EXPORTING
      repid     = sy-repid
      dynnr     = '100'
      extension = '1500'
    EXCEPTIONS
      cntl_error                  = 1
      cntl_system_error           = 2
      create_error                = 3
      lifetime_error              = 4
      lifetime_dynpro_dynpro_link = 5
      OTHERS                      = 6
      .
  IF sy-subrc ne  0.
    MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
               WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
  ENDIF.
  CREATE OBJECT grid EXPORTING i_parent = dock.
 
  CALL FUNCTION 'LVC_FIELDCATALOG_MERGE'
    EXPORTING
      i_structure_name       = 'VBAK'
    CHANGING
      ct_fieldcat            = it_fcat
    EXCEPTIONS
      inconsistent_interface = 1
      program_error          = 2
      OTHERS                 = 3.
  IF sy-subrc  ne 0.
    MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
            WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
  ENDIF.
 
  wa_fcat-hotspot = 'X'.
  MODIFY it_fcat FROM wa_fcat INDEX 2 TRANSPORTING hotspot .
 
  SET HANDLER obj->hotspot_click FOR grid.
 
  CALL METHOD grid->set_table_for_first_display
*    EXPORTING
*      i_structure_name              = 'VBAK'
    CHANGING
      it_outtab                     = it_vbak
      it_fieldcatalog               = it_fcat
    EXCEPTIONS
      invalid_parameter_combination = 1
      program_error                 = 2
      too_many_lines                = 3
      OTHERS                        = 4.
  IF sy-subrc ne  0.
    MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
               WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
  ENDIF.
 
ENDMODULE.                 " STATUS_0100  OUTPUT
*&---------------------------------------------------------------------*
*&      Module  USER_COMMAND_0100  INPUT
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
MODULE user_command_0100 INPUT.
 
  CASE sy-ucomm.
 
    WHEN 'BACK'.
      LEAVE TO SCREEN 0.
  ENDCASE.
 
ENDMODULE.                 " USER_COMMAND_0100  INPUT

Flow logic

PROCESS BEFORE OUTPUT.
 MODULE STATUS_0100.
*
PROCESS AFTER INPUT.
 MODULE USER_COMMAND_0100.

Regards

Vijay babu Dudla

Read only

Former Member
0 Likes
770

Supriya,

I think ALV Grid cannot be displayed in Background, but the list output of ALV is possible.

you can code some around this:

at seletion-screen.
if sy-batch = ' ' ."check for background
message " Report cannot be run in forground pls press F9 to execute in background.
Endif.

Read only

Former Member
0 Likes
770

ALV Grid can not be processed in background. you can process only ALV List in background.

To run the ALV in background you need to take care of following things

1.) check IF cl_gui_alv_grid=>offline( ) IS INITIAL.

2.) if cl_gui_alv_grid=>offline( ) IS INITIAL it means it is not in background

and then only you create the objectfor docking container , object for container.

and object for grid.

3.) cl_gui_alv_grid=>offline( ) is not initial.. it means it is in background.

Then don't create the object for container, splitter. just create the

object for grid.

IF cl_gui_alv_grid=>offline( ) IS INITIAL
             create object for container
             create object for splitter,
            create object for grid.
else.
           create object for grid.
            
 ENDIF.
  CALL METHOD obj_grid->set_table_for_first_display

Thanks,

Kamesh

Edited by: Kamesh Bathla on Aug 5, 2008 4:11 PM

Edited by: Kamesh Bathla on Aug 5, 2008 4:17 PM

Read only

Former Member
0 Likes
770

It is possible to Run an OOALV program in Background.

It will generate the spool also. No need to use any checks , Directly we can schedule the Background job. Did you check the sample code which i mentioned..

if not check it once..

Read only

Former Member
0 Likes
770

I have tried to execute a program with ALV grid in background (ECC 5.0). And it is working fine without any error. Pl. check.

Here is my code:

report ztest_10.

type-pools: abap, slis.

data: tab type ref to cl_abap_structdescr,

wa_tab type ref to cl_abap_structdescr,

comp_tab type cl_abap_structdescr=>component_table,

comp like line of comp_tab,

i_tab type ref to cl_abap_tabledescr,

i_table type ref to data.

data:

l_program_name type syrepid value sy-repid,

l_structure_name type tabname,

l_i_ct_fieldcat type slis_t_fieldcat_alv.

field-symbols:

<f_tab1> type standard table.

parameters:

p_tname type tabname16 obligatory, " DEFAULT 'MARA' ,

p_rows(5) type c default '200'.

tab ?= cl_abap_typedescr=>describe_by_name( p_tname ).

comp_tab = tab->get_components( ).

wa_tab = cl_abap_structdescr=>create( comp_tab ).

i_tab = cl_abap_tabledescr=>create( wa_tab ).

create data i_table type handle i_tab.

*create data wa_table type handle wa_tab.

assign i_table->* to <f_tab1>.

assign wa_table-> to <f1>.

if p_rows is initial.

p_rows = '50000'.

endif.

at selection-screen.

select count( * )

from dd02l

where tabname = p_tname

and as4local = 'A'

and tabclass = 'TRANSP'.

if sy-subrc <> 0.

message e000(z_zzz_ca_messages) with

p_tname 'is not a Transparant Table'.

endif.

start-of-selection.

*Get data

select * from (p_tname)

into table <f_tab1>

up to p_rows rows.

if sy-subrc <> 0.

message i000(z_zzz_ca_messages) with 'No data found'.

leave list-processing.

endif.

end-of-selection.

set titlebar sy-title

of program sy-cprog

with 'Display table:' p_tname.

l_structure_name = p_tname.

call function 'REUSE_ALV_FIELDCATALOG_MERGE'

exporting

i_program_name = l_program_name

i_internal_tabname = 'I_TABLE'

i_structure_name = l_structure_name

i_client_never_display = 'X'

  • I_INCLNAME =

  • I_BYPASSING_BUFFER =

  • I_BUFFER_ACTIVE =

changing

ct_fieldcat = l_i_ct_fieldcat

exceptions

inconsistent_interface = 1

program_error = 2

others = 3

.

if sy-subrc <> 0.

message id sy-msgid type sy-msgty number sy-msgno

with sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.

else.

call function 'REUSE_ALV_GRID_DISPLAY'

exporting

i_callback_program = l_program_name

it_fieldcat = l_i_ct_fieldcat

tables

t_outtab = <f_tab1>

exceptions

program_error = 1

others = 2.

if sy-subrc <> 0.

message id sy-msgid type sy-msgty number sy-msgno

with sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.

endif.

endif.