Application Development and Automation Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

Extracting data from SE37 using C#

Former Member
0 Likes
1,515

I am accessing the BAPI: BAPI_ALM_ORDER_GET_DETAIL using C# through the following code:

public double getActualCost (R3Connection connection, string orderNo)

        {

            double actualCost = 0;

            try

            {

                connection.Open();

                RFCFunction func = connection.CreateFunction("BAPI_ALM_ORDER_GET_DETAIL");

                func.Exports["NUMBER"].ParamValue = orderNo;

                func.Execute();

                RFCTable orderCostsTable = func.Tables["ET_COSTS_DETAILS"];

                if (orderCostsTable.RowCount > 0)

                {

                    actualCost = Convert.ToDouble(orderCostsTable.Rows[0][0]);

                    return actualCost;

                  

                }

                else

                    return orderCostsTable.RowCount;

            }

            catch (Exception e)

            {

                Console.WriteLine(e.Message);

                return 1;

            }

        }

The problem is that orderCostsTable.RowCount is always equal to 0. I have tried to access the table ET_COSTS_DETAILS through the SE37 transaction using SAP GUI, however there are 2 selections for this table (Shown in the attached picture). The first one has 0 entries (I suspect that this is the reason orderCostsTable.RowCount is always equal to 0), while the 2nd one has 1 entry (which is the entry I am trying to read from the C# application).

Is there any way to solve this problem?

1 ACCEPTED SOLUTION
Read only

SimoneMilesi
Active Contributor
0 Likes
1,112

Hi Sylvan,

just a question: how much do you know about ABAP? It seems to me you never tried to run a FM in se37 from what you are saying.

Because the 1st one you are seeing with 0 is the "Input status of the table" before executing the FM while the 2nd one is the "Output status of the table".


To get the correct data, be sure your orderNo here is lenght 12 with not significative 0 filled


func.Exports["NUMBER"].ParamValue = orderNo;

For example: orderNo is 12, you HAVE TO pass 000000000012

3 REPLIES 3
Read only

SimoneMilesi
Active Contributor
0 Likes
1,113

Hi Sylvan,

just a question: how much do you know about ABAP? It seems to me you never tried to run a FM in se37 from what you are saying.

Because the 1st one you are seeing with 0 is the "Input status of the table" before executing the FM while the 2nd one is the "Output status of the table".


To get the correct data, be sure your orderNo here is lenght 12 with not significative 0 filled


func.Exports["NUMBER"].ParamValue = orderNo;

For example: orderNo is 12, you HAVE TO pass 000000000012

Read only

0 Likes
1,112

I'm a beginner in ABAP (still a student). I have tried it with orderNo length 12 and it worked. Thanks a lot for your reply

Read only

0 Likes
1,112

Hi Sylvan.

You are welcome but I warmly suggest you to read the docs and check the many and many and many wikis here on scn before jumping right in the deep waters of coding.

I know the urge to write something, but better study (and train) alot before.

Under lean and training space you can find also some free online courses if you need them!