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

Similar Messages

  • Changing layout at runtime, executing background job and sending mail inXLS

    Hi
    When i execute my program in foregroung by manually changing value of s_job = 'X' in debugging mode it is sending the correct XLS file via mail with all the data , whereas  when i execute my program in backgroud mode it sends incomlete XLS file via mail, it has only first 2 records in any layout........can anybody please help in this regard....
    program is as follows...
    REPORT ZPMACR01_MD_MRP_100.
    *& Report :  ZPMACR01_MD_MRP_100
    TABLES : MARA, MARC, MAKT, MBEW,MARD.
    MAIL data declarations
    TABLES : adr6 , sscrfields.
    DATA: BEGIN OF mbody OCCURS 0,
          message(100),
          END OF mbody.
    DATA: BEGIN OF addresses OCCURS 0,
          addresses(100),
          END Of addresses.
    FIELD-SYMBOLS: <f> type ANY,
                   <tab> TYPE STANDARD TABLE,
                   <wa> type ANY.
    DATA: count TYPE i value 0,
          col_1 TYPE i.
    DATA: new_table TYPE REF TO data, "pointer to dynamic table
          new_line  TYPE REF TO data. "pointer to work area of dynamic table
    DATA: s_job TYPE c.
    DATA: i_data_out_text TYPE string OCCURS 0 WITH HEADER LINE.
    DATA: message TYPE string OCCURS 0 WITH HEADER LINE.
    DATA:  it_message TYPE STANDARD TABLE OF solisti1 INITIAL SIZE 0
           WITH HEADER LINE.
    DATA:  BEGIN OF it_attach OCCURS 0,
             line(2650) TYPE c,
           END OF it_attach.
    DATA:   t_packing_list LIKE sopcklsti1 OCCURS 0 WITH HEADER LINE,
            t_hex LIKE solix OCCURS 0 WITH HEADER LINE,
            t_receivers LIKE somlreci1 OCCURS 0 WITH HEADER LINE,
            w_cnt TYPE i,
            w_sent_all(1) TYPE c,
            w_doc_data LIKE sodocchgi1,
            gd_error    TYPE sy-subrc,
            gd_reciever TYPE sy-subrc.
    ALV data declarations
    TYPE-POOLS: SLIS.
    DATA : IT_FIELDCAT TYPE SLIS_T_FIELDCAT_ALV,
           IT_FIELDCAT2 TYPE LVC_T_FCAT,
           IT_FIELDCAT_FIN TYPE LVC_T_FCAT,
           IT_FIELDCAT3 TYPE SLIS_T_FIELDCAT_ALV,
           itab1 TYPE SLIS_T_FIELDCAT_ALV,
           W_FIELDCAT TYPE SLIS_FIELDCAT_ALV,
           W_REPID TYPE SY-REPID,
           IT_LAYOUT TYPE SLIS_LAYOUT_ALV.
    DATA: is_fieldcat LIKE LINE OF it_fieldcat.
    DATA: is_fieldcat2 LIKE LINE OF it_fieldcat2,
    Is_FIELDCAT3 LIKE LINE OF it_fieldcat3.
    Data: variant type  DISVARIANT,
          v_size LIKE sy-tabix.
    ALV Data
    DATA:
           i_sort TYPE slis_t_sortinfo_alv,
           v_lvc_title   TYPE lvc_title,
           v_repid       LIKE sy-repid,
           c_user_command TYPE slis_formname  VALUE 'ALV_USER_COMMAND',
           gt_list_top_of_page TYPE slis_t_listheader,
           gt_list_end_of_list TYPE slis_t_listheader,
           gs_layout TYPE slis_layout_alv,
           gt_events      TYPE slis_t_event,
           gs_events      type slis_alv_event,
           gt_print       TYPE slis_print_alv,
           g_top_of_page  TYPE slis_formname VALUE 'TOP_OF_PAGE'.
    Selection Parameters
    SELECTION-SCREEN BEGIN OF BLOCK B1.
    SELECT-OPTIONS : SO_MATNR FOR MARA-MATNR OBLIGATORY.
    SELECT-OPTIONS : SO_WERKS FOR MARC-WERKS.
    SELECT-OPTIONS : SO_SPRAS FOR MAKT-SPRAS.
    SELECT-OPTIONS : SO_BWKEY FOR MBEW-BWKEY.
    SELECTION-SCREEN END OF BLOCK B1.
    SELECTION-SCREEN BEGIN OF BLOCK B2 WITH FRAME TITLE TEXT-001.
    PARAMETERS: p_email TYPE somlreci1-receiver
                                      default '[email protected]'.
    SELECTION-SCREEN END OF BLOCK B2.
    SELECTION-SCREEN BEGIN OF BLOCK B3 WITH FRAME TITLE TEXT-002.
    PARAMETERS : SO_LAY TYPE DISVARIANT-VARIANT DEFAULT '/DEFAULT'.
    SELECTION-SCREEN END OF BLOCK B3.
    DATA Declarations.
    Data : BEGIN OF ITab OCCURS 0,
           manr type mara-matnr,
           end of ITAB.
    data : BEGIN OF IT_TABLE OCCURS 0,
           MATNR TYPE MARA-MATNR,
           MATKL TYPE MARA-MATKL,
           MEINS TYPE MARA-MEINS,
           MTART TYPE MARA-MTART,
           AHDIS TYPE MARC-AHDIS,
           AUSDT TYPE MARC-AUSDT,
           AUTRU TYPE MARC-AUTRU,
           BESKZ TYPE MARC-BESKZ,
           BSTFE TYPE MARC-BSTFE,
           BSTMA TYPE MARC-BSTMA,
           BSTMI TYPE MARC-BSTMI,
           BSTRF TYPE MARC-BSTRF,
           BWSCL TYPE MARC-BWSCL,
           DIBER TYPE MARC-DIBER,
           DISGR TYPE MARC-DISGR,
           DISLS TYPE MARC-DISLS,
           DISMM TYPE MARC-DISMM,
           DISPO TYPE MARC-DISPO,
           DISPR TYPE MARC-DISPR,
           DZEIT TYPE MARC-DZEIT,
           EISBE TYPE MARC-EISBE,
           EISLO TYPE MARC-EISLO,
           EKGRP TYPE MARC-EKGRP,
           FHORI TYPE MARC-FHORI,
           FXHOR TYPE MARC-FXHOR,
           KAUTB TYPE MARC-KAUTB,
           KORDB TYPE MARC-KORDB,
           KZAUS TYPE MARC-KZAUS,
           LFGJA TYPE MARC-LFGJA,
           LFMON TYPE MARC-LFMON,
           LGRAD TYPE MARC-LGRAD,
           LVORM TYPE MARC-LVORM,
           MABST TYPE MARC-MABST,
           MINBE TYPE MARC-MINBE,
           MMSTA TYPE MARC-MMSTA,
           MMSTD TYPE MARC-MMSTD,
           MRPPP TYPE MARC-MRPPP,
           MTVFP TYPE MARC-MTVFP,
           NFMAT TYPE MARC-NFMAT,
           PERKZ TYPE MARC-PERKZ,
           PLIFZ TYPE MARC-PLIFZ,
           PLVAR TYPE MARC-PLVAR,
           PSTAT TYPE MARC-PSTAT,
           QZGTP TYPE MARC-QZGTP,
           RGEKZ TYPE MARC-RGEKZ,
           RWPRO TYPE MARC-RWPRO,
           SBDKZ TYPE MARC-SBDKZ,
           SCHGT TYPE MARC-SCHGT,
           SHFLG TYPE MARC-SHFLG,
           SHPRO TYPE MARC-SHPRO,
           SHZET TYPE MARC-SHZET,
           SOBSL TYPE MARC-SOBSL,
           STRGR TYPE MARC-STRGR,
           TRAME TYPE MARC-TRAME,
           UEETK TYPE MARC-UEETK,
           UEETO TYPE MARC-UEETO,
           UMLMC TYPE MARC-UMLMC,
           UNETO TYPE MARC-UNETO,
           USEQU TYPE MARC-USEQU,
           VINT1 TYPE MARC-VINT1,
           VINT2 TYPE MARC-VINT2,
           VRBDT TYPE MARC-VRBDT,
           VRBFK TYPE MARC-VRBFK,
           VRBMT TYPE MARC-VRBMT,
           VRBWK TYPE MARC-VRBWK,
           VRMOD TYPE MARC-VRMOD,
           WEBAZ TYPE MARC-WEBAZ,
           WERKS TYPE MARC-WERKS,
           WZEIT TYPE MARC-WZEIT,
          DISKZ TYPE MARD-DISKZ,
          LBSTF TYPE MARD-LBSTF,
          LGORT TYPE MARD-LGORT,
          LMINB TYPE MARD-LMINB,
          LSOBS TYPE MARD-LSOBS,
           MAKTX TYPE MAKT-MAKTX,
           END OF IT_TABLE.
    DATA: BEGIN OF IT_MARD OCCURS 0,
           MATNR TYPE MARA-MATNR,
           MATKL TYPE MARA-MATKL,
           MEINS TYPE MARA-MEINS,
           MTART TYPE MARA-MTART,
           DISKZ TYPE MARD-DISKZ,
           LBSTF TYPE MARD-LBSTF,
           LGORT TYPE MARD-LGORT,
           LMINB TYPE MARD-LMINB,
           LSOBS TYPE MARD-LSOBS,
          MAKTX TYPE MAKT-MAKTX,
           END OF IT_MARD.
    DATA: BEGIN OF IT_MBEW OCCURS 0,
           MATNR TYPE MBEW-MATNR,
           BKLAS TYPE MBEW-BKLAS,
           SALK3 TYPE MBEW-SALK3,
           PEINH TYPE MBEW-PEINH,
           STPRS TYPE MBEW-STPRS,
           VERPR TYPE MBEW-VERPR,
           VPRSV TYPE MBEW-VPRSV,
           END OF IT_MBEW.
    data : BEGIN OF IT_FINAL0 occurs 0,
           MATNR LIKE MARA-MATNR,
           MATKL LIKE MARA-MATKL,
           MEINS LIKE MARA-MEINS,
           MTART LIKE MARA-MTART,
           AHDIS LIKE MARC-AHDIS,
           AUSDT LIKE MARC-AUSDT,
           AUTRU LIKE MARC-AUTRU,
           BESKZ LIKE MARC-BESKZ,
           BSTFE LIKE MARC-BSTFE,
           BSTMA LIKE MARC-BSTMA,
           BSTMI LIKE MARC-BSTMI,
           BSTRF LIKE MARC-BSTRF,
           BWSCL LIKE MARC-BWSCL,
           DIBER LIKE MARC-DIBER,
           DISGR LIKE MARC-DISGR,
           DISLS LIKE MARC-DISLS,
           DISMM LIKE MARC-DISMM,
           DISPO LIKE MARC-DISPO,
           DISPR LIKE MARC-DISPR,
           DZEIT LIKE MARC-DZEIT,
           EISBE LIKE MARC-EISBE,
           EISLO LIKE MARC-EISLO,
           EKGRP LIKE MARC-EKGRP,
           FHORI LIKE MARC-FHORI,
           FXHOR LIKE MARC-FXHOR,
           KAUTB LIKE MARC-KAUTB,
           KORDB LIKE MARC-KORDB,
           KZAUS LIKE MARC-KZAUS,
           LFGJA LIKE MARC-LFGJA,
           LFMON LIKE MARC-LFMON,
           LGRAD LIKE MARC-LGRAD,
           LVORM LIKE MARC-LVORM,
           MABST LIKE MARC-MABST,
           MINBE LIKE MARC-MINBE,
           MMSTA LIKE MARC-MMSTA,
           MMSTD LIKE MARC-MMSTD,
           MRPPP LIKE MARC-MRPPP,
           MTVFP LIKE MARC-MTVFP,
           NFMAT LIKE MARC-NFMAT,
           PERKZ LIKE MARC-PERKZ,
           PLIFZ LIKE MARC-PLIFZ,
           PLVAR LIKE MARC-PLVAR,
           PSTAT LIKE MARC-PSTAT,
           QZGTP LIKE MARC-QZGTP,
           RGEKZ LIKE MARC-RGEKZ,
           RWPRO LIKE MARC-RWPRO,
           SBDKZ LIKE MARC-SBDKZ,
           SCHGT LIKE MARC-SCHGT,
           SHFLG LIKE MARC-SHFLG,
           SHPRO LIKE MARC-SHPRO,
           SHZET LIKE MARC-SHZET,
           SOBSL LIKE MARC-SOBSL,
           STRGR LIKE MARC-STRGR,
           TRAME LIKE MARC-TRAME,
           UEETK LIKE MARC-UEETK,
           UEETO LIKE MARC-UEETO,
           UMLMC LIKE MARC-UMLMC,
           UNETO LIKE MARC-UNETO,
           USEQU LIKE MARC-USEQU,
           VINT1 LIKE MARC-VINT1,
           VINT2 LIKE MARC-VINT2,
           VRBDT LIKE MARC-VRBDT,
           VRBFK LIKE MARC-VRBFK,
           VRBMT LIKE MARC-VRBMT,
           VRBWK LIKE MARC-VRBWK,
           VRMOD LIKE MARC-VRMOD,
           WEBAZ LIKE MARC-WEBAZ,
           WERKS LIKE MARC-WERKS,
           WZEIT LIKE MARC-WZEIT,
           DISKZ LIKE MARD-DISKZ,
           LBSTF LIKE MARD-LBSTF,
           LGORT LIKE MARD-LGORT,
           LMINB LIKE MARD-LMINB,
           LSOBS LIKE MARD-LSOBS,
           MAKTX LIKE MAKT-MAKTX,
           END OF IT_FINAL0.
    data : BEGIN OF IT_FINAL occurs 0,
           MATNR LIKE MARA-MATNR,
           MATKL LIKE MARA-MATKL,
           MEINS LIKE MARA-MEINS,
           MTART LIKE MARA-MTART,
           AHDIS LIKE MARC-AHDIS,
           AUSDT LIKE MARC-AUSDT,
           AUTRU LIKE MARC-AUTRU,
           BESKZ LIKE MARC-BESKZ,
           BSTFE LIKE MARC-BSTFE,
           BSTMA LIKE MARC-BSTMA,
           BSTMI LIKE MARC-BSTMI,
           BSTRF LIKE MARC-BSTRF,
           BWSCL LIKE MARC-BWSCL,
           DIBER LIKE MARC-DIBER,
           DISGR LIKE MARC-DISGR,
           DISLS LIKE MARC-DISLS,
           DISMM LIKE MARC-DISMM,
           DISPO LIKE MARC-DISPO,
           DISPR LIKE MARC-DISPR,
           DZEIT LIKE MARC-DZEIT,
           EISBE LIKE MARC-EISBE,
           EISLO LIKE MARC-EISLO,
           EKGRP LIKE MARC-EKGRP,
           FHORI LIKE MARC-FHORI,
           FXHOR LIKE MARC-FXHOR,
           KAUTB LIKE MARC-KAUTB,
           KORDB LIKE MARC-KORDB,
           KZAUS LIKE MARC-KZAUS,
           LFGJA LIKE MARC-LFGJA,
           LFMON LIKE MARC-LFMON,
           LGRAD LIKE MARC-LGRAD,
           LVORM LIKE MARC-LVORM,
           MABST LIKE MARC-MABST,
           MINBE LIKE MARC-MINBE,
           MMSTA LIKE MARC-MMSTA,
           MMSTD LIKE MARC-MMSTD,
           MRPPP LIKE MARC-MRPPP,
           MTVFP LIKE MARC-MTVFP,
           NFMAT LIKE MARC-NFMAT,
           PERKZ LIKE MARC-PERKZ,
           PLIFZ LIKE MARC-PLIFZ,
           PLVAR LIKE MARC-PLVAR,
           PSTAT LIKE MARC-PSTAT,
           QZGTP LIKE MARC-QZGTP,
           RGEKZ LIKE MARC-RGEKZ,
           RWPRO LIKE MARC-RWPRO,
           SBDKZ LIKE MARC-SBDKZ,
           SCHGT LIKE MARC-SCHGT,
           SHFLG LIKE MARC-SHFLG,
           SHPRO LIKE MARC-SHPRO,
           SHZET LIKE MARC-SHZET,
           SOBSL LIKE MARC-SOBSL,
           STRGR LIKE MARC-STRGR,
           TRAME LIKE MARC-TRAME,
           UEETK LIKE MARC-UEETK,
           UEETO LIKE MARC-UEETO,
           UMLMC LIKE MARC-UMLMC,
           UNETO LIKE MARC-UNETO,
           USEQU LIKE MARC-USEQU,
           VINT1 LIKE MARC-VINT1,
           VINT2 LIKE MARC-VINT2,
           VRBDT LIKE MARC-VRBDT,
           VRBFK LIKE MARC-VRBFK,
           VRBMT LIKE MARC-VRBMT,
           VRBWK LIKE MARC-VRBWK,
           VRMOD LIKE MARC-VRMOD,
           WEBAZ LIKE MARC-WEBAZ,
           WERKS LIKE MARC-WERKS,
           WZEIT LIKE MARC-WZEIT,
           DISKZ LIKE MARD-DISKZ,
           LBSTF LIKE MARD-LBSTF,
           LGORT LIKE MARD-LGORT,
           LMINB LIKE MARD-LMINB,
           LSOBS LIKE MARD-LSOBS,
           MAKTX LIKE MAKT-MAKTX,
           BKLAS LIKE MBEW-BKLAS,
           SALK3 LIKE MBEW-SALK3,
           PEINH LIKE MBEW-PEINH,
           STPRS LIKE MBEW-STPRS,
           VERPR LIKE MBEW-VERPR,
           VPRSV LIKE MBEW-VPRSV,
           ZXPRS LIKE MBEW-STPRS,
           END OF IT_FINAL.
    data : BEGIN OF IT_display occurs 0,
           matnr LIKE MARA-MATNR,
           maktx LIKE MAKT-MAKTX,
           meins LIKE MARA-MEINS,
           werks LIKE MARC-WERKS,
           dispo LIKE MARC-DISPO,
           dismm LIKE MARC-DISMM,
           plifz LIKE MARC-PLIFZ,
           webaz LIKE MARC-WEBAZ,
           minbe LIKE MARC-MINBE,
         shzet LIKE MARC-SHZET,
         eisbe LIKE MARC-EISBE,
         disls LIKE MARC-DISLS,
         bstmi LIKE MARC-BSTMI,
         bstma LIKE MARC-BSTMA,
         bstfe LIKE MARC-BSTFE,
         ZXPRS LIKE MBEW-STPRS,
         peinh LIKE MBEW-PEINH,
         salk3 LIKE MBEW-SALK3,
           end of it_display.
    ALV Layout Variant
    AT SELECTION-SCREEN ON VALUE-REQUEST FOR so_lay.
      PERFORM get_alv_layout_values.
    SELECTION SCREEN.
    AT SELECTION-SCREEN.
      IF ( sscrfields-ucomm = 'SJOB' OR
      sy-batch = 'X' ).
        s_job = 'X'.
      ENDIF.
    select single matnr into itab from mara where matnr in so_matnr.
    if sy-subrc <> 0.
    message e001(zpal).
    endif.
    START-OF-SELECTION.
      IF SO_LAY <> ' '.
        VARIANT-REPORT = 'ZPMACR01_MD_MRP_100'.
        VARIANT-VARIANT = SO_LAY.
    else.
    VARIANT-VARIANT = '/DEFAULT'.
      ENDIF.
    INITIALIZATION.
      W_REPID = SY-REPID.
    START-OF-SELECTION.
    IF SO_LAY <> ' '.
        VARIANT-REPORT  = w_repid.
        VARIANT-VARIANT = SO_LAY.
    else.
    VARIANT-VARIANT = '/DEFAULT'.
    ENDIF.
      SELECT
      MARA~MATNR
      MARA~MATKL
      MARA~MEINS
      MARA~MTART
      MARC~AHDIS
      MARC~AUSDT
      MARC~AUTRU
      MARC~BESKZ
      MARC~BSTFE
      MARC~BSTMA
      MARC~BSTMI
      MARC~BSTRF
      MARC~BWSCL
      MARC~DIBER
      MARC~DISGR
      MARC~DISLS
      MARC~DISMM
      MARC~DISPO
      MARC~DISPR
      MARC~DZEIT
      MARC~EISBE
      MARC~EISLO
      MARC~EKGRP
      MARC~FHORI
      MARC~FXHOR
      MARC~KAUTB
      MARC~KORDB
      MARC~KZAUS
      MARC~LFGJA
      MARC~LFMON
      MARC~LGRAD
      MARC~LVORM
      MARC~MABST
      MARC~MINBE
      MARC~MMSTA
      MARC~MMSTD
      MARC~MRPPP
      MARC~MTVFP
      MARC~NFMAT
      MARC~PERKZ
      MARC~PLIFZ
      MARC~PLVAR
      MARC~PSTAT
      MARC~QZGTP
      MARC~RGEKZ
      MARC~RWPRO
      MARC~SBDKZ
      MARC~SCHGT
      MARC~SHFLG
      MARC~SHPRO
      MARC~SHZET
      MARC~SOBSL
      MARC~STRGR
      MARC~TRAME
      MARC~UEETK
      MARC~UEETO
      MARC~UMLMC
      MARC~UNETO
      MARC~USEQU
      MARC~VINT1
      MARC~VINT2
      MARC~VRBDT
      MARC~VRBFK
      MARC~VRBMT
      MARC~VRBWK
      MARC~VRMOD
      MARC~WEBAZ
      MARC~WERKS
      MARC~WZEIT
    MARD~DISKZ
    MARD~LBSTF
    MARD~LGORT
    MARD~LMINB
    MARD~LSOBS
      MAKT~MAKTX
    INTO TABLE IT_TABLE
    FROM MARA INNER JOIN MARC ON MARAMATNR = MARCMATNR
    INNER JOIN MAKT ON MARAMATNR = MAKTMATNR
    WHERE MARA~MATNR IN SO_MATNR
           AND MARC~WERKS IN SO_WERKS
           AND MAKT~SPRAS IN SO_SPRAS.
      SELECT
      MARA~MATNR
      MARA~MATKL
      MARA~MEINS
      MARA~MTART
      MARD~DISKZ
      MARD~LBSTF
      MARD~LGORT
      MARD~LMINB
      MARD~LSOBS
      INTO TABLE IT_mard
       FROM MARA INNER JOIN MARD ON MARAMATNR = MARDMATNR
                WHERE  MARA~MATNR IN SO_MATNR
                      and mard~werks in SO_WERKS.
      SELECT MATNR BKLAS SALK3 PEINH STPRS VERPR VPRSV
      INTO TABLE IT_MBEW FROM MBEW FOR ALL ENTRIES IN IT_TABLE WHERE MATNR =
      IT_TABLE-MATNR AND BWKEY IN SO_BWKEY.
      LOOP AT IT_TABLE.
       MOVE-CORRESPONDING IT_TABLE TO IT_FINAL0.
        READ TABLE IT_MARD WITH KEY MATNR = IT_TABLE-MATNR.
        IF SY-SUBRC = 0 .
         MOVE-CORRESPONDING IT_MARD TO IT_FINAL0.
        ENDIF.
         APPEND IT_FINAL0.
         CLEAR IT_FINAL0.
      ENDLOOP.
    LOOP AT IT_FINAL0.
        READ TABLE IT_MBEW WITH KEY MATNR = IT_final0-MATNR.
        IF SY-SUBRC = 0 .
         MOVE-CORRESPONDING IT_MBEW TO IT_FINAL.
         IF IT_MBEW-VPRSV = 'S'.
          MOVE IT_MBEW-STPRS TO IT_FINAL-ZXPRS.
         ELSE.
          MOVE IT_MBEW-VERPR TO IT_FINAL-ZXPRS.
         ENDIF.
        ENDIF.
        MOVE-CORRESPONDING IT_FINAL0 TO IT_FINAL.
        APPEND IT_FINAL.
        CLEAR IT_FINAL.
    ENDLOOP.
    Default Layout
      LOOP AT IT_FINAL.
        Read table it_final with key matnr = SO_matnr.
        Move it_final-MATNR to it_display-MATNR.
        Move it_final-MAKTX to it_display-MAKTX.
        Move it_final-MEINS to it_display-MEINS.
        Move it_final-WERKS to it_display-WERKS.
        Move it_final-DISPO to it_display-DISPO.
        Move it_final-DISMM to it_display-DISMM.
        Move it_final-PLIFZ to it_display-PLIFZ.
        Move it_final-WEBAZ to it_display-WEBAZ.
        Move it_final-MINBE to it_display-MINBE.
        Move it_final-SHZET to it_display-SHZET.
        Move it_final-EISBE to it_display-EISBE.
        Move it_final-DISLS to it_display-DISLS.
        Move it_final-BSTMI to it_display-BSTMI.
        Move it_final-BSTMA to it_display-BSTMA.
        Move it_final-BSTFE to it_display-BSTFE.
        MOVE it_final-ZXPRS to it_display-ZXPRS.
        Move it_final-PEINH to it_display-PEINH.
        Move it_final-SALK3 to it_display-SALK3.
        Append it_display.
      endloop.
      data: v_data type c value ' '.
      if it_display is initial.
        v_data = ' '.
      else.
        v_data = 'X'.
      endif.
    END-OF-SELECTION.
    END-OF-SELECTION.
      if s_job = 'X'.
        perform execute_back.
      else.
        perform execute_fore.
      endif.
          FORM execute_fore                                             *
    Form execute_fore.
    *&      Form REUSE_ALV_FIELDCATALOG_MERGE
      CALL FUNCTION 'REUSE_ALV_FIELDCATALOG_MERGE'
       EXPORTING
         I_PROGRAM_NAME               = W_REPID
         I_INTERNAL_TABNAME           = 'IT_FINAL'
      I_STRUCTURE_NAME             =
      I_CLIENT_NEVER_DISPLAY       = 'X'
         I_INCLNAME                   = W_REPID
      I_BYPASSING_BUFFER           =
      I_BUFFER_ACTIVE              =
        CHANGING
          CT_FIELDCAT                  = IT_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.
    *&      Form  DISPLAY_ALV_REPORT
          Display report using ALV grid
    *IF SO_LAY <> ' '.
    VARIANT-VARIANT = SO_LAY.
    *endif.
      CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
       EXPORTING
                       I_INTERFACE_CHECK                 = ' '
                       I_BYPASSING_BUFFER                =
                       I_BUFFER_ACTIVE                   = ' '
                         I_CALLBACK_PROGRAM                = W_REPID
                       I_CALLBACK_PF_STATUS_SET          = ' '
                       I_CALLBACK_USER_COMMAND           = ' '
                       I_CALLBACK_TOP_OF_PAGE            = ' '
                       I_CALLBACK_HTML_TOP_OF_PAGE       = ' '
                       I_CALLBACK_HTML_END_OF_LIST       = ' '
                       I_STRUCTURE_NAME                  =
                       I_BACKGROUND_ID                   = ' '
                       I_GRID_TITLE                      =
                       I_GRID_SETTINGS                   =
                       IS_LAYOUT                         = IT_LAYOUT
                         IT_FIELDCAT                       = IT_FIELDCAT[]
                       IT_EXCLUDING                      =
                       IT_SPECIAL_GROUPS                 =
                       IT_SORT                           =
                       IT_FILTER                         =
                       IS_SEL_HIDE                       =
                       I_DEFAULT                         = 'X'
                         I_SAVE                            = 'X'
                         IS_VARIANT                        = VARIANT
                       IT_EVENTS                         =
                       IT_EVENT_EXIT                     =
                       IS_PRINT                          =
                       IS_REPREP_ID                      =
                       I_SCREEN_START_COLUMN             = 0
                       I_SCREEN_START_LINE               = 0
                       I_SCREEN_END_COLUMN               = 0
                       I_SCREEN_END_LINE                 = 0
                       IT_ALV_GRAPHICS                   =
                       IT_ADD_FIELDCAT                   =
                       IT_HYPERLINK                      =
                       I_HTML_HEIGHT_TOP                 =
                       I_HTML_HEIGHT_END                 =
                       IT_EXCEPT_QINFO                   =
                     IMPORTING
                       E_EXIT_CAUSED_BY_CALLER           =
                       ES_EXIT_CAUSED_BY_USER            =
        TABLES
          T_OUTTAB                          = IT_FINAL
       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.
    endform.
          FORM execute_back                                             *
    FORM execute_back.
      CALL FUNCTION 'REUSE_ALV_FIELDCATALOG_MERGE'
       EXPORTING
         I_PROGRAM_NAME               = W_REPID
         I_INTERNAL_TABNAME           = 'IT_FINAL'
      I_STRUCTURE_NAME             =
      I_CLIENT_NEVER_DISPLAY       = 'X'
         I_INCLNAME                   = W_REPID
      I_BYPASSING_BUFFER           =
      I_BUFFER_ACTIVE              =
        CHANGING
          CT_FIELDCAT                  = IT_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.
    CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
    EXPORTING
      I_INTERFACE_CHECK                 = ' '
      I_BYPASSING_BUFFER                = ' '
      I_BUFFER_ACTIVE                   = ' '
         I_CALLBACK_PROGRAM                = W_REPID
      I_CALLBACK_PF_STATUS_SET          = ' '
      I_CALLBACK_USER_COMMAND           = ' '
         I_CALLBACK_TOP_OF_PAGE            = 'TOP_OF_PAGE'
      I_CALLBACK_HTML_TOP_OF_PAGE       = ' '
      I_CALLBACK_HTML_END_OF_LIST       = ' '
      I_STRUCTURE_NAME                  =
      I_BACKGROUND_ID                   = ' '
      I_GRID_TITLE                      =
      I_GRID_SETTINGS                   =
       IS_LAYOUT                         =
         IT_FIELDCAT                       = it_fieldcat[]
      IT_EXCLUDING                      =
      IT_SPECIAL_GROUPS                 =
      IT_SORT                           =
      IT_FILTER                         =
      IS_SEL_HIDE                       =
      I_DEFAULT                         = 'X'
         I_SAVE                            = 'X'
         IS_VARIANT                        = variant
        IT_EVENTS                         = gt_events[]
      IT_EVENT_EXIT                     =
      IS_PRINT                          =
      IS_REPREP_ID                      =
      I_SCREEN_START_COLUMN             = 0
      I_SCREEN_START_LINE               = 0
      I_SCREEN_END_COLUMN               = 0
      I_SCREEN_END_LINE                 = 0
      I_HTML_HEIGHT_TOP                 = 0
      I_HTML_HEIGHT_END                 = 0
      IT_ALV_GRAPHICS                   =
      IT_HYPERLINK                      =
      IT_ADD_FIELDCAT                   =
      IT_EXCEPT_QINFO                   =
      IR_SALV_FULLSCREEN_ADAPTER        =
    IMPORTING
      E_EXIT_CAUSED_BY_CALLER           =
      ES_EXIT_CAUSED_BY_USER            =
      TABLES
        T_OUTTAB                          = it_final
    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.
    endform.
    form top_of_page.
    CALL FUNCTION 'REUSE_ALV_GRID_LAYOUT_INFO_GET'
       IMPORTING
        ES_LAYOUT                 =
         ET_FIELDCAT               = IT_FIELDCAT3[]
        ET_SORT                   =
        ET_FILTER                 =
        ES_GRID_SCROLL            =
         ES_VARIANT                = VARIANT
        ET_MARKED_COLUMNS         =
        ET_FILTERED_ENTRIES       =
        ET_FIELDCAT_BACKEND       =
        ES_PRINT                  =
       EXCEPTIONS
         NO_INFOS                  = 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.
    clear count.
    LOOP AT IT_FIELDCAT3 into is_fieldcat3 where no_out eq space.
    *move-corresponding is_fieldcat3 to is_fieldcat2.
    move: is_fieldcat3-fieldname to is_fieldcat2-fieldname,
          is_fieldcat3-ref_fieldname to is_fieldcat2-ref_field,
          is_fieldcat3-ref_tabname to is_fieldcat2-ref_table,
          is_fieldcat3-seltext_l to is_fieldcat2-coltext,
          is_fieldcat3-no_out to is_fieldcat2-no_out,
          is_fieldcat3-col_pos to is_fieldcat2-col_pos.
    *move:
         is_fieldcat3-row_pos to is_fieldcat2-row_pos,
         is_fieldcat3-col_pos to is_fieldcat2-col_pos,
         is_fieldcat3-fieldname to is_fieldcat2-fieldname,
         is_fieldcat3-tabname   to is_fieldcat2-tabname,
         is_fieldcat3-outputlen to is_fieldcat2-outputlen,
         is_fieldcat3-no_out    to is_fieldcat2-no_out,
         is_fieldcat3-seltext_l to is_fieldcat2-coltext,
         is_fieldcat3-ref_fieldname to is_fieldcat2-ref_field,
         is_fieldcat3-ref_tabname to is_fieldcat2-ref_table,
         is_fieldcat3-DDIC_OUTPUTLEN to is_fieldcat2-DD_OUTLEN,
         is_fieldcat3-datatype to is_fieldcat2-datatype,
         is_fieldcat3-inttype to is_fieldcat2-inttype,
         is_fieldcat3-INTLEN to is_fieldcat2-INTLEN.
    APPEND IS_FIELDCAT2 TO IT_FIELDCAT2.
    *count = count + 1.
    ENDLOOP.
    loop at it_fieldcat2 into is_fieldcat2.
      if is_fieldcat2-no_out = 'X'.
       delete it_fieldcat2 index sy-tabix.
      else.
       count = count + 1.
      endif.
    endloop.
    describe table it_fieldcat2 lines count.
      CALL METHOD cl_alv_table_create=>create_dynamic_table
        EXPORTING
          it_fieldcatalog = it_fieldcat2[]
        IMPORTING
          ep_table        = new_table.
      ASSIGN new_table->* TO <tab>.
      CREATE DATA new_line LIKE LINE OF <tab>.
      ASSIGN new_line->* TO <wa>.
    *-- Perform to build table for attachment data
      PERFORM build_xls_data_table.
    *-- Perform to populate  e-mail message
      PERFORM populate_email_message_body.
    *-- Perform to send mail
      PERFORM send_file_as_email_attachment.
    *-- Perform to Instruct mail send program for SAPCONNECT to send email.
      PERFORM initiate_mail_execute_program.
    ENDFORM.
    *&      Form  build_xls_data_table
    form build_xls_data_table.
      data: char_var(30) type C,
            num_var(10) type n.
      CONSTANTS: con_cret TYPE x VALUE '0D',  "NEW LINE
                  tabchar TYPE x VALUE '09'.   "tab
      loop at it_fieldcat2 into is_fieldcat2.
        concatenate it_attach is_fieldcat2-coltext
        into it_attach separated by tabchar.
      endloop.
      CONCATENATE con_cret it_attach  INTO it_attach.
      APPEND  it_attach.
      CLEAR it_attach.
       field-symbols: <t> type ANY.
      LOOP AT it_final.
      col_1 = 1.
       do count times.
       Assign component col_1 of structure <wa> to <f>.
       read table it_fieldcat2 into is_fieldcat2 with key col_pos = col_1.
       loop at it_fieldcat into is_fieldcat.
       if is_fieldcat-fieldname = is_fieldcat2-fieldname.
        assign component is_fieldcat-col_pos of structure it_final to <t>.
        exit.
       endif.
       endloop.
       <f> = <t>.
       clear <t>.
       col_1 = col_1 + 1.
       enddo.
       append <wa> to <tab>.
       endloop.
      loop at <tab> into <wa>.
      col_1 = 1.
      do count times.
       Assign component col_1 of structure <wa> to <f>.
       move <f> to char_var.
       concatenate it_attach char_var
       into it_attach separated by tabchar.
       col_1 = col_1 + 1.
      enddo.
       CONCATENATE con_cret it_attach INTO it_attach.
       APPEND it_attach.
       CLEAR it_attach.
      endloop.
    ENDFORM.
    FORM send_file_as_email_attachment.
      DATA:
            ld_mtitle LIKE sodocchgi1-obj_descr,
            ld_email LIKE  somlreci1-receiver,
            ld_format TYPE  so_obj_tp ,
            ld_attdescription TYPE  so_obj_nam ,
            ld_attfilename TYPE  so_obj_des ,
            ld_sender_address LIKE  soextreci1-receiver,
            ld_sender_address_type LIKE  soextreci1-adr_typ.
      ld_email = p_email.
      ld_mtitle = text-003.
      ld_format = 'XLS'.
      ld_attdescription  = ' '.
      ld_attfilename = 'DATA'.
      ld_sender_address = ' '.
      ld_sender_address_type = ' '.
    Fill the document data.
      w_doc_data-doc_size = 1.
    Populate the subject/generic message attributes
      w_doc_data-obj_langu = sy-langu.
      w_doc_data-obj_name  = 'SAPRPT'.
      w_doc_data-obj_descr = ld_mtitle .
      w_doc_data-sensitivty = 'F'.
    Fill the document data and get size of attachment
      CLEAR w_doc_data.
      READ TABLE it_attach INDEX w_cnt.
      w_doc_data-doc_size =
    ( w_cnt - 1 ) * 255 + STRLEN( it_attach ).
      w_doc_data-obj_langu  = sy-langu.
      w_doc_data-obj_name   = 'SAPRPT'.
      w_doc_data-obj_descr  = ld_mtitle.
      w_doc_data-sensitivty = 'F'.
      LOOP AT it_attach.
        MOVE it_attach(255) TO t_hex.
        APPEND t_hex.
        MOVE it_attach+255(255) TO t_hex.
        APPEND t_hex.
        MOVE it_attach+510(255) TO t_hex.
        APPEND t_hex.
        MOVE it_attach+765(235) TO t_hex.
        APPEND t_hex.
        MOVE it_attach+765(255) TO t_hex.
        APPEND t_hex.
        MOVE it_attach+1020(255) TO t_hex.
        APPEND t_hex.
        MOVE it_attach+1275(255) TO t_hex.
        APPEND t_hex.
        MOVE it_attach+1530(255) TO t_hex.
        APPEND t_hex.
        MOVE it_attach+1785(255) TO t_hex.
        APPEND t_hex.
        MOVE it_attach+2040(255) TO t_hex.
        APPEND t_hex.
        MOVE it_attach+2295(255) TO t_hex.
        APPEND t_hex.
        MOVE it_attach+2550(100) TO t_hex.
        APPEND t_hex.
      ENDLOOP.
    Describe the body of the message
      CLEAR t_packing_list.
      REFRESH t_packing_list.
      t_packing_list-transf_bin = space.
      t_packing_list-head_start = 1.
      t_packing_list-head_num = 0.
      t_packing_list-body_start = 1.
      DESCRIBE TABLE it_message LINES t_packing_list-body_num.
      t_packing_list-doc_type = 'RAW'.
      APPEND t_packing_list.
    Create attachment notification
      t_packing_list-transf_bin = 'X'.
      t_packing_list-head_start = 1.
      t_packing_list-head_num   = 1.
      t_packing_list-body_start = 1.
      DESCRIBE TABLE t_hex LINES t_packing_list-body_num.
      t_packing_list-doc_type   =  ld_format.
      t_packing_list-obj_descr  =  ld_attdescription.
      t_packing_list-obj_name   =  ld_attfilename.
      t_packing_list-doc_size   =  t_packing_list-body_num * 255.
      APPEND t_packing_list.
    Add the recipients email address
      CLEAR t_receivers.
      REFRESH t_receivers.
      t_receivers-receiver = ld_email.
      t_receivers-rec_type = 'U'.
      t_receivers-com_type = 'INT'.
      t_receivers-notif_del = 'X'.
      t_receivers-notif_ndel = 'X'.
      APPEND t_receivers.
      CALL FUNCTION 'SO_DOCUMENT_SEND_API1'
           EXPORTING
                document_data       = w_doc_data
                put_in_outbox       = 'X'
                sender_address      = ld_sender_address
                sender_address_type = ld_sender_address_type
          IMPORTING
               sent_to_all         = w_sent_all
           TABLES
                packing_list        = t_packing_list
                contents_txt        = it_message
                contents_hex        = t_hex
                receivers           = t_receivers
           EXCEPTIONS
                too_many_receivers         = 1
                document_not_sent          = 2
                document_type_not_exist    = 3
                operation_no_authorization = 4
                parameter_error            = 5
                x_error                    = 6
                enqueue_error              = 7
                OTHERS                     = 8.
      IF sy-subrc <> 0.
    MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
            WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
      ENDIF.
    ld_error = sy-subrc.
    LOOP AT t_receivers.
       ld_receiver = t_receivers-retrn_code.
    ENDLOOP.
    ENDFORM. "SEND_FILE_AS_EMAIL_ATTACHMENT
    *&      Form  INITIATE_MAIL_EXECUTE_PROGRAM
          Instructs mail send program for SAPCONNECT to send email.
    FORM initiate_mail_execute_program.
      WAIT UP TO 2 SECONDS.
      SUBMIT rsconn01 WITH mode = 'INT'
                    WITH output = 'X'
                    AND RETURN.
    ENDFORM.                    " INITIATE_MAIL_EXECUTE_PROGRAM
    *&      Form  POPULATE_EMAIL_MESSAGE_BODY
           Populate message body text
    FORM populate_email_message_body.
      REFRESH it_message.
      it_message = text-004.
      APPEND  it_message.
      CONCATENATE SY-DATUM 'to' SY-DATUM INTO it_message SEPARATED BY
      space.
      APPEND  it_message.
    ENDFORM.                    " POPULATE_EMAIL_MESSAGE_BODY
    *&      Form  get_alv_layout_values
    FORM get_alv_layout_values.
      variant-report = w_repid.
      CALL FUNCTION 'REUSE_ALV_VARIANT_F4'
           EXPORTING
                is_variant    = variant
                i_save        = 'A'
           IMPORTING
                es_variant    = variant
           EXCEPTIONS
                not_found     = 1
                program_error = 2
                OTHERS        = 3.
      CHECK sy-subrc = 0.
      so_lay = variant-variant.
    ENDFORM.                    " get_alv_layout_values

    Hi Arpit,
    Take a look at the documentation of FM 'SO_DOCUMENT_SEND_API1' for parameter PACKING_LIST. I think you should set t_packing_list-head_num to a different value than 0 for the second attachment.
    Regards,
    John.

  • ALV Layouts are missing in ECC6 after upgrade

    Dear Friends,
    we have an issue of missing ALV Layouts in ECC6 after upgrade of ECC6 from 4.7 version
    For example, we have a custom table ZRCILOT, data displayed using tocde se16, but when we check layout are missing in ECC6 but the same exist in 4.7 version.
    please check the attached screen-shots.
    kindly suggest, is there any possibility to retrive it.
    Thanks,
    Munvar Basha.

    Hello
    Variants should be preserved by the upgrade...
    You could export/import layout using the report from the here under note
    Regards
    551178 - FAQ ALV Layout
    During the upgrade of or when importing Support Packages?
    Answer: Layouts created by the customer are retained and you can continue to use them.
    643330 - ALV layout: Importing and exporting layouts

  • 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

  • ALV list display in a Background job - Spool output

    Hi,
    We are currently working on a report scheduled to be run in the background job, and the ALV list is displayed in the spool output.
    ALV list in the spool does not look the same as front run job, the column headers are all crowded together, and there is no grid in-between different columns or rows. It's hard to read.
    Is there a way to add grid for this kind of output?
    Thanks!

    Hi Deepak:
    I expanded your report into two rows display, and the grid in the spool display simply gone!
    report zzscratch line-size 120 no standard page heading.
    type-pools slis.
    tables pa0001.
    data : li_field type standard table of slis_fieldcat_alv,
    gi_events type standard table of slis_alv_event,
    gr_layout_bck type slis_layout_alv,
    gr_save like disvariant,
    gr_events type slis_alv_event.
    types : begin of gtt_emp,
    pernr type persno,
    ename  like pa0001-ename,
    uname  like pa0001-UNAME,
    end of gtt_emp.
    data : lr_field type slis_fieldcat_alv.
    data : lc_rep like syst-repid.
    data : li_emp type standard table of gtt_emp,
    lr_emp type gtt_emp.
    data : gv_ref_table type lvc_rtname.
    gv_ref_table = 'CATSDB'.
    lr_field-fieldname = 'PERNR'.
    lr_field-ref_tabname = gv_ref_table.
    lr_field-inttype = 'N'.
    lr_field-outputlen = 8.
    lr_field-seltext_l = 'EMPLOYEE Number'.
    append lr_field to li_field.
    lr_field-fieldname = 'ENAME'.
    lr_field-ref_tabname = 'PA0001'.
    lr_field-inttype = 'C'.
    lr_field-outputlen = 40.
    lr_field-seltext_l = 'EMPLOYEE Name'.
    append lr_field to li_field.
    lr_field-fieldname = 'UNAME'.
    lr_field-ref_tabname = 'PA0001'.
    lr_field-inttype = 'C'.
    lr_field-outputlen = 12.
    lr_field-seltext_l = 'User Name'.
    lr_field-row_pos = 2.
    lr_field-col_pos = 1.
    append lr_field to li_field.
    lc_rep = sy-repid.
    gr_layout_bck-edit_mode = 'D'.
    gr_save-report = sy-repid.
    lr_emp-pernr = '00000001'.
    lr_emp-ename = 'abc'.
    lr_emp-uname = 'testus'.
    append lr_emp to li_emp.
    lr_emp-pernr = '00000002'.
    lr_emp-ename = 'def'.
    append lr_emp to li_emp.
    lr_emp-pernr = '00000003'.
    append lr_emp to li_emp.
    lr_emp-pernr = '00000004'.
    append lr_emp to li_emp.
    lr_emp-pernr = '00000005'.
    append lr_emp to li_emp.
    lr_emp-pernr = '00000006'.
    append lr_emp to li_emp.
    lr_emp-pernr = '00000007'.
    append lr_emp to li_emp.
    lr_emp-pernr = '00000008'.
    append lr_emp to li_emp.
    end-of-selection.
    Function module for ALV grid display
      call function 'REUSE_ALV_GRID_DISPLAY'
           EXPORTING
                i_buffer_active    = 'X'
                i_callback_program = lc_rep
                is_layout          = gr_layout_bck
                it_fieldcat        = li_field
                i_save             = 'A'
                is_variant         = gr_save
                it_events          = gi_events
           TABLES
                t_outtab           = li_emp[]
           EXCEPTIONS
                program_error      = 1
                others             = 2.
      if sy-subrc <> 0.
    clear gr_messages.
    message e023 into gr_messages.
    append gr_messages to gi_messages.
      endif.

  • 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

  • ALV Layout Variant Issue

    Hi Gurus,
    In my ALV report there are two Layout variants.
      a) Default Layout - /DEFAULT created by someone else earlier.
      b) User specific - created and saved by me (name CS Layout)
    I am using this function module
    alv_variant-report = sy-repid.
      alv_variant-username = sy-uname.
    CALL FUNCTION 'REUSE_ALV_VARIANT_DEFAULT_GET'
        EXPORTING
          i_save     = 'U'
        CHANGING
          cs_variant = xalv_variant
        EXCEPTIONS
          not_found  = 2.
      IF sy-subrc = 0.
        p_vari = xalv_variant-variant.
      ENDIF.
    PROBLEM: Even though I am passing user specific information to this FM, but it is returning me the Default layout, but
    I want the user specific layout(CS Layout) which I created and saved.
    Please help !

    Hi Chandan,
    alv_variant-report = sy-repid.
      alv_variant-username = sy-uname.
    CALL FUNCTION 'REUSE_ALV_VARIANT_DEFAULT_GET'
        EXPORTING
          i_save     = 'U'
        CHANGING
          cs_variant = xalv_variant
        EXCEPTIONS
          not_found  = 2.
      IF sy-subrc = 0.
        p_vari = xalv_variant-variant---------->What does this variable contain.
      ENDIF.
    You are not populating any value to the variable xalv_variant,again you are passing it again to p_vari.
    Check this link once.
    [REUSE_ALV_GRID_DISPLAY - layout variant|REUSE_ALV_GRID_DISPLAY - layout variant;
    Have a look at rich's reply
    Regards,
    Lakshman.

  • Doubt in alv layout variant.

    hi experts,
    I have a requirement that my selection screen should have 'ALV LAYOUT' as one of my parameter. I am using PNPCE LDB , now my issue is I can get the layout option when f4 is press on the alv layout parameter but the respective layout is not displaying in my output.
    ex: I have  layout A and  B .
    A have only pernr and name
    b have only pernr and address
    my normal alv layout is  pernr name and address. if i choose A in my ALV LAYOUT parameter also its displaying in default layout alv same is happening for while am choosing B. I  not getting the alv output for respective layout I chosen.
    {code}
    FORM GET_VARIANT .
    DATA: lw_variant TYPE disvariant,
       l_exit     TYPE char1.
       lw_variant-report = sy-repid.
       CALL FUNCTION 'REUSE_ALV_VARIANT_F4'
         EXPORTING
           is_variant = lw_variant
           i_save     = 'A'
         IMPORTING
           e_exit     = l_exit
           es_variant = lw_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.
           p_layout = lw_variant-variant.
           IF NOT p_layout IS INITIAL.
             PERFORM get_w_variant.
           ENDIF.
         ENDIF.
       ENDIF.
    ENDFORM.                    " GET_VARIANT
    *&      Form  GET_W_VARIANT
    *       text
    *  -->  p1        text
    *  <--  p2        text
    FORM GET_W_VARIANT .
       DATA: lw_variant TYPE disvariant.
       lw_variant-report      = sy-repid.
       lw_variant-handle      = space.
       lw_variant-log_group   = space.
       lw_variant-username    = space.
       lw_variant-variant     = p_layout.
       lw_variant-text        = space.
       lw_variant-dependvars  = space.
    ENDFORM.                    " GET_W_VARIANT
    *&      Form  ALV_DISPLAY
    *       text
    *  -->  p1        text
    *  <--  p2        text
    FORM ALV_DISPLAY .
    *  DATA: l_table      TYPE REF TO cl_salv_table.
    *  TRY.
    *  CALL METHOD CL_SALV_TABLE=>FACTORY
    **    EXPORTING
    **      LIST_DISPLAY   = IF_SALV_C_BOOL_SAP=>FALSE
    **      R_CONTAINER    =
    **      CONTAINER_NAME =
    *    IMPORTING
    *      R_SALV_TABLE   =  L_TABLE
    *    CHANGING
    *      T_TABLE        = GT_ALV
    *   CATCH CX_SALV_MSG .
    *  ENDTRY.
    *   l_table->display( ).
       DATA: lw_variant TYPE disvariant.
    DATA:I_FIELD TYPE SLIS_T_FIELDCAT_ALV,
          iWA  TYPE SLIS_FIELDCAT_ALV.
       IWA-FIELDNAME = 'PERNR'.
       IWA-SELTEXT_L = 'EMPLOYEE ID'.
       APPEND IWA TO i_FIELD.
       IWA-FIELDNAME = 'NAME'.
       IWA-SELTEXT_L = 'NAME'.
       APPEND IWA TO I_FIELD.
       IWA-FIELDNAME = 'DEPT'.
       IWA-SELTEXT_L = 'DEPT'.
       APPEND IWA TO I_FIELD.
       IWA-FIELDNAME = 'UNION'.
       IWA-SELTEXT_L = 'UNION'.
       APPEND IWA TO I_FIELD.
    CALL FUNCTION 'REUSE_ALV_LIST_DISPLAY'
       EXPORTING
         i_callback_program      = 'ZTESTPRGFOR20' "Program name
         i_callback_user_command = 'USER_COMMAND'
         it_fieldcat             = i_field
    *    it_sort                 = i_sort
         i_save                  = 'X'
         is_variant              = Lw_variant
       TABLES
         t_outtab                 = GT_ALV                       
       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.
    ENDFORM.                    " ALV_DISPLAY
    {code}

    hi Mohammed Quddus,
    thanks for your reply . but if you look at my code the concept are same as same as that link code.
    am getting all the things right.
    i Can able to change the layout by the button on alv and
    able to save that new layout
    the saved layout are displaying in the my parameter if I press f4. the problem is if I choose the saved layout that layout is not coming in my alv output always its showing default layout.
    if anything you find wrong in my code please let me know.

  • Dynamic variants for a background job

    Hi,
    I need to set up a background job for a dynamic variant. To elaborate my selection screen has date ranges which need to change dynamically , if the job is secheduled on weekly basis the selection date range should change automatically in the variant. I got to know that the same is possible through the table TVARV. Can I know about the method of setting up the same?
    Thanks,
    Shailaja

    You can set a dynamic date to today date or some other date without using the table TVARV.
    To set the dynamic date:
    Save variant on the selection screen.
    In the vairant screen, press F4 against your field in the column "Selection Variable"
    Select D here.
    In the column Name of the variable, press F4 to have the list of the possible rules.
    Here you can select "Current date - xxx,current date + yyy" if you want to have certain period.
    When you select this system will pop up to put the values for XXX and YYY.
    Say for last 7 days, you can set the values XXX as 7 and YYY as0.
    But the best way is to change the program, if possible, and fill the select option in the intialization event.
    Regards,
    Naimesh Patel

  • How to transport variants and scheduled background jobs

    Hi all
       Could anyone let me know if  variants be transported .
       also can scheduled background jobs transported.
    Thanks in advance

    Hi,
    Run the program RSTRANSP and give the name of the program and the variant name.
    It will create a transport request for the variant.
    the rest of the process is the same as is the case with all other transport requests.
    Regards,
    Raghu
    Message was edited by:
            Raghu Reddy

  • Data missing in background job

    Hi All,
    I have cretaed an ALV repot with dunamic field catalog. When I am executing the report in foreground it's working fine but when I am executing it in Background except one or fields data are not being displayed in SM37 or SP01. Can anybody tell what exactly the problem is? Thanks in advance

    Hi,
    When u have most number of fields in the output when u scheduled in background after execution u need to use one button to display all the fields . When u press that u will get all fields and all the pages . Check the button i can give the button position now.
    Regards,
    Srinivas

  • Page-break in alv background job for alv output variant not coming correctl

    Hi,
    I have created an ALV grid report. When i run the report in background i get the output with correct page-break on FIELD1. Now when i run the report in background with an "ALV output variant" (its the ALV variant that controls the fields display in the output; this is not the program variant), i do not get the page-break on FIELD1.  I have already build the sort criteria and using:
    gs_sort-group = '* '.     "New-Page
    Please let me know what could be reason for not getting the page-break in background when i am using the alv output variant and how do i correct this problem.
    Regards,
    Rakesh

    Hello Everyone,
    I have solved the problem. While running the program in background, we get the page-breaks when we use the below part of code in the sort catalogue with the condition that the program variant should not use any ALV layout variant.
    gs_sort-group = '* '.     "New-Page
    If you are using the ALV layout variant in the program variant then we can check the ROWPOS, COLPOS, and NO_OUT for that ALV layout variant and pass them along in the fieldcatalog table. You should be careful with not to pass the layout variant in the DISVARIANT. You can notice that i have cleared it and simply passing the program name into that.
    *C-- Process separately for jobs running in Background. Actually
    *C-- sortcat-group solves the problem only in Foreground. In background
    *C-- when ALV layout variant is not selected then it works otherwise it
    *C-- fails. So for background jobs we are reading the fieldcat and then
    *C-- passing the same in the display FM.
      IF sy-batch = 'X'.
        CALL FUNCTION 'REUSE_ALV_VARIANT_SELECT'
          EXPORTING
           i_dialog                  = ' '
           i_user_specific           = ' '
           i_default                 = ' '
    *   I_TABNAME_HEADER          =
    *   I_TABNAME_ITEM            =
            it_default_fieldcat       = gt_fieldcat
            i_layout                  = gs_layout
    *   I_BYPASSING_BUFFER        =
    *   I_BUFFER_ACTIVE           =
         IMPORTING
    *   E_EXIT                    =
           et_fieldcat               = lt_fieldcat
    *     et_sort                   = gt_sort[]
    *   ET_FILTER                 =
    *     es_layout                 = gs_layout
         CHANGING
           cs_variant                = gs_disvariant
         EXCEPTIONS
           wrong_input               = 1
           fc_not_complete           = 2
           not_found                 = 3
           program_error             = 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.
        CLEAR gs_fieldcat.
        LOOP AT gt_fieldcat INTO gs_fieldcat.
    *C-- Transfer all position changes to gt_fieldcat from lt_fieldcat
          CLEAR ls_fieldcat.
          READ TABLE lt_fieldcat
                INTO ls_fieldcat
                WITH KEY fieldname = gs_fieldcat-fieldname.
          IF sy-subrc = 0.
            gs_fieldcat-row_pos = ls_fieldcat-row_pos.
            gs_fieldcat-col_pos = ls_fieldcat-col_pos.
            gs_fieldcat-no_out = ls_fieldcat-no_out.
            MODIFY gt_fieldcat FROM gs_fieldcat INDEX sy-tabix.
            CLEAR gs_fieldcat.
          ENDIF.
        ENDLOOP.
    *C-- Clear the disvariant for the background job as it contains the ALV
    *C-- layout varinat
        CLEAR gs_disvariant.
        gs_disvariant-report = 'ZGPPMP0001'.
    Then pass gt_fieldcat to 'REUSE_ALV_GRID_DISPLAY'.
    The reason i'm doing it this way is that when we pass the layout variant name, the contents in gt_fieldcat were getting modified.
    One more thing i'd like to point out is that that, i tried to delete the fields with no_out = 'x'. Now when i ran the program in background with all the fields in sort catalog (suppose there are 2 fields field1 and field2) also in fieldcatalog it ran fine. In the next run in background i removed one of the fields in sort catalog from the fieldcatalog (delete the fields with no_out = 'x') and i got dump. Basically i had hidden field1 and so the code which was deleting fields with no_out = 'x' deleted this field from gt_fieldcat. So basically we should not delete fields with no_out = 'x'.
    I was getting ABAP runtime errors    MESSAGE_TYPE_X in the following part of the standard code.
    000310     LOOP AT CT_SORT INTO LS_SORT.
    000320
    000330       READ TABLE IT_FIELDCAT ASSIGNING <LS_FIELDCAT>
    000340            WITH KEY FIELDNAME = LS_SORT-FIELDNAME BINARY SEARCH.
    000350       IF SY-SUBRC NE 0.
         >         MESSAGE X000(0K).
    000370       ENDIF.
    000380
    000390       LS_SORT-SELTEXT = <LS_FIELDCAT>-SELTEXT.
    i have just mentioned this part because when i checked the forum many people were getting such errors "MESSAGE_TYPE_X". This could also be one of the reasons.

  • 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

  • How to delete variant form background job

    Hi,
    I have one background job with 5 variants associated with iy.
    Now i want to remove 2 variant from that background job.
    is it posible???
    if yes then how to do that?
    Thanks,

    Hi.
    Go to SM37, execute report to see it, click on modify, and change steps.
    If you have problems, delete job, and create a new one.
    Best regards.
    Valter Oliveira.

  • MRP background job generating Plnd Ord instead of Pur Req

    Hi Gurus,
    There is a variant created for background job of MRP, which is running once in a day. In this varaint, I have control parameters set in such a way in that , it should create purchase requisition ( Purchase requisitions in opening period = 3 ) . But its creating planned order only.
    When I am running in foreground, it is generating Pur Req as expected but not generating Pur Req when running in background.
    Please help me creating purchase requisitions instead of planned order.
    Regards,
    Om
    Edited by: Om.P.Singh on Nov 24, 2011 5:12 PM

    Dear Om.P.Singh,
    As per your settings (Setting value 3  for Create Purchase Req paremeter) it will create only planned orders for the externally
    procured items.
    If you have set the value as 1 then it creates only purchase req's for all the externally procured materials.
    If you have set the value as 2,then it creates PR in the opening period(mentioned in the scheduling margin key) and planned
    orders for the remaining period.
    This parameter setting works only for the externally procured items.
    Check and revert back.
    Regards
    Mangalraj.S

Maybe you are looking for