How to get SAP DDIC table structure in C#? - c#

I'm writing some codes about extract table's structure from SAP using C#, and I've got a question about RFC_READ_TABLE, when I define a table's name and the FIELDS table returned 5 columns, like : FIELDNAME, OFFSET, LENGTH, T and FIELDTEXT, actually I couldn't know what's the decimal places of a numeric field according to these 5 columns, is there any other way to get this? Please be noted that my SAP account is a public one because other peoples are also using it, I'm not supposed to create new function module in SAP.
Below info was what I got from FIELDS table of module RFC_READ_TABLE:
MANDT | 000000 | 000003 | C | Client**: length * 3**
BUKRS | 000003 | 000004 | C | Company Code: **length * 3**
ANLN1 | 000007 | 000012 | C | Main Asset Number: **length * 3**
ANLN2 | 000019 | 000004 | C | Asset Subnumber: **length * 3**
GJAHR | 000023 | 000004 | N | Fiscal Year: **numeric(4,0)**
LNRAN | 000027 | 000005 | N | Sequence Number of Asset Line Items in Fiscal Year: **numeric(5,0)**
AFABE | 000032 | 000002 | N | Real depreciation area: **numeric(2,0)**
ZUJHR | 000034 | 000004 | N | Asset acquisition year (currently not used): **numeric(4,0)**
ZUCOD | 000038 | 000004 | N | Sub-classification of asset acquisitions(currently not used): **numeric(4,0)**
AUFWV | 000042 | 000013 | P | Proportional cumulative revaluation on replacement value: **numeric(13,??=2)**
The datatype of this field is numeric(13,2) according to DB, but how can I get this clue?
thanks in advance!

RFC_READ_TABLE FM returns only summary of field. You can use DDIF_FIELDINFO_GET FM for details.

Related

How can I add different examples with different columns in specflow examples

The following code is my Scenario:
Scenario: TradeOrders
Given Order 'SellOrder' Has Been Registerd
| Side | Price | Amount | IsFillAndKill | ExpireTime |
| 0 | 100 | 5 | false | 2024-02-05 09:30:26.2080000 |
And Order 'BuyOrder' Has Been Defined
| Side | Price | Amount | IsFillAndKill | ExpireTime |
| <Buy> | <Price> | <Amount> | <IsFillAndKill> | <ExpireTime> |
When I Register The Order 'BuyOrder'
Then The following 'Trade' will be created
| BuyOrderId | SellOrderId | Amount | Price |
| <BuyOrderId> | <SellOrderId> | <TradeAmount> | <TradePrice> |
And BuyOrder 'BuyOrder' Should Be Modified like this
| Side | Price | Amount | IsFillAndKill | ExpireTime |
| 1 | 100 | 0 | false | 2024-02-05 09:30:26.2080000 |
Examples:
| Buy | Price | Amount | IsFillAndKill | ExpireTime |
| 1 | 100 | 5 | false | 2024-02-05 09:30:26.2080000 |
Examples:
| <BuyOrderId> | <SellOrderId> | <TradeAmount> | <TradePrice> |
| 1 | 2 | 5 | 100 |
I want to add some examples with different columns but I have faced with below error:
Severity Code Description Project File Line Suppression State
Error Generation error: Message: The example sets must provide the
same parameters.
I appreciate you in advance.
This is not supported in SpecFlow. Since both tables are used in the same scenario, they need to go in the same row. It makes for a wide table, but there isn't anything you can do about it. Second of all, you cannot have < or > tokens in the column headers.
Examples:
| Buy | Price | Amount | IsFillAndKill | ExpireTime | BuyOrderId | SellOrderId | TradeAmount | TradePrice |
| 1 | 100 | 5 | false | 2024-02-05 09:30:26.2080000 | 1 | 2 | 5 | 100 |
You can also put spaces in the column headers so they are easier to read:
Examples:
| Buy | Price | Amount | Is Fill And Kill | Expire Time | Buy Order Id | Sell Order Id | Trade Amount | Trade Price |
| 1 | 100 | 5 | false | 2024-02-05 09:30:26.2080000 | 1 | 2 | 5 | 100 |
The choice to include spaces in column headers is subjective. It is supported to aid readability, but feel free to omit spaces if this does not make the examples table easier to understand.

Get data from Examples table on scenario outline?

Does specflow provide a way to get data from the "Examples" table when using the scenario outline format? Similar to how tags are available in scenario context during execution.
No, there is no way for that.
The examples you write into the examples table are like parameter for a scenario.
These values are replaces the placeholder in your scenario steps (they are in <> brackets)
Example from the Gherkin documentation (https://cucumber.io/docs/reference - Scenario Outline)
Scenario Outline: feeding a suckler cow
Given the cow weighs <weight> kg
When we calculate the feeding requirements
Then the energy should be <energy> MJ
And the protein should be <protein> kg
Examples:
| weight | energy | protein |
| 450 | 26500 | 215 |
| 500 | 29500 | 245 |
| 575 | 31500 | 255 |
| 600 | 37000 | 305 |
You can only get the whole table, if you are using a data table as parameter.
Example:
Given the following users exist:
| name | email | twitter |
| Aslak | aslak#cucumber.io | #aslak_hellesoy |
| Julien | julien#cucumber.io | #jbpros |
| Matt | matt#cucumber.io | #mattwynne |
You can access this with this binding:
[Given(#"the following users exist:")
public void TheFollowinUsersExists(Table table)
{
//your code
}

Show data from two model with same column name same value in ASP.NET

I'm new to ASP.NET, I have only experiences in C# Windows Form and SQL Server. Now I have starting my new project in ASP.NET MVC and already have database from my customer. It has two model included some same column name like this:
Table 1
---------------------------------
| Location | Item | Model | Tag |
---------------------------------
| 1 | 10 | A5 | 221 |
| 2 | 10 | A6 | 233 |
| 3 | 12 | A8 | 332 |
| 4 | 15 | C1 | 223 |
Table 2
-------------------------------------------------
| Location | Item | Model | Tag | DWeek | DYear |
-------------------------------------------------
| 1 | 10 | A5 | 221 | 01 | 15 |
| 2 | 10 | A6 | 233 | 01 | 15 |
| 3 | 12 | A8 | 332 | 02 | 15 |
| 4 | 15 | C1 | 223 | 03 | 15 |
I just want to show the data which have same Location and Item in one table, I don't know how to query in Entity framework, I have only know how to code by SQL, and I think it seem to be like this:
select
r.Location
,r.Item
,d.Location
,d.Item
,d.DWeek
,d.DYear
,r.Model
,r.[Tag No]
,d.[Tag No]
from Register r, Due d
where r.Location = d.Location
and r.Item = d.Item
My question is how to query like this in Entity framework for show data in a view, and is it possible to update and create two model in the same time?
I am using Lambda Expression
var Query=Register.Join(Due,r=>r.Location,d=>d.Location,(r,d)=>new {r,d}).Where(
X=>X.r.Location = X.d.Location && X.r.Item = X.d.Item).Select(X=>new {
LOCATION_1 =X.r.Location;
ITEM_1=X.r.Item;
LOCATION_2=X.d.Location;
ITEM_2=X.d.Item;
DWEEK=X.d.DWeek;
DTEAR=X.d.DYear;
MODEL=X.r.Model;
TAGNO_1=X.r.Tag_No;
TAGNO_1=X.d.Tag_No;
}).ToList();

Displaying customer bi-weekly from start date for this week in SQL

I'm trying to figure out how to start with this. So each customer should be display bi-weekly starting from the start date. I want the current week to display those that should be display for this week.
Here's my table.
Customers_Id(PK)|First|Last | Address | Phone | Start_Date | Tech_Id (FK) |
----------------+-----+------+--------------+---------+-------------+---------------+
1 | Bob |Smith | 123 Fake St. | 3298492 | 8/4/2010 | 1 |
2 | John|Man | 123 Noe St. | 2930482 | 4/15/2008 | 1 |
3 | Tom |Lee | 123 Polk St. | 9308523 | 6/21/2012 | 2 |
Hopefully this is clear enough.
in mysql, you can do something like:
SELECT * FROM Customers WHERE WEEK(NOW())=WEEK(Start_Date)
This is the answer I have.
SELECT *
FROM Customers
Where DATEDIFF (ww, Start_Da, GETDATE())%2 = 0

merge 2 different datatable using DataRelation

I tried to merge 2 datatables like this. But my tables have different schema and different amount of rows. So I get an error here:
DataRelation drel = new DataRelation("EquiJoin",cr1, cr2, true);
dataSet.Relations.Add(drel);//error
As far as I understand, because first table has much more rows than second table.
Error: Cannot evaluate expression because a native frame is on top of the call stack.
Tables look like:
snowFlake: snow:
f_text | f_link_id | f_tabkey | | f_text | f_link_id | f_tabkey |
--------+---------------+-------------| |---------+---------------+-------------|
row1 | 100001 | 1 | | - | 100000 | 1 |
row2 | 100001 | 2 | | + | 100001 | 1 |
row3 | 100001 | 3 | | - | 100001 | 2 |
row4 | 100002 | 1 | | + | 100001 | 3 |
row5 | 100003 | 1 | | + | 100002 | 1 |
| + | 100003 | 1 |
| - | 100003 | 1 |
| + | 100004 | 1 |
| - | 100005 | 1 |
Primary keys that I use:
snowFlake.PrimaryKey = new DataColumn [] { snowFlake.Columns[IndexesField.F_LINK_ID], snowFlake.Columns[IndexesField.F_TABKEY] };
snow.PrimaryKey = new DataColumn [] { snow.Columns[IndexesField.F_LINK_ID], snow.Columns[IndexesField.F_TABKEY] };
DataColumn[] cr1 = { snowFlake.Columns[IndexesField.F_LINK_ID], snowFlake.Columns[IndexesField.F_TABKEY] };
DataColumn[] cr2 = { snow.Columns[IndexesField.F_LINK_ID], snow.Columns[IndexesField.F_TABKEY] };
How can I solve it?
Regards, Alexander.
Doesn't matter if they do not have same number of rows, because they are joined over a relation thus mimicking TSQL's Inner Join behavior. Without telling us the specific error, one can only assume that you haven't properly defined keys for joining (for example, the columns you specified in the relation don't exist).

Categories

Resources