How to upload the flat file records into internal table by position?

Hi
I have a flat file which has 7 records in each row and they are NOT provided with CSV or Tab demilited...
They are continous text without spaces....
but i know the fixed length of each field Eg : 1st field 7 char and seconc field 3 char and so on...
How can i upload this file into internal table by reading positions of each field...I know we can use GUI_UPLOAD and Read dataset and Open dataset...
But please let me know to read the file with the fixed postions and load into internal table...
Thanks in advance
MM

Hi
As per my knowledge i dont think thr is some function module or so to read with a fixed positions.
You can use the below method if you think this is the best way.
Suppose your file has
types : begin of ty_itab,
            field1 type char7,
            field2 type char3,
            field3 type chat3,
            field4 type char3,
            end of ty_itab.
types : begin of ty_upload,
             str type string,
            end of ty_upload.
data : it_itab type standatd table of ty_itab,
          it_upload type standard table ot ty_upload,
          wa_itab type ty_itab,
          wa_upload type ty_upload.
use gui_upload.get the data in it_upload.
here you know that u have first 16 charcters makes a first row n then next 16 charcters next row
  Loop at it_upload into wa_upload.
   v_len =  strlen ( wa_upload ).
   v_len = v_len / 16.
    You get number of rows per record ,if it is decimal value make it final value if 3.9 make to 4.
    do v_len times.
      wa_itab = wa_upload.
      By this only first 16 characters are moved and respective fields will get a value.or else u can use offset
       wa_upload+0(16).
      append wa_itab to it_itab.
      Now shift 16 characters using shift command in wa_upload.
    enddo.
  endloop.
Hope this syntax help you to resolve your issue.May be something i have missed .Right now i don't have sap system to send you the full correct syntax code.
Cheers
Joginder

Similar Messages

  • How to store the flat file data into custom table?

    Hi,
    Iam working on inbound interface.Can any one tell me how to store the flat file data into custom table?what is the procedure?
    Regards,
    Sujan

    Hie
    u can use function
    F4_FILENAME
    to pick the file from front-end or location.
    then use function
    WS_UPLOAD
    to upload into
    AT SELECTION-SCREEN ON VALUE-REQUEST FOR p_file.
      CALL FUNCTION 'F4_FILENAME'   "Function to pick file
        EXPORTING
          field_name = 'p_file'     "file
        IMPORTING
          file_name  = p_file.     "file
      CALL FUNCTION 'WS_UPLOAD'
       EXPORTING
         filename                       = p_file1
        TABLES
          data_tab                      = it_line
    *then loop at it_line splitting it into the fields of your custom table.
    loop at it_line.
              split itline at ',' into
              itab-name
              itab-surname.
    endloop.
    then u can insert the values into yo table from the itab work area.
    regards
    Isaac Prince

  • How to convert the flat file data into sap tables . ?

    how to upload flat file data into sap table . before upload mapping is also there in some filds . any one can give me some steps how to upload and mapping . ?

    Hi
    See the sample code
    REPORT zmmupload.
    Internal Table for Upload Data
    DATA: i_mara like MARA occurs 0 with header line
    PARAMETERS: p_file LIKE ibipparms-path.  " Filename
    At selection-screen on Value Request for file Name
    AT SELECTION-SCREEN ON VALUE-REQUEST FOR p_file.
    Get the F4 Values for the File
      CALL FUNCTION 'F4_FILENAME'
        EXPORTING
          program_name  = syst-cprog
          dynpro_number = syst-dynnr
        IMPORTING
          file_name     = p_file.
    Upload the File into internal Table
      CALL FUNCTION 'UPLOAD'
        EXPORTING
          filename                = p_file
          filetype                = 'DAT'
        TABLES
          data_tab                = i_mara
        EXCEPTIONS
          conversion_error        = 1
          invalid_table_width     = 2
          invalid_type            = 3
          no_batch                = 4
          unknown_error           = 5
          gui_refuse_filetransfer = 6
          OTHERS                  = 7.
      IF sy-subrc <> 0.
    MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
            WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
      ENDIF.
    Upload the Data from Internal Table
      MODIFY MARA from TABLE i_MARA.
    Regards
    Anji.

  • How to upload a flat file into a Z DB table

    Hi All,
    For a planning application I would like to permit our users to upload a flat file to a internal table to be persisted on to any given database Z Table. From here we would use it in a planning application.
    Please kindly share the code and approach to implement this in BSP.
    Thanks
    Karen

    Hi Karen,
    Check the links mentioned below.
    [Excel to internal table|Excel to Internal table in BSP;
    [upload excel into BSP|upload excel sheet into BSP application;
    The two links show how to convert an excel file data to internal table in BSP application.Similarly you can convert the flat file data to internal table and then modify the Z DB table to store the data from internal table.
    Regards,
    Anubhav

  • Bdc upload file data into internal table problem with gui_upload fm

    Hello experts,
    my coding is like this ..
    data : begin of itab occurs 0 .
    field1 like mara-matnr,
    field2......
    etc,
    end of itab.
    data: file1 type string.
    parameter :file like rlgrap-filename.
    AT SELECTION-SCREEN ON VALUE-REQUEST FOR file.
    CALL FUNCTION 'KD_GET_FILENAME_ON_F4'
    EXPORTING
    static = 'X'
    mask = space
    field_name = 'FILE'
    CHANGING
    file_name = file.
    START-OF-SELECTION.
    FILE1 = FILE . "HERE I AM PASSING INTO STRING
    CALL FUNCTION 'GUI_UPLOAD'
    EXPORTING
    filename = FILE1
    FILETYPE = 'ASC'
    has_field_separator = 'X'
    TABLES
    data_tab = itab. " here the data is not populating from the file , it is giving the error like speified table not found.
    HERE i am getting the message like "specified table name not recgonised" . the data is not populating into the itab from the file.
    file structure is same as the internal table.
    I stored the file as .txt( ie in notepad).
    my file is like this..
    10000 200 323 sunndarrr.......
    i had a problem with this bdc , i am getting like "specified table name not recgonised" in the fm gui_upload while debugging.
    when i am using the ws_upload it is working fine.
    please guide me where i have done the mistake.
    thank you so much for all the replies.

    Hi,
    Have a look on the following code.
    TABLES: kna1.
    DATA: BEGIN OF itab1 OCCURS 0,
          str(255),
          END OF itab1.
    DATA: itab2 TYPE kna1 OCCURS 0 WITH HEADER LINE.
    CALL FUNCTION 'WS_UPLOAD'
      EXPORTING
        filename                = 'D:\ABAP EVE\ffile1.txt'
        filetype                = 'ASC'
      TABLES
        data_tab                = itab1
      EXCEPTIONS
        conversion_error        = 1
        file_open_error         = 2
        file_read_error         = 3
        invalid_type            = 4
        no_batch                = 5
        unknown_error           = 6
        invalid_table_width     = 7
        gui_refuse_filetransfer = 8
        customer_error          = 9
        no_authority            = 10
        OTHERS                  = 11.
    IF sy-subrc <> 0.
      WRITE:/ 'sorry'.
    ELSE.
      LOOP AT itab1.
        SPLIT itab1-str AT ',' INTO itab2-kunnr itab2-name1.
        APPEND itab2.
      ENDLOOP.
      IF sy-subrc = 0.
        LOOP AT itab2.
          WRITE:/ itab2-kunnr,itab2-name1.
          INSERT INTO kna1 VALUES itab2.
        ENDLOOP.
        IF sy-subrc = 0.
          WRITE:/ 'inserted'.
        ELSE.
          WRITE:/ 'not inserted'.
        ENDIF.
      ELSE.
        WRITE:/ 'fail'.
      ENDIF.
    ENDIF.
    Flat file:
    10001,Sadney
    10003,Yogesh
    20005,Madan
    1.U need to define internal table with one field of max size
    2.upload the flat file data into that internal table
    3.split that internal table data into another internal table(having fields)
    <REMOVED BY MODERATOR>
    thanks,
    Chandu
    Edited by: Alvaro Tejada Galindo on Apr 30, 2008 12:17 PM

  • How to upload a Flat file into sap database if the file is in Appl'n Server

    Hello Sap Experts , Can you tel me
    " How to upload a Flat file into sap database if the file is in Application Server.
    what is Path for that ?
    Plz Tel Me its Urgent
    Thanks for all

    Hi,
    ABAP code for uploading a TAB delimited file into an internal table. See code below for structures.
    *& Report  ZUPLOADTAB                                                  *
    *& Example of Uploading tab delimited file                             *
    REPORT  zuploadtab                    .
    PARAMETERS: p_infile  LIKE rlgrap-filename
                            OBLIGATORY DEFAULT  '/usr/sap/'..
    DATA: ld_file LIKE rlgrap-filename.
    *Internal tabe to store upload data
    TYPES: BEGIN OF t_record,
        name1 like pa0002-VORNA,
        name2 like pa0002-name2,
        age   type i,
        END OF t_record.
    DATA: it_record TYPE STANDARD TABLE OF t_record INITIAL SIZE 0,
          wa_record TYPE t_record.
    *Text version of data table
    TYPES: begin of t_uploadtxt,
      name1(10) type c,
      name2(15) type c,
      age(5)  type c,
    end of t_uploadtxt.
    DATA: wa_uploadtxt TYPE t_uploadtxt.
    *String value to data in initially.
    DATA: wa_string(255) type c.
    constants: con_tab TYPE x VALUE '09'.
    *If you have Unicode check active in program attributes then you will
    *need to declare constants as follows:
    *class cl_abap_char_utilities definition load.
    *constants:
    *    con_tab  type c value cl_abap_char_utilities=>HORIZONTAL_TAB.
    *START-OF-SELECTION
    START-OF-SELECTION.
    ld_file = p_infile.
    OPEN DATASET ld_file FOR INPUT IN TEXT MODE ENCODING DEFAULT.
    IF sy-subrc NE 0.
    ELSE.
      DO.
        CLEAR: wa_string, wa_uploadtxt.
        READ DATASET ld_file INTO wa_string.
        IF sy-subrc NE 0.
          EXIT.
        ELSE.
          SPLIT wa_string AT con_tab INTO wa_uploadtxt-name1
                                          wa_uploadtxt-name2
                                          wa_uploadtxt-age.
          MOVE-CORRESPONDING wa_uploadtxt TO wa_upload.
          APPEND wa_upload TO it_record.
        ENDIF.
      ENDDO.
      CLOSE DATASET ld_file.
    ENDIF.
    *END-OF-SELECTION
    END-OF-SELECTION.
    *!! Text data is now contained within the internal table IT_RECORD
    * Display report data for illustration purposes
      loop at it_record into wa_record.
        write:/     sy-vline,
               (10) wa_record-name1, sy-vline,
               (10) wa_record-name2, sy-vline,
               (10) wa_record-age, sy-vline.
      endloop.

  • How to upload the text file into smart forms

    Hi Experts,
    can any one tell me that how to upload  the text file or html file to SAP Script form or smart forms
    i have download the form info from SAPscript form.to text file.
    now i want to upload the text file to smartforms.
    is it possible ? if it is possible, then how can i do that ?
    Thanks in Advance.
    Regards,
    Mani

    <b>For Scripts</b>
    Go to SE38. Put in the program name RSTXSCRP. Execute it.
    Mode(Export/Import) : Import.
    Give the file name from which you want to upload and execute it.
    <b>For Smartforms</b>
    TCode : smartforms.
    Give the form name.
    Utilities-->Upload form.
    Reward points if helpful.
    Thanks
    Aneesh.

  • Error message while uploading the flat file

    Hi Experts,
    I am getting the error message while uploading the flat file.
    Message class: MG
    Number: 147
    The message is: Several descriptions exist for the language JA.
    Please guide me why this error is occuring.
    Regards
    Akshay

    hi,
    how are you uploading the file and where ?
    u can use open dataset  , read dataset or gui_upload
    check this link
    http://help.sap.com/saphelp_nw04/helpdata/en/c8/e92637c2cbf357e10000009b38f936/frameset.htm

  • How to query the flat files?

    Hi
    How to query the flat files that are used in Etl From EBS source.

    That can be done in OBIEE. Save the flat file as .csv format. Then go to ODBC Administrator on windows machine where you BI server is running, and create an System DSN and select "Microsft Access Text Driver (*.txt, *.csv)" as driver type.
    Next, import tables in RPD using this ODBC connection. Rest of the steps as same as building model from a table source.
    Hope this helps.

  • How to list the JAR files loaded into the Oracle Database ?

    How to list the JAR files loaded into the Oracle Database ?

    From 11.1 onwards, the below two views are available to identify the jar files loaded into the Database.
    JAVAJAR$
    JAVAJAROBJECTS$
    By querying the JAVAJAR$ view you can know information about the JAR files loaded into the Database and using JAVAJAROBJECTS$ view you can find all the java objects associated with the given JAR file.
    These views are populated everytime you use LOADJAVA with "-jarsasdbobjects" option to load your custom java classes.
    But unfortunately this feature is available only from 11.1 onwards and there is no clear workaround for above in 10.2 or earlier.

  • How to fetch the SAP Standard Prog. built internal table into my_z_prog.?

    Hi Experts,
    Pls. let me know that,
    How to fetch the SAP Standard Prog. built internal table into my_z_prog.?
    For more explannation, pls. see my other thread with name of yestrday,
    SUBMIT RFGLBALANCE WITH selection criteria, then How to get resulted itab?
    thanq

    Hi
    Suppose RFGLBALANCE is your standard program and you have an internal table named I_RFGLBALANCE.
    And lets say your Z program name is Z_SRINIVAS.
    First find out the type of the internal table you want in your Z-program in the standard program. And declare an internal table of similar type in your Z-program.
    I hope you can do this much.
    Later wherever you are putting the below mentioned code.
    SUBMIT RFGLBALANCE WITH selection criteria
    Write the code which i have written.Obviously modify it to suit your requirement.
    Please show what is not working fine so that even anyone else can help you with the problem you are facing.
    Regards,
    Mayank

  • How to get the field name of an internal table during runtime?

    How to get the field name of an internal table during runtime?

    Hi  Sudhir,
    Declare and Use Get Cursor Field in Your Prm to get the field Name of the Intenal Table
    Example Code:
        <b>  DATA: v_field(60).                        " Insert this code.
         GET CURSOR FIELD v_field.        " Insert this code.</b>
         <b>CHECK v_field = 'ITAB-KUNNR'.    " Insert this code. (or)
    Write: v_field.</b>
    Regards,
    Ramganesan K.

  • How to upload the tif file and Display into Iframe

    Hi all,
       My requirement is to upload 'n' number of tif files and display the file name in dropdown.
       If i select the file name, it should display the file in Iframe.
    My problem is i am not able to upload the tif file.
    try{
          byte []by=new byte[wdContext.currentContextElement().getPhotoResource().read(true).available()];
          wdContext.currentContextElement().getPhotoResource().read(true).read(by);
          String ext=wdContext.currentContextElement().getPhotoResource().getResourceType().getFileExtension();
          WDWebResourceType res=wdContext.currentContextElement().getPhotoResource().getResourceType();
          IWDResource resource=null;
          resource=WDResourceFactory.createResource(by,"sample",WDWebResourceType.getWebResourceTypeForFileExtension(ext));
           wdContext.currentContextElement().setPhoto(resource.toString());
              catch(Exception e){
    In the above code Photo is Iframe Context variable.
    If i upload tif file means it directly giving Save and Open options is giving.
    Please how to slove this probelm...........................
    Thanks,
    Suni

    Hi Satya,
    In HTML a TIF file can be displayed as"
    <html>
    <body>
    <object height="100%" width="100%"
    type="image/tiff" data="PO.tif">
    </object>
    </body>
    </html>
    Hope it helps.
    Regards,
    Alka

  • How to devide the set of records into groups in SQL itself.

    Hi , i am using 10.2.4.0 of oracle.
    I am having one requirement, in which i have to devide the set of records into certain groups , so that they can be executed partly but not in one run.
    So in the 'SELECT' clause itself i want to asssign particular value (may be 1 )to first 50000 records then another value(may be 2) to next 10000, like wise. And again the total count of records will also varry time to time , if the total count of record set is less than 10000 , then it should only assign '1' to all the records. i will set the group values (1,2,3...) as another column itself.
    Can you please let me know if this can be done in SQL without going for PLSQL?

    Hi,
    That's called a Pagination Query , and here's one way to do it:
    WITH     got_grp          AS
         SELECT     x.*
         ,     CEIL ( ROW_NUMBER () OVER (ORDER BY  x_id) 
                   / 50000
                   )          AS grp
         FROM     table_x  x
    --     WHERE     ...          -- If you need any filtering, put it here
    SELECT     *               -- Or list the columns you want
    FROM     got_grp
    WHERE     grp     = 1
    ;ROW_NUMBER () OVER (ORDER BY x_id)     assigns unique integers 1, 2, 3, ... to all all rows, in the same order as x_id (even if x_id is not unique).
    CEIL (ROW_NUMBER () OVER (ORDER BY x_id) / 50000)     maps the 1st 50,000 of those numbers to 1, the 2nd 50,000 to 2, and so on.
    Analytic functions (like ROW_NUMBER) as computed after the WHERE clause is applied, so, to use the results in a WHERE clause, then you need to compute them in a sub-query. If you just want to display the number, and not use it in a WHERE clause, then you don't need a sub-query.
    I hope this answers your question.
    If not, post a little sample data (CREATE TABLE and INSERT statements, relevant columns only) for all the tables involved, and the results you want from that data.
    In the case of a DML operation (such as UPDATE) the sample data should show what the tables are like before the DML, and the results will be the contents of the changed table(s) after the DML.
    Explain, using specific examples, how you get those results from that data.
    Always say what version of Oracle you're using.
    See the forum FAQ {message:id=9360002}

  • How to upload the pdf file to the next view?....urgent

    Hi Experts,
    I need to upload the pdf file( a interactive form ) using the fileupload element in the A_view and the pdf file can be displayed in the b_view.
    But I don't know how to complete the function?
    Action:
    0.  Create a adobe form (c_form)in the R/3 using sfp with a inputfield.
    1.  Create a adobe interactive form (A_interactive_form)in the view(display_view) of the WDA for abap.
    2.  Create a context attribute(upload) in the display_view.
    3.  Bind the c_form to the A_interactive_form, so that the data can be transfered to the c_form.
    4.  Bind the "pdfSourth" property to context attribute "upload" in the A_interactive_form.
    4.  Type code in the WDA for abap for setting data("old") to the context.
    5.  Active the WDA and run the WDA.
    6.  In the IE, the interactive form is displayed with the value "old" in the field. Save the pdf form as "test.pdf" and close the IE.
    7.  Open the test.pdf, and type the inputfield "new" in the form, and save the test.pdf.
    8.  Create a context node(Pdfsourth) in the component controller, and create a attribute("upload") that type is xstring in the Pdfsourth.
    9.  Create a view(C_view), mapping the context node(Pdfsourth) in the component controller.
    10. Create a fileupload element in the C_view, and the "data" property is binded the "upload" attribute in the context node(Pdfsourth).
    11. Create a button(Display_form) and create the action with the outplug for upload the pdf file(test.pdf).
    12. Change the window and set the C_view as default view, and set the Navigation link from the C_view to B_view.
    13. Type code in the wddoinit method in the display_view for transfering the test.pdf file.
    method WDDOINIT .
    DATA lo_componentcontroller TYPE REF TO ig_componentcontroller .
    DATA upload                 TYPE        xstring.
    lo_componentcontroller =   wd_this->get_componentcontroller_ctr( ).
      lo_componentcontroller->getupload(
        IMPORTING
          upload = upload                         " xstring
      DATA lo_nd_pdfsourch TYPE REF TO if_wd_context_node.
      DATA lo_el_pdfsourch TYPE REF TO if_wd_context_element.
      DATA ls_pdfsourch TYPE wd_this->element_pdfsourch.
    navigate from <CONTEXT> to <PDFSOURCH> via lead selection
      lo_nd_pdfsourch = wd_context->get_child_node( name = wd_this->wdctx_pdfsourch ).
    get element via lead selection
      lo_el_pdfsourch = lo_nd_pdfsourch->get_element(  ).
    get single attribute
      lo_el_pdfsourch->set_attribute(
        EXPORTING
          name =  `UPLOAD`
          value = upload ).
    endmethod.
    15. Active the WDA and run the WDA.
    In the fileupload of the C_view, I select the test.pdf from my local machine. and click the button(Display_form), the display_view is displayed with the A_interactive_form.
    But in the A_interactive_form, the value "old" is in the field in the form rather than "new".
    I hope to display the test.pdf in the A_interactive_form. I don't know how to change my code or configuration?
    Do you give some example or some hint for this problem ?
    Thanks & Regards,
    Tao

    Now, The problem has been solved.Thanks a lot.

Maybe you are looking for

  • Image smooth tween

    I have five images in a row on my site and every now and then when I roll mouse over one up comes the other and then I try to close one and the other is jittering. Why? I created a movie clip for each image and also a movie clip within each movie cli

  • Copy & Paste plain text?

    It's really annoying sometimes when I can't copy just plain text from firefox to Pages. It always comes with its own font and size. How could I just copy plain text?

  • Problems with file sharing

    I'm having a lot of problems setting up OS X 10.5 server. Help with any/all of these issues would be much appreciated. 1. Sometimes, the server "forgets" that my administrator account exists. That is, I log off/restart/shut down normally, and then I

  • Why won't the archive file for photoshop elements 11 download?

    Why won't my photoshop elements 11 archive file download?

  • ESET Smart Security says there's a trojan in the plugin for Firefox

    I'm trying to install the Flash plug-in for Firefox and after being forced to use the dumb DLM, the DLM downloads the plugin and tries to install it but my ESET Smart Security  throws up a message: A variant of Win32//TrojanDropper.Agent.OVE trojan h