<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Split a string into different fields ofvariable lengths in a internal table in Application Development and Automation Discussions</title>
    <link>https://community.sap.com/t5/application-development-and-automation-discussions/split-a-string-into-different-fields-ofvariable-lengths-in-a-internal-table/m-p/5033615#M1170799</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thanks Guy,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;My problem is solved!&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Rushi&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Sun, 04 Jan 2009 17:07:51 GMT</pubDate>
    <dc:creator>Former Member</dc:creator>
    <dc:date>2009-01-04T17:07:51Z</dc:date>
    <item>
      <title>Split a string into different fields ofvariable lengths in a internal table</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/split-a-string-into-different-fields-ofvariable-lengths-in-a-internal-table/m-p/5033608#M1170792</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hello Everyone,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I have a question regarding splitting a string. I have searched in the forum for this. I did find some useful threads, but did not solve my problem.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I have nearly 80 fields in a structure.&lt;/P&gt;&lt;P&gt;I have a LCHR string where the data is seaprated by commas. I want to split this string into the 80 fields.&lt;/P&gt;&lt;P&gt;These 80 character fields have variable length. I read F1 on split. and was able to split the string at commas into a table , lets call itab which is of type table of string. But how to move this itab to my structure which has 80 fields each with different length? can it be done by using field symbols?&lt;/P&gt;&lt;P&gt;Appreciate your help!.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks,&lt;/P&gt;&lt;P&gt;Rushi&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 04 Jan 2009 03:33:56 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/split-a-string-into-different-fields-ofvariable-lengths-in-a-internal-table/m-p/5033608#M1170792</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2009-01-04T03:33:56Z</dc:date>
    </item>
    <item>
      <title>Re: Split a string into different fields ofvariable lengths in a internal table</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/split-a-string-into-different-fields-ofvariable-lengths-in-a-internal-table/m-p/5033609#M1170793</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;If i understood your question correctly than you may refer =&amp;gt;  &lt;SPAN __jive_macro_name="thread" id="67340"&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 04 Jan 2009 04:20:37 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/split-a-string-into-different-fields-ofvariable-lengths-in-a-internal-table/m-p/5033609#M1170793</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2009-01-04T04:20:37Z</dc:date>
    </item>
    <item>
      <title>Re: Split a string into different fields ofvariable lengths in a internal table</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/split-a-string-into-different-fields-ofvariable-lengths-in-a-internal-table/m-p/5033610#M1170794</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;hi,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;i think the following code will help you in this way,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;  &lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;loop at it_crow.

    clear: zfsl_stinfo.

    split it_crow at ',' into zfsl_stinfo-mandt  "here is the solution of you problem i think
                              zfsl_stinfo-st_id
                              zfsl_stinfo-st_n
                              zfsl_stinfo-st_fn
                              zfsl_stinfo-st_reg
                              zfsl_stinfo-st_ph
                              zfsl_stinfo-st_pm.
    insert zfsl_stinfo.

    if sy-subrc = 0 .
      commit work.
      count = count + 1.
    else.
      write: / , 'Insert Failed for', zfsl_stinfo-mandt,
                                      zfsl_stinfo-st_id,
                                      zfsl_stinfo-st_n,
                                      zfsl_stinfo-st_fn,
                                      zfsl_stinfo-st_reg,
                                      zfsl_stinfo-st_ph,
                                      zfsl_stinfo-st_pm..
    endif.
  endloop.
  write: count , 'Records were inserted'.&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Replay if any problem,&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Faisal&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 04 Jan 2009 05:48:11 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/split-a-string-into-different-fields-ofvariable-lengths-in-a-internal-table/m-p/5033610#M1170794</guid>
      <dc:creator>faisalatsap</dc:creator>
      <dc:date>2009-01-04T05:48:11Z</dc:date>
    </item>
    <item>
      <title>Re: Split a string into different fields ofvariable lengths in a internal table</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/split-a-string-into-different-fields-ofvariable-lengths-in-a-internal-table/m-p/5033611#M1170795</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;Use the FMs STRING_SPLIT_AT_POSITION&lt;/P&gt;&lt;P&gt;     or          IQAPI_WORD_WRAP&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;and take that LCHAR field separatly and do your process by above function modules.&lt;/P&gt;&lt;P&gt;So it solves your problem.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 04 Jan 2009 06:59:52 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/split-a-string-into-different-fields-ofvariable-lengths-in-a-internal-table/m-p/5033611#M1170795</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2009-01-04T06:59:52Z</dc:date>
    </item>
    <item>
      <title>Re: Split a string into different fields ofvariable lengths in a internal table</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/split-a-string-into-different-fields-ofvariable-lengths-in-a-internal-table/m-p/5033612#M1170796</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hello Amit,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thank you for the suggestion. My problem is I have to split the long string into fields into a structure which has variable length. For example...the string is &lt;/P&gt;&lt;P&gt;aaaaaaaaaa,bbbbbb,ggg,tttttt&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;i want to split this into structure which has fields like this&lt;/P&gt;&lt;P&gt;order(30)&lt;/P&gt;&lt;P&gt;id(8)&lt;/P&gt;&lt;P&gt;rst(20)&lt;/P&gt;&lt;P&gt;type(10)&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;so i thght of using split statement. so that i can get like this&lt;/P&gt;&lt;P&gt;order = aaaaaaaaaa.&lt;/P&gt;&lt;P&gt;id = bbbbbb&lt;/P&gt;&lt;P&gt;rst = ggg&lt;/P&gt;&lt;P&gt;type = tttttt&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;but i have 80 fields like this.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;So I don't want to write all the fields on the split statement as Faisal suggested.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;According to that thread which Amit suggested, i think i have to give line length which is constant for all fields.&lt;/P&gt;&lt;P&gt; &lt;/P&gt;&lt;P&gt;My problem still not solved...any more suggestions?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks,&lt;/P&gt;&lt;P&gt;rushi&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 04 Jan 2009 15:52:03 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/split-a-string-into-different-fields-ofvariable-lengths-in-a-internal-table/m-p/5033612#M1170796</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2009-01-04T15:52:03Z</dc:date>
    </item>
    <item>
      <title>Re: Split a string into different fields ofvariable lengths in a internal table</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/split-a-string-into-different-fields-ofvariable-lengths-in-a-internal-table/m-p/5033613#M1170797</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;You can use a code like this:&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;
TYPES:  BEGIN OF ty_upload,
          data(1000)  TYPE c,
        END OF ty_upload.

TYPES:  ty_order          TYPE ztype, " Enter your own structure here
        tt_order          TYPE STANDARD TABLE OF ty_order,
        tt_upload         TYPE STANDARD TABLE OF ty_upload.

FORM split_order_data    USING it_upload    TYPE tt_upload
                      CHANGING et_order     TYPE tt_order.

  DATA: ls_upload     TYPE ty_upload,
        ls_order      TYPE ty_order,
        lt_split_data TYPE STANDARD TABLE OF string,
        ls_split_data TYPE string,
        lv_tabix      TYPE sy-tabix.

  FIELD-SYMBOLS: &amp;lt;fs_value&amp;gt; TYPE ANY.

  LOOP AT it_upload INTO ls_upload.
    SPLIT ls_upload AT ',' INTO TABLE lt_split_data.

    LOOP AT lt_split_data INTO ls_split_data.
      lv_tabix = sy-tabix.

      ASSIGN COMPONENT lv_tabix OF STRUCTURE ls_order
        TO &amp;lt;fs_value&amp;gt;.

      IF sy-subrc EQ 0.
        &amp;lt;fs_value&amp;gt; = ls_split_data.
      ENDIF.
    ENDLOOP.

    APPEND ls_order TO et_order.
  ENDLOOP.

ENDFORM.                    "split_order_data&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The table IT_UPLOAD is the data I received from the file, and ET_ORDER is the data in my own structure.&lt;/P&gt;&lt;P&gt;Since I'm using a field symbol, the length of it doesn't matter. The only thing you need to worry about is that the type of the data is correct, that is - don't try to put strings in currency fields for example.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Let me know if you need more assistance.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Guy.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 04 Jan 2009 15:54:00 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/split-a-string-into-different-fields-ofvariable-lengths-in-a-internal-table/m-p/5033613#M1170797</guid>
      <dc:creator>GuyF</dc:creator>
      <dc:date>2009-01-04T15:54:00Z</dc:date>
    </item>
    <item>
      <title>Re: Split a string into different fields ofvariable lengths in a internal table</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/split-a-string-into-different-fields-ofvariable-lengths-in-a-internal-table/m-p/5033614#M1170798</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;hi rushi... if any thing related to field-symbols I can think related to ur scenario is to use &lt;STRONG&gt;assign-components&lt;/STRONG&gt; check the F1 help for it... and check if it might help u..&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 04 Jan 2009 16:53:32 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/split-a-string-into-different-fields-ofvariable-lengths-in-a-internal-table/m-p/5033614#M1170798</guid>
      <dc:creator>former_member156446</dc:creator>
      <dc:date>2009-01-04T16:53:32Z</dc:date>
    </item>
    <item>
      <title>Re: Split a string into different fields ofvariable lengths in a internal table</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/split-a-string-into-different-fields-ofvariable-lengths-in-a-internal-table/m-p/5033615#M1170799</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thanks Guy,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;My problem is solved!&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Rushi&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 04 Jan 2009 17:07:51 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/split-a-string-into-different-fields-ofvariable-lengths-in-a-internal-table/m-p/5033615#M1170799</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2009-01-04T17:07:51Z</dc:date>
    </item>
    <item>
      <title>Re: Split a string into different fields ofvariable lengths in a internal table</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/split-a-string-into-different-fields-ofvariable-lengths-in-a-internal-table/m-p/5033616#M1170800</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thanks Guy,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;My problem is solved!&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Rushi&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 04 Jan 2009 17:08:00 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/split-a-string-into-different-fields-ofvariable-lengths-in-a-internal-table/m-p/5033616#M1170800</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2009-01-04T17:08:00Z</dc:date>
    </item>
  </channel>
</rss>

