Things hard and not so hard.... RSS 2.0
# Sunday, May 23, 2010

As you know I’m a big fan of Virtual Box being able to run my x64 VMs on my Win7 machine. Yay!!

So armed with my trusted new Core i7/8 GB laptop – I figured the VMs will be cooking on this new kit…

After installing the lastest VirtualBox (3.2.0) I was away – only to notice the machines were running like a SLUG! (I actually have a cat that has the nick name ‘slug’ and this machine was slower than her)

After waiting a full 20mins (still booting - ‘loading windows files…’ etc) my machine Blue Screened for a millisecond and then rebooted.

So I rolled up my sleeves and started digging – could be the VHD, the bios, the machine, the 1000 and 1 settings…

Firstly I ran a command line command (from under the vbox install dir) -
VBoxManage setextradata VMNAME "VBoxInternal/PDM/HaltOnReset" 1

Finally I got a glimpse of the BSOD and it was an error “…STOP…7B…”

I twigged this is an error of “Inaccessible boot device….” which I’ve had several times when the SATA drivers couldn’t be loaded by the O/S during boot up.

Solution: (in my case)
I configured the Virtual Box VM with IDE Storage Controllers and NOT SATA ones for the bootup.(still connected to the same VHDs though)

Win2008/R2 boots up and I’m able to load the SATA drivers in and we’re away.

Back to BizTalk 2010 Beta playing…. :)

Sunday, May 23, 2010 9:53:47 PM (AUS Eastern Standard Time, UTC+10:00)  #    Comments [2] -
BizTalk | 2010 | Tips
# Wednesday, May 12, 2010

Wow! I'm finally through the other side... what a quest and I thought I'd share some of the details with you.

RFC_READ_TABLE rfc can be used to call into SAP and retrieve table data - *sort of* (and that's a big sort of) like a 'DataSet'.

Using it requires a little work and understanding.

In your either BizTalk project or other project from VS.NET:

  1. Add the SAP bits to your VS.NET project - ready for action
    1. select 'Add Adapter Service Reference' (for BTS projects -> Add New Generated Item->Consume Service Adapter...)
    2. On the Binding Wizard Screen select sapBinding and configure the appropriate connection string details such as:

      string sapUri = "sap://CLIENT=800;LANG=EN;@A/sapsrv/00?GWHOST=sapsrv&GWSERV=sapgw00&RfcSdkTrace=true";
      <You need to stick your own sapURI above - that is more or less a sample>

    3. Click on the Connect and under RFC->OTHER , select RFC_READ_TABLE (or you can type it in the box to search)
    4. Click Ok to generate the proxy and other details.
    5. Either your BizTalk Project or your non-BTS project has now all the relevant details to communicate to SAP.

      I tend to build out all this functionality first in a Console App just so I know what is needed within the BTS environment, also I find it much quicker to test/debug etc. here.
  2. Ok - onto the code. I've got 2 routines for you, one that uses the Proxy Classes built by the wizard in the last step, and a routine from 'first principles'.

    One of the things that I really like about the BTS Adapter Pack and certainly in this case, is that depending on the shape of the XML you pass to the adapter, it determines the table and type of operation that it is to do.

    Both of these examples below you could wrap into a functoid/helper/whatever and use directly from code.
  3. Proxy Code - version 1 - here I define some parameters and make a straight call to the table CSKS.
    NOTE: Use FieldNames not Field Labels (took me a few hrs on that one ;)

    using LOBTYPES = microsoft.lobservices.sap._2007._03.Types.Rfc;

    private static void GetDataFromSAP()

        
    RfcClient clnt = new RfcClient(); //myproxy client
        
    string[] data = GetAppDetailsForCurrentUser("SAP");
         clnt.ClientCredentials.UserName.UserName = data[0];
         clnt.ClientCredentials.UserName.Password = data[1];
         LOBTYPES.
    TAB512[] rfcData = new microsoft.lobservices.sap._2007._03.Types.Rfc.TAB512[0];
         LOBTYPES.
    RFC_DB_OPT[] rfcOps = new microsoft.lobservices.sap._2007._03.Types.Rfc.RFC_DB_OPT[0];
         LOBTYPES.
    RFC_DB_FLD[] rfcFlds = new microsoft.lobservices.sap._2007._03.Types.Rfc.RFC_DB_FLD[]
         { 
             n
    ew LOBTYPES.RFC_DB_FLD() {
             FIELDNAME =
    "KOSTL",
             LENGTH=10
             },
            
    new LOBTYPES.RFC_DB_FLD() {
             FIELDNAME =
    "DATBI",
             LENGTH=8
             },
            
    new LOBTYPES.RFC_DB_FLD() {
             FIELDNAME =
    "DATAB",
             LENGTH=8
             }
         };
    try
    {
      clnt.Open();
      clnt.RFC_READ_TABLE(
    ";", string.Empty, "CSKS", 50, 0,ref rfcData, ref rfcFlds, ref rfcOps);
      Console.WriteLine("RFC RESPONSE\r\n\r\nData:" + rfcData.Length.ToString());
    }
    catch (Exception ex)
     {
       Console.WriteLine("ERROR: " + ex.Message);
     }
    }

  4. More from first principles so this is to give you more of a BTS picture.
    NOTE: The use of the '%' sign to get a wildcard match on a KOSTL field, despite in the SAP Client UI the users enter a '*'

    private static void GetDataFromSAPV1()
    {
        string[] data = GetAppDetailsForCurrentUser("SAP");
        SAPBinding binding = new SAPBinding();  //A reference to Microsoft.Adapters.Sap is needed.
        //set up an endpoint address
       
    string sapUri = "sap://CLIENT=800;LANG=EN;@A/sapsrv/00?GWHOST=sapsrv&GWSERV=sapgw00&RfcSdkTrace=true";
        EndpointAddress address = new EndpointAddress(sapUri);
       
    try
        {
            ChannelFactory<IRequestChannel> fact = new ChannelFactory<IRequestChannel>(binding as Binding, address);
            // add credentials
            fact.Credentials.UserName.UserName = data[0];
            fact.Credentials.UserName.Password = data[1];
            // Open client
            fact.Open();
            //get a channel from the factory
            IRequestChannel irc = fact.CreateChannel();
            //open the channel
            irc.Open();
            string inputXml = "<RFC_READ_TABLE xmlns='http://Microsoft.LobServices.Sap/2007/03/Rfc/' xmlns:ns1='http://Microsoft.LobServices.Sap/2007/03/Types/Rfc/'>"
           
    + "<DELIMITER>|</DELIMITER>"
            + "<QUERY_TABLE>CSKS</QUERY_TABLE>"
            + "<ROWCOUNT>10</ROWCOUNT><ROWSKIPS>0</ROWSKIPS>"
            + "<DATA /><FIELDS>"
            + "<ns1:RFC_DB_FLD><ns1:FIELDNAME>KOSTL</ns1:FIELDNAME></ns1:RFC_DB_FLD>"
            + "<ns1:RFC_DB_FLD><ns1:FIELDNAME>DATAB</ns1:FIELDNAME></ns1:RFC_DB_FLD>"
            + "<ns1:RFC_DB_FLD><ns1:FIELDNAME>DATBI</ns1:FIELDNAME></ns1:RFC_DB_FLD>"
            + "</FIELDS>"
            + "<OPTIONS>"
            + "<ns1:RFC_DB_OPT><ns1:TEXT>KOSTL LIKE '1234%' AND BUKRS EQ '63' AND KOKRS EQ 'APPL'</ns1:TEXT></ns1:RFC_DB_OPT>"
            + "</OPTIONS>"
            + "</RFC_READ_TABLE>";
            //create an XML reader from the input XML
            XmlReader reader = XmlReader.Create(new MemoryStream(Encoding.Default.GetBytes(inputXml)));
            //create a WCF message from our XML reader
            Message inputMessge = Message.CreateMessage(
                         MessageVersion.Soap11,
                         http://Microsoft.LobServices.Sap/2007/03/Rfc/RFC_READ_TABLE,
                         reader);
            //send the message to SAP and obtain a reply
            Message replyMessage = irc.Request(inputMessge);
            //create a new XML document
            XmlDocument xdoc = new XmlDocument();
            //load the XML document with the XML reader from the output message received from SAP
            xdoc.Load(replyMessage.GetReaderAtBodyContents());
            XmlNodeList nds = xdoc.DocumentElement.SelectNodes("//*[local-name()='WA']");
            foreach (XmlNode nd in nds)
            {
                    string[] parts = nd.InnerText.Split('|');
                    Console.WriteLine("CC={0} From: {1} To: {2}", parts[0], parts[1], parts[2]);
             }
             xdoc.Save(
    @"d:\sapout.xml");
             irc.Close();
             fact.Close();
        }

    catch (Exception ex)
    {
             Console.WriteLine("ERROR: " + ex.Message);
    }
    }


Wednesday, May 12, 2010 3:54:57 PM (AUS Eastern Standard Time, UTC+10:00)  #    Comments [0] -
BizTalk | BizTalk Adapter Pack | SAP
Archive
<February 2012>
SunMonTueWedThuFriSat
2930311234
567891011
12131415161718
19202122232425
26272829123
45678910
Blogroll
 AppFabric CAT
AppFabric Windows Server Customer Advisory Team - New Blog.
[Feed] BizTalk 2006 - Windows SharePoint Services adapter
BizTalk 2006 Sharepoint adapter!!
 Breeze SharePoint 2010 Bootcamp
Breeze SharePoint 2010 Bootcamp
[Feed] BTS 2006 R2/EDI
[Feed] Chris Vidotto (MS BTS Legend)
Needs no intro....
 Mark Daunt
BTS/SPS/.NET GURU!!!
About the author/Disclaimer

Disclaimer
The opinions expressed herein are my own personal opinions and do not represent my employer's view in any way.

© Copyright 2012
Breeze
Sign In
Statistics
Total Posts: 518
This Year: 11
This Month: 3
This Week: 1
Comments: 259
All Content © 2012, Breeze