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.

Similar Messages

  • IDOC Flat File-- XI-- IDOC

    Hi,
       I have a requirement wherein we have to read the IDOC flat file and post it as IDOC to SAP using XI. I understand we have to use the Flat File Sender adapter and the IDOC Receiver Adapter. On the Sender Side we have to define the Content Conversion to convert the IDOC Flat File to IDOC XML. Writing File Content Conversion for the IDOC Flat File would be very tedious because of the number of fields and fixed structure of the flat file.
      I have don through the following guide Section 3.2 where it talks abt converting IDOC to IDOC XML using reportRSEINB00.
    https://www.sdn.sap.com/irj/servlet/prt/portal/prtroot/com.sap.km.cm.docs/library/xi/xi-how-to-guides/how%20to%20convert%20between%20idoc%20and%20xml%20in%20xi%203.0.pdf
    I am not clear how to invoke this report in the Flat File Sender adapter. Also is there any other approach.
    Thanks
    Rajeev Gupta

    Hi Rajeev
    You have a flatfile at the sender side so you dnt  have any feasiable option to do other than FCC....FCC is not a tediuos one...if you can provide the strucutrre we will help you out...
    Check out you have a fixedlength file or piple separated one....
    In the functional design how many fields re present and buil the DT,MT MI accoprdingly.....
    you have to just use some conecnt conversion parameters that's it...
    item.fieldSeparator
    item.endSeparator
    item.fieldNames
    here item is your recordset name
    let us know your strucutre
    regards
    Nisar

  • Converting a flat file to IDOC

    Greetings to All,
    I have a requirement where i need to convert an IDOC (flat) file to IDOC.
    the idoc is SHPMNT04.Presently i am trying to implement it using FCC at the sender side as the flat file is fixed length type.
    Can any one suggest me a better method like using XSLT or Java mapping which could make my work smarter as i am Finding it very difficult to count and write the FCC for the IDOC which is have more than 60 segments.
    Any help will be greatly admired.
    Thnaks,
    Anika.

    Hi
    I am still having a doubt if this method will work on real time scenario.I mean i have to pick files
    from an 3rd party FTP location (polling and picking as and when i get a file starting with say
    ABC*.txt).Added to this there will be issue related to the volume of file(1000 per day),will that create
    any performance issues.
    It is now that you are sharing the complete scenario/ problem , just have a glance from your first post at the top & the replies, because its the problem statement that steers the discussion.
    Making the files available for the Report is a seperate task. You have to develop FTP-to-File XI scenario (or regular ftp process to send files across, which normally will not be allowed in XI server), I dont see any other way, if any, I 'assume' that it might complicate the situation.
    Performance - it is not something to do with your scenario alone, but the overall system load, configuration etc. (b.t.w 1000 is normal)
    Can we schedule a job for running the report periodically?
    Yes, scehdule a batch job calling this Report (with necessary variants) with required frequency or exact time (if there is any agreement with sender)
    I have started a POC
    I appreciate that, best way at this moment. you can reverse engineer from the errors to configure your scenario. for any reason,if you think it does not work, you can always stop and/or look for different solution.
    need your help
    - Definitely I will share my thoughts, if time permits
    how will i get the flat file xml(IDOC) in the source side
    do you mean the source structure, you can use the same structure as your target.
    once you are convinced with your solution approach, then it is better to close this thread & start a new one with new issues, for more views & suggestions and better readability.
    @Rajesh - I appreciate your efforts to solve the issue , but the below is not correct & possible, w.r.t this issue
    Here what you need is to do configure File Sender CC with NFS protocol.
    Regards
    Vishnu

  • IDOC to Flat file and Flat file to IDOC

    Hello Experts,
      I have the following requirement in my current project:
    Third Party Sender sends the data in the in the below XML format via HTTP:
    <?xml version="1.0"?>
    <fxEnvelope>
      <header>
        <message>
          <exchangeID></exchangeID>
          <messageID></messageID>
          <subject></subject>
          <payloadType>IDOC</payloadType>
        </message>
        <from>
          <orgID></orgID>
          <locationID></locationID>
          <messageID></messageID>
        </from>
        <to>
          <orgID></orgID>
          <locationID></locationID>
        </to>
      </header>
      <body>
        <Opaque>
          <DataType></DataType>
          <DataStream></DataStream>
        </Opaque>
      </body>
    </fxEnvelope>
    In the above XML, the Tag <DataStream> is a string which contains the IDOC flat file.
    Now, the scenario is HTTP to IDOC, where the sender sends the above XML payload and PI needs to convert <DataStream> to IDOC XML and pass it on to the receiver R/3.
    But the challange i am facing is converting this <DataStream> tag which contains the IDOC flat file to IDOC XML using a Mapping program.Since both adapters are running on ABAP stack i can not go for Adapter Modules available(We are using PI 7.10).
    Looking for some guidance on the same.
    Thanks in advance.
    Cheers,
    Manasa.

    There are 2 options for you
    In either case, you might need a java mapping to convert the DataStream into String. Use a file adpater to write this string to IDOC-File.
    1) Option1: Write the content of DataStream into IDOC-Flatfile.(java mapping) Pick it from PI to convert IDOC-flat file inot IDOC-XML (using std features of PI) & send it to ECC.
    2) Option2: Write the Content of DataStream to IDOC-Flatfile (accessible to ECC system). Configure WE21 to pick the file from a file port.
    If the datastream was IDOC-XML, then it would have been simpler, it will be a direct communcation from PI to ECC (using java mapping & IDOC adapter).
    Regards,
    Siva Maranani

  • IDoc flat file to IDoc

    I am receiving flat file in SFTP Server which need to be posted into SAP (No mapping involved)
    What will be the best approach ?
    1. I tried using IDOCFlatToXmlConvertor (The limitation in the format of source file. The parent and child node relationship should be explicitly mentioned in IDoc flat file which legacy system is not able to do) - Any workarounds ?
    2. I moved the Idoc flat file into SAP application server. Now need to schedule job using program RSEINB00
    3. File Content Conversion
    Any other better solution ? Appreciate your help.
    Thanks and regards,
    Jose Augastine

    For converting Idoc Flat file to idoc xml, ABAP mapping is one of the feasible option.

  • Flat File to IDOC- didn't get data into IDOC

    Hi All,
    Our scenario is Flat File to IDOC....
    working fine... didn't get any errors... IDOC also generated but didn't get any data in that IDOC....
    for details see the attachment...
    Thanks In Advance,
    vishnu.........

    Hi Rajesh,
    I am getting payload in RWB from sender Cc like below:
    <?xml version="1.0" encoding="utf-8" ?>
    - <ns:MT_File xmlns:ns="http://mouritech.com/file2idocsender"> 
    - <MT_File> 
    <Value>1</Value>  
    <Reason>test</Reason>  
    </MT_File>
    </ns:MT_File>
    If i test with this payload in mapping i am getting a pop up with this message and mapping not completed ...
    Could you please let me know what i have to do now?
    Pop Up: 
            The processing instruction target matching "[xX][mM][lL]" is not allowed.
    See error logs for details    

  • Extract to flat file or IDOC

    Does anybody know how to use BW Datasources in R3 (found in transaction RSA5) to extract data to a flat file for the purpose of loading a non-SAP data warehouse?
    The export file may be an IDoc.
    I tried RSA3, but it seems you have to specify a "target system" which is a BW system. I simply want to use the BW extractors to extract to a file.
    Thanks - I will reward points.

    Hi,
    If it is function module based extractor then you can use the copy/modify the code (copy in case you are authorized to change it). Now at the end of the extractor write an ABAP code to download the data into a flatfile using GUI_DOWNLOAD or any suitable function module. You can use this extractor fn module in an ABAP program and schedule it everyday to create the flatfile.
    If it view/table base extractor then use that in an ABAP program to create the flatfile.
    Revert if you need more info.
    You can find the type of extractor in RSO2 and also in the tabel ROOSOURCE.
    Bye
    Dinesh
    Message was edited by: Dinesh Lalchand

  • Flat file to idoc mapping issue

    Hi Gurus,
    i had a flat file format in sender side as below:
    H_ID     TYP_CODE    line_elemet      Quantity
    5896  STANDARD                       1.transmitter    1
    5896                  STANDARD       2.xxxxxxxxx           1
    5896                   STANDARD      3.yyyyyyyyy  2
    6895                  STANDARD       1.aaaaaaaaa        1
    9436                  STANDARD       1.bbbbbbbbb          4
    9436                  STANDARD       2.ggggggggg          3
    The above file need to be send to an Idoc.
    for which same header_ID values should create only one header segment, under that many a line segments should create as many line items appear on that header_id value.
    Here my query is how to suppress the repetetive header values to create onlyone header segment. And how to create as many line_item segments as the number of line items appear.
    points obvoius for the response
    Thanks in advance,
    Sekhar.

    About map problem I suggest youn to see the following link that are really helpful to improve knowledge about mapping:
    /people/sravya.talanki2/blog/2005/08/16/message-mapping-simplified--part-i
    /people/sravya.talanki2/blog/2005/12/08/message-mapping-simplified-150-part-ii
    I suggest you to see the following link to learn more about mapping:
    Mapping functionality in XI
    https://www.sdn.sap.com/irj/sdn/go/portal/prtroot/docs/library/uuid/9202d890-0201-0010-1588-adb5e89a6638
    SAP Exchange Infrastructure - Graphical_Mapping
    https://www.sdn.sap.com/irj/sdn/go/portal/prtroot/docs/library/uuid/6658bd90-0201-0010-fbb6-afe25fb398d3
    SAP Exchange Infrastructure - Graphical Mapping Exercise
    https://www.sdn.sap.com/irj/sdn/go/portal/prtroot/docs/library/uuid/fd5ebd90-0201-0010-d697-91374d5b5190
    SAP Exchange Infrastructure - Graphical Mapping - Advanced
    https://www.sdn.sap.com/irj/sdn/go/portal/prtroot/docs/library/uuid/be05e290-0201-0010-e997-b6e55f9548dd
    SAP Exchange Infrastructure: Mapping Patterns - Understand Context Handling in Message Mapping - Webinar Powerpoint
    https://www.sdn.sap.com/irj/sdn/go/portal/prtroot/docs/library/uuid/f59730fa-0901-0010-df97-c12f071f7d3b
    SAP NetWeaver Exchange Infrastructure Mapping Troubleshooting - Webinar Powerpoint
    https://www.sdn.sap.com/irj/sdn/go/portal/prtroot/docs/library/uuid/e01e9400-9e81-2910-20a5-a862945a5e98
    Mapping Lookups a RFC API
    Mapping lookups - RFC API
    XI 3.0 New Mapping Features
    https://www.sdn.sap.com/irj/sdn/go/portal/prtroot/docs/library/uuid/8a57d190-0201-0010-9e87-d8f327e1dba7
    I hope these links will be usefull.
    Regards,
    Salvatore

  • File content conversion - flat file to Idoc error

    Dear Experts,
    I have a situation where im using FCC in the sender adapter The data is in flat file with multiple fields separated by space .
    (*header444456    line4445758 header343434 line445687*) sample falt file data . should be divided as below
    header - 44456 , 343434
    *line    -  44457578 , 445687
    So i want to read the header items and pass it into header data of the IDoc and line items into line item data of the Idoc . And the header items and fields items are mixed up in the flat file . How do i read from the position 20 to 26 , 37 to 56 intermittently .And im not using any key field name . as the whole data is in one line . Any solution would be of great help .
    Thanks in advance
    Ganga
    Edited by: N.Ganga on Jan 28, 2012 3:30 PM
    Edited by: N.Ganga on Jan 28, 2012 3:30 PM

    Dear Grzegorz ,
    Yes i totally agree with you it can be separated by comma . But it is as below
    Header       - (once ).............................................. Flat file example :
         Field 1    -
    >order    line no 1   plant        material 1  code 1  quantity 1 
          .......................................................................order    line no 2   plant        material 2  code 2  quantity 2
         Field 2  (plant vlaue shuld come........................................................|
    Line          -  repeats (0-unbounded)                                      |                                     |                             |
       field 1 (line no 1)----
    |                                     |                             |
       field 2(material1)----
    |                             |
       field 3 (quant 1)----
    |
       field 1 (line no 2)----
    |                                     |                             |
       field 2(material2)----
    |                             |
       field 3 (quant 2)----
    |
    So i need to read the data intermittently and map them in the line items ignoring the order and plant data in every line apart from the first line. The order and plant remains the same in the flat file only line items keep changing .
    Hope my question is clear .
    Regards
    Ganga

  • Mapping FLAT File to Idoc

    Hi,
    I have to implement a flatfile --> XI ---> IDOC scenario and I have a question about the mapping.
    Suppose I have a Flat Fiel as following with the first 2columns as key:
    100991;001;text1;posting date
    100991;002;text2;posting date
    100992;001;text4;posting date
    100992;002;text6;posting date
    I have to pass this items to a IDOC strucutured  with header and positions.
    By mapping how can I group  key data to pass to single Idoc?
    Thanks
    marco

    Hi ,
    I have done it with ORDERS IDOC Structure .
    Since the source is a flat file you could take a simple structure with row and all the fields following it ( say filed1 , field2, field3).
    Take a bottom up approach for the child :
    Change the context of all the individual fields to the root then apply split by value on field3 ( this introduces context changes )
    Then format its parents Queue (Field2) based on Field3 Queue for this use the function Format By Example .
    Use the resulting queue  as one of the argument and Field1 to generate the link .
    Using Graphical this requirement is achievable . How ever it is upto your ease to choose which way you want to do it .
    Thanks & Regards
    Kavitha

  • Unsorted Flat File into IDoc with multiple use of nodes

    Hi Experts!
    I am facing a little problem. I have a source flat file for a classification where some fields appear several times.
    My source flat file looks like this:
    item1; field1a
    item2; fieldA
    item3; fieldxa
    item1; field1b
    as you can see the item1 exists twice (further appearances are also possible).
    Now i have to map the flat file into an IDoc structure
    My target IDoc looks like this
    Header
    -- node1
    attribute1
    -- node2
    the "field1a" and "field1b" has to be mapped into the "attribute1" in "node1". "node1" has to be duplicated for each time an "item1" appears (.. and if item2, item3 etc. appears twice, three ... four times...).
    So how can i reach it that the node1 will be duplicated automatically when an item appears twice or more times? I know that it could be possible to work with "SplitByValue"... but for this i need all item1 in an straight order.... but i dont have them in a correct order.
    I am looking forward to your suggestions.
    Thank you in advance.
    Udo

    Complex sorting is not or not easy possible with the grafical mapping tool.
    Use a sequence mapping. The first mapping is a simple XSLT which does the sort. The second mapping works as usual.
    I have an example XSLT which I used for a different purpose:
    <?xml version="1.0" encoding="UTF-8"?>
    <xsl:stylesheet version="1.0"
    xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
      <xsl:template match="/">
        <ORDERLIST>
          <xsl:for-each select="ORDERLIST/ITEM">
            <xsl:sort select="ID"/>
            <xsl:copy-of select="."/>
          </xsl:for-each>
        </ORDERLIST>
      </xsl:template>
    </xsl:stylesheet>
    Regards
    Stefan

  • Flat File and IDoc

    Hi,
      Is it possible to read a flat file and create the sale order through IDoc.  Can i do this by DOC_INBOUND_FROM_FILE without XI?? What file format should i pass??
    Regards,
    Kit

    Hi  ,
    you can create Sales order through IDoc. IDOC_INPUT_ORDERS
    At a high level, the IDOC processing executes in the following manner:
    1.     Interpret IDOC header segments and captures organizational, customer master and purchase
                   order header details. Performs user exits for each segment to process customizations to data
                     processing.
    2.     Interprets item level segments and captures item level details like material information. Again,
                   it performs user exits for each segment.
    3.     Sums up the order data and determines the posting criterion viz. creating order with reference
                      etc.
    4.     Builds up batch data communication sequence (BDC) with respect to the required screen
                  sequence of posting a sales order.
    5.     While building up the BDC data, system performs user exit to process customizations to BDC
                    data.
    6.     Calls transactions VA01 using the BDC data.
    7.     If the processing fails, an appropriate workitem is generated for workflow processing.
    if you give me brief i can help you out more.
    if helpful REWARD points
    Thank you .
    Regards
    Ramana

  • Flat file to IDOC creation

    hi all,
    I'm looking for the ABAP (sample) Program which can help me out in generating IDOC from the Flat file.
    Flat file will be residing on local PC.
    I required this for Purchase Order Confirmation Step (MSG Type ORDRSP).
    If any had done it, then let me know.
    Regards,
    S Anand

    Hi
    Sorry it is not copied properly.
    Read the data from flst file using function module GUI_UPLOAD and for each entry of internal table fille the control recor and data record and pass to function module IDOC_INBOUND_ASYNCHRONOUS to generate IDOC.
    Sample code which i have used in my report to update customer master using IDOC
    PARAMETERS:p_kunnr TYPE kna1-kunnr,
    p_zahls TYPE knb1-zahls,
    p_tlfns TYPE knb1-tlfns,
    p_intad TYPE knb1-intad.
    START-OF-SELECTION.
      PERFORM idocgeneration.
    *&      Form  idocgeneration
          IDOC Generation
    FORM idocgeneration.
      DATA:wa_knb1 TYPE knb1,
      wa_kna1 TYPE kna1,
      wa_controlrecord LIKE edi_dc40,
      wa_detailrecord  LIKE edi_dd40,
      wa_e1kna1m TYPE e1kna1m,
      wa_e1knb1m TYPE e1knb1m.
      DATA:it_controlrecord TYPE STANDARD TABLE OF edi_dc40,
      it_detailrecord  TYPE STANDARD TABLE OF edi_dd40.
      CONSTANTS: cedidc40    LIKE edi_dc40-tabnam  VALUE 'EDI_DC40',
                 cdebmas06   LIKE edi_dc40-idoctyp VALUE 'DEBMAS06',
                 czdebmas06  LIKE edi_dc40-cimtyp  VALUE 'ZZDEBMAS06',
                 cdebmas     LIKE edi_dc40-mestyp  VALUE 'DEBMAS',
                 ce1kna1m    LIKE edi_dd40-segnam  VALUE 'E1KNA1M',
                 ce1knb1m    LIKE edi_dd40-segnam  VALUE 'E1KNB1M',
                 c_2       TYPE c VALUE '2'.
    Control Record
      CLEAR: wa_controlrecord,it_controlrecord[].
      wa_controlrecord-tabnam  = cedidc40.
      wa_controlrecord-mandt   = sy-mandt.
      wa_controlrecord-direct  = c_2.
      wa_controlrecord-idoctyp = cdebmas06.
      wa_controlrecord-cimtyp  = czdebmas06.
      wa_controlrecord-mestyp  = cdebmas.
      wa_controlrecord-mesfct  = space.
      wa_controlrecord-sndpor  = 'SAPPLD'.
      wa_controlrecord-sndprt  = 'KU'.
      wa_controlrecord-sndprn  = 'A000'.
      wa_controlrecord-rcvpor  = 'SAPPLD'.
      wa_controlrecord-rcvprt  = 'KU'.
      wa_controlrecord-rcvprn  = 'A000'.
      APPEND wa_controlrecord TO it_controlrecord.
    Remove the contents in detail record internal table
      REFRESH it_detailrecord.
    Create detailed data
    Assign values to the segment fields
      CLEAR:wa_kna1,wa_e1kna1m.
      SELECT SINGLE * FROM kna1 INTO wa_kna1 WHERE kunnr = p_kunnr.
      IF sy-subrc IS INITIAL.
        MOVE-CORRESPONDING wa_kna1 TO  wa_e1kna1m.
        wa_e1kna1m-msgfn = 'INT'.
    Create the detail record
        CLEAR wa_detailrecord.
        wa_detailrecord-segnam  = ce1kna1m.
        wa_detailrecord-mandt   = sy-mandt.
        wa_detailrecord-segnum  = '000001'.
        wa_detailrecord-psgnum  = '000000'.
        wa_detailrecord-hlevel  = '01'.
        wa_detailrecord-sdata   = wa_e1kna1m.
        APPEND wa_detailrecord TO it_detailrecord.
      ENDIF.
    *assign values to the segment fields
      CLEAR:wa_knb1,wa_e1knb1m.
      SELECT SINGLE * FROM knb1 INTO wa_knb1 WHERE kunnr = p_kunnr.
      IF sy-subrc IS INITIAL.
        MOVE-CORRESPONDING wa_knb1 TO  wa_e1knb1m.
        wa_e1knb1m-msgfn = 'INT'.
        wa_e1knb1m-intad = p_intad.
        wa_e1knb1m-zahls = p_zahls.
        wa_e1knb1m-tlfns = p_tlfns.
      ENDIF.
    Add segment to the detail record
      CLEAR wa_detailrecord.
      wa_detailrecord-segnam  = ce1knb1m.
      wa_detailrecord-mandt   = sy-mandt.
      wa_detailrecord-segnum  = '000003'.
      wa_detailrecord-psgnum  = '000001'.
      wa_detailrecord-hlevel  = '02'.
      wa_detailrecord-sdata   =  wa_e1knb1m.
      APPEND wa_detailrecord TO it_detailrecord.
      CALL FUNCTION 'IDOC_INBOUND_ASYNCHRONOUS'
        TABLES
          idoc_control_rec_40 = it_controlrecord
          idoc_data_rec_40    = it_detailrecord.
      IF sy-subrc IS INITIAL.
        WRITE:/ 'Sucessfully Update'.
      ENDIF.
    ENDFORM.                    "IDOC Generation

  • Flat file to Idoc : Last line empty in payload

    Hello everyone,
    I'm trying to import Flat File from an external partner, and insert it in our SAP System as Idoc.
    It works fine, after a small change in the flat file.
    In the normal version, I have a last record with value 'OK'.
    I have add the close record.lastFielsOptional in the FCC.
    But after checking the payload, I have seen that I have at the end the following thing :
    <ns:File xlmns:ns="http://world.com/file">
    <record>
    </record>
    <record>
    </record>
    <record />
    </ns:File>
    Can someone explain me how to avoid to have this last <record/>, or checking it in mapping ?
    Thanks a lot

    Hello Greg,
    The problem is that the key in the flat file is 3 digit numeric field, and OK is 2 char.
    If I try to use the key, I have an error on the last record because we have only 2 char for the key, and when I put the parameter record.lastFiledsOptional : yes, i have no more error on the FCC, but the last record of the payload is empty.
    Have you a possibility to avoid this error.
    Thanks and regards
    JC

  • Suggesstions on flat file to IDOC

    Hi,
       Help me on following topics,
       1) What is the use of port in program RSEINB00. I want this program to read a flat file and convert it into IDOC. How does this program recognize to which IDOC format it has to convert the flat file.
       2) what is the use of file port and ABAP port when to use them. My requirement is to download a flat file or CSV flie into the customer system through FTP.Can I specify the path in the directory itself or do i need to write a seperate program for this.
      3) what is the use of function module in file port.Is it used to generate file name alone or file itself.Can we write a own function.
    Thanks & Regards,
    Kaarthik.k

    Karthik,
    You know what you could do.. To get the input file format
    First download the MATMAS IDOC or any idoc for that matter to a flat file, using the standard transaction BD10.
    Then see the format.
    As a third step upload the same file as input file with minimal changes to the data keeping the format same.
    This way you can figure out how the system is able to fetch all the configuration details.
    Hope this helps.
    Rgds,
    HR

  • Legacy flat file to IDOC into SAP

    after been given the task of converting a flat file structure to SAP idocs my research as lead me into the daunting world of CAPS. Basically I would like to know if using CAPS is the best choice for me
    and if so what is actually involved to make this happen?
    Thanks
    Michael

    hi michael,
    from my point of view "the right thing to do" would be:
    consider if this is the only task for you that is somehow EAI ish...
    if it is do not care about technology... just do it with a very simple program
    if you have to evolve choose a tool that is capeable of your systems you own: e.g. SAP AS400 .......
    in caps you would typically do this:
    setup CAPS
    write an ftp2queue component
    write a converter (custom otd + convertion logic + IDOC OTD)
    write a idoc 2 sap component via TRFC
    run ;-)
    a good starting point would be:
    http://developers.sun.com/docs/javacaps/index.jsp
    or
    http://wikis.sun.com/display/JavaCAPS/Grok+Java+CAPS
    or try to convince your boss that sun will implement it for you if you have the money to do so.
    we did that when introducing CAPS (we got it for free besides the CAPS licences of course ;-)).
    regards chris

Maybe you are looking for

  • Shaky screen freeze problem

    It starts with a little jitter and shaky screen with everthing starting to blur...Then the screen starts to darken a bit and sometimes a vertical and plaid lines appear over the entire screen...Then it freezes and a box appears that says I must resta

  • Why won't Photoshop PDF's read well on iPads?

    At first, I thought it was specifically Safari on iPad that would not display vector data (such as text) from PDF's created with Photoshop CS6. Then I installed Chrome on my iPad and got the same problem. Displays all the pixel data, but none of the

  • Impact of changing vtp server name

    Dear Sir, Please let me know as below:- 1.) How's vtp works? 2.) what's the impact chaging vtp server name? thanks.

  • Multiple Sound fade outs during slideshow on a burned DVD

    Using iDVD, I created a slideshow, from an iPhoto album. I added music from my iTunes library. I tried it on the screen, and it worked great. Then I burned my DVD, and tried it on my TV set with a DVD player connected to it. It works OK, except that

  • Floppy, CD-Rom ...

    May I direcrly work with devices like floppy disk (format) or CD-Rom (eject) on Java2 Platform.