Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question appears to be off-topic because it lacks sufficient information to diagnose the problem. Describe your problem in more detail or include a minimal example in the question itself.
Closed 8 years ago.
Improve this question
http://sapscenarios.blogspot.in
I want to declare dynamic structure which contain a dynamic column in a internal table .
Structure is also dynamic .
You can use cl_abap_structdescr=>create and cl_abap_tabledescr=>create to create a structure and table type dynamically. They are really easy to use and works like a charm the only limitation may be that it is only available from ECC6 (possibly ECC5).
data ls_component type abap_componentdescr.
data lt_component type abap_component_tab.
data lcl_struct type ref to cl_abap_structdescr.
data lr_data type ref to data.
ls_component-name = 'FIELD1'.
ls_component-type = cl_abap_typedescr=>describe_by_name( 'I' ).
append ls_component to lt_component.
lcl_struct = cl_abap_structdescr=>create( P_COMPONENTS = lt_component ).
create data lr_data type handle lcl_struct.
FYI there is a similar question here but the answer, although correct, is limited since it generates a subroutine pool and you can only do that 36 times. However Denis Muzhzhukhin gave the same answer I did here with a reference to the SAP help.
Related
Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 4 years ago.
Improve this question
As a developer, a common mistake that I keep on repeating is assuming the data type of a column. I have read multiple articles regarding SQL column naming convention but have not seen any reference regarding data type as part of the column name - specifically for SQL Server.
E.g. Revenue_f for float, Organization_v for varchar, AccountNumber_i for integer and so on.
This must have been thought of already before but I want to know the reason why it is not being used, or an expert's input regarding the matter; pointing me to the right article/documentations will be greatly appreciated.
That is a horrible naming convention. Consider how awful it would be if you need to change AccountNumber to a character datatype. Do you then go back and rename the column and change every single query everywhere? Or do you leave the suffix in your column name even though it is no longer accurate? If you want to know the datatype of a column the ONLY way is to look at the definition of the table.
Also, a single character really is kind of useless. How do you handle nvarchar vs varchar? And what about the scale?
P.S. Even though I wrote an answer I am voting to close this question because it is primarily opinion based and as such is considered off topic for SO.
Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question appears to be off-topic because it lacks sufficient information to diagnose the problem. Describe your problem in more detail or include a minimal example in the question itself.
Closed 8 years ago.
Improve this question
I have a database table that contains a column for pricing.
Its very old, so it was written before i understood datatypes. so we are using varchar for a money value.
Ive noticed some columns have $ in them, so what I'm wondering is... is there a way with SQL Server to perform an update of the table and remove any instances of non numeric characters or at the very least remove the $ from the string in the columns in one go ?
I hope this is possible.
Update tbl
SET price = replace(price, '$', '')
Here is the replace definition
Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Closed 9 years ago.
This question was caused by a typo or a problem that can no longer be reproduced. While similar questions may be on-topic here, this one was resolved in a way less likely to help future readers.
This question appears to be off-topic because it lacks sufficient information to diagnose the problem. Describe your problem in more detail or include a minimal example in the question itself.
Improve this question
I am writing a query in Microsoft Access. and I am getting a syntax error in "field description". Here is the code:
CREATE TABLE CONS
(
Com_Type text,
Cons_2008 double(10,2),
Cons_2009 double(10,2),
Cons_2010 double(10,2)
);
Thanks!
Specify the length of the text field, unless you want a field of length 255 when called through an Access query or a Memo field when called through an ADO connection.
Com_Type Text(50),
The Double type has no size and scale specifications. Either drop them or use the Decimal type.
Cons_2008 Double
Or
Cons_2008 Decimal(10, 2)
Note: See this SO answer for a limitation related to the decimal type.
When using the Double type, you can still specify a format in the TextBoxes linked to this table column. That way you can force the display of 2 decimals.
CREATE TABLE CONS
(
Com_Type TEXT(150),
Cons_2008 DOUBLE,
Cons_2009 DOUBLE,
Cons_2010 DOUBLE
);
Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question does not appear to be about programming within the scope defined in the help center.
Closed 9 years ago.
Improve this question
Building a data driven web based application. Stated simply, how the front end is structured is defined by metadata stored as part of the database. One design consideration comes up frequently: how to store values that can take on different data types. For example, the input required from users are defined in a measurement table. The default measurement value can be string, int, or double depending on the measurement definition.
I have three possible solutions:
Option 1: Store all default values as varchar and cast to the correct type on the fly.
Option 2: Create table columns for each data type, and store null values in the columns that does not apply.
Option 3: Create separate tables to store values for each data type.
What would be the correct and professional way to handle this.
Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Closed 8 years ago.
This question appears to be off-topic because it lacks sufficient information to diagnose the problem. Describe your problem in more detail or include a minimal example in the question itself.
Questions asking for code must demonstrate a minimal understanding of the problem being solved. Include attempted solutions, why they didn't work, and the expected results. See also: Stack Overflow question checklist
Improve this question
What does the "s" do at the end of line 8 of this query:
http://www.sqlfiddle.com/#!3/f8816/20/0
I can't find it anywhere and the statement won't work without it.
Thanks!
The s is an alias for the result set which allows it to be referenced within the query.
The readability of a SELECT statement can be improved by giving a table an alias, also known as a correlation name or range variable. A table alias can be assigned either with or without the AS keyword:
table_name AS table alias
table_name table_alias
Using table aliases
The s is a table alias. It gives a name to a table or subquery used in the from clause.
SQL Server requires that all subqueries use aliases. Not all databases do.
I strongly encourage you to use them. They often make queries much more readable.
The data set getting created in the from is given the name 's' (similar to putting "AS s") so you can reference it otherwise in the code. Any data sets being created in a from requires a name be given to it, hence why it only works with the 's'.