RFC to Download table Contents

Hi  All,
I am looking for an RFC function module  through which I can select all the contents of a given table and subsequently download the table contents  to a flat file.
Regards
Martin

Hi Martin,
Try This:
Get the data for Userid(l_user) & password(l_pwd) & host string(l_host).
DATA: l_slen TYPE i,
l_error,
l_pwd(30) TYPE c.
CONSTANTS: c_dest TYPE rfcdes-rfcdest VALUE 'SAPFTP',
c_key TYPE i VALUE 26101957.
connect to ftp server
l_slen = STRLEN( l_pwd ).
CALL FUNCTION 'HTTP_SCRAMBLE'
EXPORTING
SOURCE = l_pwd
sourcelen = l_slen
key = c_key
IMPORTING
destination = l_pwd.
CALL FUNCTION 'SAPGUI_PROGRESS_INDICATOR'
EXPORTING
text = 'Connect to FTP Server'.
To Connect to the Server using FTP
CALL FUNCTION 'FTP_CONNECT'
EXPORTING
user = l_user
password = l_pwd
host = l_host
rfc_destination = c_dest
IMPORTING
handle = w_hdl
EXCEPTIONS
OTHERS = 1.
IF sy-subrc <> 0.
MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ENDIF.
Get the path to which the data file needs to be moved (w_outfile).
PERFORM download_to_ftp TABLES it_coacode USING w_outfile.
FORM download_to_ftp TABLES it_tab
USING l_string TYPE char64.
CALL FUNCTION 'FTP_R3_TO_SERVER'
EXPORTING
handle = w_hdl
fname = l_string
character_mode = 'X'
TABLES
text = it_tab[]
EXCEPTIONS
tcpip_error = 1
command_error = 2
data_error = 3
OTHERS = 4.
IF sy-subrc <> 0.
MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4
RAISING invalid_output_file.
ENDIF.
ENDFORM. " download_to_ftp
Asvhen

Similar Messages

  • Program to upload and download table content

    Hi,
    I need to create a program which should upload and download table content from PC and to PC.
    How can i develop this program..Should i use BDC or any function module?
    Ezhil.

    The 2 program requested.....
    Program to Download
    REPORT ztable_download.
    PARAMETERS: table LIKE dd02d-tabname,
                                file(50) LOWER CASE.
    DATA: code(72) OCCURS 10,
                w_code(72),
                prog(8),
                msg(120),
                lin(3),
                wrd(10),
                off(3).
    DATA: BEGIN OF rectest,
          tprec(1) VALUE '0',
          nometab(16),
          utente(20),
          data(10),
          ora(8),
    END OF rectest.
    DATA: BEGIN OF recdett,
          tprec(1) VALUE '1',
          tab LIKE table,
    END OF recdett.
    DATA: BEGIN OF rectot,
        tprec(1) VALUE '2',
        tot(9),
    END OF rectot.
    OPEN DATASET file FOR OUTPUT IN TEXT MODE.
    rectest-nometab = table.
    rectest-utente = sy-uname.
    rectest-data = sy-datum.
    rectest-ora = sy-uzeit.
    TRANSFER rectest TO file.
    APPEND 'PROGRAM SUBPOOL.'  TO code.
    CONCATENATE 'TABLES ' table '.' INTO w_code SEPARATED BY space.
    APPEND w_code TO code.
    APPEND 'FORM DYN1 USING FILE.' TO code.
    CONCATENATE 'SELECT * FROM ' table '.'
    INTO w_code SEPARATED BY space.
    APPEND w_code TO code.
    CONCATENATE 'TRANSFER ' table ' TO FILE.'
    INTO w_code SEPARATED BY space.
    APPEND w_code TO code.
    APPEND 'ENDSELECT.' TO code.
    APPEND 'ENDFORM.' TO code.
    GENERATE SUBROUTINE POOL code NAME prog
    MESSAGE msg LINE lin WORD wrd OFFSET off.
    IF sy-subrc <> 0.
       WRITE: / 'Error during generation in line', lin,
                    / msg,
                    / 'Word:', wrd, 'at offset', off.
    ELSE.
       PERFORM dyn1 IN PROGRAM (prog) USING file.
       WRITE: / 'Esportati ',sy-dbcnt,' records.'.
    ENDIF.
    Program to upload
    REPORT Ztable_upload.
    PARAMETERS: FILE(50) lower case,
                               TEST AS CHECKBOX.
    DATA: CODE(72) OCCURS 10,
                W_CODE(72),
                PROG(8),
                MSG(120),
                LIN(3),
                WRD(10),
                OFF(3).
    DATA: BEGIN OF RECTEST,
          TPREC(1) VALUE '0',
          NOMETAB(16),
          UTENTE(20),
          DATA TYPE D,
          ORA TYPE T,
    END OF RECTEST.
    DATA: BEGIN OF RECTOT,
          TPREC(1) VALUE '2',
          TOT(9),
    END OF RECTOT.
    OPEN DATASET FILE FOR INPUT IN TEXT MODE.
    READ DATASET FILE INTO RECTEST.
    WRITE:/ 'Tabella..:',RECTEST-NOMETAB.
    WRITE:/ 'Utente...:',RECTEST-UTENTE.
    WRITE:/ 'Data.....:',RECTEST-DATA,RECTEST-ORA.
    IF TEST = 'X'.
        APPEND 'PROGRAM SUBPOOL.'  TO CODE.
       CONCATENATE 'TABLES ' RECTEST-NOMETAB '.'
       INTO W_CODE SEPARATED BY SPACE.
      APPEND W_CODE TO CODE.
      APPEND 'FORM DYN1 USING FILE.' TO CODE.
      APPEND 'DATA W_COUNT TYPE P.' TO CODE.
      CONCATENATE 'SELECT * FROM' RECTEST-NOMETAB '.'
      INTO W_CODE SEPARATED BY SPACE.
      APPEND W_CODE TO CODE.
      CONCATENATE 'DELETE' RECTEST-NOMETAB '.'
      INTO W_CODE SEPARATED BY SPACE.
      APPEND W_CODE TO CODE.
      APPEND 'ENDSELECT.' TO CODE.
      APPEND ' DO.' TO CODE.
      CONCATENATE 'READ DATASET FILE INTO' RECTEST-NOMETAB '.'
      INTO W_CODE SEPARATED BY SPACE.
      APPEND W_CODE TO CODE.
      APPEND ' IF SY-SUBRC NE 0.' TO CODE.
      APPEND ' EXIT.' TO CODE.
      APPEND ' ENDIF.' TO CODE.
      CONCATENATE ' INSERT ' RECTEST-NOMETAB '.'
      INTO W_CODE SEPARATED BY SPACE.
      APPEND W_CODE TO CODE.
      APPEND 'ADD 1 TO W_COUNT.' TO CODE.
      APPEND 'ENDDO.' TO CODE.
      APPEND ' write: / ''Importati'' ,W_COUNT, ''records''.' TO CODE.
      APPEND 'ENDFORM.' TO CODE.
      GENERATE SUBROUTINE POOL CODE NAME PROG
      MESSAGE MSG LINE LIN WORD WRD OFFSET OFF.
      IF SY-SUBRC <> 0.
         WRITE: / 'Error during generation in line', LIN,
         / MSG,
         / 'Word:', WRD, 'at offset', OFF.
      ELSE.
         PERFORM DYN1 IN PROGRAM (PROG) USING FILE.
      ENDIF.
    ENDIF.
    Edited by: robcom69 on Feb 23, 2010 2:35 PM

  • Download table contents

    Hi All,
    How do i download a table contents i tried se16 with which maximum we can download is of 96 coumns
    How do i download complete table contents including field names like MARA.
    Thanks
    Martin.

    Hi Thanks for ur reply.
    I tried this using se16. I tried using se16N suggested by
    Rich Heilman the maximum i can download is only 96 fields i mean columns in the oputput list.
    The actual output list has 170 fixed columns. how do i download all of them with data?
    Is there any way to download all of the 170 columns.
    Thanks
    Martin

  • Download table content into CSV format in background

    Hi,
    I would like to download some 50 tables data content locally into csv file format. As the number of tables are quite more, I am planning to run this in background. GUI_DOWNLOAD doesnt help me here. Can you plz suggest how can I go ahead to download files then.
    I am using the FM 'SAP_CONVERT_TO_CSV_FORMAT' for converting the internal table to csv format. Suggest me if there is any other way.
    Your suggestions would be very valuable.
    Thank you in advance.

    go through this  link...
    Re: how to create a CSV file

  • Upload and download tables  from sap

    hi!
    i need to download tables from sap 46c in order to upload them again in anther sap system.
    is it possible lie doing with programs?
    regards
    yifat

    hi, about download table content, you can using this one, RFC_READ_TABLE.
    It's a RFC FM, so you can call it from your target SAP system, with a available RFC destination already built.
    After call it, do modify TABLE in target system.
    By the way, I think if you really need to copy data to onther SAP system, you can try client copy, or transportation.
    thanks

  • Downloading blob content from a custom table

    In our hosted Apex application, the following code from the Application Express Developer's Guide works great for allowing a user to download blob content from one of our custom tables via a download button. However, the code doesn't work on the Oracle Cloud because the "owa_util" package is no longer available. The code is as follows:
    CREATE OR REPLACE PROCEDURE download_my_file(p_file in number) AS
    v_mime VARCHAR2(48);
    v_length NUMBER;
    v_file_name VARCHAR2(2000);
    Lob_loc BLOB;
    BEGIN
    SELECT MIME_TYPE, BLOB_CONTENT, name,DBMS_LOB.GETLENGTH(blob_content)
    INTO v_mime,lob_loc,v_file_name,v_length
    FROM file_subjects
    WHERE id = p_file;
    -- set up HTTP header
    -- use an NVL around the mime type and
    -- if it is a null set it to application/octect
    -- application/octect may launch a download window from windows
    owa_util.mime_header( nvl(v_mime,'application/octet'), FALSE );
    -- set the size so the browser knows how much to download
    htp.p('Content-length: ' || v_length);
    -- the filename will be used by the browser if the users does a save as
    htp.p('Content-Disposition: attachment; filename="'||replace(replace(substr(v_file_name,instr(v_file_name,'/')+1),chr(10),null),chr(13),null)|| '"');
    -- close the headers
    owa_util.http_header_close;
    -- download the BLOB
    wpg_docload.download_file( Lob_loc );
    end download_my_file;
    Besides using web services, does anyone know of a way to do this? Is there a way to add access to the "owa_util" package in the cloud? I have also tried apex_util.get_blob_file_src but that is also unavailable in the Oracle Cloud.
    Thanks,
    Steve

    Following Joel's advice:
    The way I solved this was to split the code between two page processes and one application process. The download button first calls a page process to move the report data into a blob column and then calls another page process which is of "run application process" type. This calls the application level process where the download code, shown below, is called.
    Notice the following changes to the code from the one posted earlier (also from Joel)
    1) added sys.htp.init;
    2) "sys." to all htp, owa and wpg_docload calls
    3) added apex_application.stop_apex_engine; after the wpg_docload statement at the bottom of the script.
    Now the download button launches a "save as" dialog box and the report content is downloaded to the client.
    The code now looks like:
    CREATE OR REPLACE PROCEDURE download_my_file(p_file in number) AS
    v_mime VARCHAR2(48);
    v_length NUMBER;
    v_file_name VARCHAR2(2000);
    Lob_loc BLOB;
    BEGIN
    SELECT MIME_TYPE, BLOB_CONTENT, name,DBMS_LOB.GETLENGTH(blob_content)
    INTO v_mime,lob_loc,v_file_name,v_length
    FROM oehr_file_subject
    WHERE id = p_file;
    -- set up HTTP header
    -- use an NVL around the mime type and
    -- if it is a null set it to application/octect
    -- application/octect may launch a download window from windows
    sys.htp.init;
    sys.owa_util.mime_header( nvl(v_mime,'application/octet'), FALSE );
    -- set the size so the browser knows how much to download
    sys.htp.p('Content-length: ' || v_length);
    -- the filename will be used by the browser if the users does a save as
    sys. htp.p('Content-Disposition: attachment; filename="'||replace(replace(substr(v_file_name,instr(v_file_name,'/')+1),chr(10),null),chr(13),null)|| '"');
    -- close the headers
    sys.owa_util.http_header_close;
    -- download the BLOB
    sys.wpg_docload.download_file( Lob_loc );
    apex_application.stop_apex_engine;
    end download_my_file;
    Thanks Joel for your help.
    Steve

  • BSEG table contents download

    Hi,
    My requirement is to download the contents of the BSEG table for a given company code, account type. We have huge data in BSEG table and when I tried to use SE16 for just one month, it is getting timed out. Is there any way to acheive this? Like executing in background or something. It is OK if it is downloaded to application server.
    Thanks in advance.
    Kishore

    One way to do this is to use you date selection criteria and select data from BKPF first. There are indexes for posting date and document date. So that will go releatively quickly. Then use the document numbers and other keyfields to go directly to BSEG to get the data.
    I had a similar requirement a couple of years ago and this is how I did it.
    You can download to either application or presentation server. It's up to you.
    Rob

  • Read RFC output table contents using com.sap.mw.jco.* API

    Hi,
    I have a requirement where I need to call an RFC in JSPDynpage component.
    In doInitialization method, I wrote following code: -
    IPortalComponentRequest request = (IPortalComponentRequest) this.getRequest();
    IPortalComponentContext myContext = request.getComponentContext();
    IPortalComponentProfile myProfile = myContext.getProfile();
    String sapSystem = myProfile.getProperty("SystemIdentifier");
    ISystemLandscapeWrapper landscapeWrapper = (ISystemLandscapeWrapper) UMFactory.getSystemLandscapeWrappers().get(0);
    ISystemLandscapeObject systemLandscapeObject = landscapeWrapper.getSystemByAlias(sapSystem);
    IJCOClientService clientService = (IJCOClientService) PortalRuntime.getRuntimeResources().getService(JCO_CLIENT);
    request.getNode().putValue(LOCALE_NODE_KEY,     Locale.ENGLISH);
    IJCOClientPoolEntry poolEntry = clientService.getJCOClientPoolEntry(sapSystem,request);
    JCO.Client client = poolEntry.getJCOClient();
    client.connect();
    IRepository repository = JCO.createRepository("repository", client);
    IFunctionTemplate functionTemplate = repository.getFunctionTemplate(Z_BAPI_EMP_GBU_GET);
    JCO.Function function = new JCO.Function(functionTemplate);
    JCO.ParameterList importList = function.getImportParameterList();
    importList.setValue("US", "OBJTYP");
    importList.setValue(request.getUser().getUniqueName(), "USRID");
    client.execute(function);
    Now, this RFC returns two tables.
    I want to know how do I read a table and iterate over its contents to read all fields.
    (Till now, I only used getString("GBU") method that just reads an export type of String parameter)
    Please help.
    Thanks & Regards,
    Amey

    Amey,
    If I understood the problem correctly. A snippet will be something like
                   JCO.Table itemList = function.getTableParameterList().getTable("QUALIFICATION");
                   Vector qualItems = new Vector();
                   QualItemBean qualItem;
                   for (int i = 0; i < itemList.getNumRows(); i++) {
                        itemList.setRow(i);
                        qualItem = new QualItemBean();
                        qualItem.setQual(itemList.getString("TBJID").trim());
                        qualItem.setQualText(itemList.getString("TTEXT").trim());
                        qualItem.setVBDate(itemList.getString("VBEGD").trim());
                        qualItem.setSBDate(itemList.getString("SBEGD").trim());
                        qualItem.setSEDate(itemList.getString("SENDD").trim());
                        qualItem.setVEDate(itemList.getString("VENDD").trim());
                        qualItem.setProfText(itemList.getString("PROFC_TEXT").trim());
                        qualItems.add(qualItem);
                   qualBean.setQual(qualItems);
    Ofcourse you need to change the variable names based on your scenario.
    Thanks
    Prashant

  • Download database table content into internal table using Function Module?

    HI,
    Experts,
    I need a function module which can download ddic table content into internal table.
    Thank u ,
    Shabeer Ahmed.

    >
    shabeer ahmed wrote:
    > HI,
    > Experts,
    >
    > I need a function module which can download ddic table content into internal table.
    >
    > Thank u ,
    > Shabeer Ahmed.
    Hi Shabeer,
      We don't require a function module to download ddic table content to an internal table. We can use the SELECT statement for the same. Example would be:-
    DATA: <INTERNAL TABLE> type table of <DATABASE>.
    SELECT * FROM <DATABASE> into corresponding fields of <INTERNAL TABLE>.
    Also, function module might be required when you need the data from a remote system, but then it is the developer's task create this function module and the function module should be remote enabled function module.
    This remote enable function module should have the above SELECT query as its code.
    Many Regards,
    Ravi.

  • Asynch RFC Sender to File Receiver Szenario (table content)

    Hi,
    I have the following szenario: RFC(R/3) => XI => File
    At the moment I implemented the following:
    1. Z-Report in R/3 calls a function module:
         CALL FUNCTION 'Z_RFC_TO_XML'
            IN BACKGROUND TASK
            DESTINATION xi_dest
            EXPORTING
              it_table = it_table.
          COMMIT WORK.
    2. The RFC Sender Adapter on XI takes the RFC data and convert it to RFC-XML
    3. There is a message mapping from RFC-XML to XML-Structure
    4. The File Receiver Adapter write the XML document to the file system
    The scenario is working without error and the file is created. But on R/3 side the it_table is filled with 20 rows before the function module Z_RFC_TO_XML is called. But on xi side I only receive one row (the header line).
    Is it possible to transmit the whole table content to xi and not only one row? And if yes, how can I do this?
    Thanks,
    manuku

    Hi Tobias,
    Currently am doing this scenarioa RFC to file
    CALL FUNCTION 'Z_RFC_TO_XML'
    >         IN BACKGROUND TASK
    >         DESTINATION xi_dest
    >         EXPORTING
                p_werks = 'Plant no'
               TABLES
    >           it_table = it_table.
    >       COMMIT WORK.
    But here am using Exporting and Tables parameter.. When i debug this FM, the debugger is not going to the FM.
    Can you help me in solving this issue....
    Thanks and Regards,
    Vijay vikram

  • Mat. for Initial Download: Table not supported by function "C_"

    Hi All,
    We are in SRM 5.0 & ECC 6.0 with Classic scenario. While uploading the MATERIAL through R3AS, we have the "Mat. for Initial Download: Table not supported by function C_" & "No product ID determined for material number ... of logical system" error in SMW01.
    In SMQ2 in SRM, Queue is blocked with "Error in Mapping (Details: transaction SMW01)"
    For your information RFC Users at both the ends have SAP_ALL authorisation. SAP Notes 720819, 420980 & 432339 are implemented.
    Please guide me to resolve this issue.
    Regards
    Ashutosh

    hi,
    How was the issue resolved , i am having the same problem.
    can somebody provide with clue
    regards

  • How to print table contents?

    hi @,
    I am having a view which is dsiplaying data fetched from the R/3 through Adaptive RFC in a table. This table need to have a print functionality to print on the client.
    How to do this I am not having any function / UI to do this.
    Any help.
    Regards

    Hi,
    Try This:
    When the user click on Print button, launch a new window as below:
    public void onActionPrint(com.sap.xyz.webdynpro.progmodel.api.IWDCustomEvent wdEvent )
        //@@begin onActionPrint(ServerEvent)
              StringBuffer strB = new StringBuffer("/webdynpro/dispatcher/xyz.com/(component name space) ab~xyz~testprint/(application name)PrintTestApp");
              IWDWindow window = wdComponentAPI.getWindowManager().createNonModalExternalWindow(strB.toString(), "Print");
              window.show();
        //@@end
    The above code helps to launch a new window with your Web Dynpro application. The application is sepecific to print functionality.
    ThePrintTest App should have the content with format what exactly you would like to print. (Users use the browser standard print functionality to print the table content).
    This is a kind of work around and as of NW 7.0 there is no standard print functionality available in Web Dynpro.
    Thanks
    Krishna

  • Read SAP table content through VBA  why  Chinese characters display as '#'

    Hi ,
    I meet a problem . I want to get sap table content through RFC in excel  VBA. now  i have solve it . It can got table content . when  i change a new  system , it can get table content ,but chinese characters display as '#' ( it works well in sap 4.6c Chinese characters can display , when upgrate to ecc 6.0 it can't works well )
    some VBA code as below :
    Set ofun = CreateObject("SAP.FUNCTIONS")  ' create a FUNCTION object
       '  Connect  has create and conneted to SAP system
    Set ofun.Connection = Connect                     ' "connect"has create connetion sucess
    Set func = ofun.Add("RFC_READ_TABLE")    ' set RFC object to call function
        func.Exports("QUERY_TABLE") = "T179T"   ' set table name for get table content
        func.Tables("OPTIONS").DATA = "SPRAS   =   'ZH'"    ' set condition of language of  'ZH'
    If func.Call = True Then
            Set oline = func.Tables.Item("DATA")       ' set table content which get from table T179T to object "oline"
    endif
    who can give me some suggestion about this ?  Thanks .
    Edited by: Chris Xu on Oct 31, 2008 6:51 AM

    Hi Chirs,
    I am facing the same problem but i am using c sharp and this is a windows application.
    I tried to change the CodePage attribute by simply setting connection.codepage = "8040";
    But i get an exception.
    attempted to read or write protected memory.
    I cant seem to change this. What should i do. Also do we have to set this at the point of connecting to the Sap system or when i'm calling the RFC. I tried both instances but none worked. Could you please help me out.
    i am using VS 2008.
    Thanks,
    Yohan

  • How to downlaod the complete table contents

    Hi,
    I have got one Z table which has got around 108 columns/field ...now I need to download the contents/data of the table in a spreadsheet with all the fields and also need to download the fields of the table in the other spreadsheet.
    so can you please guide me how can I do this.
    Thanks,
    Rajeev

    hi All.
    I have tried the following code but it didn't transfer anything to the file and it displays the following message:
    0 bytes transmitted, code page 1160
    DATA: it_data LIKE ztable_data OCCURS 0 WITH HEADER LINE.
    DATA: v_fullpath TYPE string,
          v_length TYPE i.
    SELECT * INTO TABLE  it_data
    FROM ztmztable_data  .
    CALL FUNCTION 'GUI_DOWNLOAD'
      EXPORTING
      BIN_FILESIZE                    =
        filename                        =  v_fullpath
        filetype                        = 'DAT'
      APPEND                          = ' '
      WRITE_FIELD_SEPARATOR           = ' '
      HEADER                          = '00'
      TRUNC_TRAILING_BLANKS           = ' '
      WRITE_LF                        = 'X'
      COL_SELECT                      = ' '
      COL_SELECT_MASK                 = ' '
      DAT_MODE                        = ' '
      CONFIRM_OVERWRITE               = ' '
      NO_AUTH_CHECK                   = ' '
      CODEPAGE                        = ' '
      IGNORE_CERR                     = ABAP_TRUE
      REPLACEMENT                     = '#'
      WRITE_BOM                       = ' '
      TRUNC_TRAILING_BLANKS_EOL       = 'X'
      WK1_N_FORMAT                    = ' '
      WK1_N_SIZE                      = ' '
      WK1_T_FORMAT                    = ' '
      WK1_T_SIZE                      = ' '
    IMPORTING
       filelength                      = v_length
      TABLES
        data_tab                        = it_data.

  • Dynamic inmternal table content O/P in BGD ?

    Dear All,
    I've content in my dynamic Internal Table.
    When I'm trying to print the values of that table on the List the output is not proper .
    The problem is not with the values but the alignment of each of the column.
    It's giving some absurd output alignment. (But the data is correct )
    But the same is working fine on the grid.
    But when I'm trying to execute in the BGD and then see the spool output then there is a problem in the alignment .
    So, my Qn is how to resolve this alignment problem ?
    I've a problem even from the Grid.
    The ouput is correct when I see it on the grid.
    But, when I download the content onto the XL then the same problem is coming as of the above scenario.
    Hope I'm clear in explaining my problem !
    Thnaks & regards,
    Deepu.k

    Actually I passed the Table name to the fieldcatalog.
    My internal table is a Dynamic Int. Table and so I've passed the table name for the static fields and for the dynamic fields I dint pass the Table name
    Now, when I removed the table name for the static fields also tehn it's working fine.
    Thanks,
    Deepu.K

Maybe you are looking for