Split a field

Hi all,
I have a field of length 8. I need to split it into components of different lengths. How would i do it in ABAP?
Bala

<b>FYI</b>
SPLIT f AT g INTO h1 ... hn.
Extras:
1. ... IN BYTE MODE
2. ... IN CHARACTER MODE
Effect
Splits f wherever the separator g occurs and places the resulting sections into the fields h1 ... hn (n >= 2). Note that if g has type C, the field is used in its defined and not its occupied length.
The field is split using the following procedure: f is split internally into a set of target fields k1 to kn with the same type as f. These are then transferred into the actual target fields h1 to hn using MOVE semantics.
The Return Code is set as follows:
SY-SUBRC = 0:
All of the fields hi (1 <= i <= n) were large enough.
SY-SUBRC = 4:
One of the fields hi was not large enough and significant characters were lost.
Examples
DATA: NAMES(30)    TYPE C VALUE 'Charly, John , Peter',
      NAMES2       TYPE STRING,
      ONE(10)      TYPE C,
      TWO(10)      TYPE C,
      THREE        TYPE STRING,
      FOUR(4)      TYPE C VALUE 'FOUR',
      DELIMITER(2) VALUE ','.
SPLIT NAMES AT DELIMITER INTO ONE TWO.
    ONE contains 'Charly' and TWO contains 'John , Pet'.
    SY-SUBRC is 4, because TWO was not large enough to
    accommodate the whole of the remaining string
SPLIT NAMES AT ',' INTO ONE TWO THREE.
    ONE contains 'Charly', TWO contains ' John',
    THREE contains ' Peter'.
SPLIT NAMES AT ', ' INTO ONE THREE TWO.
    ONE contains 'Charly', THREE contains 'John',
    TWO contains 'Peter'.
CONCATENATE NAMES '' INTO NAMES2 SEPARATED BY SPACE.
SPLIT NAMES2 AT DELIMITER INTO ONE TWO THREE FOUR.
    ONE contains 'Charly', TWO contains 'John',
    THREE contains 'Peter ', FOUR is empty.
SPLIT NAMES2 AT DELIMITER INTO ONE FOUR THREE.
    ONE contains 'Charly', FOUR contains 'John',
    THREE contains 'Peter', SY-SUBRC is 4, since
    FOUR was not large enough (spaces are significant
    characters!)
Addition 1
... IN BYTE MODE
Effect
If you use this addition, all fields must be of the type X or XSTRING.
Addition 2
... IN CHARACTER MODE
Effect
This addition is optional and corresponds to the default setting (see above).
Notes
If the number of target fields is not greater than the number of separator strings in the source string, very little information can be lost. In this case, the last target field contains the "remainder", including the separator string (see first example).
If the source field does not contain the separator string, or if you specify an empty C string as the separator, the entire source field is placed in the first target field.
Any target fields that are not required are deleted.
If f begins with the separator string g, the first target field (h1) contains an initial value.
Variant 2
SPLIT f AT g INTO TABLE itab.
Extras:
As with variant 1
Effect
Similar to variant 1
The sections of f are placed in the internal table itab. The sytsem creates a table row for each section of f.
Note: If f ends with the separator string g, the system does not create an empty table row at the end. This is in contrast to what happens when g occurs at the beginning of f.
Example
TYPES: BEGIN OF ITAB_TYPE,
        WORD(20),
      END   OF ITAB_TYPE.
DATA: ITAB TYPE STANDARD TABLE OF ITAB_TYPE WITH
                NON-UNIQUE DEFAULT KEY INITIAL SIZE 5.
SPLIT 'STOP Two STOP Three STOP   ' AT 'STOP' INTO TABLE ITAB.
ITAB now has three rows. The first is empty, the second contains ' Two', and the third ' Three'.
Note
Performance:
The runtime required for the SPLIT statement in the first example of variant 1 is approximately 15 msn (standard microseconds). If you write the sections of f into an internal table, the runtime is around 30 msn.
Related
CONCATENATE, FIND, SEARCH, SHIFT
Additional help
Splitting Strings
Hope this’ll give you idea!!
<b>Pl... award the points.</b>
Good luck
Thanks
Saquib Khan
"Some are wise and some are otherwise"

Similar Messages

  • Splitting of fields using BPM

    hi
      my scenerio is about file to JDBC .  my flat file contains some 20 rows,just i want to split into 4 rows and then transfer into sql server.
      how i want to split the fields using BPM.
    thx in advance.
    Message was edited by:
            tamilarasan kandasamy

    Hi,
    <i>my scenerio is about file to JDBC . my flat file contains some 20 rows,just i want to split into 4 rows and then transfer into sql server</i>.
    is it 4 rows or 4 msgs..?? i hope , if 4 rows then it is merge , or it is split.
    Create the target structure as you required.Use the MM and IM to do accordingly, you can do without BPM.
    Any way see the below links to split.
    /people/jin.shin/blog/2006/02/07/multi-mapping-without-bpm--yes-it146s-possible
    /people/sudharshan.aravamudan/blog/2005/12/01/illustration-of-multi-mapping-and-message-split-using-bpm-in-sap-exchange-infrastructure
    Various multi-mappings and Optimizing their Implementation in Integration Processes (BPM) in XI.
    /people/narendra.jain/blog/2005/12/30/various-multi-mappings-and-optimizing-their-implementation-in-integration-processes-bpm-in-xi
    Different types of Mapping in XI - /people/ravikumar.allampallam/blog/2005/02/10/different-types-of-mapping-in-xi
    Multiple mappings into one Im - Multiple message mappings in one integration scenario
    Regards
    Chilla..
    <i>Points rewarded if it is useful..</i>

  • Document splitting causes field overflow for currency type 00 in row 003

    Hi ,
    Friends ,
    Our some of sales bills are stucking iduring  posting to finance after upgrading support packages, earlier there was no any problem.
    we are trying to post by tcode vf02 , it is throughing an error message
    Document splitting causes field overflow for currency type 00 in row 003
    Message no. GLT0004
    We are not getting any solution .
    We have raised a message to sap support , but not getting proper solution,
    Please guid us how can we solve this.
    SS
    Mobile no. 9810477923- Sundeep Gupta

    Thanks for all.
    we have solved this issue  after change some customization according sap support consultant reply as under.
    you have 3 different issues within your SD- new g/L interface.
    The most critical one is the fact that you substitute PRCTR and
    Segment assignemnts into line items to be processed by rule based
    split. This leads to the fact that you will only those cases will be
    able to post document in case the assignemnts are unique,
    which means no different kind of prctr, segment and business area
    assignments but only one single kind. This makes no sence at all.
    Please see my last reply regarding this most critical issue.
    This needs to be solved from Consulting point of view.
    Regards.
    SS
    Edited by: Lakshmipathi on Dec 22, 2010 12:21 PM
    When you say it is answered why you have closed the thread with Closed but Unanswered.  Please change it to "Answered".

  • Document Splitting causes field overflow for currency type 10 in row 007

    Dear All,
    At the time of Invoice through FB60 system is showing the above error Document Splitting causes field overflow for currency type 10 in row 007  & Message No :  GLT0004.  What could be the reason. 
    Regards

    Dear Raj,
    Please refer below link
    Document splitting causes field overflow for currency type 00 in row 003
    Br,Vivek

  • Document splitting causes field overflow for currency type 10 in row 001

    Hi Experts,
    I come across below error, while posting an entry in to SAP.
    "Document splitting causes field overflow for currency type 10 in row 001"
    Request your help in resolving the above.
    regards,
    Gopala

    Dear expert
             Document Splitting causes field overflow for currency type 10 in row 007
             GLT0004 - Document splitting causes causes field overflow
    Regards
       Ajeesh.s

  • Crystal report - how to split a field into more fields

    Hello,
    I`m new to Crystal reports and I`ve got a trouble. I have field which contains an address - street, city, zip code. The example is:
    STEHLIKOVA 977 165 00 PRAHA 620 - SUCHDOL 165 00.
    What I need to achieve is to split this string into three separated fields. I`ve trouhg a couple of forums but haven`t been able to find a proper answer. The problem is that the addresses differ so I can`t use an absolute defining of a start position. Looking at the DB (HEXA code) the parts in the string are divided by two dots:
    STEHLIKOVA 977..165 00 PRAHA 620 - SUCHDOL..165 00
    I`ve been able to work out this solution:
    stringVar array x := split({cparty.STREET_ADD},"..");
    Local numberVar i;
    Local stringVar outputString := "";
    For i:=1 to Count(x) do
    outputString := outputString + x[i] + Chr(10)
    outputString;
    It splits the string into three rows:
    STEHLIKOVA 977
    165 00 PRAHA 620 - SUCHDOL
    165 00
    And I don`t know how to find the end of each row so to be able to separate the strings and report them as three different fields.
    Would be anyone so kind and help me out with this?
    Thank you.
    Petr

    Hi
    Actually using a for loop is not necessary here. All you need to do is to add several formula fields: one for street, one for city and one for zipcode. In @street field you add formula:
    stringVar array x := split({cparty.STREET_ADD},Chr(13));
    x[1];
    Then you drag such formula field to details section of your report and watch preview to check if everything looks alright. Repeat for every formula field that you'd like see in your report.
    In @city you add almost identical formula but you change index, i. e. instead of x[1] you need to use x[2]. Then for @zip x[3].
    You may need to check if your address has all three parts - for example if you want to use formula in the second part of your address field you may need check first if there are at least two parts after split:
    stringVar array := split({cparty.STREET_ADD},Chr(13));
    numbervar c; 
    c := count(x); 
    if 2 <= c then 
    x[c]; 
    Var 'c' is used to store the number of elements in array after split. Then I'd like to check if the part (second) actually exists. So I try to check if number of part that I want to refer to is not bigger than the number of elements in array after split (here stored in var 'c').
    Actually the code presented above is not enough since you have no guarantee that you'll always get address structured in the very same way. For example in demo PL database I have zip code and city in the same row after split with Chr(13) as delimiter.
    You'll need to experiment or ask someone to prepare correctly structured data coming from B1 to your report.
    Kind regards,
    Radek

  • Split a field  into 3 columns for a report -  Shoud be done in R/3 or BW

    Hi all,
      I have to split a Text Description (TXTMD) into 3 columns for reporting.
      This description is available in R/3 table and in BW InfoObject.
      What is the best way to accomplish this task ?
      Should I enhance the Extract structure and fill those 3 new ZZ fields on R/3?
      Should I do it on BW side ? How, please ???
      Thanks in advance.
    Regards,
    Venkat.

    If the purpose of splitting is to overcome the limitation of Infoobject, I would recommend doing that in BW side for a couple reasons: You don't need worry about having R/3 transport and also if you are working on LO extractors you don't need to worry about setup tables. Secondly, it is easy to manage the fields in BW side than R/3, because you will be sending fewer fields.
    thanks.
    Wond

  • FV60 Vendor Invoice Amount Split Tab Field

    Greetings! Our users do not have authorization to access to FB60 - how can we open the fields (OTA and NAME OF OTA PAYEE) in the Amount Split Tab using FV60 - Park Vendor Invoice? Thank you in advance

    Hi:
            In the amount split tab of FV60 there will be a Yellow and blue button on the right corner named as configuration. Just click on it and go to Administrator and there you will see OTA and name of OTA payee . Please see if this has been set as invisible there. If they have not been set as invisible and still you can not see them in FV60 Amount split then the only way to fetch these fields in FV60 is through SHD0...For that please proceed as under
    Go to SHD0...Enter FV60  in Transaction code and ZFV60 in transaction variant.Press create button on the left top corner and enter co code and press enter again when next screen appears, it will take you to the main screen of FV60.. Enter vendor , invoice date,amount , GL account and and its amount and then keep on press entering and giving name to screen where it is required unless a FV60 main screen appears again...Now go to amount split tab and keep on pressing enter unless amount split tab screen appears, data already entered in main screen will be seen by you there , press enter two times times you will see a screen 0090 carrying these OTA fields there you will have to just un check the invisible tick from them and then exit and save with a proper name for screen variant. Give ABAP package name and exit. Upon exit in SDH0 standard variant tab assign and activate this ZFV60 variant and now you will be able to see them.
    Hope it resolves your issue.
    Regards

  • Document Splitting-Balancing field "Profit Centre"

    I am trying to post an F-02 transaction as follows:
    Salary & Wages   1000     Dr.   Cost Centre(A) & Profit Centre (A)
    Salary & Wages  1000     Dr.   Cost Centre (B) & Profit Centre (B)
    Salary Payable    2000     Cr.   
    But when I tried to post it, the system is showing the error that "Balancing field Profit Centre not found in item 3.
    I am expecting that the item-3 as above should be split and inherit the profit centre information.  However, the document is not split and the system is showing the error.
    I cannot assign a default Profit centre to the item -3 .  How can I reslve this error.  Document type used is SA and it is 'unspecified posting' in the Document Spitting method 0012.
    Please help out.

    Dear,
    Nikitha.
    Isn't your system asking you profit center as your mandatory field ? If it is so just put your enter your respective profit center
    and simulate the entry. ( In some cases enter your cost center system will catch assigned profit center from CC try out )
    Follow the following path :-
    IMG --- FA NEW -
    General Ledger Accounting New --- Business Transaction -
    Document Splitting -
    Define Document
    Splitting chracteristics for General Accounting.
    Here is your PRCTR is defined mandatory.
    If you untick it your system will allow you to post the document. But listen if you have activated segment also with that.
    Your reporting will be of no use and result void.
    In the SAP best practices it is said dont untick it if you have posted documents with same activated functionality
    By unticking your profit center wise & segmental reporting will be of no use.
    or do one thing go to down side of the same path a little you will see one transaction as Edit constants for non assigned
    process select your constant and double click on assignment of profit center maintained there default profit center or
    maintained dummy profit center 9999. Now your system will pick this profit center 9999 or your mentioned one
    as your default profit center.
    Or one more else thing you can do is by posting key make your profit center optional through its posting key's field status
    group.
    Hope this helps you to solve your issue.
    Please revert back for further clarification.
    Regards,
    Pankaj.
    Edited by: pankaj_ab on Nov 24, 2009 12:45 PM

  • Requesting help in splitting name field

    I'm moving from my CRM Goldmine to another CRM.  Goldmine keeps the name in the "Name" field with both first and last name.  The new CRM keeps is name in two fields: "Firstname" & "LastName"
    I have my data in an Access Database.  How can I split the name to get the the first name separated from the lastname.
    For example:  How do I split "John Smith" in one column into two columns "John" & "Smith"
    Thank you for all your help.
    Karolus

    With great difficulty.
    John Smith is easy.  Treat it as a space delimited list.  The problem comes with names like John Paul St Pierre.
    If this was my problem, I'd probably do the simple ones automatically and the complicated ones manually, as long as there weren't too many of them.

  • Splitting a Field to 2

    Hi Friends ,
               I have a field in R/3 which is 4 char , Now I should spilt it into 2 , like I need first 3 chars to map to 1 field in BW and the last one to one more field in BW. What is the code I should be using in the update rules??basically in my routine!!
    immediate help would be greatly appreciated,
    thanks alot in advance.

    very easy way?  Use a formula and do a LEFT(infoObj,3) and in the other one do a RIGHT(InfoObj,1)
    If you have 3.5, this will work very well, prior versions had some issues when compiling formulas and you might want to do a routine.

  • Mapping for split a field to several subelements

    Hi Experts,
    How can I map these lines into my target using java mapping uml??
    can you guys provide some code using java? coz I have no idea using java code.
    <A_06>0</A_06>
    <AB_07>256</AB_07>
    <A_08>0</A_08>
    <AB_09>257</AB_09>
    <A_10>0</A_10>
    <AB_11>259</AB_11>
    <A_12>0</A_12>
    <AB_13>260</AB_13>
    <A_14>0</A_14>
    <AB_15>262</AB_15>
    <A_16>-1</A_16>
    Thanks.

    here it goes..
    source message...
      \Identification_Code_Qualifier_02>92</Identification_Code_Qualifier_02>
    \  Identification_Code_03>117</Identification_Code_03>
    \ Quantity_04>0</Quantity_04>
      \Identification_Code_05>119</Identification_Code_05>
    \  Quantity_06>0</Quantity_06>
    \  Identification_Code_07>120</Identification_Code_07>
    \  Quantity_08>0</Quantity_08>
    \  Identification_Code_09>121</Identification_Code_09>
    \  Quantity_10>0</Quantity_10>
    \  Identification_Code_11>122</Identification_Code_11>
    \  Quantity_12>0</Quantity_12>
    \  Identification_Code_13>123</Identification_Code_13>
    \  Quantity_14>0</Quantity_14>
    \  Identification_Code_15>124</Identification_Code_15>
    \  Quantity_16>0</Quantity_16>
    \  Identification_Code_17>125</Identification_Code_17>
    \  Quantity_18>0</Quantity_18>
    \ Identification_Code_19>126</Identification_Code_19>
    \  Quantity_20>0</Quantity_20>
    \  Identification_Code_21>127</Identification_Code_21>
    \  Quantity_22>0</Quantity_22>
    \  /Destination_Quantity>
    \- Destination_Quantity>
    \  Identification_Code_Qualifier_02>92</Identification_Code_Qualifier_02>
    \  Identification_Code_03>128</Identification_Code_03>
    \  Quantity_04>0</Quantity_04>
    \  Identification_Code_05>129</Identification_Code_05>
    \  Quantity_06>0</Quantity_06>
    \  Identification_Code_07>130</Identification_Code_07>
    \  Quantity_08>0</Quantity_08>
    \  Identification_Code_09>132</Identification_Code_09>
    \  Quantity_10>0</Quantity_10>
    \  Identification_Code_11>133</Identification_Code_11>
    \  Quantity_12>0</Quantity_12>
    \  Identification_Code_13>134</Identification_Code_13>
    \  Quantity_14>0</Quantity_14>
    \  Identification_Code_15>135</Identification_Code_15>
    \  Quantity_16>0</Quantity_16>
    \  Identification_Code_17>136</Identification_Code_17>
    \  Quantity_18>0</Quantity_18>
    \  Identification_Code_19>137</Identification_Code_19>
    \  Quantity_20>0</Quantity_20>
    \  Identification_Code_21>138</Identification_Code_21>
    \  Quantity_22>0</Quantity_22>
    \  /Destination_Quantity>
    VDestination_Quantity>
    \  Unit_or_Basis_for_Measurement_Code_01>EA</Unit_or_Basis_for_Measurement_Code_01>
    \  Identification_Code_Qualifier_02>92</Identification_Code_Qualifier_02>
    \  Identification_Code_03>139</Identification_Code_03>
    \  Quantity_04>0</Quantity_04>
    \ Identification_Code_05>140</Identification_Code_05>
    \ Quantity_06>0</Quantity_06>
    \ Identification_Code_07>141</Identification_Code_07>
    \ Quantity_08>0</Quantity_08>
    \ Identification_Code_09>142</Identification_Code_09>
    \ Quantity_10>0</Quantity_10>
    \  Identification_Code_11>143</Identification_Code_11>
    \  Quantity_12>0</Quantity_12>
    \  Identification_Code_13>144</Identification_Code_13>
    \  Quantity_14>0</Quantity_14>
    \  Identification_Code_15>145</Identification_Code_15>
    \  Quantity_16>0</Quantity_16>
    \  Identification_Code_17>146</Identification_Code_17>
    \  Quantity_18>0</Quantity_18>
    \  Identification_Code_19>147</Identification_Code_19>
    \  Quantity_20>0</Quantity_20>
    \  Identification_Code_21>148</Identification_Code_21>
    \  Quantity_22>0</Quantity_22>
    \  /Destination_Quantity>
    \ - Destination_Quantity>
    target it should result into this...
    identification number = store number
    quantity = qty
    - Store No     Qty
    -117     0
    -119     0
    -120     0
    -121     0
    -122     0
    -123     0
    -124     0
    -125     0
    -126     0
    -127     0
    -128     0
    -129     0
    -130     0
    -132     0
    -133     0
    -134     0
    -135     0
    -136     0
    -137     0
    -138     0
    -139     0
    -140     0
    -141     0
    -142     0
    -143     0
    -144     0
    -145     0
    -146     0
    -147     0
    -148     0
    Thanks
    Edited by: Devilbatz on Oct 8, 2009 8:17 AM

  • Query to split the field value

    Hi all
        In employees table I am having employee_name column data as follows
              Aaron, Mrs. Jamie (Jamie)
              Aaron, Mrs. Jenette (Jenette)
              Abbott, Ms. Rachel (Rachel)
              Breton, Mr. Jean
              Britz, Mrs. Sarie (Sarie)
    --> Now, I want to display the employee name like "Mrs. Jamie" (with out Surname and with out bracket included text),
    --> How to achieve this by SQL query. Help me out plz
    Thanks in Advance
    Jagadeesh

    Need more sample cases:
    One way (without regexp).
    WITH t AS
            (SELECT 'Aaron, Mrs. Jamie (Jamie)' str FROM DUAL
             UNION ALL
             SELECT 'Aaron, Mrs. Jenette (Jenette)' FROM DUAL
             UNION ALL
             SELECT 'Abbott, Ms. Rachel (Rachel)' FROM DUAL
             UNION ALL
             SELECT 'Breton, Mr. Jean' FROM DUAL
             UNION ALL
             SELECT 'Britz, Mrs. Sarie (Sarie)' FROM DUAL)
    SELECT CASE
              WHEN INSTR (str, '(') > 0 THEN
                 SUBSTR (str,
                         INSTR (str, ',') + 2,
                         INSTR (str, '.') - INSTR (str, ',') - 1)
                 || ' '
                 || SUBSTR (str,
                            INSTR (str, '(') + 1,
                            LENGTH (str) - INSTR (str, '(') - 1)
              ELSE
                 SUBSTR (str, INSTR (str, ',') + 2)
           END
              str
      FROM t;
    Output:
    STR
    Mrs. Jamie
    Mrs. Jenette
    Ms. Rachel
    Mr. Jean
    Mrs. Sarie
    Cheers,
    Manik

  • How to split Value in a field while importing

    Hi,
    I want to split Value in Field and map it 2 target Field.
    Suppose Street field having values with House number and street name ,need to split  at House Number and street name and map it 2 fields
    EX : 1123 Dhuram Ave:    Need to split 1123 and Dhuram Ave ,need to map it to 2 target field.
    Here I don't have any delimeter in the field Value.
    Please help on this.
    Thanks,
    Madhu
    Edited by: Madhusudhan Honnappa on Nov 30, 2010 5:19 PM

    Hello.  I'm assuming this is a custom import as typically, standard extractors would have the house number and street already seperated into unique fields.  Here is a quick routine I tried out that would split the field.  Only thing I would add is that if writing this from scratch you would want to check that the first character is numeric and also that all characters before the space are numeric.  This routine assumes that the field will be like xx yy  where xx = house number and yy is the street.  Mainly, it would assume anything before the first space is the house number and anything after is the street.
    YLEN = STRLEN( YYINPUT ).
    YTIMES = 0.
    DO YLEN TIMES.
       IF YYINPUT+YTIMES(1) = SPACE.
          YOFFSET = YTIMES.
          "House Number" = YYINPUT(YOFFSET).
          YOFFSET = YTIMES + 1.
          "Street" = YYINPUT+YOFFSET.
          EXIT.
       ENDIF.
       YTIMES = YTIMES + 1.
    ENDDO.
    I'm sure there are many ways to go about this and may be some standard FMs you can call.  I just like trying to write it first to get a better understanding.  Not sure if this quick example will give you exactly what you need, but hopefully will at least give you a place to start.
    Thanks

  • Splitting of Currency field

    Hi All,
    We have a field (keyfigure1 and keyfigure2) which is showing in the BEx report as follows:
    COLUMN1       COLUMN2
    USD 10.00       USD 1.00
    10.00 CAD       10.00 CAD
    USD 1.00         USD 1.00
    Now we want to split this field into two columns (Desired Output):
    COLUMN1       COLUMN2        COLUMN3        COLUMN4
          USD             10.00             USD                    1.00
          CAD             10.00             CAD                   10.00
          USD               1.00             USD                    1.00
    When we are trying to do this we are facing two problems.
    1) In Key figure( Columns) section, we are not able to get 0currency which is the unit in between two keyfigure.
    2) In rows section, we are not able to bring key figures with NODIM property..
    Please suggest ways to achieve the above.
    Thanks,
    Vivek Das Gupta

    Hi,
    Try to SPLIT the data in two fields and then probably you can use these key figures properly.
    While loading data to Cube/ any DT , you can do th esplitting in Transformations.
    There just write a little code , keyword "Split".
    Regards,
    Pratap Sone

Maybe you are looking for