Thursday, October 24, 2013

Frequent UDF codes and mapping examples are used in PI system

Calling ASMA ( Adapter specific message attributes) in mapping, after enabling check boxes in adapter level.

choose your require attributes as shown in below( FileName, direcotry).

Use formatNumber , when you expect target number always in specific/fixed format/fixed length

Mapping mutiple items from sender to receiver.  E1EDL24 occurs from sender multiple times from sender, under this-> subelement. which is quanity, we need to check if the quanity more than one or not, we need to create target item's, whose items has quanity more than zero.

Substring from start index to Given number

In case, if you want to use multiple conditions, replace those multiple conditions with help fix-values standard function in-front of standard functions.

Dynamic configuration or variable substitution or Dynamic configuration Bean?

SAP Help: how to use Message mapping and advanced mapping techniques

Very userfull mapping logics from stefangrube blog

Use one as many with example:

SAP Help Messages-mapping examples

UseOneAsMany for converting deep structure to Falt structure

sender(header, items)->receiver(flat structure, items(merging header information))

Below example: Each person has many telephone numbers, sender person table maintains id's name's, 2nd table, only for id's and telephone,    For target, we need to put data based on telephone.(need to repeat id,name by telephone number)

Logic explanation: 
id, Name array length is same(1st table),we need to fetch person name by using person id(need to compare with id in 2nd table),

First using HashMap-> create mapping table for personId,TelephoneNumber;  for every value from 2nd table (personID)

By willian LI

Graphical variables, parametrized mapping, graphical looks, structural inconsistency, Functional libraries, importing structure from database.

stefangrube frequently used mapping functions:

Examples on MapwithDefault,  FormatByExample, sort, sortByKey, Index

Stefangrub's examples: suppress logic

Supress values in array:

SubString examples, Using indexOf

idoc 2 flatfile ( mapping scenarios)
picking when qualifier has xyz values, then ping another element at same level( some times this has empty, need to replace with empty)

Take IDTNR ,when qualifer =010; some times IDTNR has null values, in that case use empty field to map target filed
Handling Null values from source, replacing those with empty value,
MapwithDefault node function( its draw back, It is not properly working when source filed context is at upper level. So we need to maintain the context as it is, use mapwithdefault function as shown below
Format by examples helps to gets its previous context level

Substring for last N digitis

/* var1=var1.trim();
int Strlength =var1.length();
char  a;
boolean b;
 a = var1.charAt(Strlength-1);
 b = Character.isLetterOrDigit(a); 
return var1.substring(0,Strlength-1);
return var1;
return var1; */

Frequent sap examples on mapping.

split string and integer

public class HelloWorld{

     public static void main(String []args){
         int j =0;
         String s = "xyz123";
for(int i = 0; i < s.length(); i++)
   char c = s.charAt(i);j=i;
       // System.out.println("Hello digit"+c);
      //  else
    //     System.out.println("Hello char"+c);
     //end if
}// end for


Useful information From other blogs
copyXML( no need of sub elements in structure) and structure inconsistancy and graphical variables usage(avoid global variables)

Creating Database structure from communication channel (no need of creation of target element)

Handling fault messages in RFC response , which are arrived from soap fault messages or rest.