GUI_FILE_SAVE_DIALOG

Hi Experts,
I am using fm GUI_FILE_SAVE_DIALOG,
CALL FUNCTION 'GUI_FILE_SAVE_DIALOG'
EXPORTING
   WINDOW_TITLE            = 'Select File'
   FILE_FILTER             = '(.xls)|.xls|'
IMPORTING
   FULLPATH                = SOURCEFILENAME
   USER_ACTION             = USER_ACTION.
IF USER_ACTION <> 0 AND USER_ACTION <> 1 AND USER_ACTION <> 2.
    MESSAGE S000(ZZ) WITH TEXT-000.
    EXIT.
  ENDIF.
it is showing path select along with buttons Replace, Generate, and Extent. where i dnt need these.
i need bapi in bid like GUI_FILE_LOAD_DIALOG.
Thanks in Advance.

Thanku all for ur replies,
am not getting eventhough after making changes,
AT SELECTION-SCREEN ON VALUE-REQUEST FOR E_FILE.
*Function Module For Selecting File from its Location(error file)
  CALL FUNCTION 'F4_FILENAME'
    EXPORTING
      PROGRAM_NAME = SY-REPID
      FIELD_NAME   = 'E_FILE'
    IMPORTING
      FILE_NAME    = E_FILE.
Process lt_excel1
  LOOP AT LT_FINAL INTO WA_FINAL.
    CLEAR: OUTPUTTAB.
Validate input data
    ERRORS_OCCURED = 'X'.
    IF WA_FINAL-SHIPCUST IS INITIAL.
      OUTPUTTAB-ERRORTEXT = TEXT-002.
    ELSEIF WA_FINAL-NAME IS INITIAL.
      OUTPUTTAB-ERRORTEXT = TEXT-003.
    ELSEIF WA_FINAL-NAME2 IS INITIAL.
      OUTPUTTAB-ERRORTEXT = TEXT-004.
    ELSEIF WA_FINAL-SEARCHT IS INITIAL.
      OUTPUTTAB-ERRORTEXT = TEXT-005.
    ELSEIF WA_FINAL-STREET2 IS INITIAL.
      OUTPUTTAB-ERRORTEXT = TEXT-006.
    ELSEIF WA_FINAL-STREET3 IS INITIAL.
      OUTPUTTAB-ERRORTEXT = TEXT-007.
    ELSEIF WA_FINAL-STREET IS INITIAL.
      OUTPUTTAB-ERRORTEXT = TEXT-008.
    ELSEIF WA_FINAL-POSTAL IS INITIAL.
      OUTPUTTAB-ERRORTEXT = TEXT-009.
    ELSEIF WA_FINAL-CITY IS INITIAL.
      OUTPUTTAB-ERRORTEXT = TEXT-010.
    ELSEIF WA_FINAL-COUNTRY IS INITIAL.
      OUTPUTTAB-ERRORTEXT = TEXT-011.
    ELSEIF WA_FINAL-REGION IS INITIAL.
      OUTPUTTAB-ERRORTEXT = TEXT-012.
    ELSEIF WA_FINAL-TZONE IS INITIAL.
      OUTPUTTAB-ERRORTEXT = TEXT-013.
    ELSEIF WA_FINAL-INDUSTRY IS INITIAL.
      OUTPUTTAB-ERRORTEXT = TEXT-014.
    ELSEIF WA_FINAL-PLANT IS INITIAL.
      OUTPUTTAB-ERRORTEXT = TEXT-015.
    ELSEIF WA_FINAL-TOPAYMENT IS INITIAL.
      OUTPUTTAB-ERRORTEXT = TEXT-016.
    ELSEIF L_AGROUP(4) IS INITIAL.
      OUTPUTTAB-ERRORTEXT = TEXT-017.
    ELSEIF L_SORG(4) IS INITIAL.
      OUTPUTTAB-ERRORTEXT = TEXT-018.
    ELSEIF L_DCHAN IS INITIAL.
      OUTPUTTAB-ERRORTEXT = TEXT-019.
    ELSEIF L_DVIS(2) IS INITIAL.
      OUTPUTTAB-ERRORTEXT = TEXT-020.
    ELSEIF L_SCOND(2) IS INITIAL.
      OUTPUTTAB-ERRORTEXT = TEXT-021.
    ELSEIF L_INCO(3) IS INITIAL.
      OUTPUTTAB-ERRORTEXT = TEXT-022.
    ELSEIF L_TCLASS IS NOT INITIAL.
      OUTPUTTAB-ERRORTEXT = TEXT-023.
    ENDIF.
  ENDLOOP.
Download Error File To Pc
  CHECK LT_EXCEL1 IS NOT INITIAL.
  REFRESH DOWNLOADTAB.
  LOOP AT LT_FINAL INTO WA_FINAL.
    MOVE-CORRESPONDING WA_FINAL TO DOWNLOADTAB.
    APPEND DOWNLOADTAB.
    CLEAR DOWNLOADTAB.
  ENDLOOP.
  TRANSLATE SOURCEFILENAME TO UPPER CASE.
  SPLIT SOURCEFILENAME AT '.XLS' INTO SOURCEFILENAME FILENAME.
  CONCATENATE SOURCEFILENAME '_ERRORS' INTO FILENAME.
  CALL FUNCTION 'MS_EXCEL_OLE_STANDARD_DAT'
    EXPORTING
      FILE_NAME = FILENAME
    TABLES
      DATA_TAB  = DOWNLOADTAB
    EXCEPTIONS
      OTHERS    = 1.
  IF SY-SUBRC <> 0.
    MOVE FILENAME TO SOURCEFILENAME.
    CALL FUNCTION 'GUI_DOWNLOAD'
      EXPORTING
        FILENAME = SOURCEFILENAME
      TABLES
        DATA_TAB = DOWNLOADTAB
      EXCEPTIONS
        OTHERS   = 1.
    IF SY-SUBRC <> 0.
      MESSAGE S000(ZZ) WITH TEXT-001.
    ENDIF.
  ENDIF.

Similar Messages

  • Doubt in "GUI_FILE_SAVE_DIALOG"

    Hi All,
    (1).When calling this F.M and saving the file , if the file already exists it gives the message "file already exists"
    with the tick mark like info message.
    If i want the error message "X" what should i do??
    (2). What is the extend button for in this F.M when the popup comes??
    Regards,
    Simha.

    Hi,
    you cannnot change the message generated by the SAP.
    but you can add message by checking the sy-subrc with your requirement.
    extend button helps you to append the data in the file if already exists.
    you can have the code below for any use.
    DATA:   LDF_FILENAME TYPE STRING,
                LDF_PATH     TYPE STRING,
                LDF_FULLPATH TYPE STRING,
                LDF_FNAME    TYPE STRING.
    CALL METHOD CL_GUI_FRONTEND_SERVICES=>FILE_SAVE_DIALOG
           EXPORTING
       WINDOW_TITLE         =
       DEFAULT_EXTENSION    =
             DEFAULT_FILE_NAME    = LDF_FNAME
       FILE_FILTER          =
       INITIAL_DIRECTORY    =
       WITH_ENCODING        =
       PROMPT_ON_OVERWRITE  = 'X'
          CHANGING
            FILENAME             = LDF_FILENAME
            PATH                 = LDF_PATH
            FULLPATH             = LDF_FULLPATH
       USER_ACTION          =
       FILE_ENCODING        =
          EXCEPTIONS
            CNTL_ERROR           = 1
            ERROR_NO_GUI         = 2
            NOT_SUPPORTED_BY_GUI = 3
            OTHERS               = 4.
    regards
    -Rakesh

  • First Project - BCS

    ***INCLUDE LUCR_LSTF03 .
    *&       Form  display_detail_list
    FORM display_detail_list_subscreen.
      IF g_display_detail_again IS INITIAL.
        IF g_display_detail_next IS INITIAL.
    * Header text is displayed as dyn. document
          IF go_dydo IS INITIAL.
            CREATE OBJECT go_dydo.
          ELSE.
            FREE  go_dydo.
            CLEAR go_dydo.
            CREATE OBJECT go_dydo.
            PERFORM free_create_screen_objects.
          ENDIF.
        ELSE.
          IF NOT go_dydo->html_control IS INITIAL.
            CALL METHOD go_splitter_container->remove_control
              EXPORTING
                row    = 1
                column = 1.
          ENDIF.
        ENDIF.
      ENDIF.
    * Initialize document
      CALL METHOD go_dydo->initialize_document.
      IF  LINES( gt_header ) > 0.
    * Build and display detail-header
        PERFORM build_header TABLES gt_header
                             USING  go_dydo
                                    gs_header.
      ENDIF.
    * Merge header-document
      CALL METHOD go_dydo->merge_document.
    * set toolbar-added functions for detailed list
      REFRESH gt_toolbar.
      IF go_model->ds_tx_data_io_type-documents IS BOUND.       "mb210303
        PERFORM fill_tool_tab USING:
                     gt_toolbar gs_toolbar 'UCR_DUMMY'   '1',
                     gt_toolbar gs_toolbar 'UCR_ENTRIES' '2',
                     gt_toolbar gs_toolbar 'UCR_DUMMY'   '3',
                     gt_toolbar gs_toolbar 'UCR_PREV'    '4',
                     gt_toolbar gs_toolbar 'UCR_NEXT'    '5',
                     gt_toolbar gs_toolbar 'UCR_DUMMY'   '6'.
      ELSE.                                                   "mb210202 beg.
        PERFORM fill_tool_tab USING:
                     gt_toolbar gs_toolbar 'UCR_DUMMY'   '1',
                     gt_toolbar gs_toolbar 'UCR_PREV'    '2',
                     gt_toolbar gs_toolbar 'UCR_NEXT'    '3',
                     gt_toolbar gs_toolbar 'UCR_DUMMY'   '4'.
      ENDIF.                                                  "mb210202 end.
      SET HANDLER go_event_grid->handle_toolbar_comp   FOR go_grid.
    * Display header
      CALL METHOD go_dydo->display_document
        EXPORTING
          parent = go_container_head.
    * Set header-control visible with user set or
    * predefined height
      IF NOT go_splitter_container IS INITIAL.
        IF g_height IS INITIAL.
          g_height = 27.
        ENDIF.
        CALL METHOD go_splitter_container->set_row_height
          EXPORTING
            id     = 1
            height = g_height.
      ENDIF.
    * display detail-list
      CALL METHOD go_grid->set_table_for_first_display
        EXPORTING
          i_bypassing_buffer   = 'X'
          is_layout            = gs_layout_save
          it_toolbar_excluding = gt_exclude_toolbar
        CHANGING
          it_fieldcatalog      = gt_fieldcat_d
          it_outtab            = <gt_outtab_detail>.
      IF NOT g_display_detail_next IS INITIAL.
        CALL METHOD go_grid->refresh_table_display.
      ENDIF.
    * Set cursor on selected row if necesary
      IF NOT gt_row_id_detail IS INITIAL.
        CALL METHOD go_grid->set_selected_rows
          EXPORTING
            it_index_rows = gt_row_id_detail.
        REFRESH gt_row_id_detail.
      ENDIF.
      CLEAR: g_display_detail_next,
             g_display_detail_again.
    ENDFORM.                    " display_detail_list_subscreen
    *&      Form  display_main_list
    FORM display_main_list_subscreen. "using i_reporting_logic type uc_flg.
      CLEAR g_detail.
    * set toolbar-added functions
      REFRESH gt_toolbar.
      IF go_model->ds_tx_data_io_type IS NOT INITIAL.
        IF go_model->ds_tx_data_io_type-documents IS BOUND.     "mb210303
    *        and i_reporting_logic is initial.
          PERFORM fill_tool_tab USING:
                       gt_toolbar gs_toolbar 'UCR_DUMMY'   '1',
                       gt_toolbar gs_toolbar 'UCR_ENTRIES' '2',
                       gt_toolbar gs_toolbar 'UCR_DUMMY'   '3',
                       gt_toolbar gs_toolbar 'UCR_SEL_COND' '4',
                       gt_toolbar gs_toolbar 'UCR_DUMMY'   '5'.
        ELSE.
          PERFORM fill_tool_tab USING:
                       gt_toolbar gs_toolbar 'UCR_DUMMY'   '1',
                       gt_toolbar gs_toolbar 'UCR_SEL_COND' '2',
                       gt_toolbar gs_toolbar 'UCR_DUMMY'   '3'.
        ENDIF.                                                  "mb210303
        SET HANDLER go_event_grid->handle_toolbar_comp   FOR go_grid.
      ELSE    .
        PERFORM fill_tool_tab USING:
                     gt_toolbar gs_toolbar 'UCR_DUMMY'   '1',
                     gt_toolbar gs_toolbar 'UCR_SEL_COND' '2',
                     gt_toolbar gs_toolbar 'UCR_DUMMY'   '3'.
        SET HANDLER go_event_grid->handle_toolbar_comp   FOR go_grid.
      ENDIF.
    * Set header-control invisible while main-list is displayed
      IF NOT go_splitter_container IS INITIAL.
    * Header container can be set visible by user on main-screen
        CALL METHOD go_splitter_container->set_row_height
          EXPORTING
            id     = 1
            height = 0.
        IF NOT go_dydo IS INITIAL.
    * Display last header if user wants to set it visible
          CALL METHOD go_dydo->display_document
            EXPORTING
              parent = go_container_head.
        ENDIF.
      ENDIF.
    * subscreen with main list simply is started once again
    * prepared with current user settings
      IF ( LINES( gt_fieldcat_save ) > 0 ) AND
         NOT g_display_main_again IS INITIAL.
        REFRESH gt_fieldcat.
        gt_fieldcat[] = gt_fieldcat_save[].
    *    clear g_display_main_again.
    * is necessary, because current_frontend_fieldcat must be set
        CALL METHOD go_grid->set_table_for_first_display
          EXPORTING
            i_bypassing_buffer   = 'X'
            i_save               = g_save
            is_layout            = gs_layout
            is_variant           = gs_variant
            it_special_groups    = gt_sgrp                      "mb110403
            it_toolbar_excluding = gt_exclude_toolbar
          CHANGING
            it_fieldcatalog      = gt_fieldcat
            it_outtab            = <gt_outtab>.
    * set current fieldcat
        CALL METHOD go_grid->set_frontend_fieldcatalog
          EXPORTING
            it_fieldcatalog = gt_fieldcat.
    * now reset other current layout-infos if necessary
        PERFORM set_current_layout USING go_grid
                                         gt_filter_save
                                         gt_sort_save
                                         gs_layout_save.
    * display current main-list
        CALL METHOD go_grid->refresh_table_display.
        REFRESH: gt_fieldcat_save, gt_filter_save, gt_sort_save.
        CLEAR  : gs_layout_save.
      ELSE.
    * Show ALV
        CALL METHOD go_grid->set_table_for_first_display
          EXPORTING
            i_bypassing_buffer   = 'X'
            i_save               = g_save
            is_layout            = gs_layout
            is_variant           = gs_variant
            it_special_groups    = gt_sgrp                      "mb110403
            it_toolbar_excluding = gt_exclude_toolbar
          CHANGING
            it_sort              = gt_sort
            it_fieldcatalog      = gt_fieldcat
            it_outtab            = <gt_outtab>.
        CLEAR g_display_detail_again.
        g_display_main_again = 'X'.
      ENDIF.
    * Set cursor on selected row if necesary
      IF NOT gt_row_id IS INITIAL.
        CALL METHOD go_grid->set_selected_rows
          EXPORTING
            it_index_rows = gt_row_id.
      ENDIF.
    ENDFORM.                    " display_main_list_subscreen
    *&      Form  display_message
    FORM display_message USING lo_grid_object TYPE REF TO cl_gui_alv_grid
                               lf_refresh_msg_table TYPE c.
      DATA: l_lines       TYPE i,
            ls_layout     TYPE lvc_s_layo.
    * header_main is not used by Worbench
      IF g_subscreen IS INITIAL.
        PERFORM header_main.
      ENDIF.
      g_no_data = 'X'.
    * if first data selection results no data gt_parameter_save must be
    * filled  from lt_parameter to take care of further user changed
    * parameters from list screen
      DESCRIBE TABLE gt_parameter_save LINES l_lines.
      IF l_lines =  0.
        gt_parameter_save[] = gt_parameter[].
      ENDIF.
      PERFORM no_data_selected IN PROGRAM (gc_progname)
                                USING      gt_fieldcat_mess
                                           gs_fieldcat_mess
                                           gt_message
                                           gs_message
                                           text-101
                                           text-102
                                           'TEXT'
                                           'LT_MESSAGE'
                                           lf_refresh_msg_table   " 'X'
                                           space.      "  'C610'. no color, accessibility
    *** Start of Comment By Ramesh Babu N,IBM - C1DK900725 ***
    * Set header-control invisible while main-list is displayed
    *  IF NOT go_splitter_container IS INITIAL.
    *    CALL METHOD go_splitter_container->set_row_height
    *      EXPORTING
    *        id     = 1
    *        height = 0.
    *    CALL METHOD go_splitter_container->set_row_sash
    *      EXPORTING
    *        id    = 1
    *        type  = cl_gui_splitter_container=>type_sashvisible
    *        value = cl_gui_splitter_container=>false.
    *  ENDIF.
    *** End of Comment By Ramesh Babu N,IBM - C1DK900725  ***
    * display messages
    *  ls_layout-no_toolbar = 'X'.
      CALL METHOD lo_grid_object->set_table_for_first_display
        EXPORTING
          i_bypassing_buffer   = 'X'
          it_toolbar_excluding = gt_exclude_toolbar_mess
          is_layout            = ls_layout
        CHANGING
          it_fieldcatalog      = gt_fieldcat_mess
          it_outtab            = gt_message.
    *** Start of Comment By Ramesh Babu N,IBM - C1DK900725 ***
    * Event-Handler for docking-container
    *  IF go_event_dock IS INITIAL.
    *    CREATE OBJECT go_event_dock.
    *  ENDIF.
    *** End of Comment By Ramesh Babu N,IBM - C1DK900725  ***
      IF go_parameter IS INITIAL.
        CALL METHOD cl_uc_parameter=>get_instance
          IMPORTING
            eo_instance = go_parameter.
      ENDIF.
    *** Start of Comment By Ramesh Babu N,IBM - C1DK900725 ***
    *  SET HANDLER go_event_dock->handle_new_parameters FOR go_parameter.
    *** End of Comment By Ramesh Babu N,IBM - C1DK900725  ***
    ENDFORM.                    " display_message
    *&      Form  sub_download_data
    * Used for downloading BCS data to a TAB delimited file in Custom task *
    *      <--ct_data  HASHED TABLE
    FORM f_download_data  USING     ct_task     TYPE uc_task
                                    ct_sel      TYPE uc0_ts_sel
                                    gt_param    TYPE ucm_ts_parameter
                          CHANGING  ct_message  TYPE uc0_t_message
                                    ct_data     TYPE HASHED TABLE..
    * SUBROUTINE DESCRIPION: Used for downloading BCS data to file in Custome Task
    *           DEVELOPER: Ramesh Babu Nalla , IBM
    *       CREATION DATE: 2007-10-11
    *          DER NUMBER: None
    * TRANSPORT NUMBER(S): C1DK900725
    * REVISION HISTORY-----------------------------------------------------*
    *       REVISION NO: C1DK900725      REFERENCE NO:  None
    *         DEVELOPER: Ramesh Babu N,IBM       DATE:  2007-10-11
    *       DESCRIPTION: Copied from SAP FM UCR_LST_LOGIC *
      CONSTANTS : c_task01 TYPE uc_task VALUE 'T2700',
                  c_task02 TYPE uc_task VALUE 'T2490'.
      TYPES:  BEGIN OF ty_download,
    **            /bic/zcs_comp   TYPE char08,      " Unilever-Company
    **            /bic/zcs_item   TYPE char10,      " Unilever-Item
    **            /1fb/move_type  TYPE char03,      " Unilever-Movement type
    **            /bic/zcs_pcom   TYPE char08,      " Unilever-Partner Company
    **            /bic/zcs_invc   TYPE char08,      " Unilever-Investee Company
    **            /bic/zcs_cang   TYPE char03,      " Unilever-Cost Analysis Group
    **            /bic/zcs_ad     TYPE char08,      " Unilever-Aquisitions/Disposals
    **            /bic/zcs_cd     TYPE char08,      " Unilever-Continued/Discontinued Ops.
    **            /bic/zcs_prgp   TYPE char08,      " Unilever-Product Category
                /bic/zfb_comp   TYPE char08,      " Unilever-Company
                /bic/zfb_item   TYPE char10,      " Unilever-Item
                /bic/zfb_move   TYPE char03,      " Unilever-Movement type
                /bic/zfb_pcom   TYPE char08,      " Unilever-Partner Company
                /bic/zfb_invc   TYPE char08,      " Unilever-Investee Company
                /bic/zfb_cang   TYPE char03,      " Unilever-Cost Analysis Group
                /bic/zfb_ad     TYPE char08,      " Unilever-Aquisitions/Disposals
                /bic/zfb_cd     TYPE char08,      " Unilever-Continued/Discontinued Ops.
                /bic/zfb_prgp   TYPE char08,      " Unilever-Product Category
                /1fb/cs_trn_lc  TYPE string,      " Unilever-Period value in Local currency
                /1fb/cs_trn_qty TYPE string,     " Unilever-Periodic quantity
                unit            type string,
              END OF ty_download.
    * flag
      DATA flg_chk TYPE c.
      DATA: lr_s_data_out TYPE REF TO data,
            lr_t_data_out TYPE REF TO data,
            l_outtype     TYPE field_type VALUE 'UCR_SX_TX_DATA_LST',
            lr            TYPE REF TO data,
            lo_conv       TYPE REF TO lcl_convert_output,
            lt_char       TYPE lcl_convert_output=>th_comp,
            ls_comp       TYPE lcl_convert_output=>s_comp,
            lr_s_data     TYPE REF TO data,
            lr_t_data     TYPE REF TO data,
            l_filename    TYPE string,
            l_action      TYPE i,
            l_path        TYPE string,
            l_seperator   TYPE char01 VALUE 'X',
            l_fullpath    TYPE string,
            l_mmyy        TYPE string,
            lr_sel_data   TYPE REF TO data,
            lr_t_val      TYPE REF TO data,
            lr_t_final    TYPE REF TO data,
            lr_val        TYPE REF TO data,
            ls_download   TYPE REF TO data,
            lt_download   TYPE REF TO data,
            ls_sel        TYPE REF TO data,
            ls_msg        TYPE uc0_s_message.
    ** SOC by Dpak-------------------------------------------------------------------------------------------
    ** Changed by Deepak N Jain, IBM on 16/11/2006 as the corresponding field name assigned by Ramesh from
    ** the structure <LS_DATA_OUT> are not matching. This is because of the new cube from whch the Financial
    ** data is coming now. The new cube is ZFBCS_T1 which has replaced the old cube ZCS_T1.
    ** Hence, Short Dump on Execution.
    **  DATA: l_comp        TYPE string VALUE '/BIC/ZCS_COMP',  " Unilever-Company
    **        l_cgcomp      TYPE string VALUE '/1FB/SEM_CGCOMP'," Unilever-Consolidation Group
    **        l_pcomp       TYPE string VALUE '/BIC/ZCS_PCOM',  " Unilever-Partner Company
    **        l_doct        TYPE string VALUE '/BIC/ZCS_DOCT',  " Unilever-Document type
    **        l_plevel      TYPE string VALUE 'CS_PLEVEL',      " Unilever-Posting Level
    **        l_tc          TYPE string VALUE '/1FB/CS_TRN_TC', " Unilever-Period value in Transaction currency
    **        l_qty         TYPE string VALUE '/1FB/CS_TRN_QTY'," Unilever-Periodic quantity
    **        l_trn_lc      TYPE string VALUE '/1FB/CS_TRN_LC', " Unilever-Period value in Local currency
    **        l_bu          TYPE string VALUE '/BIC/ZCS_PROF',  " Unilever-Business Unit/Cost Centre
    **        l_low         TYPE string VALUE 'LOW'.
      DATA: l_comp        TYPE string VALUE '/BIC/ZFB_COMP',  " Unilever-Company
            l_cgcomp      TYPE string VALUE '/BIC/ZFB_CG1',   " Unilever-Consolidation Group
            l_pcomp       TYPE string VALUE '/BIC/ZFB_PCOM',  " Unilever-Partner Company
            l_doct        TYPE string VALUE '/BIC/ZFB_DOCT',  " Unilever-Document type
            l_invc        TYPE string VALUE '/BIC/ZFB_INVC',  " Unilever-Investee Company
            l_plevel      TYPE string VALUE 'CS_PLEVEL',      " Unilever-Posting Level
            l_tc          TYPE string VALUE '/1FB/CS_TRN_TC', " Unilever-Period value in Transaction currency
            l_qty         TYPE string VALUE '/1FB/CS_TRN_QTY'," Unilever-Periodic quantity
            l_trn_lc      TYPE string VALUE '/1FB/CS_TRN_LC', " Unilever-Period value in Local currency
            l_bu          TYPE string VALUE '/BIC/ZCS_PROF',  " Unilever-Business Unit/Cost Centre
            l_low         TYPE string VALUE 'LOW',
            l_unit        TYPE string  VALUE 'UNIT'.
    ** EOC by Dpak-----------------------------------------------------------------------------------------------
    ** future use **
    **  FISCVARNT TYPE L0002FISCVARNT,
    **  FISCPERIOD TYPE L0002FISCPERIOD,
    **  /BIC/ZFB_VERS TYPE L0002/BIC/ZFB_VERS,
    **  /BIC/ZFB_CG1 TYPE L0002/BIC/ZFB_CG1,
    **  /BIC/ZFB_COMP TYPE L0002/BIC/ZFB_COMP,
    **  /1FB/CS_CHART TYPE L0002/1FB/CS_CHART,
    **  /BIC/ZFB_MOVE TYPE L0002/BIC/ZFB_MOVE,
    **  /BIC/ZFB_PCOM TYPE L0002/BIC/ZFB_PCOM,
    **  ACQ_YEAR TYPE L0002ACQ_YEAR,
    **  ACQ_PER TYPE L0002ACQ_PER,
    **  /BIC/ZFB_INVC TYPE L0002/BIC/ZFB_INVC,
    **  /BIC/ZFB_ALCO TYPE L0002/BIC/ZFB_ALCO,
    **  CS_PLEVEL TYPE L0002CS_PLEVEL,
    **  /BIC/ZFB_DOCT TYPE L0002/BIC/ZFB_DOCT,
    **  BCS_CTFLG TYPE L0002BCS_CTFLG,
    **  UNIT TYPE L0002UNIT,
    **  /1FB/CURKEY_TC TYPE L0002/1FB/CURKEY_TC,
    **  /1FB/CURKEY_LC TYPE L0002/1FB/CURKEY_LC,
    **  /1FB/CURKEY_GC TYPE L0002/1FB/CURKEY_GC,
    **  /BIC/ZFB_PRGP TYPE L0002/BIC/ZFB_PRGP,
    **  /BIC/ZFB_COUN TYPE L0002/BIC/ZFB_COUN,
    **  /BIC/ZFB_CANG TYPE L0002/BIC/ZFB_CANG,
    **  /1FB/FUNC_AREA TYPE L0002/1FB/FUNC_AREA,
    **  /BIC/ZFB_CT TYPE L0002/BIC/ZFB_CT,
    **  /BIC/ZFB_CD TYPE L0002/BIC/ZFB_CD,
    **  /BIC/ZFB_AD TYPE L0002/BIC/ZFB_AD,
    **  /BIC/ZFB_FR01 TYPE L0002/BIC/ZFB_FR01,
    **  /BIC/ZFB_FR02 TYPE L0002/BIC/ZFB_FR02,
    **  FISCYEAR TYPE L0002FISCYEAR,
    **  /BIC/ZFB_ITEM TYPE L0002/BIC/ZFB_ITEM,
    ** future use **
      FIELD-SYMBOLS: <lt_data_out> TYPE STANDARD TABLE,
                     <ls_data_out> TYPE ANY,
                     <ls_data>     TYPE ANY,
                     <ls_data_cop> TYPE ANY,
                     <lt_data_std> TYPE STANDARD TABLE,
                     <ls_data_std> TYPE ANY,
                     <ls_download>  TYPE ANY,
                     <lt_download> TYPE STANDARD TABLE,
                     <comp>        TYPE ANY,
                     <cgcomp>      TYPE ANY,
                     <pcomp>       TYPE ANY,
                     <doct>        TYPE ANY,
                     <plevel>      TYPE ANY,
                     <tc>          TYPE ANY,
                     <invc>        TYPE ANY,
                     <qty>         TYPE ANY,
                     <unit>        TYPE ANY,
                     <trn_lc>      TYPE ANY,
                     <comp1>       TYPE ANY,
                     <cgcomp1>     TYPE ANY,
                     <pcomp1>      TYPE ANY,
                     <doct1>       TYPE ANY,
                     <plevel1>     TYPE ANY,
                     <tc1>         TYPE ANY,
                     <invc1>       TYPE ANY,
                     <qty1>        TYPE ANY,
                     <trn_lc1>     TYPE ANY,
                     <unit1>       TYPE ANY,
                     <bu>          TYPE ANY,
                     <bu1>         TYPE ANY,
                     <low>         TYPE ANY,
                     <l_year>      TYPE ANY ,
                     <l_period>    TYPE ANY ,
                     <l_mmyy>      TYPE ANY,
                     <ls_sel_data> TYPE ANY,
                     <ls_val>      TYPE zbcs_check_val,
                     <lt_t_val>    TYPE STANDARD TABLE,
                     <lt_t_final>  TYPE STANDARD TABLE.
    **************** Begin Of Addtion - ASIF MAQBOOL ******************
      Data: BEGIN OF l_s_tab,
            values TYPE C LENGTH 400,
           end OF l_s_tab,
          gs_param LIKE LINE OF gt_param,
          l_temp_store LIKE gt_param.
      Field-SYMBOLS: <gt_param> TYPE ANY TABLE,
                     <final_gt> TYPE any ,
                     <gs_fieldname> TYPE any,
                     <gs_value> TYPE any.
      Data: l_t_tab TYPE TABLE OF string INITIAL SIZE 0,
           str TYPE string,
           str1 TYPE string.
    **************** End Of Addtion - ASIF MAQBOOL ******************
    * create Line-structure of data table
      CREATE DATA lr_s_data LIKE LINE OF ct_data.
      ASSIGN lr_s_data->* TO <ls_data_std>.
    ** create cumulation table
      CREATE DATA lr_t_data LIKE STANDARD TABLE OF <ls_data_std>.
      ASSIGN lr_t_data->* TO <lt_data_std>.
      LOOP AT ct_data INTO <ls_data_std>.
        COLLECT <ls_data_std> INTO <lt_data_std>.
      ENDLOOP.
      FREE ct_data.
    * get reference for outtab / create outtab
      CALL METHOD go_model->create_data_reference
        EXPORTING
          io_tx_data_io_type = go_model->ds_tx_data_io_type-totals
          i_type             = l_outtype "'UCR_SX_TX_DATA_LST'
        IMPORTING
          er_data            = lr_s_data_out.
      ASSIGN lr_s_data_out->* TO <ls_data_out>.
      ASSIGN lr_s_data_out->* TO <ls_data_cop>.
      CREATE DATA lr_t_data_out LIKE STANDARD TABLE OF <ls_data_out>.
      ASSIGN lr_t_data_out->* TO <lt_data_out>.
      CREATE DATA lr LIKE LINE OF <lt_data_std>.
      ASSIGN lr->* TO <ls_data>.
      CALL METHOD lcl_convert_output=>get_instance
        EXPORTING
          io_model    = go_model
          it_char     = lt_char
        IMPORTING
          eo_instance = lo_conv
        CHANGING
          cs_data     = <ls_data>.
      ASSIGN: l_comp   TO <comp>,
              l_cgcomp TO <cgcomp>,
              l_pcomp  TO <pcomp>,
              l_invc   TO <invc>,
              l_doct   TO <doct>,
              l_plevel TO <plevel>,
              l_tc     TO <tc>,
              l_qty    TO <qty>,
              l_trn_lc TO <trn_lc>,
              l_bu     TO <bu>,
              l_mmyy   TO <l_mmyy>,
              l_low    TO <low>,
              l_unit   TO <unit>.
      LOOP AT <lt_data_std> INTO <ls_data>.    "  loop
        CALL METHOD lo_conv->convert_output.      "end of "wis240605
    *     fill outtab
        ASSIGN COMPONENT if_uc_model=>gc_type_comp_s_char
        OF STRUCTURE <ls_data> TO <ls_data_cop>.
        MOVE-CORRESPONDING <ls_data_cop> TO <ls_data_out>.
        ASSIGN COMPONENT if_uc_model=>gc_type_comp_s_kfig
        OF STRUCTURE <ls_data> TO <ls_data_cop>.
        MOVE-CORRESPONDING <ls_data_cop> TO <ls_data_out>.
        IF ct_task = c_task01 OR ct_task = space . "'it can be T2700 or blank
    *****  aggregate the transactionaldata for given Rules  *****
          ASSIGN COMPONENT : <comp>   OF STRUCTURE <ls_data_out> TO <comp1>,
                             <cgcomp> OF STRUCTURE <ls_data_out> TO <cgcomp1>,
                             <pcomp>  OF STRUCTURE <ls_data_out> TO <pcomp1>,
                             <doct>   OF STRUCTURE <ls_data_out> TO <doct1>,
                             <invc>   OF STRUCTURE <ls_data_out> TO <invc1>, "added by Asif M.
                             <plevel> OF STRUCTURE <ls_data_out> TO <plevel1>,
                             <tc>     OF STRUCTURE <ls_data_out> TO <tc1>,
                             <qty>    OF STRUCTURE <ls_data_out> TO <qty1>,
                             <trn_lc> OF STRUCTURE <ls_data_out> TO <trn_lc1>.
    **** 1st Rule ****
    * dont include records where '/1FB/CS_TRN_QTY' and '/1FB/CS_TRN_LC' are blank
          IF <trn_lc1> = 0 AND <qty1> = 0.
            CONTINUE.
          ENDIF.
    **** 2nd Rule ****
    * delete the Posting levels if it is > 1 and clear to blank  CS_PLEVEL
          CHECK <plevel1> LE 1.
          CLEAR <plevel1>.
    **** 3rd Rule ****
    * replace the Unilever Company with CG without prefix G and compare with Partner comp for deletion
    * /BIC/ZCS_COMP with   /1FB/SEM_CGCOMP and check with /BIC/ZCS_PCOM
          IF ct_task <> space.
    ***  code added by Ramesh for the removal GBRNCH  records while downloading the file.
    **** code for removal of GBRNCH records only - Hardcode - sample code
    *        IF <cgcomp1> <> 'GBRNCH'.   " to avoid BRNCH records
    ** replace Company with CG without prefix G when task name is not blank
    *          <comp1> = <cgcomp1>+1.
    *        ELSE.
    *          CONTINUE.
    *        ENDIF.
    **** code for removal of GBRNCH records only - Hardcode - sample code
    ***  the assumption here,is consider only records with Legal entity as numeric excepting the first character
            IF <cgcomp1>+1 CN sy-abcde.   " to avoid BRNCH records
    * replace Company with CG without prefix G when task name is not blank
              <comp1> = <cgcomp1>+1.
            ELSE.
              CONTINUE.
            ENDIF.
          ENDIF.
    * removing leading zero's as SAP sometimes adding them to <pcomp1>.
    *      CALL FUNCTION 'CONVERSION_EXIT_ALPHA_OUTPUT'
    *        EXPORTING
    *          input  = <pcomp1>
    *        IMPORTING
    *          output = <pcomp1>.
          PERFORM f_alpha_conversion USING <comp1>
                                          CHANGING <comp1>.
          PERFORM f_alpha_conversion USING <pcomp1>
                                     CHANGING <pcomp1>.
          " removing leading zero's from Investee Unit company - Added By Asif Maqbool, IBM/Unilever, 25/01/2008.
          PERFORM f_alpha_conversion USING <invc1>
                                     CHANGING <invc1>.
          CHECK <comp1> <> <pcomp1>.
    **** 4rth Rule ****
    * initialise Document type & PV TC to blank   /BIC/ZCS_DOCT & /1FB/CS_TRN_TC
          CLEAR: <doct1>,<tc1>.
        ENDIF.
        COLLECT: <ls_data_out> INTO <lt_data_out>.
      ENDLOOP.          " end loop
      IF <lt_data_out> IS INITIAL.
        PERFORM f_build_msgs USING 'UCM0'
                                   'W'
                                   '053'
                                   text-102
                                   space "ct_task
                                   space
                                   space
                          CHANGING ct_message.
        RETURN.
        MESSAGE e208(00) WITH text-102.
        EXIT.
      ENDIF.
    * perform various steps based on task name
      CASE ct_task.
        WHEN c_task01 OR space.              " 'T2700' or blank
    * download the data into a tab delimited file
    ****             start of Task 0001              ****
    * create Line-structure of download table
          CREATE DATA ls_download TYPE ty_download.
          ASSIGN ls_download->* TO <ls_download>.
    ** create Download data internal table for task T2700
          CREATE DATA lt_download LIKE STANDARD TABLE OF <ls_download>.
          ASSIGN lt_download->* TO <lt_download>.
          LOOP AT <lt_data_out> INTO <ls_data_out>.
            MOVE-CORRESPONDING <ls_data_out> TO <ls_download>.
            ASSIGN COMPONENT <trn_lc> OF STRUCTURE <ls_download> TO <trn_lc1>.
    *** 6th Rule **********************
            " Check for values, if present remove decimals, if not present clear it of (blank).
            UNASSIGN <qty1>.
            ASSIGN COMPONENT <qty> of STRUCTURE <ls_download> to <qty1>.
            ASSIGN COMPONENT <unit> of STRUCTURE <ls_download> to <unit1>.
            if <unit1> = '' OR <unit1> <> '%'.
              REPLACE ALL OCCURRENCES OF '.' in <qty1> WITH '' RESPECTING CASE.
              <qty1> = ''.
            endif.
            if <unit1> <> '' And <qty1> <> ''.
              <unit1> = ''. " We dont need unit downloaded.
              REPLACE ALL OCCURRENCES OF '.' in <qty1> WITH '' RESPECTING CASE.
              <qty1> = <qty1>+0(2).
            endif.
    **** 5th Rule ****
    * Move the Negative sign to front
            PERFORM f_put_sign_in_front CHANGING <trn_lc1>.
            INSERT <ls_download>  INTO TABLE <lt_download>.
          ENDLOOP.
    * move the aggregated data to final table for display
          FREE ct_data.
          ct_data = <lt_data_out>.
          CLEAR: l_path,l_filename,l_fullpath,l_action.
          CALL FUNCTION 'GUI_FILE_SAVE_DIALOG'
           EXPORTING
             window_title            = 'Download aggregated BCS data to Tab Delimited file'
             default_extension       = 'txt'
    *   DEFAULT_FILE_NAME       = dynamic file name as like ALE settings
             file_filter             = 'Text files (*.txt)'
           IMPORTING
             filename                = l_filename
             path                    = l_path
             fullpath                = l_fullpath
             user_action             = l_action .
          CALL METHOD cl_gui_cfw=>flush.
          " *************************** START OF CHANGE - ASIF MAQBOOL ************************
          IF l_action = 0 OR l_action = 1.
            ASSIGN gt_param TO <gt_param>.
            APPEND '100' to l_t_tab.
            READ TABLE gt_param INDEX 6 INTO gs_param.
            ASSIGN COMPONENT 2 OF STRUCTURE gs_param to <gs_value>.
            APPEND <gs_value> to l_t_tab.
            Clear gs_param.
            READ TABLE gt_param INDEX 4 INTO gs_param.
            ASSIGN COMPONENT 2 OF STRUCTURE gs_param to <gs_value>.
            APPEND <gs_value> to l_t_tab.
    *        LOOP AT <gt_param> INTO gs_param.
    *          ASSIGN COMPONENT 1 OF STRUCTURE gs_param to <gs_fieldname>.
    *          CASE <gs_fieldname>.
    *             WHEN '/BIC/ZFB_VERS'.
    *              APPEND '100' to l_t_tab.
    *             WHEN 'FISCPERIOD'.
    *                ASSIGN COMPONENT 2 OF STRUCTURE gs_param to <gs_value>.
    *                APPEND <gs_value> to l_t_tab.
    *             WHEN 'FISCYEAR'.
    *                ASSIGN COMPONENT 2 OF STRUCTURE gs_param to <gs_value>.
    *                APPEND <gs_value> to l_t_tab.
    *              WHEN OTHERS.
    *                ENDCASE.
    *        ENDLOOP.
            CONCATENATE LINES OF l_t_tab INTO str1 SEPARATED BY cl_abap_char_utilities=>horizontal_tab.
            CLEAR l_t_tab.
            INSERT str1 INTO TABLE l_t_tab.
            ASSIGN l_t_tab TO <final_gt>.
            "  To Start by adding the Header Data.
            CALL METHOD cl_gui_frontend_services=>gui_download
              EXPORTING
                filename              = l_fullpath
                write_field_separator = l_seperator "SPACE
              CHANGING
                data_tab              = <final_gt>
              EXCEPTIONS
                file_write_error      = 1.
            " Now append the Data after the header data insertion.
            CALL METHOD cl_gui_frontend_services=>gui_download
              EXPORTING
                filename                = l_fullpath
                write_field_separator   = l_seperator "SPACE
                append                  = 'X'
              CHANGING
                data_tab                = <lt_download>
              EXCEPTIONS
                file_write_error        = 1
                no_batch                = 2
                gui_refuse_filetransfer = 3
                invalid_type            = 4
                no_authority            = 5
                unknown_error           = 6
                header_not_allowed      = 7
                separator_not_allowed   = 8
                filesize_not_allowed    = 9
                header_too_long         = 10
                dp_error_create         = 11
                dp_error_send           = 12
                dp_error_write          = 13
                unknown_dp_error        = 14
                access_denied           = 15
                dp_out_of_memory        = 16
                disk_full               = 17
                dp_timeout              = 18
                file_not_found          = 19
                dataprovider_exception  = 20
                control_flush_error     = 21
                not_supported_by_gui    = 22
                error_no_gui            = 23
                OTHERS                  = 24.
            " *************************** END OF CHANGE - ASIF MAQBOOL ************************
            IF sy-subrc <> 0.
    *          MESSA

    Hi,
    I am also from same project.
    We are facing a problem with this code.
    How can I increase the length of the field obtained by this method.
    CALL METHOD go_model->create_data_reference
        EXPORTING
          io_tx_data_io_type = go_model->ds_tx_data_io_type-totals
          i_type             = l_outtype "'UCR_SX_TX_DATA_LST'
        IMPORTING
          er_data            = lr_s_data_out.
    ASSIGN lr_s_data_out->* TO <ls_data_out>.
    We are getting data overflow error when we try to move some large value to one of the field in <ls_data_out>.
    we can avoid this if the field length is increased.
    Waiting for your reply.
    Regards
    Madhu G S

  • How to get Header in Downloaded .xls file using  GUI_Download function

    How to get Header in Downloaded .xls file using  GUI_Download function ???
    How to use the the Header parameter available in GUI_Download function .

    HI,
    see this sample code..
    data : Begin of t_header occurs 0,
           name(30) type c,
           end of t_header.
    data : Begin of itab occurs 0,
           fld1 type char10,
           fld2 type char10,
           fld3 type char10,
           end   of itab.
    DATA: v_pass_path TYPE string.
    append itab.
    itab-fld1 = 'Hi'.
    itab-fld2 = 'hello'.
    itab-fld3 = 'welcome'.
    append itab.
    append itab.
    append itab.
    append itab.
    append itab.
    t_header-name = 'Field1'.
    append t_header.
    t_header-name = 'Field2'.
    append t_header.
    t_header-name = 'Field3'.
    append t_header.
      CALL FUNCTION 'GUI_FILE_SAVE_DIALOG'
        EXPORTING
          default_extension     = 'XLS'
        IMPORTING
          fullpath              = v_pass_path.
      CALL FUNCTION 'GUI_DOWNLOAD'
        EXPORTING
          filename                        = v_pass_path
          filetype                        = 'DBF'
        TABLES
          data_tab                        = itab
          FIELDNAMES                      = t_header
    Cheers,
    jose.

  • Regarding GUI_DOWNLOAD

    Hi Firends,
    I am using GUI_DOWNLOAD function module to downlaod the internal table data.
    It is working fine, if i am not specifying anything in the fieldnames of the function module table parametrs.
    Here is my situation:
    I declared two internal tables. one is itab1 (for data) and another one is itab2 (for displaying fieldnames).
    1.
    Itab1 consists of 75 columns.
    and rows approximately 10.
    column names like... matnr, maktx,etc
    2.
    itab2 consists of 75 columns and one row.
    FYI: column names are col1, col2, col3,... etc.
    But row (record) consists same as the itab1 column names.
    col1 = matnr, col2 = maktx, etc.
    when I passed itab1 and itab2 to the GUI_DOWNLOAD function module.
      CALL FUNCTION 'GUI_DOWNLOAD'
       EXPORTING
        FILENAME                        = 'C:\XYZ.TXT'
        FILETYPE                         = 'DAT'
      TABLES
        DATA_TAB                        = itab1        
        FIELDNAMES                    = itab2.
    But I am not getting all the field names in the download file. only first column is displaying.
    Could you pls correct me if i am doing wrong
    whether i have to populate column names in itab2 in one row or
    75 rows ( i mean each row one field name)?
    this is very urgent..
    if any body knows about populating field names in the download file, pls send me the code.
    Thanks in advance.
    Raghu

    Hi Raghu,
    see this sample code....
    data : Begin of t_header occurs 0,
           name(30) type c,
           end of t_header.
    data : Begin of itab occurs 0,
           fld1 type char10,
           fld2 type char10,
           fld3 type char10,
           end   of itab.
    DATA: v_pass_path TYPE string.
    append itab.
    itab-fld1 = 'Hi'.
    itab-fld2 = 'hello'.
    itab-fld3 = 'welcome'.
    append itab.
    append itab.
    append itab.
    append itab.
    append itab.
    t_header-name = 'Field1'.
    append t_header.
    t_header-name = 'Field2'.
    append t_header.
    t_header-name = 'Field3'.
    append t_header.
      CALL FUNCTION 'GUI_FILE_SAVE_DIALOG'
        EXPORTING
          default_extension     = 'XLS'
        IMPORTING
          fullpath              = v_pass_path.
      CALL FUNCTION 'GUI_DOWNLOAD'
        EXPORTING
          filename                        = v_pass_path
          filetype                        = 'DBF'
        TABLES
          data_tab                        = itab
          FIELDNAMES                      = t_header

  • Smartform sending pdf file as a mail

    i have done a mailing a pdf as mail i am able to down load a file in to the systam which is perfect but i am not able to send the mail can any one tell me whats the problem in this and guide me if there is any problem.
    CALL FUNCTION 'GUI_FILE_SAVE_DIALOG'
    EXPORTING
       WINDOW_TITLE            = 'Save as'
       DEFAULT_EXTENSION       = 'PDF'
       DEFAULT_FILE_NAME       = W_FNAME
      WITH_ENCODING           =
      FILE_FILTER             =
      INITIAL_DIRECTORY       =
      DEFAULT_ENCODING        =
    IMPORTING
       FILENAME                = W_FNAME
      PATH                    =
      FULLPATH                =
       USER_ACTION             = v_action
      FILE_ENCODING           =
    if v_action = '9'.
      exit.
    endif.
    CALL FUNCTION 'GUI_DOWNLOAD'
    EXPORTING
    BIN_FILESIZE = W_BIN_SIZE
    FILENAME = W_FNAME
    FILETYPE = 'BIN' "'ASC'
    IMPORTING
    FILELENGTH = V_FILESIZE
    TABLES
    DATA_TAB = T_PDF_TAB
    EXCEPTIONS
    FILE_WRITE_ERROR = 1
    NO_BATCH = 2
    GUI_REFUSE_FILETRANSFER = 3
    INVALID_TYPE = 4
    NO_AUTHORITY = 5
    UNKNOWN_ERROR = 6
    HEADER_NOT_ALLOWED = 7
    SEPARATOR_NOT_ALLOWED = 8
    FILESIZE_NOT_ALLOWED = 9
    HEADER_TOO_LONG = 10
    DP_ERROR_CREATE = 11
    DP_ERROR_SEND = 12
    DP_ERROR_WRITE = 13
    UNKNOWN_DP_ERROR = 14
    ACCESS_DENIED = 15
    DP_OUT_OF_MEMORY = 16
    DISK_FULL = 17
    DP_TIMEOUT = 18
    FILE_NOT_FOUND = 19
    DATAPROVIDER_EXCEPTION = 20
    CONTROL_FLUSH_ERROR = 21
    OTHERS = 22 .
    IF SY-SUBRC <> 0.
    MESSAGE 'File not downloaded succesfully' TYPE 'E'.
    ELSE.
    CONCATENATE 'File : ' W_FNAME 'downloaded succesfully ' INTO MSG1.
    MESSAGE MSG1 TYPE 'I'.
    ENDIF.
    data : GD_DOC_DATA type SODOCCHGI1.
    data : LT_MAILPACK type standard table of SOPCKLSTI1.
    data : LA_MAILPACK type SOPCKLSTI1.
    data : LT_OBJTXT   type STANDARD TABLE OF SOMLRECI1 WITH HEADER LINE.
    DATA:LF_LINES TYPE I.
    DATA LV_OUTPUT TYPE SDOKCNTBINS WITH HEADER LINE.
    *DATA LV_OUTPUT TYPE standard table of SOLISTI1 .
    data pdf_file type XSTRING.
    DATA: IT_RECEIVERS TYPE STANDARD TABLE OF SOMLRECI1 WITH HEADER
    LINE.
    data iv_mailid type AD_SMTPADR.
    move W_FNAME to pdf_file.
    Data : w_buffer TYPE string.
    *data : i_record LIKE solisti1 OCCURS 0
    *WITH HEADER LINE.
    data : i_record LIKE solisti1 OCCURS 0
    WITH HEADER LINE.
    data : s_record LIKE solisti1 OCCURS 0
    WITH HEADER LINE.
         CALL FUNCTION 'SCMS_XSTRING_TO_BINARY'
           EXPORTING
             BUFFER     = pdf_file "PDF file from function module
           TABLES
             BINARY_TAB = LV_OUTPUT.
         DESCRIBE TABLE LV_OUTPUT LINES LF_LINES.
    loop at T_PDF_TAB.
    *TRANSLATE T_PDF_TAB USING '~'.
    CONCATENATE w_buffer T_PDF_TAB INTO w_buffer.
      endloop.
    *TRANSLATE w_buffer USING '~ '.
    DO.
    i_record = w_buffer.
    APPEND i_record.
    SHIFT w_buffer LEFT BY 255 PLACES.
    IF w_buffer IS INITIAL.
    EXIT.
    ENDIF.
    ENDDO.
    s_record[] = i_record[].
    *DESCRIBE TABLE T_PDF_TAB LINES LF_LINES.
    select single SMTP_ADDR from ADR6 into iv_mailid where ADDRNUMBER =
    IV_ADDNR_VENDOR.
         DATA:LT_OBJTXT LIKE SOLISTI1 OCCURS 10 WITH HEADER LINE.
          MOVE 'Email sent to you from SAP' TO LT_OBJTXT.
          APPEND LT_OBJTXT.
          GD_DOC_DATA-OBJ_DESCR = 'PDF'.
          GD_DOC_DATA-OBJ_NAME  = 'PDFMail'.
          GD_DOC_DATA-OBJ_DESCR = 'PDF'.
          GD_DOC_DATA-SENSITIVTY = 'O'.
       GD_DOC_DATA-EXPIRY_DAT = SY-DATUM + 15.
          GD_DOC_DATA-DOC_SIZE = STRLEN( LT_OBJTXT ).
          CLEAR  LA_MAILPACK.
          LA_MAILPACK-HEAD_START = 1.
          LA_MAILPACK-HEAD_NUM = 0.
          LA_MAILPACK-BODY_START = 1.
          LA_MAILPACK-BODY_NUM = 1.
       LA_MAILPACK-DOC_TYPE = 'RAW'.
          LA_MAILPACK-DOC_SIZE = STRLEN( LT_OBJTXT ).
          APPEND  LA_MAILPACK TO  LT_MAILPACK.
          CLEAR LA_MAILPACK.
          LA_MAILPACK-TRANSF_BIN = ''.
          LA_MAILPACK-HEAD_START = 1.
          LA_MAILPACK-HEAD_NUM = 1.
          LA_MAILPACK-BODY_START = 1.
          LA_MAILPACK-DOC_TYPE = 'PDF'.
          LA_MAILPACK-BODY_NUM = LF_LINES.
          LA_MAILPACK-DOC_SIZE = LF_LINES * 255.
          LA_MAILPACK-OBJ_DESCR = 'Open'.
          LA_MAILPACK-OBJ_NAME = 'MAIL'.
          APPEND LA_MAILPACK TO LT_MAILPACK.
          IT_RECEIVERS-RECEIVER = iv_mailid.
          IT_RECEIVERS-REC_TYPE = 'U'.
          APPEND IT_RECEIVERS.
    CALL FUNCTION 'SO_NEW_DOCUMENT_ATT_SEND_API1'
      EXPORTING
        DOCUMENT_DATA                    = GD_DOC_DATA
       PUT_IN_OUTBOX                    = 'X'
       COMMIT_WORK                      = 'X'
    IMPORTING
      SENT_TO_ALL                      =
      NEW_OBJECT_ID                    =
      TABLES
        PACKING_LIST                     = LT_MAILPACK
      OBJECT_HEADER                    =
       CONTENTS_BIN                     = s_record
       CONTENTS_TXT                     = LT_OBJTXT
      CONTENTS_HEX                     = LV_OUTPUT
      CONTENTS_HEX                     = s_record
      OBJECT_PARA                      =
      OBJECT_PARB                      =
        RECEIVERS                        = IT_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 'Mail was not sent' type 'E'.
    else.
      MESSAGE 'Mail was sent Succesfully' type 'S'.
    ENDIF.
    thanks and regards ,
    venkat.

    refer below program
    c_par-preview = space.
        c_par-getotf = 'X'.
        out_opt-tddest = 'EPSON-COMMON'.
        CALL FUNCTION fm_name
          EXPORTING
            control_parameters = c_par
            output_options     = out_opt
            user_settings      = space
            vbeln              = it_vbeln-vbeln
            pdf                = r2
            rbiclear           = c3
          IMPORTING
            job_output_info    = opt
            einv               = einv.
        i_otf = opt-otfdata.
        CALL FUNCTION 'CONVERT_OTF'
          EXPORTING
            format        = 'PDF'
            max_linewidth = 132
          IMPORTING
            bin_filesize  = v_len_in
          TABLES
            otf           = i_otf
            lines         = i_tline.
       IF lv_check EQ 1.
         CALL METHOD cl_gui_frontend_services=>file_save_dialog
           CHANGING
             filename = file_name
             path     = file_path
             fullpath = full_path.
       ENDIF.
        CLEAR full_path.
        move wa_exnum to lv_exnum.
        shift lv_exnum left deleting leading '0'.
        move 'C:\SAPWORKDIR\' to file_path.
        CONCATENATE file_path 'Invoice_E' lv_exnum '.PDF' INTO full_path.
        CALL FUNCTION 'GUI_DOWNLOAD'
          EXPORTING
            bin_filesize = v_len_in
            filename     = full_path
            filetype     = 'BIN'
          IMPORTING
            filelength   = file_size
          TABLES
            data_tab     = i_tline.
    For mailing
        IF ch2 EQ 'X'.
          DATA sub TYPE string.
          CALL FUNCTION 'QCE1_CONVERT'
            TABLES
              t_source_tab         = i_tline
              t_target_tab         = so_ali[]
            EXCEPTIONS
              convert_not_possible = 1
              OTHERS               = 2.
    Mail Contents
          refresh objtxt[].
          objtxt = space.
          APPEND objtxt.
          objtxt = 'Dear Sir/Madam,'.
          APPEND objtxt.
    Determining the Email Ids of Mail Receivers
          PERFORM fetch_mailids.
          objtxt = 'Copy to :'.
          APPEND objtxt.
          LOOP AT reclist.
            objtxt = reclist-receiver.
            APPEND objtxt.
          ENDLOOP.
          objtxt = space.
          APPEND objtxt.
          objtxt = '<This is system generated message>.'.
          APPEND objtxt.
          objtxt = space.
          APPEND objtxt.
    Mail Body of message over.
          DESCRIBE TABLE objtxt[] LINES v_lines_txt.
          CONCATENATE 'Inv.' invno INTO sub SEPARATED BY space.
          doc_chng-obj_name = sub.
          doc_chng-expiry_dat = sy-datum + 10.
    Mail Subject
          refresh objpack[].
          CONCATENATE 'Pricol Dispatch - Invoice' invno '- Reg.' INTO sub SEPARATED BY space.
          doc_chng-obj_descr = sub.
          doc_chng-sensitivty = 'F'.
          doc_chng-doc_size = v_lines_txt * 255.
          objpack-transf_bin = ' '.
          objpack-head_start = 1.
          objpack-head_num = 0.
          objpack-body_start = 1.
          objpack-body_num = v_lines_txt.
          objpack-doc_type = 'RAW'.
          APPEND objpack.
    *PDF Attachment
          DESCRIBE TABLE so_ali[] LINES lineno.
          objpack-transf_bin = 'X'.
          objpack-head_start = 1.
          objpack-head_num = 1.
          objpack-body_start = 1.
          objpack-doc_size = lineno * 255 .
          objpack-body_num = lineno.
          objpack-doc_type = 'PDF'.
          objpack-obj_name = 'INVOICE'.
          objpack-obj_descr = 'Invoice'.
          objpack-obj_langu = 'E'.
          APPEND objpack.
          CALL FUNCTION 'SO_NEW_DOCUMENT_ATT_SEND_API1'
          EXPORTING
          document_data = doc_chng
          put_in_outbox = 'X'
          commit_work = 'X'
          TABLES
          packing_list = objpack
          contents_txt = objtxt[]
          contents_bin = so_ali[]
    *contents_hex = so_ali[]
          receivers = reclist[]
          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.
            PERFORM mail.
            MESSAGE 'Mail sent successfully' TYPE 'S'.
    *SUBMIT RSCONN01 WITH MODE = MODE.
          ENDIF.

  • Download ALV to any file

    Hi Experts,
    I am not able to see the standard ALV toolbar to download the output to an Excel or local file..etc.
    I placed my ALV container on a screen below some I/O text boxes in display mode only.
    I also need to download the I/O text boxes.
    Can someone help me with this?
    Thanks
    Dany

    Hi Dany,
    Could you verify that in the layout the no_toolbar option is equal to space.
    Regards,
    Eric
    PD. The standard download button of the ALV, its only going to work for the data on your internal table. In order to download all the data of the screen you are going to need to program the button functionality yourself.
    Add a button to the toolbar and in the user_command do something like this (to export to excel).
    CASE sy-ucomm.
        WHEN 'DOWNLOAD'.
          filefilter = 'Ficheros EXCEL (*.XLS)|*.XLS|Ficheros de texto (*.TXT)|*.TXT|Fich.(todos) (*.*)|*.*|'.
          CALL FUNCTION 'GUI_FILE_SAVE_DIALOG'
            EXPORTING
              file_filter       = filefilter
              default_extension = 'xls'
            IMPORTING
              filename          = filename
              path              = path
              fullpath          = fullpath
              user_action       = user_action.
          DATA: wa_filelength TYPE i,
                wa_archivo    TYPE string.
          CALL METHOD cl_gui_frontend_services=>gui_download
            EXPORTING
              filename                = fullpath
              filetype                = 'ASC'
              write_field_separator   = 'X'
            IMPORTING
              filelength              = wa_filelength
            CHANGING
              data_tab                = it_asc_file
            EXCEPTIONS
              file_write_error        = 1
              no_batch                = 2
              gui_refuse_filetransfer = 3
              invalid_type            = 4
              no_authority            = 5
              unknown_error           = 6
              header_not_allowed      = 7
              separator_not_allowed   = 8
              filesize_not_allowed    = 9
              header_too_long         = 10
              dp_error_create         = 11
              dp_error_send           = 12
              dp_error_write          = 13
              unknown_dp_error        = 14
              access_denied           = 15
              dp_out_of_memory        = 16
              disk_full               = 17
              dp_timeout              = 18
              file_not_found          = 19
              dataprovider_exception  = 20
              control_flush_error     = 21
              not_supported_by_gui    = 22
              error_no_gui            = 23
              OTHERS                  = 24.
    Declare a table in which you are going to save the data in the same way you want it at the output file
    DATA: BEGIN OF t_asc_file OCCURS 100,
            campo1(50)  TYPE c,
            campo2(50)  TYPE c,
            campo3(50)  TYPE c,
            campo4(50)  TYPE c,
            campo5(50)  TYPE c,
            campo6(50)  TYPE c,
            campo7(50)  TYPE c,
            campo8(50)  TYPE c,
            campo9(50)  TYPE c,
            campo10(50) TYPE c,
            campo11(50) TYPE c,
            campo12(50) TYPE c,
            campo13(50) TYPE c,
            campo14(50) TYPE c,
            campo15(50) TYPE c,
            campo16(50) TYPE c,
            campo17(50) TYPE c,
            campo18(50) TYPE c,
            campo19(50) TYPE c,
            campo20(50) TYPE c,
          END OF t_asc_file,
          it_asc_file LIKE t_asc_file OCCURS 0,
          wa_asc_file LIKE LINE OF it_asc_file.
    Reward points if helpful

  • How do you find what objects you modified?

    I am leaving my current company soon and they want me to document all objects that I touched.  Is there a simple way to do this?  I am thinking of a program that I can run (create) by searching z-objects (programs, structures, tables, forms, etc...) that I have modified.  Is this possible?
    Regards,
    Davis

    Just in case anybody finds it useful, here is a quick little program that I wrote.  It accepts a user name and a date range.  It then saves the objects in an excel file.
    Davis.
    *& Report  Z_TRANSPORTED_OBJECTS
    REPORT  z_transported_objects.
    TABLES: e070.
    DATA: t_e070 TYPE e070 OCCURS 0 WITH HEADER LINE.
    DATA : BEGIN OF t_e071 OCCURS 0.
            INCLUDE STRUCTURE e071.
    DATA : END OF t_e071.
    DATA : BEGIN OF t_header OCCURS 0,
           name(30) TYPE c,
           END OF t_header.
    DATA: v_pass_path TYPE string.
    PARAMETERS: p_user LIKE t_e070-as4user.
    SELECT-OPTIONS s_date FOR e070-as4date.
    *Get the header details for all transports created by p_user in the date range of s_date
    * if s_date is empty (no dates specified) then it will return all transports created by p_user
    SELECT * FROM e070 INTO TABLE t_e070 WHERE as4user = p_user AND as4date IN s_date.
    *Get the details (objects) in each transport
    SELECT * INTO TABLE t_e071 FROM e071 FOR ALL ENTRIES IN t_e070 WHERE trkorr = t_e070-trkorr.
    *Sort the table and delete all duplicate entries.  This will leave you with a list of all objects
    * which were "touched" by p_user ONLY if p_user created the transport.
    SORT t_e071 BY pgmid object obj_name.
    DELETE ADJACENT DUPLICATES FROM t_e071 COMPARING pgmid object obj_name.
    *Delete all transports which are included as objects in e071.
    DELETE t_e071 WHERE pgmid = 'CORR' AND object = 'RELE'.
    *Add the header lines for the output file:
    t_header-name = 'Request/Task'.
    APPEND t_header.
    t_header-name = 'Dictionary: Line item'.
    APPEND t_header.
    t_header-name = 'Program ID'.
    APPEND t_header.
    t_header-name = 'Object Type'.
    APPEND t_header.
    t_header-name = 'Object Name'.
    APPEND t_header.
    t_header-name = 'Object Function'.
    APPEND t_header.
    t_header-name = 'Lock Status'.
    APPEND t_header.
    t_header-name = 'Language'.
    APPEND t_header.
    t_header-name = 'Language Key'.
    APPEND t_header.
    t_header-name = 'Activity'.
    APPEND t_header.
    *Save the file in an excel format.
    CALL FUNCTION 'GUI_FILE_SAVE_DIALOG'
      EXPORTING
        default_extension = 'XLS'
      IMPORTING
        fullpath          = v_pass_path.
    CALL FUNCTION 'GUI_DOWNLOAD'
      EXPORTING
        filename   = v_pass_path
        filetype   = 'DBF'
      TABLES
        data_tab   = t_e071
        fieldnames = t_header.

  • Download data to file

    hi,
    all the data i need to dispaly in the output is in final internal table gt_final.
    whereas the problem i need to download this data to excelsheet.
    please let me know what are the varibles i need to pass to the FM GUI_DOWNLOAD
    where i need to write this FM.
    Please help me

    Hi Hema,
    You can use the below sample Program for your reference.
    *& Report  ZCC_EXCEL_DOWNLOAD
    REPORT  ZCC_EXCEL_DOWNLOAD.
    TYPE-POOLS:
                sydes.
    data : Begin of t_header occurs 0,
           name(30) type c,
           end of t_header.
    data : Begin of itab occurs 0,
           fld1 type char10,
           fld2 type char10,
           fld3 type char10,
           end   of itab.
    DATA: v_pass_path TYPE string value 'c:\excel\test.xlsx'..
    DATA: sy_repid LIKE sy-repid,
            td       TYPE sydes_desc.
      sy_repid = sy-repid.
    append itab.
    itab-fld1 = 'Hi'.
    itab-fld2 = '100.00'.
    itab-fld3 = 'welcome'.
    append itab.
    append itab.
    append itab.
    append itab.
    append itab.
    t_header-name = 'Field1'.
    append t_header.
    t_header-name = 'Field2'.
    append t_header.
    t_header-name = 'Field3'.
    append t_header.
    DESCRIBE FIELD itab INTO td.
      CALL FUNCTION 'GUI_FILE_SAVE_DIALOG'
        EXPORTING
          default_extension     = 'XLS'
        IMPORTING
          fullpath              = v_pass_path.
      CALL FUNCTION 'GUI_DOWNLOAD'
        EXPORTING
          filename                        = v_pass_path
          filetype                        = 'DBF'
        TABLES
          data_tab                        = itab
          FIELDNAMES                      = t_header
    Thanks,
    Chidanand

  • Need Help in download data frm APP..server

    Hi all,
    Im trying to download a file frm Application server..
    Till to internal table its ok..but Im not able to download data to excel file..
    Following is the code..Pls help where it is going wrong..
    CALL FUNCTION 'GUI_FILE_SAVE_DIALOG'
       EXPORTING
    *   WINDOW_TITLE            =
         default_extension       = 'XLS'
    *   DEFAULT_FILE_NAME       =
       WITH_ENCODING           = 'X'
    *   FILE_FILTER             =
    *   INITIAL_DIRECTORY       =
    *   DEFAULT_ENCODING        = 'X'
       IMPORTING
    *   FILENAME                =
    *   PATH                    =
         fullpath                = p_path
    *   USER_ACTION             =
    *   FILE_ENCODING           =
    CALL FUNCTION 'GUI_DOWNLOAD'
        EXPORTING
    *   BIN_FILESIZE                    =
          filename                        = p_path
          filetype                        = 'DAT'
    *   APPEND                          = ' '
       WRITE_FIELD_SEPARATOR           = 'X'
    * IMPORTING
    *   FILELENGTH                      =
        TABLES
          data_tab                        = it_final
    *   FIELDNAMES                      =
       EXCEPTIONS
         file_write_error                = 1
         no_batch                        = 2
         gui_refuse_filetransfer         = 3
         invalid_type                    = 4
         no_authority                    = 5
         unknown_error                   = 6
         header_not_allowed              = 7
         separator_not_allowed           = 8
         filesize_not_allowed            = 9
         header_too_long                 = 10
         dp_error_create                 = 11
         dp_error_send                   = 12
         dp_error_write                  = 13
         unknown_dp_error                = 14
         access_denied                   = 15
         dp_out_of_memory                = 16
         disk_full                       = 17
         dp_timeout                      = 18
         file_not_found                  = 19
         dataprovider_exception          = 20
         control_flush_error             = 21
         OTHERS                          = 22
    Thanks.
    Priya

    Hi,
    Use below code.
      DATA:lv_filename TYPE string,
           lv_wnd_tit TYPE string VALUE 'File Download Dialog: ',
           lv_def_extn TYPE string VALUE 'xls',
           lv_init_dir TYPE string VALUE 'C:\',
           filename TYPE string,
           path TYPE string,
           fullpath TYPE string,
           action TYPE i.
      CALL FUNCTION 'GUI_FILE_SAVE_DIALOG'
        EXPORTING
          window_title      = lv_wnd_tit
          default_extension = lv_def_extn
          default_file_name = lv_filename
          initial_directory = lv_init_dir
        IMPORTING
          filename          = filename
          path              = path
          fullpath          = fullpath
          user_action       = action.
    if action = 0 or action = 1 or action = 2.
      CALL FUNCTION 'GUI_DOWNLOAD'
        EXPORTING
          filename                        = fullpath
         filetype                        = 'ASC'
         write_field_separator           = 'X'
        TABLES
          data_tab                        = it_final
    ELSE.
        MESSAGE 'Action is canceled' type 'E'.
    endif.
    regards,
    muralii

  • Use unc path in gui_exec function

    Hi,
    is it possible to use an UNC path in the GUI_EXEC function?
    For example:
      call function 'GUI_EXEC'
         exporting
           command = '\\192.168.8.43\myfolder\myexec.bat'
         importing
           returncode = i_returncode.
    Thanks in advance.
    Regards.

    Calling an external program
    You want to call a program on your PC from an ABAP program ? try this function :
    *This example calls the dos prompt DATA:
    i_returncode TYPE i.
    CALL FUNCTION 'GUI_EXEC'          
        EXPORTING
            command = 'CMD' <<==-- CMD calls the DOS prompt but you can put any program here
    PARAMETER = 'test'
        IMPORTING
            returncode = i_returncode.
    there is a lot of other functions to communicate with the PC like:
    GUI_CREATE_DIRECTORY GUI_DELETE_FILE GUI_DOWNLOAD
    GUI_EXEC
    GUI_FILE_SAVE_DIALOG
    GUI_GET_DESKTOP_INFO
    GUI_GET_FILE_INFO               
    etc...

  • User exit---to capture SO header text

    Hi all,
    Requirement is to maintain SO header texts (va02>goto>header-->texts) in a z table (i.e, acceptance numbers..like remark1, remark2,3  and 4).
    plz guide me from which structure we can capture this value..i mean runtime structure..
    I can use user-exit..MV45AFZZ--->userexit_delete_document
    or any otherwayz..?

    Hi Tuborg,
    Use Function module READ_TEXT.
    or u can follow the program.
    I think it will help u to fulfill ur requirement.
    *& Report  ZSO_TEXT_CHANGE
    REPORT  zso_text_change.
    TABLES : vbak,
             vbap,
             cfstructur.
    DATA : BEGIN OF itab OCCURS 0,
           vbeln LIKE vbak-vbeln,
           posnr LIKE vbap-posnr,
           text1(30),
           text2(30),
           text3(20),
           END OF itab.
    DATA : name LIKE stxh-tdname,
           l_tid LIKE stxh-tdid,
           obj LIKE stxh-tdid.
    *& CUSTOM CONTROL DATA DECLARATIONS
    DATA: init,
          container1 TYPE REF TO cl_gui_custom_container,
          container2 TYPE REF TO cl_gui_custom_container,
          container3 TYPE REF TO cl_gui_custom_container,
          editor1    TYPE REF TO cl_gui_textedit,
          editor2    TYPE REF TO cl_gui_textedit,
          editor3    TYPE REF TO cl_gui_textedit.
    DATA: event_tab TYPE cntl_simple_events,
          event     TYPE cntl_simple_event.
    data declarations for save long text
    TYPES: BEGIN OF type_text ,
           line(65),
    END OF type_text.
    DATA:text_tab1 TYPE STANDARD TABLE OF type_text,
         text_tab2 TYPE STANDARD TABLE OF type_text,
         text_tab3 TYPE STANDARD TABLE OF type_text,
         texttab1 LIKE LINE OF text_tab1,
         texttab2 LIKE LINE OF text_tab1,
         texttab3 LIKE LINE OF text_tab1,
                line(256) TYPE c,
                field LIKE line,
                lsel LIKE sy-lisel,
                lsel1 LIKE sy-lisel,
                lin LIKE sy-lilli,
                val(50),
                val_c(50),
                val_scr(50),
                scr_val(50),
                val1(6),
                l_posnr LIKE vbap-posnr,
                l_posnr1 LIKE vbap-posnr,
                l_text1(30),
                l_vbeln LIKE vbap-vbeln.
    DATA: textlines LIKE tline-tdline OCCURS 0.
    DATA: ls_thead LIKE thead.
    DATA: lt_tline1 LIKE TABLE OF tline WITH HEADER LINE,
          lt_tline2 LIKE TABLE OF tline WITH HEADER LINE,
          lt_tline3 LIKE TABLE OF tline WITH HEADER LINE.
    DATA BEGIN OF header OCCURS 10.
            INCLUDE STRUCTURE thead.
    DATA END OF header.
    DATA: gcontrol  LIKE cfcontrol,
            l_subrc LIKE sy-subrc.
    DATA: BEGIN OF pc_tab OCCURS 10,
            line LIKE tline-tdline,
          END OF pc_tab.
    DATA: BEGIN OF pc_tab1 OCCURS 10,
            line LIKE tline-tdline,
          END OF pc_tab1.
    DATA: long_file(23) TYPE c.
    PARAMETERS : vbeln LIKE vbak-vbeln OBLIGATORY.
    SELECT-OPTIONS : posnr FOR vbap-posnr.
    INITIALIZATION.
      CLEAR : pc_tab.
      REFRESH pc_tab.
    START-OF-SELECTION.
      SELECT vbeln posnr
      FROM vbap
      INTO TABLE itab
      WHERE vbeln = vbeln
      AND   posnr IN posnr.
    LOOP AT itab.
       itab-text1 = 'Material sales text'.
       itab-text2 = 'Technical Specifications'.
       itab-text3 = 'Packing Note'.
       MODIFY itab TRANSPORTING text1 text2 text3.
    ENDLOOP.
    END-OF-SELECTION.
      WRITE: /5 'Header Level Text' COLOR 5.
      SKIP 3.
      WRITE:  /5 'General Remarks in Amendment',
              /5 'General Specifications',
              /5 'Instructions to Accounts ',
              /5 'Instructions to Product Engg',
              /5 'Instructions to Electrical ',
              /5 'Instructions to Service  ',
              /5 'Instructions to Despatch ',
              /5 'Instructions to Works ',
              /5 'Instructions to MMD      ',
              /5 'Instructions to OED ',
              /5 'Instructions to Project Markt',
              /5 'Painting Details ',
              /5 'Docs. Reqd. for Insp. Call ',
              /5 'Docs. to be sent with Invoice ',
              /5 'Spl action plan for SO Exec',
              /5 'Spl. Inst. for record keeping ',
              /5 'Customer Comm. Address ',
              /5 'Customer Supplied Products ',
              /5 'Cust. prods/traceability reqts ',
              /5 'Qualification Tests ',
              /5 'Instrument Calib. data to Cust ',
              /5 'Test Cert. reqd. for submisn ',
              /5 'Customer Inspection Stages  ',
              /5 'Un resolved points  ',
              /5 'Regret Reason ',
              /5 'Terms of payment ',
              /5 'Additional Commercial Terms ',
              /5 'Escalation',
              /5 'Mode of Despatch Details ',
              /5 'Packing Details ',
              /5 'QAP Details ',
              /5 'Approved Transporters ',
              /5 'Eye Catch ',
              /5 'LOI Details ',
              /5 'Delivery Details ',
              /5 'Order Description ',
              /5 'Penalty / LD Clause ',
              /5 'Activity Completion Schedule ',
              /5 'Inspection Details',
              /5 'Checked By ',
              /5 'Authorised By',
              /5 'Distribution',
              /5 'Send Original&Dupl. Inv. to',
              /5 'Send Copies of Inv.&Challan to ',
              /5 'Send R/R & L/R to',
              /5 'Bankers Name & Address',
              /5 'Sales Tax Details',
              /5 'Excise Duty Details',
              /5 'CST Number & Date',
              /5 'SST Number & Date',
              /5 'Bank Charges Details',
              /5 'Price Basis Details',
              /5 'Freight Details',
              /5 'Customer Collection Details',
              /5 'Road Permit Details',
              /5 'Insurance Details'.
      SKIP 5.
      WRITE: /25 'Item Level Text' COLOR 5.
      ULINE AT /24(20).
      SKIP 3.
      LOOP AT itab.
        WRITE: /5 itab-posnr.
        l_text1 = 'Technical Specifications'.
        WRITE  : 20 l_text1.
        CLEAR l_text1.
        l_text1 = 'Material sales text'.
        WRITE  : 50 l_text1.
        CLEAR l_text1.
        l_text1 = 'Packing Note'.
        WRITE  : 80 l_text1.
        HIDE : l_text1.
      ENDLOOP.
      CLEAR itab.
    AT LINE-SELECTION.
      CLEAR : lsel, lsel1.
      REFRESH text_tab2.
      lsel = sy-lisel.
      SHIFT lsel LEFT DELETING LEADING space.
      l_posnr = lsel+0(6).
      val1 = l_posnr.
    lin = sy-lilli.
    READ LINE lin FIELD VALUE itab-text1 .
      GET CURSOR FIELD l_text1 VALUE val.
      val_c = val.
      IF l_posnr IS NOT INITIAL.
        IF val = val1.
          MESSAGE s398(00) WITH 'Select a Item text'.
        ELSE.
          PERFORM itab_text.
          CALL SCREEN 0100.
        ENDIF.
      ELSEIF l_posnr IS INITIAL.
        PERFORM read_text.
        CALL SCREEN 0100.
      ENDIF.
    *&      Module  STATUS_0100  OUTPUT
          text
    MODULE status_0100 OUTPUT.
      SET PF-STATUS 'ZMENU'.
    SET TITLEBAR 'xxx'.
      IF l_posnr IS NOT INITIAL.
        CLEAR val_scr.
        CONCATENATE l_posnr '-' val INTO val_scr SEPARATED BY space.
        scr_val = val_scr.
      ELSE.
        scr_val = val.
      ENDIF.
      CLEAR :val_scr,l_posnr,val.
      INITIALIZING TEXT EDIT CUSTOM CONTROL
      IF init IS INITIAL.
        init = 'X'.
        CREATE OBJECT: container1 EXPORTING container_name = 'CUSTOM1',
                       editor1    EXPORTING parent = container1
    WORDWRAP SET SO THAT TEXT DOES NOT EXCEED THE INTERNAL TABLE FIELD
    *LENGTH.
    wordwrap_mode = cl_gui_textedit=>wordwrap_at_fixed_position
    wordwrap_mode = cl_gui_textedit=>wordwrap_at_windowborder
    wordwrap_position = '60'
    wordwrap_to_linebreak_mode = cl_gui_textedit=>true,
                       container2 EXPORTING container_name = 'CUSTOM2',
                       editor2    EXPORTING parent = container2
    wordwrap_mode = cl_gui_textedit=>wordwrap_at_fixed_position
    wordwrap_mode = cl_gui_textedit=>wordwrap_at_windowborder
    wordwrap_position = '60'
    wordwrap_to_linebreak_mode = cl_gui_textedit=>true.
        CALL METHOD editor1->set_text_as_r3table
          EXPORTING
            table = text_tab1.
        CALL METHOD editor2->set_text_as_r3table
          EXPORTING
            table = text_tab2.
        CALL METHOD editor1->delete_text.
        CALL METHOD editor2->delete_text.
    ELSE.
       CALL METHOD editor2->delete_text.
      ENDIF.
      CALL METHOD editor1->set_text_as_r3table
        EXPORTING
          table = text_tab1.
      CALL METHOD editor2->set_text_as_r3table
        EXPORTING
          table = text_tab2.
    ENDMODULE.                 " STATUS_0100  OUTPUT
    *&      Module  USER_COMMAND_0100  INPUT
          text
    MODULE user_command_0100 INPUT.
      CASE sy-ucomm.
        WHEN 'DOWNLOAD'.
          PERFORM header1.
          PERFORM header.
          PERFORM download ."changing COM_FILE LIKE LONG_FILE.
       WHEN 'SAVE'.
         PERFORM header1.
         PERFORM header.
        WHEN 'BACK' OR 'EXIT' OR 'CANCEL'.
          SET SCREEN 0.
      ENDCASE.
    ENDMODULE.                 " USER_COMMAND_0100  INPUT
    *&      Form  read_text1
          text
    -->  p1        text
    <--  p2        text
    FORM read_text1 USING   p_l_tid.
      CLEAR : lt_tline1.
      REFRESH text_tab1.
      l_tid = p_l_tid.
      name = vbeln.
      CALL FUNCTION 'READ_TEXT'
        EXPORTING
      CLIENT                        = SY-MANDT
          id                            = p_l_tid
          language                      = 'E'
          name                          = name
          object                        = 'VBBK'
      ARCHIVE_HANDLE                = 0
      LOCAL_CAT                     = ' '
    IMPORTING
      HEADER                        =
        TABLES
          lines                         =  lt_tline1
    EXCEPTIONS
       id                            = 1
       language                      = 2
       name                          = 3
       not_found                     = 4
       object                        = 5
       reference_check               = 6
       wrong_access_to_archive       = 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.
        EXIT.
      ENDIF.
      LOOP AT lt_tline1 .
       move-corresponding lt_tline1 to TEXT_tab1.
        APPEND lt_tline1-tdline TO text_tab1 .
       move '/' to lt_tline3-tdformat.
      ENDLOOP.
      REFRESH text_tab2.
    ENDFORM.                    " read_text1
    *&      Form  read_text
          text
    -->  p1        text
    <--  p2        text
    FORM read_text .
      CASE lsel.
        WHEN 'General Remarks in Amendment'.
          PERFORM read_text1 USING 'Z070'.
        WHEN 'General Specifications'.
          PERFORM read_text1 USING 'Z001'.
        WHEN 'Instructions to Accounts'.
          PERFORM read_text1 USING 'Z002'.
        WHEN 'Instructions to Product Engg'.
          PERFORM read_text1 USING 'Z003'.
        WHEN 'Instructions to Electrical'.
          PERFORM read_text1 USING 'Z004'.
        WHEN 'Instructions to Service'.
          PERFORM read_text1 USING 'Z005'.
        WHEN 'Instructions to Despatch'.
          PERFORM read_text1 USING 'Z006'.
        WHEN 'Instructions to Works'.
          PERFORM read_text1 USING 'Z007'.
        WHEN 'Instructions to MMD'.
          PERFORM read_text1 USING 'Z008'.
        WHEN 'Instructions to OED'.
          PERFORM read_text1 USING 'Z009'.
        WHEN 'Instructions to Project Markt'.
          PERFORM read_text1 USING 'Z037'.
        WHEN 'Painting Details'.
          PERFORM read_text1 USING 'Z010'.
        WHEN 'Docs. Reqd. for Insp. Call'.
          PERFORM read_text1 USING 'Z011'.
        WHEN 'Docs. to be sent with Invoice'.
          PERFORM read_text1 USING 'Z012'.
        WHEN 'Spl action plan for SO Exec'.
          PERFORM read_text1 USING 'Z013'.
        WHEN 'Spl. Inst. for record keeping'.
          PERFORM read_text1 USING 'Z014'.
        WHEN 'Customer Comm. Address'.
          PERFORM read_text1 USING 'Z015'.
        WHEN 'Customer Supplied Products'.
          PERFORM read_text1 USING 'Z016'.
        WHEN 'Cust. prods/traceability reqts'.
          PERFORM read_text1 USING 'Z017'.
        WHEN 'Qualification Tests'.
          PERFORM read_text1 USING 'Z018'.
        WHEN 'Instrument Calib. data to Cust'.
          PERFORM read_text1 USING 'Z019'.
        WHEN 'Test Cert. reqd. for submisn '.
          PERFORM read_text1 USING 'Z020'.
        WHEN 'Customer Inspection Stages '.
          PERFORM read_text1 USING 'Z021'.
        WHEN 'Un resolved points '.
          PERFORM read_text1 USING 'Z022'.
        WHEN 'Regret Reason '.
          PERFORM read_text1 USING 'Z023'.
        WHEN 'Terms of payment '.
          PERFORM read_text1 USING 'Z120'.
        WHEN 'Previous Sales Order '.
          PERFORM read_text1 USING 'Z040'.
        WHEN 'Escalation'.
          PERFORM read_text1 USING 'Z041'.
        WHEN 'Mode of Despatch Details '.
          PERFORM read_text1 USING 'Z042'.
        WHEN 'Packing Details '.
          PERFORM read_text1 USING 'Z043'.
        WHEN 'QAP Details '.
          PERFORM read_text1 USING 'Z044'.
        WHEN 'Approved Transporters  '.
          PERFORM read_text1 USING 'Z045'.
        WHEN 'Eye Catch  '.
          PERFORM read_text1 USING 'Z046'.
        WHEN 'LOI Details  '.
          PERFORM read_text1 USING 'Z047'.
        WHEN 'Delivery Details  '.
          PERFORM read_text1 USING 'Z048'.
        WHEN 'Order Description  '.
          PERFORM read_text1 USING 'Z049'.
        WHEN 'Penalty / LD Clause '.
          PERFORM read_text1 USING 'Z050'.
        WHEN 'Activity Completion Schedule  '.
          PERFORM read_text1 USING 'Z051'.
        WHEN 'Inspection Details '.
          PERFORM read_text1 USING 'Z052'.
        WHEN 'Checked By '.
          PERFORM read_text1 USING 'Z053'.
        WHEN 'Authorised By  '.
          PERFORM read_text1 USING 'Z054'.
        WHEN 'Distribution '.
          PERFORM read_text1 USING 'Z055'.
        WHEN 'Send Original&Dupl. Inv. to  '.
          PERFORM read_text1 USING 'Z056'.
        WHEN 'Send Copies of Inv.&Challan to '.
          PERFORM read_text1 USING 'Z057'.
        WHEN 'Send R/R & L/R to  '.
          PERFORM read_text1 USING 'Z058'.
        WHEN 'Bankers Name & Address  '.
          PERFORM read_text1 USING 'Z059'.
        WHEN 'Sales Tax Details  '.
          PERFORM read_text1 USING 'Z060'.
        WHEN 'Excise Duty Details  '.
          PERFORM read_text1 USING 'Z061'.
        WHEN 'CST Number & Date  '.
          PERFORM read_text1 USING 'Z062'.
        WHEN 'SST Number & Date  '.
          PERFORM read_text1 USING 'Z063'.
        WHEN 'Bank Charges Details '.
          PERFORM read_text1 USING 'Z064'.
        WHEN 'Price Basis Details '.
          PERFORM read_text1 USING 'Z065'.
        WHEN 'Freight Details  '.
          PERFORM read_text1 USING 'Z066'.
        WHEN 'Customer Collection Details  '.
          PERFORM read_text1 USING 'Z067'.
        WHEN 'Road Permit Details  '.
          PERFORM read_text1 USING 'Z068'.
        WHEN 'Insurance Details '.
          PERFORM read_text1 USING 'Z069'.
      ENDCASE.
    ENDFORM.                    " read_text
    *&      Form  itab_text
          text
    -->  p1        text
    <--  p2        text
    FORM itab_text .
    LOOP AT itab WHERE posnr = posnr.
       IF itab-posnr = lsel.
       CASE lsel.
         WHEN lsel.
      READ TABLE itab WITH KEY posnr = l_posnr.
      lsel1 = l_posnr.
      l_posnr1 = l_posnr.
      SHIFT lsel1 LEFT DELETING LEADING space.
      CONCATENATE itab-vbeln lsel1 INTO lsel1.
      CASE val.
        WHEN 'Material sales text'.
          PERFORM read_text2 USING '0001'.
        WHEN 'Technical Specifications'.
          PERFORM read_text2 USING 'Z001'.
        WHEN 'Packing Note'.
          PERFORM read_text2 USING 'Z005'.
      ENDCASE.
       ENDIF.
    ENDLOOP.
    ENDFORM.                    " itab_text
    *&      Form  read_text2
          text
         -->P_LSEL  text
    FORM read_text2 USING  p_lsel.
      CLEAR : lt_tline1.
      REFRESH text_tab1.
      CLEAR name.
      CLEAR obj.
    DATA : name LIKE stxh-tdname.
      name = lsel1.
      obj = p_lsel.
      CALL FUNCTION 'READ_TEXT'
        EXPORTING
      CLIENT                        = SY-MANDT
          id                            = p_lsel
          language                      = 'E'
          name                          = name
          object                        = 'VBBP'
      ARCHIVE_HANDLE                = 0
      LOCAL_CAT                     = ' '
    IMPORTING
      HEADER                        =
        TABLES
          lines                         =  lt_tline1
    EXCEPTIONS
       id                            = 1
       language                      = 2
       name                          = 3
       not_found                     = 4
       object                        = 5
       reference_check               = 6
       wrong_access_to_archive       = 7
       OTHERS                        = 8
      IF sy-subrc <> 0.
        CLEAR lsel1.
    MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
            WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
        EXIT.
      ENDIF.
      LOOP AT lt_tline1 .
       move-corresponding lt_tline1 to TEXT_tab1.
        APPEND lt_tline1-tdline TO text_tab1 .
       move '/' to lt_tline3-tdformat.
      ENDLOOP.
    ENDFORM.                    " read_text2
    *&      Form  save_text
          text
    -->  p1        text
    <--  p2        text
    FORM save_text1 ."USING p_l_tid.
      CALL METHOD editor2->get_text_as_r3table
        IMPORTING
          table = text_tab2.
      CLEAR lt_tline2.
      REFRESH lt_tline2.
      MOVE '*' TO lt_tline2-tdformat.
      LOOP AT text_tab2 INTO texttab2.
        MOVE texttab2 TO lt_tline2-tdline.
        APPEND lt_tline2.
        MOVE '/' TO lt_tline2-tdformat.
      ENDLOOP.
    HEADER-TDOBJECT = 'VBBK'.
    HEADER-TDNAME = p_l_tid.
    HEADER-TDID = 'ZTC1'.
    HEADER-TDSPRAS = 'EN'.
      CALL FUNCTION 'SAVE_TEXT'
        EXPORTING
      CLIENT                = SY-MANDT
          header                = header
      INSERT                = ' '
       savemode_direct       = 'X'
      OWNER_SPECIFIED       = ' '
      LOCAL_CAT             = ' '
    IMPORTING
      FUNCTION              =
       newheader             = ls_thead
    TABLES
          lines                 = lt_tline2.
    EXCEPTIONS
      ID                    = 1
      LANGUAGE              = 2
      NAME                  = 3
      OBJECT                = 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.
    ELSEIF sy-subrc  = 0.
       MESSAGE i398(00) WITH 'Text Saved'.
      ENDIF.
    ENDFORM.                    " save_text1
    *&      Form  header
          text
    -->  p1        text
    <--  p2        text
    FORM header .
      PERFORM save_text1 .
    ENDFORM.                    " header
    *&      Form  header1
          text
    -->  p1        text
    <--  p2        text
    FORM header1 .
      IF lsel1 IS NOT INITIAL.
        CLEAR header.
        REFRESH header.
        header-tdobject = 'VBBP'.
        header-tdname   = name.
        header-tdid     = obj.
        header-tdspras  = 'EN'.
        APPEND header.
      ELSEIF lsel1 IS INITIAL.
        CLEAR header.
        REFRESH header.
        header-tdobject = 'VBBK'.
        header-tdname = vbeln.
        header-tdid = l_tid.
        header-tdspras = 'EN'.
        APPEND header.
      ENDIF.
    ENDFORM.                                                    " header1
    *&      Form  download
          text
    -->  p1        text
    <--  p2        text
    FORM download ."CHANGING .
    DATA : dcp_file   LIKE long_file.
      DATA fullpath TYPE string.
      l_vbeln = vbeln.
      SHIFT l_vbeln LEFT DELETING LEADING '0'.
    concatenate 'C:\' l_vbeln '.txt' into   gcontrol-directory.
      CONCATENATE 'C:\' l_vbeln '.doc' INTO   fullpath.
    gcontrol-directory
      = 'C:\Text.txt'.
      = 'C:\Documents and Settings\Subhasis Mukherjee\Desktop\Text.txt'.
      CLEAR pc_tab.
      REFRESH pc_tab.
      IF l_posnr1 IS NOT INITIAL.
        CONCATENATE l_posnr1 '-' val_c INTO val_c SEPARATED BY space.
      ENDIF.
      pc_tab = val_c.
      APPEND pc_tab.
      pc_tab = 'Previous Text'.
      APPEND pc_tab.
         DO 2 TIMES.
      pc_tab = ''.
      APPEND pc_tab.
         ENDDO.
      LOOP AT text_tab1 INTO texttab1.
       IF sy-tabix = 1.
         IF l_posnr IS NOT INITIAL.
           CONCATENATE l_posnr '-' val INTO val SEPARATED BY space.
         ENDIF.
         pc_tab = val.
         APPEND pc_tab.
         pc_tab = 'Previous Text'.
         APPEND pc_tab.
         DO 2 TIMES.
         pc_tab = ''.
         APPEND pc_tab.
         ENDDO.
       ENDIF.
        pc_tab = texttab1-line.
        APPEND pc_tab.
       AT LAST.
         pc_tab = '***************************'.
         APPEND pc_tab.
       ENDAT.
      ENDLOOP.
      LOOP AT text_tab2 INTO texttab2.
        CLEAR pc_tab.
        IF sy-tabix = 1.
          DO 3 TIMES.
            pc_tab = ''.
            APPEND pc_tab.
          ENDDO.
          pc_tab = 'Changed Text'.
          APPEND pc_tab.
           DO 2 TIMES.
          pc_tab = ''.
          APPEND pc_tab.
           ENDDO.
        ENDIF.
        pc_tab = texttab2-line.
        APPEND pc_tab.
        AT LAST.
          pc_tab = '- - - - - - - - - - - - - - - - - - - - - - - - - - - '.
          APPEND pc_tab.
        ENDAT.
      ENDLOOP.
         CALL FUNCTION 'GUI_FILE_SAVE_DIALOG'
         EXPORTING
           window_title      = 'Path'
           default_extension = 'C:\'
           default_file_name = 'TEST.XLS'
         IMPORTING
           fullpath          = fullpath.
      CALL FUNCTION 'GUI_DOWNLOAD'
        EXPORTING
          filename                = fullpath
          filetype                = 'ASC'
          append                  = 'X'
        TABLES
          data_tab                = pc_tab
        EXCEPTIONS
          file_write_error        = 1
          no_batch                = 2
          gui_refuse_filetransfer = 3
          invalid_type            = 4
          no_authority            = 5
          unknown_error           = 6
          header_not_allowed      = 7
          separator_not_allowed   = 8
          filesize_not_allowed    = 9
          header_too_long         = 10
          dp_error_create         = 11
          dp_error_send           = 12
          dp_error_write          = 13
          unknown_dp_error        = 14
          access_denied           = 15
          dp_out_of_memory        = 16
          disk_full               = 17
          dp_timeout              = 18
          file_not_found          = 19
          dataprovider_exception  = 20
          control_flush_error     = 21
          OTHERS                  = 22.
      IF sy-subrc <> 0.
        MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
                WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
      ELSE.
        MESSAGE s001(00) WITH 'File downloaded successfully'.
      ENDIF.
    ENDFORM.                    " download
    Reward points pls if it is helpfull
    Regards
    Srimanta

  • Finding the file name with Regular Expression

    Hello All,
    I am having some requirment to find the file name for the input provided parameter.
    In my program i am having an input parameter for file name. This contains both the file name and file stored location.
    Example : C:\Dokumente und Einstellungen\xs234fs\Desktop\TEST_123_44.txt
    From the above example string i need to find only the file name that is TEST_123_44.txt by using Regular expression.
    Please let me know how to get this.
    Thank you ver much in advance.
    Thanks,
    Feroz.

    Hello,
    If you have attached an F4 help to the filename input param, in that you can use the FM: GUI_FILE_SAVE_DIALOG.
    In this there is a return param FILENAME which contains the name of the file.
    AT SELECTION-SCREEN ON VALUE-REQUEST FOR P_FILE.
          CALL FUNCTION 'GUI_FILE_SAVE_DIALOG'
           EXPORTING
             window_title            = TEXT-001
             default_extension       = p_extens
             default_file_name       = ls_deffile
             initial_directory       = ls_initdet
           IMPORTING
             filename                = ls_filename "This contains the filemame
             path                    = ls_path
             fullpath                = ls_fullpath
             user_action             = ls_usaction.
    Else if you have hardcoded the filename in the input field you can use rthe FM: PC_SPLIT_COMPLETE_FILENAME to split the filenames into different components
    BR,
    Suhas
    Edited by: Suhas Saha on Mar 6, 2009 9:31 AM

  • Download report into excel sheet

    Hi
    I have  requirement like, in report output I want a button, if I press that button it has to ask where I have to save that output list in excel sheet format.
    Plz help me out
    Thanks in advance
    Regards
    Rao

    Pls do like...
    START-OF-SELECTION.
    * Select and Process the data .
      PERFORM select_and_process_data.
    * Display Records.
      PERFORM display_result.
    * Set the pf-status and user command.
      SET PF-STATUS '110_VAL'.   " create yr button here
    AT USER-COMMAND.
    * Download result to spreadsheet.
      PERFORM download_to_spreadsheet.
    END-OF-SELECTION
    FORM download_to_spreadsheet .
      DATA:
        l_filefilter  TYPE string,
        l_filename    TYPE string,
        l_path        TYPE string,
        l_fullpath    TYPE string,
        l_user_action TYPE i.
      IF sy-ucomm = 'DLOAD'.  " Button name (Function code)
        l_filefilter = 'EXCEL Files (*.XLS)|*.XLS|Text Files (*.TXT)|*.TXT|All files (*.*)|*.*||'.
        CALL FUNCTION 'GUI_FILE_SAVE_DIALOG'
          EXPORTING
            file_filter       = l_filefilter
            default_extension = 'xls'
          IMPORTING
            filename          = l_filename
            path              = l_path
            fullpath          = l_fullpath
            user_action       = l_user_action.
        IF l_user_action = 1 OR l_user_action = 0.
          CALL FUNCTION 'GUI_DOWNLOAD'
            EXPORTING
              filename                = l_fullpath
              filetype                = 'ASC'
            TABLES
              data_tab                = o_file
            EXCEPTIONS
              file_write_error        = 1
              no_batch                = 2
              gui_refuse_filetransfer = 3
              invalid_type            = 4
              no_authority            = 5
              unknown_error           = 6
              header_not_allowed      = 7
              separator_not_allowed   = 8
              filesize_not_allowed    = 9
              header_too_long         = 10
              dp_error_create         = 11
              dp_error_send           = 12
              dp_error_write          = 13
              unknown_dp_error        = 14
              access_denied           = 15
              dp_out_of_memory        = 16
              disk_full               = 17
              dp_timeout              = 18
              file_not_found          = 19
              dataprovider_exception  = 20
              control_flush_error     = 21
              OTHERS                  = 22.
          IF sy-subrc <> 0.
            MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
                    WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
          ENDIF.
        ELSEIF l_user_action = 2.
          CALL FUNCTION 'GUI_DOWNLOAD'
            EXPORTING
              append                  = 'X'
              filename                = l_fullpath
              filetype                = 'ASC'
              trunc_trailing_blanks   = 'X'
            TABLES
              data_tab                = o_file
            EXCEPTIONS
              file_write_error        = 1
              no_batch                = 2
              gui_refuse_filetransfer = 3
              invalid_type            = 4
              no_authority            = 5
              unknown_error           = 6
              header_not_allowed      = 7
              separator_not_allowed   = 8
              filesize_not_allowed    = 9
              header_too_long         = 10
              dp_error_create         = 11
              dp_error_send           = 12
              dp_error_write          = 13
              unknown_dp_error        = 14
              access_denied           = 15
              dp_out_of_memory        = 16
              disk_full               = 17
              dp_timeout              = 18
              file_not_found          = 19
              dataprovider_exception  = 20
              control_flush_error     = 21
              OTHERS                  = 22.
          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.
      ENDIF.
    ENDFORM.                    " download_to_spreadsheet
    " Note : Give the path according yr requirement.
    Regards,
    RH

  • Download to Excel sheet

    Hi Experts,
                    I am downloading internal table data to excel sheet using
    FM 'SAP_CONVERT_TO_XLS_FORMAT', i want also the column headings to be printed in excel sheet. I am able to get data into excel sheet but not the headers. can any one help me out regarding this.
    Thanks in Advance.
    Regards,
    Krishna

    hi,
    even using GUI_DOWNLOAD ,u can include fieldnames in ur exel sheet
    The following are the long text for the parameter FIELDNAMES of GUI_DOWNLOAD.
    FU GUI_DOWNLOAD                   FIELDNAMES
    Short Text
    Field Names for the 'DBF' File Type
    Description
    Optional table with column names for the individual columns.
    'DBF': The column names are entered into the structure definition of the DBF file.
    'DAT':  An additional row with the column names is inserted at the beginning of the table.
    Function Module
    GUI_DOWNLOAD
    chk this program
    data : Begin of t_header occurs 0,
           name(30) type c,
           end of t_header.
    data : Begin of itab occurs 0,
           fld1 type char10,
           fld2 type char10,
           fld3 type char10,
           end   of itab.
    DATA: v_pass_path TYPE string.
    append itab.
    itab-fld1 = 'Hi'.
    itab-fld2 = 'hello'.
    itab-fld3 = 'welcome'.
    append itab.
    append itab.
    append itab.
    append itab.
    append itab.
    t_header-name = 'Field1'.
    append t_header.
    t_header-name = 'Field2'.
    append t_header.
    t_header-name = 'Field3'.
    append t_header.
      CALL FUNCTION 'GUI_FILE_SAVE_DIALOG'
        EXPORTING
          default_extension     = 'XLS'
        IMPORTING
          fullpath              = v_pass_path.
      CALL FUNCTION 'GUI_DOWNLOAD'
        EXPORTING
          filename                        = v_pass_path
          filetype                        = 'DBF'
        TABLES
          data_tab                        = itab
          FIELDNAMES                      = t_header
    Edited by: SivaKumar on Jul 5, 2008 10:07 AM

Maybe you are looking for

  • Ipod wont turn off

    Was very happy with the Ipod Touch until a recent problem occurred. Appreciate any assistance. The Ipod Touch will not turn off - If I leave it for the designated 1 min till sleep occurs it continuously attempts to turn itself back on displaying the

  • Desktop uploader urgent problems

    am io wrong or is the adobe cc desktop app allow you to upload files from your desktop?? i just had a very very frustrating conversation with an adobe rep over chat, are these people seriously considered professionals???... https://sales.liveperson.n

  • Flex: Are unused module project files included in the module swf's?

    Hi Currently optimizing a large application at work. There are many files in  some of the module projects that are not used by the exported (release  build) Module.swf's. Are these unused files included in the swf's? What about unused imports? Brian

  • Casting objects with reflection possible?

    I have this code: String className = "com.xyz.MeasurementUnit"; Class provider = Class.forName(className + "Provider"); Object object = context.getContractProxy(provider);The last line returns an object of type object. I must execute the method getIs

  • Drag and relate filter on AP Invoices not showing post dates past Dec2010

    Hello experts, Using the following version: 2007A (8.00.178) SP:00, PL:44 The customer is getting the following issue. In drag and relate bringing up AP Invoices, the latest AP invoice is for 21/01/2011. When the customer tries to filter by posting d