Contvert CSV to SAP and SAP to CSV

Hi Experts,
I have two independent system. One is R/3 and other one is a file server.
My need is to take the csv file from file server and do some process store in R/3 and generate csv file from R/3 and store it in the file server.
The communication is two way communication.
Without using Xi interface i need to do this. If there is any solution possible with ABAP(Function Modules)  is most welcome.

Hi,
CSV means a text file, where the columns are separated by a character ";".
The best way to change a list to CSV is to create an internal table in the ABAP, with the structure of the required CSV.
You have to fill in this internal table.
Because you are running the program in background, you can't download the file, the best would be to store the file on the server in a separated directory.
1ST capture file from application server to internal table using open dataset and close data set.
Use the Function Module SAP_CONVERT_TO_CSV_FORMAT to convert the internal table into Comma separated format then download this internal table using the Function Module GUI_DOWNLOAD.
EX-
Coding -
TYPE-POOLS: truxs.
TYPES:
BEGIN OF ty_Line,
vbeln LIKE vbap-vbeln,
posnr LIKE vbap-posnr,
END OF ty_Line.
TYPES: ty_Lines TYPE STANDARD TABLE of ty_Line WITH DEFAULT KEY.
DATA: itab TYPE ty_Lines.
DATA: itab1 TYPE truxs_t_text_data.
SELECT
vbeln
posnr
UP TO 10 ROWS
FROM vbap
INTO TABLE itab.
CALL FUNCTION 'SAP_CONVERT_TO_CSV_FORMAT'
EXPORTING
i_field_seperator = ';'
TABLES
i_tab_sap_data = itab
CHANGING
i_tab_converted_data = itab1
EXCEPTIONS
conversion_failed = 1
OTHERS = 2.
IF sy-subrc 0.
MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ENDIF.
CALL FUNCTION 'GUI_DOWNLOAD'
EXPORTING
filename = 'C:\TEMP\test.txt'
TABLES
data_tab = itab1
EXCEPTIONS
OTHERS = 1.
Check this sample code...for CSV to SAP
codeREPORT ZTEST.
TYPE-POOLS:TRUXS.
DATA: BEGIN OF ITAB OCCURS 0,
VBELN LIKE VBAP-VBELN,
POSNR LIKE VBAP-POSNR,
END OF ITAB.
data: itabt like itab occurs 0 with header line.
DATA: ITAB1 TYPE TRUXS_T_TEXT_DATA,
ITAB2 TYPE TRUXS_T_TEXT_DATA.
SELECT VBELN
POSNR
UP TO 100 ROWS
FROM VBAP
INTO TABLE ITAB.
CALL FUNCTION 'SAP_CONVERT_TO_CSV_FORMAT'
EXPORTING
I_FIELD_SEPERATOR = ','
TABLES
I_TAB_SAP_DATA = ITAB
CHANGING
I_TAB_CONVERTED_DATA = ITAB1
EXCEPTIONS
CONVERSION_FAILED = 1
OTHERS = 2.
IF SY-SUBRC 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
CALL FUNCTION 'GUI_DOWNLOAD'
EXPORTING
FILENAME = 'C:\TEMP\test.txt'
TABLES
DATA_TAB = ITAB1
EXCEPTIONS
OTHERS = 1.
CALL FUNCTION 'TEXT_CONVERT_CSV_TO_SAP'
EXPORTING
I_FIELD_SEPERATOR = ','
I_TAB_RAW_DATA = ITAB1
I_FILENAME = 'C:\TEMP\test.txt'
TABLES
I_TAB_CONVERTED_DATA = ITABt
EXCEPTIONS
CONVERSION_FAILED = 1
OTHERS = 2
IF SY-SUBRC 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.[/code]

Similar Messages

  • How to import a csv file and read  in sap ui5?

    Hi,
    I want to import a file and read it contents to bind it to table.How to do it?
    Thanks in advance.

    I tried to do this all from within the application but found it easier to just start with a JSON file. But, you can use a JS library to convert your CSV into JSON from within the application like this one:
    archan937/csonv.js · GitHub
    I just converted my CSV to JSON. Once you have that, all you need to do is instantiate a model for it and bind to table.
      onInit: function () {
        var oModel = new sap.ui.model.json.JSONModel("PATH TO YOUR JSON FILE");
        this.getView().setModel(oModel);
      <Table id="idProductsTable"
        inset="false"
        items="{
          path: '/ProductCollection',
          sorter: {
            path: 'Name'
        }">
    The UI5 demo kit is a good resource. I believe it'll be same/similar for SAPUI5:
    OpenUI5 SDK - Demo Kit
    See here for example of defining your model and binding to a table:
    sap.m Explored

  • How can i update an existing item in sap using CSV file?

    Hi,
    i am trying to update an existing Item in SAP using a CSV file.
    in the message log i get an error message that the item already exists.
    what should i do in order to update the existing record?
    Thanks, Udi

    Hi..........
    I would sugest you to use Tab delimited file and choose proper option in order to update the itsm master in DTW......
    Regards,
    Rahul

  • Transfering .csv file from SAP to NON-SAP using FTP connection

    Dear All,
    I am able to place the .CSV file successfully to other system using FTP connection, but when i open the file I could see the gaps between each record. I mean 1st line with the 1st record and 2nd line having a GAP and 3rd line with the 2nd record and so ..on as shown below
    1     1/1/2009     0     41000027
    2     1/1/2009     0     41000027
    3     1/1/2009     0     41000027
    I have declared an internal table as below
    TYPES: BEGIN OF ty_charlist,
             line(5000) type c,
           END OF ty_charlist.
    DATA:  w_charlist TYPE ty_charlist,
                 t_charlist TYPE TABLE OF ty_charlist.
    And concatenating each field seperated by ','
    CONCATENATE  res1 res2 res3 res4 res5 res6 res7 res8 res9 res10 res11 res12 res13 res14 res15 res16 res17 res18 res19  res20 res21 res22 res23 res24 res25 res26 res27 res28 res29 res30 res31 res32 res33 res34 res35 res36 res37 res38 res39
    INTO w_charlist-line SEPARATED BY ','.
    APPEND w_charlist TO t_charlist.
    Now T_CHARLIST contains 50 records which needs to be placed on other system. I can see 50 records but gap is coming
    Here res1, res2 and so on are declared as TYPE STRING..
    Please do help me this issue
    Thanks
    Prava

    Hello dprava ,
    Try to be assisted with these examples .
    1. [http://wiki.sdn.sap.com/wiki/display/ABAP/FTPfiletransferinBackground]
    2. [Reg: FTP Connection; - SAP examples programs
    Thank you,
    Boaz

  • SAP PI CSV to Proxy Structure

    Hi All,
    I have scenario wherein I will be getting data from external PI system to my PI system through XI adapter so at external PI end receiver adapter will be XI adapter and at my end sender adapter will be XI adapter.
    Now through XI adapter i will be getting CSV data in single field which i have to update in my SAP. For this I flow would be as follow
    External PI to MY PI , my PI to my SAP ECC.
    Since data coming through XI adapter would be in single field and of CSV format, I will have to convert this data into a structure say ABC having 30 odd fields. I have made inbound and outbound interface for same. Now once i have xml structure i will like to map this xml structure to my proxy structure which will hit my SAP ECC. Now the issue I am facing is there are 2 scenarios now 1st  Converting CSV data to XML structure using Java/ABAP mapping and second is XML structure mapping to proxy structure. Both these interfaces are independent of each other. Whereas I want that once I have got CSV data field it should be converted into xml and then proxy structure.
    Please suggest how this could be achieved? Also if i will use ABAP mapping can i call second outbound interface inside it?

    Hello,
    Both these interfaces are independent of each other. Whereas I want that once I have got CSV data field it should be converted into xml and then proxy structure.
    I'm not sure if I get your question correctly. You can actually link these two in your operation mapping:
    1. Specify the csv structure as your Source Interface
    2. Specify the proxy structure as your Target Interface
    3. Use two mappings in this order: Java/ABAP Mapping, then normal message mapping. Take note that in your operation mapping ,you can add additional mappings by clicking the add icon.
    Hope this helps,
    Mark

  • Loading records from .csv file to SAP table via SAP Program

    Hi,
    I have a .csv file with 132,869 records and I am trying to load it to an SAP table with a customized SAP program.
    After executing the program, only 99,999 records are being loaded into the table.
    Is there some setting to define how many records can be loaded into a table? Or what else could be the problem?
    Pls advice.
    Thanks!!!

    hi Arun ,
    A datasource need a extract structure to fetch data .It is nothing but a temp table to hold data.
    First you need to create atable in SE11 with fields coming from CSV file.
    Then you need to write a report program to read you CSV file and populate your table in BW .
    Then you can create a datasource on top of this table .
    After that replicate and load data at PSA and use to upper flow.
    Regards,
    Jaya Tiwari

  • How to update Records of SAP table from .CSV file

    Hi,
    I have written a code which takes a data from (,) delimited CSV file and adds it into the Internal table.
    Now I want to update the all fields in SAP table with the Internal table.
    I want to use Update statement.
    Update <table Name> SET <field needs to update> WHERE connditon.
    I don't want to iterate through thousand on record in sap table to check the where condition.
    Could you please tell me how to do it.

    Hi. I thing you will not workaround the iterating of the internal table.
    You can pre-load all the records into another internal table
    check lt_csv[] is not initial. " important, otherwise next select would read all records of the table
    select .... into lt_dbitab for all entries in lt_csv where key-fieds = lt_csv-key_fields...
    check sy-subrc eq 0 and lt_dbitab[] is not initial.
    then do in-memory update of the it_dbitab
    loop at it_dbitab assign <fs>.
      read table lt_csv assign <fs_csv> with key ... " lt_csv should be sorted table with key, or you should try to use binary search
      if sy-subrc eq 0.
        ...change required lt_dbitab fields: <fs>-comp = <fs_csv>-comp...
      endif.
    endloop.
    ant then you can do mass-update
    update dbtab from table lt_dbitab.
    From performance view, this solution should be much faster than iterating lt_csv directly and updating every single database record
    Br
    Bohuslav

  • Creating DataSources for File Source Systems in csv format in sap bw 7.0

    Hi,
    Please explain how to Create DataSources for File Source Systems in csv format in sap bw 7.0. WITH SCREENSHOTS
    Thanks
    JINI
    Edited by: Jini  Jayan on Jun 11, 2008 11:36 AM

    Step 1. Select Source systems under Modelling in the left panel. In the right panel, right-click Source systems and select Createu2026.
    Step 2. Select the FileSystem, manual meta data, data using file inte option, and then click  to continue.
    Step 3. Enter a name and a description for the source system, and then click  to create the source system.
    Now create an application component
    Step 1. Select InfoSources under Modelling in the left panel. In the right panel, right-click InfoSources and select Create application componentu2026.
    Step 2. Enter a name and a description for the application component, and then click  to continue. (BW automatically adds a prefix of "Z" to the technical names of application components, unlike the naming system used for other BW objects.If u give the name as AC_DEMO it will be saved as ZAC_DEMO in the system.
    Now create infosource
    Step 1.Select InfoSources under Modelling in the left panel. Right-click the newly created Application Component , and then select Create InfoSourceu2026.
    Step 2. Select the option Master data/texts/hierarchies, and then click  to continue.
    Step 3. Enter your infoobject name, and then click  to continue.
    Now you will be asked
    Infosource(name) assigned to Appln component(name)?
    Click continue
    Now go back to workbench and see the Infoobject listed under the Application component name (under Infosource)
    Right click the infoobject name and select Assign Datasource
    Enter the Infoobject name as Infosource name and the source system name and continue
    Now you ll get datasource assignment confirmations for Infosource_ATTR and Infosource_TEXT for master data and text.
    Click yes and continue
    Now you ll be taken to the Infosource(master data) change screen
    Source system name will be given
    Below that u need to give the datasource name u2026.._ATTR
    Click Activate.
    Now Click the tab transfer rules
    Copy the communication str infoobject names to an excel sheet
    For ex if your infoobj are IO_MATNUM and IO_MATNAME (material number and material name) copy and paste as
    IO_MATNUM      IO_MATNAME
    MAT001     TEA
    MAT002     COFFEE
    MAT003     SUGAR
    GIVE YOUR DATA IN THE EXCEL. AND CLICK File Save As CSV(comma delimited) and save to ur system. Give file name as something like infosourcename_ATTR.csv
    Now back to the Infosourcechange screen
    Source system name will be given
    Below that u need to give the datasource name u2026.._TEXT
    And activate
    Now Click the tab transfer rules
    Copy the communication str infoobject names to an excel sheet
    GIVE YOUR DATA IN THE EXCEL. AND CLICK File Save As CSV(comma delimited) and save to ur system. Give file name as something like infosourcename_TEXT.csv
    Now create Infoobject to load data
    Go to Infosourceu2014Appln Componentu2014InfoObju2014SourceSystemu2014rightclick->create Infopackage
    Step 2. Select the DataSource Material number (Master data), enter a description for the InfoPackage, and then click  to continue.
    Give infopackage description as Infopackage:InfoObj_ATTR
    Now take care to select the first item in datasource and click continue
    In the next screen click external data tab
    Click client workstation
    Datafileu2026.file name (browse to give the file u saved in ur system)
    There will be an option to remove header data from file.remove 1 row.
    File typeu2014csv file
    Now click schedule tabu2014start dataload immediatelyu2014start.
    In the same way
    Go to Infosourceu2014Appln Componentu2014InfoObju2014SourceSystemu2014rightclick->create Infopackage
    Step 2. Select the DataSource Material number (text)enter a description for the InfoPackage, and then click  to continue.
    Give infopackage description as Infopackage:InfoObj_TEXT
    Now take care to select the second  item in datasource and click continue
    In the next screen click external data tab
    Click client workstation
    Datafileu2026.file name (browse to give the file u saved in ur system)
    There will be an option to remove header data from file.remove 1 row.
    File typeu2014csv file
    Now click schedule tabu2014start dataload immediatelyu2014start.
    Click the icon below admn workbench to go to monitor and check the load
    Or you go back to Infosourceu2014Appln Componentu2014InfoObju2014right clickmaintain master data
    Click execute
    You can see the data load
    Hope this helps!!!

  • How to SAP data convert into csv file.

    hi,
    i have a one internal table , and i want to extract SAP data into csv file with filed separator ','(comma).
    Thanks

    you can use this coding for slove yours issue
    tables: vbak.
    Use type pool:
    TYPE-POOLS: TRUXS.
    parameters: p_erdat like vbak-erdat.
    DATA: COM TYPE C . For comma SEPERATOR
    data: begin of itab occurs 0,
          vbeln like vbak-vbeln,
          erdat like vbak-erdat,
          end of itab.
    DATA: ITAB1 TYPE TRUXS_T_TEXT_DATA OCCURS 0 .
    COM = ','.
    select vbeln
           erdat
           into table itab
           from vbak
           where erdat = p_erdat.
    FM:
    CALL FUNCTION 'SAP_CONVERT_TO_CSV_FORMAT'
    EXPORTING
       I_FIELD_SEPERATOR          = COM
      I_LINE_HEADER              =
      I_FILENAME                 =
      I_APPL_KEEP                = ' '
      TABLES
        I_TAB_SAP_DATA             =  ITAB
    CHANGING
       I_TAB_CONVERTED_DATA       = ITAB1
    EXCEPTIONS
      CONVERSION_FAILED          = 1
      OTHERS                     = 2
    IF SY-SUBRC <> 0.
    MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
            WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
    ENDIF.
    FM:
    CALL FUNCTION 'GUI_DOWNLOAD'
      EXPORTING
      BIN_FILESIZE                  =
        FILENAME                      = 'C:\TEST.CSV'
       FILETYPE                       = 'ASC'

  • CSV to SAP then bach again to CSV to compare

    Hi Guys,
    I have a CSV file to be uploaded to a SAP database tables...
    and after the upload, I need to gather those data back again from SAP DB table into a CSV format to recheck if the data entered into the SAP DB table is correct...
    Is it possible? Please let me know your thoughts on this,,,
    If this is possible, please let me know how am I going to achieve this...
    Thanks so much...
    Rgds,
    Mark

    hi Mark,
    yes, it is possible.
    you can WS_UPLOAD and WS_DOWNLOAD to upload and download your data.
    upon upload, you can use
    SPLIT wa_itab BY ',' INTO wa_table-field1                                                                            wa_table- field2 wa_table-field3.
    regards,
    Peter

  • How to create success factors csv directory path in sap ?

    Dear Gurus,
    I want to make a directory path for success factors csv exporting in sap. what should i do ? where can i start ? where can i make this directory path like "SFactors" , "E:\SFactors" ?
    Best Regards

    Hi Kemal,
    Is it working right now ? What should i do for RFC user ? Customer talks about rfc user and authorization to folder ? How can i associate with RFC dialog user ? Should i create rfc user ?
    Yes you can now view the contents of the folder SFactors using your ID.
    I can't comment much on the RFC users as I have no clue on your integration scenario. You may refer an example of integration using PI in the link below
    SAP HCM and SuccessFactors BizX Integration Using SAP PI
    If your scenario is as below
    Create a CSV file from SAP and Successfactors can do FTP to the SAP server and pull the file.
    Sol: You need to create a ftpuser on successfactors . Write a script in SAP server to connect to successfactor server using ftpuser. Copy the files from SAP server to Successfactor using ftp commands. No RFC user required here.
    Hope this helps.
    Regards,
    Deepak Kori

  • Can we send .csv file from sap srm system to sap pi?

    Hi Experts,
    we have 3 options send the data from sap systems to sap pi.i. e.proxy,idoc and rfc only
    How can we send .csv file from sap srm to sap pi?
    Regards,
    Anjan

    Anjan
    As you know SAP SRM and SAP PI are different boxes.
    *_Option 1:_*
    we need a shared AL11 directory in between SAP SRM and SAP PI (Ask basis to setup shared folder). Place / Populate the file in the folder from SAP SRM and then it can be picked through sender file communication channel.
    In this case you (Basis team) will share one folder which is visible from the AL11 transaction of both the systems (SRM and PI). You will drop .csv file using some report or program from SRM at this location and from PI you can read that file using File communication channel (NFS mode).
    Option 2:
    Setup a FTP at SRM environment and expose some folder which can be accessible from PI. Use sender file communication channel at PI end to pick the file.
    You can use this option incase sharing of folder is not possible (due to network / other constrains). Here FTP server is required to expose any folder as FTP so as it can be accessible from internet (remote location). You need to expose some folder at SRM machine.  You will drop .csv file using some report or program from SRM at this location. Now PI can fetch the file from that location using  sender file communication channel (FTP Mode) providing user credentials.
    Hope it clears now.
    Regards
    Raj

  • Format non-sap files to CSV

    Hi,
    I have this issue and would want your suggestions. we are pulling data from a non-sap system. We are using MS Access to retrieve the tables from the non-sap system. We then have to gro through and manually format the tables into attribute and text CSV files by pciking and choosing the table fields form the MS Access database. This is extremely tedious. What are other options for me to do this efficiently?
    Thanks,
    RT

    Hi RT,
    Yes you can load it via ETL. If it is a SAP certified ETL tool for e.g. Informatica then you can have a add-in in BW side known as SAP CONNECT and ETL can directly talk to your BW system via RFC. But if you don't have a SAP CONNECT in BW system then you need to interact via file interface. There will be definitely a high performance issues when you are interchanging big volume files between ETL and BW. Why don't you considering DB CONNECT ? Got feeling says that it would be much faster than ETL extraction.
    If you are going for ETL interface then you might need to consider few design issues: -
    1) How BW system should now when to extract the file or the file has reached the application server in BW ?
    2) How to ensure that the file delivered by ETL is complete?
    3) Data reconciliation may be required.
    Hope it helps.
    Thx,
    Soumya

  • Automated way to update PIR records in SAP via an uploadable CSV file

    HI,
      Can we get in place an automated way to update PIR records in SAP via an uploadabel CSV file. Right now we have to manually update PIRs by going into ME12 and updating the pricing and PIR timing manually.If anyone hassuggestions of how to go about it please do pool in here. Do we have BAPI related to this ?
    Thanks,
    Sindhu.

    I woudl suggest you check ORDERS05 IDOC type (ORDCHG message type).
    FM - idoc_input_ordchg

  • Issues when sending mail from sap to outlook in .csv FORMAT

    hI all,
    Im using 'SO_NEW_DOCUMENT_ATT_SEND_API1'
    FM TO send a mail from SAP to user with attachment in .csv format but the data isnot getting displayed correctly ...
    I thnk it is competely displayed in ASCII format ..
    Can anybody give me suggestionson the same
    thanks

    Hi.
    How is the user opening the .csv attachment?
    I'm guessing that it should be opened with Excel.
    Are you using an attachment document type of 'XLS'?
    If not, then the attachment won't be opened with Excel unless the user right-clicks on it and does 'Open with'.
    Even then, the user will have to use the Excel import wizard.
    Is a .csv file what you want?
    You can use the ABAP OLE stuff to write a native Excel file that can be attached to an email.
    Or you can (at the cost of more work) write the Excel file (still type XLS) using XML, which gives you more control, and still works when your program is run in the background.
    John

Maybe you are looking for

  • IPhoto uses 100% CPU and crashes after some time even when idle

    Hi I need some help with iPhoto. It consistently crashes after running for sometime even if left idle over night. Following advice from the community, I've done the following so far: Repaired Permissions Fix Library Rebuild Library Disable All email

  • LabVIEW DSC Logging too Many Data Points for Integer Tags

    Hi, I am having a strange problem with LabVIEW 2013 SP1 DSC data logging, running on XP SP3. All the integer Data Type Tags in my Tag Database that are set to data log, are logging way too much data. When I look at the amount of logged data points fo

  • Redirecting XSLT output to multiple files

    Hi, I am trying to redirect the output of the XSLT into multiple files using <xsl:variable name="filename" select="concat(@id,'.xml')" /> <redirect:write select="$filename"> </redirect:write>I dont want to hard-code the directory of the $filename in

  • Extracting payloads from Dehydration Store

    Is it possible to write SQL against the dehydration store to extract the payloads being received into a process? A quick look at the database appears to show they are stored as BLOB. Pete

  • The technical name of 5GHz has high priority in dual band AP

    Hi, As I know, when open dual radio on some Cisco's AP, and configure one dual wireless client associate with the AP, the AP will use 5GHz for wireless client to associate first. Does somebody know this technical or function name? I'm looking for the