Read line and split into different fields

I have a flat file with space (multiple spaces between different fields) as a delimiter. The problem is, file is coming from 3rd party and they don't want to change the separator as comma or tab delimited CSV file. I have to load data in ODS (BW 3x).
Now I am thinking to load line by line and then split data into different objects in Transfer rules.
The Records looks like:
*009785499     BC               2988              244        772       200
*000000033     AB                     0                  0            0           0
*000004533    EE                     8                  3            2           4
Now I want data to split like:
Field1 = 009785499
Field2 = BC
Field3 = 2988
Field4 = 244
Field5 = 772
Field6 = 200
After 1st line load, go to 2nd line and split the data as above and so on. Could you help me with the code pleaseu2026?
Is it a good design to load data? Any other idea?
Thanks.

Hi Mau,
First capture the data into the internal table (say itab).
Loop at itab.
  it_final-field1 = itab+1(9).
  it_final-field2 = itab+12(2).
  it_final-field1 = itab+16(4).
  it_final-field1 = itab+21(3).
  it_final-field1 = itab+25(3).
  it_final-field1 = itab+29(3).
  Append it_final.
Endloop.
&*********** Reward Point if helpful**********&

Similar Messages

  • Split data into different fields in TR

    I have a flat file with space (multiple spaces between different fields) as a delimiter. The problem is, file is coming from 3rd party and they don't want to change the separator as comma or tab delimited CSV file. I have to load data in ODS (BW 3x).
    Now I am thinking to load line by line and then split data into different objects in Transfer rules.
    The Records looks like:
    *009785499 ssss BC sssss 2988 ssss 244 sss 772 sss  200
    *000000033 ssss AB ssss        0  ssss   0 ssss 0 ssss 0
    *000004533 ssss EE ssss        8  ssss   3 ssss 2 ssss 4
    s = space
    Now I want data to split like:
    Field1 = 009785499
    Field2 = BC
    Field3 = 2988
    Field4 = 244
    Field5 = 772
    Field6 = 200
    After 1st line load, go to 2nd line and split the data as above and so on. Could you help me with the code pleaseu2026?
    Is it a good design to load data? Any other idea?
    I appreciate your helps..

    Hi,
    Not sure how efficient this is, but you can try an approach on the lines of this link /people/sap.user72/blog/2006/05/27/long-texts-in-sap-bw-modeling
    Make your transfer structure in this format. Say the length of each line is 200 characters. Make the first field of the structure of length 200. That is, the length of Field1 in the Trans Struc will be 200.
    The second field can be the length of Field2 as you need in your ODS, and similarly for Field3 to Field6. Load it as a CSV file. Since there are no commas, the entire line will enter into the first field of the Trans Structure. This can be broken up into individual fields in the Transfer Rules.
    Now, in your Start Routine of transfer rules, write code like this (similar to the ex in the blog):
    Field-symbols <fs> type transfer-structure.
    Loop at Datapak assigning <fs>.
        split <fs>-Field1 at 'ssss' into <fs>-field1 <fs>-field2 <fs>-field3....
        modify datapak from <fs>
    endloop.
    Now you can assign Field1 of Trans Struc to Field1 of Comm Struc, Field2 of Trans Struc to Field2 of Comm Struc and so on.
    Hope it helps!
    Edited by: Suhas Karnik on Jun 17, 2008 10:28 PM

  • SCs line items are getting splitted into different POs.

    Hi Experts,
    I am using SRM 5.0 (EBP4.0) ECS.
    When operational purchaser is doing carry out sourcing then SC line items are getting splitted into different POs whereas all the criteria are same I mean all the SC line items are having same
    1.Purcg.Grp
    2.Purch.Org.
    3.Company Code
    4.Plant/Location
    5.Vendor (Preferred)
    6.All product Cat.are assigned to one system only.
    (In BBP_PD for the SC I dont see any reason for the split)
    7.Using Intended for Gouping Option also at the time of Carry out sourcing.
    Earlier also I have raised the same question but I didnt get any reply, only some hints and other reference and help bu Yann but I am still facing the same issue and Pls help me if there is any OSS note for it .
    Here I'd like to let you know that I have seen same ticket and checked all the possible cause for split but never find any reason for split in this case.Pls help me on this issue urgently.
    Brgds
    Gopesh

    Hi
    As Yann told, there might be some standard BADIs for which we need to either modify the standard code in this case.
    Has SAP replied on this problem with any comments - on your OSS message yet ?
    <u>As far as I know, the following BADIs are some how, involved in the creation of the Local SRM PO. </u> 
    <b>BBP_ECS_PO_OUT_BADI </b>
    ( ECS: PO Transfer to Logistics Backend                  )
    <b>BBP_EXTLOCALPO_BADI </b>
    ( Control Extended Classic Scenario                   )
    <b>BBP_GROUP_LOC_PO   </b> 
    ( Exit Grouping of Items for Local Purchase Orders    )
    Please send me your detailed requirements at my email id for further analysis.
    [email protected]
    Hope this will help.
    Please reward suitable points, incase it suits your requirements.
    Regards
    - Atul

  • How do I insert multiple values into different fields in a stored procedure

    I am writing a Stored Procedure where I select data from various queries, insert the results into a variable and then I insert the variables into final target table. This works fine when the queries return only one row. However I have some queries that return multiple rows and I am trying to insert them into different fields in the target table. My query is like
    SELECT DESCRIPTION, SUM(AMOUNT)
    INTO v_description, v_amount
    FROM SOURCE_TABLE
    GROUP BY DESCRIPTION;
    This returns values like
    Value A , 100
    Value B, 200
    Value C, 300
    The Target Table has fields for each of the above types e.g.
    VALUE_A, VALUE_B, VALUE_C
    I am inserting the data from a query like
    INSERT INTO TARGET_TABLE (VALUE_A, VALUE_B, VALUE_C)
    VALUES (...)
    How do I split out the values returned by the first query to insert into the Insert Statement? Or do I need to split the data in the statement that inserts into the variables?
    Thanks
    GB

    "Some of the amounts returned are negative so the MAX in the select statement returns 0 instead of the negative value. If I use MIN instead of MAX it returns the correct negative value. However I might not know when the amount is going to be positive or negative. Do you have any suggestions on how I can resolve this?"
    Perhaps something like this could be done in combination with the pivot queries above, although it seems cumbersome.
    SQL> with data as (
      2        select  0 a, 0 b,  0 c from dual   -- So column a has values {0, 1, 4},
      3  union select  1 a, 2 b, -3 c from dual   --    column b has values {0, 2, 5},
      4  union select  4 a, 5 b, -6 c from dual ) --    column c has values {0, -3, -6}.
      5  --
      6  select  ( case when max.a > 0 then max.a else min.a end) abs_max_a
      7  ,       ( case when max.b > 0 then max.b else min.b end) abs_max_b
      8  ,       ( case when max.c > 0 then max.c else min.c end) abs_max_c
      9  from    ( select  ( select max(a) from data ) a
    10            ,       ( select max(b) from data ) b
    11            ,       ( select max(c) from data ) c
    12            from      dual ) max
    13  ,       ( select  ( select min(a) from data ) a
    14            ,       ( select min(b) from data ) b
    15            ,       ( select min(c) from data ) c
    16            from      dual ) min
    17  /
    ABS_MAX_A  ABS_MAX_B  ABS_MAX_C
             4          5         -6
    SQL>

  • When downloading from my PD 150 to the event window in my iMac the clips are out of order and split into many subclips   ac  iMac the clips in the

    when downloading from my PD 150 to the event window in my iMovie the clips are out of order and split into many subclips. Very frustrating

    Nevermind, somehow it's magically back in order.

  • How to read from and write into the same file from multiple threads?

    I need to read from and write into a same file multiple threads.
    How can we do that without any data contamination.
    Can u please provide coding for this type of task.
    Thanks in advance.

    Assuming you are using RandomAccessFile, you can use the locking functionality in the Java NIO library to lock sections of a file that you are reading/writing from each thread (or process).
    If you can't use NIO, and all your threads are in the same application, you can create your own in-process locking mechanism that each thread uses prior to accessing the file. That would take some development, and the OS already has the capability, so using NIO is the best way to go if you can use JDK 1.4 or higher.
    - K
    I need to read from and write into a same file
    multiple threads.
    How can we do that without any data contamination.
    Can u please provide coding for this type of task.
    Thanks in advance.

  • Reading a text file line by line and splitting each line into an array

    I have a text file that I want to read in line by line and within each line, I want to do some processing. I have a file like the following:
    apples||oranges||bananas||grapes
    cars||trucks||planes||boats
    And I want to end up with an array such that
    First...
    item(0) = apples
    item(1) = oranges
    item(2) = bananas
    item(3) = grapes
    Then move onto the next line with item getting cleared each time. Can anyone offer any ideas on how do to this? I am unclear on reading line by line and then also splitting into an array as I am new to this.
    Thanks.

    For reading a text file in line by line, you want to use a FileReader (java.io.FileReader)
    If you wrap it in a Buffered reader, you can call readLine() and get the file one line at a time.
      File file = new File("C:\myFile.txt");
      BufferedReader in = new BufferedReader(new FileReader(file));
      String s = in.readLine();
      while (s != null){
        // string handling here
        s = in.readLine();
      }For the second part, you probably want to look at the method String.split() which should split your string up into an array for you. Check out the API for java.lang.String
    Check out the

  • Split data and insert into different rows

    I have a string like 'sfdsf,sfdsf,sfsd,qweqeqw,iuoi,"
    I have created a single column table
    I have to extract data from first untill comma(,) occurs and insert into the table like the following
    sfdsdf
    sfdsf
    sfsd
    qweqeqw
    iuoi
    Please help me how to do it

    Or a Single SQL query
    SELECT trim(',' from DECODE(ROWNUM,1,SUBSTR(STR,1,INSTR(STR,',',1)),
                                        LENGTH(STR)-LENGTH(REPLACE(STR,','))+1,SUBSTR(STR,INSTR(STR,',',-1,1)),
                                         SUBSTR(STR,INSTR(STR,',',1,ROWNUM-1), INSTR(STR,',',1,ROWNUM)-INSTR(STR,',',1,ROWNUM-1))
                                   ))  STR1
                     FROM (SELECT 'sfdsf,sfdsf,sfsd,qweqeqw,iuoi' STR FROM DUAL),ALL_TABLES
                     WHERE ROWNUM <= LENGTH(STR)-LENGTH(REPLACE(STR,','))+1
                      ORDER BY ROWNUM

  • BPM 1:N split into different service interfaces

    Hi everyone, just a quick question about multimapping scenarios.
    If I want to make a 1:N message split in BPM I should use a transformation step and specify a multiline container element to get the result of the transformation. That multiline container element is bound to a single message type so, If I want to split my incoming interface into different service interfaces (based on different message types), how can I handle that in BPM? Or is it just not possible?
    Thanks in advance.

    Hi,
    It is possible to specify more than one container element for the resulting messages of the transformation step
    Its possible.
    In operation mapping in IR if you add 3 interfaces in Target side and the same mapping if you select in BPM transform step then it will ask for three contaner.
    Create 3 contaneir.
    Select type as Abstract Interface.
    Then select individual interface in those containers.

  • Combining Date and Time into 1 Field

    Post Author: Marc Vaccarino
    CA Forum: Formula
    Hi,
    I'm trying to write a formula to combine 2 fields (date and time) into one. I would like it to look like this.
    2/12/2007 + 12:00pm = 2/12/2007 12:00pm
    Thanks,

    Post Author: Marc Vaccarino
    CA Forum: Formula
    Thanks that worked but my problem is currently the date field I'm using has a date and time (12/12/2007 12:00am) and the time field has it as well  (12/12/2007 1:45am).  I've been going into crystal and clicked on format field and just showing the date and in the time field, just showing time. Then I would extract the report to excel then run another formula to get it to work. I'm looking to automate it a little. Any ideas??

  • Converting drummer to midi and split into separate tracks

    The drummer app in logic pro is great. I can then convert a phrase into mdi and copy to my own track for further modifications. Also great. But is there an easy way to convert a drummer track into midi, and to split each part of the drum (hh, snare, kick etc) out into their own bespoke tracks? So that each part of the drum is then on its own track for futher processing and control.

    Thanks to all for advice, tips and ideas. Just shows that there is no one way to do something in LPX.
    Here is what I have found works for me, so that I can take a great groove from the drummer track, convert to midi (so that I can modify the drum part), split the kit components out to individual tracks, then ensure each kit part has its own channel strip so that each part can be fully managed independently:
    The drummer track is great for brilliant drum parts. But to make your own edits you want to convert the drum part to a midi track.
    To this:
    Highlight the drummer track and r/click Convert To Midi Region.
    Create a new track, then copy the midi region above into this new track.
    In the new midi track, r/click the midi region, then select Separate By Note Pitch.
    This auto creates a new track for each drum part, but they all share the same channel strip, so changing volume on one changes it on all.
    To put these kit components into separate trax, do this:
    To move them into unique channel strips, create a new midi/software track for each drum part, then drag each part from the original split into each of the new tracks. They now have their own channel strip.
    Delete the original drummer and channel split trax.
    You know have full independent control over each drum part. Assign your required drum kit to these trax and head bang away.

  • Reading files and converting into xml structure

    Hi,
    In my application a client requests for the folder structure information to a server through RMI. The server needs to read files and folders on local machine and convert it into some structure (I am thinking of using xml) and send it back. For eg: I am planning to have Server send back something like:
    <directory name = "parentdirectory">
    <file name = "abc.jpg"/>
    <file name = "def.bmp"/>
    <directory" name = "subdirectory">
    <file name = "hij.jpg"/>
    <file name = "klm.bmp"/>
    </directory>
    </directory>
    It is just the names of the files I am interested in and not the contents. Is this a good approach of sending back the data as a string containg xml definition. Is there any better appproach in terms of performance, memory etc? I am currently planning on using DOM for construction of this structure. Is there a source code for reading and converting the folder structure into xml. Just for your information, the clients gets this information and shows it as a tree structure on the GUI.
    Thanks!!!!

    Is this a good approach of sending back the data as a string containg xml definition. It'll work.
    An alternative, more direct approach is to build a memory representation and send this as argument/return value of an RMI call. You'd need to write classes MyDirectory and MyFile; MyFile has just a name; MyDirectory has a name and a collection of MyDirectory and one of MyFile. Make these classes implement Serializable and you can send them over RMI.
    The effort to write those trivial classes would be less than to implement XML encoding/decoding, and also in terms of runtime performance and memory it will be hard to beat Java's serialization with anything XML-based. In this case I doubt performance/memory are relevant considerations though.
    If for some reason I'd go for sending XML Strings anyway, I wouldn't do the encoding/decoding myself; I'd use XStream to convert Java classes to/from XML and still end up writing the above two classes and be done.
    Sorry if you wanted a simple yes or no :-)

  • Import photos and video into different folders

    Hi, is there any way to import photos and videos into seperate folders?
    I use lightroom to manage my photos and videos, but the videos are much larger so I prefer they are stored in a different location.
    I can import them together and drag the photos to a new folder, but this does not create the same folder heirarchy as importing them would.
    Currently I import once for photos and onece for videos, but I'd prefer to just "import"
    Thanks!

    This plugin from Rob Cole might do what you're after http://www.robcole.com/Rob/ProductsAndServices/ImporterLrPlugin/index.cfm

  • Getting user name, date and time into 1 field

    Hi All,
    I have to add a new field in a customising include of AUFK table. This field should have user name, date and time. How do I store all these values in a single field of the table? Please help.

    Ok Thanks all. Will try your suggestions. But there is one problem. As i have already mentioned that i will have to display this detail in one field of the table control, The format of display is: user name should be seen above and the date and time separated by space should be displayed below the name. How can i ultimately display this in the table control. Do i have to create 2 different fields (one for name and other for date and time) in the AUFK table or is there any other solution?
    Thanks

  • Strokes of line and polyline behave different during zooming - why?

    Hello,
    I noticed a different behaviour between the a line an a polyline during zooming. The stroke of the line will not be increased while zooming. But the stroke of the polyline will be increased while zooming. I don't understand this behaviour. Is this a feature or a bug? For a better understanding you can execute the following demo:
    import javafx.application.Application;
    import javafx.beans.value.ChangeListener;
    import javafx.beans.value.ObservableValue;
    import javafx.scene.Group;
    import javafx.scene.Node;
    import javafx.scene.Scene;
    import javafx.scene.control.Slider;
    import javafx.scene.paint.Color;
    import javafx.scene.shape.Line;
    import javafx.scene.shape.Polyline;
    import javafx.stage.Stage;
    public class ScaleDemoLinePolyline extends Application {
         public static void main(String[] args) {
              launch(args);
         @Override
         public void start(Stage stage) throws Exception {
              final Group root = new Group();
              Scene scene = new Scene(root, 800, 600, Color.WHITE);
              stage.setScene(scene);
              //create a group with line and polyline
              final Group elements = new Group();
              Line line = new Line(100, 100, 400, 100);
              Polyline polyline = new Polyline(new double[] { 100, 200, 400, 200 });
              elements.getChildren().add(line);
              elements.getChildren().add(polyline);
              root.getChildren().add(elements);
              //init the slider for zooming
              Slider scale = new Slider();
              scale.setMin(1);
              scale.setMax(50);
              scale.setValue(1);
              scale.setLayoutX(100);
              scale.setLayoutY(500);
              root.getChildren().add(scale);
              scale.valueProperty().addListener(new ChangeListener<Number>() {
                   public void changed(ObservableValue<? extends Number> ov,
                             Number old_val, Number new_val) {
                        for (Node node : elements.getChildren()) {
                             node.setScaleX(new_val.doubleValue());
                             node.setScaleY(new_val.doubleValue());
              stage.show();
    }Thanks for your help!
    Best Regards

    Sorry for the thread. I regonized, that this is bug, which is fixed in version 2.1. see http://javafx-jira.kenai.com/browse/RT-13328

Maybe you are looking for