String condense

Is there a way to take a very large string write it to a file in a way that the file is fairly small then read it back? doesn't have to be readable when it's writen out

Ya but that can only write byte i want to write stringThat's why they've put the getBytes(...) method in the String class.

Similar Messages

  • How to print the script in condensed mode

    Hi to all,
    Pls help me.
    How to print the script in condensed mode and particular window only print in the condensed mode.

    Hi,
    Hi
    It will remove the blank spaces in front of the variable
    and if you use the extension NO-GAPS
    It will remove all the blank spaces in the variable field.
    DATA: ws_val1 type char12.
    ws_val1 = ' 100 123'.
    Condense ws_val1.
    Write / ws_val1.
    Condense ws_val1 no-gaps.
    write / ws_val1.
    It will give output as
    100 123
    100123
    The CONDENSE statement deletes redundant spaces from a string:
    CONDENSE c NO-GAPS.
    This statement removes any leading blanks in the field c and replaces other sequences of blanks by exactly one blank. The result is a left-justified sequence of words, each separated by one blank. If the addition NO-GAPS is specified, all blanks are removed.
    Please check this link for sample code.
    http://help.sap.com/saphelp_nw2004s/helpdata/en/fc/eb33e6358411d1829f0000e829fbfe/content.htm
    Regards,
    Raj.

  • Comma separated format is required

    Hi all
    this is the code which i have written:
    OPEN DATASET g_ufile FOR OUTPUT IN TEXT MODE ENCODING DEFAULT.
       LOOP AT t_file WHERE werks = t_file1-werks.
        MOVE : gc_kaganplntcode TO t_file-fieldname1,
               gc_productcode TO t_file-fieldname2,
               gc_qtyavailable TO t_file-fieldname3.
              CONCATENATE t_file-fieldname1
                          t_file-fieldname2
                          t_file-fieldname3
                       INTO gv_itemdet1 separated by ','.
       ENDLOOP.
         transfer gv_itemdet1 to g_ufile.
        loop at t_file into t_file1.
        condense t_file1 no-gaps.
        transfer t_file1 to g_ufile.
        append t_file1.
        clear t_file1.
        clear gv_itemdet.
        endloop.
    in t_file1 data is coming in continous manner. i need to have comma separated data. ie each field shud be separated by ','.
    can anybody tell me logic for it.
    very urgent.
    regrd
    Mona
    Edited by: Alvaro Tejada Galindo on Apr 14, 2008 1:03 PM

    Try it this way mona
    Declare a fiel-symbol type any and an string to tranfer the contents.
    loop at t_file into t_file1.
    clear string.
    condense t_file1 no-gaps.
    do.
    assign component sy-index of structure t_file1 to <fs>.
    if sy-subrc ne 0.
    exit.
    endif.
    concatenate string <fs> ',' into string.
    enddo.
    transfer string to g_ufile.
    append t_file1.
    clear t_file1.
    clear gv_itemdet.
    endloop.

  • Help changing text in a textfield

    Hello, I am trying to create buttons that will replace the text in a text field. 
    The text field is "Staff_Copy"
    The buttons are "Staff_Saam_btn", "Staff_Nicolas_btn", "Staff_David_btn", and "Staff_Anthony_btn".
    //Code in frame 1 of timeline
    var Staff_Copy_Value:Number = 0;
    var Saam_Copy:String = "This is the text for Saam's Bio";
    var Nicolas_Copy:String = "This is the text for Nick's Bio";
    var Anthony_Copy:String = "This is the text for Anthony's Bio";
    var David_Copy:String = "This is the text for David's Bio";
    //code in frame in which textfield first appears on stage
    Staff_Saam_btn.onPress = function()    {
                    Staff_Copy_Value = 4;
    Staff_Nicolas_btn.onPress = function() {
                    Staff_Copy_Value = 3;
    Staff_David_btn.onPress = function()    {
                    Staff_Copy_Value = 2;
    Staff_Anthony_btn.onPress = function()              {
                    Staff_Copy_Value = 1;
    _root.onEnterFrame = function()             {
                    if (Staff_Copy_Value == 4)          {
                                    Staff_Copy.text = Saam_Copy;
                    } else if (Staff_Copy_Value == 3)              {
                                    Staff_Copy.text = Nicolas_Copy;
                    } else if (Staff_Copy_Value == 2)              {
                                    Staff_Copy.text = David_Copy;
                    } else if (Staff_Copy_Value == 1)              {
                                    Staff_Copy.text = Anthony_Copy;
    This doesn't work.  Whatever the initial value of the variable "Staff_Copy_Value" is will determine the text in the field.  So if I use the value 0 as in the above, whatever is in the textfield on the stage shows.  If I use 1,2,3, or 4 then the text strings in the defined variables shows up.  What am I missing.  I am assuming it is has to do with the onEnterFrame command.  How do I make the movie keep checking the value of "Staff_Copy_Value"?
    Thanks!

    Hi,
    try this:
    //frame 1 of timeline
    var pressing:Boolean = false;
    var movement:Number = 0;
    var Staff_Copy_Value:Number = 3;
    //the text in the following strings are condensed.  The actual text takes
    //more space than the text box will show.  Hence the need for scroll
    //buttons.
    var Saam_Copy:String = "This is the text for Saam's Bio";
    var Nicolas_Copy:String = "This is the text for Nick's Bio";
    var Anthony_Copy:String = "Condensed text for Anthony's Bio.";
    var David_Copy:String = "This is the text for David's Bio";
    //frame in which the textfield enters stage (25).
    upButton_btn.onPress = function() {
        _root.pressing = true;
        _root.movement = -1;
    upButton_btn.onRelease = function() {
         _root.pressing = false;
    downButton_btn.onPress = function() {
         _root.pressing = true;
        _root.movement = 1;
    downButton_btn.onRelease = function() {
         _root.pressing = false;
    Staff_Saam_btn.onPress = function() {
         _root.Staff_Copy_Value = 4;
    Staff_Nicolas_btn.onPress = function() {
         _root.Staff_Copy_Value = 3;
    Staff_David_btn.onPress = function() {
         _root.Staff_Copy_Value = 2;
    Staff_Anthony_btn.onPress = function() {
         _root.Staff_Copy_Value = 1;
    _root.onEnterFrame = function() {
        if (Staff_Copy_Value == 4) {
             Staff_Copy.text = Saam_Copy;
        } else if (Staff_Copy_Value == 3) {
             Staff_Copy.text = Nicolas_Copy;
        } else if (Staff_Copy_Value == 2) {
            Staff_Copy.text = David_Copy;
        } else if (Staff_Copy_Value == 1) {
             Staff_Copy.text = Anthony_Copy;
        if (_root.pressing == true) {
              _root.Staff_Copy.scroll = _root.Staff_Copy.scroll + _root.movement;
    Warm Regards
    Deepanjan Das
    http://deepanjandas.wordpress.com/

  • Find the number of consecutive numeric digits in string

    I am trying to see if a string has say 9 consecutive numeric digits in it but it will only work if the long string of numbers is the first string of numbers.
    e.g.
    This would recongnise the following string (if p_len = 9)
    Tel number 20 20 30 369 for 2nd meeting
         but would not recongnise the following
    For 2nd meeting tel 20 20 30 369
    Could anyone give guidance on how to proceed / a better way of find consecutive numbers in a string?
    Thanks
    Simon
    Code sample -
        LOOP AT TLINETAB.
    Remove blank spaces
          CONDENSE TLINETAB-TDLINE NO-GAPS.
    Find first number and its position *
          IF TLINETAB-TDLINE CA '0123456789'.
            pos = sy-fdpos.
    Does the next x characters contain only numbers?
            IF TLINETAB-TDLINE+pos(p_len) CO '0123456789'.
              append i_report.
            endif.
          ENDIF.
        ENDLOOP.

    Dear Simon,
    you want to check for consecutive numbers in a string. Then you may do the following -
    1. Get all the numbers in the given string into a table in a sequencial order, that is the order in which they appear in the string
    2. Once you have all the numbers you may find out if the numbers are consecutive or not. The following is the code which is not tested
    lv_len = 1.
    lv_pos = 1.
    lv_strlen = strlen ( lv_str ).
    do lv_strlen times.
      lv_alpha = lv_str+lv_pos(lv_len).
      if lv_alpha co '0123456789'.
       append lv_alpha to lt_number.
      endif.
      lv_pos = lv_pos + 1.
    enddo.
    loop at lt_number into ls_number.
      if lv_no is initial.
       lv_no = ls_number.
       lv_no = lv_no + 1.
      else.
       if ls_number eq lv_no and
          lv_consec is initial.
        lv_consec = c_x.
       else.
        clear lv_consec.
       endif.
      endif.
    endloop.
    if lv_consec eq c_x.
    *  !!! string has consecutive numbers
    endif.
    Hope it helps. Thank you.
    Regards,
    kartik

  • A little help with tokenizing a string

    Have most of this working and i will add the code to the end of the for you all to look at.
    Essentially what i am trying to do is tokenize a string that looks like:
    program int ABC, D;
         begin read ABC; read D;
              while (ABC != D) begin
                                       if (ABC > D) then ABC = ABC - D;
                                       else D = D - ABC;
                                  end;
                             end;
              write D;
         endMy tokeizing stuff works just fine for simpler version of this but it screws up a little when it gets to the "special symbols" that are a combination of more then one special token. The special symbols are:
    ; , = ! [ ] && or ( ) + - * != == < > <= >=Now i obviously have to look for those as tokenizing points, but the problem comes when i get to double ones like &&, or, !=, etc.
    I was wondering if there was a way to make it look for the combination != instead of just the ! and then the =.
    If there is not an easy way to do it what would be the best and easiest way to go about parsing that string into tokens? I am kinda leaning towards string.split but am not quite sure on how to set it up. some examples or pointers would be welcome!!
    Thanks and here is the code of the relevant part:
    import java.util.ArrayList;
    import java.util.StringTokenizer;
    import java.io.*;
    * @author Kyle Hiltner
    public class KHTokenizer implements KHTokenizerInterface
         private String current_token; //used to specify current token
         private int token_count=0; //used to keep track of which token is being asked for
         private ArrayList<String> file = new ArrayList<String>(); //stores the parsed input file
          * Creates a new KHTokenizer with the name of the file as input
          * @param inputFileName the specified file to be read from
          * @throws IOException
         KHTokenizer(String inputFileName) throws IOException
              FileReader freader = new FileReader(inputFileName); //create a FileReader for reading
              BufferedReader inputFile = new BufferedReader(freader); //pass that FileReader to a BufferedReader
              String theFile = Create_String_From_File(inputFile); //create a space separated string for easier tokenizing
              StringTokenizer tokenized_input_file = new StringTokenizer(theFile, ";=,()[] ", true); //tokenize the string using ;, =, and " " as delimiters
              String_Tokenizer(tokenized_input_file, file); //create the array by adding tokens
              this.current_token = file.get(this.token_count); //set the current token to the first in the array
         //----Private Operations----//
          * Determines if the specified word is a special Reserved word
          * @param reserved_word the current token
          * @return true if and only if the reserved_word is a Reserved Word
         private static Boolean Is_Reserved_Word(String reserved_word)
              //determine is reserved_word is one the established Reserved Words
              return ((reserved_word.equals("program")) || (reserved_word.equals("begin")) ||
                        (reserved_word.equals("end")) || (reserved_word.equals("int")) ||
                        (reserved_word.equals("if")) || (reserved_word.equals("then")) ||
                        (reserved_word.equals("else")) || (reserved_word.equals("while")) ||
                        (reserved_word.equals("read")) || (reserved_word.equals("write")));
          * Determines if the specified word is a Special Symbol
          * @param special_symbol the current token
          * @return true if and only if the special_symbol is a Special Symbol
         private static Boolean Is_Special_Symbol(String special_symbol)
              //determines if special_symbol is one of the established Special Symbols
              return ((special_symbol.equals(";")) || (special_symbol.equals(",")) ||
                        (special_symbol.equals("=")) || (special_symbol.equals("!")) ||
                        (special_symbol.equals("[")) || (special_symbol.equals("]")) ||
                        (special_symbol.equals("&&")) || (special_symbol.equals("or")) ||
                        (special_symbol.equals("(")) || (special_symbol.equals(")")) ||
                        (special_symbol.equals("+")) || (special_symbol.equals("-")) ||
                        (special_symbol.equals("*")) || (special_symbol.equals("!=")) ||
                        (special_symbol.equals("==")) || (special_symbol.equals("<")) ||
                        (special_symbol.equals(">")) || (special_symbol.equals("<=")) ||
                        (special_symbol.equals(">=")));
          * Determines if the specified token is an integer
          * @param integer_token the current token to be converted to an integer
          * @return true is and only if integer_token is an integer
         private static Boolean Is_Integer(String integer_token)
              Boolean is_integer=false; //set up boolean for check
              //try to convert the specified string to an integer
              try
                   int integer_token_value = Integer.parseInt(integer_token); //convert the string to an integer
                   is_integer = true; //set is_integer to true
              catch(NumberFormatException e) //if unable to parse the string to an integer set is_integer to false
                   is_integer = false; //set is_integer to false
              return is_integer; //return the integer
          * Determines if the specified token is an Identifier
          * @param identifier_token the current token
          * @return true if and only if the identifier_token is an identifier
         private static Boolean Is_Identifier(String identifier_token)
              //rule out that it is a Reserved Word, Special Symbol, or integer so then it must be an Identifier; so return true or false
              return ((!Is_Reserved_Word(identifier_token)) && (!Is_Special_Symbol(identifier_token)) && (!Is_Integer(identifier_token)));
          * Determines which value to assign to the specified token
          * @param which_reserved_word_token the current token
          * @return token_value the integer value relating to the Reserved Word token
         private static int Which_Reserved_Word(String which_reserved_word_token)
              int token_value=0; //set initial token_value
              //run through and check which Reserved word it is and then set it to the correct value
              if(which_reserved_word_token.equals("program"))
                   token_value = ReservedWords.PROGRAM.ordinal()+1;
              else if(which_reserved_word_token.equals("begin"))
                   token_value = ReservedWords.BEGIN.ordinal()+1;
              else if(which_reserved_word_token.equals("end"))
                   token_value = ReservedWords.END.ordinal()+1;
              else if(which_reserved_word_token.equals("int"))
                   token_value = ReservedWords.INT.ordinal()+1;
              else if(which_reserved_word_token.equals("if"))
                   token_value = ReservedWords.IF.ordinal()+1;
              else if(which_reserved_word_token.equals("then"))
                   token_value = ReservedWords.THEN.ordinal()+1;
              else if(which_reserved_word_token.equals("else"))
                   token_value = ReservedWords.ELSE.ordinal()+1;
              else if(which_reserved_word_token.equals("while"))
                   token_value = ReservedWords.WHILE.ordinal()+1;
              else if(which_reserved_word_token.equals("read"))
                   token_value = ReservedWords.READ.ordinal()+1;
              else
                   token_value = ReservedWords.WRITE.ordinal()+1;
              return token_value; //return the token_value
          * Determines which value to assign to the specified token
          * @param which_special_symbol_token the current token
          * @return special_symbol_token_value the integer value relating to the Special Symbol token
         private static int Which_Special_Symbol(String which_special_symbol_token)
              int special_symbol_token_value=0; //set initial value
              //check to figure out which Special Symbol it is and assign the correct value
              if(which_special_symbol_token.equals(";"))
                   special_symbol_token_value = SpecialSymbols.SEMICOLON.ordinal()+11;
              else if(which_special_symbol_token.equals(","))
                   special_symbol_token_value = SpecialSymbols.COMMA.ordinal()+11;
              else if(which_special_symbol_token.equals("="))
                   special_symbol_token_value = SpecialSymbols.EQUALS.ordinal()+11;
              else if(which_special_symbol_token.equals("!"))
                   special_symbol_token_value = SpecialSymbols.EXCLAMATION_MARK.ordinal()+11;
              else if(which_special_symbol_token.equals("["))
                   special_symbol_token_value = SpecialSymbols.LEFT_BRACKET.ordinal()+11;
              else if(which_special_symbol_token.equals("]"))
                   special_symbol_token_value = SpecialSymbols.RIGHT_BRACKET.ordinal()+11;
              else if(which_special_symbol_token.equals("&&"))
                   special_symbol_token_value = SpecialSymbols.AND.ordinal()+11;
              else if(which_special_symbol_token.equals("or"))
                   special_symbol_token_value = SpecialSymbols.OR.ordinal()+11;
              else if(which_special_symbol_token.equals("("))
                   special_symbol_token_value = SpecialSymbols.LEFT_PARENTHESIS.ordinal()+11;
              else if(which_special_symbol_token.equals(")"))
                   special_symbol_token_value = SpecialSymbols.RIGHT_PARENTHESIS.ordinal()+11;
              else if(which_special_symbol_token.equals("+"))
                   special_symbol_token_value = SpecialSymbols.PLUS.ordinal()+11;
              else if(which_special_symbol_token.equals("-"))
                   special_symbol_token_value = SpecialSymbols.MINUS.ordinal()+11;
              else if(which_special_symbol_token.equals("*"))
                   special_symbol_token_value = SpecialSymbols.MULTIPLY.ordinal()+11;
              else if(which_special_symbol_token.equals("!="))
                   special_symbol_token_value = SpecialSymbols.NOT_EQUALS.ordinal()+11;
              else if(which_special_symbol_token.equals("=="))
                   special_symbol_token_value = SpecialSymbols.EQUALS_EQUALS.ordinal()+11;
              else if(which_special_symbol_token.equals("<"))
                   special_symbol_token_value = SpecialSymbols.LESS_THAN.ordinal()+11;
              else if(which_special_symbol_token.equals(">"))
                   special_symbol_token_value = SpecialSymbols.GREATER_THAN.ordinal()+11;
              else if(which_special_symbol_token.equals("<="))
                   special_symbol_token_value = SpecialSymbols.LESS_THAN_OR_EQUAL_TO.ordinal()+11;
              else
                   special_symbol_token_value = SpecialSymbols.GREATER_THAN_OR_EQUAL_TO.ordinal()+11;
              return special_symbol_token_value; //return the correct value
          * Creates the string separated by white spaces to be read by the String Tokenizer
          * @param input_file the stream to be converted into a string
          * @return theFile the inputFile converted to a string
          * @throws IOException
         private static String Create_String_From_File(BufferedReader input_file) throws IOException
              String theFile="", keepReadingFromFile=""; //set initial value of the strings
              //run through the stream and create a file
              while(keepReadingFromFile != null)
                   keepReadingFromFile = input_file.readLine(); //read one line at a time
                   //if the line is null stop and break
                   if(keepReadingFromFile == null)
                        break;
                   else //keep reading from the file and make it into a string
                        theFile = theFile + keepReadingFromFile;
              theFile = theFile.replaceAll("\\t", " "); //remove any tabs from the string and replace with spaces so it is easier to Tokenize
              return theFile; //return the newly created string
          * Creates the array of tokens but tokenizing based on the given parameters
          * @param theInputFile
          * @param file to store the individual tokens in
         private void String_Tokenizer(StringTokenizer theInputFile, ArrayList<String> file)
              String token=""; //set up the intial token
              //keep reading with there is still more in the token stream
              while (theInputFile.hasMoreTokens())
                   token = theInputFile.nextToken(); //set token to the next token
                   //if the token is not a white sapce then add it to the array
                   if(!token.equals(" "))
                        file.add(token); //add token to the array
              file.add("nill"); //add a final spot to designate the end of the file
         //----Public Operations-----//
          * Returns the integer value of the current token
          * @return the integer value of the current token
         public int getToken()
              int token_number=0; //set initial value
              //determine if the current token is a Reserved Word, Special Symbol, Identifier, or nill (for end of file)
              if(Is_Reserved_Word(this.current_token))
                   token_number = Which_Reserved_Word(this.current_token); //determine the correct value for the Reserved Word
              else if(Is_Special_Symbol(this.current_token))
                   token_number = Which_Special_Symbol(this.current_token); //determine the correct value for the Special Symbol
              else if(Is_Integer(this.current_token))
                   token_number = 30; //the current token is an integer so set it to 30
              else if(this.current_token.equals("nill"))
                   token_number = 32; //the current token is nill so set it to 32
              else//(Is_Identifier(this.current_token))
                   token_number = 31; //the token is an identifer so set it to 31
              return token_number; //return the token_number
          * Sets the current token as the next one in line
         public void skipToken()
              //keep getting the next token as long as token_count is less then the size of the array
              if(this.token_count < file.size()-1)
                   this.token_count++; //increase token_count
                   this.current_token = file.get(token_count); // get the new token
          * This method can only be called to convert an integer in string form to its integer value.
          * If called on an non integer token an error is printed to the screen and execution of the Tokenizer is stopped.
          * @return integer value of the specified token assuming the token is an integer
         public int intVal()
              int integer_token_value=0; //set the initial value
              //if true is returned then go ahead and convert
              if(Is_Integer(this.current_token))
                   integer_token_value = Integer.parseInt(this.current_token); //parse the current_token string and get an integer value
              else // print he error message and exit Tokenizing
                   System.out.print("You called intVal() on a non-integer token. You tryed to convert the " );
                   if(Is_Reserved_Word(this.current_token))
                        System.out.print("reserved word " + "\"" + this.current_token +"\"" + " to an integer");
                   else if(Is_Special_Symbol(this.current_token))
                        System.out.print("special symbol " + "\"" + this.current_token +"\"" + " to an integer");
                   else
                        System.out.print("identifier " + "\"" + this.current_token +"\"" + " to an integer");
                   System.exit(1); //exit the system and quit tokenizing
              return integer_token_value; //return the current_token integer value
          * Returns a string if and only if the token is of the id type.
          * @return the name of the id token
         public String idName()
              String id_token_name=""; //setup the initial value
              //if the current_token is an Identifer then set it so and return it.
              if(Is_Identifier(this.current_token))
                   id_token_name = this.current_token;
              else // print message and quit tokenizing
                   System.out.print("You called idName() on ");
                   if(Is_Reserved_Word(this.current_token))
                        System.out.print("a reserved word, ");
                   else if(Is_Special_Symbol(this.current_token))
                        System.out.print("a special symbol, ");
                   else
                        System.out.print("an integer, ");
                   System.out.println("which is not an identifier token.");
                   System.exit(1); //exit and quit tokenizing
              return id_token_name; //return the id_token_name if possible
    }left some stuff out

    volunteers are supposed to read all that? and no tea and crumpets?
    Seriously though, we don't want to see all of your code, we don't even want to see most of your code, but rather you should condense your code into the smallest bit that still compiles, has no extra code that's not relevant to your problem, but still demonstrates your problem, in other words, an SSCCE (Short, Self Contained, Correct (Compilable), Example). For more info on SSCCEs please look here:
    [http://homepage1.nifty.com/algafield/sscce.html|http://homepage1.nifty.com/algafield/sscce.html]

  • How to find combinations of a string

    Hi Dear,
    How can we find the combination of a given string whatever input given by user.
    If the String is A1C the possible outcomes are:
    A1C
    AC1
    1CA
    1AC
    CA1
    C1A
    Best Regards,
    Aditya

    PARAMETERS :
      p_char(12) TYPE c.                   " Input character.
    * Data declarations...................................................*
    * Work variables                                                      *
    DATA :
      w_fact     TYPE i                    " Factorial.
                 VALUE 1,
      w_index    TYPE i,                   " Index.
      w_count    TYPE i,                   " count.
      w_str(40)  TYPE c,                   " String.
      w_str3(40) TYPE c,                   " String.
      w_str2(40) TYPE c,                   " String.
      w_temp     TYPE c,                   " Temporary character.
      w_i        TYPE p,                   " Index outer.
      w_j        TYPE p,                   " Index inner.
      w_flag     TYPE i,                   " Flag variable.
      w_len      TYPE i.                   " Length.
    w_str = p_char.
    w_len = STRLEN( p_char ).
    IF p_char IS INITIAL.
      WRITE 'Enter any string'.
    ELSE.
      IF w_len < 7.
    *Populating w_str and w_str2 with numbers-----------------------------*
        DO w_len TIMES.
          w_index = sy-index - 1.
          w_count = w_len - sy-index.
          w_fact = w_fact * sy-index.
          w_str+w_index(1) = sy-index.
          w_str2+w_count(1) = sy-index.
        ENDDO.                             " DO w_len times.
        w_i = w_str.
        w_j = w_str2.
    *Removing comma and spaces--------------------------------------------*
        WRITE w_i TO w_str3 LEFT-JUSTIFIED.
        TRANSLATE w_str3 USING ', '.
        CONDENSE w_str3 NO-GAPS.
        w_index = 0.
    *While first number is less then last number--------------------------*
        WHILE w_i <= w_j.
          CLEAR w_str2.
          WRITE w_i TO w_str LEFT-JUSTIFIED.
          TRANSLATE w_str USING ', '.
          CONDENSE w_str NO-GAPS.
          DO w_len TIMES.
            w_index = sy-index - 1.
    *If w_str contains only digits from w_str3 then copy that digit into--*
    *w_str2---------------------------------------------------------------*
            IF w_str+w_index(1) CA w_str3.
              w_str2+w_index(1) = w_str+w_index(1).
            ELSE.
    *Else set flag and exit from loop as it is not proper combination-----*
              w_flag = 1.
              EXIT.
            ENDIF.                          " IF w_str+w_index(1) CA w_str3.
          ENDDO.                           " DO w_len TIMES.
    *If flag is zero check for repitation of digits-----------------------*
          IF w_flag = 0.
            DO w_len TIMES.
              w_index = sy-index - 1.
              FIND ALL OCCURRENCES OF w_str3+w_index(1)
                      IN w_str2 MATCH COUNT w_count.
    *If digit repeats set flag and exit from loop-------------------------*
              IF w_count > 1.
                w_flag = 1.
                EXIT.
              ENDIF.                       " IF w_count > 1.
            ENDDO.                         " DO w_len times.
          ENDIF.                           " IF w_flag = 0.
    *If flag is zero then replace digits with corresponding positions of--*
    *real string----------------------------------------------------------*
          IF w_flag = 0.
            DO w_len TIMES.
              w_index = sy-index - 1.
              w_temp = w_str2+w_index(1) - 1.
              w_str2+w_index(1) = p_char+w_temp(1).
            ENDDO.                         " DO w_len TIMES.
            WRITE :/ w_str2.
          ENDIF.                           " IF w_flag = 0.
          w_i = w_i + 1.
          w_flag = 0.
        ENDWHILE.                          " WHILE w_i <= w_j.
        WRITE :
          / 'TOTAL ',
          w_fact,
          ' combinations '.
      ELSE.
        WRITE :/ 'Enter shorter string.'.
      ENDIF.                               " IF w_len < 10.
    ENDIF.                                 " IF p_char IS INITIAL.

  • Sample code to identify special characters in a string

    Hi,
    I need to identify special characters in a string.... could anybody send me some code please.......
    Thanks,
    Best regards,
    Karen

    data: str(100) type c.
    data: str_n type string.
    data: str_c type string.
    data: len type i.
    data: ofst type i.
    str = '#ABCD%'.
    len = strlen( str ).
    do.
      if ofst = len.
        exit.
      endif.
      if str+ofst(1) co sy-abcde.
        concatenate str_c str+ofst(1) into str_c.
      else.
        concatenate str_n str+ofst(1) into str_n.
      endif.
      ofst = ofst + 1.
    enddo.
    write:/ str.
    write:/ str_c.
    write:/ 'spacial chracter',20 str_n.
    Function module  <b>SF_SPECIALCHAR_DELETE</b> <b>DX_SEARCH_STRING</b>
    l_address1 = i_adrc-street.
    CHECK NOT L_ADDRESS1 IS INITIAL.
    len = STRLEN( l_address1 ).
    do len times.
    if not l_address1+l(1) ca
    'ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789 '.
    if i_adrc-street+l(1) CO sy-abcde.
    elseif i_adrc-street+l(1) CO L_NUMCHAR.
    exit.
    endif.
    l = l + 1.
    enddo.
    data : spchar(40) type c value '~!@#$$%^&()?...'etc.
    data :gv_char .
    data:inp(20) type c.
    take the string length .
    len = strlen (i/p).
    do len times
    MOVE FNAME+T(1) TO GV_CHAR.
    IF gv_char CA spchar.
    MOVE fnameT(1) TO inp2T(1).
    ENDIF.
    T = T + 1.
    enddo.
    REPORT ZEX4 .
    PARAMETERS: fname LIKE rlgrap-filename .
    DATA: len TYPE i,
    T TYPE I VALUE 0,
    inp(20) TYPE C,
    inp1(20) type c,
    inp2(20) type c,
    inp3(20) type c.
    DATA :gv_char.
    data : spchar(20) type c value '#$%^&*()_+`~'.
    START-OF-SELECTION.
    CONDENSE fname.
    len = strlen( fname ).
    WRITE:/ len.
    DO len TIMES.
    MOVE FNAME+T(1) TO GV_CHAR.
    IF gv_char ca spchar.
    MOVE fnameT(1) TO inpT(1).
    ENDIF.
    T = T + 1.
    ENDDO.
    CONDENSE INP.
    write:/ 'Special Characters :', inp.
    Rewards if useful..........
    Minal

  • String data size is limited?

    Hi, ABAPERs.
    I'm implementing, following several threads, the uploading of a XML via an XML stream prior to set a XSLT transformation. The problem is that most of the 'job' is doing based on data defined as strings, but the file is cutted in a certain length. The question is that I wanna know is that limit really exists or whether I have to do an alternative uploading process to succeed.
    Thanks for your helping.

    As you all may see, it's the code set in any previous thread with allows me to upload a binary file code up to get a XML. In spite the table line is set to (256 type x lenght), and there's an offset, even before of that it does not get the full file:
      types: begin of ty_xml_line,
             data(256) type x,
             end   of ty_xml_line.
      data:
        lv_ixml type ref to if_ixml,
        lv_stream type ref to if_ixml_stream_factory,
        lt_xml_table type table of ty_xml_line,
        lv_xml_line type ty_xml_line,
        lc_conv type ref to cl_abap_conv_in_ce,
        lv_xml_table_size type i,
        lv_len type i,
        lv_len2 type i,
        lt_tab type tsfixml,
        lv_content type string,
        lv_str1 type string.
    * Generation of XML Stream.
      clear: lv_ixml, lv_stream.
      lv_ixml = cl_ixml=>create( ).
      lv_stream = lv_ixml->create_stream_factory( ).
    * File Generic Management.
      open dataset p_fichero for input in binary mode.
      if not sy-subrc is initial.
    *   call method me->escribir_log( ).
        exit.
      else.
        do.
          read dataset p_fichero into lv_xml_line.
          if sy-subrc is initial.
            append lv_xml_line to lt_xml_table.
          else.
            exit.
          endif.
        enddo.
        close dataset p_fichero.
      endif.
    * Extract XML File Contents..
    * Convert from HEX to XML..
      describe table lt_xml_table.
      lv_xml_table_size = ( sy-tleng ) * ( sy-tfill ).
      loop at lt_xml_table into lv_xml_line.
        lc_conv = cl_abap_conv_in_ce=>create( input = lv_xml_line-data
                                              replacement = space
                                              encoding = 'UTF-8' ).
        lc_conv->read( importing data  = lv_content len = lv_len ).
        concatenate lv_str1 lv_content into lv_str1.
      endloop.
      lv_str1 = lv_str1+0(lv_xml_table_size).
      split lv_str1 at cl_abap_char_utilities=>cr_lf into table pt_contenido.
      loop at pt_contenido into lv_str1.
        replace all occurrences of cl_abap_char_utilities=>horizontal_tab
                                in lv_str1 with space.
        condense lv_str1.
      endloop.
    As said before, is a very standard code.
    Best Regards.

  • Counting SPACES in a string field.

    Hi ,
           can any one plz send me the code for counting the number of spaces in a particular string.
       like if we have the value as 100 00 0000.  we must get the out put as 2 .

    try this...
    DATA : str TYPE string VALUE '100 00 0000',
           str_len TYPE i,
           str_len2 TYPE i,
           space_count TYPE i.
    str_len = STRLEN( str ).
    CONDENSE str NO-GAPS.
    str_len2 = STRLEN( str ).
    space_count = ( str_len - str_len2 ).
    WRITE :/ space_count.

  • Simple string optimization question

    ABAPpers,
    Here is the problem description:
    In a SELECT query loop, I need to build a string by concatenating all the column values for the current row. Each column is represented as a length-value pair. For example, let's say the current values are:
    Column1 (type string)  : 'abc          '
    Column2 (type integer) : 7792
    Column3 (type string)  : 'def                    '
    The resulting string must be of the form:
    0003abc000477920003def...
    The length is always represented by a four character value, followed by the actual value.
    Note that the input columns may be of mixed types - numeric, string, date-time, etc.
    Given that data is of mixed type and that the length of each string-type value is not known in advance, can someone suggest a good algorithm to build such a result? Or, is there any built-in function that already does something similar?
    Thank you in advance for your help.
    Pradeep

    Hi,
    At the bottom of this message, I have posted a program that I currently wrote. Essentially, as I know the size of each "string" type column, I use a specific function to built the string. For any non-string type column, I assume that the length can never exceed 25 characters. As I fill 255 characters in the output buffer, I have to write the output buffer to screen.
    The reason I have so many functions for each string type is that I wanted to optimize concatenate operation. Had I used just one function with the large buffer, then "concatenate" statement takes additional time to fill the remaining part of the buffer with spaces.
    As my experience in ABAP programming is limited to just a couple of days, I'd appreciate it if someone can suggest me a better way to deal with my problem.
    Thank you in advanced for all your help. Sorry about posting such a large piece of code. I just wanted to show you the complexity that I have created for myself :-(.
    Pradeep
    REPORT ZMYREPORTTEST no standard page heading line-size 255.
    TABLES: GLPCA.
    data: GLPCAGL_SIRID like GLPCA-GL_SIRID.
    data: GLPCARLDNR like GLPCA-RLDNR.
    data: GLPCARRCTY like GLPCA-RRCTY.
    data: GLPCARVERS like GLPCA-RVERS.
    data: GLPCARYEAR like GLPCA-RYEAR.
    data: GLPCAPOPER like GLPCA-POPER.
    data: GLPCARBUKRS like GLPCA-RBUKRS.
    data: GLPCARPRCTR like GLPCA-RPRCTR.
    data: GLPCAKOKRS like GLPCA-KOKRS.
    data: GLPCARACCT like GLPCA-RACCT.
    data: GLPCAKSL like GLPCA-KSL.
    data: GLPCACPUDT like GLPCA-CPUDT.
    data: GLPCACPUTM like GLPCA-CPUTM.
    data: GLPCAUSNAM like GLPCA-USNAM.
    data: GLPCABUDAT like GLPCA-BUDAT.
    data: GLPCAREFDOCNR like GLPCA-REFDOCNR.
    data: GLPCAAWORG like GLPCA-AWORG.
    data: GLPCAKOSTL like GLPCA-KOSTL.
    data: GLPCAMATNR like GLPCA-MATNR.
    data: GLPCALIFNR like GLPCA-LIFNR.
    data: GLPCASGTXT like GLPCA-SGTXT.
    data: GLPCAAUFNR like GLPCA-AUFNR.
    data: data(255).
    data: currentPos type i.
    data: lineLen type i value 255.
    data len(4).
    data startIndex type i.
    data charsToBeWritten type i.
    data remainingRow type i.
    SELECT GL_SIRID
    RLDNR
    RRCTY
    RVERS
    RYEAR
    POPER
    RBUKRS
    RPRCTR
    KOKRS
    RACCT
    KSL
    CPUDT
    CPUTM
    USNAM
    BUDAT
    REFDOCNR
    AWORG
    KOSTL
    MATNR
    LIFNR
    SGTXT
    AUFNR into (GLPCAGL_SIRID,
    GLPCARLDNR,
    GLPCARRCTY,
    GLPCARVERS,
    GLPCARYEAR,
    GLPCAPOPER,
    GLPCARBUKRS,
    GLPCARPRCTR,
    GLPCAKOKRS,
    GLPCARACCT,
    GLPCAKSL,
    GLPCACPUDT,
    GLPCACPUTM,
    GLPCAUSNAM,
    GLPCABUDAT,
    GLPCAREFDOCNR,
    GLPCAAWORG,
    GLPCAKOSTL,
    GLPCAMATNR,
    GLPCALIFNR,
    GLPCASGTXT,
    GLPCAAUFNR) FROM GLPCA
    perform BuildFullColumnString18 using GLPCAGL_SIRID.
    perform BuildFullColumnString2 using GLPCARLDNR.
    perform BuildFullColumnString1 using GLPCARRCTY.
    perform BuildFullColumnString3 using GLPCARVERS.
    perform BuildFullColumnString4 using GLPCARYEAR.
    perform BuildFullColumnString3 using GLPCAPOPER.
    perform BuildFullColumnString4 using GLPCARBUKRS.
    perform BuildFullColumnString10 using GLPCARPRCTR.
    perform BuildFullColumnString4 using GLPCAKOKRS.
    perform BuildFullColumnString10 using GLPCARACCT.
    perform BuildFullColumnNonString using GLPCAKSL.
    perform BuildFullColumnNonString using GLPCACPUDT.
    perform BuildFullColumnNonString using GLPCACPUTM.
    perform BuildFullColumnString12 using GLPCAUSNAM.
    perform BuildFullColumnNonString using GLPCABUDAT.
    perform BuildFullColumnString10 using GLPCAREFDOCNR.
    perform BuildFullColumnString10 using GLPCAAWORG.
    perform BuildFullColumnString10 using GLPCAKOSTL.
    perform BuildFullColumnString18 using GLPCAMATNR.
    perform BuildFullColumnString10 using GLPCALIFNR.
    perform BuildFullColumnString50 using GLPCASGTXT.
    perform BuildFullColumnString12 using GLPCAAUFNR.
    ENDSELECT.
    if currentPos > 0.
      move '' to datacurrentPos.
      write: / data.
    else.
      write: / '+'.
    endif.
    data fullColumn25(29).
    data fullColumn1(5).
    Form BuildFullColumnString1 using value(currentCol). 
      len = STRLEN( currentCol ).
      concatenate len currentCol into fullColumn1.
      data startIndex type i.
      data charsToBeWritten type i.
      charsToBeWritten = STRLEN( fullColumn1 ).
      data remainingRow type i.
      do.
        remainingRow = lineLen - currentPos.
        if remainingRow > charsToBeWritten.
          move fullColumn1+startIndex(charsToBeWritten) to
            data+currentPos(charsToBeWritten).
          currentPos = currentPos + charsToBeWritten.
          exit.
        endif.
        if remainingRow EQ charsToBeWritten.
          move fullColumn1+startIndex(charsToBeWritten) to
            data+currentPos(charsToBeWritten).
          write: / data.
          currentPos = 0.
          exit.
        endif.
        move fullColumn1+startIndex(remainingRow) to
            data+currentPos(remainingRow).
        write: / data.
        startIndex = startIndex + remainingRow.
        charsToBeWritten = charsToBeWritten - remainingRow.
        currentPos = 0.
      enddo.
    EndForm.
    data fullColumn2(6).
    Form BuildFullColumnString2 using value(currentCol). 
      len = STRLEN( currentCol ).
      concatenate len currentCol into fullColumn2.
      data startIndex type i.
      data charsToBeWritten type i.
      charsToBeWritten = STRLEN( fullColumn2 ).
      data remainingRow type i.
      do.
        remainingRow = lineLen - currentPos.
        if remainingRow > charsToBeWritten.
          move fullColumn2+startIndex(charsToBeWritten) to
            data+currentPos(charsToBeWritten).
          currentPos = currentPos + charsToBeWritten.
          exit.
        endif.
        if remainingRow EQ charsToBeWritten.
          move fullColumn2+startIndex(charsToBeWritten) to
            data+currentPos(charsToBeWritten).
          write: / data.
          currentPos = 0.
          exit.
        endif.
        move fullColumn2+startIndex(remainingRow) to
            data+currentPos(remainingRow).
        write: / data.
        startIndex = startIndex + remainingRow.
        charsToBeWritten = charsToBeWritten - remainingRow.
        currentPos = 0.
      enddo.
    EndForm.
    data fullColumn3(7).
    Form BuildFullColumnString3 using value(currentCol). 
    EndForm.
    data fullColumn4(8).
    Form BuildFullColumnString4 using value(currentCol). 
    EndForm.
    data fullColumn50(54).
    Form BuildFullColumnString50 using value(currentCol). 
    EndForm.
    Form BuildFullColumnNonString using value(currentCol). 
      move currentCol to fullColumn25.
      condense fullColumn25.     
      len = STRLEN( fullColumn25 ).
      concatenate len fullColumn25 into fullColumn25.
      data startIndex type i.
      data charsToBeWritten type i.
      charsToBeWritten = STRLEN( fullColumn25 ).
      data remainingRow type i.
      do.
        remainingRow = lineLen - currentPos.
        if remainingRow > charsToBeWritten.
          move fullColumn25+startIndex(charsToBeWritten) to
            data+currentPos(charsToBeWritten).
          currentPos = currentPos + charsToBeWritten.
          exit.
        endif.
        if remainingRow EQ charsToBeWritten.
          move fullColumn25+startIndex(charsToBeWritten) to
            data+currentPos(charsToBeWritten).
          write: / data.
          currentPos = 0.
          exit.
        endif.
        move fullColumn25+startIndex(remainingRow) to
            data+currentPos(remainingRow).
        write: / data.
        startIndex = startIndex + remainingRow.
        charsToBeWritten = charsToBeWritten - remainingRow.
        currentPos = 0.
      enddo.
    EndForm.

  • Delete spaces on the right of a string of characters

    Hi,
    I'd like to know how to delete space on the right of a string of characters and ONLY the ones on the right in order I can get the real length of the string (I don't want to condense the spaces between words even though there's more than one).
    data: text(20).
    text = 'SAP Forum'
    In this case, if I use both DESCRIBE LENGTH and DESCRIBE OUTPUT LENGTH, the result will be 20, but the real length is 9.

    Use STRLEN( ), as described by the other posters.
    To delete space chars on the right of a string, use following static method:
    CALL METHOD cl_abap_string_utilities=>del_trailing_blanks
      CHANGING
         str = lv_text.

  • PASS STRING IN TO WHERE CLAUSE

    Hi All,
    i'm facing a problem when i used
    SELECT * INTO TABLE ITAB FROM T000 WHERE T000~MANDT IN (810, 812, 800).
    then it's gives three values which is right according to requirement.
    but i hve to use a string n pass these values by string so i developed a string V_STRING N IT'S VALUE IS SAME AS 810, 812, 800.
    MEANS
    V_STRING = 810, 812, 800
    BUT WHEN I PASSED THIS STRING TO THIS SELECT THEN IT'S GIVE ONLY ONE VALUE FOR ONLY FIRST VALUE MEANS FOR ONLY 810.
    PLS SUGGEST ME WHY IT'S ONLY THROW ING RESULT ONLY FOR ONE VALUE.
    REGARDS,

    The only dynamic select is allowed by using an internal table of not more than 72 characters, so build the full string WHERE clause like:
    DATA: where_clause TYPE TABLE OF char72,
          clause LIKE LINE OF where_clause.
    PARAMETER p_mandt TYPE char50.
    CONCATENATE 'MANDT IN (' p_mandt ')' INTO clause.
    APPEND clause TO where_clause.
    and then
    SELECT * FROM t000  CLIENT SPECIFIED
      WHERE (where_clause).
    Remenber the limit of 72 char. So if only one field is of concern, you should better build a RANGE type internal table and use it in a IN logical expression of the WHERE clause. (Use SPLIT AT ',')
    DATA it_mandt TYPE TABLE OF char4 WITH HEADER LINE.
    DATA range_mandt TYPE RANGE OF t000-mandt WITH HEADER LINE.
    SPLIT p_mandt AT ',' INTO TABLE it_mandt.
    CLEAR range_mandt.
    range_mandt-sign = 'I'.
    range_mandt-option = 'EQ'.
    LOOP AT it_mandt.
      CHECK NOT it_mandt IS INITIAL.
      CONDENSE it_mandt.
      range_mandt-low = it_mandt.
      APPEND range_mandt.
    ENDLOOP.
    and then
    SELECT * FROM t000  CLIENT SPECIFIED
      WHERE mandt IN range_mandt.
    Regards

  • How to convert a string to a currency value ? getting a dump with exception

    Hi,
    I am getting a exception not caught in CX_SY_CONVERSION_NO_NUMBER.
    I am trying to convert a string value with ',' to a currency value.
    I tried using Replace and Condense. But the error still persists.
    Is there a FM or a casting that I can use?
    Cheers
    Kiran

    Hi,
    Sorry I got my question wrong. I have a problem - that when I'm trying to pass a value from a string to a currency field.
    But, the currency field is a field symbol.
    so, I have
    data abc type string.
    abc = "5345"
    <curr_val> = abc.
    now <curr_val> = 0.000
    Please suggest.

  • Retrieving the union of letters from two or more character strings

    Dear Gurus,
    Need your help in writing ABAP logic for the below requirement.
    Assume we have Var1 = 'ABCD' , Var2 = 'CDEF' and Var3 = 'EFGH'. The requirement is to populate Var4 with union of the letters from the above three strings. That means, Var4 should be equivalent to 'ABCDEFGH' after the logic is executed. Can any body help in writing this logic.
    Appreciate your quick help.
    Thanks
    Aryan

    Here's an algorithm that might work for you.. I'm sure there are plenty more!
    report zlocal_jc_union.
    parameters:
      p_var1(10)            type c default 'ABCD',
      p_var2(10)            type c default 'CDEF',
      p_var3(10)            type c default 'EFGH'.
    start-of-selection.
      perform logic.
    *&      Form  logic
    form logic.
    * "Work out unique letters and keep them in sequence.
      data:
        l_union(300)        type c,
        l_byte(1)           type c,
        l_offset            type i.
      concatenate
        p_var1
        p_var2
        p_var3 into l_union. "append them together
      format reset.
      write: / 'Before:', l_union(80).
    *" then remove duplicates, one at a time...
      do.
        l_byte = l_union+l_offset(1).
        do.
          replace l_byte with space into l_union.
          if not sy-subrc is initial. "no more to replace
            exit.
          endif.
        enddo.
        l_union+l_offset(1) = l_byte. "replace original value
        condense l_union no-gaps.
        write: / 'Offset', l_offset, l_union(80).
        add 1 to l_offset.
        if l_offset = strlen( l_union ). "run out of bytes
          exit.
        endif.
      enddo.
    endform.                    "logic

Maybe you are looking for

  • Clear Down Payments at the time of Invoice Posting

    Hi, At the time of invoice posting (customer/vendor) we will a message on exsting down payments.  Is it possible to link the down payment with current invoices??   Please let me the possibilities. Thanks Partha

  • How to find the date and time difference in InfoPath 2013?

    Hi All, My date and time format is like: 2013-12-24T10:47:38 and have three fields Start date, End date and Actual time taken. If start date and end date filled then actual time taken field should automatically should fill, for example 2 days 12 hour

  • LR cc slideshow.

    I tried to export a slideshow with music and Ken Burns effect to DVD.  When I played it on TV it did not have music or any effects.  Am I supposed to be able to export to DVD and play on any tv.  I was told in a weekend seminar by Terry White that th

  • Need to change the buffering of a tbale

    Hi , Im trying with transaction SE13 to change the buffering of a table (usr02) , but when i change the buffering the system tell me that the value is not permited , this happen with all the tables that have the data class 'APPL0 , APPL1 y APPL2' , I

  • Show Attachment in Decision Task

    Hi Experts, I have a Multiline attribute and i want to display the content of the Multi line element in the Decision Task just for the display Purpose in Table format so that it can help the user to take the Decision. Is there any way i can attach th