Dynamic table with field type table
Hi,
I´m using "cl_alv_table_create=>create_dynamic_table" to create a dynamic table for ALV Grid.
But...I need to use colors in ALV, then I need to declare a field type LVC_S_SCOL in dynamic table from "cl_alv_table_create=>create_dynamic_table".
How can I declare this in fieldcat?
The code:
Creating dynamic table
DATA: table_agrup TYPE REF TO data,
line_agrup TYPE REF TO data.
CALL METHOD cl_alv_table_create=>create_dynamic_table
EXPORTING
it_fieldcatalog = t_fieldcat
IMPORTING
ep_table = table_agrup
EXCEPTIONS
generate_subpool_dir_full = 1
OTHERS = 2.
ASSIGN table_agrup->* TO .
Printing ALV
CALL METHOD obj_grid->set_table_for_first_display
EXPORTING
is_variant = w_variant
i_save = 'A'
is_layout = w_layout
CHANGING
it_outtab =
it_fieldcatalog = t_fieldcat
it_sort = t_sort
EXCEPTIONS
invalid_parameter_combination = 1
program_error = 2
too_many_lines = 3
OTHERS = 4.
Thanks.
It is not possible with the METHOD cl_alv_table_create=>create_dynamic_table to include another table inside that newly generated table.
I have tried to do it with the code and I got the dynamic table created after at the end of the program.
In the code,
<DYN_TABLE> has same effect as your <table> variable
<DYN_WA> has same effect as your <HEADER>
REPORT ZTEST_NP_DYNAMIC.
DATA: DY_TABLE TYPE REF TO DATA,
DY_LINE TYPE REF TO DATA.
FIELD-SYMBOLS: <DYN_TABLE> TYPE STANDARD TABLE,
<DYN_WA>,
<DYN_FIELD>.
FIELD-SYMBOLS: <FS> TYPE ANY.
* To generate the Dyanmic table with the COLOR
DATA: LS_SOURCE TYPE STRING.
DATA: LT_SOURCE LIKE STANDARD TABLE OF LS_SOURCE WITH HEADER LINE.
DATA: L_NAME LIKE SY-REPID.
DATA: L_MESSAGE(240) TYPE C,
L_LINE TYPE I,
L_WORD(72) TYPE C.
DATA: L_FORM(30) TYPE C VALUE 'TABLE_CREATE'.
LT_SOURCE = 'REPORT ZTEST_SUBROUTINE_POOL.'.
APPEND LT_SOURCE.
LT_SOURCE = 'FORM TABLE_CREATE USING I_FS TYPE ANY.'.
APPEND LT_SOURCE.
LT_SOURCE = 'DATA: BEGIN OF LT_GENTAB OCCURS 0.'.
APPEND LT_SOURCE.
LT_SOURCE = 'DATA: BUKRS TYPE BUKRS. '.
APPEND LT_SOURCE.
LT_SOURCE = 'DATA: BKTXT TYPE BKTXT. '.
APPEND LT_SOURCE.
* you can add your fields here.....
LT_SOURCE = 'DATA: COLOR TYPE lvc_t_scol. '.
APPEND LT_SOURCE.
LT_SOURCE = 'DATA: END OF LT_GENTAB.'.
APPEND LT_SOURCE.
LT_SOURCE = 'DATA: POINTER TYPE REF TO DATA.'.
APPEND LT_SOURCE.
LT_SOURCE = 'CREATE DATA POINTER LIKE STANDARD TABLE OF LT_GENTAB.'.
APPEND LT_SOURCE.
LT_SOURCE = 'I_FS = POINTER.'.
APPEND LT_SOURCE.
LT_SOURCE = 'ENDFORM. '.
APPEND LT_SOURCE.
L_NAME = 'ZTEST_SUBROUTINE_POOL'.
CATCH SYSTEM-EXCEPTIONS GENERATE_SUBPOOL_DIR_FULL = 9.
GENERATE SUBROUTINE POOL LT_SOURCE NAME L_NAME
MESSAGE L_MESSAGE LINE L_LINE WORD L_WORD. "#EC CI_GENERATE
ENDCATCH.
IF NOT L_MESSAGE IS INITIAL.
MESSAGE E000(0K) WITH L_MESSAGE L_LINE L_WORD.
ENDIF.
ASSIGN DY_TABLE TO <FS>.
PERFORM (L_FORM) IN PROGRAM (L_NAME) USING <FS>.
ASSIGN DY_TABLE->* TO <DYN_TABLE>.
* Create dynamic work area and assign to FS
CREATE DATA DY_LINE LIKE LINE OF <DYN_TABLE>.
ASSIGN DY_LINE->* TO <DYN_WA>.
Write: 'bye'.
Regards,
Naimesh Patel
Similar Messages
-
Loop at table with unspecified type but with where-condition
Hi,
Doing a loop over an internal table with unspecified type and in addition using a condtion may be done as follows: Thereby the
condition would be "... WHERE parentid EQ i_nodeid" if the type of <it_htab> would be static. However dynamic specification of a component through bracketed character-type data objects is not possible.
FIELD-SYMBOLS: <it_htab> TYPE STANDARD TABLE,
<wa_htab> TYPE ANY,
<parentid> TYPE rsparent.
ASSIGN me->ref_htab->* TO <it_htab>.
LOOP AT <it_htab> ASSIGNING <wa_htab>.
ASSIGN COMPONENT 'PARENTID' OF STRUCTURE <wa_htab> TO <parentid>.
CHECK <parentid> EQ i_nodeid.
ENDLOOP.
Since you have to loop over the whole table and to check within the loop whether the condition is fullfilled, this is rather bad for performance.
Questions: Are there any tricks to do this better?
Best Regards and Thank you,
Ingo>
Lalit Mohan Gupta wrote:
> you can put the condition in the where clause....
only if you have the upcoming 7.0 EhP2 (Kernel 7.02 or 7.20) the following dynamic where works:
DATA cond_syntax TYPE string.
cond_syntax = `parentid = i_nodeid`.
LOOP AT <it_htab> ASSIGNING <wa_htab>
WHERE (cond_syntax).
in older releases you would have to use program generation to achieve a dynamic where... .
Kind regards,
Hermann -
Table with fields containig more thn 300 characters
Hello Friends,
i want to create one ZTABLE and intht i want a field tht can store more thn 300 characters.
i have used string data type for the same but while activating the table its giving me error saying :
" Table contains more than 3 long string fields"
Pls suggest...
Sunnyhi
sunny ,
You can create table with field more than 300 characters but there should be one more field
which has to be primary key .
such as
create table ztest
in that create field MANDT type clnt size 3 primary key
name type String .
then change technical settings according to requirement .
Delivery maintenance
delivery class and Data Browser/Table View M
according to requirement .
Before activating table save technical setting and then activate .
Regards
deepak -
How to create an internal table with fields from different sources
Hi.
I need to create an internal table where some of the fields are from a database table, and the other fields are user specified. How do i do that?
Example:
DB table ZTAB with fields ZTAB-FIELD1, ZTAB-FIELD2.
I want to create an internal table ITAB with the fields ZTAB-FIELD1, ZTAB-FIELD2 from ZTAB. In addition, I also want to have one more field RECORD_NO, which is not from ZTAB. How do I do it? Could I do something like below?
DATA BEGIN OF ITAB.
INCLUDE STRUCTURE ZTAB.
DATA RECORD_NO TYPE I.
DATA END OF UPLINE.
Or, are there more efficient way of doing it? Thanks.hi KIan,
go:
general type
TYPE : BEGIN OF ty_itab,
field1 TYPE ztab-field1,
field2 TYPE ztab-field2,
*your own fields here:
field TYPE i,
field(30) TYPE c,
END OF ty_itab.
work area
DATA : gw_itab TYPE ty_itab.
internal table
DATA : gt_itab TYPE TABLE OF ty_itab.
hope this helps
ec -
Import from database an internal table with generic Type : Web Dynpro ABAP
Hi everyone,
i have a requirement in which i'm asked to transfer data flow between two frameworks, from WD Component to another. The problem is that i have to transfer internal tables with generic types. i used the import/ export from database approache but in that way i get an error message saying "Object references and data references not yet supported".
Here is my code to extract a generic internal table from memory.
DATA l_table_f4 TYPE TABLE OF REF TO data.
FIELD-SYMBOLS: <l_table_f4> TYPE STANDARD TABLE.
DATA lo_componentcontroller TYPE REF TO ig_componentcontroller .
DATA: ls_indx TYPE indx.
lo_componentcontroller = wd_this->get_componentcontroller_ctr( ).
lo_componentcontroller->fire_vh_search_action_evt( ).
ASSIGN l_table_f4 TO <l_table_f4>.
*-- Import table for Help F4
IMPORT l_table_f4 TO <l_table_f4> FROM DATABASE indx(v1) TO ls_indx ID 'table_help_f4_ID'.
The error message is desplayed when last instruction is executed " IMPORT l_table_f4...".
I saw another post facing the same problem but never solved "Generic Type for import Database".
Please can anyone help ?
Thanks & Kind regards.hi KIan,
go:
general type
TYPE : BEGIN OF ty_itab,
field1 TYPE ztab-field1,
field2 TYPE ztab-field2,
*your own fields here:
field TYPE i,
field(30) TYPE c,
END OF ty_itab.
work area
DATA : gw_itab TYPE ty_itab.
internal table
DATA : gt_itab TYPE TABLE OF ty_itab.
hope this helps
ec -
Sorting internal table with line types
Hi,
I have internal table juts for an example with four entries as below:
A[]
Line.....Line Types
444001.....P
New York...C
Evershine..B
Mary.......N
I want to sort the internal table with line types in order of lin types NBCP.
How can i do this ?
Please help.
Note: Above example is just with four entries, there might be internal table with ten entries and ten defined sorting order for line types.Hi Tushar,
Please note that we can't changes the mandatory sequence of the address format as defined in the country specif address format. We can change the sequence of others fields by line_priority.
Try to change the address type :
ADDRESS_TYPE - Address type (from 3.0C)
There are three types of address:
Address type '1': addresses of firms or organizations; the address structure which is used in most SAP applications as 'Address'.
Address type '2': address of a person
Address type '3': work address, usually the address of a contact person in a company
Please use T/code "OY01"> Select Country> Example :AU"--> Display --> Select address key and press F1. You will find SAP 's Address format configuration .
sap help:
Formatting Routine Key for Printing Addresses
For printing addresses, there are country-specific routines which in each case copy the correct postal formatting of the address.
The three-character "Address Layout Key" for the recipient country controls which of the routines available for formatting addresses in the relevant country is used.
These routines are programmed into the ADDRESS_INTO_PRINTFORM function module.
They are based on different national and international guidelines and norms, including:
ISO 11180,
contracts of the World Postal Union (Seoul 1994),
international address samples from the World Postal Union
as well as the available rules of the individual countries.
Below you will find an overview of the country-specific formats currently implemented.
Customers can program their own formatting routines using a customer exit. The SZAD0001 SAP enhancement has been defined in the package SZAD for this (-> transaction CMOD).
General formatting rules
The following parameters are used depending on the transaction:
whether the company address (street/house number) or the P.O. Box address is printed if both exist,
how many lines are available for printing,
which is the sender country.
If there are not enough lines, then lines are left out according to a standard sequence.
The address format depends on whether the sender country is the same as, or different from, the recipient country. The country is always specified from abroad, either as a text name, or as an identification code of up to three characters (license plate code or country key).
Where the country name is written out in full, it is written in the language of the sender country. If a language is not specified for the sender country, or the sender country itself is not specified, the logon language is used instead.
Exception: the language for the country code can be explicitly overwritten by a parameter in the print program (e.g. when the country code for customs transit papers is always to be specified in a particular language, such as English). if the "Print country name in recipient language" flag is set in the print program, the recipient language is used.
Other language-dependent components such as the title and the word 'PO Box' are printed in the recipient language or the recipient country language. If this cannot be determined, the logon language is again used.
For all formats except Great Britain (006), Japan (013), and South Korea (017), the core of the address is formatted as follows (without empty lines, except for the compulsory empty line:)
title line (if applicable)
name block (differs depending on the address type, see below)
street address or PO Box
(compulsory empty line, if applicable)
city line with postal code
country code (if applicable)
The city line and the country name are always printed in upper case for foreign addresses (only for the complete address, not for short forms).
The name block generally consists of the following:
"Normal" addresses (address type SPACE and address type 1):
NAME1
NAME2
NAME3
NAME4
Personal addresses (address type 2):
Title of person and name of person
Business address with department and contact person (address type 3):
NAME1
NAME2
NAME3
NAME4
department
title of person and name of person
In addresses entered using Business Address Services (central address management) (see Release notes Central Address Management for Release 4.0 and Central Address Management for Release 4.5 ), the street address can comprise several lines (see Print street address), otherwise street and house number are maintained in the Street field.
Some countries do not have a compulsory empty line (see notes below). The city and district are printed in the city line, connected by a hyphen (exceptions: 004 USA, 006 Great Britain/Ireland, 013 Japan, 015 Germany, 017 South Korea, 019 Denmark), provided that the total length does not exceed 35 characters. If a different city is specified for the PO Box (PFORT), this is used in the PO Box address.
In all formats which use a country code (currently 001 European standard format 002 Italy, 011 Switzerland and 014 Austria ), the license plate code for that country is used. If this is not maintained, the country key in table T005 is used.
If the "Print country name in foreign addresses" flag is set for the sender country in table 005, the country code is not used; the country name is printed in the last line of the address.
Formats 004 (USA), 005 (Canada) and 008 (Singapore) contain a line ('F') for the function of the contact person in the company (if address type = '3'). This line comes immediately after the line 'N' (Name (and title) of the natural person).
In formats 002 (Italy), 004 (USA), 005 (Canada), 006 (Great Britain), 007 (Brazil) and Australia (009), the REGIO field (Region, State, Province, County) is formatted. For the USA, Canada, Brazil and Australia, the key from table T005S is used; for Great Britain the text name from table T005U.
In all countries for which no "Address structure key" is maintained, a standard format is used which corresponds to format "010".
Hope this may help you.
Lanka -
How to create table with row type in smart forms
How to create table with row type in smart forms with out line type
please explain me the procedureHI,
A table type describes the structure and functional attributes of an internal table in ABAP. In ABAP programs you can reference a table type TTYP defined in the ABAP Dictionary with the command DATA <inttab> TYPE TTYP. An internal table <inttab> is created in the program with the attributes defined for TTYP in the ABAP Dictionary.
A table type is defined by:
its line type, that defines the structure and data type attributes of a line of the internal table
the options for managing and accessing the data ( access mode) in the internal table
the key ( key definition and key category) of the internal table
The row type is defined by directly entering the data type, length and number of decimal places or by referencing a data element, structured type ( structure, table or view) or other table type. Or the row type can be a reference type.
<b>for more info :</b> http://help.sap.com/saphelp_nw2004s/helpdata/en/fc/eb366d358411d1829f0000e829fbfe/content.htm
Internal table
Regards
Sudheer -
Creating dynamic internal table(Not field symbol table)
Hi Experts,
I am facing problem creating Intarnal table
I have fieldcatalog, I want create dynamic internal table(Not field symbol table).
I have written----
CALL METHOD cl_alv_table_create=>create_dynamic_table
EXPORTING
i_style_table =
it_fieldcatalog = it_fldcat
it_fieldcatalog = me->gt_fieldcat
i_length_in_byte =
IMPORTING
ep_table = lt_new_table
e_style_fname =
EXCEPTIONS
generate_subpool_dir_full = 1
OTHERS = 2.
ASSIGN lt_new_table->* TO <gt_dyn_repdata>.
CREATE DATA ls_new_line LIKE LINE OF <gt_dyn_repdata>.
ASSIGN ls_new_line->* TO <gs_dyn_repdata>.
above logic creating dynamic field symbol table.... But I want create normal internal table.
Thanks,
RajasekharHi
What do you mean?
It needs to use the field-symbol, this is the price to pay if it wants a dynamic object
Max -
Hi,
I need to put a table with in a Table pop in. I am able to achieve the table but the I am unable to display different data for each pop in. action.
Example.
Table has 3 records
Row 1
Row 2
Row 3
On expanding Row1 using pop in I am able to display the table.
On expanding Row 2, leaving Row 1 expanded, changes the data in both the Areas, showing data of Row 2.
Could you please help in resolving the issue.Hi Prasanth,
To display different data inside the table popin, create child node inside the parent node.
Parent_node(0....n)
Child_node( 0....n )
Create a supply function for CHILD_NODE and on select of any row in parent table, write the logic to fill data of child node . Bind this child node to TABLE_POPIN's table
Now, if you select row1, you can fill child node in supply function and it populates the data,
similarly, it works for other rows as well
Hope this helps you.
Regards,
Rama -
The table with Name of 'Table Name' does not exist.An error occurred when loading the Model.
We get this error when we try to check the properties of an analysis server using SQL Server Management studio(right click the instance name
and check properties). We have resolved this issue twice by Stopping the SQL Server analysis service,removing db folders from Analysis Server Data folder and starting the services back on. The db folder that we removed was advised by the BI team.
The SQL Server Analysis Server is 2012 SP1Hi RB_ORIPW,
The table with name of 'XXX' doesn't exist.
An error occurred when loading the model(Micorsoft.AnalysisServices)
If I understanding correctly, you encounter the error randomly, now what you want it that avoid this issue completely, other than stop the services, detele the db filder and restart the services, right?
The error might be caused by that the data file is corrupted. However, we cannot give you the exact reason that cause this issue. You can troubleshoot this issue by using the Windows Event logs and msmdsrv.log.
You can access Windows Event logs via "Administrative Tools" --> "Event Viewer". SSAS error messages will appear in the application log.
The msmdsrv.log file for the SSAS instance that can be found in \log folder of the instance. (C:\Program Files\Microsoft SQL Server\MSAS10.MSSQLSERVER\OLAP\Log)
Here is a blog about data collection for troubleshooting Analysis Services issues, please see:
Data collection for troubleshooting Analysis Services issues
Besides, here is fix that describe the similar issue, and it was fixed in Cumulative Update 7 for SQL Server 2012 SP1, please refer to the link below to see the details.
http://support.microsoft.com/kb/2897263/en-us
Regards,
Charlie Liao
If you have any feedback on our support, please click
here.
Charlie Liao
TechNet Community Support -
How to change Table Cell Field Type Dynamically?
Hi All,
I am fetching some news data from backend DB and displaying them in a WD Table. Now one News Item may or may not have a URL behind it. If I find the URL as null then I want to display the news as simple TextView otherwise as LinkToUrl. How can I change this input type dynamically for each row in the runtime?
If I use LinkToUrl all the time then the items which has URL as null gets displayed as normal text, but they are of very faint color and I can not change the text design. Whether if I user TextView I can set some text design like Header2, Header 3 etc.
Can anybody please help with some code block? My main requirement is how to change the table cell input type dynamically.
Thanks in Advance.
ShubhadipHi Shubhadip,
This is the sample code for creating and adding a table cell editor table dynamically.
public static void wdDoModifyView
(IPrivateDynamicTableCreationView wdThis, IPrivateDynamicTableCreationView.IContextNode wdContext, com.sap.tc.webdynpro.progmodel.api.IWDView view, boolean firstTime)
//@@begin wdDoModifyView
/*** 1.Create Table **/
IWDTable table =
(IWDTable) view.createElement(IWDTable.class, "table1");
table.setWidth("100%");
table.setVisibleRowCount(data.length);
/*** 2.Create nameColumn **/
IWDTableColumn nameColumn =
(IWDTableColumn) view.createElement(IWDTableColumn.class, "Name");
IWDCaption colHeader =
(IWDCaption) view.createElement(IWDCaption.class, "NameHeader");
colHeader.setText("¼O");
nameColumn.setHeader(colHeader);
IWDTextView nameViewer =
(IWDTextView) view.createElement(IWDTextView.class, "NameViewer");
nameViewer.bindText(nameAtt);
IWDTableCellEditor editor = (IWDTableCellEditor) nameViewer;
nameColumn.setTableCellEditor(editor);
table.addColumn(nameColumn);
IWDTableColumn nationalityColumn =
(IWDTableColumn) view.createElement(
IWDTableColumn.class,
"Nationality");
IWDTableCellEditor nationalityEditor =
(IWDTableCellEditor) nationalityViewer;
nationalityColumn.setTableCellEditor(nationalityEditor);
table.addColumn(nationalityColumn);
/** 3. Bind context to table **/
table.bindDataSource(nodeInfo);
//@@end
Bala
Kindly reward appropriate points. -
Dynamic Internal table with field symbol
I made the report where the user enters two different tables and two fields that are to be compared.
Eg. If I enter (MARA & NAME1) and (MARC & NAME2) , I wish to compare all the entries of Mara-name1 against all entries in Marc-name2.
<u>The code I need to write is:</u>
DATA:
gdo_data TYPE REF TO data.
DATA:
gdo_data1 TYPE REF TO data.
FIELD-SYMBOLS:
<gt_itab> TYPE table,
<wa> LIKE <gt_itab>, "<gt_itab>,
<gs_entry> TYPE ANY.
FIELD-SYMBOLS:
<gt_itab1> TYPE table,
<wa1> LIKE <gt_itab>, "<gt_itab>,
<gs_entry1> TYPE ANY.
PARAMETERS:
p_table TYPE tabname, " DEFAULT 'KNA1',
p_fld TYPE fieldname. " DEFAULT 'KUNNR'.
PARAMETERS:
p_table1 TYPE tabname, " DEFAULT 'KNA1',
p_fld1 TYPE fieldname.
DATA: var TYPE fieldname.
var = p_fld.
DATA: var1 TYPE fieldname.
var1 = p_fld1.
START-OF-SELECTION.
CREATE DATA gdo_data TYPE TABLE OF (p_table).
ASSIGN gdo_data->* TO <gt_itab>.
CREATE DATA gdo_data1 TYPE TABLE OF (p_table1).
ASSIGN gdo_data1->* TO <gt_itab1>.
SELECT * FROM (p_table) INTO CORRESPONDING FIELDS OF TABLE <gt_itab>.
SELECT * FROM (p_table1) INTO CORRESPONDING FIELDS OF TABLE <gt_itab1>.
<b> LOOP AT <gt_itab> ASSIGNING <gs_entry>.
READ TABLE <gt_itab1> ASSIGNING <gs_entry1>
WITH KEY (var1) = <gt_itab>-(var).
IF sy-subrc EQ 0.
MESSAGE 'Success' TYPE 'S'.
ENDIF.
ENDLOOP.</b>
END-OF-SELECTION.
But the portion in bold is creating error: <b><gt_itab> is a table without a header lineand therefore has no component called "".</b>
please help.Hi Amit
Try like this
LOOP AT <gt_itab> ASSIGNING <gs_entry>.
READ TABLE <gt_itab1> ASSIGNING <gs_entry1>
WITH KEY (var1) = <b><gs_entry></b>-(var).
IF sy-subrc EQ 0.
MESSAGE 'Success' TYPE 'S'.
ENDIF.
ENDLOOP.
Regards,
Atish -
Dynamic ITAB copy problem with field type P
Hello everyone
I need to copy the structure of an internal table that is pass by reference into a method.
Actually everything is fine else than the field type P with decimal is not created properly in the new itab.
Scenario:
An internal table is pass by reference to a method. We need to trait the data without modifying the original table. The Idea is to copy the structure and the data of the referenced internal table into an internal table created dymanically in the method.
Here is what I did and working fine when there are no field of data type "CURR".
Extract the structure of the reference data.
Create a dynamic internal table.
So far so good. Everything seams to work fine. BUT
when I am trying to copy the data from the reference table to the just created internal table the field with data type "CURR" doesn't work.
Here is my example:
FIELD-SYMBOLS: <FS_TABLE> TYPE STANDARD TABLE,
<TMP_TABLE> TYPE STANDARD TABLE,
<LS_TMP_TABLE> TYPE ANY,
<LS_TABLE> TYPE ANY,
<LS_VALUE> TYPE ANY.
DATA: lt_data TYPE STANDARD TABLE OF vbak,
ls_data LIKE LINE OF lt_sortfield,
ref_data TYPE REF TO data,
l_structure TYPE REF TO DATA,
lv_ltname TYPE string.
select * from vbak UP TO 10 rows INTO CORRESPONDING FIELDS OF TABLE lt_data.
* --- Assign the reference variable to the table
* ---- Only use to simulate a parameter that is assign to a reference to a internal table
unassign <FS_TABLE>.
lv_ltname = 'lt_data[]'.
ASSIGN (lv_ltname) to <FS_TABLE>.
GET REFERENCE OF <FS_TABLE>[] INTO ref_data.
* --- Assign the reference to the field-symbol
UNASSIGN <FS_TABLE>.
ASSIGN ref_data->* TO <FS_TABLE>.
* --- Create a working area for the reference table to a field-table
CREATE DATA l_structure LIKE LINE OF <FS_TABLE>.
ASSIGN l_structure->* TO <LS_TABLE>.
* --- Retrieve the structure of the field-symbol pointing to the internal table
DATA: lr_tabledescr TYPE REF TO cl_abap_tabledescr, " Internal Table description
_r_structdescr TYPE REF TO cl_abap_structdescr.
lr_tabledescr ?= cl_abap_tabledescr=>describe_by_data( <fs_table> ).
_r_structdescr ?= lr_tabledescr->get_table_line_type( ).
* --- Read internal table structure to create dynamic internal table
data: ls_struc like LINE OF _r_structdescr->components,
xfc type lvc_s_fcat,
ifc type lvc_t_fcat.
* --- Why the field (component) NETWR length is now 8 instead of 15?
LOOP AT _r_structdescr->components into ls_struc.
clear xfc.
xfc-fieldname = ls_struc-name .
xfc-datatype = ls_struc-type_kind.
xfc-inttype = ls_struc-type_kind.
xfc-intlen = ls_struc-length.
xfc-decimals = ls_struc-decimals.
append xfc to ifc.
ENDLOOP.
DATA: dy_table type ref to data,
* --- Create dynamic internal table
call method cl_alv_table_create=>create_dynamic_table
EXPORTING
it_fieldcatalog = ifc
IMPORTING
ep_table = dy_table.
* --- assign reference internal table to Field-symbol
assign dy_table->* to <tmp_table>.
unassign <ls_tmp_table>.
DATA: ls_tmp_struc type REF TO DATA.
CREATE DATA ls_tmp_struc like LINE OF <tmp_table>.
ASSIGN ls_tmp_struc->* TO <ls_tmp_table>.
Loop at <fs_table> INTO <LS_TABLE>.
MOVE-CORRESPONDING <ls_table> TO <ls_tmp_table>.
APPEND <ls_tmp_table> TO <tmp_table>.
ENDLOOP.
* <fs_table>-netwr length is 15
* <ls_tmp_table>-netwr length is 8
* ??????????? Why the length is different?
* ??????????? It should a structure copy and have the
* ??????????? same length
I use VBAK as example, and the field NETWR is using data type "NETWR_AK" where it us a data type "CURR" with length 15 and decimal 2.
When reading the structure, the method get_table_line_type of the class cl_abap_tabledescr return a length of 8 instead of 15.
Any idea how to get the exact structure of a variable that is refering to a data type?
Regards
DanielHello Everyone
Thank you for your replies.
I think I didn't explain myself clearly.
My goal is to be able to create an exact structure copy of a "Type ref to data" into a new internal table that is not defined yet.
Example:
A method contain a parameter that is a ref to DATA type.
That parameter is refering to an internal table from the calling program.
Now I want to create an internal table into the method where this one will be an exact structure copy of the parameter.
So, lets put some name here.
parameter: ip_data type ref to data.
FIELD-SYMBOLS: <FS_REF_DATA> TYPE STANDARD TABLE,
<FS_CP_DATA> TYPE STANDARD TABLE.
ASSIGN ip_data->* TO <FS_REF_DATA>.
" some code to assign the same structure to <FS_CP_DATA> from <FS_REF_DATA>
" than copy the data from <FS_REF_DATA> to <FS_CP_DATA>.
<FS_CP_DATA> [ ] = <FS_REF_DATA> [ ]. " This is working if no type P with decimal exist into the structure
" Than I can play with the data of <FS_CP_DATA> without modifying the data of <FS_REF_DATA>.
My problem would be solved if I can create dynamically an internal table that has an exact structure copy of the passed parameter.
Regards
Daniel -
AMDP exporting table with fields from various sources
I am writing an AMDP that has an output table a list of employees and attributes. These attributes have various sources with various keys. If I cannot with any practicality construct this table with a single select statement, which given my search criteria, I probably can't, must I break my output table into multiple output tables that can be created with a single select?
I declare the structure of output table et_employees in the class as something like
BEGIN OF ty_employee,
emp_id(12) TYPE c,
emp_name(80) TYPE c,
org_unit(8) TYPE c,
region(5) TYPE c,
country(3) TYPE c,
jb_prf_as TYPE c,
sol_gr_as TYPE c,
snippet(1000) TYPE c,
score TYPE integer,
END OF ty_employee,
tt_employes type table of ty_employee.
As far as I can tell, I cannot do an update et_employees in the method to modify individual fields. I can only do the select statement.
I see my choices as
elaborate select statement that I may or may not be able to construct (haven't thought this through but it may be doable)
more than one output table
create multiple local tables and then do a join on them for the output table.
I am seeing the last one as my best option.
To throw in an unrelated issue, AMDP procedure cannot seem to cope with a table that begins with a slash, e.g., /MRSS/D_SQP_ESTR. The USING statement is o.k. but any access in a select or inner join gets an error.Hi Deborah,
let me do some assumptions on your problem and then try to help you:
Assumption A: You only like to query data from tables, which, I simply assume, are available in the ABAP data dictionary. In this case, I don't think there is a performance gain with AMDPs compared to OpenSQL, so just use OpenSQL and do joins on the relevant tables, leading to exaclty one resultset in the output.
Assumption B: You need the AMDP because you have a good reason and you like to query data from tables employee_source_a and employee_source_b for your resultset. In case yes, you can e.g. use "temporary" tables (don't declare them explicitly), e.g. use the construct like:
lt_employee_source_a = select ...from employee_source_a ...;
lt_employee_source_b = select ... from employee _source_b...;
et_employee = select ... from :lt_employee_source_a ... (inner/left outer) join lt_employee_source_b on...;
Or you could use the CE_JOIN function if that suits your SQLScript development better.
To elaborate a query statement for et_employee for without the lt_xxx tables is hard to say from your question - it should be posible if there are no nasty aggregations/calculations which prevent it :-).
There's no need to use two resultsets in the output in case that's not what you need in the application.
The option to have several resultsets is rather a feature of DB Procedures, which allow for several resultsets while a view/OpenSQL query can only give you one resultset.
Conclusion: You answered your question yourself, the last option seems to be the best option :-).
Concerning the "slash issue": Guessing around I'd propose to use quote the table name like "/MRSS/D_SQP_ESTR"... but just a guess. Could you please post the error message or open a second discussion on the issue?
Cheers,
Jasmin -
How to enter values to a database table with data type 'LCHR'?
Hello All,
I have created a database table with five fields, of which the last field is 'Value' field in which i have to enter text with a maximum of 1000characters. I have also specified a 'Length' field preceding the 'Value' field.
The datatype specified for the 'Length' field is 'INT2' and for the value field is 'LCHR' with length 1000.
When i tried inserting values to the table through a report, the report is giving an error that 'Literals that take up more than one line are not permitted', which means 255characters.
Also, when i entered a short text which is less than 250 characters to the 'Value' field,, the report is working fine and the table entry is visible.
Can anyone help me in this?
It would be really helpful if you explain how to use 'LCHR' data type in tables and how to enter values to such a field with more than 255characters.
Thanks in Advance,
ShinoHi shino,
Alternatively,
you can use STRING instead of LCHR.
I too have tried with LCHR and am facing the same issue.. i am not sure why its coming..
i have tried STRING and its working perfectly.
wa-key_field = 'IN4'.
CONCATENATE 'Long text over 200 chars length '
'another Long text over 200 chars length '
'another Long text over 200 chars length '
INTO wa-long_text.
wa-len = strlen( wa-long_text ).
INSERT zshino_table from wa.
SELECT * FROM zshino_table INTO table it.
clear wa.
LOOP AT it INTO wa.
WRITE:/ wa-len, ' ' , wa-long_text.
ENDLOOP.
Also, remember to set the type of the database field as String.
hope this was of some help,
thanks and regards,
Sagar.
Maybe you are looking for
-
My OD is down because the CA athority can't be found. I'm running 10.8.5 with Server 2.2.x OD won't start anymore. I replaced the Certificate with a new valid one. But i can't assign the Cert to OD again. How te resolve this.
-
i´d like pay for music, but no for a filee!!!! it`s ok, i like the music, i pay for!!!!!
-
Newbie: How to import text
Hi CS4, AS2 or AS3 (haven't decided which on to use) I have text stored in a Sql Server 2005 database, and this text I want displayed inside a textfield in flash movie. Any ideas how to accomplish this? any guidens whould be great
-
Data source | Clarification Required
hi, I have created a report in CR designer using oracle as datasource. Now i need to add other datasource like text files or excel or xml. I can able to create report using it in CR designer. When i launch it in CR viewer it was throwing unexpected D
-
Video formats compatible with iPhone
I have some video files that will sync with iPhone and some will not. Looks like mp4 will and WMV will not. What formats will iPhone accept, and how can I change the wmv's to be compatible. Thanks.