Skip to Content
author's profile photo Former Member
Former Member

Split Statement

Hi to all Guru's,

before splitting any string if i want to know how many words are there so that i can create a internal table containing same number of fileds.

i want to do some thing like this.

text = `What a drag it is getting old`.

SPLIT text AT space INTO: TABLE itab. "how can i come to know that i need

to create 7 fields.

Thanks & Regards

Priyalatha

Add a comment
10|10000 characters needed characters exceeded

Assigned Tags

Related questions

9 Answers

  • Best Answer
    author's profile photo Former Member
    Former Member
    Posted on Dec 04, 2007 at 08:42 AM

    hi,

    try like this.

    types : begin of struct,

    words(50) type c,

    end of struct.

    data : itab type standard table of struct with header line,

    num_words type i.

    split text at space into table itab.

    describe table itab lines num_words.

    num_words contains total no of words in the text.

    hope this gives u some idea.

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Dec 04, 2007 at 07:57 AM

    Hi Priya,

    Yes you have to create all fields.

    What you can do is to create a Internal table with a exhaustive number of fileds ( for eg : 100 ).

    data: begin of st1,
    ch01(50) type c,
    ch02(50) type c,
    ch03(50) type c,
    ....
    ch99(50) type c,
    end of st1.
    data: itab1 like table of st1.
    

    OR,

    <i>If each record have the same number of splitted fields, you can count them and create a dinamyc table.</i>

    Hope this helps,

    Erwan

    Add a comment
    10|10000 characters needed characters exceeded

  • Posted on Dec 04, 2007 at 08:24 AM

    So far, only Eric has the correct answer. Stick to his.

    matt

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Dec 04, 2007 at 07:57 AM

    you can do like this...

    data: begin of wa1,

    ch(10) type c,

    end of wa1.

    data: itab1 like table of wa1.

    split 'i know you know' at space into table itab1.

    loop at itab1 into wa1.

    write:/ wa1-ch.

    endloop.

    Add a comment
    10|10000 characters needed characters exceeded

  • Posted on Dec 04, 2007 at 07:57 AM

    hi Prya,

    the SPLIT statement will split the words not into fields of the internal table, but into different lines. Your internal table will look like after SPLIT:

    What

    a

    drag

    it

    is

    getting

    old

    hope this helps

    ec

    Add a comment
    10|10000 characters needed characters exceeded

  • Posted on Dec 04, 2007 at 07:59 AM

    Hi Priya

    First understand the importance of split command and when we go for split command.

    see the example:

    Split valuation enables you to valuate sub-stocks of a material in different ways (for example, according to external procurement or in-house production or by batches).

    Recommended valuation levels are at Plant level.

    In split valuation, you can distinguish between partial stocks of a material according to certain criteria and valuate them separately.

    The material stock is divided according to valuation category and valuation type:

    The valuation category determines how the partial stocks are divided, that is, according to which criteria.

    The valuation type describes the characteristics of the individual stocks.

    With the function "Setting" you can determine:

    which valuation categories exist in your company (global categories)

    which valuation types exist in your company (global types)

    which valuation types belong to which valuation category

    which valuation categories exist in a valuation area (local categories)

    Your entries are only relevant if you set split valuation as active in the function "Global settings".

    In the standard SAP R/3 System, the following valuation categories are preset:

    Example:

    B procurement type

    with the valuation types:

    "EIGEN" for in-house production

    "FREMD" for external procurement

    H Origin

    X automatic valuation (only for batch)

    Actions

    To select split valuation, proceed as follows:

    1. Determine the valuation categories and valuation types that are allowed for all valuation areas:

    global valuation categories via menu "Goto --> Global Categories"

    global valuation types via menu "Goto --> Global Types"

    2. Allocate the valuation types to the valuation categories.

    a) Select "Goto --> Global Categories".

    b) Position the cursor on a valuation category and select "Goto --> Global Categories --> Allocations --> Types->Category".

    c) Activate the valuation types you want.

    3. Determine the local valuation categories for each valuation area.

    a) Select "Goto --> Local definitions".

    b) Position the cursor on a valuation area and select "Goto --> Local Definitions --> Allocate Categoires->Org.units". You obtain a list of the global valuation categories.

    c) Activate the categories to be used in this valuation area.

    The system creates the local valuation types based on the allocations under point 2.

    Only now can you create a master record with split valuation.

    Please refer below link

    http://www.sap-img.com/mm025.htm

    Regards,

    Sree

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Dec 04, 2007 at 08:00 AM

    Hi Priya,

    Try this program

    data: text(50) type c value  '0011 1110 0111 1100 1111 1001 0011 0101',
          len type i,
          ind type i,
          pos type i,
          cnt type i.
     
    len = strlen( text ).
     cnt = 1.
    do len times.
     ind = sy-index.
     pos = sy-tabix.
     if text+ind(pos) = ' '.
      cnt = cnt + 1.
     endif.
    enddo.
    write cnt. " CNT will have total number of words.

    Regards,

    Satish

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Dec 04, 2007 at 09:29 AM

    Thanks to all Guru's

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Dec 04, 2007 at 09:52 AM

    Hi,

    priya

    data: begin of wa1,

    ch(10) type string,

    end of wa1.

    data: itab1 like table of wa1.

    data:w_int type i.

    split 'i know you know' at space into table itab1.

    loop at itab1 into wa1.

    w_int = w_int + 1.

    endloop.

    WRITE: / W_INT.

    TRY THIS CODE

    PLZZZZ REWARD IF USEFULLL

    Add a comment
    10|10000 characters needed characters exceeded

Before answering

You should only submit an answer when you are proposing a solution to the poster's problem. If you want the poster to clarify the question or provide more information, please leave a comment instead, requesting additional details. When answering, please include specifics, such as step-by-step instructions, context for the solution, and links to useful resources. Also, please make sure that you answer complies with our Rules of Engagement.
You must be Logged in to submit an answer.

Up to 10 attachments (including images) can be used with a maximum of 1.0 MB each and 10.5 MB total.