cancel
Showing results for 
Search instead for 
Did you mean: 

Two way interoperability with nco3.0 in .net4

Former Member
0 Kudos

Hi All,

I am new to using nco and I must say, I am really impressed with what I have seen so far..

All I have so far achieved is designing a small windows form project that pulls out customer details (from accounts receivable) based on a customer number supplied by the end user.

Im pretty pleased to have got that working so quickly and with so few lines of code (c#).

My mind has now gone on to thinking that maybe I can improve this form by allowing users to update customer master data from this form. i.e. end user retrieves customer record and is able to make a change to that record and save it back to SAP..

Based on this, can anyone answer these questions:

1) Do i need to invoke a BAPI to first display the customer details and then invoke another (on a different button click) to actually update the record.

2) Would something like this work to update a field : bapivalue.customername.setvalue("BAPIFIELD", updatedvalue.tostring());

3) Does the gateway connection still perform the same role access checking that the GUI would. i.e. if the connected user doesnt have a roll that would allow updating, would the process fail?

4) Are there any examples of updating masterdata of employees/customers/vendors through nco3 out there?

Many thanks

Iain

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Hi,

The short answer is this :

  1. You can get data from sap ( with BAPI ) or even use other input source ( file,local DB or input from UI ).
    when you finish prepare your data you should invoke another bapi which have update capabilities .
  2. Yes,the line you wrote would update data in structure,but you still need to invoke FM for update, you should remember that you don't work directly on system ( asynchronous).
  3. Yes.
  4. in my document ... ( i apologize for not attaching full code but I write this code in machine without any IDE,NCO or even SAP ... )

the long one bit longer ...

First,I should say that my approach to sap connector is as DAL ( Data Access Layer ).
In other words – I  use sap connector as data source and update against sap application but not as my application object model.
So my application will contain view layer and model layer with application specific classes .
in this classes I utilize sap nco in all method which interact with sap ( GetData,UpdateRecord and etc. ).
This encapsulate complex call's, object structure and simplify program flow and view model.
After said all that let's get to business …
In SAP , Most BAPI's are designed to do one thing (update,create,get detail and etc.),that’s mean – you should use two BAPI's in order to update data ( at least) .
Reasonable flow for update will be in this sequence :
1. Get data from SAP ( BAPI XXX_get_detail) and fill object with relevant data.
2.  Do something :
* Display view to user.
* Get input from files.
* Apply changes to object.
3. Write data back to sap - Map data from object to BAPI_XXX_UPDATE.

In order to update sap back you should flow this sequence data to function:
1. Create structure\table to hold data and set values to fields (like reading but with SetValue() ).
2. set table to function.
3. Invoke function.

Some BAPI's demand executing commit after "update" FM.
in this case we use the "context" concept which ensure FM invocation in one connection
For this example let's look at purchase requisition update call sequance :

RfcDestination destSys = RfcDestinationManager.GetDestination("some destination");
RfcRepository rep = destSys.Repository ;
IRfcFunction bapi_pr_change = rep.Createfunction("BAPI_PR_CHANGE");
IRfcFunction bapi_commit  = rep.Createfunction("BAPI_TRANSACTION_COMMIT");

// set values to structrues,tables and return them to function.
//for example
bapi_pr_change["NUMBER"].SetValue("1234567890");
bapi_commit["WAIT"].SetValue("X");
//invoke update
RfcSessionManager.BeginContext(destSys);
bapi_pr_change.Invoke(destSys);
bapi_commit.Invoke(destSys);
RfcSessionManager.EndContext(destSys);

Former Member
0 Kudos

Thankyou that is a very helpful & comprehensive answer - I have plenty to go on there.

As an aside, do you deploy your .net projects out to webapplicaitons or as windows form applications?

Former Member
0 Kudos

Hi,

like all software development it's all depend on customer use-case , requirements and constraint ( UI & technology ).

When desktop application is needed - I turn to WPF with MVVM pattern.

When web application is needed as standalone - I use MVC ( currently 3 , seen some cool stuff MVC 4 beta ).

the third deployment option is to use Microsoft Silverlight Islands Integration for ABAP WD ( Web Dynpro ) for better UI ( that's not  SAP NCO but you should take a look... ).

Yarden

Former Member
0 Kudos

I hadnt heard of silverlight islands - that sounds like one i need to read up on.


many thanks for all you help.

Answers (0)