Dynamic structure of "string" data type. Please help.

ABAPers,
I am calling cl_alv_table_create=>create_dynamic_table method to dynamically create a structure. The input structure definition is as follows:
data: xfc type lvc_s_fcat.
data: ifc type lvc_t_fcat.
* define Fld1
clear xfc.
xfc-fieldname = 'Fld1'.
xfc-datatype = 'string'.
append xfc to ifc.
* define Fld2
clear xfc.
xfc-fieldname = 'Fld2'.
xfc-datatype = 'string'.
append xfc to ifc.
Although the call to create_dynamic_table does not throw any exceptions, it appears Fld1 and Fld2 are not of "string" data type. I don't know of a way to see what type they are. However, they do have a length limit of 10 characters.
After some experimenting, it turns out that the method simply ignores "datatype" value if it doesn't understand it and creates the field with some default data type.
I would appreciate it if someone can show me how to create fields of "string" data type.
Thank you in advance for your help.
Pradeep

That's right, use STRG as the datatype.  Please see the example program.
report zrich_0003.
type-pools: slis.
data: new_table type ref to data,
      new_line  type ref to data.
data:  xfc type lvc_s_fcat,
       ifc type lvc_t_fcat.
field-symbols: <dyn_table> type standard table,
               <dyn_wa>,
               <fs>.
start-of-selection.
  clear xfc.
  xfc-fieldname = 'Field1' .
  xfc-datatype = 'STRG'.
  append xfc to ifc .
  clear xfc.
  xfc-fieldname = 'Field2' .
  xfc-datatype = 'STRG'.
  append xfc to ifc .
* Create dynamic internal table and assign to FS
  call method cl_alv_table_create=>create_dynamic_table
    exporting
      it_fieldcatalog = ifc
    importing
      ep_table        = new_table.
  assign new_table->* to <dyn_table>.
* Create dynamic work area and assign to FS
  create data new_line like line of <dyn_table>.
  assign new_line->* to <dyn_wa>.
  assign component 1 of structure <dyn_wa> to <fs>.
  <fs> = 'This is string 1'.
  assign component 2 of structure <dyn_wa> to <fs>.
  <fs> = 'This is string 2'.
  append <dyn_wa> to <dyn_table>.
* Write the values of internal table.
  loop at <dyn_table> into <dyn_wa>.
    do.
      assign component sy-index of structure <dyn_wa> to <fs>.
      if sy-subrc <> 0.
        exit.
      endif.
      write:/ <fs>.
    enddo.
  endloop.
REgards,
Rich Heilman

Similar Messages

  • Logical data type -please help

    Hello there
    I want to use same jdbc code for different databases like MS Access, SQL server, Oracle, DB2 etc. But in case of logical data type fields (trye/false) in table I am facing problem in compatibilty. because it is being defined differently in sme databases.
    Is there anybody who can help me solving the problem?
    thanks in advance.
    mortoza

    You can use a char(1) column(as jschell said) or int(1) and use 1 and 0 for true/false or you could have VARCHAR(30) with "the value is true..". It doesn't really matter, but you have to check for this value to set your boolean value in your program:
    boolean bool;
    if ( resultset.getString(column_number).equals("T")
    // or if ( resultset.getInt(column_number) == 1)
    // or if ( resultset.getString(column_number).equals("the value is true..")
    bool = true;
    else
    bool = false;

  • Unicode and non-unicode string data types Issue with 2008 SSIS Package

    Hi All,
    I am converting a 2005 SSIS Package to 2008. I have a task which has SQL Server as the source and Oracle as the destination. I copy the data from a SQL server view with a field nvarchar(10) to a field of a oracle table varchar(10). The package executes fine
    on my local when i use the data transformation task to convert to DT_STR. But when I deploy the dtsx file on the server and try to run from an SQL Job Agent it gives me the unicode and non-unicode string data types error for the field. I have checked the registry
    settings and its the same in my local and the server. Tried both the data conversion task and Derived Column task but with no luck. Pls suggest me what changes are required in my package to run it from the SQL Agent Job.
    Thanks.

    What is Unicode and non Unicode data formats
    Unicode : 
    A Unicode character takes more bytes to store the data in the database. As we all know, many global industries wants to increase their business worldwide and grow at the same time, they would want to widen their business by providing
    services to the customers worldwide by supporting different languages like Chinese, Japanese, Korean and Arabic. Many websites these days are supporting international languages to do their business and to attract more and more customers and that makes life
    easier for both the parties.
    To store the customer data into the database the database must support a mechanism to store the international characters, storing these characters is not easy, and many database vendors have to revised their strategies and come
    up with new mechanisms to support or to store these international characters in the database. Some of the big vendors like Oracle, Microsoft, IBM and other database vendors started providing the international character support so that the data can be stored
    and retrieved accordingly to avoid any hiccups while doing business with the international customers.
    The difference in storing character data between Unicode and non-Unicode depends on whether non-Unicode data is stored by using double-byte character sets. All non-East Asian languages and the Thai language store non-Unicode characters
    in single bytes. Therefore, storing these languages as Unicode uses two times the space that is used specifying a non-Unicode code page. On the other hand, the non-Unicode code pages of many other Asian languages specify character storage in double-byte character
    sets (DBCS). Therefore, for these languages, there is almost no difference in storage between non-Unicode and Unicode.
    Encoding Formats: 
    Some of the common encoding formats for Unicode are UCS-2, UTF-8, UTF-16, UTF-32 have been made available by database vendors to their customers. For SQL Server 7.0 and higher versions Microsoft uses the encoding format UCS-2 to store the UTF-8 data. Under
    this mechanism, all Unicode characters are stored by using 2 bytes.
    Unicode data can be encoded in many different ways. UCS-2 and UTF-8 are two common ways to store bit patterns that represent Unicode characters. Microsoft Windows NT, SQL Server, Java, COM, and the SQL Server ODBC driver and OLEDB
    provider all internally represent Unicode data as UCS-2.
    The options for using SQL Server 7.0 or SQL Server 2000 as a backend server for an application that sends and receives Unicode data that is encoded as UTF-8 include:
    For example, if your business is using a website supporting ASP pages, then this is what happens:
    If your application uses Active Server Pages (ASP) and you are using Internet Information Server (IIS) 5.0 and Microsoft Windows 2000, you can add "<% Session.Codepage=65001 %>" to your server-side ASP script.
    This instructs IIS to convert all dynamically generated strings (example: Response.Write) from UCS-2 to UTF-8 automatically before sending them to the client.
    If you do not want to enable sessions, you can alternatively use the server-side directive "<%@ CodePage=65001 %>".
    Any UTF-8 data sent from the client to the server via GET or POST is also converted to UCS-2 automatically. The Session.Codepage property is the recommended method to handle UTF-8 data within a web application. This Codepage
    setting is not available on IIS 4.0 and Windows NT 4.0.
    Sorting and other operations :
    The effect of Unicode data on performance is complicated by a variety of factors that include the following:
    1. The difference between Unicode sorting rules and non-Unicode sorting rules 
    2. The difference between sorting double-byte and single-byte characters 
    3. Code page conversion between client and server
    Performing operations like >, <, ORDER BY are resource intensive and will be difficult to get correct results if the codepage conversion between client and server is not available.
    Sorting lots of Unicode data can be slower than non-Unicode data, because the data is stored in double bytes. On the other hand, sorting Asian characters in Unicode is faster than sorting Asian DBCS data in a specific code page,
    because DBCS data is actually a mixture of single-byte and double-byte widths, while Unicode characters are fixed-width.
    Non-Unicode :
    Non Unicode is exactly opposite to Unicode. Using non Unicode it is easy to store languages like ‘English’ but not other Asian languages that need more bits to store correctly otherwise truncation will occur.
    Now, let’s see some of the advantages of not storing the data in Unicode format:
    1. It takes less space to store the data in the database hence we will save lot of hard disk space. 
    2. Moving of database files from one server to other takes less time. 
    3. Backup and restore of the database makes huge impact and it is good for DBA’s that it takes less time
    Non-Unicode vs. Unicode Data Types: Comparison Chart
    The primary difference between unicode and non-Unicode data types is the ability of Unicode to easily handle the storage of foreign language characters which also requires more storage space.
    Non-Unicode
    Unicode
    (char, varchar, text)
    (nchar, nvarchar, ntext)
    Stores data in fixed or variable length
    Same as non-Unicode
    char: data is padded with blanks to fill the field size. For example, if a char(10) field contains 5 characters the system will pad it with 5 blanks
    nchar: same as char
    varchar: stores actual value and does not pad with blanks
    nvarchar: same as varchar
    requires 1 byte of storage
    requires 2 bytes of storage
    char and varchar: can store up to 8000 characters
    nchar and nvarchar: can store up to 4000 characters
    Best suited for US English: "One problem with data types that use 1 byte to encode each character is that the data type can only represent 256 different characters. This forces multiple
    encoding specifications (or code pages) for different alphabets such as European alphabets, which are relatively small. It is also impossible to handle systems such as the Japanese Kanji or Korean Hangul alphabets that have thousands of characters."<sup>1</sup>
    Best suited for systems that need to support at least one foreign language: "The Unicode specification defines a single encoding scheme for most characters widely used in businesses around the world.
    All computers consistently translate the bit patterns in Unicode data into characters using the single Unicode specification. This ensures that the same bit pattern is always converted to the same character on all computers. Data can be freely transferred
    from one database or computer to another without concern that the receiving system will translate the bit patterns into characters incorrectly.
    https://irfansworld.wordpress.com/2011/01/25/what-is-unicode-and-non-unicode-data-formats/
    Thanks Shiven:) If Answer is Helpful, Please Vote

  • Column "A" cannot convert between unicode and non-unicode string data types

    I am following the SSIS overview video-
    https://secure.cbtnuggets.com/it-training-videos/series/microsoft-sql-server-2008-business-development/6143?autostart=true
    I have a flat file that i want to import the contents onto a SQL database.
    I created a Dataflow task, source file and oledb destination.
    I am getting the folliwung error -
    "column "A" cannot convert between unicode and non-unicode string data types"
    in the origin file the data type is coming as string[DT_STR] and in the destination object it is coming as "Unicode string [DT_WSTR]"
    I used a data conversion object in between, dosent works very well
    Please help what to do

    I see this often.
    Right Click on FlatFileSource --> Show Advanced Editor --> 'Input and Output Properties' tab --> Expand 'Flat File Source Output' --> Expand 'Output Columns' --> Select your field and set the datatype to DT_WSTR.
    Let me know if you still have issues.
    Thank You,
    Jay

  • How to fix "cannot convert between unicode and non-unicode string data types" :/

    Environment: SQL Server 2008 R2
    Introduction:Staging_table is a table where data is being stored from source file. Individual and ind_subject_scores are destination tables.
    Purpose: To load the data from a source file .csv while SSIS define table  fields with 50 varchar, I can still transfer the data to the entity table/ destination and keeping the table definition.
    I'm getting validation error "Cannot convert between a unicode and a non-unicode string data types" for all the columns.
    Please help

    Hi ,
    NVARCHAR = DT_WSTR
    VARCHAR = DT_STR
    Try below links:
    http://social.msdn.microsoft.com/Forums/sqlserver/en-US/ed1caf36-7a62-44c8-9b67-127cb4a7b747/error-on-package-can-not-convert-from-unicode-to-non-unicode-string-type?forum=sqlintegrationservices
    http://social.msdn.microsoft.com/Forums/en-US/eb0d1519-4be3-427d-bd30-ae4004ea9e8d/data-conversion-error-how-to-fix-this
    http://technet.microsoft.com/en-us/library/aa337316(v=sql.105).aspx
    http://social.technet.microsoft.com/wiki/contents/articles/19612.ssis-import-excel-to-table-cannot-convert-between-unicode-and-non-unicode-string-data-types.aspx
    sathya - www.allaboutmssql.com ** Mark as answered if my post solved your problem and Vote as helpful if my post was useful **.

  • SSIS Package : While Extracting Sharepoint Lookup column, getting error 'Cannnot convert between unicode and non-unicode string data types'

    Hello,
    I am working on one project and there is need to extract Sharepoint list data and import them to SQL Server table. I have few lookup columns in the list.
    Steps in my Data Flow :
    Sharepoint List Source
    Derived Column
    its formula : SUBSTRING([BusinessUnit],FINDSTRING([BusinessUnit],"#",1)+1,LEN([BusinessUnit])-FINDSTRING([BusinessUnit],"#",1))
    Data Conversion
    OLE DB Destination
    But I am getting the error of not converting between unicode and non-unicode string data types.
    I am not sure what I am missing here.
    In Data Conversion, what should be the Data Type for the Look up column?
    Please suggest here.
    Thank you,
    Mittal.

    You have a data conversion transformation.  Now, in the destination are you assigning the results of the derived column transformation or the data conversion transformation.  To avoid this error you need use the data conversion output.
    You can eliminate the need for the data conversion with the following in the derived column (creating a new column):
    (DT_STR,100,1252)(SUBSTRING([BusinessUnit],FINDSTRING([BusinessUnit],"#",1)+1,LEN([BusinessUnit])-FINDSTRING([BusinessUnit],"#",1)))
    The 100 is the length and 1252 is the code page (I almost always use 1252) for interpreting the string.
    Russel Loski, MCT, MCSE Data Platform/Business Intelligence. Twitter: @sqlmovers; blog: www.sqlmovers.com

  • Cannot convert between unicode and non-unicode string data types.

    I'm trying to copy the data from 21 tables in a SQL 2005 database to a MS Access database using SSIS. Before converting the SQL database from 2000 to 2005 we had this process set up as a DTS package that ran every month for years with no problem.  The only way I can get it to work now is to delete all of the tables from the Access DB and have SSIS create new tables each time. But when I try to create an SSIS package using the SSIS Import and Export Wizard to copy the SQL 2005 data to the same tables that SSIS itself created in Access I get the "cannot convert between unicode and non-unicode string data types" error message. The first few columns I hit this problem on were created by SSIS as the Memo datatype in Access and when I changed them to Text in Access they started to work. The column I'm stuck on now is defined as Text in the SQL 2005 DB and in Access, but it still gives me the "cannot convert" error.

    I was getting same error while tranfering data from SQL 2005 to Excel , but using following method i was able to tranfer data. Hopefully it may also help you.
    1) Using Data Conversion transformation
       data types you need to select is DT_WSTR (unicode in terms of SQL: 2005)
    2) derived coloumn transformation
       expression you need to use is :
        (DT_WSTR, 20) (note : 20 can be replace by your character size)
    Note:
    Above teo method create replica of your esting coloumn (default name will be copy of <coloumn name>).
    while mapping data do not map actual coloumn to the destination but select the coloumn that were created by any of above data transformer (replicated coloumn).

  • What is the size of a string data type

    Hello,
    What is the size of a string data type. Also what is the maximum size upto which a text file can grow?
    Thanks in advance
    cooldude 

    Hi cooldude,
    the size of a string is given back by the function "String size". Strings are dynamically managed in LabView.
    The max filesize is limited by the used filesystem. FAT-based systems are limited to 4GB (or was it 2GB?), other filesystems may allow more...
    Best regards,
    GerdW
    CLAD, using 2009SP1 + LV2011SP1 + LV2014SP1 on WinXP+Win7+cRIO
    Kudos are welcome

  • I recently have ipad but before i sell it i made a back up of it and by an iphone when i put all the date on my iphone some files and software did not install is there anything i can do to recover the lost data? please help

    i recently have ipad but before i sell it i made a back up of it and by an iphone when i put all the date on my iphone some files and software did not install is there anything i can do to recover the lost data? please help

    I don't think you're on iOS 5, I think you're using iOS 6.  That's the latest version.
    Unless you've used iCloud to back up your documents, you won't be able to restore them.  And for future reference, you don't have to uninstall Pages to update your iPad anymore.  Sorry about this.

  • About string data type

    Hi
    Maximum number of characters that a string data type accepts in Java.
    Thanks..

    The next may give a rough test.
    public static void main(String[] args) throws Exception{
    int factor= Integer.parseInt(args[0]);
    char[] data = new char[Integer.MAX_VALUE/factor];// note: integer division
    for(int k=0;k<data.length;k++)  data[k]=(char)0x30;
    String s=new String(data);
    System.out.println(Integer.toString(s.length()));
    }

  • Hello, okay? since then, was robbed today, and my find my    iphone this down, please tell me if he has a way to locate the computer, I need the iphone again, it has many important data it please help me

    hello, okay? since then, was robbed today, and my find my
      iphone this down, please tell me if he has a way to locate the computer, I need the iphone again, it has many important data it please help me

    It's gone and you most likely are not getting it back.
    If you had important info on it, you should have made backups so you would not lose the data.

  • I ordered an iphone 6 plus 64 gig space gray on 9/19/14. I still have not gotten any information on the ship date. Please help verizon!!!

    I ordered an iphone 6 plus 64 gig space gray on 9/19/14. I still have not gotten any information on the ship date. Please help verizon!!!

        urdea123,
    You called and help has arrived. Congrats on the new phone. The iPhone 6 Plus 64GB space gray device is shipping on 11/7. You can always check your order here http://vz.to/1qKj0Rx
    RobinD_VZW
    Follow us on twitter @VZWSupport

  • Entry Point Not Found, AVCFAssestCreateWithByteStremAndOptions could not be located in the dynamic link libary AVFoundationCF.dll.  Please help!

    Entry Point Not Found, AVCFAssestCreateWithByteStremAndOptions could not be located in the dynamic link libary AVFoundationCF.dll.  Please help!
    have followed all the touble shooting links to deleate temp files, unistal ect. still not working! when I reinstalled I got an error code. Please help
    I am running Windows 7.

    It says "error 7, windows error 127"
    Please help!

  • Just installed OS Yosemite, and now I can't open Illustrator CS6. Asks me to update my Java, but I check and my Java is up to date. Please help!

    Just installed OS Yosemite, and now I can't open Illustrator CS6. Asks me to update my Java, but I check and my Java is up to date. Please help!

    Some people have reported reinstalling the Apple 2014-001 Java update has helped.
    See thread 7 here  Illustrator CC 2014 crashes on startup after Yosemite 10.10 upgrade today.

  • I don't have wifi connection.I need to update my software to ios 8.0.2.How can I download it using cellular data?Please help

    I don't have wifi connection.I need to update my software to ios 8.0.2 using cellular data.How can I download using cellular data?.Please help.

    There are often places to go which have free WiFi ie coffee shops, shopping malls, fast-food places.
    You can connect the phone to your computer & download/update via iTunes if you have one.

Maybe you are looking for

  • Unable to Re-download Adobe Acrobat X Pro - Order History is Empty

    The SSD on my laptop computer failed, so after I got a new one and got Windows 7 loaded I logged into my Adobe account to re-download Acrobat X Pro.  I purchased the product in March 2012, and Adobe.com shows I have a registered copy of the product. 

  • How to publish a local audio stream using NetStream?

    As all we know, if we want to publish a stream to FMS or Red5, we can code like below: var nc:NetConnection = new NetConnection(); nc.connect("rtmp://localhost/myApp"); var ns:NetStream = new NetStream(nc); ns.attachAudio(Microphone); ns.publish("aud

  • No Sleep/Wake button option under Settings

    I just had my ipod nano replaced, and there is no Sleep/Wake button option under Settings anywhere (In Music, etc.) I had no problems finding it and setting it up in my previous nano (need to useit for the next song option when I work out.) Did Apple

  • Can not copy spaces from some pdf file

    https://sites.google.com/site/sharedacrobat/data/cannot_copy_text.pdf I'm trying to copy some text from the above pdf file (with mouse and ctrl-C). But many spaces are missing (e.g., the following text). Is it a problem with acrobat. Or it is a probl

  • Toshiba A660-1 General Problems

    Hello there, My name is Diego and I have had some troubles with my computer lately. I recently did a backup of all my information and reinstalled Windows 7 on my Satellite A660-1 since it was running slow. However I have had some problems since then,