Friday, June 8, 2012

SRM standard Datatypes enhancements in SAP PI



Scenario: SAP SRM ->(Proxies) XI -> SOAP

Requirement: 1.New fields are to be added into SRM standard objects.
                     2. Use those fields in mapping.

steps: 1. add additional fields to standard SRM datatype, by creating new namespace as shown in below(at upper level by creating new namespace).
          2. after activate , SRM person can see these object in sproxy (t-code) section,
                  
Just create, Data type enhancement as shown in below image, 

Actually, sender message type for SRM standard object found in Basis Object, But we can not modify the direct datatype directly in that software component. as shown in image create new namespace at upper level and create datatype enhancement object as shown in below(right side)

Note:Please create a data type enhancement in a custom SWCV. Do not use the standard SWCV.
Use the standard SWCV under the dependent SWCV of the custom SWCV. Now you would be able to see your message interfaces and service interfaces under the custom SWCV


In my scenario,my actual fields are zstandard_text and zpurpose_code, But i have created Data type enhancement name RFX_DataTypeExt, under i have mentioned my objects.




Now we need to specify our actual Datatype to add these 2 fields, select tab enhanced data type, specify your standard Data type.


Above enhancement datatype tab, you can find my actual datatype.



now,see the results in message mapping, if it is properly added or not. in my case it is added properly.




Other hints:
Use SXMB_MONI t-code to see the messages at SRM side that are sent to XI and received from XI.

Debugging your inbound proxies
http://scn.sap.com/people/stefan.grube/blog/2006/07/28/xi-debug-your-inbound-abap-proxy-implementation

Message mapping test after adding fields,
http://pdpsappireference.blogspot.in/2012/06/avoid-namespace-errors-in-message.html

Michal: Datatype enhancement at xi side : using that in abap side.
http://scn.sap.com/community/pi-and-soa-middleware/blog/2006/11/14/xipi-data-type-enhancements-standard-business-partner









Tuesday, June 5, 2012

Avoid Namespace errors in XI or PI Message mapping test


Avoid namespace errors in message mapping.

In most of the cases, Sender message types has some optional fields, this means, we can get this business data some times, sometime, we can not see this filed also.

If we want to test our mapping with sample data. Which does not contain some option fields. We would like to put those and we want to test.

In mapping, test tab, if we right click on specific root node, it allows you to add some additional fields.

After adding it shows, some red colored filed , even you are sure about case-sensitive

Then observe the SRC(Source code) by clicking source code button. the problem, tool is adds some additional namespace for that field, which we can not see for already existing fields 

For existing test data,I am trying to add new field.


My below message type has full information about all fields( ex: ListOfItemReferences)


How to avoid this problem. Simple , we can find wizard icon( generate test instance), if you click on that , it allows you to enter manual test data. Now go for SRC(Source code for this), you will find all fields( mandatory and optional fields). then find your field in the source code. you can copy entire SRC into separate note pad.

Use Notepad logic : find and replace, where ever it required ex: ns0, ns1, ns2....

add business data for your field. and place in SRC and then view in graphical mode. you will not see the red colored field in  test mapping.


WIZARD ICON for Generating Test instance
After you message mapping successful. Just save your test data for future reference.

click on icon beside Wizard icon as shown in blow image 
Q) Getting strange namespace and causes failure in sxmb_moni due to that.
 Q)Not able to load runtime message in message mapping tool , because of name space. how to rectify.
Ans)   1) first check with your sender system. if they are able to send message as in (test instance of message mapping structure).
          2) if not , just find out the runtime namespace and copy the name space and paste in sender message type structure( we can see additional text box for xmlnamespace).


Now, activate the message mapping by simple change in description. and test message mapping, you can see green colored fields in graphical view.




Q) Additional message tags in message mapping( for multiple message types, 1- n, n-1,n-n)
A)  Test those message with out disturbance of these additional tags, then only mapping works.
     But, we you test integration test, put message with out those additional tags.
         Ex: 1)sender file location
                2) http client test
                3) Integration directory test tool.










Use XI development system as test system in most of the cases




End to end testing in XI/PI Development system using Dev as Quality in most of the cases.

            As everybody knows, we can test our interface using RWB http client. i.e. directly placing our request on http port.

RWB HTTP CLIENT



But it has some limitations
  1. We can not see response for synchronous interfaces in this GUI.
  2. This GUI is specific to SAP PI.
  3. Some times my SRM is sending attachments also to XI. In this we can not use RWB Http client.

What is the alternative then? My goal is, I should able to test my interface in most of the cases.

*Yes, We can use HTTP external client. The additional feature for this is,
  1. We can use this externally (i.e. independent on SAP PI software).
  2. We can use this for synchronous interfaces also.

Drawback: Some times using this external HTTP client at client environment is not recommendable.

Then What is the alternative?

*Yes, we use web-client like XML spy and SOAP UI.

As Stefan said, we can post our payload directly on integration server. We can test our interface.

Moreover, there is another advantages of using this. We can also put certain parameters in SOAP header section.

Example:


You can dynamically pass file content parameters(file) in soap envelope as shown above blog.  

So. I tried to test my scenario by using above procedure.

But it fails every time.

Why?
I have identified SOAP envelope of soap request.( in SAP PI)



Using SOAP client(soap UI)



             By Default, soap ui(web client) or IE understand any request as synchronous mode.
This the below message failed in IE.





When I am sending request from soap client(soap ui), I never mentioned quality of service information. So, By default PI IE understands quality of service as syncrouns. And there is no option, like to send request only in asynchronous mode.

For this interface, we are using multiple receivers.

Then I have modified the soap envelop in SOAP ui, simply specified specific target.(target system information)

Once again I got an error. Saying that “ invalid Soap envelope.”

I have tried all various cases. But no use.  Getting same error.

Finally, I concluded. We can not set dynamically certain mandatory parameters in soap envelope. IE always takes care about how to create soap envelope header parameters.

After reading couple forums, I have understood, we can specify mode of communication by simply appending this parameter at the end of url.

http://sapabc.xyaz.com:8001/sap/xi/engine?type=entry&version=3.0&Sender.Service=&Interface=http://sap.com/xi/SRM/Procurement/Global^PurchaseOrderRequest_Out? QualityOfService=ExactlyOnce

After adding, this context to url : QualityOfService=ExactlyOnce

This is integration engine behavior.

Finally , I understood, to test our interfaces in various cases, we need to understand the IE behavior. Authors like Stefan grube is supposed to leak this.
There is no proper documentation on IE parameters also.

Can not we test our interface, with our knowing IE behavior?

Got an idea.

Why do not we use soap channel for this. We have specific documentation also there. It helps us to configure
1)      Quality of service parameters
2)      It helps us to send attachments.
3)      Also provided some additional information,  that could be useful for various requirements.

Here the things is
1)      We need to create 2 more additional objects a) sender soap communication b) sender agreement.( we need to create these 2 only for testing).
    
 

For Testing’s. We can choose our required option based on different conditions
  1. RWB http client
  2. external http client( download existing code from sdn and save as html and use)
  3. Soap client( placing request on IE)
  4. Soap client (placing request on AE).  (
 
By considering all above options we can test our interface in most of the cases.

This helps us, 
1. to minimize the number of transports from XI development system to XI Quality.
2. avoid many errors in-front of business user.
3. Developer has confidence for his interface.

How do i get test data?
1. you can get it from user.
2. can create sample data using message mapping tool( by seeing sample data, that you have received from user)
3. take test data from quality, even it is not moved to quality(  ex: SAP ECC-> XI) messages fails in xi quality, if the transport is not moved to quality. we can take test data from this(sxmb_moni).