Thursday, December 6, 2012
MS Excel: REPLACE Function
In Microsoft Excel, the REPLACE function replaces a sequence of characters in a string with another set of characters.
Syntax
REPLACE( old_text, start, number_of_chars, new_text )
old_text is the original string value.
start is the position in old_text to begin replacing characters.
number_of_chars is the number of characters to replace in old_text.
new_text is the replacement set of characters

*&----------------------------------------------------------------------*
"Form  build_xls_data_table
*&----------------------------------------------------------------------*
FORM build_xls_data_table.
  "If you have Unicode check active in program attributes then
  "you will need to declare constants as follows.
  CLASS cl_abap_char_utilities DEFINITION LOAD.
  CONSTANTS:
        con_tab  TYPE c VALUE cl_abap_char_utilities=>horizontal_tab,
        con_cret TYPE c VALUE cl_abap_char_utilities=>cr_lf.
  DATA: ld_store(50) TYPE c.  "Leading zeros

  CONCATENATE 'PERNR' 'PERSG' 'PERSK' 'PLANS' 'STELL'  
         INTO  w_attachment  SEPARATED BY  con_tab.
  CONCATENATE con_cret  w_attachment  
         INTO w_attachment.
  APPEND w_attachment TO i_attachment.
  CLEAR  w_attachment.

  LOOP AT i_emp_data INTO w_emp_data.
    CONCATENATE '=REPLACE("' w_emp_data-pernr '",1,5,"' w_emp_data-pernr '")' 
           INTO ld_store .
    CONCATENATE ld_store
                w_emp_data-persg
                w_emp_data-persk
                w_emp_data-plans
                w_emp_data-stell
          INTO w_attachment
          SEPARATED BY con_tab.

    CONCATENATE con_cret w_attachment INTO w_attachment.
    APPEND w_attachment TO i_attachment.
    CLEAR  w_attachment.
  ENDLOOP.
ENDFORM.                    "build_xls_data_table
Output

5 comments:

  1. this is valuable information for learners.thanks
    sas online training

    ReplyDelete

  2. such a good website and given to more information thanks! and more visit
    sas online training

    ReplyDelete
  3. I feel thanks to you for posting such a good articles here, pls keep updates regularly
    Websphere Training In Hyderabad

    ReplyDelete
  4. Awesome post
    This is such a great resource that you are providing and you give it away for free. I love seeing websites that understand the value of providing a quality resource for free. It?s the old what goes around comes around routine. Did you acquired lots of links and I see lots of trackbacks??
    sap sd training
    sap mm training

    ReplyDelete

Your useful comments, suggestions are appreciated.Your comments are moderated.

Followers

Contact Form

Name

Email *

Message *

Web Dynpro ABAP Book

An SAP Consultant

Follow US


Want to Contribute ?

If you are interested in writing about the new stuff you learn everyday while working, please write to the.sap.consultants@gmail.com.

Click on Contribution for more details.