Skip to Content
avatar image
Former Member

OO ALV two grids -- need background as well (Fatal error GUI not reached)


I have a report based on UWE's two grids example.

The Top and bottom parts both contain data which needs to be printed

However there is now a requirement to be able to run this in the background as well.

UWE's report basically creates a Docking container with splitters and will only run ONLINE.

Now if you ALREADY use a docking container then the examples I've seen posted won't work because the report creation starts from the premise that if the report is ONLINE then you create the Custom container but if it's Batch then you create a docking container.

UWE's report uses a Docking container right from the start (no custom control container).

I messed around with creating another docking container but still get the Fatal error GUI not reached

I suppose I could change the report to use a custom container but I really need the Grids to be "Top and Bottom" with no gaps between them etc (as per UWE's Two Grids report).

Please OO only (No REUSE function module groups).

Note also this system doesn't have the new salv classes so it will have to be based on cl_gui_alv_grid.



Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

1 Answer

  • avatar image
    Former Member
    Jul 17, 2008 at 07:07 AM

    I'm going to reply to my own question here -- nobody seems to have an answer for this one

    however I can essentially make it work via a bit of "poodle faking".

    I basically have 2 lists -- one of Errors and one of the data . These are normally displayed in Foreground on a single screen using the SPLITTER control but of course this won't work in batch.

    What I essentially do is to let the ist list print normally (the data list) and create the 2nd list via submitting a small program with export list to memory.

    After the main list has printed I retrieve the 2nd list and print that -- although you get 2 spool lists it does work. It's better also printing from the main program as the user can easily identify his / her output.

     ..... extract
    describe table t_errors lines lv_tab.
      if lv_tab > 0.    " Only if there is data to print
        if sy-batch = 'X'.  "  only if batch
    * Note here that because of the way the OO GRID control framework
    * is set up there is a problem of  printing multiple GRIDS  in the background when
    * you have multiple grids on a single screen.
    * The control framework only prints the ist Grid when running in background
    * The get around here is to use the "Old Fashioned"  REUS LIST DISPLAY
    * module  to print the secondary list but note again if this is used from the main OO program
    * the spool program will overwrite this in our call to screen 100
    *  and You'll only get a single list of the primary grid.
    * So the not very elegant solution is simply to pass the field catalog
    * and table data and call an external program generate the list.
    * Note the field catalog is a little different from the OO CL_GUI_ALV_GRID
    * but the fields we are interested are essentially the same ones.
    * so we create the SLIS type of field catalog and pass the data
    * to zr_mm_0021a to create the the error listing
    * which we print at the end of the program. The spool list is
    * imported back into this program where it is printed
    * after SCREEN 100 has been processed.
    * Screen 100 is exited after PBO with set screen 0, leave screen sequence
    * so normal list processing can print the list after the primary
    * OO ALV list has been printed without the spool manager overwriting the list..
    *It doesn't seem possible currently to print multiple ALV lists
    * via OO CL_GUI_ALV_GRID when run in the background
      * generate SLIS type of fieldcat
          loop at it_fldcat1 into wa1_it_fldcat1.
            move-corresponding wa1_it_fldcat1 to lv_fieldcat.
    * Create column header titles for the secondary list
            case lv_fieldcat-fieldname.
              when 'CAT'.
                lv_fieldcat-seltext_m  =  'Error'.
                lv_fieldcat-ddictxt = 'M'.
                lv_fieldcat-outputlen =  12.
              when 'MATNR'.
                lv_fieldcat-seltext_m  =  'Material Number'.
                lv_fieldcat-ddictxt = 'M'.
                lv_fieldcat-outputlen =  16.
              when 'MAKTX'.
                lv_fieldcat-seltext_l  =  'Material Description'.
                lv_fieldcat-ddictxt = 'L'.
                lv_fieldcat-outputlen =  23.
              when 'MTART'.
                lv_fieldcat-seltext_m  =  'Mat.Type'.
                lv_fieldcat-ddictxt = 'M'.
                lv_fieldcat-outputlen =  12.
              when 'MATKL'.
                lv_fieldcat-seltext_m  =  'Mat.Grp'.
                lv_fieldcat-ddictxt = 'M'.
                lv_fieldcat-outputlen =  12.
              when 'WERKS'.
                lv_fieldcat-seltext_m  =  'Plant'.
                lv_fieldcat-ddictxt = 'M'.
                lv_fieldcat-outputlen =  12.
              when 'MESS'.
                lv_fieldcat-seltext_l  =  'Error Description'.
                lv_fieldcat-ddictxt =  'L'.
                lv_fieldcat-outputlen =  40.
            append lv_fieldcat to ta_fieldcat.
            clear lv_fieldcat.
          assign ta_fieldcat[] to <a>.
          assign t_errors[] to <b>.
          export <a>  to memory id 'katalog'.   " the field catalog
          export <b> to memory  id 'errortab'.  "data table 
    * Note we need to retrieve the generated spool list later 
          submit zr_mm_0021a
          exporting list to memory
          and return.
          call function 'LIST_FROM_MEMORY'
              listobject = ta_abaplist.
    .... extract
    *after printing  initial grid in background
    * Print the error list created (if any).
    * Note because the Split object is not available in the
    * Background (GUI ctl frame work and objects don't exist in the background))
    * only the primary GRID object will be printed
    * so we need to separately print the secondary list
      case sy-batch.
        when 'X'.
          describe table ta_abaplist lines sy-index.
          if sy-index > 0.
            call function 'WRITE_LIST'
                listobject = ta_abaplist.
    * submitted program is 
    program xxxxx.
    type-pools:  slis.
    * Generates error report for Inventory aging when run in batch
    * Normal splitter only prints ist list.
     types:  ls_fieldcat type slis_fieldcat_alv.
      data: lv_fieldcat type ls_fieldcat.
      data: ta_fieldcat type ls_fieldcat occurs 1.
    types: begin of ty_errors,
              cat      type icon-id,
              matnr    type mara-matnr,
              maktx    type makt-maktx,
              mtart    type mara-mtart,
              matkl    type mara-matkl,
              werks    type marc-werks,
              mess(40)  type c,
              end of ty_errors.
      data  t_errors  type table of ty_errors.
      field-symbols : <a> type standard table,
                      <b> type standard table.
      data: g_repid like sy-repid.
    g_repid = sy-repid.
    assign ta_fieldcat to <a>.
    assign t_errors to <b>.
    import <a>  from memory id 'katalog'.   " Field catalog created from main program
    import <b> from memory id 'errortab'.   "Data table passed from main table
    call function 'REUSE_ALV_LIST_DISPLAY'
          i_callback_program = g_repid
          it_fieldcat        = <a>[]
          t_outtab          =  <b>[].
    * end

    Not very elegant but it works.



    Add comment
    10|10000 characters needed characters exceeded

    • Former Member


      I just encounter this issue,

      I have two comments about this

      1, SALV can solve batch alv run.

      data or_doc type ref to cl_gui_docking_container,

      if cl_gui_alv_grid=>offline( ) is initial.

      if lv_container is initial.

      create object lv_container


      container_name = 'GD_CONTAINER'.



      call method cl_salv_table=>factory


      r_container = lv_container

      container_name = 'GD_CONTAINER'


      r_salv_table = lv_table


      t_table = p_output[].

      catch cx_salv_msg .




      call method cl_salv_table=>factory


      r_container = or_doc

      container_name = 'GD_CONTAINER'


      r_salv_table = lv_table


      t_table = p_output[].

      catch cx_salv_msg .



      2, if use method set_table_for_first_display

      a, you should use exist structure for reference ,

      b, container should be difference setting

      Refer to std program BCALV_GRID_02

      it can run background job directly .

      and code should be :

      if CL_GUI_ALV_GRID=>offline( ) is INITIAL .

      create object custom_container


      container_name = cont_for_flights


      cntl_error = 1

      cntl_system_error = 2

      create_error = 3

      lifetime_error = 4

      lifetime_dynpro_dynpro_link = 5.

      if sy-subrc ne 0.

      • add your handling, for example

      call function 'POPUP_TO_INFORM'


      titel = g_repid

      txt2 = sy-subrc

      txt1 = 'The control could not be created'(510).


      endif." just importing container for foreend run .

      • create an instance of alv control

      create object grid1

      exporting i_parent = custom_container.


      • Set a titlebar for the grid control


      gs_layout-grid_title = 'Flights'(100).

      call method grid1->set_table_for_first_display

      exporting i_structure_name = 'SFLIGHT'

      is_layout = gs_layout

      changing it_outtab = gt_sflight.