Skip to Content

SPLIT statement

Hi,

I am working on a BDC program. Here, I have to split a text at # and move the same into an internal table. See below.

W_STRING = #H#263##030108#DG#030108#EUR#Rf.123#DN-123#0002#############

SPLIT W_STRING AT '#' INTO E_HEAD-FIRST E_HEAD-RTYPE E_HEAD-BUKRS......

where E_HEAD is the structure I want to move the data.

But, after this statement, E_HEAD-FIRST is holding # and rest all the fields are blank.

Is anything wrong in the statement I have used....? Could someone clarify my doubt..? Please suggest me how to split in such case.

Thanks in advance.

Best Regards,

Paddu.

Add a comment
10|10000 characters needed characters exceeded

Assigned Tags

Related questions

7 Answers

  • Best Answer
    author's profile photo Former Member
    Former Member
    Posted on Jan 05, 2008 at 09:48 AM

    HI,

    data: abc type table of string with header line.

    split field-name at '#' into Table abc.

    Read Table abc index 1.

    itab-field1 = abc.

    Read Table abc index 2

    itab-field2 = abc.

    Do like this ..

    Finally, append itab to an internal table.

    Regards,

    TALWINDER

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Jan 05, 2008 at 09:54 AM

    First Use:

    Shift w_string.

    and then split it.

    Then use this statement on all values.

    Replace ALL OCCURENCES of '#' with ' '.

    This will surely solve ur problem.

    awrd points if helpful

    Bhupal

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Jan 05, 2008 at 09:54 AM

    Hai Paddu,

    Your statement is correct. But i dont know how you declared the structure(E_HEAD).once again Check it.

    Regards,

    Nagaraju

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Jan 05, 2008 at 09:55 AM

    hi,

    it might be due to the first #.

    try

    shift w_string by 1 places left.

    den split

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Jan 05, 2008 at 10:04 AM

    Hi Paddu,

    Execute the below code then ur problem will be resolved ok..

    W_STRING =' #H#263##030108'.

    SHIFT W_STRING.

    SPLIT W_STRING AT '#' INTO E_HEAD-FIRST E_HEAD-RTYPE E_HEAD-BUKRS......

    *DEFAULT SHIFT IS LEFT SHIFT AT THAT TIME FIRST HASH SYMBOL WILL DELETED..

    Award points if helpful.

    Kiran Kumar.G

    Have a Nice Day..

    Add a comment
    10|10000 characters needed characters exceeded

    • Hi Kiran,

      Thanks for your reply.

      I tried like you said. I shifted the string left first after that I splitted that at #. But, even now I am getting only one field.

      I am getting E_HEAD-RTYPE as H. and rest all the fields blank. I used the same statement you said.

      Please suggest me how to proceed.

      Thasnks,

      Paddu.

  • author's profile photo Former Member
    Former Member
    Posted on Jan 05, 2008 at 10:16 AM

    Hi,

    I think this is due to two or more ## symbols like this beside.

    So before splitting the string do:-

    REPLACE ‘##’WITH ‘#’ INTO W_STRING.

    These REPLACE statements can repeated if u have ### in u r file.

    ie W_STRING = ‘#xyz##abd###cd#’.

    Then for three ###

    REPLACE ‘##’WITH ‘#’ INTO W_STRING.

    REPLACE ‘##’WITH ‘#’ INTO W_STRING.

    Then

    1. SPLIT W_STRING AT ‘#’ INTO field1 field2 ... fieldn.

    2. SPLIT W_STRING AT ‘#’ INTO TABLE itab.

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Jan 05, 2008 at 11:42 AM

    Hi Paddu,

    dont use hard code '#' while spliting. just follow as below.

    data: lv_tabch TYPE char01 VALUE cl_abap_char_utilities=>horizontal_tab.

    if you use lv_tabch system will take care of the Symbols either ',' or '#' or tab delimeted.......

    and SPLIT LS_FILE AT lv_tabch INTO -


    -


    Reward me with points if it helps you

    Thanks,

    Murali.

    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.