Assigning part of a string dynamically to a component of a structure

Hello,
I want to take part of a string
example: value = string+10(7)
and assign this value to a structure. But I only have the fieldnames of the structure. I need something like the following
Assign value TO COMPONENT (fieldname) of structure
Thanks.
Regards, Lars.

do you have a set structure name you're dealing with or is that dynamic?
If it's the first scenario and, say, you were dealing with mara and field matnr you could do this:
data l_string.
field-symbols <field> type any.
l_string = in_string+10(18).
assign l_string to <field> casting type matnr.
(or assign l_string to <field> casting like mara-matnr).
now <field> is a 'matnr' type field.
If it's more complex please give some more info as I'm sure what you want can be done.

Similar Messages

  • Assigning amount to months in Dynamic

    Hi all,
    I have a Dynamic ITAB, which is having month names as Dynamic columns. Now i want to assign some amount to each month.
    so, in the assignment part, i write :
    LOOP AT itab   INTO  wa_itab.
        ASSIGN COMPONENT  'MNT_AMT'  OF STRUCTURE <gwa_line> TO <gwa_field>.
        <gwa_field> = wa_itab-mnt_amt.  " this is my Amount value
        DO l_terms TIMES.  " l_terms is dynamic..
              ASSIGN COMPONENT  wa_flname OF STRUCTURE <gwa_line> TO <gwa_field>.
          <gwa_field> = wa_itab-mnt_amt.
        ENDDO.
    endloop.
    but the amount is assigning to the last month only.
    for ex: say i have months, starting from JANUARY to DECEMBER, in my case the amount is assigned to DECEMBer.
    i want to assign amount to each month.
    how to do that ?
    Thanks
    Kamala

    Hi,
    Do as below.
    Assume the month names are stored in an internal table with header line it_months with a single field month. Which means the content of the table it_months will be the colomns of the final interanal table of structure <gwa_line>.
    I assume there is a field which stores the month names in the internal table itab.
    The modified code is below.
    LOOP AT itab INTO wa_itab.
    ASSIGN COMPONENT 'MNT_AMT' OF STRUCTURE <gwa_line> TO <gwa_field>.
    <gwa_field> = wa_itab-mnt_amt. " this is my Amount value
    LOOP AT it_months WHERE month = wa_itab-month.
        ASSIGN COMPONENT it_months-month OF STRUCTURE <gwa_line> TO <gwa_field>.
        <gwa_field> =  wa_itab-mnt_amt.
      ENDLOOP.
    append <gwa_line> to <gt_line>.
    endloop.
    Hope this helps you,
    Murthy.

  • OpenSQLException caught: Cannot assign a blank-padded string

    Hi,
    sometimes I get this exception, when updating a bo instance.
    I didn't managed it to reproduce the error, because it is thrown in a complex background job.
    Can anybody give me more information about the reason behind this?
    Thanks,
    Jens
    stacktrace:
    com.sap.sql.log.OpenSQLException: Cannot assign a blank-padded string to host variable 13.
    at com.sap.sql.log.Syslog.createAndLogOpenSQLException(Syslog.java:95)
    at com.sap.sql.log.Syslog.createAndLogOpenSQLException(Syslog.java:188)
    at com.sap.sql.jdbc.common.dispatch.VarcharHostVariable.setString(VarcharHostVariable.java:34)
    at com.sap.sql.jdbc.common.CommonPreparedStatement.setString(CommonPreparedStatement.java:626)
    at com.sap.engine.services.dbpool.wrappers.PreparedStatementWrapper.setString(PreparedStatementWrapper.java:380)
    at com.sap.engine.services.orpersistence.jdbcaccess.StringBinder.setValue(StringBinder.java:33)
    at com.sap.engine.services.orpersistence.core.StoreManager.bindParameterValues(StoreManager.java:387)
    at com.sap.engine.services.orpersistence.core.StoreManager.executeStatement(StoreManager.java:652)
    at com.sap.engine.services.orpersistence.core.StoreManager.updateEntity(StoreManager.java:625)
    at com.sap.engine.services.orpersistence.core.PersistenceContextImpl.flush(PersistenceContextImpl.java:300)
    at com.sap.engine.services.orpersistence.entitymanager.EntityManagerImpl.flush(EntityManagerImpl.java:121)
    at com.sap.engine.services.orpersistence.entitymanager.EntityManagerHandleImpl.flush(EntityManagerHandleImpl.java:50)
    at com.sap.engine.services.orpersistence.container.EntityManagerProxy.flush(EntityManagerProxy.java:105)
    at com.sap.caf.rt.bol.da.jpa.JPADataAccessService.store(JPADataAccessService.java:495)
    at com.sap.caf.rt.bol.da.jpa.JPADataAccessService.store(JPADataAccessService.java:483)
    at com.siemens.sm3k.mntstrat.modeled.bonode.functionfailure.functionfailure.FunctionFailureBean.update(FunctionFailureBean.java:137)

    Hi,
    I got the same exception with the following code:
    stringVarible="someString"+someMethod.getValue();
    here getValue returns String.But sometimes it may return null valu also.when it returns null value,the same SQL Exception will occure becuse we are trying to save a string in SQL which is blank padded.
    I think your code is also having the similar problem.
    Sampath

  • Converting part of the string to a date and subtract with sysdate.

    HINT! In order solve this you must know how the pnr is assembled. Study this:
    650323-5510, we only need the first six characters. They inform us about when the person (car owner) was born. In this case it is 23 Mars 1965. You have to use several oracle built-in-functions to solve this. Hint! Begin by converting part of the string to a date and subtract with sysdate.
    select to_char(to_date(cast(pnr,'YYMMDDMM'))) from car_owner;
    please what am i doing wrong. i need the result to be something like this
    Hans, Rosenboll, 59,6 years.

    Hi.
    The main problem here is you have only last two digits of year. That could be the problem in a couple of years from now, when somebody born after 2k would get in to your database. For now if we ignore this problem the right solution would be :
    <code>
    SELECT months_between(trunc(SYSDATE),
    to_date('19' || substr('650323-5510',
    1,
    6),
    'YYYYMMDD')) / 12 years_old
    FROM dual
    </code>
    Suppose you are expecting the age of the car owner as a result above code will give you that. One again notice the '19' I appended.
    Best regards.

  • Replacing a part of a String with a new String

    Hi everybody,
    is there a option or a method to replace a part of a String with a String???
    I only found the method "replace", but with this method I only can replace a char of the String. I don't need to replace only a char of a String, I have to replace a part of a String.
    e.g.:
    String str = "Hello you nice world!";
    str.replace("nice","wonderfull");   // this won't work, because I can't replace a String with the method "replace"
                                        // with this method I'm only able to replace charsDoes anyone know some method like I need???
    Thanks for your time on answering my question!!
    king regards
    IceCube-D

    do check java 1.4 api, I think there is a method in it, however for jdk1.3 you can use
    private static String replace(String str, String word,String word2) {
         if(str==null || word==null || word2 == null ||
               word.equals("") || word2.equals("") || str.equals("")) {
              return str;
         StringBuffer buff = new StringBuffer(str);
         int lastPosition = 0;
         while(lastPosition>-1) {
              int startIndex = str.indexOf(word,lastPosition);
              if(startIndex==-1) {
                   break;
              int len = word.length();
              buff.delete(startIndex,startIndex+len);
              char[] charArray = word2.toCharArray();
              buff.insert(startIndex,charArray);
              str = buff.toString();
              int len2 = startIndex+word2.length();
              lastPosition = str.indexOf(word,len2);
         return buff.toString();

  • Can i assign an 'order by' clause dynamically in forms ??

    I know it's possible to assign an 'order by' clause in reports with lexical parameter.
    for example..
    select A
    from TABLE
    where A is not null
    &V_ORDERBY
    In this, v_orderby might be 'order by name' like that,,,
    can i assign an 'order by' clause dynamically IN FORMS ??
    If you understan my question, please answer to me,,,ㅜㅜ

    Have you tried this build-in function?
    SET_BLOCK_PROPERTY('[BLOCK_NAME]', ORDER_BY, 'SORTCOL1, SORTCOL2...');
    Where 'SORTCOL1, SORTCOL2...' are the table columns name.

  • JAXB unmarshalling error for " " token as part of xsd:string type element

    JAXB unmarshalling error for "<" token as part of xsd:string type element
    We are getting a JAXB unmarshalling error:
    while processing the following <condition> tag which is of type xsd:string
    <condition> x < 100 </condition>
    The error is probably happening due to "<" token as a part of string type.
    xml.bind.JAXBException: Unexpected error in Unmarshalling
    at oracle.xml.jaxb.JaxbUnmarshaller.unmarshal(JaxbUnmarshaller.java:224)
    Any ideas how to resolve this issue?
    Note
    <condition> x > 100 </condition> is getting unmarshalled successfully by JAXB unmarshaller.
    Thanks

    Hi,
    Did you tried to put & lt; (without space) instead of < ?
    Best Regards,
    Paweł

  • Addressing of part of the string in the container

    Hello,
    in a mail task I would like to print only some characters from a string - e.g. from second to tenth - is it possible to address some part of the string in the container as is usual in abap?
    thx,
    JJ

    Hi,
    Yes , it is possible. If you want to show only some part of the string value in mail description you can use normal abap string operations. For example: In Mail description if you want to show only a part variable VALUE. you can just use &VALUE+a(b)&. It will work !!
    You can try it out !!
    Regards
    Krishna Mohan

  • Delete part of a string question

    Hello I have this String 12a
    I need to get a the value 12 of it an make it an int
    But the problem is that I don't know what the string is it can be
    12
    or 12 a
    or 12a
    It is for people to fill in there house address and this is the number part.
    The string is like this String number ="\"12a\"";
    Is it possible to look for a letter in a String and delete it if you only want ints???

    Try this on the command line. Dealing with java.lang.NumberFormatException in cases where the number is too large is left as an exercise.
    Harald.
    import java.util.regex.*;
    * demonstrates use of <code>java.util.regex</code> to check if a
    * string starts with digits.
    public class bla {
       * thrown by {@link #getNumber} if the given string does not start
       * with digits.
      private static class BoomBoom extends Exception {
        public BoomBoom(String msg) {super(msg);}
       * reusable pattern to check for digits.
      private static Pattern p = Pattern.compile("[0-9]+");
       * convert leading digits of the parameter to an <code>int</code>
       * and return it.
       * @throws BoomBoom if the parameter does not start with digits.
      public static int getNumber(String s) throws BoomBoom {
        Matcher m = p.matcher(s);
        if( !m.lookingAt() ) {
          throw new BoomBoom("The string `"+s+"' does not start with "
                    +"a positive number.");
        return Integer.parseInt(m.group(0));
      // don't clutter the javadoc
      private bla() {}
       * passes each command line argument through {@link #getNumber} and
       * prints the output or error to <code>System.out</code> or
       * <code>System.err</code> respectively.
      public static void main(String[] argv) {
        for(int i=0; i<argv.length; i++) {
          try {
         System.out.println("Your string `"+argv[i]
                      +"' starts with number "
                      +getNumber(argv));
    } catch( BoomBoom e ) {
         System.err.println(e.getMessage());

  • How Do I Mirror A Part Of A String?

    Dear Programmers,
    Does Anyone know how to mirror a string in C#:
    For example:  looks -> skool
    Thank you in advance,

    There is a Reverse method:
    string s = "looks";
    s = new string(s.Reverse().ToArray());
    Best way to reverse a string:
    http://stackoverflow.com/questions/228038/best-way-to-reverse-a-string
    And you can get a part of a string using the Substring method:
    https://msdn.microsoft.com/en-us/library/system.string.substring(v=vs.110).aspx
    Please remember to mark helpful posts as answer to close your threads and then start a new thread if you have a new question.

  • Using INSTR to extract part of the string ?

    Morning guys and Happy Friday.
    I have a situation where I have to pull out part of the string using a select statement.
    Here is the string and I have to get the contents between the 2nd and 3rd backslash. So, basically, I have to extract marypoppins. Any ideas ?
    C:\USERS\marypoppins\Docs\SpecificationHere is where I started ... and I have stumbled upon trying to find the 3rd backslash. I can easily start the INSTR at 4 because I know that it will always be 'C:\'
    select select substr(C:\USERS\marypoppins\Docs\Specification',
                                INSTRB('C:\USERS\marypoppins\Docs\Specification', '\', 4), .....) from dual;

    Additionally you can break it all up simply with regular expressions..
    SQL> ed
    Wrote file afiedt.buf
      1  with t as (select 'C:\USERS\marypoppins\Docs\Specification' as txt from dual)
      2  -- END OF TEST DATA
      3  select rownum, regexp_substr(txt, '[^\]+',1,rownum) as element
      4  from t
      5* connect by rownum <= length(regexp_replace(txt,'[^\]'))+1
    SQL> /
        ROWNUM ELEMENT
             1 C:
             2 USERS
             3 marypoppins
             4 Docs
             5 Specification
    SQL>

  • Replace part of a string

    I want to replace a part of a string value with another in table column(VARCHAR). For example \\server01\data\doc\123.eps with \\server02\data\doc\123.eps . How to replace the server01 part with server02?

    Use REPLACE.
    Cheers, APC
    SQL> select replace('\\server01\data\doc\123.eps', 'server01', 'server02')
      2  from dual
      3  /
    REPLACE('\\SERVER01\DATA\DO
    \\server02\data\doc\123.eps
    SQL>

  • How to replace part of a String with another String :s ?

    Got a String
    " Team_1/Team_2/Team_3/ "
    And I want to be able to rename part of the string (they are seperated by '/'), for example I want to rename "Team_3" to "Team C", and "Team_1" to "Team A" while retaining the '/' character how would I do this?
    I have tried using String.replace(oldValue, newValue); but this doesnt work, any ideas?

    What do you mean that it doesn't work? You do know that the method returns the modified string? The actual string that you invoke the method on is not altered.
    /Kaj

  • CS3: grep search to replace part of a string

    Can I do a grep search for a string of text but only replace a portion of the string while leaving the remainder intact?
    iMac G5, OS 10.5.5

    In addition to Eric:
    Find "some search string", Replace "some replacement string " also replaces part of the string, not touching anything...
    But the GREP search has two advantages: First, if you define formatting in the Replace field (italics, superscript, a character style), only the 'search'/'replacement' part will be affected, rather than the entire found string (as in regular search).
    The second big advantage is you can use any regular GREP single character wildcard in the 'left' and 'right' (matching-but-not-marking) parts. A few useful examples: '\d' (digit), '\l' and '\u' (lowercase and uppercase), '.' (any character), or even '[a-f]' (lowercase 'a' to 'f'). The only limitation is that you cannot use the once, zero-or-more, or once-or-more modifiers -- the strings must have a fixed length. FYI, those three modifiers are, respectively, ?, *, and +.
    This restriction does not apply to the 'middle' string, the one you are going to replace anyway -- use whatever GREP you want.

  • Is it possible to use the value of a string to reference a component in the

    I'm fairly new to Java so this may be a stupid question!
    Is it possible to use the value of a string to reference a component in the code? For example in the code below, Wall is a class holding 3 different arrays. The Robot class has an array called finishBricks. When the buildWall method is run it receives the integers width and height which are used to construct the dimensions string. I want to use this string to then load the appropriate Wall array into the finishBricks array.
    I hope this makes sense! Any help would be greatly appreciated!
    class Robot {
    public double[][] finishBricks;
    public void buildWall(int width, int height) {
    Wall w = new Wall();
    String dimensions = "Wall" width "x" +height;
    this.finishBricks = w.xxxx; // where xxxx is replaced by whatever the String dimensions is
    class Wall {
         public double[][] Wall4x2 = {
              {-30.00,-01.60,27.45},
              {-30.00,-06.75,27.45},
              {-30.00,-13.55,27.45},
              {-30.00,-20.35,27.45},
              {-30.00,-22.00,28.65},
              {-30.00,-16.85,28.65},
              {-30.00,-10.05,28.65},
              {-30.00,-03.25,28.65}
         public double[][] Wall3x3 = {
              {-30.00,-01.60,27.45},
              {-30.00,-06.75,27.45},
              {-30.00,-13.55,27.45},
              {-30.00,-15.20,28.65},
              {-30.00,-10.05,28.65},
              {-30.00,-03.25,28.65},
              {-30.00,-01.60,29.85},
              {-30.00,-06.75,29.85},
              {-30.00,-13.55,29.85},
         public double[][] Wall2x4 = {
              {-30.00,-01.60,27.45},
              {-30.00,-06.75,27.45},
              {-30.00,-08.40,28.65},
              {-30.00,-03.25,28.65},
              {-30.00,-01.60,29.85},
              {-30.00,-06.75,29.85},
              {-30.00,-08.40,31.05},
              {-30.00,-03.25,31.05},

    Map walls = new HashMap ();
    walls.put ("2x2", new double[][] {
        new double[] {
            1,
            0
        new double[] {
            0,
            1
    double[][] wall = (double[][]) walls.get ("2x2");

Maybe you are looking for

  • Adobe Photoshop Elements 8 Problem

              Ok so here is the problem. I have a windows vista. If that has anything to do with my problem. But the thing is everytime i try to download it i get a report saying i can acess it and it is already installed, but i can not find the file it

  • With Adobe Dynamic Link do you have to buy a suite to be able to use it or can you buy just After Effects and Premiere?

    The company I work for has me on Sony Vegas and After Effects right now.  I am working on getting over to Premiere.  On my personal computer I bought the suite and I have Adobe Dynamic Link and love it.  My questions is since they purchased After Eff

  • Please solve the code

    class Horseradish //insert code here protected HorseRadish(int x) System.out.println("bok choy"); class Washabi extends HorseRadish{ public static void main(String[] args) Wasabi w=new Wasabi(); which two,inserted independently at line 2,will allow t

  • Remotely upgrading/updating Adobe Creative Suite 2

    We have around 30 Mac clients running on our network and I need to upgrade several of them to the latest CS2 versions. They all already have CS2 install, so are just normal Adobe updates, but I'd like to push them out with ARD if possible. Has anyone

  • Hilfe .. Apple ID

    hey , folgende frage durch einen fehler ist meine apple id deaktiviert worden und muss jetzt wieder aktiviert werden .. wie soll ich das machen ?? mfg maxi