Thursday, May 13, 2010

Exception has been thrown by the target of an invocation

Hello,

You may get this error when you use BizTalk SAP adapter to call a BAPI in SAP. This error mostly doesn't occur in development machines and it usually happens when you migrate the code to higher tiers(staging server or Production).

The interesting part about SAP is we have got out of box components to generate Schema structures for IDOC and BAPI's. We also have SAP adapter to communicate with SAP. When we want to communicate with SAP using IDOC mode, we don't need to have any assemblies specific to the schemas. However, when we want BizTalk to call a BAPI in SAP, we need to have a dll in the below folder
[BizTalk SAP adapter Installed Directory]\Microsoft BizTalk Adapter v2.0 for mySAP Business Suite\Bin

Before you start sending messages from BizTalk to RFC, you need to first generate schemas from SAP. There are two modes where you can either generate a schema from an IDOC or RFC. When you given your criteria and proceed to generate the schema, the tool generates a dll and places it in the above mentioned folder. Then you go forward and implement your business process and deploy your artifacts and test the application. But you should remember to copy this dll to the target machine where you will deploy the application and where it will be used for testing or live production server.

Hope this will be helpfull for someone.

I didnt find a blog item anywhwere which could have saved me 2 hours of my time.

Vanakkam