Reading Flat File

I ma having a falt file like this
35,45,UUUUUUUUUUUUUUUUUUUUUUUUJHHNNBGHHHHHHHHHHHHHHHHH
KKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKK~
678,323,unnmiMM>>LLLLLHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHKMKKKKKKKM
JJJJJJJJJJJJJJJJJJJJJJJJJIKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKK~
980,765,HJJMMFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF
BBBBBBBBBBBBBBBBBBBHHHHHHHHHHHHGGGGGGGGGGGGGGGGGGGGGGGGGGGGGG~
each record ends with ~ sign.
Now how do i read a single record using I/O package.
can someone please post the code snippet or some logic to read such files.

Read the file using RandomAccessFile
File fileToRead = new File( fileName );
RandomAccessFile raf = new RandomAccessFile(
fileToRead, "r" );
String str[] = null;
str = raf.readLine().split("~");
so the records will be stored in str, array of
String, first rec is str[0]
thank u sir,
i will be doing it very soon.
Like that.
Ganesh

Similar Messages

  • How to read flat file and convert to xml throught OSB

    Hi ,
    Can somebody help how to read flat file and convert to xml in OSB.
    appreciate ur help.
    Thanks & Regards ,
    Siva K Divi

    if you're using the oepe with osb plugin (will be installed when you install the osb locally) and then in your osb project > rightmouseclick > new > MFL.
    that's it
    maybe you're trying to create it within an oepe installation which doesnt have the osb plugin ?

  • Problem Reading Flat File from Application server

    Hi All,
    I want to upload a Flat File which is having a Line Length of 3000.
    While uploading it to Application server , only upto 555 length it is getting uploaded .
    i am using the code :
    DATA: BEGIN OF TB_DATA OCCURS 0,
            LINE(3000),
          END OF TB_DATA.
    *----Uploading the flat file from the Local drive using FM "UPLOAD".
    OPEN DATASET TB_FILENAM-DATA FOR OUTPUT IN TEXT MODE." ENCODING DEFAULT.
    IF SY-SUBRC NE 0.
      WRITE:/ 'Unable to open file:', TB_FILENAM-DATA.
    ELSE.
      LOOP AT TB_DATA.
        TRANSFER TB_DATA TO TB_FILENAM-DATA.
      ENDLOOP.
    ENDIF.
    CLOSE DATASET TB_FILENAM-DATA.
    What could be the problem?
    Could it be due to any Configuration Problem?
    Waiting for your replies.
    Thanks and Regards.
    Suki

    Your code looks OK, but you may have touble displaying the full width. Try:
    WRITE: /001 TB_FILENAM-DATA+555.
    (And don't forget to append your ITAB after each read.)
    Rob

  • To read flat file from a unix server

    We need to read a flat file from a Unix server, where our Database is located.
    The location gets created correctly.
    But while we are trying to import files from the location in Design Center , we get an error that "directory does not exists", although the directory has all the permissions.
    Can someone please suggest how should we create the location so as it can read the files.
    Please Reply ASAP......

    We have started Design Center on a local machine(Windows Machine) with uaer as repository owner of the server,
    In the design center we can not sample the file till we import it,
    can you please tell how to sampe the file without importing it.
    Also a location pointing to server location gets easily created on the design center and the file module points to that location only, but when we try to import the file through that location, it says directory does not exists, although oracle user has all the read write permissions on the directory......
    Please help!

  • Reading flat files with variable names in SSIS

    I have a ssis package that reads a flat file from a network drive (using a flat file connection manager) and loads the data into sql server tables. I have this working on a fixed file name, however in reality the file name will not be the
    same from run to run.      Essentially, I need to check a folder each day and if there is a file there with a certain prefix (for example, 'datafile'), I need to process this file(s). In other words, if there is a file in the folder
    called datafilexyz, my process needs to read it in and process it.    If there are files named datafileabc, datafiledef, and testfile123, I need to read in and process the datafileabc and datafiledef flat files.    
    I'm not sure how to make this work.     I haven't had any SSIS training, just what I can find on the internet and looking at existing SSIS packages (I haven't found any that do what I'm trying to do here) so I'm kind of lost.   
    Any help is appreciated.  

    this is working well.    How can I, after loading each flat file, move the flat file to an archive folder?    I'm trying to use a file system task, but doing something wrong.    I created and reference
    an archive folder connection manager in the destination connection, and reference the original folder connection manager for the source connection, but get 'sourcepath is not valid on operation movefile'.    I think a file system task is what
    is needed (within the foreach loop after the data load for each flat file), but I'm not doing something correctly.
    Sounds fine except for one thing. Did you assign the filename variable to connection string property of the source file connection manager used by file system task?
    Also it should be existing file option you should choose for
    source connection and existing folder for destination.
    Please Mark This As Answer if it solved your issue
    Please Mark This As Helpful if it helps to solve your issue
    Visakh
    My MSDN Page
    My Personal Blog
    My Facebook Page

  • Read flat file into IDOC

    Hello All,
    I have a file in application server, now I need to convert this file into IDOC format and save the records in SAP database. Can any one provide us the steps to do this. I would like to know how to create a port for file type to read the flat file.
    Thank you,

    Hi,
    Create a Z program in se38 and in that you will have to make use of OPEN DATASET, READ DATASET and CLOSE DATASET statements to read the fiel from the application server.
    IDOC is just an intermediate document with some structure.
    It does not have a capability to read a file by itself.
    The file had to be explicitely read from the application server making use of the above statements and then pass the data to the idoc structure.
    For more help do F1 on these statements.
    Regards,
    Ankur Parab

  • Read flat file form other than sapserver(not in sapser) in background mode

    Dear Friends,
    I want to upload data from flat file to sap in background mode.
    I know how to read file for application server in background mode, but my requirement is , i need to read the flat file data from other than sap server in backgound mode.
    please help me,
    Regards,
    prabhu

    hi
    you can do like this way.
    fist should get de directory file name.
      CALL FUNCTION 'RZL_READ_DIR_LOCAL'
        EXPORTING
          NAME           = FILE_PATH
        TABLES
          FILE_TBL       = I_FILES
        EXCEPTIONS
          ARGUMENT_ERROR = 1
          NOT_FOUND      = 2
          OTHERS         = 3.
      IF SY-SUBRC EQ 0.
        FILES_TAG = 1.
      ENDIF.
    second
       LOOP AT I_FILES.
    open datafilenaem.
    close datafilename.
    endloop.

  • Is it possible to read flat file .CSV place in Client Machine in network?

    Hi All,
    I want or read the flat file in the client machine place in network through external table.
    I have created an directory called DATALOADNW for client machine path as \\velmurugand\temp
    When i tried to read an flat file iam getting the below error
    ERROR at line 1:
    ORA-29913: error in executing ODCIEXTTABLEFETCH callout
    ORA-29400: data cartridge error
    KUP-04001: error opening file \\velmurugand\temp\Locfile.csv
    ORA-06512: at "SYS.ORACLE_LOADER", line 52
    ORA-06512: at "SRIRAM.LIGHTINGEVENT1", line 68
    ORA-06512: at line 1
    Please can any one help me i have shared and given full permission to access the .CSV file.

    velu wrote:
    I want or read the flat file in the client machine place in network through external table.You can't. External Tables only work when the flat file (and directory) are on the database server.
    Please can any one help me i have shared and given full permission to access the .CSV file.Move the file to the database server.
    Or use your client application (whatever it is) to read in the file.

  • RE: ODI READING FLAT FILES

    Hi,
    I have a file that is produce by Hyperion MAXL and it is not formatted in such a way to read it by ODI. There is no delimited iinformation and it has several junk header and footer lines. I have been resarching and found that I can use Jython or Python. The ODI is installed on a Windows 2003 server. I would like to know what is the best way to format the file in such a way that I can read it in ODI? The column and rows will need to be strip of space and i will have to build the header line and place dilimited symbol after every column value.
    Fsanchez

    I think I answered my own question.
    Here is sample code in VBScript that formats the file and add delimited symbol between columns.
    I would like to know if this can be done in other language as Jython?
    Option Explicit
    On Error Resume Next
    '** DECLARE AND SET VARIABLES **
    Const ForReading = 1
    Const ForWriting = 2
    Const baseDir = "D:\PlanningData\exportdata\"
    Dim objFSO, strLength
    Dim InputFileName, OutputFileName, strMessage
    Dim objInputFile ,objOutputFile
    Dim strInLine, strOutLine
    Dim iColCounter, iCharCounter, iRowCounter
    Dim strMember, strValue
    '** CREATE A FILE SYSTEM OBJECT **
    Set objFSO = CreateObject("Scripting.FileSystemObject")
    '** OPEN INPUT FILE **
    InputFileName = baseDir & "inputData.txt"
    Set objInputFile = objFSO.OpenTextFile(InputFileName, ForReading)
    '** CHECK FOR ERRORS **
    If Err.Number <> 0 Then
    strMessage = "ERROR: Unable to open Input File " & InputFileName & "."
    DisplayCustomError(strMessage)
    WScript.Quit
    End If
    '** OPEN OUTPUT FILE **
    OutputFileName = baseDir & "reformattedData.txt"
    Set objOutputFile = objFSO.CreateTextFile(OutputFileName, ForWriting)
    '** CHECK FOR ERRORS **
    If Err.Number <> 0 Then
    strMessage = "ERROR: Unable to open Output File " & OutputFileName & "."
    DisplayCustomError(strMessage)
    WScript.Quit
    End If
    '** READ INPUT FILE AND BUILD NEW OUTPUT FILE **
    Do Until objInputFile.AtEndOfStream
    strInLine = objInputFile.readLine()
    iRowCounter = iRowCounter + 1
    '** PARSE INPUT LINE **
    For iColCounter = 1 to 2
    If iColCounter = 1 Then
    strMember = Trim(Mid(strInLine, 1, 31))
    End If
    if iColCounter = 2 Then
    strDatabase = Trim(Mid(strInLine, 32, 9))
    End If
    Next
    '** ADD ROW HEADER TO OUTPUT FILE **
    If iRowCounter = 1 Then
    strOutLine = "MEMBER_NAME" & "|"
    objOutputFile.writeLine strOutLine
    End If
    '** WRITE DATA TO OUTPUT FILE **
    strOutLine = strMember & "|"
    strLength = Len(strMember)
    If strLength > 0 Then
    objOutputFile.writeLine strOutLine
    End if
    Loop
    '** CLOSE FILES AND QUIT **
    objInputFile.Close
    objOutputFile.Close
    Wscript.quit
    Sub DisplayCustomError(strMessage)
    'Display custom message and information from VBScript Err object.
    strError = VbCrLf & strMessage & VbCrLf & _
    "Number (dec) : " & Err.Number & VbCrLf & _
    "Number (hex) : &H" & Hex(Err.Number) & VbCrLf & _
    "Description : " & Err.Description & VbCrLf & _
    "Source : " & Err.Source
    Err.Clear
    WScript.Echo strError
    End Sub
    '** END OF VBSCRIPT **
    '*************************************************************************

  • Reading Flat File in Inbound and Converting it to a Idoc

    Hi
    We are stuck with a situation where in we get a ASN file from Mainframe to XI . XI just reroutes it to SAP and puts the file on Application server. Now R/3 has to read that ASN File and has to split it according to the Invoices and create Idocs for PO's as per the invoice Numbers. (We have a program which splits the incoming file into different Files depending on the Invoices)
    Now My doubt here is how can i get a Idoc triggered after the File has been read and split in the R/3.
    I checked Transaction WE16 , Prog. RSEINB00  but couldnt get a understanding .
    Please suggest.
    regards
    Vikas Chaudhary

    Hi Shiva,
    Thanks for a response .
    But as per my Functional Consultant ; PI's Role should be limited only to reroute the file and store it on Application Server .
    R/3 Picks up that file and then splits it based on the Invoice Number; and again stores it in the application server.
    Then R/3 Should Pick it up again one by one and convert to Idocs .
    ASN to be splitted into Diff. Invoices . Once Splitted. Each Invoice Creates a PO . Once a PO is created Goods Reciept should be done. And after the Goods Reciept is done Service Entry Sheet needs to be created too.
    A Query Again : I donn think this can be done via One Message Type. I am also lookin out for using  one msg. type for creating a PO and other activities can be done by extending a existing msg. type.
    Regards
    Vikas Chaudhary

  • OutOfMemoryError while reading flat files

    Hi,
    I am redesigning a Java program. This program reads two huge falt files, compares the data-records and write results into three different files. It was written in jdk1.1 before and it uses String everywhere to compare and process the data. Now since I am re-writing this again, I am trying to use HashTable/HashMap so that the data comparison will be a lot more easier and fatser.
    Each of the two input files can have more than 400000 records. I am getting OutOfMemoryError while I read and load my files into a HashMap.
    Is it because that HashMap/HashTable cant be that big or is it that my JVM is dying?
    What else can I use to read these many key-value pair?
    Thanks a bunch

    Hi,
    I've been facing the same problem although I have
    ve 1024MB Ram....
    That happens when I try to read a 64MB File.
    From what I've heard, It might be a memory leak
    ak or..... whatever... It is a JRE problem...You're telling the JRE to use the default maximum heap size (64MB) by not specifying a value suitable for your application with the -Xmx option.
    It is a JRE problem only in so much as the error doesn't point you to the JRE memory options documentation.
    Pete

  • Loading transaction data from flat file to SNP order series objects

    Hi,
    I am an BW developer and i need to provide data to my SNP team.
    Can you please let me know more about <b>loading transaction data (sales order, purchase order, etc.,) from external systems into order based SNP objects/structure</b>. there is a 3rd party tool called webconnect that gets data from external systems and can give data in flat file or in database tables what ever required format we want.
    I know we can use BAPI's, but dont know how. can you please send any <b>sample ABAP program code that calls BAPI to read flat file and write to SNP order series objects</b>.
    Please let me know ASAP, how to get data from flat file into SNP order based objects, with options and I will be very grateful.
    thanks in advance
    Rahul

    Hi,
    Please go through the following links:
    https://forums.sdn.sap.com/click.jspa?searchID=6094493&messageID=4180456
    https://forums.sdn.sap.com/click.jspa?searchID=6094493&messageID=4040057
    https://forums.sdn.sap.com/click.jspa?searchID=6094493&messageID=3832922
    https://forums.sdn.sap.com/click.jspa?searchID=6094493&messageID=4067999
    Hope this helps...
    Regards,
    Habeeb
    Assign points if helpful..:)

  • Converting flat file to XML

    Hi
    i just want to read flat file and convert it into xml but there are some problem ,it throws a ArrayIndexOutOfBoundException.Here is code.
    import java.io.*;
    import java.util.*;
    class FlatXMLBudget {
      public static void convert(List data, OutputStream out)
       throws IOException {
        Writer wout = new OutputStreamWriter(out, "UTF8");
        wout.write("<?xml version=\"1.0\"?>\r\n");
        wout.write("<Budget>\r\n");
        Iterator records = data.iterator();
        while (records.hasNext()) {
          wout.write("  <LineItem>\r\n");
          Map record = (Map) records.next();
          Set fields = record.entrySet();
          Iterator entries = fields.iterator();
          while (entries.hasNext()) {
            Map.Entry entry = (Map.Entry) entries.next();
            String name = (String) entry.getKey();
            String value = (String) entry.getValue();
            // some of the values contain ampersands and less than
            // signs that must be escaped
            //value = escapeText(value);
            wout.write("    <" + name + ">");
            wout.write(value);       
            wout.write("</" + name + ">\r\n");
          wout.write("  </LineItem>\r\n");
        wout.write("</Budget>\r\n");
        wout.flush();
      public static String escapeText(String s) {
        if (s.indexOf('&') != -1 || s.indexOf('<') != -1
         || s.indexOf('>') != -1) {
          StringBuffer result = new StringBuffer(s.length() + 4);
          for (int i = 0; i < s.length(); i++) {
            char c = s.charAt(i);
            if (c == '&') result.append("&");
            else if (c == '<') result.append("<");
            else if (c == '>') result.append(">");
            else result.append(c);
          return result.toString(); 
        else {
          return s;  
      public static void main(String[] args) {
        try {
            /*if(args.length<1)
            System.out.println("Usage: FlatXMLBudget infile outfile");
            return;
          InputStream in = new FileInputStream("d:\\file.txt");
          OutputStream out;
          int a=in.available();
          System.out.println("dd:"+a);
         /*if (args.length < 2) {
            out = System.out;
          else {*/
          List results = BudgetData.parse(in);
          int aa=results.size();
          System.out.println("dd:"+aa);
          out = new FileOutputStream("d:\\flattoxml.xml");
          convert(results, out);
        catch (IOException e) {
          System.err.println(e);      
    import java.io.*;
    import java.util.*;
    class BudgetData
    public static List parse(InputStream src) throws IOException
             // The document as published by the OMB is encoded in Latin-1
             InputStreamReader isr = new InputStreamReader(src, "8859_1");
              BufferedReader in = new BufferedReader(isr);
              List records = new ArrayList(); 
              String lineItem;
              while ((lineItem = in.readLine()) != null)
                 records.add(splitLine(lineItem));
            return records;
      // the field names in order
      public final static String[] keys = {
        "AgencyCode",
        "AgencyName",
        "BureauCode",
        "BureauName",
        "AccountCode",
        "AccountName",
        "TreasuryAgencyCode",
        "SubfunctionCode",
        "SubfunctionTitle",
        "BEACategory",
        "On-Off-BudgetIndicator",
        "FY1976", "TransitionQuarter", "FY1977", "FY1978", "FY1979", 
        "FY1980", "FY1981", "FY1982", "FY1983", "FY1984", "FY1985", 
        "FY1986", "FY1987", "FY1988", "FY1989", "FY1990", "FY1991", 
        "FY1992", "FY1993", "FY1994", "FY1995", "FY1996", "FY1997", 
        "FY1998", "FY1999", "FY2000", "FY2001", "FY2002", "FY2003",
        "FY2004", "FY2005", "FY2006"
      private static Map splitLine(String record)
                  record = record.trim();
                          int index = 1;
             Map result = new HashMap();
              for (int i = 1; i < keys.length; i++)
                      //find the next comma   
                    StringBuffer sb = new StringBuffer();
             char c;
               boolean inString = false;
               while (true)
                 c = record.charAt(index);
                 if (!inString && c == '"') inString = true;
                 else if (inString && c == '"') inString = false;
                 else if (!inString && c == ',') break;
                 else sb.append(c);
                 index++;
                 if (index == record.length()) break;
          String s = sb.toString().trim();
          result.put(keys, s);
    index++;
    return result;
    [output/error]
    java.lang.StringIndexOutOfBoundsException: String index out of range: 71
    at java.lang.String.charAt(String.java:444)
    at BudgetData.splitLine(BudgetData.java:55)
    at BudgetData.parse(BudgetData.java:16)
    at FlatXMLBudget.main(FlatXMLBudget.java:79)
    Exception in thread "main"
    [output/error]
    Can any one help me about this problem.

    Off-by-one error.
    In a String of length 70, for example, the characters are numbered from 0 to 69 in Java. Your program is written as if they were numbered from 1 to 70. So when you try to get #70, the exception occurs.
    But if you want to use commas as a delimiter to break a string into substrings, it's much easier just to use the split() method of String than to write all that code you have there.

  • Flat File to IDOC

    Hi,
    I have to post the data from Flat File to SAP using IDOC. Please help me out with all the posibilities.
    Regards,
    Kiran.L

    Hi,
    Step 1 Read flate file into internal table.
    step 2  Follow below program to create a idoc through Z program,
    REPORT ZOUTBD_IDOC_TEMPLATE NO STANDARD PAGE HEADING.
    *************************START OF DECLARATIONS**********************
    *eject
    Table Declarations
      TABLES:  ZIDOC_TAB_EX1,  "Equivalent to an SAP Master table.
               ZIDOC_TAB_EX2.  "Equivalent to an SAP Master table.
    *eject
    Types Declarations with data work Areas / Internal tables.
      TYPES: begin of ty_idoc_par,
               werks      LIKE   ZIDOC_TAB_EX1-werks,
               c_rec_ind  LIKE   ZIDOC_TAB_EX1-c_rec_ind,
               name1      LIKE   ZIDOC_TAB_EX1-name1,
               name2      LIKE   ZIDOC_TAB_EX1-name2,
               stras      LIKE   ZIDOC_TAB_EX1-stras,
               pfach      LIKE   ZIDOC_TAB_EX1-pfach,
               ort01      LIKE   ZIDOC_TAB_EX1-ort01,
               counc      LIKE   ZIDOC_TAB_EX1-counc,
               pstlz      LIKE   ZIDOC_TAB_EX1-pstlz,
               telf1      LIKE   ZIDOC_TAB_EX1-telf1,
               regio      LIKE   ZIDOC_TAB_EX1-regio,
            end of ty_idoc_par.
      TYPES: begin of ty_idoc_chd,
               werks     LIKE    ZIDOC_TAB_EX2-werks,
               eroed     LIKE    ZIDOC_TAB_EX2-eroed,
               schld     LIKE    ZIDOC_TAB_EX2-schld,
             end of ty_idoc_chd.
      TYPES: begin of ty_message,
               OBJNR      LIKE    MCMAILOBJ-OBJNR,
               OBJLEVEL   LIKE    MCMAILOBJ-OBJLEVEL,
               OBJTYPE    LIKE    MCMAILOBJ-OBJTYPE,
               OBJNAM     LIKE    MCMAILOBJ-OBJNAM,
               OBJDES     LIKE    MCMAILOBJ-OBJDES,
               OBJLINE    LIKE    MCMAILOBJ-OBJLINE,
             end of ty_message.
      TYPES: begin of ty_mess_output,
               v_err_out(1000)     TYPE  C,
               v_err_out_2(1000)   TYPE  C,
             end of ty_mess_output.
    *eject
    Data Declarations
    Essential declarations for populating the IDOC:
      DATA:  begin of itab_idoc_data occurs 0.
               include structure edidd.                    "Data record.
      DATA:  end of itab_idoc_data.
      DATA:  begin of itab_comm_idoc_control occurs 0.
               include structure edidc.                    "Control record.
      DATA:  end of itab_comm_idoc_control.
    Internal Table for Mail Recipient.
      DATA: BEGIN OF ITAB_RECIPIENT OCCURS 0.
              INCLUDE STRUCTURE  ZINT_RECEIVER.
      DATA: END OF ITAB_RECIPIENT.
    Declare an internal table for Parent segment.
      DATA:  itab_idoc_par TYPE ty_idoc_par occurs 0 with header line.
    Declare an internal table for child segment.
      DATA:  itab_idoc_chd TYPE ty_idoc_chd occurs 0 with header line.
    Declare variables for Parent and Child Segments
      DATA:  i_z1parseg  LIKE   z1parseg,     "PARENT SEGMENT DATA.
             i_z1child   LIKE   z1child.      "CHILD  SEGMENT DATA.
    Internal table to process function to send error mails.
      DATA: itab_err_mess  TYPE   ty_message     occurs 0 with header line.
      DATA: itab_mess_output TYPE ty_mess_output occurs 0 with header line.
    Variables for sending error mails.
      DATA: objnr                 LIKE   SOOD1-ACNAM, "Name of object.
            V_ERR_DESC_1          LIKE   SOOD1-OBJDES,
                        "Error message on pop up box after program executes.
            V_OBJLINE             LIKE   ITAB_ERR_MESS-OBJLINE,
            V_MESSAGE_1(60)       TYPE   C,
            V_MESSAGE_2(120)      TYPE   C,
            V_MESSAGE_3(75)       TYPE   C,
            V_MESSAGE_4(150)      TYPE   C,
            V_MESSAGE_5(150)      TYPE   C,
            V_MESSAGE_6(150)      TYPE   C,
            V_RDATE(10)           TYPE   C,
            V_RTIME(8)            TYPE   C,
            V_RECIPIENT(12)       TYPE   C,
            v_itab_idoc_par_lines,
            v_itab_idoc_chd_lines,
            child_counter         TYPE   C,
            parent_counter        TYPE   C,
            idoc_counter          TYPE   C,
            v_mess_output(1000)   TYPE   C,
            v_error_detail(88)    TYPE   C,
            v_final_detail(1000)  TYPE   C,
            V_DUMMY               TYPE   C.   "Dummy File Indicator.
    *eject.
    Constant Declarations
      CONSTANTS:
    BASIC IDOC TYPE AS CREATED FROM TRANSACTION CODE we30.
      C_Segment_type1(8)         TYPE C  VALUE  'Z1IDOCOB',
      C_mestyp(11)               TYPE C  VALUE  'ZSAMPLEMESS',
      C_SENDMODE                 TYPE C  VALUE  'B',   "Sending Mode
      C_EXPRESS                  TYPE C  VALUE  'E',
      C_LANGUAGE                 LIKE sy-langu   VALUE  'E'.
    **********************END OF DECLARATIONS*****************************
    *eject
    Initialisation
    INITIALIZATION.
    Assign the initial settings for sending error mails.
      v_err_desc_1   = 'Message from processing ZOUTBD_IDOC_TEMPLATE.'.
                       "Error message in pop up box after program executes.
      v_error_detail = 'A complete set of detail records is not held for'.
      idoc_counter   = '0'.   "No of Idocs processed.
      parent_counter = '0'.   "No of parent segments selected.
      child_counter  = '0'.   "No of child segments selected.
    *************************BEGIN OF PROCESSING**************************
    Call form to initialize standard structures
      PERFORM clear_Structures.
    Fill report to tell user when the interface was run.
      PERFORM fill_mail_report.
    Call function to populate parent structure:
      PERFORM select_parent_data.
    Call function to populate child structure:
      PERFORM select_child_data.
    Inform the user of the number of records that were selected.
      PERFORM fill_record_selected.
    Loop at contents of parent structure:
      LOOP AT itab_idoc_par.
    Populate the control structure with the partner and port sending and
    receiving details.
       REFRESH itab_idoc_data.
       PERFORM populate_Control_structure USING  c_mestyp
                                                 c_SEGMENT_type1.
       PERFORM transfer_Parent_data_to_seg.
    Loop at the children structure - retrieving the children segments
    for this parent.
       LOOP AT itab_idoc_chd WHERE WERKS = itab_idoc_par-WERKS.
    Call form to transfer data to child Idoc.
       PERFORM transfer_Child_data_to_seg.
    ENDLOOP.      "Stop looping through the children structure.
    Call SAP function to transfer data.
       PERFORM master_idoc_distribute.
    Form to close logical unit of work.
       PERFORM COMMIT_WORK.
    ENDLOOP.   " Stop looping through the parent structure.
    Fill the number of articles processed for online mail.
       PERFORM fill_process_record.
    Write to online mail report on data interface has processed.
       PERFORM FILL_ERR_MESSAGE USING  V_OBJLINE
                                       V_MESSAGE_1
                                       V_MESSAGE_2
                                       V_MESSAGE_3
                                       V_MESSAGE_4
                                       V_MESSAGE_5
                                       V_MESSAGE_6.
    Send online mail with contents of message fields.
       PERFORM SEND_MAIL.

  • Data Transfer from Flat file To SAP system,

    Hi SAP Guru's,
    My query is :
    How to update Material master data by using idoc type MATMAS05 . The data is present in flat file at application server.
    I am  new to idoc area.Please provide me the sample program that how to update material master data by using standard idoc type.
    I am clear with the point that we have to read flat file from application server to internal table.
    But i got stucked at this point that how to update data from internal table data , by using standard idoc type MATMAS 05.
    I am in real need.Please provide me with the answer of this query.
    I will really appreciate your <<removed by moderator>> reply.
    Thanks
    Simran
    Edited by: Simran_SAP on Aug 25, 2010 10:46 AM
    Edited by: kishan P on Aug 25, 2010 4:36 PM

    Hi Vinod,
    Thanks for reply..
    I am new to idoc area.and my requirement is to generate the idoc after reading data from a flat file. The file is passed to the application server
    by a middleware . The SAP interface program reads the file from the application server and then starts processing the data. Please help me how to create the inbound IDoc and which FM needs to be used.
    Please provide a sample Program .
    This will really help..
    Waiting fr ur early response.
    Thanks
    Simran

Maybe you are looking for