Add 2 strings together

Hello,
i have a really weird error message here:
say I define 2 dta type c objects:
data: tot_str(50) type c,
      sub_str(20) type c.
then I do
    tot_str = 'ABCDEF' & substr
assuming both tot_str and sub_str are already initialized.
However, the error message I got is:
Incorrect arithmetic or bit expression: Instead of "&", an operator (+,     -, *, /, ... or BIT-AND, BIT-XOR, BIT-OR) was expected.)
Why is it so? I thought & is the standard concatenation character for ABAP. And BTW, when I changed to +, it will give me a run-time error saying that the 2 strings can not be added....
Thanks a lot!
Regards,
Anyi

Hi Anyi,
yes you are right. I found it in SAP help hidden somewhere in the data objects section:
"If you want to enter a character literal in the ABAP Editor that is longer than a single editor line, ABAP syntax allows you to enter several character literals and link them using the & character. "
So this was just a crutch to bypass the (meanwhile obsolete) editor line length limit.
I the section "Processing Character Strings", chapter "Concatenating Character Strings", they say:
"The CONCATENATE statement combines two or more separate strings into one.
CONCATENATE <c1> ... <cn> INTO <c> [SEPARATED BY <s>].
This statement concatenates the character fields <c1> to <cn> and assigns the result to <c>. The system ignores spaces at the end of the individual source strings.
The addition SEPARATED BY <s> allows you to specify a character field <s> which is placed in its defined length between the individual fields."
That means that all leading and trailing spaces will disappear except the ones in the separator string <sep>.
So it depends on the result you want as how to do the concatenation. if you want a fixed position regardless of blanks, then you must work with offset and length addition.
Kind regards,
Clemens

Similar Messages

  • How do I add strings together with JSTL?

    How do I add strings together with JSTL?
    Thanks,
    JN

    Just include them together in an expression string.
    For printing
    <c:out value="${user.lastName}, ${user.firstName}"/>
    or with a set statement
    <c:set var="fullName" value="${user.lastName}, ${user.firstName}"/>

  • Putting 2 strings together

    Dear Colleagues
    I have a short piece of coding I would hope for some advice on.
    public class ReadTest {
    public static String readString() throws java.io.IOException {
    java.io.BufferedReader in =
    new java.io.BufferedReader(new java.io.InputStreamReader(System.in));
    return in.readLine();
    public static void main(String args[]) {
    try {
    System.out.println("Enter a string: ");
    String inputValue = ReadTest.readString();
    System.out.println("You entered: " + inputValue);
    } catch (java.io.IOException e) {
    System.out.println("An error occurred!");
    I have compiled this and was invited on the DOS screen to:"Enter a string". But where do I enter the string?
    Then I need to modify the program a little to read two strings and to ensure that the first string ends with the second string. Do I then take it that once I have grasped the fundamentals of joing 2 strings together, that that is the normal rule?
    Hopefully, I will begin to understand the code with some help here.
    Best wishes
    Quetzal1

    println isnot for user input try the following
    import javax.swing.*;
    import java.awt.event.*;
    import java.awt.*;
    class KeyView extends JFrame implements KeyListener {
    JTextField keyText = new JTextField(80);
    JLabel keyLabel = new JLabel("Press any key in the text field.");
    KeyView() {
    super("KeyView");
    setSize(350, 100);
    setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    keyText.addKeyListener(this);
    Container pane = getContentPane();
    BorderLayout bord = new BorderLayout();
    pane.add(keyLabel, BorderLayout.NORTH);
    pane.add(keyText, BorderLayout.CENTER);
    setContentPane(pane);
    setVisible(true);
    public void keyTyped(KeyEvent input) {
    char key = input.getKeyChar();
    keyLabel.setText("You pressed " + key);
    public void keyPressed(KeyEvent txt) {
    // do nothing
    public void keyReleased(KeyEvent txt) {
    // do nothing
    public static void main(String[] arguments) {
    KeyView frame = new KeyView();

  • Add String to JNDI Tree

    I'm coming from a Glassfish/Tomcat environment where we can add Strings directly to the JNDI tree. What we would like to do is add "config/env/dev" to the JNDI tree so that we can use Spring to determine which environment we are in based on this setting in each node in the cluster environment. From there, we use CommonsConfiguration to manage our environment specific settings in our applications.
    Can someone tell me how I can add a string variable as such to the JNDI tree in WebLogic 10.3?
    Thanks,
    Lou

    WRITE THE FOLLOWING SCRIPT IN THE WHEN-BUTTON-PRESSED
    INSERT INTO TABLE VALUES (NEW_DISPLAY_LABEL,NEW_VALUE);
    COMMIT;
    P_PARENT_NODE_VALUE:= ftree.get_tree_node_property('tree4',:system.trigger_node,ftree.node_value);
    P_PARENT_NODE := Ftree.Find_Tree_Node('tree4',P_PARENT_NODE_VALUE,Ftree.FIND_NEXT, Ftree.NODE_value, Ftree.ROOT_NODE, Ftree.ROOT_NODE);
    P_NEW_NODE := ftree.add_tree_node('tree4',P_PARENT_NODE,ftree.parent_offset,ftree.last_child,ftree.expanded_node,NEW_DISPLAY_LABEL,null,NEW_VALUE);
    Message was edited by:
    zakaoullah

  • Generate n sine waves and add them together

    Hi
    I'm new to Labview and I want to generate n number of sine waves and add them together to form one signal that can be out put through a DAQ card. Each successive wave frequency will be the multiple of a base wave all will be the same amplitude.
    This to me suggested a For loop with a sig generator  and a passback in it but when I tried this it threw an error because the dt were different.
    Any help will be appreciated.
    Thanks

    Show us what you did.
    LabVIEW Champion . Do more with less code and in less time .

  • Can I string together multiple iPad videos to make a DVD?

    Can I string together multiple iPad videos to make a DVD ?

    Not on the ipad itself.
    You need a computer with the appropriate software.

  • Add String to array

    I have an array:
    private static Person[] names;
    names= new array[10];
    How do I write a method to add Strings to the array

    Hi
    Well you could have a variable inside the class which tells you how many slots are filled up.
    Then in your addString method you would just use this variable as the index, and then increment the index.
    Its best that you use an array if the number of elements are known, on one hand you will get the benefit of strong typing (Vector will take an object and you will have to typecast the object back before using it), and on the second hand it will be much faster
    Aly.

  • How to add strings to file?..

    Hi, everybody!
    Please, help me in a simple question:
    I have to add strings to text-file.
    ADD!
    My task is:
    if(the file isn't excist ){
    create new file, open it and write, for example, 3 strings;
    else{
    open file and ADD 3 strings;
    How to make it?
    My text-file is big - nearly 65MB..
    I'll be happy, if you can give example..

    This file allows you to add to already available file, but if not available, it will be created.
    Tell me if this helps you .
    Cheers
    * @Title    :AddFile.java
    * @date     :today
    * @version  :v1.0
    * @author   :Your name
    import java.io.*;
    import java.net.*;
    public class AddFile extends Object
        public static void main (String [] args) throws IOException
            System.out.print ("Enter your message: ");
            BufferedReader input = new BufferedReader (
                              new InputStreamReader (System.in));
            String userInput = input.readLine ();
            BufferedWriter out = new BufferedWriter (
                           new FileWriter ("akoko.txt", true));
            out.write (userInput);
            out.close ();
    }

  • Add numbers together from a file

    I need to be able to determine the difference of each number from the average and square each difference and sum all the differences.
    I found out that the average of the numbers from the file (7 4 5 9 10) is 7. i just need to minus each number from the average then add those numbers together.
    import java.io.File.*;
    import java.util.Scanner;
    import java.io.IOException.*;
    import java.io.*;
    public class Statistics{
    double Placeholder=0.0;
    double count;
    double Totalnumber=0.0;
    double Difference;
    int line = 0;
    int line1;
    // constructor
      public void CalculateStats()throws Exception {
            Scanner in = new Scanner(new FileReader("H:/programs/num.txt"));
            while  (in.hasNextInt()){
                line = in.nextInt();
                System.out.println(line);
                Placeholder = Placeholder + 1;
                Totalnumber= Totalnumber + line;
                for (count=0; count < Placeholder; count += 1){
                    Difference =Difference + Math.pow((line-(Totalnumber / Placeholder)),2);
                System.out.printf("There are "+Placeholder);
                System.out.printf(" numbers");
                System.out.println("");  
                System.out.println("");
                double Average = Totalnumber / Placeholder;
                System.out.printf("The total value= "+Totalnumber);
                System.out.println("");
                System.out.println("");
                System.out.printf("The average of the numbers= ");
                System.out.printf("%.2f",+Average);
                System.out.println("");
                System.out.println("");
                System.out.println("Difference=" +Difference);
    public static void main (String args[])throws Exception{
    Statistics Run  = new Statistics();
    Run.CalculateStats();
    }so far it displays the average correctly. i just need to find out how to loop the equation for finding the distance.
    To me my loop looks like it would work. where should i go from here?

    while  (in.hasNextInt()){
    line = in.nextInt();
    System.out.println(line);
    Placeholder = Placeholder + 1;
    Totalnumber= Totalnumber + line;
    for (count=0; count < Placeholder; count += 1){
    Difference =Difference + Math.pow((line-(Totalnumber / Placeholder)),2);
    }so far it displays the average correctly. i just need to find out how to loop the equation for finding the distance.
    To me my loop looks like it would work. where should i go from here?You have a for-loop inside your while-loop. The first item through the while-loop your for-loop iterates 1 time; the second time through your while-loop your for-loop iterates 2 times; the third time through your while-loop your for-loop iterates 3 times; ...
    I do not think this is what you want. I'm not sure you need the for-loop at all.

  • How do I add variables to different checkboxes without using the 'Export Value' and then add them together (if checked)?

    Hello,
    I am very new to JavaScript.  I would like to create a checkbox with a numerical value variable activated if the box is checked.  Unfortunately, I cannot use the 'Export Value' because I already need to use it for something else.
    Any help is really appreciated.
    Thanks,
    Robyn

    Brace yourself, here's your solution.
    First of all, the export value of you checkboxes should definitly be the number of hours for the class since you will just add them up further.
    Second, we will use the userName property for our second export value (its the field right under Name and its labeled "tooltip").  You will name the class there.
    Finally, you need to name each checkbox with a number at the end starting with 1 all the way to 190.  This will be used in loops. ("whatever.1", "whatever.2,....."whatever.190")
    In the calculate event of "total hours":
    var sum = 0;  //declaring a variable that will be used in the loop
    for (var i = 1; i <= 190; i++){    //this loop will scan through all your checkboxes
         if (this.getField("whatever."+i).isBoxChecked(0) == true){  //if box is checked....
              sum += Number(this.getField("whatever."+i).value);   //.....add its value to the sum
    event.value = sum;  //display the total
    Now for the course name field, we will use the same pattern in the calculate event
    var courseList = new Array();  //declaring an empty array that will contain the courses
    for (var i = 1; i <= 190; i++){    //this loop will scan through all your checkboxes
         if (this.getField("whatever."+i).isBoxChecked(0) == true){  //if box is checked....
              courseList.push(this.getField("whatever."+i).userName);   //.....add its userName (tooltip) to the array
    event.value = "You are attending these courses:  "+courseList.join(", ")+".";  //display the array by turning it into a string and joining its items with ", "
    You can try it out with just a few checkboxes at first.  Don't forget that the loop mustn't go further than the existing field or you will get an error and the script will stop.  Make sure no error show in the console (ctrl+J).

  • Add string  in sql statement

    hi
    i want to add one string in a output of the sqlstatemnt.below is my sql statement
    select
    XMLELEMENT ("DATABASE_OBJECTS",xmlagg(
    XMLFOREST (owner,
    object_type,
    object_name,
    object_user_name,
    physical_name
    ).getClobVal()
    FROM xxhex_custom_objects;
    the string whic i want to add in output is:
    '<?xml version="1.0" encoding="UTF-8"?>'.
    i tried the below query but it is giving me an error.
    select '<?xml version="1.0" encoding="UTF-8"?>',
    XMLELEMENT ("DATABASE_OBJECTS",xmlagg(
    XMLFOREST (owner,
    object_type,
    object_name,
    object_user_name,
    physical_name
    ).getClobVal()
    FROM xxhex_custom_objects;

    >
    i want to add one string in a output of the sqlstatemnt.below is my sql statement
    select
    XMLELEMENT ("DATABASE_OBJECTS",xmlagg(
    XMLFOREST (owner,
    object_type,
    object_name,
    object_user_name,
    physical_name
    ).getClobVal()
    FROM xxhex_custom_objects;
    the string whic i want to add in output is:
    '<?xml version="1.0" encoding="UTF-8"?>'.
    >
    Unless the result of your XMLELEMENT query is valid XML adding that string won't accomplish anything. The result will NOT be valid XML.
    See my replies in this thread
    Re: expression must have same datatype
    If your query result is a string then you use || to concatenate strings so just do that in your query.
    SELECT 'abc' || 'def' FROM DUAL;
    select '<?xml version="1.0" encoding="UTF-8"?>' || XMLELEMENT . . .

  • How to add string in editable datagrid

    Hai
           I have attached the mxml below.
       I need to add ' ' before and after the value.
       1. here i have the mxml, run the mxml , enter some vlaue in textbox and click add button, now the values will be added
       2. u can see the value in single quotes ie. ' '
       3. now u click the Value column  u can edit the value, after editing the value will not be in ' '
       4. here i have a problem, if the value is not in ' ' , i cant submit that query.
       5. how can i add ' ' after editing .
    can any one help me
    Thanks in Advance : )
    <mx:Application 
    xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute"
    >
    <mx:Script>
    <![CDATA[
    // ActionScript fileimport  
    mx.rpc.events.FaultEvent;
    import  
    mx.controls.Alert; 
    importmx.managers.CursorManager;
    import  
    mx.collections.ArrayCollection;[
    Bindable]
    public var adhoc:ArrayCollection = newArrayCollection();[
    Bindable] 
    public var serverString = "";
    private function initImage(event:MouseEvent):void{
    if(adhoc.length > 0){
    private function onChange():void{
    if(comboBox.selectedIndex == 0){
    else{
    private function onChange1():void{
    if(combo2.selectedItem == "DATEDEPLOYED" || combo2.selectedItem == "DATEUPLOADED"){datepick.visible =
    truetxt.visible =
    false}
    else{txt.visible =
    truedatepick.visible =
    false
    private function add():void{
    varstr:String = txt.text; 
    if(str.length == 0 && txt.visible == true){Alert.show(
    "Value Can Not Be Empty"); 
    return;
    if(combo2.selectedItem != "DATEDEPLOYED" || combo2.selectedItem != "DATEUPLOADED"){
    if(txt.visible == true){ 
    var temp:Object = newObject();
    "'"+txt.text+"'";
    varstr1:String = datepick.text; 
    if(comboBox.selectedIndex == 1){ 
    if(combo2.selectedItem == "DATEDEPLOYED" || combo2.selectedItem == "DATEUPLOADED"){ 
    if(str1.length == 0 && datepick.visible == true){Alert.show(
    "Date Cannot Be Empty");}
    else{ 
    var temp:Object = newObject();
    false;addopenbracket.enabled =
    false;combo2.enabled =
    false;combo1.enabled =
    false;
    private function querydelete():void{
    if(AdHoc.selectedIndex > 0) { 
    if(AdHoc.selectedIndex == (adhoc.length-1)){adhoc[AdHoc.selectedIndex-1].cond =
    ""; addopenbracket.enabled =
    false;addclosebracket.enabled =
    false;addbutton.enabled =
    false;combo2.enabled =
    false;combo1.enabled =
    false;
    // adhocdetailgridcompilance.dataProvider = null ; 
    // adhocdetailgrid.dataProvider = null ;
    else if(adhoc.length == 1) {
    // adhocdetailgridcompilance.dataProvider = null ; 
    // adhocdetailgrid.dataProvider = null ;addopenbracket.enabled =
    true;addclosebracket.enabled =
    true;addbutton.enabled =
    true;combo2.enabled =
    true;combo1.enabled =
    true;}
    else{Alert.show(
    "Select The Rows To Delete");
    private function andSubmit():void{
    for each(var obj:Object inadhoc){ 
    if(obj.fname == combo2.selectedItem && obj.opera == combo1.selectedItem){ 
    if(combo2.selectedItem != "DATEDEPLOYED" || combo2.selectedItem != "DATEUPLOADED"){ 
    if(txt.visible == true){ 
    trace("2 equals"); 
    var temp:Object = newObject();
    else{ 
    trace(obj.fname + ":"+ combo2.selectedItem);  
    trace(obj.opera + ":"+ combo1.selectedItem); 
    trace(obj.val + ":" + "'"+txt.text+"'");
    else if(obj.fname == addclosebracket.label){ 
    if(combo2.selectedItem != "DATEDEPLOYED" || combo2.selectedItem != "DATEUPLOADED"){ 
    if(txt.visible == true){ 
    trace("2 equals"); 
    var temp:Object = newObject();
    else{ 
    trace(obj.fname + ":"+ combo2.selectedItem);  
    trace(obj.opera + ":"+ combo1.selectedItem); 
    trace(obj.val + ":" + "'"+txt.text+"'");
    if(obj.fname == combo2.selectedItem && obj.opera == combo1.selectedItem){ 
    if(combo2.selectedItem == "DATEDEPLOYED" || combo2.selectedItem == "DATEUPLOADED"){ 
    if(datepick.visible == true){ 
    trace("2 equals"); 
    var temp:Object = newObject();
    else{ 
    trace(obj.fname + ":"+ combo2.selectedItem);  
    trace(obj.opera + ":"+ combo1.selectedItem); 
    trace(obj.val + ":"+ datepick.text);
    else if(obj.fname == addclosebracket.label){ 
    if(combo2.selectedItem == "DATEDEPLOYED" || combo2.selectedItem == "DATEUPLOADED"){ 
    if(txt.visible == true){ 
    trace("2 equals"); 
    var temp:Object = newObject();
    else{ 
    trace(obj.fname + ":"+ combo2.selectedItem);  
    trace(obj.opera + ":"+ combo1.selectedItem); 
    trace(obj.val + ":"+ datepick.text);
    true;addopenbracket.enabled =
    true;combo2.enabled =
    true;combo1.enabled =
    true;
    private function orSubmit():void{
    for each(var obj:Object inadhoc){ 
    if(obj.fname == combo2.selectedItem && obj.opera == combo1.selectedItem){ 
    if(combo2.selectedItem != "DATEDEPLOYED" || combo2.selectedItem != "DATEUPLOADED"){ 
    if(txt.visible == true){ 
    trace("2 equals"); 
    var temp:Object = newObject();
    else{ 
    trace(obj.fname + ":"+ combo2.selectedItem);  
    trace(obj.opera + ":"+ combo1.selectedItem); 
    trace(obj.val + ":" + "'"+txt.text+"'");
    else if(obj.fname == addclosebracket.label){ 
    if(combo2.selectedItem != "DATEDEPLOYED" || combo2.selectedItem != "DATEUPLOADED"){ 
    if(txt.visible == true){ 
    trace("2 equals"); 
    var temp:Object = newObje

    you declare Fchg's three parameter is any data type,so you can directly use Fchg
    function.
    "beawhycn" <[email protected]> wrote:
    >
    1.if buffer type=FML,then ' Fchg(sendBuf, Fldid("ACCOUNT_ID"), 0, accountNumber&,
    0)' can add the accountnumber into sendbuffer.
    2.if buffer type=STRING ,then how can i add a simple string into sendbuffer
    before
    the tpcall()?
    Eager for the reply.

  • How to add string to sendbuffer in visual basic?

    1.if buffer type=FML,then ' Fchg(sendBuf, Fldid("ACCOUNT_ID"), 0, accountNumber&,
    0)' can add the accountnumber into sendbuffer.
    2.if buffer type=STRING ,then how can i add a simple string into sendbuffer before
    the tpcall()?
    Eager for the reply.

    you declare Fchg's three parameter is any data type,so you can directly use Fchg
    function.
    "beawhycn" <[email protected]> wrote:
    >
    1.if buffer type=FML,then ' Fchg(sendBuf, Fldid("ACCOUNT_ID"), 0, accountNumber&,
    0)' can add the accountnumber into sendbuffer.
    2.if buffer type=STRING ,then how can i add a simple string into sendbuffer
    before
    the tpcall()?
    Eager for the reply.

  • Masterdata upload - Add string after conversion

    Hi experts,
    I upload masterdata from BW using transformationfile and conversionfile. To create a BPC specific ID I need to remove the leading zeros first (using js:parseInt in conversion) and afterwards I need to add a string (VK) at the end of the ID. How can I do that. Using *Str(VK) in transformation will lead to an error as the js:parseInt statement in the conversion file will no longer work.
    Any help appreciated.
    Thanks in advance
    Felix

    Hi Flex,
    You can achive this by using end routine badi.
    LOOP AT <lt_data_im> ASSIGNING <ls_data>.
    Get ID value
    ASSIGN COMPONENT `ID` OF STRUCTURE <ls_data> TO <lv_id>.
    IF sy-subrc <> 0 OR <lv_id> IS INITIAL.
    CONTINUE.
    ENDIF.
    CALL FUNCTION 'CONVERSION_EXIT_ALPHA_OUTPUT'
        EXPORTING
          INPUT  = <lv_id>
        IMPORTING
          OUTPUT = <lv_id>.
    Concatenate your string to <lv_id>
    ENDLOOP.
    Thanks & Regards,
    Kalyan Undavally.

  • Add fields together

    I am rather new at all this, but I am trying to add two fieds together. co_ann_lv and co_sick_lv.
    I want it under Total CO Leave, but I don't know where to start.
    Thanks.

    This is FormCalc.  Set the Total CO Leave field to the Change event and use this cript:
    Sum(co_ann_lv, co_sick_lv)

Maybe you are looking for

  • Can I add a WiFi printer through WPS with the new AirPort Extreme and AirPort Utility 6.3?

    It says here that AirPort Utility 6.2 supports WPS-capable WiFi printers, but on the new AirPort Extreme techs pecs Apple insists that the way printing is shared is by connecting the printer to the AirPort Extreme with a USB cable, which really defea

  • External Hard Drive and iTunes Help

    iTunes Here is my impossible question that many people keep giving me the wrong answer or at least differing answers.  This involves "senior advisors" in apple.  Few things to note: - I'm using iTunes 11.0.1 - I have the newest gen Apple TV - I have

  • Oracle 10.2.0.4 cannot find sdo_georaster

    Hello, I got a machine (installed by others), when I tried to create sdo_georaster object: SQL> create table t1(id number, img mdsys.sdo_georaster); create table t1(id number, img mdsys.sdo_georaster) ERROR at line 1: ORA-00902: invalid datatype 1. S

  • Reverse video

    Not able to print reverse video field using Smartform with Zebra printer. Help required. Regards.

  • Source file information

    I have the original source file for an illustrator image used for a business card. My intention is to bring this image to the web.  I would like to make some color changes, is there any way that I can detect or find using the source image the exact f