How to coerce data types to strings in a SELECT statement?

ABAPers,
I need to coerce column outputs to strings in a SELECT statement. Here is a pseudo example:
select ConvertToString(count(*)) from MARA
On help.sap.com, I could not find enough information on the functions that are supported within SELECT statement. I would appreciate it if someone can enlighten me on how to achive this.
Note that my real problem is that I do not know the return type of the specified columns. The columns are passed as a user-specified parameter. As I do not know the column types, I am mandating that customers specify columns that return only string type data.
Thank you in advance for your help.
Pradeep

Hi Pradeep,
Convert to string wont be possible in the SELECT statement.
What you can do is use Field Symbols. This allows to assign data types dynamically.
Field-Symbols
Best regards,
Prashant
Pls. mark points for helpful answers

Similar Messages

  • How to get data type of variable in program..

    Hi ABAP Guru.
    I need to know how to get data type of variable or any structure field.. because I got short dump when use command REPLACE ALL OCCURANCE ... with variable/structure field that has data type I or P, I think it should be used with data type CHAR only, So I need to check the data type first.
    Please give me your advice
    Thank you all.
    Nattapash C.

    data : v_value type i,
             v_char(10) type c.
    v_value = 10.
    move v_value to v_char.
    REPLACE ALL OCCURRENCES of '#' from v_char....
    Best regards,
    Prashant

  • How to change data type of attribute in caf

    hi.
    this is my problem.
    i been added a attribute in an entity service called emloyee. named "Birthday", use the data type "com.sap.caf.core.date".
    when i tried modify the entity service, i hit exception about "DST Daylight Saving Time".
    because of DST, the date will add an hour such like "1957/04/01 00:00:00.0" to "1957/04/01 01:00:00.0", and com.sap.caf.core.date will throw an exception.
    is anyone had same problem like me?
    how to fixed it(if passable)?
    and, how to change data type?
    thanks.

    Hi Sruthi,
    all you need to do on this is open the report go to the parameters, select the parameter that you wish to change and click "Edit". This will allow you to change thefield to a date rather than a date time.
    Regards,
    Noel

  • Problem in using a structure with a field of  data type 'RAW STRING'

    Friends
    I have written a ZBAPI that imports a structure which has 5 fields. I have defined this in the IMPORT tab of Tr.Code <SE37>.  One of the field of this structure is of data type 'RAW STRING'.
    When I try to activate this BAPI, I get an error message as follows:
    Function Module ZBAPI_ADD_CONFIG_DNA
    "ZDAMPER_CON_DNA" Must be a flat structure. You cannot use internal table
    strings, references, or structures as components.
    Where ZDAMPER_CON_DNA is the table name that I am using.
    FOR TESTING PURPOSE, WHEN I CHANGE THE DATA TYPE FROM 'RAW STRING' TO JUST A CHAR OF LENGHT 5, IT WORKS FINE.
    Here is the source code of the simple BAPI that i am trying to activate.
    FUNCTION ZBAPI_ADD_CONFIG_DNA.
    ""Local Interface:
    *"  IMPORTING
    *"     VALUE(CONFIG_DNA_DATA) TYPE  ZCONFIG_DNA_STRUCTURE
    *"  EXPORTING
    *"     VALUE(MESSAGE) TYPE  ZRETURNMESSAGE
    tables: ZDAMPER_CON_DNA.
        ZDAMPER_CON_DNA-CONFIG_ID       =     CONFIG_DNA_DATA-CONFIG_ID.
        ZDAMPER_CON_DNA-STRING_NAME     =     CONFIG_DNA_DATA-STRING_NAME.
        ZDAMPER_CON_DNA-STRING_FORMAT   =     CONFIG_DNA_DATA-STRING_FORMAT.
        ZDAMPER_CON_DNA-STRING_VALUE    =     CONFIG_DNA_DATA-STRING_VALUE.
        ZDAMPER_CON_DNA-OBJECT_NAME     =     CONFIG_DNA_DATA-OBJECT_NAME.
        INSERT ZDAMPER_CON_DNA.
        MESSAGE-SUBRC = sy-subrc.
        if sy-subrc = 0.
            MESSAGE-RETURNMESSAGE = 'SuccessfullyInserted'.
        else.
            MESSAGE-RETURNMESSAGE = 'Insert Failed'.
        endif.
    =============
    ANY KIND OF FEED BACK WILL BE HIGHLY APPRECIATED.
    THANKS
    RAM

    Hi ram,
    there is no data element exists with the name RAW STRING ,
    but check one of these names..
    Data element                   Short text
    C2S_RAWSTRING                  C2-Server: Data Element of Type Rawstring
    N2_RAWSTRING                   Byte String of Variable Length
    QISRDRAW_STRING                Data in Format RAW Character String
    RCF_RAWSTRING                  Rawstring
    RPAP_TEMPLATE_RAWSTRING        Blob of Template File
    RSRAWSTRING                    Raw String
    RSRD_RAWSTRING                 Binary Content in the Broadcasting Framework
    SWH_RAWSTRING                  Workflow: Data Type RAWSTRING
    WDR_RAWSTRING                  Byte Sequence of Variable Length
    <REMOVED BY MODERATOR>
    venkat.
    Edited by: Alvaro Tejada Galindo on Mar 7, 2008 5:15 PM

  • How to crete data type from XSD

    Hi All,
    can anyone tell me ...how to create data type from agiven xsd.
    I need urgently....
    thanks in advance....

    import this XSD, load this in your mapping editor and then use this to crate the datatype manually.
    Or, use XML spy, load this XSD and then you should be able to see the Structure, or,
    Look into the XSD data and decipher things yourself
    Regards
    Bhavesh

  • How to check data type of the field symbol at run time

    Hi,
    My code is as following:
          LOOP AT <fs> ASSIGNING <wa_covp_ext>.
            ASSIGN COMPONENT 86 OF STRUCTURE <wa_covp_ext> TO <f_zzname>.
            IF sy-subrc = 0.
              ASSIGN COMPONENT 158 OF STRUCTURE <wa_covp_ext> TO <f_pernr>.
              IF sy-subrc = 0.
                  SELECT SINGLE sname INTO <f_zzname> FROM pa0001
                                WHERE pernr = <f_pernr>
                                AND endda GE sy-datum
                                AND begda LE sy-datum.
             ENDIF.
          ENDIF.
        ENDLOOP.
    This query is giving dump when <f_zzname> is type P length 8 and decimals 2, because it tries to put PA0001-sname into it which is type C length 30. So I want to check the type of <f_zzname> before the select statement. If it is character 30, then I will write the select statement else not.
    How to check data type of the field symbol at run time? If it's not possible, then can somebody suggest a workaround? Thanks.

    check this ...
    write describe statement  ...
    field-symbols : <f_zzname> .
    data : sname like pa0001-sname,
           typ(10).
    assign sname to  <f_zzname>.
    describe  field <f_zzname> type typ.
    write : typ. <-- typ contains character type in this case ..
    U can check if typ is of character(C) if so .. write the select statement ...

  • How to find the number of fetched lines from select statement

    Hi Experts,
    Can you tell me how to find the number of fetched lines from select statements..
    and one more thing is can you tell me how to check the written select statement or written statement is correct or not????
    Thanks in advance
    santosh

    Hi,
    Look for the system field SY_TABIX. That will contain the number of records which have been put into an internal table through a select statement.
    For ex:
    data: itab type mara occurs 0 with header line.
    Select * from mara into table itab.
    Write: Sy-tabix.
    This will give you the number of entries that has been selected.
    I am not sure what you mean by the second question. If you can let me know what you need then we might have a solution.
    Hope this helps,
    Sudhi
    Message was edited by:
            Sudhindra Chandrashekar

  • String compare in select statement

    Hi All,
    i have a problem in select statement. i have a name field in my selection screen, i am using name field to comapre string in my select statement, but i am not getting the resule can anyone suggest me on this . please find my code below,s_name1 is my select option name.
    IF s_name1-low IS NOT INITIAL.
    LOOP AT S_NAME1.
      CONCATENATE s_name1-low '%' INTO s_name1-low.
      TRANSLATE s_name1-low TO UPPER CASE.
      s_name1-option = 'CP'.
      MODIFY s_name1.
    ENDLOOP.
    ENDIF.
    SELECT lifnr land1 name1 ort01 ort02 pfach pstl2 pstlz regio stras
             erdat ernam ktokk loevm sperr sperm sperz nodel
        INTO (gs_vendor-vendor_num, gs_vendor-land1, gs_vendor-name,
              gs_vendor-ort01, gs_vendor-ort02, gs_vendor-pfach,
              gs_vendor-pstl2, gs_vendor-pstlz, gs_vendor-regio,
              gs_vendor-stras, gs_vendor-created_on, gs_vendor-created_by,
              gs_vendor-account_gp, gs_vendor-deletion_flag,
              gs_vendor-central_post, gs_vendor-ctr_purch_block,
              gs_vendor-payment_block, gs_vendor-central_deletion)
        FROM  lfa1
             WHERE  lifnr  IN s_lifnr
             AND    name1  LIKE s_name1
    Start of Change G9007789 03/12/2008 - D01K946651
    Additional selection criteria added for City and Region
             AND    ort01  IN s_ort01
             AND    regio  IN s_regio
    End of Change G9007789 03/12/2008 - D01K946651
             AND    ktokk  IN s_ktokk
             AND    ( ktokk  NE 'ZHMT' AND ktokk NE 'ZTER' ).
        APPEND gs_vendor TO gt_vendor.
        CLEAR gs_vendor.
      ENDSELECT.

    Hi,
    Have you checked whether you have given proper events.
    Check this code below.
    AT selection screen output. "Change here
    IF s_name1-low IS NOT INITIAL.
    LOOP AT S_NAME1.
    CONCATENATE s_name1-low '%' INTO s_name1-low.
    TRANSLATE s_name1-low TO UPPER CASE.
    s_name1-option = 'CP'.
    MODIFY s_name1.
    ENDLOOP.
    ENDIF.
    Start-of-Selection. " change here
    SELECT lifnr land1 name1 ort01 ort02 pfach pstl2 pstlz regio stras
    erdat ernam ktokk loevm sperr sperm sperz nodel
    INTO (gs_vendor-vendor_num, gs_vendor-land1, gs_vendor-name,
    gs_vendor-ort01, gs_vendor-ort02, gs_vendor-pfach,
    gs_vendor-pstl2, gs_vendor-pstlz, gs_vendor-regio,
    gs_vendor-stras, gs_vendor-created_on, gs_vendor-created_by,
    gs_vendor-account_gp, gs_vendor-deletion_flag,
    gs_vendor-central_post, gs_vendor-ctr_purch_block,
    gs_vendor-payment_block, gs_vendor-central_deletion)
    FROM lfa1
    WHERE lifnr IN s_lifnr
    AND name1 LIKE s_name1
    Start of Change G9007789 03/12/2008 - D01K946651
    Additional selection criteria added for City and Region
    AND ort01 IN s_ort01
    AND regio IN s_regio
    End of Change G9007789 03/12/2008 - D01K946651
    AND ktokk IN s_ktokk
    AND ( ktokk NE 'ZHMT' AND ktokk NE 'ZTER' ).
    APPEND gs_vendor TO gt_vendor.
    CLEAR gs_vendor.
    ENDSELECT.
    Reward if helpful.
    Regards.

  • How to determine data type of cell in Excel file

    I have a company standard Excel file that needs to be read to determine what tests to run.  I have no control over its format.  I need to be able to tell what the data type is in order to read it using the LabView sample code.  It is a hodge poge of numbers and strings.  Some of the numeric fields are formated as hex while some are floating point.  There does not appear to be a vi that I can call to determine info about the cell formating.  As I remember it, the Windows Active X control for accessing Excel support that.  I really was hoping to avoid dealing with the Active X control for Excel directly.
    Any help/ideas?
    Outputting it in CSV or similar is not an option.
    Solved!
    Go to Solution.

    If you have to deal with Excel directly, I don't see how you're going to get around using Active X.
    MSDN page on using ActiveX

  • FLEX- how to serialize date type to null in web service call

    Does anyone know how to get actionscript to render a null date value '000:00:00T00:00:00' into a SOAP xml structure? I am calling a commercial web service that exposes data structures. I use one of these data structures as a parameter to a method call in the web service. The data structure has about 12 date fields and I need most of them to be null in the resulting database. The WSDL/SOAP force me to populate these fields with a date type. I can't figure out how to populate a date variable with a NULL value. The closest value I can get is '1899-11-30T00:00:00Z'. Below is the code I am using:
    var dateStr:String = "0000-00-00T00:00:00+";
    var emptyDate:Date = DateUtil.parseW3CDTF(dateStr);
    newReqData.DateTimeInit = emptyDate;
    When calling this same web service with a .Net client, it automatically puts in the null date value of '000:00:00T00:00:00' into the xml for me, if I don't populate the date field in the data structure.
    Any help would be appreciated.

    Hi,
    Thanks frank.
    I already check this link before posting this so if you have any other link then kindly reply.
    Regards,
    Devang

  • How to define data type

    hi all,
    I wana make a data type of this form
      Employee_MT     0..1
        EmpRec     0..Unbounded
            EmployeeId     0..1
            FullName     0..1
            AddressLine1     0..1
    but then im not able to maintain it as it is not accepting the attribute as element.
    i wana insert a new line at alower virson but the catagory should be element. but its comming as
    attribute. how to do it.

    Hi,
    If you want the same below DT.
    copy it and import as XSD.
    <?xml version="1.0" encoding="ISO-8859-1"?>
    <xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns="Http://Namespace.com" targetNamespace="Http://Namespace.com">
         <xsd:complexType name="Employee">
              <xsd:sequence>
                   <xsd:element name="Employee_MT" type="xsd:string" minOccurs="0" maxOccurs="unbounded">
                        <xsd:annotation>
                             <xsd:appinfo source="http://sap.com/xi/TextID">
                             131f861027e511dd8b640016e69bcda4
                             </xsd:appinfo>
                        </xsd:annotation>
                   </xsd:element>
                   <xsd:element name="EmpRec" type="xsd:string" minOccurs="0" maxOccurs="unbounded">
                        <xsd:annotation>
                             <xsd:appinfo source="http://sap.com/xi/TextID">
                             131f861127e511dda4e80016e69bcda4
                             </xsd:appinfo>
                        </xsd:annotation>
                   </xsd:element>
                   <xsd:element name="EmployeeId" type="xsd:string" minOccurs="0">
                        <xsd:annotation>
                             <xsd:appinfo source="http://sap.com/xi/TextID">
                             131f861227e511ddcc380016e69bcda4
                             </xsd:appinfo>
                        </xsd:annotation>
                   </xsd:element>
                   <xsd:element name="FullName" type="xsd:string" minOccurs="0">
                        <xsd:annotation>
                             <xsd:appinfo source="http://sap.com/xi/TextID">
                             131f861327e511dd9b560016e69bcda4
                             </xsd:appinfo>
                        </xsd:annotation>
                   </xsd:element>
                   <xsd:element name="AddressLine1" type="xsd:string" minOccurs="0" maxOccurs="0">
                        <xsd:annotation>
                             <xsd:appinfo source="http://sap.com/xi/TextID">
                             131f861427e511ddab930016e69bcda4
                             </xsd:appinfo>
                        </xsd:annotation>
                   </xsd:element>
              </xsd:sequence>
         </xsd:complexType>
    </xsd:schema>
    Change the Name space.
    Regards,
    Ramesh.

  • Converting premitive data types into strings

    Hello everybody,
    I have a small doubt. Is it possible to convert all data types like int, boolean etc to strings. I know it is possible to convert them individually. But I would like to have it a common method to convert them all. Because I am reading the whole line, so it is taking as strings. I am unable to read their original data types, all are reading as strings.
    Can anybody tell me how to solve this problem?
    Thank you in advance,
    Kashi.

    Hi all,
    Thanx for your answers. But as I told you before I don't know the exact data type of those. Because I am reading whole file by using DataInputStream's readLine() method. It returns the whole line as String. If there are any integer or boolean etc, it converts them as strings. So I could not read the exact data type of them.
    for example:
    int a = 10;
    boolean b = true;
    String str = "The Values are" + a + b;
    this code is in one file. If I read this file from another file, the line
    String str = "The Values are" + a + b;
    reads as a string, but I couldn�t get the 'a' as ineger and 'b' as boolean. it gives they are of strings.
    Thanx,
    Kashi.

  • Determine data type of string field

    I am trying to determine the data type of input strings in a data flow task.  For each column in the input (all of which are strings) I want to sample X number of records, try to cast them as money, date, boolean, etc and if 100% of X records pass then
    use the first data type that passes the test.  I looked into row sample but this doesn't appear to be the right data flow task.  Can anyone point me in the right direction?
    Thanks!

    You have two tasks:  find the datatype by looking at X rows; cast all rows to the popular datatype.
    What I use is the TryParse method that occurs on several datatypes in .Net (http://msdn.microsoft.com/en-us/library/f02979c7(v=vs.110).aspx).  It returns true if it parses
    and false if it doesn't.  I have used this in a profiling package that reads a CSV and stores counts of values that can be converted to different datatypes.
    The second piece is trickier.  If you can afford, I would add a second dataflow.  The first dataflow looks at a sample of the data and determines the datatype. You assign that to a variable.  Then the second one has a derived column that has
    a set of derived columns, each with a formula like this:
    @DataType == "Int"?(DT_I4)[Column]:NULL(DT_I4)
    Russel Loski, MCT, MCSE Data Platform/Business Intelligence. Twitter: @sqlmovers; blog: www.sqlmovers.com

  • How to change data type of input parameter

    Hi
    In my procedure i declared the data type of "Value Date" Input parameter as Date where as in CR it is showing data type as "Date Time". Can any one please specify how to change to Date.
    While prompting for input parameter in description it is showing message as
    Please enter Date time in format"yyy-mm-dd hh:mm:ss" . To change the content selected "format field" option. But is there any way to change input parameter data type.
    Please suggest how to change.
    Thanks Sruthi

    Hi Sruthi,
    all you need to do on this is open the report go to the parameters, select the parameter that you wish to change and click "Edit". This will allow you to change thefield to a date rather than a date time.
    Regards,
    Noel

  • How to convert Date type

    I have a JSP to read the date value and use it to update the corresponding column in the table. In the JSP, the data type returned from request.getParameter("hiredate") is java.util.Date. Unfortunately, the CachedRowSet requires the java.sql.Date type. How can I convert the java.util.Date type to java.sql.Date type? Please advise,thanks.
    SK

    SK,
    This is how I do it:
    java.util.Date utilDate = new java.util.Date();
    long millis = utilDate.getTime();
    java.sql.Date sqlDate = new java.sql.Date(millis);Good Luck,
    Avi.

Maybe you are looking for

  • Can you trade in your ipod touch 5th gen for a ipod touch 6th gen

    I can't wait for the iPod 6 to come out, and I am wondering if you're able to trade in your 5th gen for the 6th gen? I've only had my iPod Touch 5g for a year and there are little to no scratches. How much of credit would I get for it? Also, I still

  • False low ink warning on the 220 Black cartridge

    Every time I get a low ink warning on the black PGBK 220 cartridge, upon visual inspection, the cartridge still contains approximately 20-25% of the ink.  Non-OEM cartidges especially have a lot a ink left.  Makes me think there's a Canon conspiracy

  • Itunes cant find track/album info on GRACENOTE DATABASE?

    Whenever I import songs the tracks end up as 'track 1, track2' etc. I have itunes 10.6 installed and all correct settings checked. Does anyone know how to solve this? Thanks

  • PSE 9 - Importing photos into Organizer

    I have just upgraded from a previous version of PSE and none of my photos from the hard drive are in Organizer. Organizer only has a handful of photos - mainly I think from those recent shots which I have edited over in the Editor. I have spent ages

  • Can You Add Places To Events?

    Hi, I'm wondering if it's possible to a certain place to an event or group of photo's in iPhoto 11? I can't seem to find the option at all? I don't particularly want to go through all my photo's one by one adding a place as my photo's are set into gr