cancel
Showing results for 
Search instead for 
Did you mean: 

PI/PO graphical mapping - UDF to group functions

ChRa
Explorer
0 Kudos

Hello

i have to map Partner data vom an IDoc to a flat file structure.

i designed the following mapping for the field AG_Nr.

the next fields are street, county, postal code, ...

Is it possilbe to bild one UDF that contains

equalS

if ... then

removeContexts?

or is it possible to build a functiongroup with those functions?

or is it possible to copy this functions from one target field to another (eg. AG_street)

Kind regards,

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

1.Just right click from remove context > Copy

2. select other target field, paste and map.

Answers (3)

Answers (3)

yeeloon-khoo
Explorer
0 Kudos

Hi Christian,

UDF suggestion, i used this UDF extensively and repeatedly in Partner_Q/Qualifier pattern to get desired value.

UDF1, in your example will be...

input1 = PARTNER_Q
input2 = "Const" or "Const;AnotherConst"

input3 = PARTNER_ID

UDF2, to get rid of the SUPPRESS and only the desired value, map to this UDF then output will be the one you want.

Reference:

0 Kudos

Hi Experts,

               I am facing below error while creating UDF please guide me.

Former Member
0 Kudos

Are you using single value ? Use Queue or Context for execution Type.

0 Kudos

Hi Kintali,

I am using multi queues, I am facing two error which was shown earlier, below is code:

String[] db_connect_string;

String[] db_user_id;

String[] db_password;

String[] storedproc_name;

String[] Value;

ResultList[] result;

try {

Class.forName("com.microsoft.sqlserver.jdbc.SQLServerDriver");

Connection con = DriverManager.getConnection(db_connect_string[0],db_user_id[0],db_password[0]);

String SQL = "EXECUTE dbo."+storedproc_name[0];

Statement stmt = con.createStatement();

  boolean results = stmt.execute(SQL);

         do {

             if(results) {

                ResultSet rs = stmt.getResultSet();

                ResultSetMetaData rsmd = rs.getMetaData();

                int numberOfColumns = rsmd.getColumnCount();

                while (rs.next()) {

                                for (int k=1;k<=numberOfColumns;k++)

{

  String Value = rs.getString(k);

       result.addValue(Value);

   }

                }

                   result.addContextChange();

                rs.close();

             }

             results = stmt.getMoreResults();

             } while(results);

           stmt.close();

      }

    catch (SQLException e)

                         {               

  

                            }

      catch (Exception e) {

    

      }

Former Member
0 Kudos

Are the variable declared part of your UDF parameters or are they declared inside your UDF ?

Looks like you have selected the execution type to "Single Values" and you are declaring result inside the UDF.

Can you paste the screenshot of your UDF singature as well ?

ChRa
Explorer
0 Kudos

Thanks guy's Copy and Paste scenario solved my problem

sugata_bagchi2
Active Contributor
0 Kudos

Christian,

you can also use a single UDF to handle this scenario -

in the UDF you need to provide two inputs - the source field from IDoc and the possible value.

inside the udf you will check the value and then produce your output. at the end you can use removecontext.

Thanks

Sugata Bagchi Majumder

iaki_vila
Active Contributor
0 Kudos

Hi Christian,

If your idea is to reuse the mapping in other message mappings, may be to use a mapping template, to wrap all the map, can be helpful for you: http://www.sdn.sap.com/irj/scn/go/portal/prtroot/docs/library/uuid/50171256-1ee2-2a10-3f84-ddecf098f...

Regards.