Doubt in using replace statement

Hi all,
   I have a requirement where user will enter more than 1 label no in a screen, which will be populated internally in a table by SAP with ## for every ENTER button pressed by the user. the internal table populated by SAP will be having values like this. 11111111111##22222222222##3333333333
I need to separate the values from ## and move it to another internal table. I used replace statement to replace ##. But its not working.  I dont know what could be the problem. Can any one suggest me in doing this.
POINTS PROMISED
Regards,
Buvana

You will need to use the replace, but you need to be searching for cl_abap_char_utilities=>CR_LF in the REPLACE statement, the ## is an internal representation of the CR_LF,  so use 
replace  cl_abap_char_utilities=>CR_LF  with .....
Regards,
RIch Heilman

Similar Messages

  • Problem with Replace statement?

    Hi Guys,
                 I am using Replace statement for replacing '%20' in a partucular field like given below
    "  Replace All occurrences of REGEX '%20' in I_ZSTR_BPSITEUSER-FIRSTNAME with space ."
       But the problem is if Firstname = " Gopi%20%20%20A " after using this replace i am getting as
    " GopiA " but what my req is i need like "Gopi   A"(i want spaces in %20 place)so how to get it?
    Thanks,
    Gopi

    Hi,
    Try this..
    DATA: patt TYPE string VALUE '%20',
          text TYPE char100 VALUE 'Gopi%20%20%20A'.
    DATA: result_tab TYPE match_result_tab.
    DATA: v_length TYPE i.
    FIELD-SYMBOLS <match> LIKE LINE OF result_tab.
    * Find
    FIND ALL OCCURRENCES OF patt IN
         text
         RESULTS result_tab.
    SORT result_tab BY offset DESCENDING.
    * Replace
    LOOP AT result_tab ASSIGNING <match>.
      v_length = <match>-length - 1.
      text+<match>-offset(v_length) = space.
      SHIFT text+<match>-offset LEFT DELETING LEADING space.
      text+<match>-offset(1) = space.
    ENDLOOP.
    WRITE: / text.
    Thanks
    Naren

  • Can we use Loop Statement for Ranges

    Hi Friends,
    I have a range say R_Range. I need to loop at each line item and get the values in another range R_New_Range, i have to count the number of items in R_new_range. How is it possible.
    I know range is nothing but an internal table. So we can direcly use Move statements or so ...,
    But my question is .....
    My R_range has values as below
    'I' 'EQ' '001'
    'I' 'EQ' '002'
    'I' 'BT' '003' '007'
    'I' 'EQ' '008'
    I have to move all these values to R_New_range and my count of items should be '8'.
    How can i do that????????
    Expecting ur answers....
    Thanks in advance
    Cheers,
    R.Kripa.

    hey friends,
    Its nice to see the replies.... but i think i had confused u all with the question
    Now i'll explain u all in detail ....
    See i have 15000 projects ( eg., AAA111... ) and 100 GL accounts ( eg., 123443... ) .....
    I have to get the costs from COSS and COSP tables for all the projects - GL account combinations which leads to some 1500000 entries ..... So it is giving me a SQL Dump "DBIF_RSQL_INVALID_RSQL" .........
    Description of the Dump is
    Error in the module RSQL accessing the database interface
    An exception occurred. This exception is dealt with in more detail below
    . The exception, which is assigned to the class 'CX_SY_OPEN_SQL_DB', was
    neither                                                                
    caught nor passed along using a RAISING clause, in the procedure        
    "GET_COSP_COSS" "(FORM)"                                               
    Since the caller of the procedure could not have expected this exception
    to occur, the running program was terminated.                          
    The reason for the exception is:                                        
    The SQL statement generated from the SAP Open SQL Statement violates a  
    restriction imposed by the database system used in R/3.                                                                               
    Possible errors:                                                        
    o The maximum size of an SQL statement has been exceeded.              
    o The statement contains too many input variables.                     
    o The space needed for the input data exceeds the available memory.    
    o ...                                                                               
    You can usually find details in the system log (SM21) and in the        
    developer trace of the work process (ST11).                             
    If an error occurs the developer trace often informs you about the      
    current restrictions.                                                   
    So now i want to fine tune the program so that the execution works perfectly and get me the values for all the data 1500000 :-|
    Now :
    My Projects are stored in the form of a range R_Range
    I have to loop at this range and then process 100 records at a time and then again take other 100 records .... i'll count till 100 records by getting loopaing at the range and for each loop pass i'll increment the counter ....
    I am clear till this .....
    If record consist of 'EQ' option .... then ofcourse we can consider the total record to be 1 record and we can add 1 to counter ......
    But if the record consist of 'BT' option ...... then how can we loop that and get the number of -low numbers in that range and add to my counter ????
    Hope iam clear with my question
    If not do revert back ....
    Thanks in advance for the replies
    Cheers,
    R.Kripa.
    My Doubt is ....

  • If we use DML statement in function then that function can be used inside s

    if we use DML statement in function then that function can be used inside select query or any DML query?

    select f from t2;I think you meant to query t1.
    It works if the function is an autonomous transaction:
    create or replace function f return number
    is
    PRAGMA AUTONOMOUS_TRANSACTION;
    begin
        update t1 set c=2;
        commit;
        return 1;
    end;
    select f from t1But as Billy said why would you want to do DML this way. And this is not the way autonomous procedures should be used either.
    An an answer to an interview question though nothing wrong with it.

  • Can I use if statement in SQL???

    Hello everyone.
    I know that this is a silly question. The answer is no. Instead I should use decode function.
    But what if I dont know all possible outcomes, can I still use decode function?
    Also, I have created a view, in the where clause i want to use if statement. Is it possible to do?
    Thanks in advance,
    Sonya

    here is the view that I created:
    create or replace view import_shipment2
    ( order_no, cust_no,ORDER_SUFFIX,ship_addr1,ship_addr2, city,state,ZIP,country, terms_cd,shipvia_cd,
    freight_cd, shipto_cdoehead,shipto_cdshipto,ship_name,ship_attn,order_status, org_unit_id, order_date,
    estship_dt,confirm_status,gross_inv_value,phone,total_line_no,total_qty_order,total_qty_shipped,
    total_qty_backordered,service,hold_cd,invno)
    as select
    to_char(c.order_no)||'_'||c.ORDER_SUFFIX, c.cust_no,c.ORDER_SUFFIX,d.ship_addr1,
         d.ship_addr2, b.city, b.state, b.zip_code,b.country, d.terms_cd,d.shipvia_cd,d.freight_cd, d.shipto_cd,b.shipto_cd,
         nvl(d.ship_name,b.shipto_attn), nvl2(d.ship_attn,b.shipto_attn,e.contact),d.order_status, d.org_unit_id,
         d.order_date, d.estship_dt, c.confirm_status, f.gross_inv_value ,nvl(d.shipto_recip_phone ,g.phone_no),
         sum(c.line_no),sum(c.qty_order),sum(c.qty_shipped),sum(c.qty_bo),d.shipvia_cd ,d.hold_cd,d.invno
    from shipto_test b, oehead_test d,oedetl_test c, oesummary_test f ,CONTACT_MASTER_TEST e ,CONTACT_PHONE_TEST g
    where c.order_no=d.order_no
    and b.cust_no=d.cust_no
    and b.shipto_cd=d.shipto_cd
    and d.cust_no=f.cust_no
    and d.order_no=f.order_no
    and d.org_unit_id in ('110','120')
         and e.cust_no=d.cust_no
    and e.shipto_cd= d.shipto_cd
    and d.order_status in ('J','S')
    and g.contact_id=e.contact_id
    and g.phone_type='Business'
    Group by
    to_char(c.order_no)||'_'||c.ORDER_SUFFIX, c.cust_no,c.ORDER_SUFFIX,d.ship_addr1,
         d.ship_addr2, b.city, b.state, b.zip_code,b.country, d.terms_cd,d.shipvia_cd,d.freight_cd, d.shipto_cd,b.shipto_cd,
         nvl(d.ship_name,b.shipto_attn), nvl2(d.ship_attn,b.shipto_attn,e.contact),d.order_status, d.org_unit_id,
         d.order_date, d.estship_dt, c.confirm_status, f.gross_inv_value ,nvl(d.shipto_recip_phone ,g.phone_no),
         d.shipvia_cd ,d.hold_cd,d.invno;
    I need to do the validation of the g.phone_type. Does phone number exist at all in table?
    How do I all PL/SQL to this view??
    Thanks once agin,
    Sonya

  • Can we use return statement in procedure?

    Can we use return statement in procedure or we can use more than one return statement in procedure?

    HamidHelal wrote:
    NOReally? Did you at least test it? You can use RETURN in procedure or in anonymous PL/SQL block. The only restriction is you can't specify return value:
    SQL> begin
      2      dbms_output.put_line('Before return');
      3      return;
      4      dbms_output.put_line('After return');
      5  end;
      6  /
    Before return
    PL/SQL procedure successfully completed.
    SQL> create or replace
      2    procedure p1
      3      is
      4      begin
      5          dbms_output.put_line('Before return');
      6          return;
      7          dbms_output.put_line('After return');
      8  end;
      9  /
    Procedure created.
    SQL> exec p1;
    Before return
    PL/SQL procedure successfully completed.
    SQL> begin
      2      dbms_output.put_line('Before return');
      3      return 99;
      4          dbms_output.put_line('After return');
      5  end;
      6  /
        return 99;
    ERROR at line 3:
    ORA-06550: line 3, column 5:
    PLS-00372: In a procedure, RETURN statement cannot contain an expression
    ORA-06550: line 3, column 5:
    PL/SQL: Statement ignored
    SQL> create or replace
      2    procedure p1
      3      is
      4      begin
      5          dbms_output.put_line('Before return');
      6          return 99;
      7          dbms_output.put_line('After return');
      8  end;
      9  /
    Warning: Procedure created with compilation errors.
    SQL> show err
    Errors for PROCEDURE P1:
    LINE/COL ERROR
    5/9      PL/SQL: Statement ignored
    5/9      PLS-00372: In a procedure, RETURN statement cannot contain an
             expression
    SQL> SY.

  • Advantages of using prepared statement..... ?

    can anyone please tell me that what r the advantages of using prepared statements.
    for eg in case if statement object is executed inside a for loop where query is executed multiple times the sql query is compiled outside loop and therefore compilation is done only once. which makes sense
    But if there the query is not executed multiple times then what is the real benifit of using prepared statement . because the statement object will be closed after executing the query.
    and a new statement object will be created when other user access the same code.
    please clearify my doubts
    thanks
    Pankaj

    Other advantages of using PreparedStatement:
    1. It's easier to create SQL that looks like "Select This, That, TheOther from Something where ID=? and Usage=?" than to try to generate that with string concatenations.
    2. You don't have to deal with escaping quote characters that happen to appear in strings you want to insert in your database.
    3. PreparedStatements can do some things that Statement can't, such as updating very large text columns.

  • Doubt in Drop Table statement

    Hi,
    what will happen(internally), when we use DROP TABLE <table name>?
    Could you please elaborate for the above?
    Version : Oracle 9.2
    For example:
    If we use DML statements. It ll record the changes in redo log/archive log.
    My doubt is...
    i use DROP TABLE <table name>;
    What operation takes place?
    Will it record the changes in redo log/archive log file?
    Thanks in advance

    Hi,
    You can start 10046 trace and see what all happens when you fire a drop table command.
    Different Version and different functionalities would do additional task.
    eg: Database with recyclebin on would perform different task when compared to the database with recyeclebin off.
    They all would fire set of recursive SQL which would insert/update/delete the data dicitionary objects.
    Since drop table command would internally fire these dmls, hence would get logged into the redo log too.
    Regards
    Anurag

  • How to pass parameter in Function by using select statement?

    Hi,
    I got a problem. I cant pass in parameter to function by using select statement. But it can pass in parameter by using 'hardcode' method. How can I solve this problem?
    Eg,
    select * from table (SplitFunction('HS750020,HS750021')) <<< this work.
    but
    select * from table (SplitFunction(select LOT_NO from TRACER_SEARCH_SCHEDULE where JOB_ID = '36')) <<< do not work.
    Thanks for who try to help. Thanks.

    skymonster84 wrote:
    I have try this before. But it not work.here is an example
    create or replace type stringlist as table of varchar2(100)
    create or replace function splitstring(pstring in varchar2) return stringlist
    as
      lstringlist stringlist;
    begin
      select regexp_substr(pstring,'[^,]+',1, level) bulk collect into lstringlist
        from dual
      connect by level <= length(pstring)-length(replace(pstring,','))+1;
      return lstringlist;
    end;
    select * from table(select splitstring('xx,yy,zz') from dual)
    create table t(str varchar2(100))
    insert into t values('x,y,z')
    insert into t values('a,b,c')
    select * from table(select splitstring(str) from t where rownum<2)
    /If you supply multiple values then it will fail.
    select * from table(select splitstring(str) from t)
    /

  • Problem in using modify statement inside a Perform

    Hi Experts,
    loop at t_data into wa_data.
    IF wa_data1-zbukrs IS INITIAL.
            wa_data1-zstat = 'E'.
            w_messg =  'Company code is blank in upload data'.
            CONCATENATE wa_data1-zbukrs w_messg INTO w_msg
              SEPARATED BY space.
              CONCATENATE w_msg  wa_data1-zmsg INTO w_msg
    SEPARATED BY
    '|'.
              wa_data1-zmsg = w_msg.
              MODIFY t_data1 FROM wa_data1.
    endif.
    IF wa_data1-zfwcd IS INITIAL.
             wa_data1-zstat = 'E'.
             w_messg =  'Forwarder code is blank in upload data'.
            CONCATENATE wa_data1-zfwcd w_messg INTO w_msg
              SEPARATED BY space.
              CONCATENATE w_msg  wa_data1-zmsg INTO w_msg
    SEPARATED BY
    '|'.
              wa_data1-zmsg = w_msg.
              MODIFY t_data1 FROM wa_data1.
    endif.
    IF wa_data1-zinvno IS INITIAL.
              wa_data1-zmsg = w_msg.
              MODIFY t_data1 FROM wa_data1.
       wa_data1-zstat = 'E'.
             w_messg =  'Invoice number is blank in upload data'.
            CONCATENATE wa_data1-zinvno w_messg INTO w_msg
              SEPARATED BY space.
              CONCATENATE w_msg  wa_data1-zmsg INTO w_msg
    SEPARATED BY
    '|'.
              wa_data1-zmsg = w_msg.
              MODIFY t_data1 FROM wa_data1.
    endif.
    endloop.
    My doubt is:
            wa_data1-zstat = 'E'.
            w_messg =  'Company code is blank in upload data'.
            CONCATENATE wa_data1-zbukrs w_messg INTO w_msg
              SEPARATED BY space.
              CONCATENATE w_msg  wa_data1-zmsg INTO w_msg
    SEPARATED BY
    '|'.
              wa_data1-zmsg = w_msg.
              MODIFY t_data1 FROM wa_data1.
    i want write the above code to be written in a perform statement
    becos iam using the above code in multiple places in my program.
    but the problem iam facing is modify not working in perform statement.
    Regards,
    Raj.

    hi Raj,
       use FIELD-SYMBOLS so that you don't have to use MODIFY statement.
    FIELD-SYMBOLS: <fs> like line of T_data.
    loop at t_data ASSIGNING <fs>.
    IF  <fs>-zbukrs IS INITIAL.
    <fs>-zstat = 'E'.
    w_messg = 'Company code is blank in upload data'.
    CONCATENATE <fs>-zbukrs w_messg INTO w_msg
    SEPARATED BY space.
    CONCATENATE w_msg <fs>-zmsg INTO w_msg
    SEPARATED BY   '|'.
    <fs>-zmsg = w_msg.
    endif.
    IF <fs>-zfwcd IS INITIAL.
    <fs>-zstat = 'E'.
    w_messg = 'Forwarder code is blank in upload data'.
    CONCATENATE <fs>-zfwcd w_messg INTO w_msg
    SEPARATED BY space.
    CONCATENATE w_msg <fs>-zmsg INTO w_msg
    SEPARATED BY '|'.
    <fs>-zmsg = w_msg.
    endif.
    endloop.

  • FETCHING VALUES IN MULTI RECORD BLOCK FROM ANOTHER TABLE USING SELECT STATEMENT.

    Hi,
    I have one multi record block in which i want to fetch values
    (more then one record) from another table using select statement
    IN KEY NEXT ITEM.I am getting following error.
    ORA-01422: exact fetch returns more than requested number of rows
    Thanks in advance.

    In your case I see no reason to use non-database block and to try to populate it from a trigger with a query, instead of using the default forms functionality where you can associate the block and the fields with table, create where clause using bind variables and simply use execute_query() build-in to populate the block. The power of the forms is to use their build-in functionality to interact with the database.
    Also, you can base your block on a query, not on a table and you dynamically change this query using set_block_property() build-in. You can use any dynamic queries (based on different data sources) and you simply need to control the column's data type, the number of the columns and their aliases. Something like creating inline views as a block data source.
    However, you can replace the explicit cursor with implicit one like
    go_block('non_db_block_name');
    first_record();
    FOR v_tab IN (SELECT *
    FROM tab
    WHERE col_name = :variable)
    LOOP
    :non_db_block_name.field1 := v_tab.col1;
    :non_db_block_name.field2 := v_tab.col2;
    next_record();
    END LOOP;

  • Using 'replace' in Oracle

    Hi All,
    I am trying to use replace to replace a string with some tags as shown below:
    replace('ADAFETG3B-D0LA,ADAFETG3B-D0WA ', ',' , '</PartName><PartName>')
    but in the output it replaces the < with '&ltsemicolon' and > with '&gtsemicolon'
    Is there any other way to include < and > within strings and have them get displayed as is??
    Thanks for your help in advance.
    -Avantika

    Actually I am simply generating valid XML, so that no conversion of special characters like < or > take place. The output of the statement is as follows:
    X                                                                              
    <StartMaterials>                                                               
      <SMat>                                                                       
        <PartName>partname1</PartName>                                             
        <Alternates>                                                               
          <PartName>my first part</PartName>                                       
          <PartName>my second part</PartName>                                      
        </Alternates>                                                              
        <Qty>50</Qty>                                                              
      </SMat>                                                                      
      <SMat>                                                                       
        <PartName>partname2</PartName>                                             
        <Alternates>                                                               
          <PartName>my first part - my second part</PartName>                      
        </Alternates>                                                              
        <Qty>150</Qty>                                                             
      </SMat>                                                                      
    </StartMaterials> 

  • Query abourt  'REPLACE' statement in SAP 4.7

    hello,
          I have developed one program in SAP 4.7 version.Now i have copied it to 4.6C in SAP.When i tried to run this program it gives me error in  
    REPLACE ALL OCCURRENCES OF ':' IN l_col_time WITH ' '.
    this statement.this statement is working in 4.7 but not in 4.6C.What should i do to eliminate this replace statement?should i use any function module that replaces off occurrences of particular character with specified character.

    hi,
      try this
    DO.
      REPLACE  ':' IN l_col_time WITH ' '.
      IF SY-INDEX <> 0.
        EXIT.
      ENDIF.
    ENDDO.
    or
       CLEAR lv_length.
       lv_length = STRLEN( lv_format_sdata ).
       DO lv_length TIMES.
         REPLACE ',""' WITH ',' INTO lv_format_sdata.
         IF sy-subrc <> 0.
           EXIT.
         ENDIF.
       ENDDO.
    This will solve ur problem.
    <b>Mark Helpful answers</b>
    Regards

  • Explain me the following replace statement

    Hi guys,
    Please explain me the following replace statement with an example :
    REPLACE ALL OCCURRENCES OF '''' IN materialgroup_desc WITH ''''''.
    Please explain me the purpose of the above statement by showing the input and output.
    Regards,
    Vishu.

    Hi Rob,
    It's working fine .Thank you.But I just want to know the purpose of it as the functionality in one of the programs I have seen is as below  :
    Requirement :
    Need to get all the material groups and description2 based on the material descriptions we enter in the selection-screen .
    The program is coded in such a way that all the single quotes are replaced with double quotes :
    The following 3 statements are written in the code  :
    REPLACE ALL OCCURRENCES OF '''' IN materialgroup_desc  WITH ''''''.
    REPLACE ALL OCCURRENCES OF '*'  IN materialgroup_desc WITH '%'.
    REPLACE ALL OCCURRENCES OF '''' IN materialgroup_desc  WITH ''''''.
    and finally the result string is concatenated between quotes again to query the data.
    For instance if we give MAT'ER*IAL as the input it is converted to 'MAT''''ER%IAL'
    and by querying with a select statement using
    materialgroup_desc LIKE 'MAT''''ER%IAL' we are getting the required data.
    Hope you understand mny question.Please explain me why we are replacing the single quotes with double quotes 2 times.Is it a way to skip the special characters.
    Regards,
    Vishu shetty.

  • Bulk Replacements using Replace function in oracle 8i

    Hi All,
    Iam using oracle 8i version and i need to use Replace function for bulf replacements i mean i need to replace around 250 rows. So please anyone suggest me how to proceed
    on this request as iam using oracle 8i version.
    Thanks!
    Srini

    Write one update statement.
    The where condition is the filter what rows need to be touched.
    The SET condition will do the data change. For example it could use the REPLACE function if that is what it is needed.
    One single update statement over 20 rows would mean the task is done in BULK. 20 single updates that each handle one row would mean it is row by row = slow by slow processing.

Maybe you are looking for

  • No video support with iPad lightning-VGA adapter (iOS 8.3)

    Just subscribed to HBO NOW and bought a lightning-to-VGA adapter ($55!) to watch HBO on my computer monitor (no HDMI, only VGA) from my iPad mini. Worked fine on iOS 8.2, but then when upgraded to 8.3 I could no longer get video support. Still have i

  • Interactive Form/Report - href

    Page 2 is interactive report/Page 3 is form for report Currently have interactive report link on field set up as this: Link Text: #DOCNO# Link Attributes: href=#DOC_LINK#, target=_blank URL: #DOC_LINK# All works as anticipated and fine. But when the

  • HP Pavillion dv6647cl - CD/DVD drive not working

    My DVD/CD drive isn't working. I was in the process of reinstalling my OS through the Windows Vista recovery discs(Which I did a few times before) and now all of the sudden, the BIOS isn't recognizing the drive. Because of that I was forced to use a

  • After boot can't mount SDS file systems on 3300 mount: cannot mount /dev/md

    Hi I have a SUNW,Netra-440 with two SE 3300 SCSI each with two controllers. The server was working fine but after a boot, it can not see the metadevices stored in the 3300. I have tried restarting the SE3300 and a boot -r from ok prompt but I still c

  • Help my iphone is stuck in DFU (blackscreen) mode!!!

    my iphone 3gs is stuck at DFU mode after i restore to 4.3.3 and it cant wake up and is on blackscreen too!! I tried holding the home and the wake button for 10 sec and release the wake button and continue pressing the home button until the apple logo