Add Namespce and message type to incoming file

Hi Experts,
I have a file to Idoc scenario where my input file comes without a name space message type like this
<?xml version="1.0" encoding="UTF-8"?>
<Header>
    <Field>
      <FieldSeparator/>
      <EncodingCharacters/>
      <SendingApplication/>
</Field>
     In PI I have created the data type in a particular namespace and the message type, so when this file is polled for at the source folder, it fails in the moni
any idea on how to proceed ??
Regards,
Teja

Hi Ravi,
You can do it with a simple JAVA mapping.
You need to add this Java Mapping in Operation mapping Before your actual graphical mapping.
INPUT:
<?xml version="1.0" encoding="UTF-8"?>
<Header>
<Field>
<FieldSeparator/>
<EncodingCharacters/>
<SendingApplication/>
</Field>
</Header>
OUTPUT:
<?xml version="1.0" encoding="UTF-8"?>
<ns0:MessageType xmlns:ns0="urn:sap.com:test:mapping:java">
<Header>
<Field>
<FieldSeparator/>
<EncodingCharacters/>
<SendingApplication/>
</Field>
</Header>
</ns0:MessageType>
Please find the Java code.
package addMessageTypeAndNamespace;
import java.io.BufferedInputStream;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
//1. AbstractTransformation class is imported.
import com.sap.aii.mapping.api.AbstractTransformation;
import com.sap.aii.mapping.api.InputAttachments;
import com.sap.aii.mapping.api.InputParameters;
import com.sap.aii.mapping.api.InputPayload;
import com.sap.aii.mapping.api.OutputAttachments;
import com.sap.aii.mapping.api.OutputHeader;
import com.sap.aii.mapping.api.OutputParameters;
import com.sap.aii.mapping.api.OutputPayload;
import com.sap.aii.mapping.api.StreamTransformationException;
import com.sap.aii.mapping.api.TransformationInput;
import com.sap.aii.mapping.api.TransformationOutput;
import com.sap.aii.mapping.api.InputHeader;
public class addMessageTypeAndNamespace extends AbstractTransformation{
     public void transform(TransformationInput arg0, TransformationOutput arg1) throws StreamTransformationException
          try {
               String strinput=readInputStreamAsString(arg0.getInputPayload().getInputStream());
               String withoutXmlDeclaration=strinput.substring(39, strinput.length());
               String XmlDeclaration=strinput.substring(0, 38);
               strinput=XmlDeclaration+"<ns0:MessageType xmlns:ns0=\"urn:sap.com:test:mapping:java\">"+withoutXmlDeclaration+"</ns0:MessageType>";
               arg1.getOutputPayload().getOutputStream().write(strinput.getBytes("UTF-8"));
          } catch (IOException e) {
               // TODO Auto-generated catch block
               e.printStackTrace();
          catch (NullPointerException e) {
               // TODO Auto-generated catch block
               e.printStackTrace();
               getTrace().addInfo(e.getMessage());
public static String readInputStreamAsString(InputStream in)      throws IOException
     BufferedInputStream bis = new BufferedInputStream(in);
     ByteArrayOutputStream buf = new ByteArrayOutputStream();
     int result = bis.read();  
     while(result != -1)
          byte b = (byte)result;  
          buf.write(b);    
          result = bis.read(); 
     return buf.toString();

Similar Messages

  • EDI 821 and EDI 823 field mapping file and basic IDOC type and message type

    Hi All,
    We are facing some issues regarding EDI 821 and EDI 823 file mappings.
    We are mapping EDI 821 and EDI 823 transactions into SAP using IDOCs. Currently we are using the below entries
    EDI 823 - Lock Box
    Basic IDOC type - FINSTA01
    Message type - FINSTA
    Process Code  - FINS
    The problem is we are able to get the IDOC into SAP with status red and the various errors were due to not able to create the lockbox entry in SAP and once we got yellow status also but the lock box entry was not created and the errors are like No Conversions,no header etc.
    EDI 821 -
    Basic IDOC type - PEXR2002
    Message type - PAYEXT OR REMADV
    Process Code  - PEXC OR REMA
    We are facing the same problem here also and the internal payment order is not creating in SAP and IDOC was generated with yellow status and red status.
    We are trying different combinations but nothing is working so far.
    I need the following things to proceed furthur.
    1)Are the IDOC , Message and process codes are correct that I am using now for both EDI 821 and EDI 823
    2)If those are not correct, can you please let me know the correct entries
    3) Please provide me the field mapping if any one of you have worked earlier for both the above IDOC and message type or new ones and we have one field mapping now but if you can send it to me then  I can re check it.
    4) Do we have to create any configuraion or customizing in SAP to create the IDOC in green status and if so please let me know the customizing steps and procedures for both EDI 821 and EDI 823.
    thanks in advance for all your help.
    Please let me know if my question is not clear.
    Thanks,
    Ramesh.

    Hi Ramesh,
    I believe you are using those interfaces with the business partner type as Bank, Whatever idoc type, message type and process code you have used are perfectly correct.
    First of all did you enable your bank for EDI, the house bank has to be EDI enabled first then only your idoc's can be processed, talk to your fi functional consultant and he might help you.
    Are you can give me the exact error and i can help you as well.
    Thanks,
    Mahesh.

  • Where can I get the realtion  between Tcode ,idoctype and message type??

    Hello ,
    I would like to know the relation between Transaction code,idoc type and Message type.
    In which table I can find or which Transatcion I can get all these information..?
    Relation with Transaction code is must where can i find....??
    Please help me in this....
    Thanks in Advance
    Regards
    Preethi

    Hello ,
        It was very helpful answer.....
        But I want the relation with Transaction code....How can I find the realtion between Tcode and Idoc type or Tcode and message type...??
    Please let me know this...
    Thanks in advance..
    Regards
    Preethi

  • Idoc types and message types

    Hi ,
    Anyone can send what are all the std idoc types and message types are there in SAP?
    Coz i dnt have SAP.
    Please let me know

    The IDoc type indicates the SAP format that is to be used to interpret the data of a business transaction.
    An IDoc type consists of the following components:
    ·       a control record
    This is identical for each IDoc type.
    ·       several data records
    One data record consists of a fixed key part and a variable data part. The data part is interpreted using segments, which differ depending on the IDoc type selected.
    ·       several status records
    These are identical for each IDoc type and describe the statuses an IDoc has already passed through or the status an IDoc has attained.
    You find various IDOC / Message types in SAP -
    http://www.erpgenie.com/sapedi/message_types_masterdata.htm
    IDoc Types - Message Types -Accounting Business Processes
    IDoc Types - Message Types - HR Business Processes
    IDoc Types - Message Types - Logistics Business Processes
    Eg.
    General       Message types / IDoc types / BAPI
    Vendor        CREMAS / CREMAS02
    Customer      DEBMAS / DEBMAS03
    Accounting   Message types / IDoc types / BAPI
    G/L account   GLMAST / GLMAST01
    Cost center     COSMAS / COSMAS01
    Cost element  COELEM / COELEM01

  • Diff bet IDOC and Message Types.

    What are the difference between IDOC and Message types.
    Diff between MATMAS01 ,MATMAS02 and MATMAS03

    IDOCs:
    - IDOC is an Intermediate Document. It is simply a data container used to exchange information between any two processes  that can understand the syntax and semantics of the data.
    An IDOC is created as a result of executing an Outbound ALE or EDI process.
    In an inbound ALE or EDI process, an IDOC serves as input to create an application document. When an IDOC is created in the system , an unique number(16 Digits) is assigned to it.IDOC will wait until the Remote System is Active.
    Basic Idoc Type: Basic Idoc type defines the structure and format of the business document
    that is to be exchanged between  two systems. Basic Idoc type can refer to an SAP provided
    basic IDOC type or a customer developed basic IDOC type.
    - A basic IDOC type has the following characteristics:
    Name : A basic Idoc type can be assigned upto a thirty character name.
    List of permitted segments: The segments make up the IDOC structure.
    Hierarchy of segments : The hierarchy of segments specifies the physical sequence and any parent - child relationship in the segments.
    Mandatory Vs Optional Segments : When used in the IDOC type, each segment has an attribute that defines whether the segment  is option or mandatory. Minimum/Maximum range for each segment: It defines the maximum and minimum number of timesa data record corresponding to a segment cn exist in an IDOC.
    -Segments : A segment defines the format and structure of a data record. Segments are reusable componets. A segment consists of various fields that represent data in data record.
    IDOC Record Types:
    1. Control Record : The control record contains all of the control information about an IDOC, this information basically includes the IDOC number, sender and receiver information, and information such as the message type it represents and the IDOC type. 
    - there is only one control record per IDOC.
    - The stucture of the control record is the same for all the IDOCs and is defined by SAP.
    - The structure of the control record is defined by the data dictionary structure EDI_DC40. The control record is stored in the EDIDC table.
    2. Data Record : Data records contain the application data. A data record has two sections
    Administrative Section and a Data section.
    - The Administrative section cotain the segment name, client, IDOC number, segment number, hierarchy level information.
    - The Data section of a data record is a stram of 1000 bytes where the actual data resides.
    - The data record is defined by the data dictionary structure EDI_DD40.
    - Data records for IDOCs stored in the EDID4 table.
    3. Status Record : Status records are attaced to an IDOC throughout the process as the IDOC achieves different milestones or encounters an error. At every milestone a statu code, date and time are assigned.
    - Status codes 01 to 49 are reserved for OUtbound process, 50 and above are reserved for inbound processes.
    <u><b>IDOC TYPE IS AN INSTANCE OF IDOC</b></u>
    Message Type: Identifies what type of information transformed between logical systems or partners.Message type is not   a   local object type , it is transportable.
    For different applicatons we have different MESSAGETYPE.
    example:
    <u>APPLICATION</u>                <u>  MESSAGETYPE</u>
    MATERIAL MASTER                       MATMAS
    VENDOR MASTER                          CREMAS
    CUSTOMER MASTER                      DEBMAS
    MATMAS01, MATMAS02, MATMAS03, MATMAS04, MATMAS05 are all MESSAGETYPES  ... FOR NEW VERSIONS LIKE SAP 4.7EE, SAP ECC5.0....we have to use MATMAS05 message type. for older versions like SAP R/3 we have to use MATMAS01.
    REWARD ME IF THIS IS HELPFUL

  • Process code or Fmodule  for Idoc type PREQCR101 and message type PREQCR1

    hi all,
           Iam unable to find the process code or function module for the idoc type PREQCR101 and message type PREQCR1 for inbound process.
    help from some one would be a lot appretiated.

    Hi,
    Go to transaction WE57 and you can find the processing FM and message type that are associcated to the IDOC type.
    For process code if it is Inbound check WE42 and outbound check WE41 transactions
    Regards
    Shiva

  • Which IDoc Type and Message Type to use for Credit Memo?

    Could you guys please tell me which IDoc type and Message Type to use for Credit Memo? Also if possible tell me the process code/ function module.
    Will certainly give points for right answer. Thank you for reading.

    Hi,
    You can use IDoc type FIDCCP02 with message type FIDCC1/FIDCC2 for Credit Memo.
    Also you can use this FM FI_IDOC_CREATE_FIDCC1/
    FI_IDOC_CREATE_FIDCC2 to generate the IDoc.
    Regards,
    Ferry Lianto

  • How to find a realtion between Tcode ,Idoctype and message type

    Hello ,
       I would like to know the relation between Transaction code,idoc type and Message type.
    In which table I can find or which Transatcion I can get all these information..?
    Please help me in this....
    Thanks in Advance
    Regards
    Preethi

    Hello Anji,
       I want the relation with Transaction code....Could you please tell me....
    Thanks in advance
    Regards
    Preethi

  • ISU Billing/Invoicing IDOCS and Message Type

    Hi,
    Could any body provide me the list of IDOCS and Message types for Billing and Invocing Module. I was unable find the list across web.

    To get the idoc list , u should go to the transaction WE02, and give the search parameter as the  basic type of the above said message types..

  • Difference Between Data type and message type

    Hi,
        i have doubt on data type and message type.why we are mapping the message type why not data type?wht is the difference between data type and message type?

    Hi Narayanana,
    Data type defines the structure of your xml message.Message type is the wrapper of data type.You will be using your message type while mapping and not the data type.Its the abstraction concept used in oops
    kanan thiyam  
    Posts: 28
    Questions: 7
    Registered: 1/8/07
    Forum points: 24 
       Re: What is deffernce b/w Data type and message type  
    Posted: Jun 13, 2007 8:05 AM    in response to: suresh k         Reply      E-mail this post 
    Hi Suresh,
    Data Type defines the structure of the message and it will be wrapped under Message Type.
    Hope the details below will clearify your doubts.
    A data type in a programming language is a set of data with values having predefined characteristics. Examples of data types are: integer, floating point unit number, character, string, and pointer.
    The characteristic of columns and variables that defines what types of data values they can store.
    Check out the details:
    http://en.wikipedia.org/wiki/Data_type
    A message type comprises a data type that describes the structure of a message. At the following points in SAP Exchange Infrastructure you can refer to the message to be exchanged at runtime by using the message type:
    Details:
    http://help.sap.com/saphelp_nw04/helpdata/en/2d/c0633c3a892251e10000000a114084/content.htm
    kanan

  • Difference between IDOC Type and Message Type

    Hi, please let me know the difference between IDOC type and Message Type?
    Thanks

    Hi,
    Message type is business name for IDOC you are sending hiding all technical details of the IDOC.
    IDOC type gives more technical information about structure of the IDOC.
    You will be linking IDOC type to message type while processing IDOC in runtime.  You will be specifying message type and IDOC type in WE20 trasaction which says which message will go to which partner whether it is outbound or inbound.
    Best Regards,
    Krishna

  • Idoc type and message type for Planned Independent Requirement (PIR)

    Hi
    Can anyone please give me the information on the idoc type and message type for Planned Independent Requirement(PIR)?
    And also the prerequisites to use them.
    Regards,
    Lohitha
    Moderator message: please do more research before asking, show what you have done yourself when asking.
    Edited by: Thomas Zloch on May 23, 2011 10:45 AM

    Hi,
    You can use IDoc type WMMBID02 with message type WMMBXY.
    Also please check test program RLMBXY00 to simulate IDoc WMMBID02.
    Regards,
    Ferry Lianto

  • Basic type and message type

    hi,
    may i know what is the difference between basic type and message type in WE05.
    thanks

    Hi,
    This is similar  as Subject of a mail and content of the mail..
    Without seeing the contect if the give appropriate subject we will know what was the mail regarding.
    the same thing applies to IDOC also.
    Regards,
    Nagaraj

  • Idoc type and message type for inventory

    Hi All
    What is the idoc type and message type for inventory adjustments? Thanks for any help
    Thanks
    Ricky

    Hi,
    You can use IDoc type WMMBID02 with message type WMMBXY.
    Also please check test program RLMBXY00 to simulate IDoc WMMBID02.
    Regards,
    Ferry Lianto

  • Resources for designing data types and message types

    Hi
    I wanted to know if anyone can recommend me some good resources which can explain the design considerations for designing data types and message types in XI which can help promote reusability.
    Thanks.
    Best Regards,
    Kiran

    hi,
    there no rare rule whe you define your data type, why i tell you this, because you define a data type since the documentation that sender sistem team gives to you. so you only have to copy this structure to PI.
    now about Message Type less problems, because, you a Data type is assign to a Message Type, whats it means.
    when you define a DATA type you are defining the structure of you XML, que you assing the data type to a message type this structure pass to be an xml document.
    Thanks you
    Rodrigo

Maybe you are looking for

  • IE7 & CSS Opacity

    I'm curious if any experts out there have had any experience with this. I have tried using the following in my CSS document: opacity:.4; //For Everything Else filter:alpha(opacity=40); //I thought this would do the trick for IE And despite that code

  • Docking station for iPhone?

    I've been trying to find one, but I can't. Regular docking stations for iPods don't work. Any advice?

  • Thousands of photo duplicates

    Help! I am a new Mac/iPhoto user and am swimming in duplicates of photos, due to indiscriminate dowloading of several backup CDs. Trouble is, I have loaded over 3000 photos into library, and am now stuck because I can't get rid of duplicates without

  • After upgrading to Lion from Snow Leopard, mail server does not receive incoming email

    After upgrading my server last night [2011.07.20] from Snow Leopard to Lion, my mail server settings went belly up.  After toying around with the server, its certificates and what-not, I was able to get it running, but it is no longer receiving any e

  • JDE media object in CR

    Post Author: Carl Cooper CA Forum: Crystal Reports Using CR to design reports from JD Edwards Enterprise 1 on Oracle DB. Connecting to Edwards via Oracle tools. We have created reports but want to include media objects from JDE in report. Have seen s