none
.net biztalk communication sap RRS feed

  • Question

  • Hi All,

    I am trying to  connect .net using biztalk with sap on hp ux.

    I have found the  tutorial http://msdn.microsoft.com/en-us/library/cc185473.aspx

    To install the RFC
    1. Copy files from the computer running the adapters to the SAP application server.

      1. Log in as the SAP R/3 system administrator to the SAP application server of your development system.
      2. Copy the transport file with the naming pattern K9*.BI1 from the installation directory on the computer running the adapters to the following directory on the SAP application server:
        <drive>:\usr\sap\trans\cofiles
      3. Copy the transport file with the naming pattern R9*.BI1 from the installation directory on the computer running the adapters to the following directory on the SAP application server:
        <drive>:\usr\sap\trans\data
    2. Load the transport into the transport buffer on the SAP application server

      1. At the command prompt, navigate to the transport program directory on the SAP application server:
        <drive>:\usr\sap\trans\bin
      2. To load the transport into the transport buffer, execute the following command at the \usr\sap\trans\bin directory and replace sysid with the system ID of your development system:
        tp addtobuffer <TransportNumber> <sysid> pf=TP_DOMAIN_<sysid>.PFL
        where TransportNumber is the actual transport number (for example BI1K900201).
      3. After the tp command finishes, you will see a report similar to the following:
        This is tp version 320.56.66 (release 620)
        Addtobuffer successful for TransportNumber
        tp finished with return code: 0
        Return code "0" means that everything is OK.
        A return code of 0 or 4 is acceptable. Contact Microsoft Customer Service and Support, if you receive a return code of 8 or above.
        Note
        You can easily derive the actual transport number from the cofile file name. For example, a cofile named K900201.BI1 provides a transport number of BI1K900201.

    3. Import the transport into SAP.

      1. Execute the following command at the command prompt:
        tp import <TransportNumber> <sysid> client=clientnumber pf=TP_DOMAIN_<sysid>.PFL
        Replace sysid with the system ID of your development system. Replace clientnumber with the client number of your development system.
        You can use the U2 parameter to overwrite previously installed objects, as follows:
        tp import <TransportNumber> <sysid> client=<clientnumber> U2
        - OR -
        tp import <TransportNumber> <sysid> client=<clientnumber> pf=TP_DOMAIN_<sysid>.PFL U2
        Note
        You can easily derive the actual transport number from the cofile file name. For example, a cofile named K900201.BI1 provides a transport number of BI1K900201.

      2. After the tp command finishes, you will see a report similar to the following:
        This is tp version 320.56.66 (release 620)
        This is R3trans.exe version 6.08 (release 620 - 04.02.03 - 14:54:00).
        R3trans.exe finished (0000).
        This is R3trans.exe version 6.08 (release 620 - 04.02.03 - 14:54:00).
        R3trans.exe finished (0000).
        tp finished with return code: 0
        Return code "0" means that everything is OK.


    I get the return code 4

    I did 

    tp addtobuffer BI1K900503 SVI pf=TP_DOMAIN_SVI.PFL

    tp import BI1K900503 SVI client=200 pf=TP_DOMAIN_SVI.PFL

    seems ok then I try to compile the project in .net using this library


    using Microsoft.Data.SAPClient;



    PROGRAM

    using System;
    using System.Text;
    using Microsoft.Data.SAPClient;
    using System.Data;
    using System.Xml;
    using System.IO;

    namespace SAPDataProviderTest
    {
        public class SapSample1
        {
            //Replace "YourSAPHost", "YourUserName", "YourPassword" appropriately
           
            static string connstr = "TYPE=A; ASHOST=192.168.0.62; SYSNR=10; CLIENT=200; LANG=EN; USER=usr; PASSWD=pwd;";
           
            public static void Main()
            {
               

                //Sample Code for selecting records from SAP tables with
                //join condition on two tables and where condition is
                //specified through SAP parameter.
                SelectSample1();

                //Sample code for executing RFC with named parameters
                //for simple and complex parameters
                ExecSample1();
                Console.WriteLine("Press any key to exit");
                Console.ReadLine();
            }

          

            /// <summary>
            /// select top 1 * from sflight inner join spfli on sflight.connid = spfli.connid where spfli.connid = @connid
            /// </summary>
            static void SelectSample1()
            {
                try
                {
                    using (SAPConnection conn = new SAPConnection(connstr))
                    {
                        conn.Open();
                        using (SAPCommand cmd = conn.CreateCommand())
                        {
                            cmd.CommandText = "select top 1 * from sflight inner join spfli on sflight.connid = spfli.connid where spfli.connid = @connid";
                            cmd.Parameters.Add(new SAPParameter("@connid", 17));
                            //cmd.CommandText = " select KUNNR  from KNA1 ";
                            cmd.ExecuteReader();
                           
                           
                            using (SAPDataReader dr = cmd.ExecuteReader()) // HERE THE ERROR on runtime
                            {

                                do
                                {
                                    int rows = 0;
                                    while (dr.Read())
                                    {
                                        rows++;
                                        StringBuilder b = new StringBuilder();
                                        for (int i = 0; i < dr.FieldCount; i++)
                                        {
                                            b.Append(drIdea.ToString() + " ");
                                        }
                                        Console.WriteLine("row {0}: {1} ", rows, b.ToString());
                                    }
                                    Console.WriteLine("Number of rows:{0}", rows);

                                } while (dr.NextResult());
                            }
                        }
                    }
                }
                catch (Exception e)
                {
                    Console.WriteLine("Select sample failed with exception: {0}", e);
                }
            }

            /// <summary>
            /// exec rfc_read_table @query_table='KNA1', @rowcount=2, @FIELDS= '<FIELDS> <RFC_DB_FLD xmlns=\"http://Microsoft.LobServices.Sap/2007/03/Types/Rfc/\"><FIELDNAME>KUNNR</FIELDNAME></RFC_DB_FLD> </FIELDS>', @DATA = @outResultData output
            /// </summary>
            static void ExecSample1()
            {
                try
                {
                    using (SAPConnection conn = new SAPConnection(connstr))
                    {
                        conn.Open();
                        using (SAPCommand cmd = conn.CreateCommand())
                        {
                            cmd.CommandText = "exec rfc_read_table @query_table='KNA1', @rowcount=2, @FIELDS= '<FIELDS> <RFC_DB_FLD xmlns=\"http://Microsoft.LobServices.Sap/2007/03/Types/Rfc/\"><FIELDNAME>KUNNR</FIELDNAME></RFC_DB_FLD> </FIELDS>', @DATA = @outResultData output";
                            SAPParameter param = new SAPParameter("@outResultData", ParameterDirection.InputOutput);
                            cmd.Parameters.Add(param);
                            SAPDataReader rdr = cmd.ExecuteReader();
                            DataTable dtResult = (DataTable)cmd.Parameters["@outResultData"].Value;
                            foreach (DataRow row in dtResult.Rows)
                            {
                                object[] data = row.ItemArray;
                                for (int i = 0; i < data.Length; i++)
                                {
                                    Console.Write(" {0} ", dataIdea.ToString());
                                }
                                Console.Write("\n");
                            }
                        }
                    }
                }
                catch (Exception e)
                {
                    Console.WriteLine("Exec sample failed with exception: {0}", e);
                }

            }

        }
    }


    Now I use the framework 3.5 on windows xpsp2 then when I try to run the program  I get the error when it try to execute the reader

    what it says is that that there is "no permission on  sflight" 


    what I  tryied to do is change the  string sql but the error is the same then I suppose is not a problem of permission on single table but other kind of permission on sap


    probably is here the problem

    Setting User Authorization

    The Z_EXTRACT_DATA_OO RFC requires user IDs with specific authorization objects. Use the SAP GUI authorization administration tools to set the minimum restrictions on the execution of the RFC:

    Z_EXTRACT_DATA_OO requires both S_TABU_DIS and Z_EIP_TABL. The following values provide the minimum restrictions for S_TABU_DIS, which allow users to view metadata for any table in the system.
    ACTVT: 03
    DICBERCLS: *
    You can use DICBERCLS to restrict authorization to tables by authorization class.
    You can use the TDDAT table to view the authorization class for tables.
    Note
    To prevent changes to tables by table maintenance transactions, you should only grant display privileges in a production environment (ACTVT: 03 sets the permissible activity to display).

    The minimum values for Z_EIP_TABL are:
    ACTVT: 03
    TABLE: *
    You can use TABLE to explicitly define the authorized tables. Note, too, that S_TABU_DIS is also used in other transactions.


    I dont know how to set it pls help

    cheers
    Thursday, November 13, 2008 8:47 AM

Answers


  • Go to T-code PFCG
    Create a role with the name ZTEST (Name can be anything), click on the create button and save it.
    Click on the Tab “Authorization”
    Click on “Change Authorization Data”
    IF any popup comes, select “Do not Select Templates”.
    In change role: Authorization screen, click on the tool button “manually”
    In”Manual selection of authorizations”, please enter the authorization object “Z_EIP_TABL” and click enter.
    Provide value 03 for Activity and * for Table name
    Click on the Save button and generate the profile. Go back to “Change role” screen.
    By selecting the tab “User”, you can assign the user id, after entering the User ID, click on the button “User Comparison”,  popup window will be displayed on the screen, in that screen please select the button “Complete Comparison”, that will update the user master record.
    Save and exit, you are done.

     

    Tuesday, November 18, 2008 7:34 AM

All replies

  •  

    Are you able to read the table through SAP GUI? Can you try to use SE16 command to view the table?
    Friday, November 14, 2008 10:22 AM
  • Hi Abhinavp I have tried to connect  using sap gui with the same user on the gui and trying the se16 command I  did not receive any error seems a permission problem on the rfc installed is there some way to put the privilege on the biztalk adaptar
    on the object that
    the tutorial say

    Setting User Authorization

    The Z_EXTRACT_DATA_OO RFC requires user IDs with specific authorization objects. Use the SAP GUI authorization administration tools to set the minimum restrictions on the execution of the RFC:

    Z_EXTRACT_DATA_OO requires both S_TABU_DIS and Z_EIP_TABL. The following values provide the minimum restrictions for S_TABU_DIS, which allow users to view metadata for any table in the system.
    ACTVT: 03
    DICBERCLS: *
    You can use DICBERCLS to restrict authorization to tables by authorization class.
    You can use the TDDAT table to view the authorization class for tables.

    Note
    To prevent changes to tables by table maintenance transactions, you should only grant display privileges in a production environment (ACTVT: 03 sets the permissible activity to display).
    The minimum values for Z_EIP_TABL are:
    ACTVT: 03
    TABLE: *
    You can use TABLE to explicitly define the authorized tables. Note, too, that S_TABU_DIS is also used in other transactions.


    but I dont know how to set it pls help

    especially on this table
    Z_EIP_TABL

    cheers

    Friday, November 14, 2008 11:10 AM

  • Go to T-code PFCG
    Create a role with the name ZTEST (Name can be anything), click on the create button and save it.
    Click on the Tab “Authorization”
    Click on “Change Authorization Data”
    IF any popup comes, select “Do not Select Templates”.
    In change role: Authorization screen, click on the tool button “manually”
    In”Manual selection of authorizations”, please enter the authorization object “Z_EIP_TABL” and click enter.
    Provide value 03 for Activity and * for Table name
    Click on the Save button and generate the profile. Go back to “Change role” screen.
    By selecting the tab “User”, you can assign the user id, after entering the User ID, click on the button “User Comparison”,  popup window will be displayed on the screen, in that screen please select the button “Complete Comparison”, that will update the user master record.
    Save and exit, you are done.

     

    Tuesday, November 18, 2008 7:34 AM
  • Hi Abhinavp thank you very much for your help the problem it was just the problem of authorization
    I have created the role like you have suggested and I gave the authorization on that object and the problem went away..
    cheers

    Tuesday, November 18, 2008 9:54 AM