Layout variant error

Please find code below. When I run this report with transaction it gives variant error .How can I fix this problem
REPORT yiwm_uom_stock                         .
*---Data Include
INCLUDE yiwm_uom_stock_data.
*INITIALIZATION.
PERFORM initialize_variant.
*----ON SELECTION SCREEN
AT SELECTION-SCREEN ON VALUE-REQUEST FOR p_vari.
  PERFORM f4_for_variant .
*---START-OF-SELECTION
START-OF-SELECTION.
  PERFORM get_data.
  PERFORM write_data .
*&      Form  get_data
FORM get_data.
*--Quants of stock with selection screen.
  SELECT werks lgort lgnum gesme
         verme einme ausme lgpla
         lgtyp matnr lqnum
    FROM lqua
    INTO CORRESPONDING FIELDS OF TABLE gt_itab
   WHERE werks IN s_werks
     AND lgnum EQ p_lgnum
     AND lgort IN s_lgort
     AND lgtyp IN s_lgtyp
     AND kober IN s_kober
     AND matnr IN s_matnr.
  LOOP AT gt_itab.
    CLEAR lagp .
    SELECT SINGLE  lgtyp lgber lptyp plauf skzua skzue skzsa skzse
                   skzsi spgru anzqu maxqu anzle maxle btanr btaps
                   kzdyn lgewi gewei mgewi bdatu bzeit ivivo sorlp
                   rdatu rzeit kzinv idatu ivnum ivpos brand uname
                   laedt kober reihf verif
             FROM  lagp
      INTO CORRESPONDING FIELDS OF gt_itab
     WHERE  lgnum = gt_itab-lgnum
       AND  lgpla = gt_itab-lgpla
       AND  lgtyp = gt_itab-lgtyp.
    CLEAR mara.
    SELECT SINGLE matnr meins zzshmat matkl
                  mtart ean11 zzkshrtyp
      FROM mara
      INTO CORRESPONDING FIELDS OF gt_itab
     WHERE matnr EQ gt_itab-matnr.
    CLEAR marm.
    SELECT SINGLE meinh umrez umren breit hoehe
                  meabm volum voleh brgew gewei
      FROM marm
      INTO CORRESPONDING FIELDS OF gt_itab
     WHERE matnr EQ gt_itab-matnr
       AND meinh EQ p_meinh.
    CLEAR mlgn.
    SELECT SINGLE ltkza ltkze lgbkz block
                  bsskz l2skr mkapv
      FROM mlgn
      INTO CORRESPONDING FIELDS OF gt_itab
     WHERE matnr EQ gt_itab-matnr
       AND lgnum EQ gt_itab-lgnum.
    CLEAR mlgt.
    SELECT SINGLE lgpla lpmax lpmin
                  mamng nsmng kober rdmng
     FROM mlgt
     INTO CORRESPONDING FIELDS OF gt_itab
     WHERE lgnum EQ gt_itab-lgnum
       AND lgpla EQ gt_itab-lgpla
       AND matnr EQ gt_itab-matnr
       AND lgtyp EQ gt_itab-lgtyp.
    CLEAR makt.
    SELECT SINGLE maktx
      FROM makt
      INTO gt_itab-maktx
     WHERE matnr EQ gt_itab-matnr.
    MODIFY  gt_itab.
    CLEAR   gt_itab.
  ENDLOOP.
ENDFORM.                    "get_data
     Form  write_data                                              *
FORM write_data.
  PERFORM find_list_header.
  PERFORM fill_field_cat TABLES gt_fldcat
                         USING  'GT_ITAB'
                                'YIWM_UOM_STOCK'.
  gv_repid = sy-repid.
  gs_variant-report  = sy-repid.
  gs_variant-variant = p_vari.
  CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
    EXPORTING
      i_buffer_active    = ' '
      i_callback_program = gv_repid
      i_default          = 'X'
      i_save             = 'A'
      is_layout          = gs_layout
      it_fieldcat        = gt_fldcat[]
      is_variant         = gs_variant
    TABLES
      t_outtab           = gt_itab.
ENDFORM.                    " write_data
    Form  find_list_header                                         *
FORM find_list_header.
  CLEAR : gt_header, gt_header[].
  gt_header-typ  = 'H'.
  sy-title = 'UOM STOCK REPORT'.
  MOVE sy-title TO gt_header-info.
  APPEND gt_header.
ENDFORM.                    " find_list_header
    Form  fill_field_cat                                           *
FORM fill_field_cat  TABLES gt_fldcat
                      USING p_intname
                            p_inclname.
  CALL FUNCTION 'REUSE_ALV_FIELDCATALOG_MERGE'
    EXPORTING
      i_program_name         = sy-repid
      i_inclname             = p_inclname
      i_internal_tabname     = p_intname
    CHANGING
      ct_fieldcat            = gt_fldcat[]
    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.
  ENDIF.
ENDFORM.                    " fill_field_cat
*&      Form  INITIALIZE_VARIANT
      text
FORM initialize_variant .
  g_save = 'A'.
CLEAR g_variant.
g_variant-report = sy-repid.
gx_variant = g_variant.
  CALL FUNCTION 'REUSE_ALV_VARIANT_DEFAULT_GET'
    EXPORTING
      i_save     = g_save
    CHANGING
      cs_variant = gx_variant
    EXCEPTIONS
      not_found  = 2.
  IF sy-subrc = 0.
    p_vari = gx_variant-variant.
  ENDIF.
ENDFORM.                               " INITIALIZE_VARIANT
*&      Form  F4_FOR_VARIANT
      text
FORM f4_for_variant.
  gs_variant-report  = sy-repid.
  gs_variant-variant = p_vari.
  CALL FUNCTION 'REUSE_ALV_VARIANT_F4'
    EXPORTING
      is_variant = gs_variant
      i_save     = g_save
    IMPORTING
      e_exit     = g_exit
      es_variant = gx_variant
    EXCEPTIONS
      not_found  = 2.
  IF sy-subrc = 2.
    MESSAGE ID sy-msgid TYPE 'S'      NUMBER sy-msgno
            WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
  ELSE.
    IF g_exit = space.
      p_vari = gx_variant-variant.
    ENDIF.
  ENDIF.
ENDFORM.                               " F4_FOR_VARIANT
*&      Form  PAI_OF_SELECTION_SCREEN
      text
FORM pai_of_selection_screen.
IF NOT p_vari IS INITIAL.
   MOVE g_variant TO gx_variant.
   MOVE p_vari TO gx_variant-variant.
   CALL FUNCTION 'REUSE_ALV_VARIANT_EXISTENCE'
     EXPORTING
       i_save     = g_save
     CHANGING
       cs_variant = gx_variant.
   g_variant = gx_variant.
ELSE.
   PERFORM initialize_variant.
ENDIF.
ENDFORM.                               " PAI_OF_SELECTION_SCREEN

Hi Narendan ..
I changed but it is already leave to the code screen (leave program). I think it will be useful to send complete code again .Please remember , it gives  error only call with transaction.
REPORT yiwm_uom_stock                         .
*---Data Include
INCLUDE yiwm_uom_stock_data.
INITIALIZATION.
  PERFORM initialize_variant.
*----ON SELECTION SCREEN
AT SELECTION-SCREEN ON VALUE-REQUEST FOR p_vari.
  PERFORM f4_for_variant .
*---START-OF-SELECTION
START-OF-SELECTION.
  PERFORM get_data.
  PERFORM write_data .
*&      Form  get_data
FORM get_data.
*--Quants of stock with selection screen.
  SELECT werks lgort lgnum gesme
         verme einme ausme lgpla
         lgtyp matnr lqnum
    FROM lqua
    INTO CORRESPONDING FIELDS OF TABLE gt_itab
   WHERE werks IN s_werks
     AND lgnum EQ p_lgnum
     AND lgort IN s_lgort
     AND lgtyp IN s_lgtyp
     AND kober IN s_kober
     AND matnr IN s_matnr.
  LOOP AT gt_itab.
    CLEAR lagp .
    SELECT SINGLE  lgtyp lgber lptyp plauf skzua skzue skzsa skzse
                   skzsi spgru anzqu maxqu anzle maxle btanr btaps
                   kzdyn lgewi gewei mgewi bdatu bzeit ivivo sorlp
                   rdatu rzeit kzinv idatu ivnum ivpos brand uname
                   laedt kober reihf verif
      FROM  lagp
      INTO CORRESPONDING FIELDS OF gt_itab
     WHERE  lgnum = gt_itab-lgnum
       AND  lgpla = gt_itab-lgpla
       AND  lgtyp = gt_itab-lgtyp.
    CLEAR mara.
    SELECT SINGLE matnr meins zzshmat matkl
                  mtart ean11 zzkshrtyp
      FROM mara
      INTO CORRESPONDING FIELDS OF gt_itab
     WHERE matnr EQ gt_itab-matnr.
    CLEAR marm.
    SELECT SINGLE meinh umrez umren breit hoehe
                  meabm volum voleh brgew gewei
      FROM marm
      INTO CORRESPONDING FIELDS OF gt_itab
     WHERE matnr EQ gt_itab-matnr
       AND meinh EQ p_meinh.
    CLEAR mlgn.
    SELECT SINGLE ltkza ltkze lgbkz block
                  bsskz l2skr mkapv
      FROM mlgn
      INTO CORRESPONDING FIELDS OF gt_itab
     WHERE matnr EQ gt_itab-matnr
       AND lgnum EQ gt_itab-lgnum.
    CLEAR mlgt.
    SELECT SINGLE lgpla lpmax lpmin
                  mamng nsmng kober rdmng
     FROM mlgt
     INTO CORRESPONDING FIELDS OF gt_itab
     WHERE lgnum EQ gt_itab-lgnum
       AND lgpla EQ gt_itab-lgpla
       AND matnr EQ gt_itab-matnr
       AND lgtyp EQ gt_itab-lgtyp.
    CLEAR makt.
    SELECT SINGLE maktx
      FROM makt
      INTO gt_itab-maktx
     WHERE matnr EQ gt_itab-matnr.
    MODIFY  gt_itab.
    CLEAR   gt_itab.
  ENDLOOP.
ENDFORM.                    "get_data
     Form  write_data                                              *
FORM write_data.
  PERFORM find_list_header.
  PERFORM fill_field_cat TABLES gt_fldcat
                         USING  'GT_ITAB'
                                'YIWM_UOM_STOCK'.
  gv_repid = sy-repid.
  gs_variant-report  = sy-repid.
  gs_variant-variant = p_vari.
  CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
    EXPORTING
      i_buffer_active    = ' '
      i_callback_program = gv_repid
      i_default          = 'X'
      i_save             = 'A'
      is_layout          = gs_layout
      it_fieldcat        = gt_fldcat[]
      is_variant         = gs_variant
    TABLES
      t_outtab           = gt_itab.
ENDFORM.                    " write_data
    Form  find_list_header                                         *
FORM find_list_header.
  CLEAR : gt_header, gt_header[].
  gt_header-typ  = 'H'.
  sy-title = 'UOM STOCK REPORT'.
  MOVE sy-title TO gt_header-info.
  APPEND gt_header.
ENDFORM.                    " find_list_header
    Form  fill_field_cat                                           *
FORM fill_field_cat  TABLES gt_fldcat
                      USING p_intname
                            p_inclname.
  CALL FUNCTION 'REUSE_ALV_FIELDCATALOG_MERGE'
    EXPORTING
      i_program_name         = sy-repid
      i_inclname             = p_inclname
      i_internal_tabname     = p_intname
    CHANGING
      ct_fieldcat            = gt_fldcat[]
    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.
  ENDIF.
ENDFORM.                    " fill_field_cat
*&      Form  INITIALIZE_VARIANT
      text
FORM initialize_variant .
  g_save = 'A'.
  CLEAR g_variant.
  g_variant-report = sy-repid.
  gx_variant = g_variant.
  CALL FUNCTION 'REUSE_ALV_VARIANT_DEFAULT_GET'
    EXPORTING
      i_save     = g_save
    CHANGING
      cs_variant = gx_variant
    EXCEPTIONS
      EXCEPTIONS
      wrong_input = 1
      not_found = 2
      program_error = 3
    OTHERS = 4 .
  IF sy-subrc = 0.
    p_vari = gx_variant-variant.
  ENDIF.
ENDFORM.                               " INITIALIZE_VARIANT
*&      Form  F4_FOR_VARIANT
      text
FORM f4_for_variant.
  gs_variant-report  = sy-repid.
  gs_variant-variant = p_vari.
  CALL FUNCTION 'REUSE_ALV_VARIANT_F4'
    EXPORTING
      is_variant = gs_variant
      i_save     = g_save
    IMPORTING
      e_exit     = g_exit
      es_variant = gx_variant
    EXCEPTIONS
      not_found  = 2.
  IF sy-subrc = 2.
    MESSAGE ID sy-msgid TYPE 'S'      NUMBER sy-msgno
            WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
  ELSE.
    IF g_exit = space.
      p_vari = gx_variant-variant.
    ENDIF.
  ENDIF.
ENDFORM.                               " F4_FOR_VARIANT
*&      Form  PAI_OF_SELECTION_SCREEN
      text
FORM pai_of_selection_screen.
  IF NOT p_vari IS INITIAL.
    MOVE g_variant TO gx_variant.
    MOVE p_vari TO gx_variant-variant.
    CALL FUNCTION 'REUSE_ALV_VARIANT_EXISTENCE'
      EXPORTING
        i_save     = g_save
      CHANGING
        cs_variant = gx_variant.
    g_variant = gx_variant.
  ELSE.
    PERFORM initialize_variant.
  ENDIF.
ENDFORM.                               " PAI_OF_SELECTION_SCREEN

Similar Messages

  • ALV layout variant missing in background job.

    hi guys,
    Having problem on getting the default ALV layout variant when run the job in backgorund. Please advise any correction needed in the following code.
    Thanks.
    *&  Include           Z_MM_KBR_AGSUBCONINV_MOD2                        *
    MODULE status_0100 OUTPUT.
      SET PF-STATUS '100'.
      SET TITLEBAR '100'.
    ENDMODULE.                 " STATUS_0100  OUTPUT
    *&      Module  display_data  OUTPUT
          text
    MODULE display_data OUTPUT.
    IF sy-batch IS INITIAL. "Foreground
      IF w_container IS INITIAL.
        IF cl_gui_alv_grid=>offline( ) IS INITIAL.
    *Creating the container
          CREATE OBJECT w_container
            EXPORTING
              container_name              = c_container
            EXCEPTIONS
              cntl_error                  = 1
              cntl_system_error           = 2
              create_error                = 3
              lifetime_error              = 4
              lifetime_dynpro_dynpro_link = 5
              OTHERS                      = 6.
          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.
    *Creating the ALV GRID
        CREATE OBJECT w_grid
          EXPORTING
            i_parent          = w_container
            i_appl_events     = c_check
          EXCEPTIONS
            error_cntl_create = 1
            error_cntl_init   = 2
            error_cntl_link   = 3
            error_dp_create   = 4
            OTHERS            = 5.
        IF sy-subrc <> 0.
         MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
                    WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
        ENDIF.
        else.
         exit.
        ENDIF.
      ELSE.
    *Creating the ALV GRID
        CREATE OBJECT w_grid
          EXPORTING
            i_parent          = go_dock_container
            i_appl_events     = c_check
          EXCEPTIONS
            error_cntl_create = 1
            error_cntl_init   = 2
            error_cntl_link   = 3
            error_dp_create   = 4
            OTHERS            = 5.
        IF sy-subrc <> 0.
          WRITE:/ 'Error in grid'.
        ENDIF.
         CREATE OBJECT w_grid
          EXPORTING  i_parent = go_dock_container.
      ENDIF.
    *getting the variant option
        wa_variant-report     = sy-repid.
        wa_variant-username   = sy-uname.
        wa_layout-grid_title  = sy-title.
        wa_layout-cwidth_opt  = c_check.
        wa_layout-zebra       = c_check.
        wa_layout-no_f4       = c_check.
        wa_layout-sel_mode    = 'D'.
    *Excluding the unwanted buttons
         PERFORM exclude_toolbar_buttons.
    build field catalog.
        CALL FUNCTION 'LVC_FIELDCATALOG_MERGE'
          EXPORTING
            i_buffer_active        = c_check
            i_structure_name       = c_fcat_str
            i_bypassing_buffer     = c_check
          CHANGING
            ct_fieldcat            = t_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.
        ENDIF.
        loop at t_fieldcat into w_fieldcat.
         if w_fieldcat-FIELDNAME = 'AGING1'.
          W_FIELDCAT-NO_ZERO = 'X'.
          MODIFY t_fieldcat FROM W_FIELDCAT INDEX SY-TABIX.
         ENDIF.
        endloop.
    Generate sort critria
        PERFORM generate_sort.
    Create object of class lcl_event_receiver.
        CREATE OBJECT w_event.
    Handler for events.
       SET HANDLER w_event->handle_top_of_page       FOR w_grid.
       SET HANDLER w_event->handle_print_top_of_page FOR w_grid.
       SET HANDLER w_event->handle_print_end_of_list FOR w_grid.
        SET HANDLER w_event->handle_hotspot_click     FOR w_grid.
    *Displaying the alv
       IF NOT sy-batch IS INITIAL.
         PERFORM create_snp.
       ENDIF.
    t_data = i_final.
        CALL METHOD w_grid->set_table_for_first_display
          EXPORTING
            i_save                        = 'A'
            is_layout                     = wa_layout
            is_variant                    = wa_variant
          CHANGING
            it_outtab                     = t_data
            it_fieldcatalog               = t_fieldcat
          EXCEPTIONS
            invalid_parameter_combination = 1
            program_error                 = 2
            too_many_lines                = 3
            OTHERS                        = 4.
        IF sy-subrc <> 0.
        ENDIF.
    ENDIF.
    ENDIF.
    ENDMODULE.                 " display_data  OUTPUT
    *&      Module  user_command_0100  INPUT
          text
    MODULE user_command_0100 INPUT.
      DATA: lt_rows TYPE lvc_t_row,
             w_rows TYPE lvc_s_row.
      CASE sy-ucomm.
        WHEN c_back.
          LEAVE TO SCREEN 0.
        WHEN c_exit.
          LEAVE TO SCREEN 0.
        WHEN c_cancel.
          LEAVE TO SCREEN 0.
       WHEN 'BILDET'.
         CALL METHOD w_grid->get_selected_rows
           IMPORTING
             et_index_rows = lt_rows.
         CALL METHOD cl_gui_cfw=>flush.
         IF sy-subrc EQ 0.
           READ TABLE lt_rows INTO w_rows INDEX 1.
           READ TABLE i_vbfa INTO w_vbfa INDEX w_rows-index.
           IF sy-subrc EQ 0.
             CLEAR i_zbw_br_nf4.
             LOOP AT i_zbw_br_nf3 INTO w_zbw_br_nf3 WHERE
                         refkey = w_vbfa-v_vbeln.
               APPEND w_zbw_br_nf3 TO i_zbw_br_nf4.
             ENDLOOP.
    call dialog screen and display new alv control
             CALL SCREEN 101 STARTING AT 10 5.
           ENDIF.
         ENDIF.
         WHEN 'NOTAF'.
         CALL METHOD w_grid->get_selected_rows
           IMPORTING
             et_index_rows = lt_rows.
         CALL METHOD cl_gui_cfw=>flush.
         IF sy-subrc EQ 0.
           READ TABLE lt_rows INTO w_rows INDEX 1.
           READ TABLE i_zbw_br_nf3 INTO w_zbw_br_nf3 INDEX w_rows-index.
           DATA docnum LIKE j_1bdydoc-docnum.
           docnum = w_zbw_br_nf3-docnum.
           SET PARAMETER ID 'JEF' FIELD docnum.
           CALL TRANSACTION 'J1B3N' AND SKIP FIRST SCREEN.
         ENDIF.
      ENDCASE.
      ENDMODULE.                 " user_command_0100  INPUT
    *&      Form  modify_col_name
          text
         -->P_<FCAT>  text
         -->P_TEXT_H01  text
    FORM modify_col_name  USING  pwa_fcat TYPE lvc_s_fcat
                                 value(pw_text) TYPE any.
      pwa_fcat-coltext   = pw_text.
      pwa_fcat-scrtext_l = pw_text.
      pwa_fcat-scrtext_m = pw_text.
      pwa_fcat-scrtext_s = pw_text.
    ENDFORM.                    " modify_col_name
          FORM display_hotspot                                          *
    FORM display_hotspot USING pw_row_id    TYPE lvc_s_row
                               pw_column_id TYPE lvc_s_col.
      FIELD-SYMBOLS <l_data> TYPE zbrforecast.
    READ TABLE t_br_nf_acum ASSIGNING <l_data> INDEX pw_row_id-index.
    CHECK sy-subrc = 0.
    IF pw_column_id = ' '.
    ENDIF.
    ENDFORM.                    "display_hotspot
    *&      Form  generate_sort
          Genereate Sort criteria
    FORM generate_sort.
    Local variables
    DATA: wal_sort TYPE lvc_s_sort,
           wl_pos   TYPE numc2.
    wl_pos = 01.
    sort ORDER
    wal_sort-spos      = wl_pos.
    wal_sort-fieldname = c_aufnr.
    wal_sort-up        = c_check.
    APPEND wal_sort TO t_sort.
    ENDFORM.                    "generate_sort
    *&      Form  f4_variant
          text
         <--PW_VARI  text
    FORM f4_variant CHANGING pw_vari TYPE disvariant-variant.
    wa_variant-report = sy-cprog.
      CALL FUNCTION 'REUSE_ALV_VARIANT_F4'
        EXPORTING
          is_variant    = wa_variant
          i_save        = c_u
        IMPORTING
          es_variant    = wa_variant
        EXCEPTIONS
          not_found     = 1
          program_error = 2
          OTHERS        = 3.
      IF sy-subrc IS INITIAL.
        pw_vari = wa_variant-variant.
      ELSE.
        MESSAGE s208(00) WITH text-t04.
      ENDIF.
    ENDFORM.                    " f4_variant
    *&      Form  validate_layout
    *This subroutine is to validate the layout
    No parameters are passed to this subroutine
    FORM validate_layout.
    IF NOT p_layout IS INITIAL.
      Check Layout
       wa_variant-report   = sy-repid.
       wa_variant-username = sy-uname.
       wa_variant-variant  = p_layout.
       CALL FUNCTION 'LVC_VARIANT_EXISTENCE_CHECK'
         EXPORTING
           i_save     = c_u
         CHANGING
           cs_variant = wa_variant
         EXCEPTIONS
           OTHERS     = 01.
       IF NOT sy-subrc IS INITIAL.
         SET CURSOR FIELD 'P_LAYOUT'.
         MESSAGE s001(00) WITH text-t06 p_layout.
         STOP.
       ENDIF.
    ELSE.
      clear wa_variant.
    ENDIF.
    ENDFORM.                    " validate_layout
    *&      Form  validate_data
          text
    FORM validate_data .
    PERFORM validate_layout.
    ENDFORM.                    " validate_data

    Hi,
    Before the call to method set_table_for_first_display, populate
    wa_variant-report = sy-repid.
    Best regards,
    Prashant

  • How to pass layout variant in background job?

    Dear Gurus,
    I have set layout variant as PARAMETERS in my program.
    The report will be executed successfully in front-end, but if I set it in background , it will pop up error msg: Program (IS_VARIANT-REPORT) not specified.
    But the alv function I have check...
    CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
        EXPORTING
          I_BYPASSING_BUFFER       = 'X'
          I_CALLBACK_PROGRAM       = W_REPID
          I_GRID_TITLE             = V_GRID_TITLE
          I_CALLBACK_PF_STATUS_SET = 'SET_PF_STATUS'
    *      I_CALLBACK_USER_COMMAND  = 'FORM_USER_COMMAND'
    *      I_STRUCTURE_NAME         = 'ZSDS0005'
          I_SAVE                   = 'A'
          IS_LAYOUT                = I_LAYOUT
    *      IS_VARIANT               = STRU_DISVAR
          IS_VARIANT               = DEF_VARIANTE_F4
          IT_FIELDCAT              = I_FIELDCAT_ALV[]
          IT_SORT                  = XT_SORT[]
        TABLES
          T_OUTTAB                 = IT_OUT
        EXCEPTIONS
          PROGRAM_ERROR            = 1
          OTHERS                   = 2
    Jamie

    Thank you so much, but the sample code have one bug, and  I have already modified the code.
    The variant will be caught only after clicking F4 list, if there's already one default variant, system will ignore it.
    AT SELECTION-SCREEN.
    *  Validating selection screen fields
      PERFORM F_AT_SELECTION_SCREEN.
    *&      Form  f_at_selection_screen
    *       text
    *  -->  p1        text
    *  <--  p2        text
    FORM F_AT_SELECTION_SCREEN .
    * ALV Layout variant
      IF NOT P_VARI IS INITIAL.
        MOVE GX_VARIANT TO G_VARIANT.
        MOVE P_VARI          TO G_VARIANT-VARIANT.
        CALL FUNCTION 'REUSE_ALV_VARIANT_EXISTENCE'
          EXPORTING
            I_SAVE     = 'A'
          CHANGING
            CS_VARIANT = G_VARIANT.
        GX_VARIANT = G_VARIANT.
      ELSE.
        PERFORM F_INITIALIZE_VARIANT.
      ENDIF.
    ENDFORM.                    " f_at_selection_screen
    *&      Form  f_initialize_variant
    *       text
    *  -->  p1        text
    *  <--  p2        text
    FORM F_INITIALIZE_VARIANT .
    *  CLEAR DEF_VARIANTE_F4.
    *  gv_save           = 'X'.
      GX_VARIANT-REPORT = SY-REPID.
    *  DEF_VARIANTE      = DEF_VARIANTE_F4.
      CALL FUNCTION 'REUSE_ALV_VARIANT_DEFAULT_GET'
        EXPORTING
          I_SAVE     = G_SAVE
        CHANGING
          CS_VARIANT = GX_VARIANT
        EXCEPTIONS
          NOT_FOUND  = 2.
      IF SY-SUBRC = 0.
        P_VARI = GX_VARIANT-VARIANT.
      ENDIF.
    ENDFORM.                    " f_initialize_variant

  • Layouts - Variant &1 does not exist for version &2 of layout module &3

    Hi Sap All.
    when i am trying to create IDOC's of type LAYMOD01 using LSMW with IDOC Object type ,there were some IDOC;s failing in SAP With status 51 saying as  "Layouts - Variant &1 does not exist for version &2 of layout module &3".
    the following below text explain you the error message related to one particular IDOC of type LAYMOD 01 which was failed in sap with status 51 :
    Variant 6325 does not exist for version 0000 of layout module EC-83-0214
    can any one explain me the reason on why the IDOC's were failed.
    regards.
    Varma

    not required any more

  • Layout variant not working

    Hi ,
      I have executed a report . I hide one column and saved the layout. The layout name comes on to the selection screen parameter which i have defined on the selection screen.
    PARAMETERS: p_vari LIKE disvariant-variant. " ALV Variant
    i have made the i_save = 'A' and is_default = 'x'. and also used other function modules reg. Variants.
    but if i select the layout variant in the selection screen and execute it is not working . the hidden column also coming on the output.
    But if the select the layout variant on the output of the report from the icon select layout it is working fine. the column which i have hidden is not coming. it is perfect. why it is not working when i select the variant in the selection screen.
    Regards,
    Rose.

    Hi,
    Please try this code
    AT SELECTION-SCREEN ON VALUE-REQUEST FOR p_vari.
      w_variant-report = sy-repid.
    * Function module to show the variant of a ALV report
      CALL FUNCTION 'REUSE_ALV_VARIANT_F4'
        EXPORTING
          is_variant = w_variant
          i_save     = 'A'
        IMPORTING
          es_variant = w_kvariant
        EXCEPTIONS
          not_found  = 2.
      IF sy-subrc = 2.
        MESSAGE ID sy-msgid TYPE 'S'      NUMBER sy-msgno
                WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
      ELSE.
        p_vari = w_kvariant-variant.
      ENDIF.
    END-OF-SELECTION.
    MOVE w_variant TO w_kvariant.
        MOVE p_vari TO w_kvariant-variant.
        MOVE sy-repid TO w_kvariant-report.
    *   Function module to check the variant existence
        CALL FUNCTION 'REUSE_ALV_VARIANT_EXISTENCE'
          EXPORTING
            i_save     = w_save
          CHANGING
            cs_variant = w_kvariant.
        w_variant = w_kvariant.          
    CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
        EXPORTING
          i_callback_program          = sy-repid
          i_callback_pf_status_set    = 'SET_PF_STATUS'
          i_callback_user_command     = 'USER_COMMAND'
          i_callback_html_top_of_page = 'HTML_HEADING'
          i_grid_title                = text-t06
          i_grid_settings             = wa_grid_set
          is_layout                   = wa_layout
          it_fieldcat                 = t_fieldcat
          i_save                      = 'X'
          is_variant                  = w_variant
          is_print                    = wa_print
        TABLES
          t_outtab                    = t_header
        EXCEPTIONS
          program_error               = 1
          OTHERS                      = 2.
      IF sy-subrc <> 0.
        CASE sy-subrc.
          WHEN 1. RAISE program_error.
          WHEN 2. RAISE others.
        ENDCASE.
      ENDIF.
    Regards
    Krishna
    Edited by: Krishna Gowrneni on Apr 17, 2009 5:27 PM

  • Layout variant is not working in background in ALV report

    Hi,
    I have one LAV report to send the report output through mail in foreground and backgroud.Final internal table is having 46 fileds to display the output.But here user is saving the layout variant and sending that layout variant output to mail id in excel format with zip file.Its working in foreground.But in background its not working.Even if we select the layout variant,its sending all the 46 fileds to mail.
    here we have used the below FM to update the fieldcat itab.
    CALL FUNCTION 'REUSE_ALV_GRID_LAYOUT_INFO_GET'
        IMPORTING
          et_fieldcat   = it_fieldcat[]
          es_variant    = v_disvariant
        EXCEPTIONS
          no_infos      = 1
          program_error = 2
          OTHERS        = 3.
    In for ground NO_OUT = 'x' for non selected fields and NO_OUT = ' ' for selected fields.
    But in background NO_OUT = ' ' for all the fileds, even if we select the layout variant.
    Please suggest me  with the solution.
    Regards,
    Jayaram

    hi ,
    Do according to this
    SORT t_ekbe by belnr.
      if  t_ekbe[] is not initial  .
          SELECT  MBLNR
            BWART
            SMBLN
            ERFMG   " This is the new added field
            erfme     " This is the new added field
          INTO CORRESPONDING FIELDS OF TABLE t_mseg
        for all entries in t_ekbe
          from mseg
          where mblnr = t_ekbe-belnr
          AND   bwart = '101'.
      endif.
    after this
    loop at t_ekbe .
    loop at t_mseg  where mblnr  = t_ekbe-belnr .
      t_ekbe-ERFMG = t_mseg-ERFMG .
    t_ekbe-erfme =   t_mseg-erfme  .
    modify t_ekbe transporting ERFMG  erfme .
    clear t_mseg .
    endloop.
    clear t_ekbe .
    endloop.
    Regards
    Deepak .

  • Unable to save the ALV layout variant and display of selection screen on F4

    Hi All,
    The end user wants to directly select the layout variant (SLIS_VARI). I have used the following code to display the layout variant on selection screen. But, I am unable to save the variant on ALV. Whenever I am trying to select the layout variants (by doing F4 on selection screen) its displaying "No Layout found".
    Following is the code for displaying layout variant:
    PARAMETERS: p_var TYPE slis_vari.
    AT SELECTION-SCREEN ON VALUE-REQUEST FOR p_var.
      PERFORM f4_variant CHANGING p_var.
    FORM f4_variant  CHANGING c_variant TYPE slis_vari.
      DATA: ls_variant TYPE disvariant,
                l_exit     TYPE char1.
      ls_variant-report = sy-repid.
      CALL FUNCTION 'REUSE_ALV_VARIANT_F4'
        EXPORTING
          is_variant = ls_variant
          i_save     = 'A'
        IMPORTING
          e_exit     = l_exit
          es_variant = ls_variant
        EXCEPTIONS
          not_found  = 2.
      IF sy-subrc = 2.
        MESSAGE ID sy-msgid TYPE 'S' NUMBER sy-msgno
                WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
      ELSE.
        IF l_exit EQ space.
          c_variant = ls_variant-variant.
        ENDIF.
      ENDIF.
    ENDFORM.                    " f4_variant
    and following is the code for displaying the ALV:
    FORM edition_alv.
      ws_variant2 = ls_variant.
    * Call ALV editor in list mode
      IF p_list = 'X'.
        CALL FUNCTION 'REUSE_ALV_LIST_DISPLAY'
          EXPORTING
            i_callback_program      = ws_extract1-report
            i_callback_user_command = ws_user_command
            is_layout               = ws_layout
            it_fieldcat             = wt_fieldcat
            it_sort                 = wt_sort
            i_save                  = 'A'
            is_variant              = ws_variant2
            it_events               = wt_events[]
          TABLES
            t_outtab                = wt_edition.
    * Call ALV editor in grid mode
      ELSE.
        CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
          EXPORTING
            i_callback_program      = ws_extract1-report
            i_callback_user_command = ws_user_command
            it_fieldcat             = wt_fieldcat
            it_sort                 = wt_sort
            i_save                  = 'A'
            is_variant              = ws_variant2
            it_events               = wt_events[]
          TABLES
            t_outtab                = wt_edition.
      ENDIF.
    ENDFORM.  
    I am not sure whats going wrong, but I am unable to save variants.
    Please help.
    Thanks,
    Vishal.

    The F4 will display you the existing layouts only. So you need to save the layout first & then execute the report again & check if you are getting F4 values for that field.
    The Layout needs to get stored with variant.
    Regards,
    Mahesh

  • Download alv report using layout variant in background

    Hi All,
    I want to download an Alv report using layout varaint in background job.
    can any one please help me.
    i.e...
    I am facing a problem in downloading a text file to the Application server.
    My requirement is, when the user downloads a file with the layout variant, the file should have only the columns which was selected in the variant.
    Will rewards to helpfull ans
    regards
    Chetan

    hey seshu,
    I am facing a problem in downloading a text file to the Application server.
    My requirement is, when the user downloads a file with the layout variant, the file should have only the columns which was selected in the variant.

  • DB Table for Layout Variant in ALV report

    Please help me by providing the table name which will get an entry when we save Layout Variant in ALV(OO ALV grid) output.

    Hi,
    I have seen the table LTDX which is giving me the Variant names for a particular program. Hope this will help you.
    Database table is LTDX
    Database view is V_LTDX.
    Regards,
    Venaktesh

  • Layout Variant.

    Hello,
    This is regarding Layout variant.
    In my program I have called the function module for layout variant . Its working correctly.
    When the user click the change-layout from toolbar.  -> then change_layout screen will come. Up to this it is ok.
    My problem is -
    <b>But there I am not getting the save buttom inside the change_layout screen.
    I need the save button there.</b>
    I am using object oriented method .
    Please help me.
    Thanks in advance.
    LIJO JOHN.

    Solved myself.

  • Not printing do_sum value in output while selecting layout variant

    Hi experts,
       I had created layout variant for selection screen . if i dont put layout variant it show proper output with do_sum value(TOTAL), but when i save screen layout variant as both default and user-specific , it gives output but the field having do_sum value in fieldcatlog  is not showing do_sum vaule(TOTAL), it show all record but not there total. So please tell me what should be done to show the do_sum value(Total).
    Thanks In Advance,
    Ashish

    Hi Anish,
    Try using gs_layout-no_totline =  ' '.
    Thanks,
    Regards
    Kiran

  • Using Layout Variant in jobs that are scheduled to run in background

    Hi Guys,
    I have an issue in using the "layout variant" in running a report in the background. Here is what i do to run a report.
    I select a "selection Variant" and at the bottom of the Report input screen, I choose an User- Specific "Layout Variant" which i have saved with few columns only to show in the report.
    When i run this in foreground, i am able to get the report with my "Layout variant" with only my selected columns. I could also export this output and it looks fine in excel.
    When i run the same report with the same "Layout Variant" in background and save it to my local desktop as an excel file, my "Layout Variant" doesn't seem to work and i am getting all the columns and fields of the reports as such.
    Is this the way, the "Layout variants" will work? Whether this will not work in background jobs? Is this the way standard SAP work?
    Please guide me...
    Good rating points will be given for useful inputs..
    Anand Viswanathan

    Standard SAP functionality

  • Report Layout variant missing in ECC6

    Hi All,
    we are going for upgrade from 4.6 to ECC6. In ECC6 in most of report's  report layout variant are missing in ECC6.But our client want same variant in ECC6 as in 4.6.
    Please sugest how to over come this issue.
    Thanks
    Mohit Khandelwal

    Mohit,
    I think you can try out this...
    Include the variant in a transport request and give the transport req no to the basis guy; and inform him to import the same req no into ECC6 version.
    He can export the transport req no from 4.6 to windows desktop and then he can import the same into ECC 6 system.
    I hope this will solve your issue.
    - Seenu
    Edited by: Sreenivasulu Nallani on Jan 25, 2010 12:24 PM

  • Issues in Change layout Variant of ALV grid

    Hi all,
    I am using a ALV gird to display the data with some table column. I am able to save/ choose the Layout variant. I choose the existing layout varaint it works fine but when I change the column fields display from selected layout then it will immidiately looks fine, but if I perform some event, it goes to the initial stage of the choosed layout varaint.
    I can solve this issue if I clear the Variant from the is_variant (of set_table_for_first_display method). So if I can find the fieldcatalog for layout Variant, then it will solved very easily.
    Please suggest, if you have any idea on this.
    Thanks,
    Sanket Sethi

    I got the solution. You can find the Variant field catalog by using Function module 'LVC_VARIANT_SELECT'. You can set the dialog box based on your requirements as well. So closing this thread. Thanks..

  • Issue in setting layout variant in ALV tables

    Hi,
    I have 2 ALV’s displaying in a view, 1’st is a header data & 2’nd Item data.
    Based on the row selection in the Header ALV, the data is determined and displayed in the 2’nd ALV i.e., the Item data.
    Now the 2’nd ALV (Item data) can contain 20 columns so based on certain requirement I want to save a layout variant with only 10 Columns for display in the 2’nd ALV.
    But the issue what is happening is once I change my row selection in the 1’st ALV (Header data) the layout in the second ALV is refreshing back to the 20 fields EVEN though the name of the variant layout still displays the one I saved earlier.
    I have searched the SCN for this issue and found http://scn.sap.com/thread/1986147, but it does NOT work.
    Could anyone please suggest a solution.
    Thanks & Regards,
    Divaker

    Hi Katrice,
          Thank you for the reply and the links, I will go through them, but please find below the code that I presently have in place, could you please advise if there is anything missing or wrong in here.
    Thanks & Regards,
    Divaker
      lo_cmp_usage =   wd_this->wd_cpuse_pwq_alv( ).
      IF lo_cmp_usage->has_active_component( ) IS INITIAL.
        lo_cmp_usage->create_component( ).
      ENDIF.
      lo_interfacecontroller =   wd_this->wd_cpifc_pwq_alv( ).
    * enable column adjustment
      lv_value = lo_interfacecontroller->get_model( ).
    *-- Get the API reference
      lo_api_interfacecontroller  = lo_interfacecontroller->wd_get_api( ).
      CALL METHOD lo_api_interfacecontroller->get_personalization_manager
        RECEIVING
          pers_manager = lo_pers.
      IF lo_pers IS NOT INITIAL.
        CALL METHOD lo_pers->get_variants
          RECEIVING
            variants = lt_var.
      ENDIF.
      IF lt_var IS NOT INITIAL.
        READ TABLE lt_var INTO ls_var INDEX 1.
        IF sy-subrc = 0.
          ls_config_key-config_id   = ls_var-config_id.
          ls_config_key-config_type = ls_var-config_type.
          ls_config_key-config_var  = ls_var-config_var.
        ENDIF.
        TRY.
            CALL METHOD lo_pers->set_default_variant
              EXPORTING
                config_key = ls_config_key
                set        = abap_true.
          CATCH cx_wd_personalization .
        ENDTRY.
        CALL METHOD lo_pers->load_config_by_key
          EXPORTING
            config_key            = ls_config_key
            fetch_default_variant = abap_true.
      ENDIF.

Maybe you are looking for