Application Development 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: 

ALV background

Former Member
0 Kudos

Hi,

We are trying to build a ALV able to be launched in background mode. We need to see the result ALV of the job. We have looked up in this forum and we have found this helpful thread:

but even though we follow its instructions, when we go to SM37 and look in the job log we don't find the ALV results.

Thanks in advance for your help.

Regards.

4 REPLIES 4

Former Member
0 Kudos

Hi,

U wont get the output for ALV grid in background. Try to use ALV list.

Former Member
0 Kudos

we are using an object oriented ALV (with class CL_GUI_ALV_GRID)

0 Kudos

Hi Carla

If yuo want to run the ALV GRID in background mode u need to force to create a spool print request and u doesn't need to set the instance for container.

So u try to set the right value in the parameter IS_PRINT of method SET_TABLE_FOR_FIRST_DISPLAY:

* Check if the process is in background
  CALL METHOD CL_GUI_ALV_GRID=>OFFLINE
    RECEIVING
      E_OFFLINE = E_OFFLINE.

  IF E_OFFLINE IS INITIAL.

    IF G_CUSTOM_CONTAINER IS INITIAL.
      CREATE OBJECT G_CUSTOM_CONTAINER
             EXPORTING CONTAINER_NAME = G_CONTAINER.
      CREATE OBJECT GRID1
             EXPORTING I_PARENT = G_CUSTOM_CONTAINER.

      CALL METHOD GRID1->SET_TABLE_FOR_FIRST_DISPLAY
           EXPORTING
             I_STRUCTURE_NAME = 'SFLIGHT'
           CHANGING
           IT_OUTTAB        = GT_SFLIGHT.
    ENDIF.
  ELSE.
    I_PRINT-PRINT = 'X'.

    CREATE OBJECT GRID1
           EXPORTING I_PARENT = G_CUSTOM_CONTAINER.

    CALL METHOD GRID1->SET_TABLE_FOR_FIRST_DISPLAY
         EXPORTING
           I_STRUCTURE_NAME = 'SFLIGHT'
           IS_PRINT         = I_PRINT
         CHANGING
         IT_OUTTAB        = GT_SFLIGHT.
  ENDIF.

Max

0 Kudos

It is possible to run the report in background also. this case we don't need any custom control on the screen. create an empty screen and test it foreground and background.

report  ztest_alv_oo.

data: it_carr type table of scarr,
      it_flight type table of sflight.

data: grid1 type ref to cl_gui_alv_grid,
      con1 type ref to cl_gui_custom_container.
data: layout1 type lvc_s_layo.

start-of-selection.

  select * from scarr
  into table it_carr.

  if grid1 is initial.
    create object grid1
      exporting
        i_parent = con1.
    layout1-grid_title = 'Carrid data'.
    layout1-smalltitle = 'X'.
    layout1-sel_mode   = 'A'.
    layout1-cwidth_opt = 'X'.
    layout1-zebra      = 'X'.
    grid1->set_table_for_first_display(
      exporting
        i_structure_name              = 'SCARR'
        is_layout                     = layout1
      changing
        it_outtab                     = it_carr
      exceptions
        invalid_parameter_combination = 1
        program_error                 = 2
        too_many_lines                = 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.

  endif.
  if sy-batch ne abap_true.
    call screen 100.
  endif.
*&---------------------------------------------------------------------*
*&      Module  STATUS_0100  OUTPUT
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
module status_0100 output.
  set pf-status 'CARR'.

endmodule.                 " STATUS_0100  OUTPUT
*&---------------------------------------------------------------------*
*&      Module  USER_COMMAND_0100  INPUT
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
module user_command_0100 input.
  case sy-ucomm.
    when 'BACK' or 'CANCEL' or 'EXIT'.
      leave to screen 0.
  endcase.
endmodule.                 " USER_COMMAND_0100  INPUT