Trim field's preceeding blank spaces in select statement

Dear Gurus,
  I have a select query like this.
  DATA : znormt TYPE NORMT.
  select normt into znormt from mara where normt EQ  Mymatnr.
Mymatnr is coming from one of the Z table and the field contains 3 preceding spaces. Can you please tell me how I can trim the spaces in the select statement to get the result. I am looking for something like this.
  select normt into znormt from mara where normt EQ  ltrim(rtrim(Mymatnr)).
Appreciate your inputs.
Thanks!
Surya.

Run it through FM CONVERSION_EXIT_MATN1_OUTPUT thusly:
CALL FUNCTION 'CONVERSION_EXIT_MATN1_OUTPUT'
  EXPORTING
    input  = mymatnr
  IMPORTING
    output = mymatnr.
SELECT normt
  INTO znormt
  FROM mara
  WHERE normt EQ mymatnr.
Rob

Similar Messages

  • Specify database field's name dynamically in a select statement

    Hi to all!!
    I have the following problem:
    I got a paraneters statement where the user is to choose the month of the year,once i have the month, i need to make a query on a database(select field_name) of a field whose name deppend on the month that the user chose before, is it possible?
    What I need? I think i can do it using field simbols but I've never worked with field simbols and I have no time to learn it now.
    Thanks everybody

    Hi,
    <b>Below code is the Simple one:</b>
    <b>DATA: DYN_FIELD(15)
    SELECT single (DYN_FIELD)
    into corresponding fields of <IT_TABLE>
    from <TABLE> where XXX = YYY.</b>
    This is the complex program, have a look at it ...
    REPORT zdany_dynamic_select.
    * We use some parameters to dynamically control the select, this is not very
    * clever but this is just a test program !!
    PARAMETER : p_tabnam TYPE tabname DEFAULT 'SFLIGHT',
                p_selfl1 TYPE edpline DEFAULT 'CARRID',
                p_selfl2 TYPE edpline DEFAULT 'CONNID',
                p_selfl3 TYPE edpline DEFAULT 'FLDATE',
                p_selfl4 TYPE edpline DEFAULT 'PRICE',
                p_selfl5 TYPE edpline DEFAULT 'CURRENCY',
                p_where1 TYPE edpline DEFAULT 'PRICE > 300',
                p_where2 TYPE edpline DEFAULT 'AND CURRENCY = ''EUR'''.
    FIELD-SYMBOLS : <lt_outtab> TYPE ANY TABLE,
                    <ls_outtab> TYPE ANY,
                    <l_fld> TYPE ANY.
    DATA: lt_where    TYPE TABLE OF edpline,
          lt_sel_list TYPE TABLE OF edpline,
          lt_group    TYPE TABLE OF edpline,
          l_having    TYPE string,
          l_wa_name   TYPE string,
          l_sel_list  TYPE edpline,
          dref        TYPE REF TO data,
          itab_type   TYPE REF TO cl_abap_tabledescr,
          struct_type TYPE REF TO cl_abap_structdescr,
          elem_type   TYPE REF TO cl_abap_elemdescr,
          comp_tab    TYPE cl_abap_structdescr=>component_table,
          comp_fld    TYPE cl_abap_structdescr=>component.
    TYPES: f_count TYPE i.
    * Creation of the output table including a non standard field, f_count
    * see ABAP FAQ #14 for more information on this topic
    struct_type ?= cl_abap_typedescr=>describe_by_name( p_tabnam ).
    elem_type   ?= cl_abap_elemdescr=>describe_by_name( 'F_COUNT' ).
    comp_tab = struct_type->get_components( ).
    * We remove the unnecessary fields
    LOOP AT comp_tab INTO comp_fld.
       IF comp_fld-name <> p_selfl1 AND
          comp_fld-name <> p_selfl2 AND
          comp_fld-name <> p_selfl3 AND
          comp_fld-name <> p_selfl4 AND
          comp_fld-name <> p_selfl5.
             DELETE TABLE comp_tab WITH TABLE KEY name = comp_fld-name.
       ENDIF.
    ENDLOOP.
    comp_fld-name = 'F_COUNT'.
    comp_fld-type = elem_type.
    APPEND comp_fld TO comp_tab.
    struct_type = cl_abap_structdescr=>create( comp_tab ).
    itab_type   = cl_abap_tabledescr=>create( struct_type ).
    l_wa_name = 'l_WA'.
    CREATE DATA dref TYPE HANDLE itab_type.
    ASSIGN dref->* TO <lt_outtab>.
    CREATE DATA dref TYPE HANDLE struct_type.
    ASSIGN dref->* TO <ls_outtab>.
    * Creation of the selection fields and the "group by" clause
    APPEND p_selfl1 TO lt_sel_list.
    APPEND p_selfl1 TO lt_group.
    APPEND p_selfl2 TO lt_sel_list.
    APPEND p_selfl2 TO lt_group.
    APPEND p_selfl3 TO lt_sel_list.
    APPEND p_selfl3 TO lt_group.
    APPEND p_selfl4 TO lt_sel_list.
    APPEND p_selfl4 TO lt_group.
    APPEND p_selfl5 TO lt_sel_list.
    APPEND p_selfl5 TO lt_group.
    APPEND 'COUNT(*) AS F_COUNT' TO lt_sel_list.
    * creation of the "where" clause
    APPEND p_where1 TO lt_where.
    APPEND p_where2 TO lt_where.
    * Creation of the "having" clause
    l_having = 'count(*) >= 1'.
    * THE dynamic select
    SELECT          (lt_sel_list)
           FROM     (p_tabnam)
           INTO CORRESPONDING FIELDS OF TABLE <lt_outtab>
           WHERE    (lt_where)
           GROUP BY (lt_group)
           HAVING   (l_having)
           ORDER BY (lt_group).
    * display of the results
    LOOP AT <lt_outtab> ASSIGNING <ls_outtab>.
       LOOP AT comp_tab INTO comp_fld.
          ASSIGN COMPONENT comp_fld-name OF STRUCTURE <ls_outtab> TO <l_fld>.
          WRITE: <l_fld>.
       ENDLOOP.
       SKIP.
    ENDLOOP.
    Have a look at the link, this link will have lot of examples :-
    http://www.susanto.id.au/papers/DynOpenSQL.asp
    Regards
    Sudheer

  • Automatic trimming of blank spaces

    Hello,
    I noticed that Oracle Forms will remove all blank spaces from a text field automatically (if the text field contains only blank spaces).
    Is this controlled by a specific setting ?
    Thanks

    Hello,
    No,i do not need those spaces.
    But i was asking if this can be changed or not.

  • Using TRIM function in select statement

    Hi All,
    I'm using the TRIM function in my select statement to eliminate the white spaces.
    But while using in select the TRIM function is not working in SQL*PLUS client(The query returns the white spaces also)
    Kindly provide some pointers regarding the issue.........
    I want to get only the data without the spaces in select statement
    Regards,
    Mohan

    Hi, Mohan,
    SQL*Plus always pads columns to make them line up nicely.
    If you have a column declared as VARCHAR2 (20), then SQL*Plus will normally display 20 characters for that column, even in the maximum actual length is, say, 5 (or even if the column always happens to be NULL).
    If you want the output to include only the actual data, without the padding that SQL*Plus adds, then concatenate all the columns into one big string column.
    People often do something like the following to generate a CSV file, with no exta spaces:
    SELECT       TO_CHAR (empno)
    || ',' || ename
    || ',' || job
    || ',' || TO_CHAR (deptno)
    || ',' || TO_CHAR (hiredate, 'DD-Mon-YYYY')     AS all_data
    FROM          scott.emp;

  • Blank space is not taking in change bdc (cr02)

    Hi,
    I am working on a change bdc for cr02 tcode. i am changing the data of particular work center. what i want in some fields i need blank space as it had already some data. so that in external file i made it blank but  while uploading data the previous data is not changing to blank space , it is as before. i tried giving 0 or 1 for that field but it is not picking because it is a formula field and in its table 0 or 1 is not available.
    so please give some solution to make that field blank  . it is a urgent bdc and datas are huge.
    Regards
    Banaja

    See if you can clear that in online mode..that is directly in CR02. If you cannot clear them in online mode, you probably will not be able to do that in BDC. It would need some config change by the functional analyst.
    But if you can clear & save it in CR02 and see it clear when you come to this work center again later, you can do it in BDC too..
    Try this eg :
    perform bdc_field       using 'RF02D-KTONR(01)'
    FORM BDC_FIELD USING FNAM FVAL.
      IF FVAL <> NODATA.
        CLEAR BDCDATA.
        BDCDATA-FNAM = FNAM.
        BDCDATA-FVAL = FVAL.
        APPEND BDCDATA.
      ENDIF.
    ENDFORM.

  • SELECT statement takes long time

    Hi All,
    In the following code, if the T_QMIH-EQUNR contains blank or space values ,SELECT statement takes longer time to acess the data from OBJK table. If it T_QMIH-EQUNR contains values other than blank, performance is good and it fetches data very fast.
    Already we have indexes for EQUNR in OBJK table.
    Only for blank entries , it takes much time.Can anybody tell why it behaves for balnk entries?
    if not T_QMIH[] IS INITIAL.
            SORT T_QMIH BY EQUNR.
            REFRESH T_OBJK.
            SELECT EQUNR OBKNR
              FROM OBJK INTO TABLE T_OBJK
              FOR ALL ENTRIES IN T_QMIH
              WHERE OBJK~TASER = 'SER01' AND
             OBJK~EQUNR = T_QMIH-EQUNR.
    Thanks
    Ajay

    Hi
    You can use the field QMIH-QMNUM with OBJK-IHNUM
    in QMIH table, EQUNR is not primary key, it will have multiple entries
    so to improve the performance use one dummy internal table for QMIH  and sort it on EQUNR
    delete adjacent duplicates from d_qmih and use the same in for all entries
    this will improve the performance.
    Also use the fields in sequence of the index and primary keys also in select
    if not T_QMIH[] IS INITIAL.
    SORT T_QMIH BY EQUNR.
    REFRESH T_OBJK.
    SELECT EQUNR OBKNR
    FROM OBJK INTO TABLE T_OBJK
    FOR ALL ENTRIES IN T_QMIH
    WHERE  IHNUM =  T_QMIH-QMNUM
    OBJK~TASER = 'SER01' AND
    OBJK~EQUNR = T_QMIH-EQUNR.
    try this and let me know
    regards
    Shiva

  • Select statement on cube

    Hi
    I am writing a routine (select statement) on the characterstics which has to get the data from other cube.
    My scenairo:
    Extracting the data from the flat file.
    In the cube i have a characteristics for which I need to pull the data from other cube.
    Routine:
    Select single xxxx into result from /bic/fsd_c03
    where bill_no = source_fields_rule-bill_no..
    When i click on the check, I am getting the following error" Unknown column name "XXXX" until runtime, you cannot specify a
    field list.
    Can we write select statements on cubes? or is there any issue in my routine?
    Thanks
    Annie

    Hi Annie,
    I would suggest not because of the following reasons:
    1) The way data is stored in the Info cube is multi-dimensional, which means to say that all the characteristic are grouped into dimensions and they result in unique dimension ID's which connect to your fact table (/BI0/F*)
    This would mean, your characteristics and key figures would not be available in the same table for doing the select.
    2) If you happen to compress the data in the infocube, the data in the fact table would be  moved to the E fact table (/BI0/E) from the f fact table (/BI0/F).
    This would need change of code.
    I would rather suggest to go about this way.
    --> Check if the cube which you are trying to do a lookup is fed from a DSO.
    --> If so, use the Active table(/BI0/A*00) of the DSO for the lookup.
    Hope this helps!
    Edited by: Suchindra B R on Feb 10, 2010 7:45 AM

  • Want to use Index in Select statement

    Hi,
    I want to use the index tha is created for LIPS table for creation date. I want to use that INdex in the select statement to get the data from that table. Any one can tell me how can I right the select statement in report?
    thanks.

    Like I mentioned earlier, the optimizer is smart enough to choose the correct index based on the WHERE clause.  So if you created an index on field ERDAT for LIPS and your SELECT statement is like so.....
    Select ERDAT WERKS MATNR
              from LIPS
                          into table Itab
                                    Where erdat in s_erdat        "< - ERDAT First in WHERE Clause
                                        and werks in s_werks
                                        and Matnr in s_matnr.
    Then the optimizer will choose your index to use to access the data.  You can see these if you would do an SQL trace over your program and use the "Explain" button on ST05.  It will tell you which index it used and why.
    There is no need to use HINTs to force the use of the index.
    Regards,
    Rich Heilman

  • 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.

  • Simple??? Want "INSERT" function to return blank space after a field, how?

    All,
    Am I just having a brain fart? I have a situation where I have a field that needs to return just one space, or a value that has a space before and after it.
    Example:
    In the text ==> I am<field>going to the office. <-- notice no space between am, <field> and going
    I want it to say if FALSE, then "I am *not* going to the office."
    If true, then "I am going to the office."
    If true, I'm simply RETURN(""); <-- This returns a blank space
    If FALSE, I have tried:
    ret="not"
    RETURN(" " & ret & " ");
    This returns "I am notgoing to the office". <-- Notice no blank space after "not"?
    I've tried
    ret="not";
    ret2=(" " & ret);
    RETURN(Insert(ret2, 3, " "));
    Still the same result. What's strange is, if I do a RETURN(Insert(ret2, *2*, " "));, then it returns "I am no tgoing to the office" <-- Notice the space between the "o" and the "t"?
    Ideas?

    Trailing spaces are often removed from data. In your case, the easiest thing to do will be to use what is called the "hard space" character instead of a "real" space. This is key code ALT+0160. For all intent and purposes, it looks like a space and will print as a space, but since it is not technically the space (0032) character, it will not be trimmed from your projects. Just open the quotes, turn off the NUMLOCK and hold down the ALT key and type 0160 and then release the ALT key. This will add the hard space into your string. Then if you are like me, you will have to remember to turn the NUMLOCK back on.
    " not "
    I'm not sure how this will post into this message, but the example above is using hard space characters.
    Edited by: user9976634 on Dec 5, 2012 12:52 PM

  • How do you add additional fields in infotypes?i want to leave blank space

    how do you add additional fields in infotypes?i want to leave blank space in front of the field?

    Hi,
    To add new fields go to PM01 and select Enhance Infotype option and then follow the steps in sequence.
    I am not getting blank space in front of the field. please elaborate it.
    Regards,
    Raja.D

  • How can I remove blank space after month value while selecting to_char(sysdate)

    select to_char(sysdate,'dd-month-yyyy') from dual;
    when I give this query, I'm getting a blank space after the month value. How can I trim that?

    Or else try this one
    select to_char(sysdate,'dd-fmmonth-yyyy') from dual;
    Best of luck.

  • How can I print a selection in Firefox 11 without it wasting paper and printing blank space in place of the non-selected material?

    In Firefox 10 and before, I could select a small portion of a web page and it would print the selected portion on a single page. In Firefox 11, it prints blank space for the portion above my selection before printing my selection. This blank space could span several pages, and my printer prints those several blank pages with only headers and footers.

    Still happens with Firefox 12. I wish they'd just fix it, the way it used to be in Firefox 10, without the complicated workaround suggested above.

  • Check for a Comma (,) in an address field and send tht (,) as blank space t

    Hi,
    I have requirement , where I'm supposed to check for a Comma (,) in an address field and send tht (,) as blank space to the workarea.
    Do we have any FM or any check method for this.
    Plz tell me.
    Rohini.

    Hi,
      say address fields is "v_addr"
    DATA : v_len TYPE I,
               v_cnt1 TYPE i,
               v_cnt2 TYPE I value 1.
    v_addr = 'adresss,fiedls '.
    v_len = strlen( v_addr ) .
    DO v_len TIMES.
         IF v_addr+v_cnt1(v_cnt2)  EQ ','  .
             v_addr+v_cnt1(v_cnt2) = ' '.
            v_cnt1 = v_cnt1 + 1.
         ENDIF. 
    ENDDO.

  • Remove blank spaces in a text field?

    How can I remove blank spaces in a text field? Some text fields have a lot of blank fields that need to be removed so that I can report only on the text.
    CRXI
    Edited by: Burton Roger on Feb 10, 2009 5:48 PM

    Ex:
    "Hi,
    I have a need for monthly service desk reporting.
    Please provide data on single sheet.
    Thank you"
    I would like to shrink it down to -
    Hi, I have a need for monthly service desk reporting. Please provide data on single sheet. Thank you"

Maybe you are looking for

  • Problem with my USB port in MSI MS-6534

    Hello everybody. I bought an external hard drive and when I connected it to the USB port appear a message that I don't have any port of high velocity and I need to install a controller or high velocity. I don't understant to much about that, but I bo

  • Due for a new phone soon...what to get?

    I have an HTC Incredible right now, but I'm eager to get rid of it because of the poor battery life and low signal issues. I'm mostly concerned about getting a phone with better reception. I can be sitting at home and waver between zero and one bars,

  • FLV Video Goes Black

    Hello, I have a FLV video playing through the Media Display componet, however, when the video is finished playing, the image goes black. I've tried reseting the video, adding an extra frame at the end of the FLV video, moving the componet off the sta

  • Is there an expiration date for MAC OSX Snow Leopard 10.6.3

    Just wondering how much longer I will have access to programs on my MacBook.

  • NSM 3.0.3 Pending Events

    Just noticed 32 pending events of which the majority are Event Type (Action): 101:Evaluating Remove Member, and Current State: 2:evaluating user policy. I'm not sure how to clear those or complete those. 30 of these events are from user deletes. Two