CSV file to Ztable

Can u guys tell me steps/give sample code to upload a ZTABLE from a CSV file.
Iam not using all fields in the CSV file( if file have 5 fields,I am using 3 out of it) and also not all fields in  the ZTABLE ( uploading 3 fields out of 7 fields)and some necessary validations.
Thnaks..

HI,
Try this. We use this FM and it works quite well.
** internal table to receive stat key figures data from EXCEL
data: begin of intab01 occurs 0,
kostl(10) type n, " cost center number
lstar(10), " stat key figure code
per01(15), " period 01 value
per02(15), " period 02 value
per03(15), " period 03 value
per04(15), " period 04 value
per05(15), " period 05 value
per06(15), " period 06 value
per07(15), " period 07 value
per08(15), " period 08 value
per09(15), " period 09 value
per10(15), " period 10 value
per11(15), " period 11 value
per12(15), " period 12 value
end of intab01.
* Added Input Work Area
data: begin of in_wa,
kostl(10), " cost center number
lstar(10), " stat key figure code
per01(15), " period 01 value
per02(15), " period 02 value
per03(15), " period 03 value
per04(15), " period 04 value
per05(15), " period 05 value
per06(15), " period 06 value
per07(15), " period 07 value
per08(15), " period 08 value
per09(15), " period 09 value
per10(15), " period 10 value
per11(15), " period 11 value
per12(15), " period 12 value
end of in_wa.
data: w_index type i.
* FIELD SYMBOLS
field-symbols : <fs>.
* S E L E C T I O N S C R E E N F I E L D S
parameters: p_input like rlgrap-filename obligatory.
parameters: p_skp type n default 0.
** transfer data from EXCEL input file to internal table INTAB01
perform upload_excel.
form upload_excel.
* load plan data from EXCEL into table INTAB01 via function UPLOAD *
data : i_intern type alsmex_tabline occurs 0 with header line."BCT004
data : w_start_col type i value '1',
w_start_row type i value '1',
w_end_col type i value '18', "must = # of excel columns
w_end_row type i value '65536'.
call function 'ALSM_EXCEL_TO_INTERNAL_TABLE' "BCT004
exporting
filename = p_input
i_begin_col = w_start_col
i_begin_row = w_start_row
i_end_col = w_end_col
i_end_row = w_end_row
tables
intern = i_intern.
if i_intern[] is initial. " File empty SLG001
format color col_negative.
skip 1.
write: / 'There is a problem with'.
format color col_normal.
write: / p_input.
format color col_negative.
write: / 'Check the file and rerun'.
skip 2.
write: /15 '>>>>>>>> E N D O F P R O G R A M <<<<<<<<'.
stop.
endif.
* Begin SLG001
sort i_intern by row col.
loop at i_intern.
if i_intern-row <= p_skp.
continue.
endif.
move : i_intern-col to w_index.
if w_index <= 18. "Col 18-last data col
assign component w_index of structure in_wa to <fs>.
move : i_intern-value to <fs>.
endif.
at end of row.
move-corresponding in_wa to intab01.
shift intab01-per01 right deleting trailing ' '.
shift intab01-per02 right deleting trailing ' '.
shift intab01-per03 right deleting trailing ' '.
shift intab01-per04 right deleting trailing ' '.
shift intab01-per05 right deleting trailing ' '.
shift intab01-per06 right deleting trailing ' '.
shift intab01-per07 right deleting trailing ' '.
shift intab01-per08 right deleting trailing ' '.
shift intab01-per09 right deleting trailing ' '.
shift intab01-per10 right deleting trailing ' '.
shift intab01-per11 right deleting trailing ' '.
shift intab01-per12 right deleting trailing ' '.
append intab01 .
clear: in_wa, intab01 .
endat.
endloop.
endform. " upload_excel
<b>See the below links for more example programs</b>
http://sap.ittoolbox.com/code/archives.asp?d=3365&a=s&i=10
http://sap.ittoolbox.com/code/archives.asp?d=3126&a=s&i=10
http://sap.ittoolbox.com/code/archives.asp?d=3127&a=s&i=10
http://sap.ittoolbox.com/code/archives.asp?d=2128&a=s&i=10
http://sap.ittoolbox.com/code/archives.asp?d=1721&a=s&i=10
Thanks
Sudheer

Similar Messages

  • Issuse in Uploading a .CSV file from AL11 to Database table.

    Hi All,
    I have a .CSV file (UTF-8 format) which contains Chinese Characters.
    I uploaded the file to AL11 and it shows that all teh data is correct in AL11.
    Now i am using a program to Read file from AL11 and update a ztable but some of the characters are
    modified and some are getting saved as junk characters.
    Kindly let me know what can be done.
    Regards,
    Jose

    Jose,
    The issue is pretty much clear. Ask the IT team to change the regional settings for languages. Normally we don't have
    access to Korean, Traditional chinese....etc.
    You might be getting characters/symbols as ?? ##. Go ahead and change the regional setting.
    This will solve your issue.

  • 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

  • Loading 361000 records at a time from csv file

    Hi,
    One of my collegue loaded 361000 records from one file file , how is this possible as excel accepts 65536 records in one file
    and even in the infopackage the following are selected what does this mean
    Data Separator   ;
    Escape Sign      "
    Separator for Thousands   .
    Character Used for Decimal Point   ,
    Pls let me know

    hi Maya,
    it just possible, other than ms-excel, we have editor like Textpad that support more 65k rows (and windows Notepad), the file may be generated by program or edited outside in excel, or newer version of excel is used, ms-excel 2007 support more 1 million rows.
    e.g we have csv file
    customer;product;quantity;revenue
    a;x;"1.250,25";200
    b;y;"5.5";300
    data separator ;
    - char/delimeter used to separate field, e.g
    escape sign, e.g
    - "1.250,25";200 then quantity = 1.250,25
    separator for thousands = .
    - 1.250,25 means one thousand two hundred ...
    char used for decimal point
    - - 1.250<b>,</b>25
    check
    http://help.sap.com/saphelp_nw70/helpdata/en/80/1a6581e07211d2acb80000e829fbfe/frameset.htm
    http://help.sap.com/saphelp_nw70/helpdata/en/c2/678e3bee3c9979e10000000a11402f/frameset.htm
    hope this helps.

  • Error while creating table from csv file

    I am getting an error while creating a table using 'Import Data' button for a csv file containing 22 columns and 8 rows. For primary key, I am using an existing column 'Line' and 'Not generated' options.
    ORA-20001: Excel load run ddl error: drop table "RESTORE" ORA-00942: table or view does not exist ORA-20001: Excel load run ddl error: create table "RESTORE" ( "LINE" NUMBER, "PHASE" VARCHAR2(30), "RDC_MEDIA_ID" VARCHAR2(30), "CLIENT_MEDIA_LABEL" VARCHAR2(30), "MEDIA_TYPE" VARCHAR2(30), "SIZE_GB" NUMBER, "RDC_IMG_HD_A" NUMBER, "START_TECH" VARCHAR2(30), "CREATE_DATE" VARCHAR2(30), "RDC_MEDIA_DEST" VARCHAR2(30), "POD" NUMBER, "TAPE" NUMBER, "ERRORS_YN" VA
    Any idea?

    I am getting an error while creating a table using 'Import Data' button for a csv file containing 22 columns and 8 rows. For primary key, I am using an existing column 'Line' and 'Not generated' options.
    ORA-20001: Excel load run ddl error: drop table "RESTORE" ORA-00942: table or view does not exist ORA-20001: Excel load run ddl error: create table "RESTORE" ( "LINE" NUMBER, "PHASE" VARCHAR2(30), "RDC_MEDIA_ID" VARCHAR2(30), "CLIENT_MEDIA_LABEL" VARCHAR2(30), "MEDIA_TYPE" VARCHAR2(30), "SIZE_GB" NUMBER, "RDC_IMG_HD_A" NUMBER, "START_TECH" VARCHAR2(30), "CREATE_DATE" VARCHAR2(30), "RDC_MEDIA_DEST" VARCHAR2(30), "POD" NUMBER, "TAPE" NUMBER, "ERRORS_YN" VA
    Any idea?

  • Error while refreshing a report using local csv file

    Hi,
    I'm using BI 4.1 SP02.
    While using Rich client, I've created a report with some merged queries, while one of the queries is a local CSV file - saved on AD in some server, and not on the repository inside BO.
    While trying to refresh the report with the Rich client, it all went great.
    Now, while using BI Launchpad java based app, I can't refresh the report - I get the following error:
    "An Internal error occurred while calling 'processDPCommandsEx' API. (Error: ERR_WIS_30270) (WIS 30270)"
    Should I be able to refresh a report without the Rich if it contains a local file (which is possible to EDIT only with rich) ?
    If so, then did someone ran into this error?
    Thank you,
    Or.

    First of all, thanks for both of the replies.
    Second,
    my problem is unlikely have to do something with permissions from one reasons -
    when the report is using XLS\XLSX on same folder(with same name prefix) - the report is running without any problem.
    Only problem is while refreshing without Rich while the source is network CSV file.
    Any suggestions?
    Thanks.

  • Issue in conversion of output file from alv to csv file using GUI_DOWNLOAD

    hi,
    I am using GUI_DOWNLOAD to convert the internal table that am getting as the output of an alv into a csv(comma separated file) file.I am using the following code but its not generating a csv file instead it is generating a normal space delimited file.
    The code is as follows:
    data : lv_fname type string.
    lv_fname = 'C:\Users\pratyusha_tripathi\Desktop\status8.csv'. " Provide the file path & file name with CSV extention
    CALL FUNCTION 'GUI_DOWNLOAD'
    EXPORTING
    filename = lv_fname " File name including path, give CSV as extention of the file
    FILETYPE = 'DAT'
    WRITE_FIELD_SEPARATOR = '#' " Provide comma as separator
    tables
    data_tab = ITAB " Pass the Output internal table
    FIELDNAMES =
    EXCEPTIONS
    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.
    Kindly let me know what changes can be made to make my code work.Also can GUI_download be used for batch processing and storing the output in application server?
    Thanks ,
    Pratyusha

    Hi,
    the short text description for WRITE_FIELD_SEPARATOR is "Separate Columns by Tabs in Case of ASCII Download", so why do you expect a comma?
    Try SAP_CONVERT_TO_CSV_FORMAT and then download.
    And no, GUI_DOWNLOAD is only for download via SAP GUI to a users computer.
    Best regards,
    Oliver

  • Creation of CSV file on client machine with data from forms

    Hi,
    My requirement is to generate a CSV file(or .XLS) on the client machine ie local drive with the details shown in a form.
    Oracle version -
    Oracle Database 11g Enterprise Edition Release 11.1.0.7.0 - 64bit Production
    PL/SQL Release 11.1.0.7.0 - Production
    CORE 11.1.0.7.0 Production
    TNS for Solaris: Version 11.1.0.7.0 - Production
    NLSRTL Version 11.1.0.7.0 - Production.
    I have searched the web for last couple of days and got to know that TEXT_IO is to be used to generate files on client machine. However, when I tried TEXT_IO, it was not able to generate the file on client rather it was able to generate on database server. After further browsing on this, there was a link which said that we need to use CLIENT_TEXT_IO to generate file on client side. For this, i was required to subclass the webutil.pll which i did and corrected the code to use CLIENT_TEXT_IO. The form was unable to compile and was not able to find "webutil_core" package.
    I am very confused with the disparity in the information available on the web as in what to use to generate a file on client side. If anyone has use it in the past, can he/she please detail what to use to get things sorted.
    Thanks,
    R

    Oracle version - Oracle Database 11g Enterprise Edition Release 11.1.0.7.0 - 64bit Production
    PL/SQL Release 11.1.0.7.0 - Production
    CORE 11.1.0.7.0 Production
    TNS for Solaris: Version 11.1.0.7.0 - Production
    NLSRTL Version 11.1.0.7.0 - Production. >
    So, what is your FORMS version. This is more important than your database version.
    My requirement is to generate a CSV file(or .XLS) on the client machine ie local drive with the details shown in a form. Depending on your Forms version, you would use TEXT_IO (if Forms 6i running in Client/Server mode) or WebUtil (if Forms 9i or higher).
    I'm going to guess that you are at least using Oracle Forms 9i since you stated that your attempt at using TEXT_IO produced a file on the DB server.
    There is more to using WebUtil than just attaching the WEBUTIL.PLL. If you had performed a simple search of the Forms Help System would have found numerous WebUtil topics to include: Introduction to WebUtil, Configuring WebUtil, Using WebUtil in Your Applications and the WebUtil User's Guide. If you have Oracle Forms release 10g or higher, WebUtil is included when you installed Forms, however, you do need to configure your installation to use WebUtil and you must download the Java COM Bridge (jacob.jar) from Source Forge. Take a look at the Configuring WebUtil Forms Help topic to find out which version of the Java COM Bridge you will need to download.
    After you have successfully configured WebUtil, take a look at the Using WebUtil in Your Applications topic to find out how to implement WebUtil in a form.
    Searching the Internet for answers is great, but don't forget the look at the Forms Help System because the majority of your questions can be answered there. :)
    Lastly, configuration of WebUtil is primarily done on your Application Server (AS). However, if you plan to perform preliminary runtime testing by running your Form from the Forms Builder, then you will configure your local runtime to support WebUtil as well as configure your AS. The steps are exactly the same. A common mis-step is to skip a step during the configuration because you don't think the step applies. Take a look at the Forms Help Runtime Setup Checklist topic for a list of step you need to complete in order to enable WebUtil.
    Hope this helps,
    Craig B-)
    If someone's response is helpful or correct, please mark it accordingly.

  • Sender "Mail" adapter - CSV file attachment

    Hi there
    I'm looking for some help in configuring a sender mail adapter that receives ".csv" files. I did read some blogs that mention using the "PayloadSwapBean" module to read the mail attachment instead of the mail content. My problem is to now convert the ".csv" file into a message. Is there a module that I can use ( is it the "MessageTransfomBean" ) and how. Any help would be appreciated.
    Thanks
    Salil

    Hi Salil,
    If you want to send a mail with a body and attachments, the message sender HAS to provide an XI message with attachments. I doubt a CSV file does justice.
    As Renjith said you need to convert CSV to XmL.
    A short description about the Standard Modules:
    MessageTransformationBean is a standard module used to apply the XSLT mapping to the adapter module by using <i>Transform.class</i> ( This xslt mapping is done to create a mail package, Dont confuse with the actual mapping in your case this is NOT for converting csv to xml).
    Also this module can be used to change the name and type of payloads by using <i>Transform.contentType</i>, <i>Transform.contentDisposition</i>, <i>Transform.contentDescription</i>.
    PayloadSwapbean is a standard module for replacing payloads with other payloads (SWAP)
    If you want to give each attachment a certain name use Parameters, <i>swap.keyname</i> for name of the payload and <i>swap.keyvalue</i>.
    I Hope the use of standard modules is understood.

  • Read a CSV file and dynamically generate the insert

    I have a requirement where there are multiple csv's which needs to be exported to a sql table. So far, I am able to read the csv file and generate the insert statement dynamically for selected columns however, the insert statement when passed as a parameter
    to the $cmd.CommandText
    does not evaluate the values
    How to evaluate the string in powershell
    Import-Csv -Path $FileName.FullName | % {
    # Insert statement.
    $insert = "INSERT INTO $Tablename ($ReqColumns) Values ('"
    $valCols='';
    $DataCols='';
    $lists = $ReqColumns.split(",");
    foreach($l in $lists)
    $valCols= $valCols + '$($_.'+$l+')'','''
    #Generate the values statement
    $DataCols=($DataCols+$valCols+')').replace(",')","");
    $insertStr =@("INSERT INTO $Tablename ($ReqColumns) Values ('$($DataCols))")
    #The above statement generate the following insert statement
    #INSERT INTO TMP_APPLE_EXPORT (PRODUCT_ID,QTY_SOLD,QTY_AVAILABLE) Values (' $($_.PRODUCT_ID)','$($_.QTY_SOLD)','$($_.QTY_AVAILABLE)' )
    $cmd.CommandText = $insertStr #does not evaluate the values
    #If the same statement is passed as below then it execute successfully
    #$cmd.CommandText = "INSERT INTO TMP_APL_EXPORT (PRODUCT_ID,QTY_SOLD,QTY_AVAILABLE) Values (' $($_.PRODUCT_ID)','$($_.QTY_SOLD)','$($_.QTY_AVAILABLE)' )"
    #Execute Query
    $cmd.ExecuteNonQuery() | Out-Null
    jyeragi

    Hi Jyeragi,
    To convert the data to the SQL table format, please try this function out-sql:
    out-sql Powershell function - export pipeline contents to a new SQL Server table
    If I have any misunderstanding, please let me know.
    If you have any feedback on our support, please click here.
    Best Regards,
    Anna
    TechNet Community Support

  • Not able to write image in csv file

    I have tried to write JPEG file in csv but having a critical probem.
    The JPEG in the CSV is coming wrongly. Means whenever I open the created CSV file I can see the image has been moved upside down.
    Can any one please help me how to write a proper image using ClientAnchor?
    Can anyone please provide any sample code
    Edited by: 837718 on Feb 17, 2011 6:25 PM

    Try this
         Workbook workBookObject= new HSSFWorkbook();
         Sheet sheet = wb.createSheet();
         CreationHelper helper = wb.getCreationHelper();
         Drawing drawing = sheet.createDrawingPatriarch();
    ByteArrayOutputStream img_bytes = new ByteArrayOutputStream();
                   int b;
                   while ((b = fis.read()) != -1)
                        img_bytes.write(b);
                   fis.close();
                   helper = workBookObject.getCreationHelper();
                   ClientAnchor anchor = helper.createClientAnchor();
                   int picIndex = workBookObject.addPicture(img_bytes.toByteArray(),Workbook.PICTURE_TYPE_JPEG);
                   anchor.setCol1(col);
         anchor.setRow1(0);
                   anchor.setAnchorType(ClientAnchor.MOVE_DONT_RESIZE);
                   pic = drawing.createPicture(anchor, picIndex);
                   pic.resize();

  • PI 7.11 CSV file

    Hello All,
    I have a simple scenerio IDOC to File.
    We had a requirement of making a XML file of IDOC received in PI , ery simple and straight forward.
    Now Target side as a requirement to place a file in CSV format.
    I mean the IDOC received in PI should be placed in target directory as CSV file.
    I am working on PI7.11 , can anyone help me with some info.
    Thanks a lot in advance.
    Regards,
    Vikrant

    Hi Vikrant,
    >>Now Target side as a requirement to place a file in CSV format. I mean the IDOC received in PI should be placed in target directory as CSV file.
    If you want the XMLized IDoc to be converted to a plain IDoc, either use the approach suggested by Michal in this blog (use tunneling and create a by-pass scenario)
    /people/michal.krawczyk2/blog/2005/11/21/xi-idoc-to-idoc-tunneling--how-fast-and-easy-can-you-get
    or
    download the IDoc as a flat Idoc and use PI to transfer the content from one directory to another.
    PS: All this is applicable if you want the Flat version of XMLized Idoc
    Regards
    Suraj

  • Creating a CSV file from a pl/sql procedure

    Hi Everyone,
    I would like to know how to write a procedure in pl/sql where i need to check if they are any records in a table say "Table A".
    If they are any records in the "Table A" then we need to write those records in the "Table A" to the CSV file.
    If they are no records then we need to insert a record into the CSV file that "No records are found in "Table A".
    Could anybody please help ?
    Thanks in advance

    see this
    ops$tkyte@8i> create or replace procedure dump_table_to_csv( p_tname in varchar2,
    2 p_dir in varchar2,
    3 p_filename in varchar2 )
    4 is
    5 l_output utl_file.file_type;
    6 l_theCursor integer default dbms_sql.open_cursor;
    7 l_columnValue varchar2(4000);
    8 l_status integer;
    9 l_query varchar2(1000)
    10 default 'select * from ' || p_tname;
    11 l_colCnt number := 0;
    12 l_separator varchar2(1);
    13 l_descTbl dbms_sql.desc_tab;
    14 begin
    15 l_output := utl_file.fopen( p_dir, p_filename, 'w' );
    16 execute immediate 'alter session set nls_date_format=''dd-mon-yyyy hh24:mi:ss''
    17
    18 dbms_sql.parse( l_theCursor, l_query, dbms_sql.native );
    19 dbms_sql.describe_columns( l_theCursor, l_colCnt, l_descTbl );
    20
    21 for i in 1 .. l_colCnt loop
    22 utl_file.put( l_output, l_separator || '"' || l_descTbl(i).col_name || '"'
    23 dbms_sql.define_column( l_theCursor, i, l_columnValue, 4000 );
    24 l_separator := ',';
    25 end loop;
    26 utl_file.new_line( l_output );
    27
    28 l_status := dbms_sql.execute(l_theCursor);
    29
    30 while ( dbms_sql.fetch_rows(l_theCursor) > 0 ) loop
    31 l_separator := '';
    32 for i in 1 .. l_colCnt loop
    33 dbms_sql.column_value( l_theCursor, i, l_columnValue );
    34 utl_file.put( l_output, l_separator || l_columnValue );
    35 l_separator := ',';
    36 end loop;
    37 utl_file.new_line( l_output );
    38 end loop;
    39 dbms_sql.close_cursor(l_theCursor);
    40 utl_file.fclose( l_output );
    41
    42 execute immediate 'alter session set nls_date_format=''dd-MON-yy'' ';
    43 exception
    44 when others then
    45 execute immediate 'alter session set nls_date_format=''dd-MON-yy'' ';
    46 raise;
    47 end;
    48 /
    Procedure created.
    ops$tkyte@8i> exec dump_table_to_csv( 'emp', '/tmp', 'tkyte.emp' );
    PL/SQL procedure successfully completed.

  • How can I make an easy *.CSV file to load into database table

    Hi All,
    I have a huge excel sheet having columns item#, description and qty. The description column sometimes maybe one word name, two word name separated with space or may be , spearated name. I want to write and PL/SQl code which will read this file and load it into database table. Now the *.CSV file is either comma delimited or tab text delmited which both do not solve my issue. Is there any better solution with anyone which can prevent the manual editing to the *.CSV file and I can easily load it to table.
    Your help is appreciated,
    Thanks
    Zahir

    SQL*Loader is probably the fastest method, but since you specifically asked for a PL/SQL method:
    http://asktom.oracle.com/pls/ask/f?p=4950:8:::::F4950_P8_DISPLAYID:464420312302

  • How Can I Import Contacts from Excel (XLSX/XLS) and CSV file to VCF File?

    Hi Friends,
    I have stored my all official and personal contacts list in the Excel (XLSX/XLS) spreadsheet and CSV file from long time. But now, I want to move my all contacts in an MS outlook 2013 and also Samsung S4 Contacts directory. But for this process, I require to import all Excel and CSV file contacts into VCF file format. So that, I could export vCard (VCF) file in the outlook and Samsung S4 contacts book. But I don't know about this process that how to import Excel and CSV file contacts into vCard format. If anyone has best solution to import and export excel or CSV file contacts into VCF file, so please share with me that information.
    Thanks & Best Regards
    Jackson T.
    <Edited By Host>

    https://itunes.apple.com/gb/app/csv-to-vcard/id713295900?mt=12

Maybe you are looking for

  • Bootcamp on Macbook, W7, NO INTERNET

    SPECS: Macbook 09, Lion, Airport Express, Bootcamp installed at Apple store 7-8-12. I ONLY wanted the bootcamp to run my genealogy program (Mac built genealogy programs are inadequate for advanced researchers). The program is installed, but I can not

  • Must touch speaker phone to be able to use ipone

    Hello all, My wifes' iphone 4S is driving her crazy.  She uses it as a phone with no headsets, nor bluetooth.  When she answers a call, she cannot hear the calling party until after she hits the speaker phone button.  People cannot hear her answer ei

  • How to load third party SCORM 1.2 to Adobe Connect 9?

    Can someone please guide me on how to load any third party SCORM 1.2 package to Adobe Connect 9 room?

  • Process Code for Outbound Idoc

    Hi All, We need to find out the Process Code for an Idoc. Note : We dont have access to WE41, WE20 ,BD51. Could you please suggest any alternatives. Thanks, Sanjeet

  • Screen capture apps

    is there any screen capture apps available? Nokia N95-1 v30.0.015