How to create alv table dynamically by performing action on the button.
Hi all,
my requirement is to create alv table dynamically.
that is i will create two buttons
1) show alv table
2) close alv table
if user selects show alv table then the alv table should be displayed.
and if user selects clsoe alv table then the alv table should be closed.
to create alv table dynamically i have followed this procedure.
under view properties i have added salv_wd_table component. then under the action of showalvbutton i went to code wizard and i have selected instantiate used component component use salv_wd_table. the following code will be generated
with this code i am unable to display alv table dynamically correct me where i went wrong kindly send me the necessary steps how to create alv table dynamically
data lo_cmp_usage type ref to if_wd_component_usage.
lo_cmp_usage = wd_this->wd_cpuse_salv_wd_table( ).
if lo_cmp_usage->has_active_component( ) is initial.
lo_cmp_usage->create_component( ).
endif.
to close table i have used the following code. with this code i am able to achieve the functionality to delete the alv table
data lo_cmp_usage type ref to if_wd_component_usage.
lo_cmp_usage = wd_this->wd_cpuse_salv_wd_table( ).
if lo_cmp_usage->has_active_component( ) is initial.
else.
lo_cmp_usage->Delete_component( ).
endif.
Thanks & Regards,
Naveen
Edited by: naveen.webhelp on Feb 10, 2011 5:52 AM
Hi
ALV table will be shown in the viewcontainerUI element.
it is shown there empty if you dont fill the node bound to the data node of the interface controller of the comp usage
SALV_WD_TABLE.
and if you are not getting the table filled in the first place.
then check have you mapped the DATA node to some node in the comp controller
wht basically is your requirment is that you want to show ALV gird on click of one button and delete it on click of other button.
there are many ways to do so.
best way is control the visiblity of the viewcontainer UI element which containes the TABLE view of SALV_WD_table comp.
create an attribute of type WDUI_VISIBILITY name say VIS.
now go to the layout and bound hte visible property of the viewcontainer to this attribute VIS.
then in the showalv grid button's eventhandler write
wd_context->set_attribute(
name = 'VIS'
value = '02'
and in the wddoinit and delete alv grid button's event handler write
wd_context->set_attribute(
name = 'VIS'
value = '01'
thanks
sarbjeet singh
Similar Messages
-
How to create internal table dynamically based on a table entry
hi Experts,
I have table yprod_cat. It has product categories.
In my ABAP program I need to create internal table dynamically based on the number of entries in the table.
For example:
If the table has 3 entries for product category
1. Board
2. Micro
3. Syst
Then create three (3) internal tables.
i_board
i_micro
i_syst
How can we do this? Any sample code will be very usefull
Thanks & Regards
Gopal
Moderator Message: No sample codes can be given. Please search for them or work it!
Edited by: kishan P on Jan 19, 2011 4:22 PMOur APEX version is 4.2We are using below SQL query to display radio groups dynamically..
SELECT APEX_ITEM.RADIOGROUP (1,deptno,'20',dname) dt
FROM dept
ORDER BY 1;
Created a form using SQL type and given abouve SQL query as source.. But when we run the page, there were no radio groups displayed in the page..
Below is the output of the query..
<input type="radio" name="f01" value="10" />ACCOUNTING
<input type="radio" name="f01" value="20" checked="checked" />RESEARCH
<input type="radio" name="f01" value="30" />SALES
<input type="radio" name="f01" value="40" />OPERATIONS
>
If Tabular Form:
Edit Region > Report Attributes > Edit Column > Change the Column type to "Standard Report Column"
If normal Page Item:
Edit Page Item > Security > Escape special characters=No.
Pl read the help on that page item to understand the security risk associated with =NO.
Cheers,
Edited by: Prabodh on Dec 3, 2012 5:59 PM -
How to create a table dynamically
Hello All,
I want to create a table dynamically in DDIC. I know that there is function module exist DB_CREATE_TABLE but i am getting some errors while using it.
Could any please post some code for it.
Regards,
LisaHere is the code i have writen my self.
PARAMETERS: tabname TYPE dd02l-tabname,
fldname TYPE dd03p-fieldname,
rollname TYPE dd03p-rollname.
DATA: gt_cl_bc_dyn TYPE REF TO zcl_bc_dyn,
status TYPE sy-subrc.
data: lct_table type ZTT_ZTSITAB.
INITIALIZATION.
tabname = 'ZTEST1'.
CREATE OBJECT gt_cl_bc_dyn.
START-OF-SELECTION.
CALL METHOD gt_cl_bc_dyn->create_table
EXPORTING
tabname = tabname
fieldname = fldname
rollname = rollname
itab = lct_table
IMPORTING
status = status .
IF status = 0.
WRITE: 'Table creation is successful'.
ELSE.
WRITE: 'Table creation is unsuccessful'.
ENDIF.
Code in the method
METHOD create_table.
DATA: ls_dd02v_wa TYPE dd02v,
ls_dd09l_wa TYPE dd09l,
ls_dd03p TYPE dd03p,
lt_dd03p TYPE TABLE OF dd03p,
rc TYPE sy-subrc.
ls_dd02v_wa-tabname = tabname.
ls_dd02v_wa-tabclass = 'TRANSP'.
ls_dd02v_wa-contflag = 'A'.
ls_dd09l_wa-tabname = tabname.
ls_dd09l_wa-tabkat = '0'.
ls_dd09l_wa-tabart = 'APPL0'.
ls_dd03p-tabname = tabname.
ls_dd03p-fieldname = fieldname.
ls_dd03p-position = '0001'.
ls_dd03p-keyflag = 'X'.
ls_dd03p-rollname = rollname.
APPEND ls_dd03p TO lt_dd03p.
CALL FUNCTION 'DDIF_TABL_PUT'
EXPORTING
name = tabname
dd02v_wa = ls_dd02v_wa
dd09l_wa = ls_dd09l_wa
TABLES
dd03p_tab = lt_dd03p
EXCEPTIONS
tabl_not_found = 1
name_inconsistent = 2
tabl_inconsistent = 3
put_failure = 4
put_refused = 5
OTHERS = 6
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 FUNCTION 'DDIF_TABL_ACTIVATE'
EXPORTING
name = tabname
IMPORTING
rc = rc
EXCEPTIONS
not_found = 1
put_failure = 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.
status = rc.
ENDMETHOD. -
How to create a table dynamically in webdynpro
hai everybody
in webdynpro we know how to create at design time
but i want to create it at runtime that is dynmamically i want to set the rows and coloums of the table at run time
Thanks & Regards
sravanI guess this should work,
Suppose you want to dynamically create a Table (say Category) having a column called Category Code, then in the wdDoModifyView() hook method, just add the following code snippet,
if (firstTime) {
//Create the Table UI Element
IWDTable table = (IWDTable) view.createElement(IWDTable.class, null);
//Set the Table Header
IWDCaption tableCaption = (IWDCaption) view.createElement(IWDCaption.class, null);
tableCaption.setText("Category Table Contents");
table.setHeader(tableCaption);
//Create and add a Column UI element for the above table
IWDTableColumn column = (IWDTableColumn) view.createElement(IWDTableColumn.class, null);
table.addColumn(column);
//Set the required column header using the caption (Category Code here)
IWDCaption caption = (IWDCaption) view.createElement(IWDCaption.class, null);
caption.setText("Category Code");
column.setHeader(caption);
//Create a TableCellEditor and bind it to an attribute of the Category Node in the context
IWDTextView editor = (IWDTextView) view.createElement(IWDTextView.class, null);
editor.bindText("tb_Category.cat_code");
column.setTableCellEditor(editor);
//Finally add the Table UI element to the view
IWDUIElementContainer root = (IWDUIElementContainer) view.getRootElement();
root.addChild(table);
You need to follow the same procedure for adding multiple columns to the table.
Hope this answers your question!
Regards
Kishan -
How to create internal table dynamically?
hi all
I have a particular internal table in memory area( thru EXPORT TO MEMORY ID ....)
how can i create an internal table of this type in another program at runtime ?
this internal table need not be a data dictionary type.
i.e., i need to create an internal table of type which
is stored in a particular memory-id.
Regards,
Naveen........
nullHi,
Check this code :
TYPE-POOLS: slis.
FIELD-SYMBOLS: <t_dyntable> TYPE STANDARD TABLE,
<fs_dyntable>,
<fs_fldval> type any.
PARAMETERS: p_cols(5) TYPE c.
DATA: t_newtable TYPE REF TO data,
t_newline TYPE REF TO data,
t_fldcat TYPE slis_t_fldcat_alv,
t_fldcat TYPE lvc_t_fcat,
wa_it_fldcat TYPE lvc_s_fcat,
wa_colno(2) TYPE n,
wa_flname(5) TYPE c.
* Create fields .
DO p_cols TIMES.
CLEAR wa_it_fldcat.
move sy-index to wa_colno.
concatenate 'COL'
wa_colno
into wa_flname.
wa_it_fldcat-fieldname = wa_flname.
wa_it_fldcat-datatype = 'CHAR'.
wa_it_fldcat-intlen = 10.
APPEND wa_it_fldcat TO t_fldcat.
ENDDO.
* Create dynamic internal table and assign to FS
CALL METHOD cl_alv_table_create=>create_dynamic_table
EXPORTING
it_fieldcatalog = t_fldcat
IMPORTING
ep_table = t_newtable.
ASSIGN t_newtable->* TO <t_dyntable>.
* Create dynamic work area and assign to FS
CREATE DATA t_newline LIKE LINE OF <t_dyntable>.
ASSIGN t_newline->* TO <fs_dyntable>.
DATA it_fieldcatalog TYPE lvc_t_fcat.
DATA lr_table TYPE REF TO data.
FIELD-SYMBOLS <lt_table> TYPE table.
*-- Import the fieldcatalog
IMPORT it_fieldcatalog TO it_fieldcatalog
FROM MEMORY ID 'CREATE_DYNAMIC_TABLE'.
IF sy-subrc <> 0.
EXIT.
ENDIF.
*-- Create the dynamic table with the field catalog as structure
CALL METHOD cl_alv_table_create=>create_dynamic_table
EXPORTING
it_fieldcatalog = it_fieldcatalog
IMPORTING
ep_table = lr_table
EXCEPTIONS
generate_subpool_dir_full = 1
OTHERS = 2.
IF sy-subrc <> 0.
EXIT.
ENDIF.
*-- Convert the reference into a table
ASSIGN lr_table->* TO <lt_table>.
IF sy-subrc <> 0.
EXIT.
ENDIF.
*-- Export the created table so that the function module can import it
EXPORT lt_table FROM <lt_table>
TO MEMORY ID 'CREATE_DYNAMIC_TABLE'.
Regards
L Appana -
How to create a table report with alphabetic link at the top
Hello,
I have a db table of users, and have created a report based on this table, however I want to have each aphabet letter at the top of the report so that users can click on the letter and see all records where the username field starts with that letter.
How can I achieve this?
Thanks,Hello user11243298 (please tell us your name),
Your report query would look something like this (assuming page number is 1):
select some_column1, some_column2
from your_user_table
where username like :P1_INITIAL || '%'
For the letters at the top of the report, here's a couple options:
- If you want all letters to appear whether or not there are any rows, you can create a series of buttons or links, one for each letter, and specify the target URL to submit back to the report page, setting the item P1_INITIAL to each letter.
- If you want only letters that have rows, one way is to create a dynamic LOV based on a query like this:
select distinct upper(substr(username, 1, 1)) d, distinct upper(substr(username, 1, 1)) v
from your_user_table
order by upper(substr(username, 1, 1))
Then use that for a select list with submit, again targeting the report page and setting P1_INITIAL to the selected value.
Hope this helps (if it does, please reward it),
John -
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 -
How To create Taxonomy Tables in MDM
Hi all,
I am new to MDM and want to know how to create Taxonomy Tables in MDM data manager for the various available categories and attributes.
Regards,
Gavin.Hi Gavin,
Here's a solution.
1. Create a calculated field of type boolean - you can name it On-Site or something similar.
2. Enter the following as the calculation expression
IF(HAS_ANY(COUNTRY_FIELD_NAME, "country 1", "country 2", "country n"), TRUE, FALSE) - where country 1...country n are the countries that are on considered On-Site.
All Vendors from countries you have listed in the expression will have the value TRUE for the field On-Site. All other Vendors will have the value False. This way you can separate the 2 groups of Vendors by searching on the field On-Site.
Hope this helps,
Richard -
Can we create internal table dynamically ? how?
hi to all experts,
can we create internal table dynamically ? how?plz explain me with an example.Anybody with good example will be rewarded.it was asked in an interview what the answer for itHI
Yes you can create
see this
/people/rich.heilman2/blog/2005/07/27/dynamic-internal-tables-and-structures--abap
JUST USE THIS CODE AND DO THE ESSENTIAL CHANGES ACCORDING TO YOU
STEP: 1 - get backend field catalog (currently displayed alv)
CLEAR: tl_fieldcatalog. REFRESH: tl_fieldcatalog.
CALL METHOD w_grid->get_backend_fieldcatalog
IMPORTING
et_fieldcatalog = tl_fieldcatalog.
STEP: 2 - create a new fieldcatalog for dynamic internal table
CLEAR: sl_fieldcatalog.
CLEAR: t_outtab_fieldname. REFRESH: t_outtab_fieldname.
CLEAR: tl_fieldcatalog_new. REFRESH: tl_fieldcatalog_new.
CLEAR: t_download_fieldname. REFRESH: t_download_fieldname.
CLEAR: t_download_fieldheading. REFRESH: t_download_fieldheading.
LOOP AT tl_fieldcatalog INTO sl_fieldcatalog.
STEP: 2.1 - populate data in T_OUTTAB_FIELDNAME
APPEND sl_fieldcatalog-fieldname TO t_outtab_fieldname.
STEP: 2.2 - populate TL_FIELDCATALOG_NEW & T_DOWNLOAD_FIELDNAME
IF sl_fieldcatalog-no_out EQ ''.
IF sl_fieldcatalog-fieldname NE 'STATUS'
OR sl_fieldcatalog-fieldname NE 'MESG_STATUS'
OR sl_fieldcatalog-fieldname NE 'ZLOCK'
OR sl_fieldcatalog-fieldname NE 'T_PLANT'
OR sl_fieldcatalog-fieldname NE 'T_CSR'.
If field is COMM_PLANT, change its length
IF sl_fieldcatalog-fieldname EQ 'COMM_PLANT'.
sl_fieldcatalog-outputlen = 1800.
sl_fieldcatalog-intlen = 1800.
sl_fieldcatalog-dd_outlen = 1800.
ENDIF. "comm_plant
sl_fieldcatalog_new = sl_fieldcatalog.
APPEND sl_fieldcatalog_new TO tl_fieldcatalog_new.
APPEND sl_fieldcatalog-fieldname TO t_download_fieldname.
APPEND sl_fieldcatalog-scrtext_l TO t_download_fieldheading.
CLEAR: sl_fieldcatalog, sl_fieldcatalog_new.
ENDIF.
ENDIF.
ENDLOOP.
STEP: 3 - create dynamic internal table
FREE: ref_download.
CALL METHOD cl_alv_table_create=>create_dynamic_table
EXPORTING
I_STYLE_TABLE =
it_fieldcatalog = tl_fieldcatalog_new
IMPORTING
ep_table = ref_download
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 ref_download->* TO <ft_download>.
CREATE DATA ref_wa LIKE LINE OF <ft_download>.
ASSIGN ref_wa->* TO <fs_download>.
STEP: 4 - populate data in dynamic internal table
LOOP AT t_outtab INTO wa_outtab.
LOOP AT t_download_fieldname.
ASSIGN COMPONENT t_download_fieldname OF STRUCTURE
<fs_download> TO <fs_download_field>.
IF t_download_fieldname-field EQ 'COMM_PLANT'.
STEP: 4.1 - get long text from database table
CLEAR: wal_table.
SELECT SINGLE * FROM zshaven_plnt_txt
INTO wal_table
WHERE vbeln = wa_outtab-vbeln
AND posnr = wa_outtab-posnr
AND del_no = wa_outtab-del_no
AND del_itm = wa_outtab-del_itm.
IF sy-subrc EQ 0.
STEP: 4.2 - break long-text into separate lines
CLEAR: tl_text. REFRESH: tl_text.
SPLIT wal_table-plant_comm
AT '~'
INTO TABLE tl_text.
STEP: 4.3 - Combine these separate lines with space in
between two lines
CLEAR: wal_text, final_text.
LOOP AT tl_text INTO wal_text.
IF final_text IS INITIAL.
final_text = wal_text.
ELSE.
CONCATENATE final_text '-' wal_text
INTO final_text.
REPLACE '-' WITH ' ' INTO final_text.
ENDIF.
ENDLOOP.
STEP: 4.4 - move long text to work-area
<fs_download_field> = final_text.
ENDIF. "subrc
ELSE. "t_download_fieldname
READ TABLE t_outtab_fieldname
WITH KEY field = t_download_fieldname-field.
ASSIGN COMPONENT t_outtab_fieldname-field OF STRUCTURE
wa_outtab TO <fs_outtab_field>.
<fs_download_field> = <fs_outtab_field>.
ENDIF.
ENDLOOP.
STEP: 4.5 - Move data from work-area to dynamic internal table
APPEND <fs_download> TO <ft_download>.
CLEAR: <fs_download>.
ENDLOOP.
STEP: 5 - download
CALL FUNCTION 'DOWNLOAD'
EXPORTING
filename = 'C:\zshaven.xls'
filetype = 'DAT'
filetype_no_show = 'X'
filetype_no_change = 'X'
TABLES
data_tab = <ft_download>
fieldnames = t_download_fieldheading
EXCEPTIONS
invalid_filesize = 1
invalid_table_width = 2
invalid_type = 3
no_batch = 4
unknown_error = 5
gui_refuse_filetransfer = 6
customer_error = 7
OTHERS = 8.
IF sy-subrc <> 0.
MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ENDIF. -
How to create a table,columns,rows dynamically
Hi All,
I would like to build an application which takes from date and to date as inputs and click on button it should create a table dynamically in the following format( rows - project Act1,Service Act2 etc....columns dates and total should be display rowwise and columnwise)
From 06.22.2009 To 06.23.2009 Go(button)
06.22.2009 06.23.2009 Total
Project act1 2 2 4
Project Act2
Service Act1 3 3 6
Total 5 5
How do i build this application
I should have ALV capability so that I can download.
Thanks
Bala Duvvuri
Edited by: Bala Duvvuri on Jun 23, 2009 5:21 AM
Edited by: Bala Duvvuri on Jun 23, 2009 5:22 AM
Edited by: Bala Duvvuri on Jun 23, 2009 5:25 AMDATA lo_table_settings TYPE REF TO if_salv_wd_table_settings.
DATA lo_standard_functions TYPE REF TO if_salv_wd_std_functions.
DATA lo_column_settings TYPE REF TO if_salv_wd_column_settings.
DATA lo_column TYPE REF TO cl_salv_wd_column.
DATA lo_column_hdr TYPE REF TO cl_salv_wd_column_header.
lo_table_settings ?= lo_table.
lo_table_settings->set_selection_mode( cl_wd_table=>e_selection_mode-auto ).
lo_table_settings->set_cell_action_event_enabled( value = abap_true ).
lo_table_settings->set_width( value = '100%' ).
set default ALV Functions off
lo_standard_functions ?= lo_table.
lo_standard_functions->set_sort_headerclick_allowed( abap_false ).
lo_standard_functions->set_filter_filterline_allowed( abap_false ).
lo_standard_functions->set_filter_complex_allowed( abap_true ).
lo_standard_functions->set_sort_complex_allowed( abap_true ).
lo_standard_functions->set_column_selection_allowed( abap_true ).
lo_standard_functions->set_view_list_allowed( abap_true ).
lo_standard_functions->set_pdf_allowed( abap_true ).
lo_standard_functions->set_export_allowed( abap_true ).
lo_standard_functions->set_dialog_settings_as_popup( abap_true ).
lo_standard_functions->set_display_as_allowed( abap_true ).
lo_standard_functions->set_graphic_allowed( abap_true ).
lo_column_settings ?= lo_table.
*To create a row with heading Matter No.
lo_column = lo_column_settings->get_column( 'MTRID' ).
lo_column_hdr = lo_column->create_header( ).
lo_column_hdr->set_text( 'MATTER NO.' ).
same way for other required field. -
How to Create a Table Component Dynamically based on the Need
Hello all,
I have a problem i need to create dynamically tables based on the no of records in the database. How can i create the table object using java code.
Please help.Winston's blog will probably be helpful:
How to create a table component dynamically:
http://blogs.sun.com/roller/page/winston?entry=creating_dynamic_table
Adding components to a dynamically created table
http://blogs.sun.com/roller/page/winston?entry=dynamic_button_table
Lark
Creator Team -
How to create a table component dynamically in netbeans 6.0 (JSF 1.2)?
How to create a table component dynamically in netbeans 6.0 (JSF 1.2)?
This example http://developers.sun.com/jscreator/reference/techart/2/createTableDynamically.html works only with JSF 1.1.Please help my write correct code.
How to replace this strings for run example?
rowGroup.setValueBinding("sourceData", getApplication().createValueBinding("#{Page1.tripDataProvider}"));
staticText1.setValueBinding("text", getApplication().createValueBinding("#{currentRow.value['TRIP.TRIPID']}")); -
How to create a table with events in smartforms?
How to create a table with events view in smartforms?
It doesn't like general table with header, main area and footer.
for example:
in smartforms: LE_SHP_DELNOTE
table name is TABLEITEM(Delivery items table)Vel wrote:
I am creating XML file using DBMS_XMLGEN package. This XML file will contain data from two different database tables. So I am creating temporary table in the PL/SQL procedure to have the data from these different tables in a single temporary table.
Please find the below Dynamic SQL statements that i'm using for create the temp table and inserting the data into it.
Before insert the V_NAME filed, i will be appending a VARCHAR field to the original data.
EXECUTE IMMEDIATE 'CREATE TABLE TEMP_TABLE (UNIQUE_KEY NUMBER , FILE_NAME VARCHAR2(1000), LAST_DATE DATE)';
EXECUTE IMMEDIATE 'INSERT INTO TEMP_TABLE values (SEQUENCE.nextval,:1,:2)' USING V_NAME,vLastDate;What exactly i need is to eliminate the INSERT portion of it,Since i have to insert more 90,000 rows into it. Is there way to have the temp table created with data in it along with the sequence value as well.
I'm using Oracle 10.2.0.4 version.
Edited by: 903948 on Dec 22, 2011 10:58 PMWhat you need to do to eliminate the INSERT statement is to -- as already suggested by others - eliminate the temporary table. You don't need it. It is just necessary overhead. Please explain why you (apparently) believe that the suggestion of a view will not meet your requirements. -
How to create a table control from a program internal table
Hi all,
I try to create a table control that matches following requirements :
- the source table is an internal table from program (not a dictionary table)
- I need to specify my own column header titles
- the fields need to be editable
- some of the columns fields must be displayed as checkboxes, other one as texts
When I try using "Table Control WIth Wizard", the generated TabControl has the expected columns titles but the fields are not displayed as checkboxes. Moreoever, when I look at "Dictionnary, program Fields list", the table fields choosed using wizard are locked (a padlock is displayed in front of the line) So, I can not check "checkbox display"
When I try using simple Table Control -I mean without ALV-, I can use the "checkbox display" for wanted fields but I don't know how to specify the resquired columns headers titles
So, could you please help me ? How to do both : maage columsn header titles and display some of the columns as checkboxes ?
thanks for help
Regards
morganHi Morgan,
Create an Interanal Table in Top Include and activate it first. Then go the Screen Layout and Drag and Drop a Table control.
Enter a name like TC. now press F6 (Dictionary/Program Fields Window). Enter the Interanal Table and Press
Get From Program Push button. Select the required Columns and transfer them. Double click on the Table Control Area only (any corner of the TC) now you get attribute window POP UP. now select the check box for with column Header or remove the available column header and place your own Text Field and give meaningful Text for them. With in the Table control you can Drag and Drop a Check Box which will occupy all the rows. Make sure you include one more column in the TOP include type C with length one.
Hope this is very Clear to YOU.
Cheers
Ram -
How to create some columns dynamically in the report designer depending upon the input selection
Post Author: ekta
CA Forum: Crystal Reports
how to create some columns dynamically in the report designer depending upon the input selection
how export this dynamic report in (pdf , xls,doc and rtf format)
report format is as below:
Element Codes
1
16
14
11
19
10
2
3
Employee nos.
Employee Name
Normal
RDO
WC
Breveavement
LWOP
Sick
Carers leave
AL
O/T 1.5
O/T 2.0
Total Hours
000004
PHAN , Hanh Huynh
68.40
7.60
76.00
000010
I , Jungue
68.40
7.60
2.00
5.00
76.00
000022
GARFINKEL , Hersch
66.30
7.60
2.10
76.00
In the above report first column and the last columns are fixed and the other columns are dynamic depending upon the input selection:
if input selection is Normal and RDO then only 2 columns w'd be created and the other 2 fixed columns.
Can anybody help me how do I design such report....
ThanksHi Developer life,
According to your description that you want to dynamically increase and decrease the numbers of the columns in the table, right?
As Jason A Long mentioned that we can use the matrix to do this and put the year field in the column group, amount fields(Numric values) in the details, add an filter to filter the data base on this column group, but if
the data in the DB not suitable to add to the matrix directly, you can use the unpivot function to turn the column name of year to a single row and then you can add it in the column group.
If there are too many columns in the column group, it will fit the page size automatically and display the extra columns in the next page.
Similar threads with details steps for your reference:
https://social.technet.microsoft.com/Forums/en-US/339965a1-8cca-41d8-83ef-c2548050799a/ssrs-dataset-column-metadata-dynamic-update?forum=sqlreportings
If your still have any problem, please try to provide us more details information, such as the data structure in the DB and the table structure you are currently designing.
Any question, please feel free to let me know.
Best Regards
Vicky Liu
Maybe you are looking for
-
Sorting Column's Label in Pivot Table
Hi Fellows !! This is my problem: I have two tables, dates and rates, providing me data for a report. Dates has a DateId (number), Year(number) and Month(varchar2(12)), and Rates has DateId(number) and RateAmount(number). I wrote a quite simple query
-
Which Browser Is Best On Lion?
Which browser do you find works best on Lion? I like the backward/forward affects of Safari. I've found that Chrome appears to be the fastest and has two-finger swipe.
-
What is code fix for Internet Exp. 6 and 7 for my site?
My posted site <cumccda.org> is not presenting correctly in Internet Explorer 6 and 7. I was under the impression that Dreamweaver automatically put in code to make a site work correctly with the new CSS in the older browsers of I.E.. Am I wrong? If
-
Iphoto won't open after laptop powered down (ran out of batteries)
I was transferring some photos from iphoto to facebook when my macbook pro ran out of charge. When I plugged it back on, iphoto would not open. Blank with spinning rainbow disc. I had to force quit several times. How do I back up my pics? Are they lo
-
How to remove the 'Execute' Icon
Dear Friends , Good Morning. Can anybody know how to remove the Execute Icon?Pls. help on this.