cancel
Showing results for 
Search instead for 
Did you mean: 

ABAP mapping along with message mapping

Former Member
0 Kudos

Hi XI gurus,

I have a requirement to remove Doctype tag from inbound CXML file before it hits message mapping. So I have created an Abap class and in execute method I am removing doctype tag from input file. This works fine when i debug this class explicitly. I have configured this abap class in operation mapping first, then message mapping. But when I send message from RWB, my class does not get hit and also message still fails since doctype tag was not deleted. When I try to test in SXI_mapping_test, it never stopped in abap class though I have placed hard break point. I have gone through blogs , but all of them speak about having only ABAP class in operation mapping. My question is can I use both abap and message mapping in same operation mapping? If not how can I achieve my requirement?

Thanks very much in advance!

Latha

Accepted Solutions (0)

Answers (3)

Answers (3)

subhro_de
Active Participant
0 Kudos

Hi Latha,

Is this the first ABAP Mapping you are using in your system have you set the property R3_ABAP|Abapclass;R3_XSLT|XSL (ABAPEngine) in Exchange profile.

In general this requirement that can be addressed using Java Mapping - something like the one below - depending on the version you are using may need a bit of modification :

package com.java.mapping;

   

    import java.io.BufferedReader;

    import java.io.InputStream;

    import java.io.InputStreamReader;

    import java.io.Reader;

    //1. AbstractTransformation class is imported.

    // The associated jar file is: com.sap.xpi.ib.mapping.lib.jar

    import com.sap.aii.mapping.api.AbstractTransformation;

    import  com.sap.aii.mapping.api.DynamicConfiguration;

    import com.sap.aii.mapping.api.DynamicConfigurationKey;

    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 Java_Mapping extends AbstractTransformation {

        public void transform(TransformationInput arg0, TransformationOutput arg1) throws StreamTransformationException {

           getTrace().addDebugMessage("JAVA Mapping Called");

        String inData = convertStreamToString(arg0.getInputPayload().getInputStream());

        DynamicConfiguration conf = arg0.getDynamicConfiguration();

        inData = inData.replace("<!DOCTYPE cXML SYSTEM \"http://xml.cXML.org/schemas/cXML/1.2.014/cXML.dtd\">","");

       

        try

        {

            arg1.getOutputPayload().getOutputStream().write(inData.getBytes());

        }

        catch(Exception exception1) {

           

        }

         }

        

        /* Converts Input stream to String */

        public String convertStreamToString(InputStream in){

        StringBuffer sb = new StringBuffer();

        try

        {

        InputStreamReader isr = new InputStreamReader(in);

        Reader reader =

        new BufferedReader(isr);

        int ch;

        while((ch = in.read()) > -1) {

            sb.append((char)ch);}

            reader.close();

        }

        catch(Exception exception) { }

        return sb.toString();

        }

    }

Regards

Subhro

Former Member
0 Kudos

Hi everyone,

Thanks very much for all valuable ideas. The reason why my abap mapping and java mapping does not work is interface is not getting determined and it is not finding the operation mapping. Did anyone encounter this problem because of doctype tag?

Any help is really appreciated!

Thanks

Latha

subhro_de
Active Participant
0 Kudos

Hi Latha,

You may want to check in the configuration wizard test in case if this is not for the doctype tag in the payload, While configuring are you selecting the operation mapping from the popup selection or providing the name writing manually in the Interface Determination part.

Regards

Subhro

Former Member
0 Kudos

Hi Subhro,

Thanks for the quick response. When I delete doctype tag and post the payload in RWB and if I  test everything works fine and the idoc gets posted fine in to ECC. Problem is only when doctype is n payload.

ALSo yes,, I have selected mapping in interface determination.

Thanks

Latha

anupam_ghosh2
Active Contributor
0 Kudos

Hi Latha,

                For removing the doctype you can check my response in this thread. In case the interface is not getting determined , try putting a condition and check if it works. Secondly did you try test configurations in ID with a sample payload with the doctype tag?

Regards

Anupam

Former Member
0 Kudos

Hi Anupam,

Thank you for the response. Yes, when I test in ID with DOCTYPE tag it errors out. When there is not DOCTYPE tag it shows Green. I have implemented java mapping and have configured in OM . When i try to execute java mapping it deletes the doctype tag correctly. Whne i send from RWB below is the reponse.

="IF_DETERMINATION">CX_ID_PLSRV</SAP:Code>


<SAP:P1>No interface determination found for outbound interface
Error while determining root
tag of XML: '<!--' or '<![CDATA[' expected
</SAP:P1>


<SAP:P2 />


<SAP:P3 />


<SAP:P4 />


<SAP:AdditionalText />


<SAP:Stack>Error when determining the inbound interface: No interface
determination found for outbound interface
Error while determining root
tag of XML: &#39;&lt;!--&#39; or &#39;&lt;![CDATA[&#39;
expected No interface determination found for outbound interface
Error while determining root
tag of XML: &#39;&lt;!--&#39; or &#39;&lt;![CDATA[&#39;
expected Error while determining root tag of XML: &#39;&lt;!--&#39;
or &#39;&lt;![CDATA[&#39; expected Error while parsing an XML
stream: &#39;&#39;&lt;!--&#39; or
&#39;&lt;![CDATA[&#39; expected&#39;.
</SAP:Stack>

OSS response says like below.
From the error
message in SXI_MONITOR, the error "Error while

determining root tag of XML: '<! ' or '<![CDATA[' expected"

is thrown by our runtime before your mapping is called in the interface

determination.



In the cache, there are more than one mapping programs found, so the

runtime tries to determine the operation name (the root tag) form the

xml, but this is not valid.
There are 2 OMs one for sending invoice to ECC and one is an acknowledgement to vendor.
I am very new to PI and any help towards the solution is really appreciated!
Thanks
Latha
subhro_de
Active Participant
0 Kudos

HI Latha ,

On the sender side service interface do you have multiple operations - is it possible to use one operation XI 3.0 compatible (selecting from drop down in sender service interface) and try this.

Regards

Subhro

iaki_vila
Active Contributor
0 Kudos

Hi Latha,

As Amit say you can do all the possible combinations inside the operation mapping.

For my experience i'd rather to use a XSL mapping to remove determinated tags or namespaces, with the abap-mapping you are doing you scenario dependent of the ABAP-stack and you should consider if your system is going to be uppgraded in the future the possibility that you would use the ICO object, more efficient, without ABAP stack or the installation 7.31 only java stack.

Regards.

Former Member
0 Kudos

Hello,

Yes, u can use combination of ABAP+Graphical mapping in ur OM, but not sure how u r writing ur ABAP code.

Having said that, removing doctype declaration is a common req and u can find lots of discussion on the same

http://scn.sap.com/thread/3184205

Thanks

Amit Srivastava

Former Member
0 Kudos
Hi Amit,  Thanks for the quick response. I have gone through the forums and have tried xslt and java mapping in operational mapping but none of them worked.  I am an abaper and hence created class and configured abap class and message mapping in operation mapping.   For both source is CXML and target is invoice idoc. If I run class in se24 it works like a charm. But from RWB I don't think it is getting hit. If you have an example of both mappings in operation mapping, can you pls send screen shots? Thanks again!
Former Member
0 Kudos

Hello,

I don't have any screenshot which shows how to call abap+graphical in single OM, but certainly it should work.

http://scn.sap.com/people/michal.krawczyk2/blog/2005/11/01/xi-xml-node-into-a-string-with-graphical-...

In addition to that, i hope you have correctly maintained the parameters under exchange profile to enable ABAP mapping? BTW u can refer below blog to test ur abap mapping locally

http://scn.sap.com/community/pi-and-soa-middleware/blog/2007/12/06/xipi-easy-abap-mapping-tests--no-...

Thanks

Amit Srivastava