Creation of tables at runtime
Hi,
In our project, requirement is such that, customer can create a form definition from UI. He can define all columns for the form, it's datatype, constraints etc. Based on that information, then they can do data entry in that form. So, until runtime, we don't know the structure of the form and each form can be unique so we cannot pre-define any columns. We need to have database tables to store the data they enter.
We evaluated few options and we are leaning towards creating the table at runtime based on the form definition. There can be thousands of records for each form and we also need some calculations on this data. So, creating one table for each form seems to be a better fit but creating tables at runtime is discouraged, in general. I would like to know opinion on this option.
(if any specific details are required then I can post it)
Thank you for your time.
1005222 wrote:
In our project, requirement is such that, customer can create a form definition from UI. He can define all columns for the form, it's datatype, constraints etc. Based on that information, then they can do data entry in that form. So, until runtime, we don't know the structure of the form and each form can be unique so we cannot pre-define any columns. We need to have database tables to store the data they enter.Wrong. What the customer wants to is use the database directly - as creating tables and constraints and the like is exactly that. Using database DDL to define objects. The database also has a data dictionary (a very comprehensive one at that). So there is no need for you to insert another layer in-between the customer and the database that contains meta data and what not.
The only automation required is to have the customer enter the definition in a template/form, and for your code to translate this directly to a DDL. Exactly the same as what DBCA does when you create a new database and click the icon to define a new tablespace. A form pops up. You enter the attributes and name of the tablespace. The s/w turns that into a DDL statement.
If you want some kind of auditing, then log the DML created to an audit/log table, after constructing it. The s/w can also log the result (error or success) of that DML's execution.
This should be the extent of your s/w's functionality. To create additional user/custom meta data tables, would be just plain silly IMO. Use the Oracle dictionary. Use the COMMENT command to add to the meta data. Do not reinvent Oracle's meta data layer.
We evaluated few options and we are leaning towards creating the table at runtime based on the form definition. There can be thousands of records for each form and we also need some calculations on this data. So, creating one table for each form seems to be a better fit but creating tables at runtime is discouraged, in general. I would like to know opinion on this option.I agree that this approach is questionable - as you just as well can give the customer a copy of SQL-Developer instead to use. As that would be the most appropriate tool for someone who insists on creating and maintaining their own data objects in Oracle.
The key issue IMO is, if this is the approach decided on, to use Oracle as a database. And not invent your own custom database layer with meta data and have the user using that, while your code then "maps/translates" that to the real tables and objects in the database.
Similar Messages
-
Dynamic Creation of cells or change of cell behaviour of a table at runtime
Hello all,
Can anybody tell me how can we change the cell behaviour of a table at runtime or creating the table row with different cell properties dynamically at runtime in ABAP webdynpro.
for ex the table at runtime can be like...
The 1st row the 1st cell can be a check box.
The 2nd row the 1st cell can be a input field.
The 3rd row the 1st cell can be a radio selection field.
Business Ex : Dynamic Attributes in BID Invitation
Thanks in advance in clarifying the doubt.Hi Mani,
You could use code similar to the following code in your WDDOMODIFY method of the view in which the table is placed.
data wd_table_cell_editor type ref to cl_Wd_view_element.
data wd_table_column type ref to cl_wd_table_column.
wd_table_cell_editor ?= view->get_element( ID ). (Or any other way to get the refernce to the table cell editor)
wd_table_column ?= wd_table_cell_editor->get__parent( ).
(Get a refernce to table column throught table cell editor or directly)
Now use the set_cell_editor method of wd_table_column to set the column to check box or input or any other field of your requirement.
Also, I suggest you to use ALV as it is simpler change the cell editor and it provides many other improved functionalities.
Regards,
Srini. -
Creation of tables using JDBC or SQLJ in webdynpro application
Hi,
I am trying to create tables in javadictionary(MaxDB)using my WebDynpro application.I tried creating tables using SQLJ and JDBC.But I was not able to do it.I can select and insert data into already created tables.
Whwn I tried creating a table using JDBC I encountered the following exception.
com.sap.sql.log.OpenSQLException: The SQL statement "CREATE TABLE TMP_DEPID (DEPID varchar(10) NOT NULL,DEPNAME VARCHAR(25))" contains the syntax error[s]: Open SQL syntax error: CREATE ... TABLE is not supported
SQL syntax error: "VARCHAR" is a reserved keyword and cannot be used as an unquoted identifier
Does this mean that creating tables is not supported?
Can anyone help me in this matter?
Thanks in advance,
regards
~Pradeep ShettyHi Pradeep,
Yes, OpenSQL does not support creation of tables. But why would you need to create tables at runtime?! The natural way is to create the model at design time of your application, i.e. with the Java DataDictionary.
However, if for any reason you really need to create database tables at runtime, you can achieve this by using a non-OpenSQL datasource, e.g. you could create a VendorSQL one and use it to obtain JDBC connections in your app. See also http://help.sap.com/saphelp_nw04/helpdata/en/c0/3ad4d5cdc66447a188b582aad537d3/frameset.htm.
Hope that helps!
Vladimir -
Accessing internal tables at runtime.
Hi all,
I am writing a code where in i have to transfer data from excel to database table.
Iam getting the excel data in an itab. Can anybody help me with how to access internal tables at runtime ?
i am using the following code with sy-tabix. here, when the sy-tabix is odd it picks up the value,
but i want that within the same loop when i increment sy-tabix by 1, then it should fetch the second column of same row. But its not working as it shows an error that it does not permit subfield access.
the code is as follows:
LOOP AT t_tab[] into wa_tab .
data: l_tabix type sy-tabix,
name_index type sy-tabix.
data: c type i.
l_tabix = sy-tabix.
name_index = l_tabix+1.
c = ( l_tabix mod 2 ).
******to check if sy-tabix is odd**********
if c ne 0.
READ TABLE t_tab into wa_tab index l_tabix.
wa_product1-product = wa_tab-VALUE.
************incrementing sy-tabix*************
READ TABLE t_tab into wa_tab index name_index. (here it shows error)
wa_product1-product_name = wa_tab-value.
endif.
endloop.
Thanks in advance.Hi Omer,
Copy and paste this code.
=====================================
REPORT ztest_create_data_dynamic .
TYPE-POOLS: slis.
DATA: it_fcat TYPE slis_t_fieldcat_alv,
is_fcat LIKE LINE OF it_fcat.
DATA: it_fieldcat TYPE lvc_t_fcat,
is_fieldcat LIKE LINE OF it_fieldcat.
DATA: new_table TYPE REF TO data.
DATA: new_line TYPE REF TO data.
FIELD-SYMBOLS: <l_table> TYPE ANY TABLE,
<l_line> TYPE ANY,
<l_field> TYPE ANY.
Build fieldcat
CALL FUNCTION 'REUSE_ALV_FIELDCATALOG_MERGE'
EXPORTING
i_structure_name = 'SYST'
CHANGING
ct_fieldcat = it_fcat[].
LOOP AT it_fcat INTO is_fcat WHERE NOT reptext_ddic IS initial.
MOVE-CORRESPONDING is_fcat TO is_fieldcat.
is_fieldcat-fieldname = is_fcat-fieldname.
is_fieldcat-ref_field = is_fcat-fieldname.
is_fieldcat-ref_table = is_fcat-ref_tabname.
APPEND is_fieldcat TO it_fieldcat.
ENDLOOP.
Create a new Table
CALL METHOD cl_alv_table_create=>create_dynamic_table
EXPORTING
it_fieldcatalog = it_fieldcat
IMPORTING
ep_table = new_table.
Create a new Line with the same structure of the table.
ASSIGN new_table->* TO <l_table>.
CREATE DATA new_line LIKE LINE OF <l_table>.
ASSIGN new_line->* TO <l_line>.
Test it...
DO 30 TIMES.
ASSIGN COMPONENT 'SUBRC' OF STRUCTURE <l_line> TO <l_field>.
<l_field> = sy-index.
INSERT <l_line> INTO TABLE <l_table>.
ENDDO.
LOOP AT <l_table> ASSIGNING <l_line>.
ASSIGN COMPONENT 'SUBRC' OF STRUCTURE <l_line> TO <l_field>.
WRITE <l_field>.
ENDLOOP. -
How to get the PRIMARY KEY of a table at runtime ???
Hi everybody,
My requirement is to update a z-table at runtime according to the data given ata runtime. So the main difficulties for me is that whenever I tried to update the table based on the data given in UI many rows are getting updated as these fields are not unique. So I think if I can get the PRIMARY KEY along with these given fields then I can update only one row at a time.
So Can anyone suggest me how to get PRIMARY KEY of a table based on the data in UI..??
Any suggestions will be appreciated..
Thanks,
SekharU will get primary keys of transparent tables using FM "REUSE_FIELDCALATLOG_MERGE".
pass tyour table name and u will get fieldcatalog filled. In tht their is a field called "KEY" if it has 'X' then tht field is a primary key of transparent tables & if it has "space" then it is not a primary key...
Or else you can try with 'DDIF_TABT_GET'
Or try this code
PARAMETERS: p_table TYPE tabname OBLIGATORY.
DATA: go_strucdescr TYPE REF TO cl_abap_structdescr,
gt_tab_fields TYPE ddfields.
FIELD-SYMBOLS: <gwa_tab_field> TYPE dfies.
TRY .
* Get the details of the DDIC table
go_strucdescr ?= cl_abap_elemdescr=>describe_by_name( p_table ).
CATCH cx_sy_move_cast_error .
MESSAGE 'Error while casting' TYPE 'S'. RETURN.
ENDTRY.
* Check if input is a DDIC table
CHECK go_strucdescr->is_ddic_type( ) = 'X'.
* Get the details of the table fields
gt_tab_fields = go_strucdescr->get_ddic_field_list( ).
* Display the Key fields of the table
LOOP AT gt_tab_fields ASSIGNING <gwa_tab_field> WHERE keyflag = 'X'.
WRITE: / <gwa_tab_field>-fieldname.
ENDLOOP. -
Dynamic creation of table with variable field-names
HI
I am looking for a way in order to create a table during runtime. The problem is that the field names of the table are provided in another table.
TO illustrate the case at hand, an example:
The initial table contains the fields
UserID - attribut_name - attribute_value
Example Data
d00587 - first_name - Jon
d00587 - last_name - Smith
d00587 - age - 48
d00127 - first_name - Jack
d00127 - last_name - Daniels
d00127 - position - Manager
Now I need to create a table per User that looks as follows:
for user d00587
first_name - last_name - age
**Values
Jon - Smith - 48
for user d00127
first_name - last_name - positioin
Jack - Daniels - Manager
I split the initial table by sorting it according to userID and then looping into an itab with an AT END OF userid, thus I receive the table per user:
Example iTab
UserID - attribut_name - attribute_value
Example Data
d00587 - first_name - Jon
d00587 - last_name - Smith
d00587 - age - 48
However I have no clue on how to create a new internal table with field-names = attribute_name.
Does anybody have an idea or example code for this?
Thanks a lot for your help,
Kind regards,
MingoloHello Minima
Here is some sample coding:
DATA:
gt_fcat type lvc_t_fcat,
gdo_data TYPE REF TO data.
FIELD-SYMBOLS:
<gt_itab> TYPE table.
CALL FUNCTION 'LVC_FIELDCATALOG_MERGE'
EXPORTING
* I_BUFFER_ACTIVE =
i_structure_name = 'MARA'
* I_CLIENT_NEVER_DISPLAY = 'X'
* I_BYPASSING_BUFFER =
CHANGING
ct_fieldcat = gt_fcat
EXCEPTIONS
inconsistent_interface = 1
program_error = 2
OTHERS = 3
IF sy-subrc <> 0.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
* WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
CALL METHOD cl_alv_table_create=>create_dynamic_table
EXPORTING
* I_STYLE_TABLE =
it_fieldcatalog = gt_fcat
IMPORTING
ep_table = gdo_data
* E_STYLE_FNAME =
EXCEPTIONS
generate_subpool_dir_full = 1
OTHERS = 2.
IF sy-subrc <> 0.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
* WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
ASSIGN gdo_data->* TO <gt_itab>.
In your case, you would call the function module with your tables (D00587, D00127). Remove all fields from the fieldcatalog that you do not need before calling the static method.
Regards
Uwe -
Problem regarding the creation of Table using CSS.
Hi ,
Here I have a Problem regarding the creation of Table using CSS.
In My Application i have a table with multiple rows(Rows are Dynamically added to the table).First i am setting the table with the following properties:
width:900px;
height : auto,
Overflow : visible,
Max-height: : 200px.
If I use above properties,I'm getting a table with 5 or 6 rows(height upto 200px).After that i am getting the Vertical ScrollBar.
The problem is when a table has many columns, Vertical and Horizontal Scrolls are coming at the time of setting the table. The table height is not Increasing dynamically.
How can i use "height" property in CSS? (I want the table height to be increased when the columns are more.)
Thanks & Regards
MadhaviHey humble user. Errr I'm trying to understand what ur trying to do. U want to create a section of a region destructively from an existing region right? If so select the option convert to new region (opt-comm-R or selecting it by right clicking). Check your audio bin to make sure. Whats the "merge" function? Are u refering to the glue tool?
-
Reg: Creation of Table Types
Hi All,
I have a small question regaridng the creation of Table type.
Let us suppose I am creating Table type for a custom table zsample which is having 5 fields. I am generally creating a structure similar to custom table and using that structure as line type for the table type. Let us suppose if there are any changes in the custom table like change in the order of fields or if new fields are added the table type will give dump.
My question is If I use the custom table itself as a line type, will there be any effect in the performance or some thing or I can go ahead and use it..
Thanks,
RaveeWhat dump are you expecting ???
It is idea behind the creation with reference to get structures and tables which always look like
the tables they refer to.
I can not see a possibilty for a dump as long as you create only an internal table.
A dump could appear, if the internal table is later used to update another db-table. But there it should be clear that the structure of an internal should be created with reference to the tables which they change.
Siegfried -
MDM Java API (Creation of table)
Hi,
can anyone help me for creation of tables in repository using MDM java API .
Can u Provide sample code for this.
Edited by: Srikanth Josyula on Jun 26, 2008 8:52 AMHi Srikanth,
Check with this code.It may be useful.
createflattable.java
Created on June 25, 2008, 5:08 PM
To change this template, choose Tools | Options and locate the template under
the Source Creation and Management node. Right-click the template and choose
Open. You can then make changes to the template in the Source Editor.
package tabletype;
import com.sap.mdm.commands.AuthenticateRepositorySessionCommand;
import com.sap.mdm.commands.CommandException;
import com.sap.mdm.commands.CreateRepositorySessionCommand;
import com.sap.mdm.commands.GetRepositoryRegionListCommand;
import com.sap.mdm.data.MultilingualString;
import com.sap.mdm.data.RegionProperties;
import com.sap.mdm.data.RegionalString;
import com.sap.mdm.net.ConnectionException;
import com.sap.mdm.net.ConnectionPool;
import com.sap.mdm.net.ConnectionPoolFactory;
import com.sap.mdm.schema.TableProperties;
import com.sap.mdm.schema.commands.CreateTableCommand;
import com.sap.mdm.schema.commands.GetFieldListCommand;
import com.sap.mdm.schema.commands.GetTableListCommand;
import com.sap.*;
import com.sap.mdm.server.DBMSType;
import com.sap.mdm.server.RepositoryIdentifier;
import java.util.Locale;
public class createflattable {
/** Creates a new instance of createflattable */
public createflattable() {
private static MultilingualString createMultilingualString(RegionProperties[] regionPropertiesList, String baseString)
MultilingualString mlString = new MultilingualString();
for (int i = 0; i < regionPropertiesList.length; i++)
Locale locale = regionPropertiesList<i>.getLocale();
//Locale locale = regionPropertiesList<i>.getLocale();
String regionCode = regionPropertiesList<i>.getRegionCode();
String string = baseString + "_" + locale.getLanguage() + "_" + locale.getCountry();
RegionalString regionalstring = new RegionalString(string, regionCode);
mlString.set(regionalstring);
return mlString;
private static TableProperties createFlatTable(RegionProperties[] regionPropertiesList)
//MultilingualString tableName = createMultilingualString(regionPropertiesList, "NewTable" + System.currentTimeMillis());
MultilingualString tableName = createMultilingualString(regionPropertiesList, "first"+System.currentTimeMillis());
System.out.println("table is" +tableName);
TableProperties table = new TableProperties(TableProperties.FLAT);
table.setName(tableName);
table.setCode("NewCode" + System.currentTimeMillis());
table.setKeyMappable(true);
table.setDescription("");
return table;
public static void main(String[] args) {
// System Name
String tag = "";
ConnectionPool connections = null;
try {
connections = ConnectionPoolFactory.getInstance(tag);
catch (ConnectionException e)
e.printStackTrace();
return;
//////////////// specify the repository to use
//RepositoryName
String repositoryName = "";
//DataBase Name
String dbmsName = "";
RepositoryIdentifier reposId = new RepositoryIdentifier(repositoryName, dbmsName, DBMSType.MS_SQL);
/////// create a repository session
CreateRepositorySessionCommand sessionCommand = new CreateRepositorySessionCommand(connections);
sessionCommand.setRepositoryIdentifier(reposId);
try {
sessionCommand.execute();
catch (CommandException e) {
e.printStackTrace();
return;
System.out.println("Currently connected to "+reposId);
String sessionId = sessionCommand.getRepositorySession();
/////////// authenticate the repository session
String userName = "";
String userPassword = "";
AuthenticateRepositorySessionCommand authCommand = new AuthenticateRepositorySessionCommand(connections);
authCommand.setSession(sessionId);
authCommand.setUserName(userName);
authCommand.setUserPassword(userPassword);
try {
authCommand.execute();
catch (CommandException e) {
e.printStackTrace();
return;
//////////////////// retrieve the list of tables
GetTableListCommand tableListCommand = new GetTableListCommand(connections);
tableListCommand.setSession(sessionId);
try {
tableListCommand.execute();
catch (CommandException e) {
e.printStackTrace();
return;
// get change stamp
// this is required when we make any kind of changes to the repository
int changeStamp = tableListCommand.getChangeStamp();
//////get repository regionlist
//A command for retrieving the list of regions supported by the repository.
// retrieve the available regions (languages) for the repository
// we need this to set up the table name for each region
GetRepositoryRegionListCommand gm = new GetRepositoryRegionListCommand(connections);
gm.setRepositoryIdentifier(reposId);
try {
gm.execute();
catch (CommandException e) {
e.printStackTrace();
return;
// RegionProperties[] rs = gm.getRegions();
RegionProperties[] regionPropertiesList = gm.getRegions();
TableProperties newtable = createFlatTable(regionPropertiesList);
CreateTableCommand c = new CreateTableCommand (connections);
c.setSession(sessionId);
c.setTable(newtable);
c.setInChangeStamp(changeStamp);
try {
c.execute();
System.out.println("sdf");
catch (CommandException e) {
e.printStackTrace();
return; -
Capacity Planning for Creation of Table
Hello Guys,
I just need some advise here.
I have been told to work out the space needed for the creation of a table.
The table in question would have three columns with datatypes [num(10), varchar(10),date] and would be loaded with 100,000 rows. How do I go about it.
Thanks in AdvanceTry with something like this, may help you.
Prerreqs: parameter OPTIMIZER_MODE != RULE.
grant to execute DBMS_SPACE
DDL Table creation:
CREATE TABLE SAMPLE
ID NUMBER(9),
NAME VARCHAR(50),
CREATE_DATE_TIME DATE,
MOD_DATE_TIME DATE,
USER_ID VARCHAR(15)
set serveroutput on
declare
calc_used_bytes NUMBER;
calc_alloc_bytes NUMBER;
cols sys.create_table_cost_columns;
begin
cols := sys.create_table_cost_columns
sys.create_table_cost_colinfo('NUMBER', 9),
sys.create_table_cost_colinfo('VARCHAR2', 50),
sys.create_table_cost_colinfo('VARCHAR2', 15),
sys.create_table_cost_colinfo('DATE', NULL),
sys.create_table_cost_colinfo('DATE', NULL)
DBMS_SPACE.CREATE_TABLE_COST (
tablespace_name => 'USERS',
--avg_row_size => 100, quitar comentario para 11g
row_count => 5000,
pct_free => 10,
used_bytes => calc_used_bytes,
alloc_bytes => calc_alloc_bytes
dbms_output.put_line('Used (M): '||round(calc_used_bytes/(1024*1024)));
dbms_output.put_line('Allocated (M): '||round(calc_alloc_bytes/(1024*1024)));
end;
/More info: http://download.oracle.com/docs/cd/B19306_01/appdev.102/b14258/d_space.htm#i1003180
Regards.
johnxjean
Edited by: johnxjean on 18-Mar-2011 09:43
Edited by: johnxjean on 18-Mar-2011 09:44 -
How to get the field name of an internal table during runtime?
How to get the field name of an internal table during runtime?
Hi Sudhir,
Declare and Use Get Cursor Field in Your Prm to get the field Name of the Intenal Table
Example Code:
<b> DATA: v_field(60). " Insert this code.
GET CURSOR FIELD v_field. " Insert this code.</b>
<b>CHECK v_field = 'ITAB-KUNNR'. " Insert this code. (or)
Write: v_field.</b>
Regards,
Ramganesan K. -
How to create hashed table in runtime
hi experts
how to create hashed table in runtime, please give me the coading style.
please help me.
regards
subhasisHi,
Have alook at the code, and pls reward points.
Use Hashed Tables to Improve Performance :
report zuseofhashedtables.
Program: ZUseOfHashedTables **
Author: XXXXXXXXXXXXXXXXXX **
Versions: 4.6b - 4.6c **
Notes: **
this program shows how we can use hashed tables to improve **
the responce time. **
It shows, **
1. how to declare hashed tables **
2. a cache-like technique to improve access to master data **
3. how to collect data using hashed tables **
4. how to avoid deletions of unwanted data **
Results: the test we run read about 31000 rows from mkpf, 150000 **
rows from mseg, 500 rows from makt and 400 from lfa1. **
it filled ht_lst with 24500 rows and displayed them in **
alv grid format. **
It needed about 65 seconds to perform this task (with **
all the db buffers empty) **
The same program with standard tables needed 140 seconds **
to run with the same recordset and with buffers filled in **
Objetive: show a list that consists of all the material movements **
'101' - '901' for a certain range of dates in mkpf-budat. **
the columns to be displayed are: **
mkpf-budat, **
mkpf-mblnr, **
mseg-lifnr, **
lfa1-name1, **
mkpf-xblnr, **
mseg-zeile **
mseg-charg, **
mseg-matnr, **
makt-maktx, **
mseg-erfmg, **
mseg-erfme. **
or show a sumary list by matnr - menge **
You'll have to create a pf-status called vista - **
See form set_pf_status for details **
tables used -
tables: mkpf,
mseg,
lfa1,
makt.
global hashed tables used
data: begin of wa_mkpf, "header
mblnr like mkpf-mblnr,
mjahr like mkpf-mjahr,
budat like mkpf-budat,
xblnr like mkpf-xblnr,
end of wa_mkpf.
data: ht_mkpf like hashed table of wa_mkpf
with unique key mblnr mjahr
with header line.
data: begin of wa_mseg, " line items
mblnr like mseg-mblnr,
mjahr like mseg-mjahr,
zeile like mseg-zeile,
bwart like mseg-bwart,
charg like mseg-charg,
matnr like mseg-matnr,
lifnr like mseg-lifnr,
erfmg like mseg-erfmg,
erfme like mseg-erfme,
end of wa_mseg.
data ht_mseg like hashed table of wa_mseg
with unique key mblnr mjahr zeile
with header line.
cache structure for lfa1 records
data: begin of wa_lfa1,
lifnr like lfa1-lifnr,
name1 like lfa1-name1,
end of wa_lfa1.
data ht_lfa1 like hashed table of wa_lfa1
with unique key lifnr
with header line.
cache structure for material related data
data: begin of wa_material,
matnr like makt-matnr,
maktx like makt-maktx,
end of wa_material.
data: ht_material like hashed table of wa_material
with unique key matnr
with header line.
result table
data: begin of wa_lst, "
budat like mkpf-budat,
mblnr like mseg-mblnr,
lifnr like mseg-lifnr,
name1 like lfa1-name1,
xblnr like mkpf-xblnr,
zeile like mseg-zeile,
charg like mseg-charg,
matnr like mseg-matnr,
maktx like makt-maktx,
erfmg like mseg-erfmg,
erfme like mseg-erfme,
mjahr like mseg-mjahr,
end of wa_lst.
data: ht_lst like hashed table of wa_lst
with unique key mblnr mjahr zeile
with header line.
data: begin of wa_lst1, " sumary by material
matnr like mseg-matnr,
maktx like makt-maktx,
erfmg like mseg-erfmg,
erfme like mseg-erfme,
end of wa_lst1.
data: ht_lst1 like hashed table of wa_lst1
with unique key matnr
with header line.
structures for alv grid display.
itabs
type-pools: slis.
data: it_lst like standard table of wa_lst with header line,
it_fieldcat_lst type slis_t_fieldcat_alv with header line,
it_sort_lst type slis_t_sortinfo_alv,
it_lst1 like standard table of wa_lst1 with header line,
it_fieldcat_lst1 type slis_t_fieldcat_alv with header line,
it_sort_lst1 type slis_t_sortinfo_alv.
structures
data: wa_sort type slis_sortinfo_alv,
ls_layout type slis_layout_alv.
global varialbes
data: g_lines type i.
data: g_repid like sy-repid,
ok_code like sy-ucomm.
selection-screen
"text: Dates:
select-options: so_budat for mkpf-budat default sy-datum.
"text: Material numbers.
select-options: so_matnr for mseg-matnr.
selection-screen uline.
selection-screen skip 1.
"Text: show summary by material.
parameters: gp_bymat as checkbox default ''.
start-of-selection.
perform get_data.
perform show_data.
end-of-selection.
FORM get_data *
form get_data.
select mblnr mjahr budat xblnr
into table ht_mkpf
from mkpf
where budat in so_budat. " make use of std index.
have we retrieved data from mkpf?
describe table ht_mkpf lines g_lines.
if g_lines > 0.
if true then retrieve all related records from mseg.
Doing this way we make sure that the access is by primary key
of mseg.
The reason is that is faster to filter them in memory
than to allow the db server to do it.
select mblnr mjahr zeile bwart charg
matnr lifnr erfmg erfme
into table ht_mseg
from mseg
for all entries in ht_mkpf
where mblnr = ht_mkpf-mblnr
and mjahr = ht_mkpf-mjahr.
endif.
fill t_lst or t_lst1 according to user's choice.
if gp_bymat = ' '.
perform fill_ht_lst.
else.
perform fill_ht_lst1.
endif.
endform.
form fill_ht_lst.
refresh ht_lst.
Example: how to discard unwanted data in an efficient way.
loop at ht_mseg.
filter unwanted data
check ht_mseg-bwart = '101' or ht_mseg-bwart = '901'.
check ht_mseg-matnr in so_matnr.
read header line.
read table ht_mkpf with table key mblnr = ht_mseg-mblnr
mjahr = ht_mseg-mjahr.
clear ht_lst.
* note : this may be faster if you specify field by field.
move-corresponding ht_mkpf to ht_lst.
move-corresponding ht_mseg to ht_lst.
perform read_lfa1 using ht_mseg-lifnr changing ht_lst-name1.
perform read_material using ht_mseg-matnr changing ht_lst-maktx.
insert table ht_lst.
endloop.
endform.
form fill_ht_lst1.
refresh ht_lst1.
Example: how to discard unwanted data in an efficient way.
hot to simulate a collect in a faster way
loop at ht_mseg.
filter unwanted data
check ht_mseg-bwart = '101' or ht_mseg-bwart = '901'.
check ht_mseg-matnr in so_matnr.
* note : this may be faster if you specify field by field.
read table ht_lst1 with table key matnr = ht_mseg-matnr
transporting erfmg.
if sy-subrc <> 0. " if matnr doesn't exist in sumary table
" insert a new record
ht_lst1-matnr = ht_mseg-matnr.
perform read_material using ht_mseg-matnr changing ht_lst1-maktx.
ht_lst1-erfmg = ht_mseg-erfmg.
ht_lst1-erfme = ht_mseg-erfme.
insert table ht_lst1.
else." a record was found.
" collect erfmg. To do so, fill in the unique key and add
" the numeric fields.
ht_lst1-matnr = ht_mseg-matnr.
add ht_mseg-erfmg to ht_lst1-erfmg.
modify table ht_lst1 transporting erfmg.
endif.
endloop.
endform.
implementation of cache for lfa1.
form read_lfa1 using p_lifnr changing p_name1.
read table ht_lfa1 with table key lifnr = p_lifnr
transporting name1.
if sy-subrc <> 0.
clear ht_lfa1.
ht_lfa1-lifnr = p_lifnr.
select single name1
into ht_lfa1-name1
from lfa1
where lifnr = p_lifnr.
if sy-subrc <> 0. ht_lfa1-name1 = 'n/a in lfa1'. endif.
insert table ht_lfa1.
endif.
p_name1 = ht_lfa1-name1.
endform.
implementation of cache for material data
form read_material using p_matnr changing p_maktx.
read table ht_material with table key matnr = p_matnr
transporting maktx.
if sy-subrc <> 0.
ht_material-matnr = p_matnr.
select single maktx into ht_material-maktx
from makt
where spras = sy-langu
and matnr = p_matnr.
if sy-subrc <> 0. ht_material-maktx = 'n/a in makt'. endif.
insert table ht_material.
endif.
p_maktx = ht_material-maktx.
endform.
form show_data.
if gp_bymat = ' '.
perform show_ht_lst.
else.
perform show_ht_lst1.
endif.
endform.
form show_ht_lst.
"needed because the FM can't use a hashed table.
it_lst[] = ht_lst[].
perform fill_layout using 'full display'
changing ls_layout.
perform fill_columns_lst.
perform sort_lst.
g_repid = sy-repid.
call function 'REUSE_ALV_GRID_DISPLAY'
exporting
i_callback_program = g_repid
i_callback_pf_status_set = 'SET_PF_STATUS'
is_layout = ls_layout
it_fieldcat = it_fieldcat_lst[]
it_sort = it_sort_lst
tables
t_outtab = it_lst
exceptions
program_error = 1
others = 2.
endform.
form show_ht_lst1.
"needed because the FM can't use a hashed table.
it_lst1[] = ht_lst1[].
perform fill_layout using 'Sumary by matnr'
changing ls_layout.
perform fill_columns_lst1.
perform sort_lst.
g_repid = sy-repid.
call function 'REUSE_ALV_GRID_DISPLAY'
exporting
i_callback_program = g_repid
i_callback_pf_status_set = 'SET_PF_STATUS'
is_layout = ls_layout
it_fieldcat = it_fieldcat_lst1[]
it_sort = it_sort_lst
tables
t_outtab = it_lst1
exceptions
program_error = 1
others = 2.
endform.
form fill_layout using p_window_titlebar
changing cs_layo type slis_layout_alv.
clear cs_layo.
cs_layo-window_titlebar = p_window_titlebar.
cs_layo-edit = 'X'.
cs_layo-edit_mode = space.
endform. " armar_layout_stock
form set_pf_status using rt_extab type slis_t_extab.
create a new status
and then select extras -> adjust template -> listviewer
set pf-status 'VISTA'.
endform. "set_pf_status
define add_lst.
clear it_fieldcat_lst.
it_fieldcat_lst-fieldname = &1.
it_fieldcat_lst-outputlen = &2.
it_fieldcat_lst-ddictxt = 'L'.
it_fieldcat_lst-seltext_l = &1.
it_fieldcat_lst-seltext_m = &1.
it_fieldcat_lst-seltext_m = &1.
if &1 = 'MATNR'.
it_fieldcat_lst-emphasize = 'C111'.
endif.
append it_fieldcat_lst.
end-of-definition.
define add_lst1.
clear it_fieldcat_lst.
it_fieldcat_lst1-fieldname = &1.
it_fieldcat_lst1-outputlen = &2.
it_fieldcat_lst1-ddictxt = 'L'.
it_fieldcat_lst1-seltext_l = &1.
it_fieldcat_lst1-seltext_m = &1.
it_fieldcat_lst1-seltext_m = &1.
append it_fieldcat_lst1.
end-of-definition.
form fill_columns_lst.
set columns for output.
refresh it_fieldcat_lst.
add_lst 'BUDAT' 10.
add_lst 'MBLNR' 10.
add_lst 'LIFNR' 10.
add_lst 'NAME1' 35.
add_lst 'XBLNR' 15.
add_lst 'ZEILE' 5.
add_lst 'CHARG' 10.
add_lst 'MATNR' 18.
add_lst 'MAKTX' 30.
add_lst 'ERFMG' 17.
add_lst 'ERFME' 5.
add_lst 'MJAHR' 4.
endform.
form fill_columns_lst1.
set columns for output.
refresh it_fieldcat_lst1.
add_lst1 'MATNR' 18.
add_lst1 'MAKTX' 30.
add_lst1 'ERFMG' 17.
add_lst1 'ERFME' 5..
endform.
Regards,
Ameet -
Creation of table in interactive form
hai,
any one can explain me the creation of table in interactive forms transcation code(sfp)
or any can send any material because i am new to this, how to build interactive forms
advance thanks.
regards,
shravanramidi .Hi,
TRy https://www.sdn.sap.com/irj/sdn/go/portal/prtroot/docs/library/uuid/cacb9a7d-0c01-0010-1281-be4962c9ab3e
Regards,
Shiva Kumar(Reward if helpful). -
Declare dynamic internal table during runtime error
Hi Gurus,
I have encounter a problem here. I would like to have several block of alv list output; for each customer open items details. Thus, i need to create dynamic internal table duirng runtime as i do not know how many customers that should be output before user enter from the selection screen field for customer code.
I tried to search in the forums and found this website [Runtime Declaration of Internal Table;.
But when i tried to execute it, i have an error. The field symbols that i passed into the call function REUSE_ALV_BLOCK_LIST_APPEND for parameter t_outtab does not match. May i know how do i go about it?
Or are there any other solutions to display this kind of reports? I ever think of using hierarchy list alv. But it does not match the requirement. I would like to display the total amount for each customer. Can hierarchy list able to do so? Or it can only display as the grand total at the end of the report? I think it would be best to display as alv block output.
Your help will be much appreciated. <offer removed by moderator>
Thanks
Edited by: Thomas Zloch on Oct 22, 2010 11:23 AMthe problem comes up, when there are fields in the table which represent numbers with decimals (type p). Best is to reference the field directly what comes from SAP. Replace the LOOP At idetails ... ENDLOOP with:
LOOP AT idetails INTO xdetails.
CLEAR xfc.
xfc-fieldname = xfc-ref_field = xdetails-name .
xfc-ref_table = p_table.
* xfc-datatype = xdetails-type_kind.
* xfc-inttype = xdetails-type_kind.
* xfc-intlen = xdetails-length.
* xfc-decimals = xdetails-decimals.
APPEND xfc TO ifc.
ENDLOOP. -
Significance of Initial (intial_extent)parameter while creation of table
Hi All,
I am designing a new schema for my 10g database and I am in process of creation of tablespaces and tables.
My Tablespace are extent management local autoallocate and auto segment space management.
With “segment space management Auto”, I understand that I don’t have to define storage clause in tablespace and freelist will be taken care by bitmap
My question is
while creation of tables what’s the significance of Intial (intial_extent in user_tables) parameter.?
Do I need to consider this parameter while defining large and small tables?
Is this not controlled by “auto segment space management.” Parameter of tablespace.?While it is unlikely to make a measurable impact on anything in practice, it is almost always preferable in theory, assuming perfect knowledge of the system, to have a few different tablespaces with different uniform extent sizes and to put each object in the appropriate tablespace for its size (i.e. giant tables in the tablespace with giant extent sizes, tiny tables in the tablespace with tiny extent sizes, etc.). The problem with this, however, is that you very rarely have perfect knowledge in advance about object sizes and growth and size patterns are likely to evolve over the life of the system, so you can suck up a great deal of DBA and developer time gathering and maintaining this sort of information as well as responding to changes over time (i.e. moving objects from one tablespace to another as their usage patterns change). For most systems, the potential benefit to having a perfect setup, rather than putting everything in an AUTOALLOCATE tablespace, is far smaller than the cost of actually doing so.
Unless you have some reason to believe that your application is in the minority where squeezing the last bit of storage efficiency is worth the hassle, I'd tend to suggest throwing everything in an AUTOALLOCATE tablespace.
Justin
Maybe you are looking for
-
Hi I have the followig problem: We create Sale orders through VA01. Then whe run a Batc input that reads transaccion VF06. The fact is that some Sale ordors are wrong (price, quantity etc) and the batch creates the Invoice. Then we reverse the docume
-
I am trying to delete the icons that websites use which are located in the user file of appdata/local/mozilla, and the website adresses that are located at the bottom of the thumbnails when opening a new tab. clearing data deletes the actual thumbnai
-
Mapping JDBC lookup: Passing values to multiple fields at target
Hi all i my scenario i am using mapping JDBC lookup ,and it is working sucessfully. but i need to select 4 fields from lookups select query and passing it to 3 different target field at target MT. if i use Global container object methods,than only 1
-
Travel Expenses and General Claims
Hi All, Please advise how to configure travel expense types and general expense types in SPRO differently. In our project, we have different screens in portal for travel expenses and general claims. Now for the client to see the expense types differe
-
Can someone tell me what are the specs for a fully charged new battery for a 2008 MB (aluminum)? i.e. full charge capacity, voltage, amperage, etc. My current battery shows 3276 charge capacity, 12419 volts, 0 amperage, 551 cycles. It used to say "re