Function module to read Comma Seperated File (CSV)

Hi,
Is there any Function module to read CSV file from presentation server or Application server?
Regards,
Madhu

Hi madhukeshwar,
1. Exactly for this purpose,
i have developed an independent FORM
where we give inputs
a) file name (eg. abcd.txt)
b) separator (eg , COMMA in your case)
c) internal table (eg. t001)
2. It will provide the data
in proper format
(no matter what the separator)
(it can work with any kind of separator)
3. just copy paste in new program.
REPORT abc.
change your table declaration and file name
DATA : t001 LIKE TABLE OF t001 WITH HEADER LINE.
PERFORM myupload TABLES t001 USING 'd:\t001.txt' ','.
BREAK-POINT.
in debug see t001
INDEPENDENT FORM
FORM myupload TABLES orgtab
USING filename separator.
Data
DATA : BEGIN OF itab OCCURS 0,
myline(1000) TYPE c,
END OF itab.
DATA : extension(5) TYPE c.
DATA : name(100) TYPE c.
DATA : newfilename TYPE string.
Step 1
CALL FUNCTION 'GUI_UPLOAD'
EXPORTING
filename = filename
TABLES
data_tab = itab.
Step 2
LOOP AT itab.
REPLACE ALL OCCURRENCES OF separator IN itab-myline WITH
cl_abap_char_utilities=>horizontal_tab.
MODIFY itab.
ENDLOOP.
Step 3
DATA : path LIKE pcfile-path.
path = filename.
CALL FUNCTION 'PC_SPLIT_COMPLETE_FILENAME'
EXPORTING
complete_filename = path
CHECK_DOS_FORMAT =
IMPORTING
DRIVE =
extension = extension
name = name
NAME_WITH_EXT =
PATH =
EXCEPTIONS
invalid_drive = 1
invalid_extension = 2
invalid_name = 3
invalid_path = 4
OTHERS = 5
Step 4
newfilename = filename.
REPLACE name IN newfilename WITH 'temp'.
CALL FUNCTION 'GUI_DOWNLOAD'
EXPORTING
BIN_FILESIZE =
filename = newfilename
TABLES
data_tab = itab
FIELDNAMES =
Step 5
CALL FUNCTION 'GUI_UPLOAD'
EXPORTING
filename = newfilename
has_field_separator = 'X'
TABLES
data_tab = orgtab.
ENDFORM. "myupload
3.
regards,
amit m.

Similar Messages

  • Function Module To read all the Files in a Given UNIX directory.

    Can anyone provide me with a FUNCTION MODULE which reads all the files available in a UNIX directory?
    I have the UNIX directory given. I need to find all the files available in that particular Directory so that I can choose and process accordingly. Probably I can store all files in an Internal Table.
    Thanks in advance.
    Sunil

    Hi Nick,
    Thankyou very much for the response.
    The Function Module /SAPDMC/LSM_F4_SERVER_FILE is interactive wherein we can select only one file.
    But my requirement is I need to collect (probably in an internal table) all the files exixting in the given UNIX directory.
    Can you please find in that direction. I would be very grateful.
    Thanks.
    Sunil

  • Function module to read xml file

    Hi
    Can anyone help me with using function module to read the xml file into SAP. Any ideas! Any help!
    Thanks

    Found a note, but not very helpful
    Note 877328 - SE37: Error when generating the test frame

  • Send mail as comma seperated file from abap

    Hi,
    i need to send mail from my program...as a comma seperated file...can u help me out.
    regards
    shankar

    See function module SO_NEW_DOCUMENT_ATT_SEND_API1, there is an example in the documentation. The example is for a .BMP file but you should be able to use the similar code for a text file (you might need to use object RAW). The content of comma-separated file must be in an internal table when you'll call this function module.
    There are also lots of examples available all over the Internet, use search by FM name.

  • 9iJSP Report output to a comma seperated file

    Hi,
    Is it possible to create a comma seperated file with output data from a 9iJSP report. If yes, can anyone tell me how ??
    thanks in advance
    Unmesh

    Hello Unmesh,
    If your JSP report has a paper layout, then you can use Reports Builder or the client/servlet/runtime executables to generate the paper layout to CSV formatted output with the DESFORMAT=DELIMITEDDATA and DELIMITER=, command-line options. If you have only a web layout , it will generate its output only in HTML format.
    You can add a paper/web layout to your JSP report, if it already doesn't have one, by opening it in Reports Builder, and inserting a report block in the paper layout view/web source view. This JSP report can then be used both to generate to CSV format using rwservlet, and to the web when deployed as a JSP.
    Thanks,
    The Oracle Reports Team.

  • Comma Seperated Files

    I am trying to read in data from a .CSV file.
    The CSV file contains a list of questions and answers in the
    format;
    Question, option1, option2,option3,option4, correct answer
    My problem is that I can get the whole line into an array but
    I can't find a way of getting each element of the comma seperated
    file into a multi dimensioned array.
    I need to be able to use MyArray[1,1] is equal to
    Question and MyArray[1,2] is equal to
    option1 etc etc
    Hope this makes sense
    Paul

    In your routine you have two loops.
    Either one will work on thier own but as soon i nest them
    then it just stops working........
    The below data is stored as a Data.csv file (Obviously it
    contains a lot more these are the first 3 records.) **Can't count =
    4 records lol)
    ,,B,,,,Lorry,,,,,X,,,,,CC5001 ,Mark one answer,,under 7.5
    tonnes maximum authorised mass,over 7.5 tonnes maximum authorised
    mass,over 7.5 metres overall height,under 7.5 metres overall
    height,,,1111,This sign means no entry for goods
    vehicles,TS4619.eps,CC5001.gif ,Vehicle Weights and Dimensions
    ,,B,,,,Lorry,,,,,X,,,,,CC5002 ,Mark one answer,,either the
    left-hand or middle lane,only the left-hand lane,only the middle
    lane,any of the lanes,,,1111,Your lorry is over 7.5 tonnes maximum
    authorised mass. This sign means you may use,TS4545.eps,CC5002.gif
    ,Vehicle Weights and Dimensions
    ,,C,,,,Lorry,,,,,,X,,,,CC5003,Mark one answer,,30 mph,40
    mph,50 mph,60 mph,,,1111,You are driving a lorry with a maximum
    authorised mass of 7 tonnes. What is the maximum speed limit on a
    single carriageway?,,,Vehicle Weights and Dimensions
    ,,B,,,,Lorry,,,,,X,,,,,CC5004,Mark one answer,,30 mph,40
    mph,50 mph,60 mph,,,1111,What is the national speed limit on a
    single carriageway road for a rigid lorry weighing more than 7.5
    tonnes maximum authorised mass?,,,Vehicle Weights and
    Dimensions

  • Generate an Upload the current table to a comma seperated file

    Hi Freaks,
    i want to generate a comma seperated file from the current table (which was modified in the current Apex Window) and also upload the file to a file server.
    What is the best practice?
    Thanks a lot
    Wolle

    Hello Wolle,
    In the APEX SQL Workshop -> Object browser, when you select a table, and select the Data tab. There's a link at the bottom of the table, "Download". This will automatically generate a csv file for you.
    Alternatively you can use a client like toad or sql developer to generate a csv.
    Greetings,
    Rutger
    http://rutgerderuiter.blogspot.com/
    ===============================================================================
    You can reward this reply by marking it as either Helpful or Correct ;-)

  • Function module to read the directory list and also run in background

    Hi All,
    I need to read few files from a folder in the server and upload the data in the file using a BDC. This process has to happen in the background as I am going to schedule the program. I had used the function module "EPS_GET_DIRECTORY_LISTING" to list the file names, it is working properly but when I schedule the program this function module does not work, the jobs gets finished in 0 secs. I am suspecting that it is not running in back ground. Can any one suggest me the function module which runs in background to read the files or an alternate method.
    Ajeetha

    Thanks for the reply.
    Sorry, this function module is working properly, why I assumed it is not working is that the background job got completed in 0 secs which made me feel that the function module is not working. Also I am subsequently copying the file to another folder and deleting it from the source folder, actually thiese two functionalities are not working in background. which added to my conclusion that all the function modules are not working in background. I am using two methods to copy and delete files, they are
    CL_GUI_FRONTEND_SERVICES=>FILE_COPY,
    CL_GUI_FRONTEND_SERVICES=>FILE_DELETE.
    as these are not working in background, now I need to replace them with a method or function module which will run in background.
    As I have mentioned earlier, my main objective is to upload the data in the file using a bdc. If I am not able to delete the file in the source folder,  then duplicate upload will happen which I have to avoid. So, if someone could help me to find a way to delete the file will be of great help to me.
    Ajeetha

  • Is there any inbuilt function to split a comma seperated text

    Dear Friends,
    Is there any inbuilt function to split a comma seperated text for inserting the values thus split in to a table.
    Text Ex: Mango, Orange, Pinapple, Jack Fruit
    Output: Mango
    Orange
    Pineapple
    Jack Fruit
    Thanking you,
    With regards,
    Franklin

    Using DBMS_UTILITY.COMMA_TO_TABLE:--
    DECLARE
    l_tab dbms_utility.uncl_array;
    l_tablen number;
    BEGIN
    dbms_utility.comma_to_table('A,B,C', l_tablen, l_tab);
    dbms_output.put_line('TABLE LENGTH : '|| l_tablen);
    dbms_output.put_line('TABLE COUNT : '|| l_tab.COUNT);
    for i in 1..l_tablen
    loop
    dbms_output.put_line(l_tab(i));
    end loop;
    END;
    source --google.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   

  • How to make comma seperated file

    hi
    I have a select statement that looks like below. I want to make comma seperated file for the selected columns. How to write it?
    SELECT MM.DAL_NUMBER,
    '19-NOV-2009' as WSS_CE,
    CPN_INT,
    TRADE_DATE,
    MX_DATE "LAST_DATE",
    CUSTOMER_SPECIF CUST_GID,
    NAME_SHORT CUST_NAME_SHORT
    from my_table;
    if you could provide me with exact query.
    Thanks

    Slightly more generic approach...
    As sys user:
    CREATE OR REPLACE DIRECTORY TEST_DIR AS '\tmp\myfiles'
    GRANT READ, WRITE ON DIRECTORY TEST_DIR TO myuser
    /As myuser:
    CREATE OR REPLACE PROCEDURE run_query(p_sql IN VARCHAR2
                                         ,p_dir IN VARCHAR2
                                         ,p_header_file IN VARCHAR2
                                         ,p_data_file IN VARCHAR2 := NULL) IS
      v_finaltxt  VARCHAR2(4000);
      v_v_val     VARCHAR2(4000);
      v_n_val     NUMBER;
      v_d_val     DATE;
      v_ret       NUMBER;
      c           NUMBER;
      d           NUMBER;
      col_cnt     INTEGER;
      f           BOOLEAN;
      rec_tab     DBMS_SQL.DESC_TAB;
      col_num     NUMBER;
      v_fh        UTL_FILE.FILE_TYPE;
      v_samefile  BOOLEAN := (NVL(p_data_file,p_header_file) = p_header_file);
    BEGIN
      c := DBMS_SQL.OPEN_CURSOR;
      DBMS_SQL.PARSE(c, p_sql, DBMS_SQL.NATIVE);
      d := DBMS_SQL.EXECUTE(c);
      DBMS_SQL.DESCRIBE_COLUMNS(c, col_cnt, rec_tab);
      FOR j in 1..col_cnt
      LOOP
        CASE rec_tab(j).col_type
          WHEN 1 THEN DBMS_SQL.DEFINE_COLUMN(c,j,v_v_val,2000);
          WHEN 2 THEN DBMS_SQL.DEFINE_COLUMN(c,j,v_n_val);
          WHEN 12 THEN DBMS_SQL.DEFINE_COLUMN(c,j,v_d_val);
        ELSE
          DBMS_SQL.DEFINE_COLUMN(c,j,v_v_val,2000);
        END CASE;
      END LOOP;
      -- This part outputs the HEADER
      v_fh := UTL_FILE.FOPEN(upper(p_dir),p_header_file,'w',32767);
      FOR j in 1..col_cnt
      LOOP
        v_finaltxt := ltrim(v_finaltxt||','||lower(rec_tab(j).col_name),',');
      END LOOP;
      --  DBMS_OUTPUT.PUT_LINE(v_finaltxt);
      UTL_FILE.PUT_LINE(v_fh, v_finaltxt);
      IF NOT v_samefile THEN
        UTL_FILE.FCLOSE(v_fh);
      END IF;
      -- This part outputs the DATA
      IF NOT v_samefile THEN
        v_fh := UTL_FILE.FOPEN(upper(p_dir),p_data_file,'w',32767);
      END IF;
      LOOP
        v_ret := DBMS_SQL.FETCH_ROWS(c);
        EXIT WHEN v_ret = 0;
        v_finaltxt := NULL;
        FOR j in 1..col_cnt
        LOOP
          CASE rec_tab(j).col_type
            WHEN 1 THEN DBMS_SQL.COLUMN_VALUE(c,j,v_v_val);
                        v_finaltxt := ltrim(v_finaltxt||',"'||v_v_val||'"',',');
            WHEN 2 THEN DBMS_SQL.COLUMN_VALUE(c,j,v_n_val);
                        v_finaltxt := ltrim(v_finaltxt||','||v_n_val,',');
            WHEN 12 THEN DBMS_SQL.COLUMN_VALUE(c,j,v_d_val);
                        v_finaltxt := ltrim(v_finaltxt||','||to_char(v_d_val,'DD/MM/YYYY HH24:MI:SS'),',');
          ELSE
            v_finaltxt := ltrim(v_finaltxt||',"'||v_v_val||'"',',');
          END CASE;
        END LOOP;
      --  DBMS_OUTPUT.PUT_LINE(v_finaltxt);
        UTL_FILE.PUT_LINE(v_fh, v_finaltxt);
      END LOOP;
      UTL_FILE.FCLOSE(v_fh);
      DBMS_SQL.CLOSE_CURSOR(c);
    END;This allows for the header row and the data to be written to seperate files if required.
    e.g.
    SQL> exec run_query('select * from emp','TEST_DIR','output.txt');
    PL/SQL procedure successfully completed.Output.txt file contains:
    empno,ename,job,mgr,hiredate,sal,comm,deptno
    7369,"SMITH","CLERK",7902,17/12/1980 00:00:00,800,,20
    7499,"ALLEN","SALESMAN",7698,20/02/1981 00:00:00,1600,300,30
    7521,"WARD","SALESMAN",7698,22/02/1981 00:00:00,1250,500,30
    7566,"JONES","MANAGER",7839,02/04/1981 00:00:00,2975,,20
    7654,"MARTIN","SALESMAN",7698,28/09/1981 00:00:00,1250,1400,30
    7698,"BLAKE","MANAGER",7839,01/05/1981 00:00:00,2850,,30
    7782,"CLARK","MANAGER",7839,09/06/1981 00:00:00,2450,,10
    7788,"SCOTT","ANALYST",7566,19/04/1987 00:00:00,3000,,20
    7839,"KING","PRESIDENT",,17/11/1981 00:00:00,5000,,10
    7844,"TURNER","SALESMAN",7698,08/09/1981 00:00:00,1500,0,30
    7876,"ADAMS","CLERK",7788,23/05/1987 00:00:00,1100,,20
    7900,"JAMES","CLERK",7698,03/12/1981 00:00:00,950,,30
    7902,"FORD","ANALYST",7566,03/12/1981 00:00:00,3000,,20
    7934,"MILLER","CLERK",7782,23/01/1982 00:00:00,1300,,10The procedure allows for the header and data to go to seperate files if required. Just specifying the "header" filename will put the header and data in the one file.
    Adapt to output different datatypes and styles are required.

  • Function Module to Read Hierarchy Node

    Hi,
    Is there is any function module to read from existing Node of Hierarchy (includes sub Nodes, including all its children) similar to RRH1_HIERARCHY_HELP_VALUES_GET.
    Requirement is to create custom Hierarchy from existing Hierarchy (eg: 0WBSELMNT - has XXX Hierarchy, In there is (2nd level) HIER_NODE say yyy. Now read yyy node and create custom Hierarchy to 0WBSELMNT ).
    If we know the Functional modules if any then we can manipulate in ABAP code and write to flat file and upload same file with different Hierarchy Name.
    Thanks in Advance,
    Madhu

    Hi,
    Pls try this:
    RSNDI_SHIE_STRUCTURE_GET3
    RSSH_HIERARCHY_READ
    RSAR_HIERARCHY_GET
    Looking  up BW-Hierarchy with ABAP
    Regards
    CSM Reddy

  • Create datastore for complex comma seperated file

    I am trying to integrate a comma seperated file to an Oracle database. The files contain multiple record types each of which have different number of fields and a different order of datatypes within those fields. The order that the records types are listed in the file determines the relationship between them, e.g.
    The file could contained the following record types in the order shown:
    Segment
    Fixture
    Position
    Position
    Segment
    Segment
    Fixture
    Position
    Position
    Position
    So there is a parent-child relationship between the Segement record and the Fixture record that immediately follows it and similarly the position records are child records to the Fixture record.
    How can I create datastores that represents this relationship when there is no parent field in the child record types?

    I dont think ODI would be able to help you much with Out of the box functionality. You will need to modify the LKM (SQLLDR) to achieve this.
    The following entry illustrates the logic:
    [http://asktom.oracle.com/pls/asktom/f?p=100:11:0::::P11_QUESTION_ID:7526680049479]
    Hope that helps

  • Comma seperated file uploading

    Hi ,
    i want to upload comma seperated file into sap.
    iam using 'GUI_UPLOAD' fm.
    problem is flat file currency field it is also contains comma.
    i can't change file type comma to tab.
    How can i upload currency fields with comma.
    Regards,
    Suresh.

    You can upload your file into a string table. Now split it:
    split uploadtab at ',' into table items.
    if you have
    a,b,c,11,d,e,f
    your tables items contains 7 elements now.
    if you have
    a,b,c,11,22,d,e,f
    your table contains 8 elements now. In that case you now that you have splitted a number with a comma and need to do some actions, e.g. merge elements 4 and 5 together to get 11,22 again and shift the 6th to 5th, the 7th to 5th and the 8th to 7th element.
    After that you number is again in item 4.
    An easier way is to enforce you customer to put values into apostrophes or quotes. If this is not possible, you have to check if an unwanted split was taken in place and act as shown above.
    But: this will work only if one item with a comma in between. If oyu have more components you can not evaulate where the unwanted split is in effect.

  • Is there standard function module to read "open office" in SAP

    Hi All,
    Is there any standard function module to read open office document from SAP.
    Please confirm.
    Thanks and best regards
    Rajeev Chhabra

    Hi all!
    I have a similar problem. I need  create a formatted spread sheet managed open office. The work sheet must be formatted.
    I do not find the function module for doing this.
    Do yo have any idea? The only thing I have found is the functionallity included in program BCALV_TEST_GRID.
    Also I will need a function to upload the file to fill a table control.
    Thanks in advance.
    Cristina.

  • Function modules to read ibase at runtime

    Hi guru's,
                Is there any function modules to read ibase at run time if yes please send those function modules its urgent please please.
    regards
    naveen kumar

    answered

Maybe you are looking for

  • Implementing own Policy - Problems occur.

    I am implementing my own Policy class (via the -Xbootclasspath and java.security file). (Using jdk 1.4) I have two problems: 1. My Policy class is not instantiated unless I call Policy.getPolicy() a. I have run the app as such: java -Djava.security.m

  • Ie8 and clearfloat problems

    Hi, I'm using ie tester to test my css and I've run into a problem with ie8. For some reason it appears to be ignoring my clearfloat style. Here's the page: http://www.esc-online.com/neher/linecard.html Notice how in ie8 the lists are sitting below t

  • ESS - working time - record working time - blank site

    Hi, if i follow the link <u>record working time</u> in the working time overview i get a blank site. Has somebody an idea why?

  • Error Starting Certificate Authority after upgrading in place from Server 2003 Enterprise (32 bit) to Server 2008 Enterprise (32 bit).

    Hope this is the place to seek help with Active Directory Certificate Services.  We recently upgraded in place an issuing CA in our lab from 2003 to 2008 and the upgrade of the OS was successful but the CA service now will not start.  The error is: E

  • Disappearing DV25 clip video

    Hi there.... Had a interesting situation develop with FCS 5 and our Quad G5 system, all footage on a external FW800 drive, latest OS and 8Gig of RAM.... Editing a DV25 project (NTSC-DV 720x480) project sequence[s] lost all video (bin and sequences),