Sort table field from type character

Hi all,
I have a database table where a specific field (e. g. ID) is specified as character.
This field contains a number.
Now I want to get the highest ID which is available in the database table.
This statement does not work, because the max value is only determined by the first character.
SELECT single * FROM <table>
  INTO <workarea>
  WHERE id = (
    SELECT MAX( id ) FROM <table>
Example: Entries in database table
ID
1
10
2
3
The max value is here then 3 and not 10. -> only the first character will be checked
Any ideas?
regards

>
VENKATESWARAREDDY D wrote:
> Hai,
>
> Here matnr is a character data type.
>
> data matnr type matnr.
>
> select max( matnr ) from mara into matnr.
>
> write: matnr.
>
>
>
> Regards,
> Venkat
Never forget: if a materialno. consist of digits only, the database value will have leading zeroes. And then it will work. In this case there are no leading zeroes, so character 3 is bigger than 10.
If there were leading zeroes, then 10 would be bigger then 03.

Similar Messages

  • Help with writing and retrieving data from a table field with type "LCHR"

    Hi Experts,
    I need help with writing and reading data from a database table field which has a type of "LCHR". I have given an example of the original code but don't know what to change it to in order to fix it and still read in the original data that's stored in the LCHR field.
    Basically we have two Function modules, one that saves list data to a database table and one that reads in this data. Both Function modules have an identicle table which has an array of fields from type INT4, CHAR, and type P. The INT4 field is the first one.
    Incidentally this worked in the 4.7 non-unicode system but is now dumping in the new ECC6 Unicode system.
    Thanks in advance,
    C
    SAVING THE LIST DATA TO DB
    DATA: L_WA(800).
    LOOP AT T_TAB into L_WA.
    ZDBTAB-DATALEN = STRLEN( L_WA ).
    MOVE: L_WA to ZDBTAB-RAWDATA.
    ZDBTAB-LINENUM = SY-TABIX.
    INSERT ZDBTAB.
    READING THE DATA FROM DB
    DATA: BEGIN OF T_DATA,
                 SEQNR type ZDBTAB-LINENUM,
                 DATA type ZDBTAB-RAWDATA,
               END OF T_TAB.
    Select the data.
    SELECT linenum rawdata from ZDBTAB into table T_DATA
         WHERE repid = w_repname
         AND rundate = w_rundate
         ORDER BY linenum.
    Populate calling Internal Table.
    LOOP AT T-DATA.
    APPEND T_DATA to T_TAB.
    ENDLOOP.

    Hi Anuj,
    The unicode flag is active.
    When I run our report and then to try and save the list data a dump is happening at the following point
    LOOP AT T_TAB into L_WA.
    As I say, T_TAB consists of different fields and field types whereas L_WA is CHAR 800. The dump mentions UC_OBJECTS_NOT_CONVERTIBLE
    When I try to load a saved list the dump is happening at the following point
    APPEND T_DATA-RAWDATA to T_TAB.
    T_DATA-RAWDATA is type LCHR and T_TAB consists of different fields and field types.
    In both examples the dumps mention UC_OBJECTS_NOT_CONVERTIBLE
    Regards
    C

  • How to empty XE database and re-create tables/fields from scratch?

    Hi,
    I've installed XE database to port my VB6/Access application to it, and I know that XE is limited to one single database, so far so good. But I want to erase everything from inside this default database to create my own tables/fields from scratch. How can I do that?
    I just want to have one single database file with some tables/fields inside it, and nothing else. The rest will be done through VB straight.
    And what is the name of the default XE database file? Where is it stored? If I make a backup of this file, can I restore it after a crash in the future by overwriting the corrupted file? Is that this simple as Access is?
    Sorry about those many questions and thanks for reading!
    Roger.

    If you want to erase everything, one solution is to uninstall Oracle XE and just to reinstall it.
    Under Windows to avoid any issue, see http://download.oracle.com/docs/cd/B25329_01/doc/install.102/b25143/toc.htm#CIHDDHJD.
    If your application is owned by a single Oracle user account, you can also run (where <schema> is the Oracle user account name):
    drop user <schema> cascade;To reinstall your application you would need to recreate the user account <schema> with the right privileges (CREATE USER ... and GRANT ...).

  • Populate dynamic table fields from internal table

    Hi,
    Im trying to populate an dynamic table , but it's giving me a few errors witch i can't solve ...
    Basically i have an internal table with te following types :
    DATA: BEGIN OF tab_docs41 OCCURS 0,
          conta TYPE bsis-hkont,
          banco TYPE t012t-text1,
          ano_3 TYPE i,
          ano_2 TYPE i,
          ano_1 TYPE i,
          jan TYPE  i,
          fev TYPE  i,
          mar TYPE  i,
          abr TYPE  i,
          mai TYPE  i,
          jun TYPE  i,
          jul TYPE  i,
          ago TYPE  i,
          set TYPE  i,
          out TYPE  i,
          nov TYPE  i,
          dez TYPE  i,
          total TYPE i,
          montante TYPE betrag11,
    END OF tab_docs41.
    and the following fieldcatalog , for the dynamic table :
    DATA : ls_fieldcat TYPE lvc_s_fcat.
      DATA: lv_period TYPE i.
      DATA str_period TYPE string.
      SUBTRACT 3 FROM ano.
      MOVE ano TO str_period.
      CLEAR ls_fieldcat.
      ls_fieldcat-fieldname = 'CONTA'.
      ls_fieldcat-seltext = 'Conta do Razão'.
      ls_fieldcat-datatype = 'HKONT'.
    *  ls_fieldcat-intlen = '10'.
      APPEND ls_fieldcat TO p_fieldcat.
    Since the internal table, tab_docs41 it's allready filled how can i pass the tab_docs41 values to the corresponding fields of the dynamic table (the move-corresponding it's not working..)
      ASSIGN fs_data->* TO <fs_1>.
      CREATE DATA new_line LIKE LINE OF <fs_1>.
    *  ASSIGN new_line->*  TO <fs_2>.
    *** Next step is to create a work area for our dynamic internal table.
      LOOP AT tab_docs41.
       ASSIGN COMPONENT 'CONTA' OF STRUCTURE  tab_docs41 TO <fs2>.
    But this last step it's not working ...
    Can anyone help me please ?
    Point's will be rewarded
    Best Regards
    Thanks in advance
    João Martins

    Looks like you have used the method CL_ALV_TABLE_CREATE=>CREATE_DYNAMIC_TABLE to create the dynamic internal table.
    You have to change the last part of the code:
    FIELD-SYMBOLS:
    <itab> TYPE STANDARD TABLE,
    <wa> TYPE ANY,
    <val> TYPE ANY .
    ASSIGN fs_data->* TO <itab>.
    CREATE DATA new_line LIKE LINE OF <itab>.
    ASSIGN new_line->*  TO <wa>.
    LOOP AT tab_docs41.
      ASSIGN COMPONENT 'CONTA' OF STRUCTURE <wa> TO <val>.
      <val> = tab_docs41-conta.
      ASSIGN COMPONENT 'BANCO' OF STRUCTURE <wa> TO <val>.
      <val> = tab_docs41-banco.
      APPEND <wa> to <itab>.
    ENDLOOP.
    BR,
    Suhas

  • Unable to access the data and table fields from handheld

    Hi,
    I've created a Testing.sdf file on the local pc using SQL Server Management Studio, creating table, fields and insert some data. in local pc i can access the the data as normal. the problem is after i moved the file to handheld device i
    cannot access the data within the table, it shown error 'Failed to retrieve data for this request. (Microsoft.SqlServer.SmoEnum)' . I tried to google it, but still got no solution.
    Thanks,

    'Name Space
    Imports System.Data.SqlServerCe
    'String Connection
    'Data Source = D:\SKUDWN3 .sdf'
    Public Sub CreateDB(ByVal StrConn As String)
            'Declaration
            Dim cn As SqlCeConnection = Nothing
            Dim cm As SqlCeCommand = Nothing
            Dim SQLEngine As SqlCeEngine = Nothing
            Dim rs As SqlCeResultSet = Nothing
            Dim rec As SqlServerCe.SqlCeUpdatableRecord = Nothing
            'Tables -
            Const TB_SKUDWN3 As String = "SKUDWN3"
            'Fields TB_SKUDWN3
            Const FL_SKUDWN3_UPC As String = "UPC"
            Const FL_SKUDWN3_SKU As String = "SKU"
            Const FL_SKUDWN3_LD As String = "LD"
            Const FL_SKUDWN3_SD As String = "SD"
            Const FL_SKUDWN3_AN As String = "AN"
            Const FL_SKUDWN3_Price As String = "Price"
            Const FL_SKUDWN3_GST_FLAG As String = "GSTFLAG"
            'Create Database
            SQLEngine = New SqlCeEngine(StrConn)
            SQLEngine.CreateDatabase()
            SQLEngine.Dispose()
            'Open Connection
            If IsNothing(cn) Then cn = New SqlCeConnection(StrConn)
            If cn.State = Data.ConnectionState.Closed Then cn.Open()
            cm = cn.CreateCommand
            'Create Table, Fields
            cm.CommandText = "CREATE TABLE " & TB_SKUDWN3 & " (" & FL_SKUDWN3_UPC & " NVARCHAR (13)," & _
                " " & FL_SKUDWN3_SKU & " NVARCHAR (9), " & FL_SKUDWN3_LD & " NVARCHAR(30)," & _
                " " & FL_SKUDWN3_SD & " NVARCHAR (18), " & FL_SKUDWN3_AN & " NVARCHAR(15), " & _
                " " & FL_SKUDWN3_Price & " NVARCHAR (10), " & FL_SKUDWN3_GST_FLAG & " BIT)"
            cm.ExecuteNonQuery()
            'Close Connection
            cm = Nothing
            If Not IsNothing(cn) Then
                If cn.State = ConnectionState.Open Then cn.Close()
                cn.Close()
                cn.Dispose()
            End If
        End Sub
    'The DB was successfully created, but after moving to Handheld the fields of table can't be accessed

  • How to find internal table fields from which table.

    Hello Experts,
    I have to use a dynamic select inner join query.
    SELECT (lv_string)
      FROM (from_tab)
      INTO CORRESPONDING FIELDS OF TABLE <fs_itab1>
      WHERE (where_tab).
    ELSEIF table_1 NE ''.
      SELECT *
      FROM (table_1)
      INTO CORRESPONDING FIELDS OF TABLE <fs_itab1>
      WHERE (where_tab).
    in that LV_string is dynamicaly select. from a structure which is a combination of say  VBAK and VBAP
    i have to
    CONCATENATE 'VBAK~' wa_fields-fname INTO str_temp.
    CONCATENATE lv_string str_temp INTO lv_string SEPARATED BY space
    CONCATENATE 'VBAP~' wa_fields-fname INTO str_temp.
      CONCATENATE lv_string str_temp INTO lv_string SEPARATED BY space.
    with there identifire....how to find that...
    Regards,
    Ketan.

    Ketan,
    I believe you CAN find this only when you are creating lv_string from your structure (or whatever it is).
    So paste that code that what is your 'structure' type and on what conditions you want to Fill lv_string from it.
    in that LV_string is dynamicaly select. from a structure which is a combination of say VBAK and VBAP
    If you have a custom or standard Structure from which you need to fill lv_string, then you should have no worries to full VBAK~ or VBAP~ because fieldnames will be always unique in any Structure and hence ~ additions are not necessarily needed.
    The issue can be in the case where you are picking few fields each from std tables VBAK and VBAP in your lv_string and
    your "(from_tab)" is an inner join condition. I believe in that case you should be able to identify VBAK~ and VBAP~ while populating lv_string itself. Also you can use DB view MASSVBAP.
    Regards,
    Diwakar

  • Abap MDM API - get table fields and types

    Hi gurus,
    dealing with a simple task for my development... I need to retrieve, for a given MDM table name, a list of field's names with their data types in Value_pair format.
    Basically, this is what RETRIEVE method does; but:
    - I don't need any value; I just need to know which fields build up the table (in order to create entries for that)... Let's say that I'm interested in the CODE and the TYPE  fields of an MDM_NAME_VALUE_PAIR structure describing each field of my MDM table.
    - I can't workaround extracting a certain index (say, the first) from the table using a RETRIEVE, as the target table could also be empty.
    How to do that?
    Thanks in advance

    Hello Binori,
    Thanks a lot for the immediate reply!
    I have connected MS SQL server mgmt studio to MAP tool, as you have already mentioned!
    How do I get access to MAP's db, since I need data from MAP's db in our application db, and our application is purely java based.
    For ex: I need data of all Operating Systems, Performance metrics, Server name, Hardware Configurations etc.
    Thanks in advance,
    Sheetal 

  • Populate a table field from selection made from drop down menu

    Hello all,
    I'm having a bit of head scratching problem that i just can't get my head around. I'm using Dreamweaver CS4
    and phpmyadmin for my site.
    I have a form that inputs a record into a table in my database.
    The form is a user picking a fantasy sports team. A user selects a player from a drop down menu.
    The players name is got from a recordset that accesses the player database, with the values coming
    from the id field and the values from the name, so a user selects a player by there name and not
    there unique id value. The code for this is as follows:
    <tr valign="baseline">
    <td nowrap="nowrap" align="right">GoalKeeper:</td>
    <td><select name="gkid_team">
    <?php
    do {
    ?>
    <option value="<?php echo $row_rs_pt_gk['gkid_gk']?>" ><?php echo $row_rs_pt_gk['gkname_gk']?></option>
    <?php
    } while ($row_rs_pt_gk = mysql_fetch_assoc($rs_pt_gk));
    ?>
    </select></td>
    What i'm trying to achieve is that when a user selects a player from the drop down menu, their price is displayed in the table cell next to the menu. The value is held in the same table of database as the names and id values. I need to do it so the page doesn't need to be refreshed so i assume i need to use some sort of javascript, php and/or maybe ajax. However with java and ajax i have very little or no experience so i'm not really sure what i'm doing. I've been on numerous forums, looked in text books and have been searching the net for hours but i can't seem to solve this problem.
    Any help or advice would really be appreciated as i just can't seem to get my head around it,
    Thanks,
    pb1uk

    can this be done??? thanks in advance annieYes.
    One way of doing it is submitting the form on change of the selected value and fetch back the query results. Have a servlet invoke the method and set the results in the request.
    Another way (not recommended) is to fetch the results corresponding to all the values in the dropdown and have it in the session. The latter solution would obviously be slow.

  • Table creation from type - Primary key with 2 columns

    Hello,
    I have to create a table from a type that I created.
    The thing is that I want to create a primary key using two column.
    Because this table is junction table.
    How can I do this ?
    CREATE TABLE CONTENT OF CONTENT_T (ID_COMP primary key, ID_CHAR_J NOT NULL PRIMAR
    Y KEY);
    Oracle return:
    CREATE TABLE CONTENT OF CONTENT_T (ID_COMP primary key,ID_CHAR_J NOT NULL PRIMARY KEY)
    ERROR at line 1:
    ORA-02260: table can have only one primary key
    So I tried:
    CREATE TABLE CONTENT OF CONTENT_T (ID_COMP,ID_CHAR_J NOT NULL PRIMARY KEY)
    ERROR at line 1:
    ORA-02338: missing or invalid column constraint specification
    Tahnk's in advance.
    Edited by: user8266437 on 29 avr. 2009 13:56
    Edited by: user8266437 on 29 avr. 2009 13:56

    SCOTT@orcl_11g> CREATE OR REPLACE TYPE content_t AS OBJECT
      2    (id_comp    NUMBER,
      3       id_char_j  VARCHAR2 (10),
      4       other_cols VARCHAR2 (10));
      5  /
    Type created.
    SCOTT@orcl_11g> CREATE TABLE CONTENT OF CONTENT_T (PRIMARY KEY (ID_COMP, ID_CHAR_J))
      2  /
    Table created.
    SCOTT@orcl_11g> INSERT INTO content VALUES (content_t (1, 'A', 'WHATEVER'))
      2  /
    1 row created.
    SCOTT@orcl_11g> COMMIT
      2  /
    Commit complete.
    SCOTT@orcl_11g> INSERT INTO content VALUES (content_t (1, 'A', 'DUPLICATE'))
      2  /
    INSERT INTO content VALUES (content_t (1, 'A', 'DUPLICATE'))
    ERROR at line 1:
    ORA-00001: unique constraint (SCOTT.SYS_C0062057) violated
    SCOTT@orcl_11g> COMMIT
      2  /
    Commit complete.
    SCOTT@orcl_11g> SELECT * FROM content
      2  /
       ID_COMP ID_CHAR_J  OTHER_COLS
             1 A          WHATEVER
    SCOTT@orcl_11g>

  • Translate table field from German to English?

    I need to translate the desc field of SLIN_DESC table. I am using 'select' statement to pull 'DESC' field. The data is stored in German. How do i translate it to English before i display the data?
    Thanks
    Nahman

    Hi Nahman,
    I think you need to have values for german in your table to get the greman content.
    But you can have an option to change repository text for a table using transaction code SE63.
    For this Click on Translation->Repository texts.
    It will display list of reposotiy text that you can do translation.
    Data Elements
    Matchcode IDs
    Matchcode Objects
    Search Helps
    Table Descriptions
    Table Types
    Type Groups
    Fixed Values for Domains
    Views
    Thanks,
    Vinay

  • Can't get table field from two different tables if named same

    select c.notes, o.notes
    from cusomters c, orders o
    :does not work in getting the RS.
    :if i change database to:
    select c.customer_notes, o.order_notes
    from cusomters c, orders o
    :then it works.
    :i make PURE DYNAMIC META SQL database
    applicaitons, and i need for abstract SQL tables.
    i have the same problem in getting
    the max values:
    select
    max(height),
    max(weight),
    max(age)
    from person_stats
    group by geographical_area

    When you select from 2 different tables you need to join them on some condition, otherwise it has no idea how to associate the 2 tables together.
    try select c.notes, o.notes from cusomters c, orders o where c.customer_id = o.customer.id or whatever the join fields are.
    For the group by I believe you have to include the field that you group by:
    select geopraphical_area, max(height), max(weight), max(age) from person_stats group by geographical_area
    give them a try
    Jamie

  • Translate table field from German to English? Info on SCI generated table?

    I need to translate the desc field of SLIN_DESC table. I am using 'select' statement to pull 'DESC' field. The data is stored in German. How do i translate it to English before i display the data? Or is there any other table which contains the description when SCI generates error/warning report. Basically i need to display error/warning description generated by SCI when it is executed. Any help will be appreciated.
    Thanks
    Nahman

    Hello Nahman
    This table appears to be a special one. When I call SE16 (logon language = EN) I see the German code descriptions like you did.
    If you look at package SLIN you will find class <b>CL_SLIN_TEST_INFO</b> which has a static method <b>DESC_GET_DESCRIPTION</b>. When I call this method for code='0000' I get the English text (<i>Program contains syntax errors</i>).
    Regards
      Uwe

  • How to read table fields form a table  having length of 7 characters

    HI all,
    could you please tell me how to read table fields from a table having length 7 characters, i have requirement that in my ztable i have 30 fields out of which 20 fields are location fields, i want to select 20 fields which have 7 characters length.
    please could any body suggest me on this issue.
    thanks,
    sre.

    hi,
    try like this
    create a data variable of type i as
    data: len type i.
    create internal table for 20 fields as
    data:begin of itab,
               fld 1 type .......
            end of itab.
    data:itab type itab1 occurs 0 with header line.
    loop at itab2. // original internal table which all fields.
    read table itab2 with index sy-tabix.
    len = strlen (itab2-fld).
    if len eq 7.
          move itab2 itab1.
          append itab1.
    endif.
    endloop.
    if helpful reward some points.
    with regards,
    Suresh.A

  • Infoobject - table field relation

    Hi All,
    is there a way to find out what infoobject is to be related to a table field from a R/3 infosource?
    For example, I was checking in infosource, and found out that table field BKPF-GJHAR is related to 0FISCPER infoobject.
    How do I know what standard infoobject is to be related to a standard table field from R/3 ?
    thanks for the Help.
    Mauricio

    Check this if it help:
    Re: What is the corresponding  BW InfoObject for MARC - ABCIN field
    Re: infoobject to field in structure
    Re: Infoobject for an R3 field

  • From which table field could we find the 'material type' of delivery items.

    Hi,
    Please kindly advise from which table field could we find the 'material type' for one delivery items??
    Thank you.

    Hi,
    You cant get the material type directly from delivery item. Pls make a joint between LIPS and MARA tables to get the same.
    In LIPS, get the material numbers of the delivery document.
    Give them in MARA to get their material types

Maybe you are looking for

  • Solution to error 200 -- "unknown error occured. (-200)"

    Open Quicktime. Windows will then configure Quicktime (the source of the problem I believe). Once configured, leave Quicktime open and open iTunes. Should open fine. After that, you should be able to open iTunes without opening Quicktime.

  • Problems and Requests

    Sir How can i get free intro tampletes for version CS3...And 1 More Thing... How can i Solve the problem of "AEGP Plugin AAF"

  • Adobe AIR on Mobile with Facebook

    I am developing an Adobe AIR app for mobile devices to work with Facebook. I am using the Adobe ActionScript API for Facebook Platform I am accessing the Facebook from Actionsctipt code as follows: FacebookMobile.init("my-numeric-app-id", initHandler

  • Migration from Essbase 7.5.1 to system 9

    Hi all, I have an immediate requirement to migrate huge essbase applications from essbase 7.5.1 to system 9. as per my knowledge, i believe that we can migrate from 7.5.1 --->9.2.0.2--->9.3.1 or EPM 11i. Anybody who have worked on the same please con

  • Read an Attachment attached within a process instance

    Hi I am using BPM 11.1.1.6, can someone tell me how do I read and parse an attachment attached within a process instance. Thank you. Regards Venkat