String operations in internal table

Dear friends..
        Good morning.
                    I wish to know.. how i segregate the field from a database table to internal table into two different internal table field. say for example.
i have db table tab1 which has field number
tab1 -> number
and i have another internal table itab1 whic has two fields numa and numb
tab1 -> numa
     -> numb
i have value in tab1->number is 001 and 0001
i wish to segregate this two values in to internal table
if the value is 001 then it should be into 001 -> numa
if the value is 0001 then it should be into 0001-> numb
i dont know how to perform the string operations in internal table.. would you like to tell me how i fix this problem any suggetion, article, code will be great help of mine..
thanking you
Regards
Naim

Hi,
  what u can do is check the lenth
lit_data_tab.
lit_data_3
lit_data_4.
lv_char3 type char3.
lv_char4 type char4.
lv_length type i.
loop at lit_data_tab.
lv_length = STRLEN ( lit_data_tab-value ).
if lv_length = 3.
   lv_char3 = lit_data_tab-value .
   append lv_char3 to lv_char3 type char3.
else.
   lv_char4 = lit_data_tab-value .
   append lv_char4 to lv_char3 type char4.
endif.
endloop.
if u want
numa  numb
003   0003.
then u have to loop in one table and modify other.
that is any one table should contains both the field.
read the table with one field
mark helpfull answers
Regards
Message was edited by: Manoj Gupta

Similar Messages

  • String operations on internal table text....

    Original table is consists of 2 columns:
    E        
    RFC error(SM_DHTCLNT010_READ): Error when opening connection
    E RFC error(SM_DHLCLNT010_READ): Error when opening connection
    E RFC error(SM_DHKCLNT010_READ): Error when opening connection
    E RFC error(SM_E10CLNT000_READ): 'tdhtci00.emea.gdc:sapgw02' E     No read RFC FOR SM_B72CLNT003_READ
    E     No read RFC FOR SM_B71CLNT003_READ
    S     Clients for system 'E21' found in RFC  'SM_E21CLNT001_READ'
    S     Clients for system 'E22' found in RFC  'SM_E22CLNT001_READ'
    S     Clients for system 'E23' found in RFC  'SM_E22CLNT001_READ'
    Now we need to apply string operations such that result table is 3 columns with new refined message:
    status       sid            
    Message NEW_TEXT
    E     DHT         
    RFC error               Error when opening connectionE     DHL         RFC error                       Error when opening connection
    E     DHK         RFC error                       Error when opening connection
    E     E10       RFC error                      tdhtci00.emea.gdc:sapgw02
    E     B72        No RFC LINK
    E     B71        No RFC LINK
    S     E21        DATA READ
    S     E22       DATA READ
    S     E23       DATA READ
    String conditions to arrive at new table is:
    1) to get SID column : the conditions are
    •     If the Status is “RFC Error” then next 3 Characters after the “_” must be extracted as SID
    •     Else the SID is between the first and the second inverted comma ‘
    Example:  Clients for system 'E21' found in RFC  'SM_E21CLNT001_READ'extracts “E21” as SID
    2) for message column
    ·         message “RFC Error” if the message text
    starts with “RFC Error”
    · message “no RFC Link” if the message text starts with “No read RFC*”
    · message “Data Read” if the Substring “found in RFC”</b> was found in the Message      
    3) •     If the Status is “RFC Error” then the whole Textstring behind the “: “ must be Extracted
    For example if message is RFC error(SM_DHLCLNT010_READ): Error when opening connection NEW_TEXT will be Error when opening connection
    Need ur inputs on these.
    Bset regards,
    Subba

    Hi,
    this u can acheive simply using offset:
    var_name+off(len). "
    e.g. wa_message-fld+0(3) = first threee characters
    wa_message-fld(3) same as above first three characters
    wa_message-fld+2(2) " will display second and third characte of wa_message-fld
    this u can use to set condtions like :
    if wa_message-fld(9) = 'RFC Error'.
    "process here
    endif.
    Hope this will help u...
    Jogdand M B

  • Set operations on Internal tables.

    Hi,
      Last week i had to enhance a program that has a internal table with some records. I need to find populate a table with the records in the internal table. But before populating i must find out the difference in the records (i.e) the extra records in the internal table compared with the records in the database table and then i have to append those records in the internal table again and then insert the internal table records into database table. while doing it i need to create another internal table with records in database table and then loop at it to find the extra records and rest of the logic goes on.
      At this point of time it clicked in my mind "WHY DON'T WE HAVE SET OPERATIONS ON TWO INTERNAL TABELS(UNION, INTERSECTION, MINUS)".
      Now i am doing some study how to implemnt it. Before that i want to find out whether that functionality exists in ABAP or anybody of youo gurus have done similar work on it.
    Pls help me in proceeding with my work.

    Hi Arul,
    There is no special aided SET operations upon internal tables in ABAP. Concerning your particular task I would say that you can try INSERT statement for each record in your internal table without preliminary comparing them with DB table. If there is a record in DB table with the same key then sy-subrc after INSERT will be non zero (actually 4) and no real insert would occur. So, only those records would be inserted which have no counterpart in DB table.
    Best regards, Sergei

  • Put a string in an Internal Table

    Dear All,
    Hope you have a solution.
    In a program, I have a field type String.
    In this field I put some values separated by TAB -
    I would like to take this field and put it in the header line of an internal table.
    The length of the values put on the string file is not fix.
    Ex: ITAB
                Field1(50)
                FIELD2(50),
                Field3(50)
                FIELD4(50)
    Field_string = 'TOTO#TATA#TITI#TUTU#'
    I would like to obtain
        ITAB-field1 = TOTO
        ITAB-field2 = TATA
        ITAB-field3 = TITI
        ITAB-field4 = TUTU.
    And of course I don't want to write something like
        IF 1 then ITBA1-FIELD1 = u2026
        IF 2 then ITBA1-FIELD2 = u2026
      I'll be surprised that we can't do that in one coding line.
    DO you have an idea ?
    Thanks in advance

    hi,
    see the below pseudo code
    DATA : text TYPE string VALUE 'toto#tata#titi#tutu',
           it_tab TYPE TABLE OF string,
           wa_tab LIKE LINE OF it_tab.
    SPLIT text AT '#' INTO TABLE it_tab.
    " it_tab contain four rows
    LOOP AT it_tab INTO wa_tab.
    "loop it_tab and do your operations
    ENDLOOP.
    BREAK-POINT.
    Thanks

  • Xml string to abap internal  table

    HI Experts ,
    I want to parse this XML file to abap internal table ,i read as usual  the Help and i think
    that something is missing on my code.
    There is someone can help.
    The fields is type string and the value is :
    <Containers> <Container workitemid = "00000017" IsParent = "X"><Element name = "_WF" value = "USI029"/><Element name = "_WF_PRIOR" value = "5"/><Element name = "_WF_VERSION" value = "0000"/><Element name = "_WF_NESTING_LEVEL" value = ""/><Element name = "XUBNAME" value = ""/><Element name = "XUACCNT" value = ""/><Element name = "SHORTTEXT" value = ""/><Element name =
    i use the call transformation code and there i put this code:
    <?sap.transform simple?>
    <tt:transform xmlns:tt="http://www.sap.com/transformation-templates">
    <tt:root name="XML_TAB"/>
      <tt:template>
        <Containers>
          <tt:loop name="a" ref=".XML_TAB">
            <Container>
              <tt:attribute name="Element name" value-ref="$a.name"/>
              <tt:attribute name="value" value-ref="$a.value"/>
            </Container>
          </tt:loop>
        </Containers>
      </tt:template>
    </tt:transform>
    I think that i miss something with the line :<Container workitemid = "0000007" IsParent = "X">
    the dump is:
    An exception occurred that is explained in detail below.
    The exception, which is assigned to class 'CX_ST_MATCH_ATTRIBUTE', was not
      caught and
    therefore caused a runtime error.
    The reason for the exception is:
    XML matching error
    Expected was attribute: "Elementname" [ ] Read was element-start: "Container" [
    Please help
    Regards
    Chris
    Edited by: Chris Teb on Aug 6, 2009 9:57 AM

    H Siva,
    Thanks ,
    I try exactly like u tell and i get this dump:
    An exception occurred that is explained in detail below.
    The exception, which is assigned to class 'CX_ST_MATCH_ELEMENT', was not caught
      and
    therefore caused a runtime error.
    The reason for the exception is:
    XML matching error
    Expected was element-end: "Containers" [ ] Read was element-start: "Container"
    <Containers>
        <Container>
            <tt:loop name="a" ref=".XML_TAB">
            <Element >
              <tt:attribute name="name" value-ref="$a.name"/>
              <tt:attribute name="value" value-ref="$a.value"/>
              </Element>
              </tt:loop>
            </Container>
        </Containers> ->**the dump in the debugger is here .**
      </tt:template>
    </tt:transform>
    Any Idea?
    Regards
    Chris

  • DIFF: Field string ,Structure and Internal table declaration

    Hai,
           what is the diference between  Field string ,Structure in ABAP program and Internal table declaration and how it will work ?
    Thank you
    ASHOK KUMAR.

    hi,
    Look this u will get a good idea.
    *& Report  ZTYPES                                                      *
    REPORT  ZTYPES                                                  .
    * Table declaration (old method)
    DATA: BEGIN OF tab_ekpo OCCURS 0,             "itab with header line
      ebeln TYPE ekpo-ebeln,
      ebelp TYPE ekpo-ebelp,
    END OF tab_ekpo.
    *Table declaration (new method)     "USE THIS WAY!!!
    TYPES: BEGIN OF t_ekpo,
      ebeln TYPE ekpo-ebeln,
      ebelp TYPE ekpo-ebelp,
    END OF t_ekpo.
    DATA: it_ekpo TYPE STANDARD TABLE OF t_ekpo INITIAL SIZE 0,      "itab
          wa_ekpo TYPE t_ekpo.                    "work area (header line)
    * Build internal table and work area from existing internal table
    DATA: it_datatab LIKE tab_ekpo OCCURS 0,      "old method
          wa_datatab LIKE LINE OF tab_ekpo.
    * Build internal table and work area from existing internal table,
    * adding additional fields
    TYPES: BEGIN OF t_repdata.
            INCLUDE STRUCTURE tab_ekpo.  "could include EKKO table itself!!
    TYPES: bukrs  TYPE ekpo-werks,
           bstyp  TYPE ekpo-bukrs.
    TYPES: END OF t_repdata.
    DATA: it_repdata TYPE STANDARD TABLE OF t_repdata INITIAL SIZE 0,   "itab
          wa_repdata TYPE t_repdata.                 "work area (header line)
    Regards
    Reshma

  • How to decompose a string with ';' into Internal table

    Hello all,
    I need your help for find a Function module or Abap code.
    I have a file with the separator is the ';'
    Example of the contains of my file :
    521010;16;46048,00;;*Soucet*Odmena za
    524012;41;103807,00;;Zdrav.p.organizace
    524012;42;;18332,00;Zdrav.p.organizace
    I want a module function which can separate all the String separate by a ';' into a internal table :
    for example my internal table have 5 column :
    Num......|.....CC.....|............Credit....|...........Debit........|.....Label
    521010....|.....16.....|......46048,00.....|...........................|.....Soucet**Odmena za
    524012....|.....41.....|......103807,00...|...........................|.....Zdrav.p.organizace
    524012....|.....42.....|..........................|........18332,00....|.....Zdrav.p.organizace
    For read the date of my file is not a problem with ABAP Code :
    DO.
          CLEAR : ws_facm.
          break epetrini.
          READ DATASET myFile INTO test.
          IF sy-subrc EQ 0.
            IF ws_facm-codenreg = 'D'.
              APPEND ws_facm TO wt_facm.
            ENDIF.
          ELSE.
            EXIT.
          ENDIF.
        ENDDO.
    Thank you for your helps.
    Best regards Emilien
    Edited by: Emilien P. on Mar 31, 2010 4:30 PM
    Edited by: Emilien P. on Mar 31, 2010 4:34 PM
    Edited by: Emilien P. on Mar 31, 2010 4:35 PM
    Edited by: Emilien P. on Mar 31, 2010 4:36 PM

    Hi,
    Try whith this:
    DATA: str1 TYPE string,
          str2 TYPE string,
          str3 TYPE string,
          itab TYPE TABLE OF string,
          text TYPE string.
    text = `What a drag it is getting old`.
    SPLIT text AT space INTO: str1 str2 str3,
                              TABLE itab.
    Let me know if it works.
    Regards,
    Moh.

  • How to perform aritmetic operations on interna table's fields ?

    i have an internal table containing entries from ekpo table.
    while displaying the internal table's entries i would like to add the field containing net price for the same po numbers.
    so, how do i perform arithmetic operations on this itab ? plz help..

    HI,
    see this example.
    u can do like this.
    DATA: BEGIN OF seats OCCURS 0,
            carrid   TYPE sflight-carrid,
            connid   TYPE sflight-connid,
            seatsocc TYPE sflight-seatsocc,
          END OF seats.
    DATA seats_tab LIKE HASHED TABLE OF seats
                   WITH UNIQUE KEY carrid connid with header line.
    SELECT carrid connid seatsocc
           FROM sflight
           INTO table seats.
    loop at seats.
      COLLECT seats INTO seats_tab.
    endloop.
    LOOP AT seats_tab.
    write:/ seats_tab-carrid,seats_tab-connid,seats_tab-seatsocc.
    ENDLOOP.
    rgds,
    bharat.

  • Split a string into multiple internal tables

    Hi all,
    I need to split a string based internal table into multiple internal tables based on some sub strings in that string based internal table...
    High priority help me out...
    eg...
    a | jhkhjk | kljdskj |lkjdlj |
    b | kjhdkjh | kldjkj |
    c | jndojkok |
    d |
    this data which is in the application server file is brought into a internal table as a text. Now i need to send 'a' to one internal table, 'b' to one internal table, so on... help me
    <Priority downgraded>
    Edited by: Suhas Saha on Oct 12, 2011 12:24 PM

    Hi pradeep,
    eg...
    a | jhkhjk | kljdskj |lkjdlj |
    b | kjhdkjh | kldjkj |
    c | jndojkok |
    d |
    As per your statement "Now i need to send 'a' to one internal table, 'b' to one internal table"
    Do you want only a to one internal table and b to one internal table
    OR
    Do you want the whole row of the internal table i mean
    a | jhkhjk | kljdskj |lkjdlj | to 1 internal table
    Having the case of an internal table which is of type string,
    1) Loop through the internal table.    LOOP AT lt_tab INTO lwa_tab.
    2) Ge the work area contents and get the first char wa_tab-string+0(1)
    3)   FIELD-SYMBOLS: <t_itab> TYPE ANY TABLE.
      w_tabname = p_table.
      CREATE DATA w_dref TYPE TABLE OF (w_tabname).
      ASSIGN w_dref->* TO <t_itab>.
    Follow the link
    http://www.sap-img.com/ab030.htm
    http://www.sapdev.co.uk/tips/dynamic-structure.htm
    and then based on the sy-tabix values you will get that many number of internal table
           <FS> = wa_tab-string+0(1)
          append  <FS>
    OR
    USE SPLIT statement at the relevant seperator
    revert for further clarification
    Thanks
    Sri
    Edited by: SRIKANTH P on Oct 12, 2011 12:36 PM

  • Operation on internal table

    Dear experts,
    I have 2 internal table , 1 inernal table have 4 fields and 10 records in that and the other hv 3 fields and 10 records in each field in that . My task is to transfer the 4th field and records of that of 1st table to 2nd field. Need some help on that..
    Table 1 Table 2
    fields- F1 F2 F3 F4 I1 I2 I3 I4
    A1 B1 C1 D1 A1 P1 Q1
    A2 B2 C2 D2 A2 P2 Q2
    A10 B10 C10 D10 A10 P10 Q10
    Here i want records of f4 in i4. Is insert syntax is the way or any other way we can insert the data from table 1 to table 2.
    Loop at Internal table1 into worka area1.
    modify Internaltable2 from work area1 transporting internaltable2-2nd filed = work area1-4th field.
    endloop.
    i tryed with the above  query but i am getting the following error.
    "No component exist with the name internaltable2-2nd filed".
    Thanks And regards.
    Sumeet
    Moderator Message: Duplicate question from a different ID => Double Trouble.
    Edited by: kishan P on Mar 1, 2011 2:15 PM

    REPORT  ZTEST.
    DATA: BEGIN OF IT_TBL OCCURS 0,
            LINE TYPE I,
          END OF IT_TBL.
    DATA: LV_CNT TYPE I.
    DO 20 TIMES.
      LV_CNT = LV_CNT + 1.
      IT_TBL-LINE = LV_CNT.
      APPEND IT_TBL.
    ENDDO.
    delete it_tbl INDEX 5.
    delete it_tbl INDEX 7.
    delete it_tbl INDEX 12.
    LOOP AT IT_TBL.
      WRITE: / IT_TBL-LINE.
    ENDLOOP.

  • Date operations with internal table

    Dear friends
               would you like to tell me. how i determine the most recent date and time from internal table i am not supposed to sort the table by date and time... I must check date and time with other records date and time to determine which record is most recently changed...
    here the scenario is.
    id       idnumber  chdate      chtime
    1        123456    20060606    135312
    2        123456    20060606    135900
    3        123456    20060606    132300
    4        123457    20060606    140000
    5        123457    20060606    142500
    in the above scenario i must keep in my mind that the most recently changed record is identical to its idnumber i can say that:
    the record should be fetched this way
    id       idnumber  chdate      chtime
    3        123456    20060606    132300
    5        123457    20060606    142500
    because here the id 3 is the most recently changed in the idnumber 123456
    where id 5 is the most recently changed in the idnumber 123457
    please help me to determin how i am supposed to carry out this task  any suggestion, code will be great help of mine.
    regards
    Naim

    Hi Naim,
      For example if ur select statement is like this..
       select id idnumber chdate chtime from xtable into table itab  where ...<condn>..
        sort itab by  idnumber chdate chtime  descending.
         delete adjacent duplicates from itab comparing idnumber .
         Code like above statement..
       You can get result...
    id idnumber chdate chtime
    3 123456 20060606 132300
    5 123457 20060606 142500
      Reward the points if it helps.

  • Split String value into internal table at Carriage return

    Hi All,
    I have given a string type context ( text edit  box ) to the user to enter the values. The data can have carriage returns also.
    My Requirement is that I want to split the data at carriage returns and store it in my tables.
    I tired with a constant value of '%CR_LF' as available in CL_ABAP_CHAR_UTILITIES but to no good result.
    Can the Experts suggest some solution?/??
    Thankx in advance.
    Regds,
    Srini

    Hi Srini,
    Have you looked at your string containing the text in the debugger to verify that you really have <CR>+<LF> (i.e. reflecting CL_ABAP_CHAR_UTILITIES=>CR_LF, which should be easily visible when looking at the hex codes of the string)? Maybe it's just a <LF> (i.e. CL_ABAP_CHAR_UTILITIES=>NEWLINE). Might be good to do a REPLACE first using a regular expression for identifying the line feeds and then doing the SPLIT.
    Cheers, harald
    p.s.: If you still cannot get it to work, provide some more details of what you're doing...

  • Converting XML string to internal table

    Hello everyone,
    I am trying to convert an XML string to an internal table. The format of the XML string is as follows:
    <node label="Compressors" NODE_ID="783" checked="1" expandStatus="false">
       <node label="Nail guns" NODE_ID="78543" checked="1" expandStatus="false"/>
       <node label="Spray guns" NODE_ID="855" checked="0" expandStatus="false"/>
       <node label="Cleaning equipment" NODE_ID="9" checked="1" expandStatus="false"/>
    </node>
    What I need is an internal table with the fields NODE_ID and checked filled. The hierarchy here doesn't matter, so I just need an internal table of a structure with 2 fields. The whole XML is hierarchical and contains only the <node> tag, which can be self-closing or not with the attributes within the tag.
    What is the best way to accomplish this?
    Performance here is quite important too, as this XML can contain over 100,000 nodes.
    Should it be done with an xpath expression, with a regex, with the iXML parser, an XSLT call transformation?
    Any help is greatly appreciated!
    Best regards,
    Vincent

    Use this FM to get into internal table
                CALL FUNCTION 'ECATT_CONV_XSTRING_TO_STRING'
                  EXPORTING
                    im_xstring = zl_attcntx
                  IMPORTING
                    ex_string  = zl_attcont.
       SPLIT zl_attcont AT cl_abap_char_utilities=>newline INTO TABLE zit_legacy.

  • Finding duplicates:Minus set operator in dealing with internal tables

    Dear experts,
    I am newbie to ABAP developement,i have been given an assignment to find the duplicate list of vendors in lfa table.
    Now duplicate list doesnot means that text tokens will be just exact to conclude them as duplicate ,it could also be like
    1111 Vendor ABC
    1222 ABC Vendor
    If anybody has clue ,how to work on such a problem ,plz come forward.
    Right now i just tried initially how to find exact duplicates,i found  on change command,it do works.
    Then i am trying a new way which should just do the same thing.
    I did as per this algorithm
    1.Compute wholesome list in one internal table itab1
    2.Used delete adjacent duplicates in itab2.
    3.I feel itab3=itab1-itab2 will contain all duplicates in itab3.
    Can anyone give me a hint.How can i do A-B ?.

    Hi Arul,
    There is no special aided SET operations upon internal tables in ABAP. Concerning your particular task I would say that you can try INSERT statement for each record in your internal table without preliminary comparing them with DB table. If there is a record in DB table with the same key then sy-subrc after INSERT will be non zero (actually 4) and no real insert would occur. So, only those records would be inserted which have no counterpart in DB table.
    Best regards, Sergei

  • String and Internal table

    We have a large character string in the memory, e.g. of 5M.
    (1) we want to split the character string into an internal table with a field of c(1000), for example.
    (2) we want to read the internal table, and concatenate each line into one string.
    For STRLEN and CONCATENATE, it always ignores the trailing blanks. However, we don't want to LOSE ANY BLANKS.
    thanks,
    -Stanley

    I don't think there is any availble function module that does it. You may have to code for it. Also the blanks are a problem. So try something like this, which was actually suggested by Sanjay while responding to another question in this forum
    First replace all the blank space with a character that you know for sure, will not be there in your string.
    TRANSLATE mystring USING ' @'.
    Now do your STRLEN and get your string length.
    The you can split your string using the option INTO TABLE. Your itab will have only one field of 1000 length.
    Then read the internal table and concatenate them back into the long string.
    Finally, you reverse the pattern in the previous TRANSLATE statement to '@ '.
    Srinivas

Maybe you are looking for

  • Jabber voice crashes on iPhone 5S

    Hi, Just installed latest version if Jabber Voice from the Apple AppStore and it immediately crashes when selected. I am running IOS 7.0.4. Anyone experiencing the same thing? Appreciate all assistance!

  • This Computer is no longer authorized!! HELP PLEASE!

    After changing the logic board on my MacBookPro recently, tried to sync and transfer my purchased apps & music to ITunes, it comes back saying "This computer is no longer authorized for this Iphone... and then I continue to authorize it, the it says

  • HOWTO/FIX: How to get your iPod touch recognised in iTunes

    Hi, I'm going to explain how to fix this problem but let me give you a little background first. I was starting from scratch so what could go wrong: 1. Fresh Windows XP SP2 install, fully updated on brand new MacBook pro. 2. Firewall (Komodo) and Anti

  • HTTP error [403] in "Add Forums Administrator User"-iView (Forum)

    Hi All, I need help with installing the forum functionality. When I open the "Add Forums Administrator User"-iView I always get the following error message: <i>403   Forbidden You are not authorized to view the requested resource.</i> In the log-file

  • Error Message: System UIDs Inconsistent

    I got this message after I turned on the phone: "UIDs on the system are inconsistent, you need to wipe your data partition or your device will be unstable." Can someone put this in plain English for me and tell me what exactly it is telling me and ho