Colors in Dynamic ALV table display
Hello All,
I have dynamic ALV table display in which i created the columns dynamically and finally binded that created node and diplayed the table ..
Now what i want to do is depending on some condition i need to change the colors in the table display..
I tried to set the color in this way inside the loop .
if lv_phase = '3'.
lr_column->set_cell_design( CL_WD_TABLE_COLUMN=>E_CELL_DESIGN-badvalue_medium ).
else.
lr_column->set_cell_design( CL_WD_TABLE_COLUMN=>E_CELL_DESIGN-standard ).
endif.
This piece of code either changes all the coloumns into one color only why it is not changing the color based upon the condition . I am unable to understand..
Please help me in this...Do i need to some thing else..
Solved by creating a new column called cell design ... and settign the set_cell_design_fieldname ...
This solved my Problem ..
Similar Messages
-
How can i change the column label text in a alv table display
how can i change the column label text in a alv table display??
A similar kinda of question was posted previuosly where the requirement was the label text was needed and following below code was given as solution :
<i>* declare column, settings, header object
DATA: lr_column TYPE REF TO cl_salv_wd_column.
DATA: lr_column_settings TYPE REF TO if_salv_wd_column_settings.
DATA: lr_column_header type ref to CL_SALV_WD_COLUMN_HEADER.
get column by specifying column name.
lr_column = lr_column_settings->get_column( 'COLUMN_NAME1' ).
set Header Text as null
lr_column_header = lr_column->get_header( ).
lr_column_header->set_text( ' ' ).</i>
My specific requirement is i have an input field on the screen and i want reflect that value as the column label for one of the column in the alv table. I have used he above code with slight modification in the MODIFYVIEW method of the view since it is a process after input. The component gets activated without any errors but while run time i get an error stating
<i>"The following error text was processed in the system CDV : Access via 'NULL' object reference not possible."</i>
i have checked in debugging and the error occured at the statement :
<i>lr_column = lr_column_settings->get_column( 'CURRENT_YEAR' ).</i>Please can you provide me an alternative for my requirement or correct me if i have done it wrong.
Thanks,
SuriI found it myself how to do it. The error says that it is not able to find the reference object i.e it is asking us to refer to the table. The following piece of code will solve this problem. Have to implement this in WDDOMODIFYVIEW method of the view. This thing works comrades enjoy...
DATA : lr_cmp_usage TYPE REF TO if_wd_component_usage,
lr_if_controller TYPE REF TO iwci_salv_wd_table,
lr_cmdl TYPE REF TO cl_salv_wd_config_table,
lr_col TYPE REF TO cl_salv_wd_column.
DATA : node_year TYPE REF TO if_wd_context_node,
elem_year TYPE REF TO if_wd_context_element,
stru_year TYPE if_alv_layout=>element_importing,
item_year LIKE stru_year-i_current_year,
lf_string TYPE char(x),
DATA: lr_column TYPE REF TO cl_salv_wd_column.
DATA: lr_column_header TYPE REF TO cl_salv_wd_column_header.
DATA: lr_column_settings TYPE REF TO if_salv_wd_column_settings.
Get the entered value from the input field of the screen
node_year = wd_context->get_child_node( name = 'IMPORTING_NODE' ).
elem_year = node_year->get_element( ).
elem_year->get_attribute(
EXPORTING
name = 'IMPORT_NODE-PARAMETER'
IMPORTING
value = L_IMPORT_PARAM ).
WRITE L_IMPORT_PARAM TO lf_string.
Get the reference of the table
lr_cmp_usage = wd_this->wd_cpuse_alv( ).
IF lr_cmp_usage->has_active_component( ) IS INITIAL.
lr_cmp_usage->create_component( ).
ENDIF.
lr_if_controller = wd_this->wd_cpifc_alv( ).
lr_column_settings = lr_if_controller->get_model( ).
get column by specifying column name.
IF lr_column_settings IS BOUND.
lr_column = lr_column_settings->get_column( 'COLUMN_NAME').
set Header Text as null
lr_column_header = lr_column->get_header( ).
lr_column_header->set_text( lf_string ).
endif. -
WD4A Dynamic ALV Table with dynamic tables
Hi all,
first I want give you the information what I try to do.
I have an another WD4A application for administrative use in which I can assign certain tablefields to a certain user. You can say it's something like a customizing application.
In the next application (with my issues) I will display the tables for the user, but these tables are not the complete table.
I have a node in my context of the component controller which is bound to my ALV. I add during the runtime attributes to my node.
* .... coding ....declaration
* get the node
lr_node = wd_context->get_child_node( 'M_TABLE' ).
lr_node_info ?= lr_node->get_node_info( ).
* remove the attributes, if exists
lr_node_info->remove_dynamic_attributes( ).
* .... coding ....
* add attributes
LOOP AT l_t_m_table INTO l_s_m_table.
CLEAR ls_attribute.
* name of the attribute
MOVE l_s_m_table-NAME TO ls_attribute-NAME.
* DDIC type of the attribute
MOVE l_s_m_table-TYPE_NAME TO ls_attribute-TYPE_NAME.
* If the DDIC has a gen namespace like /B135/ replace the / with _
REPLACE ALL OCCURRENCES OF '/' IN ls_attribute-NAME WITH '_'.
* add the attribute
lr_node_info->add_attribute( EXPORTING
attribute_info = ls_attribute ).
ENDLOOP.
This coding works fine I get the columns in my ALV. Then I tried to fill my ALV table with data from a database table.
I created dynamicly an internal table with the following coding:
* Create dynamic table
CALL METHOD CL_ALV_TABLE_CREATE=>CREATE_DYNAMIC_TABLE
EXPORTING
IT_FIELDCATALOG = l_t_FLDCAT
IMPORTING
EP_TABLE = l_t_NEW_M_TABLE.
* assign the table
ASSIGN l_t_NEW_M_TABLE->* TO <M_TABLE>.
* structure of table
CREATE DATA l_s_NEW_M_TABLE LIKE LINE OF <M_TABLE>.
ASSIGN l_s_NEW_M_TABLE->* TO <l_s_m_table>.
* get data from database
SELECT * FROM (l_m_table) INTO CORRESPONDING FIELDS OF TABLE <M_table> WHERE OBJVERS = 'A'.
With this coding I get the data from the database and only the required fields that means I have e.g. an itab with columns1, columns3, columns4 from the database.
I also added e.g. these columns (columns1, columns3, columns4 from the database) to the node as attribute. Now it should be possible to bind the table to the structure with this coding:
lr_comp_usage_m = wd_this->wd_cpuse_usage_alv_M_table( ).
* create component if not active
IF lr_comp_usage_m->has_active_component( ) IS INITIAL.
lr_comp_usage_m->create_component( ).
else.
* set data if node exists
l_ref_interfacecontroller = wd_this->wd_cpifc_usage_alv_M_table( ).
l_ref_interfacecontroller->set_data( lr_node ).
endif.
* bind table
lr_node->bind_table( <M_TABLE> ).
Now, I get an error, which is caused by the table binding.
In ST22 I get:
Short text
Line types of an internal table and a work area not compatible.
What happened?
Error in the ABAP Application Program
The current ABAP program "CL_WDR_CONTEXT_NODE_VAL=======CP" had to be
terminated because it has
come across a statement that unfortunately cannot be executed.
Error analysis
The statement
"INSERT wa INTO TABLE itab"
requires the lines of the internal table "TABLE" and the
work area " wa" to be compatible. Compatibility means
equivalence in the context of ABAP/4 type checking.
In this case, the condition is not satisfied because the internal table
"TABLE" has the line type "u" and the length 28, but the work area " wa"
has the type "C" and the length 2.
(If the work area " wa" is the header line of the internal
table "TABLE", the above inconsistency can arise if an internal
table t with the line type T1 is passed to a subroutine (FORM or
FUNCTION) as an actual parameter and the corresponding formal
parameter p is declared in the subroutine by "TABLES p STRUCTURE T2".
If then T1 and T2 are incompatible, the header line p
has the type T2 (specifed by STRUCTURE), but the internal
table p has the line type T1 (passed from the actual parameter)).
Source Code Extract
Line SourceCde
1 method if_wd_context_node~get_static_attributes_table .
2
3 field-symbols:
4 <element> like line of me->collection,
5 <static_attributes> type data,
6 <table> type index table.
7
8 * check whether elements are supllied or not
9 if me->elements_supplied = abap_false.
10 me->supply_elements( ).
11 endif.
12
13 clear table.
14
15 if me->table_ref is not initial.
16 assign me->table_ref->* to <table>.
17 table = <table>.
18 else.
19 loop at me->collection assigning <element> from from to to.
20 assign <element>->static_attributes->* to <static_attributes>.
error in line 21 insert <static_attributes> into table table.
22 endloop.
23 endif.
24
25 endmethod.
Any suggestions? Is it allowed to use bind_table() with a field symbol?
Another strange thing is that if I try the same with static itab and attributes during runtime it works, but only if the fields of the itab has the same name as the attributes, which means that I can not use itabs with fieldnames like /BI0/S_CUSTOMER and if I can not use them it's difficult to read data from database with SELECT * FROM ... INTO CORRESPONDING FIELDS OF TABLE itab.
Thanks in advance for your suggestions!
Best Regards,
MarcelHi Francois,
I solve it with the RTTI and the method
lr_node_info = lr_node_info->add_new_child_node(
name = 'Dynamic_TABLE'
IS_MANDATORY = ABAP_false
IS_MULTIPLE = ABAP_true
STATIC_ELEMENT_RTTI = lr_struct_descr
IS_STATIC = ABAP_false
I don't know why it doesn't work with adding attributes and binding the table after adding the attributes.
Anyway thanks for your help.
Best Regards,
Marcel -
How to change the selected row color in an alv grid display ?
Hello ,
I WANT TO CHANGE THE COLOR OF THE SELECTED RECORDS IN AN ALV GRID DISPLAY ?
ITS URGENT..
WILL BE REWARDED...hai Ssnagh Samala
EXicut This report >
Hope It Will Meet U r Requirement.
If Found Helpfull Reward.
REPORT zcuitest_alv_07.
Use of colours in ALV grid (cell, line and column) *
Table
TABLES : mara.
Type
TYPES : BEGIN OF ty_mara,
matnr LIKE mara-matnr,
matkl LIKE mara-matkl,
counter(4) TYPE n,
free_text(15) TYPE c,
color_line(4) TYPE c, " Line color
color_cell TYPE lvc_t_scol, " Cell color
END OF ty_mara.
Structures
DATA : wa_mara TYPE ty_mara,
wa_fieldcat TYPE lvc_s_fcat,
is_layout TYPE lvc_s_layo,
wa_color TYPE lvc_s_scol.
Internal table
DATA : it_mara TYPE STANDARD TABLE OF ty_mara,
it_fieldcat TYPE STANDARD TABLE OF lvc_s_fcat,
it_color TYPE TABLE OF lvc_s_scol.
Variables
DATA : okcode LIKE sy-ucomm,
w_alv_grid TYPE REF TO cl_gui_alv_grid,
w_docking_container TYPE REF TO cl_gui_docking_container.
PARAMETERS : p_column AS CHECKBOX,
p_line AS CHECKBOX,
p_cell AS CHECKBOX.
START-OF-SELECTION.
PERFORM get_data.
END-OF-SELECTION.
PERFORM fill_catalog.
PERFORM fill_layout.
CALL SCREEN 2000.
*& Module status_2000 OUTPUT
text
MODULE status_2000 OUTPUT.
SET PF-STATUS '2000'.
ENDMODULE. " status_2000 OUTPUT
*& Module user_command_2000 INPUT
text
MODULE user_command_2000 INPUT.
DATA : w_okcode LIKE sy-ucomm.
MOVE okcode TO w_okcode.
CLEAR okcode.
CASE w_okcode.
WHEN 'BACK'.
LEAVE TO SCREEN 0.
ENDCASE.
ENDMODULE. " user_command_2000 INPUT
*& Module alv_grid OUTPUT
text
MODULE alv_grid OUTPUT.
IF w_docking_container IS INITIAL.
PERFORM create_objects.
PERFORM display_alv_grid.
ENDIF.
ENDMODULE. " alv_grid OUTPUT
*& Form create_objects
text
--> p1 text
<-- p2 text
FORM create_objects.
Ratio must be included in http://5..95
CREATE OBJECT w_docking_container
EXPORTING
ratio = 95
EXCEPTIONS
cntl_error = 1
cntl_system_error = 2
create_error = 3
lifetime_error = 4
lifetime_dynpro_dynpro_link = 5
others = 6.
CREATE OBJECT w_alv_grid
EXPORTING
i_parent = w_docking_container.
ENDFORM. " create_objects
*& Form display_alv_grid
text
--> p1 text
<-- p2 text
FORM display_alv_grid.
CALL METHOD w_alv_grid->set_table_for_first_display
EXPORTING
is_layout = is_layout
CHANGING
it_outtab = it_mara
it_fieldcatalog = it_fieldcat
EXCEPTIONS
invalid_parameter_combination = 1
program_error = 2
too_many_lines = 3
OTHERS = 4.
ENDFORM. " display_alv_grid
*& Form get_data
text
--> p1 text
<-- p2 text
FORM get_data.
SELECT * FROM mara UP TO 5 ROWS.
CLEAR : wa_mara-color_line, wa_mara-color_cell.
MOVE-CORRESPONDING mara TO wa_mara.
ADD 1 TO wa_mara-counter.
MOVE 'Blabla' TO wa_mara-free_text.
IF wa_mara-counter = '0002'
AND p_line = 'X'.
Color line
MOVE 'C410' TO wa_mara-color_line.
ELSEIF wa_mara-counter = '0004'
AND p_cell = 'X'.
Color cell
MOVE 'FREE_TEXT' TO wa_color-fname.
MOVE '5' TO wa_color-color-col.
MOVE '1' TO wa_color-color-int.
MOVE '1' TO wa_color-color-inv.
APPEND wa_color TO it_color.
wa_mara-color_cell] = it_color[.
ENDIF.
APPEND wa_mara TO it_mara.
ENDSELECT.
ENDFORM. " get_data
*& Form fill_catalog
text
--> p1 text
<-- p2 text
FORM fill_catalog.
Colour code : *
Colour is a 4-char field where : *
- 1st char = C (color property) *
- 2nd char = color code (from 0 to 7) *
0 = background color *
1 = blue *
2 = gray *
3 = yellow *
4 = blue/gray *
5 = green *
6 = red *
7 = orange *
- 3rd char = intensified (0=off, 1=on) *
- 4th char = inverse display (0=off, 1=on) *
Colour overwriting priority : *
1. Line *
2. Cell *
3. Column *
DATA : w_position TYPE i VALUE '1'.
CLEAR wa_fieldcat.
MOVE w_position TO wa_fieldcat-col_pos.
MOVE 'MATNR' TO wa_fieldcat-fieldname.
MOVE 'MARA' TO wa_fieldcat-ref_table.
MOVE 'MATNR' TO wa_fieldcat-ref_field.
APPEND wa_fieldcat TO it_fieldcat.
ADD 1 TO w_position.
CLEAR wa_fieldcat.
MOVE w_position TO wa_fieldcat-col_pos.
MOVE 'MATKL' TO wa_fieldcat-fieldname.
MOVE 'MARA' TO wa_fieldcat-ref_table.
MOVE 'MATKL' TO wa_fieldcat-ref_field.
Color column
IF p_column = 'X'.
MOVE 'C610' TO wa_fieldcat-emphasize.
ENDIF.
APPEND wa_fieldcat TO it_fieldcat.
ADD 1 TO w_position.
CLEAR wa_fieldcat.
MOVE w_position TO wa_fieldcat-col_pos.
MOVE 'COUNTER' TO wa_fieldcat-fieldname.
MOVE 'N' TO wa_fieldcat-inttype.
MOVE '4' TO wa_fieldcat-intlen.
MOVE 'Counter' TO wa_fieldcat-coltext.
APPEND wa_fieldcat TO it_fieldcat.
ADD 1 TO w_position.
CLEAR wa_fieldcat.
MOVE w_position TO wa_fieldcat-col_pos.
MOVE 'FREE_TEXT' TO wa_fieldcat-fieldname.
MOVE 'C' TO wa_fieldcat-inttype.
MOVE '20' TO wa_fieldcat-intlen.
MOVE 'Text' TO wa_fieldcat-coltext.
APPEND wa_fieldcat TO it_fieldcat.
ENDFORM. " fill_catalog
*& Form fill_layout
text
--> p1 text
<-- p2 text
FORM fill_layout.
Field that identify color line in internal table
MOVE 'COLOR_LINE' TO is_layout-info_fname.
Field that identify cell color in inetrnal table
MOVE 'COLOR_CELL' TO is_layout-ctab_fname.
ENDFORM. " fill_layout
Regards.
Eshwar. -
About setting color properties to alv table....
Hi experts,
I have scenario in which i have created one node with two columns..one for data and othr for cell design...both dis node attributed are bind to standard table's column's value property and cell design properties respectively...
Bt now..dis is only poss in Standard tables...and i want da same in ALVs..
In which m not gettin where to bind dat cell design attribute of da node to ALV table...lik we bind data..using set_data( ) thg...
Hope u understood ma query...
Please help me out to solve dis.....
Thanks and Regards,
Runali.Then have a field cell_design in your context. And instead of calling set_cell_design, you should just say
lr_column->set_cell_design_fieldname( 'CELL_DESIGN' ).
In ALV, for every property, a method set_<property>_fieldname is available to bind the proerty to a context attribute. When you initialise your ALV settings, set this attribute and it will be bound to the cell design.
The attribute cell_design should be in the same context node that you bind to the ALV. You can make the column with column ID cell_design as invisible. This way you can set the colors even at an individual cell level. In your internal table, if you wish, you can set a particular color for a set of values etc.
Hope this helps you solve your problem.
Regards,
Nithya -
Hi Experts,
I have one final table(assume it contains 25 fields) for final output in ALV report.
I've 5 different radiobuttons on my selection-screen.
Depending upon the radiobutton selected , user needs 5 different report outputs
from this one table.
I mean if he selected first radiobutton , he needs some 15 fields only to be displayed out of 25 fields.
Similarly if he select 3rd radiobutton then he needs some 10 fields only to be displayed out of 25 fields.
Is it possible to display the reuired fields only from my final table ?Otherwise I've create 5 more int.tables and move the contents depending upon the radibutton selected.
Please help me, point for sure..
Thanks,
Ponraj.s.Pon,
FORM build_fieldcat .
IF itab[] IS INITIAL.
MESSAGE 'No Values exist for the Selection.' TYPE 'S'.
STOP.
ENDIF.
DEFINE m_fieldcat.
itfieldcat-fieldname = &1.
itfieldcat-col_pos = &2.
itfieldcat-seltext_l = &3.
itfieldcat-do_sum = &4.
itfieldcat-outputlen = &5.
append itfieldcat to itfieldcat.
clear itfieldcat.
END-OF-DEFINITION.
m_fieldcat 'LFBNR' '' 'GR NO' '' 10.
m_fieldcat 'BELNR' '' 'MIRO NO' '' 10.
m_fieldcat 'BUZEI' '' 'MIRO LN ITM' '' 10.
m_fieldcat 'LIFNR' '' 'VENDOR CODE' '' 10.
m_fieldcat 'NAME1' '' 'VENDOR NAME' '' 14.
m_fieldcat 'STR_SUPPL1' '' 'VENDOR ADDRESS' '' '15' .
m_fieldcat 'POST_CODE1' '' 'PINCODE' '' 6.
m_fieldcat 'XBLNR' '' 'VEN INV NO' '' 16.
m_fieldcat 'BLDAT' '' 'VEN INV DATE' '' 8.
m_fieldcat 'EBELN' '' 'PUR ORD NO' '' 10.
*Start of Insertion by Kiran.K to display PO Doc. Type dated 060707.
*m_fieldcat 'BSART' '' 'PUR ORD DOC.TYPE' '' 5. "Pur.Doc Type
m_fieldcat 'BATXT' '' 'PUR ORD DOC.TYPE' '' 20. "Pur Doc. Type Description
*End of Insertion by Kiran.K to display PO Doc. Type dated 060707
m_fieldcat 'EBELP' '' 'PUR LN ITM' '' 5.
m_fieldcat 'WERKS' '' 'PLANT' '' 8.
m_fieldcat 'MATNR' '' 'MAT NO' '' 18.
m_fieldcat 'MAKTX' '' 'MAT DESC' '' 15.
m_fieldcat 'MATKL' '' 'MAT CC' '' 7.
m_fieldcat 'MENGE' '' 'QTY' '' 13.
m_fieldcat 'WRBTR' '' 'VAL. OF GOODS' '' 11.
m_fieldcat 'WAERS' '' 'CURR' '' 5.
m_fieldcat 'INRVAL' '' 'INR VALUE' '' 13.
m_fieldcat 'BED' '' 'BED' '' 10.
m_fieldcat 'CVD' '' 'CVD' '' 10.
m_fieldcat 'ECVD' '' 'CESS ON CVD' '' 10.
m_fieldcat 'ECED' '' 'CESS ON DUTIES' '' 13.
*Bill of Lading Removed and Bill of Entry Added.
m_fieldcat 'FRBNR' '' 'BILL OF LADING' '' 13.
m_fieldcat 'BELNR1' '' 'BILL OF ENTRY' '' 13.
m_fieldcat 'REVERSE' '' 'Reversed' '' 2.
m_fieldcat 'FIDOC' '' 'FI DOC NO' '' 10.
m_fieldcat 'MWSKZ' '' 'TC' '' 2.
m_fieldcat 'BKLAS' '' 'VL CLS' '' 4.
m_fieldcat 'CITY1' '' 'VENDOR CITY' '' 10.
m_fieldcat 'QTR_MTH' '' 'MONTH' '' 10.
m_fieldcat 'QTR_YR' '' 'YEAR' '' 4.
m_fieldcat 'REMARKS' '' 'REMARKS' '' 15.
ENDFORM. " build_fieldcat
Define the fieldcatalog in the above said way,so that there won't be lengthy coding.
K.Kiran. -
Hi experts.
I am working on web dynpros ALV display.
A simple program that makes use of salv_wd_table.
I accept gjahr and bukrs from the user and display the corresponding entries from 'bseg' table.
The problem that i face is that, even when in the output node, i am binding only few fields from table to be displayed, when i run the application, the entire bseg table is being displayed with values filled for only those fields which were present in my output node.
Please help.
Thanks,
Prati.Hi,
Remove the BSEG from the DICTIONARY STRUCTURE property of the Node to which the ALV is bound.
Map the node again to ALV data node.
Regards,
Lekha. -
Dynamic Alv for Dynamic Internal Table
Hi All,
I am new for abap dynpro.
How can i create a dynamic alv table in abap dynpro withoud ddic structure??
My requirement is as follows:
I have a table having some field e.g MATNR WERKS NETWR.
I want to pivot data werks and to display in webdynpro alv.
Thnx:
N. N. TiwariYou can use the RTTI to build up a dynamic structure in memory:
Something like this - where both the data and its structure and meta data all come from an external source (which happens to be MDM in this case):
****ALV
data:
rootnode_info type ref to if_wd_context_node_info,
dyn_node type ref to if_wd_context_node,
dyn_node_info type ref to if_wd_context_node_info,
tabname_node type ref to if_wd_context_node,
current_tablename type string,
tablename type string,
struct_type type ref to cl_abap_structdescr,
table_type type ref to cl_abap_tabledescr,
comp_tab type cl_abap_structdescr=>component_table,
comp like line of comp_tab,
my_table type ref to data,
my_row type ref to data.
field-symbols: <table> type table,
<row> type data,
<f> type any,
<wa_string> type string,
<wa_date_time> type mdm_cdt_date_time,
<wa_integer> type mdm_gdt_integervalue.
rootnode_info = wd_context->get_node_info( ).
* create subnode_info
try.
rootnode_info->remove_child_node( 'MDM_DATA' ).
catch cx_wd_context.
endtry.
field-symbols <wa_detail> like line of field_details.
field-symbols <wa_result> like line of result_set.
field-symbols <wa_pair> type mdm_name_value_pair.
read table result_set assigning <wa_result> index 1.
loop at field_details assigning <wa_detail>.
* build a structure description from the list of single fields
if strlen( <wa_detail>-field_code ) > 30.
comp-name = <wa_detail>-field_code+0(30).
else.
comp-name = <wa_detail>-field_code.
endif.
if <wa_result> is assigned.
read table <wa_result>-name_value_pairs assigning <wa_pair>
with key code = <wa_detail>-field_code.
if sy-subrc = 0.
case <wa_pair>-type.
when `MDM_CDT_DATE_TIME`.
comp-type ?= cl_abap_datadescr=>describe_by_name( 'TZNTSTMPL' ).
when `MDM_GDT_INTEGERVALUE`.
if <wa_detail>-field_lookup_table is not initial.
comp-type ?= cl_abap_datadescr=>describe_by_name( 'STRING' ).
else.
comp-type ?= cl_abap_datadescr=>describe_by_name( 'INT4' ).
endif.
when others.
comp-type ?= cl_abap_datadescr=>describe_by_name( <wa_pair>-type ).
endcase.
else.
comp-type ?= cl_abap_datadescr=>describe_by_name( 'STRING' ).
endif.
else.
comp-type ?= cl_abap_datadescr=>describe_by_name( 'STRING' ).
endif.
append comp to comp_tab.
endloop.
struct_type = cl_abap_structdescr=>create( comp_tab ).
dyn_node_info = rootnode_info->add_new_child_node(
name = 'MDM_DATA'
is_mandatory = abap_false
is_mandatory_selection = abap_false
static_element_rtti = struct_type
is_multiple = abap_true
is_static = abap_false ).
* get instance of new node
dyn_node = wd_context->get_child_node( name = 'MDM_DATA' ).
****Process Table Data
data content_string type string.
data l_tabix type sytabix.
table_type = cl_abap_tabledescr=>create( p_line_type = struct_type ).
create data my_table type handle table_type.
assign my_table->* to <table>.
loop at result_set assigning <wa_result>.
create data my_row type handle struct_type.
assign my_row->* to <row>.
loop at field_details assigning <wa_detail>.
l_tabix = sy-tabix.
read table <wa_result>-name_value_pairs assigning <wa_pair>
with key code = <wa_detail>-field_code.
* loop at <wa_result>-name_value_pairs assigning <wa_pair>.
if sy-subrc = 0 and <wa_pair>-value is not initial.
assign component l_tabix of structure <row> to <f>.
* READ TABLE field_details ASSIGNING <wa_detail> INDEX sy-tabix.
case <wa_pair>-type.
when 'STRING'.
assign <wa_pair>-value->* to <wa_string>.
if <wa_string> is assigned.
* DATA: int TYPE i VALUE 258.
* DATA: buffer TYPE xstring,
* text_buffer TYPE string,
* conv TYPE REF TO cl_abap_conv_out_ce.
* conv = cl_abap_conv_out_ce=>create(
* encoding = 'UTF-8'
* endian = 'L' ).
* CALL METHOD conv->write( data = <wa_string> ).
* buffer = conv->get_buffer( ).
* DATA: convin TYPE REF TO cl_abap_conv_in_ce.
* CALL METHOD cl_abap_conv_in_ce=>create
* EXPORTING
* input = buffer
* RECEIVING
* conv = convin.
* CALL METHOD convin->read
* IMPORTING
* data = text_buffer.
* MOVE text_buffer TO <f>.
move <wa_string> to <f>.
endif.
when 'MDM_CDT_DATE_TIME'.
assign <wa_pair>-value->* to <wa_date_time>.
if <wa_date_time> is assigned.
move <wa_date_time>-content to <f>.
endif.
when 'MDM_GDT_INTEGERVALUE'.
assign <wa_pair>-value->* to <wa_integer>.
if <wa_integer> is assigned.
if <wa_detail>-field_lookup_table is not initial.
content_string = wd_assist->perform_value_lookup(
i_lookup_table = <wa_detail>-field_lookup_table
i_lookup_key = <wa_integer> ).
move content_string to <f>.
else.
move <wa_integer> to <f>.
endif.
endif.
endcase.
endif.
endloop.
append <row> to <table>.
endloop.
dyn_node->bind_table( <table> ).
* Connect to the component Usage of the ALV
data: l_ref_cmp_usage type ref to if_wd_component_usage.
l_ref_cmp_usage = wd_this->wd_cpuse_alv( ).
if l_ref_cmp_usage->has_active_component( ) is initial.
l_ref_cmp_usage->create_component( ).
endif.
* Through the interface controller of the ALV Component set the DATA node dynamically
data: l_ref_interfacecontroller type ref to iwci_salv_wd_table .
l_ref_interfacecontroller = wd_this->wd_cpifc_alv( ).
l_ref_interfacecontroller->set_data(
r_node_data = dyn_node ).
data alv_model type ref to cl_salv_wd_config_table.
alv_model = l_ref_interfacecontroller->get_model( ).
data columns type salv_wd_t_column_ref.
field-symbols <wa_column> like line of columns.
columns = alv_model->if_salv_wd_column_settings~get_columns( ).
data column_id type string.
data header type ref to cl_salv_wd_column_header.
data l_text type string.
loop at field_details assigning <wa_detail>.
* build a structure description from the list of single fields
if strlen( <wa_detail>-field_code ) > 30.
column_id = <wa_detail>-field_code+0(30).
else.
column_id = <wa_detail>-field_code.
endif.
translate column_id to upper case.
read table columns assigning <wa_column> with table key id = column_id.
if sy-subrc = 0.
header = <wa_column>-r_column->get_header( ).
header->set_ddic_binding_field( if_salv_wd_c_column_settings=>ddic_bind_none ).
* if <wa_detail>-field_lookup_table is initial.
header->set_text( <wa_detail>-field_name1 ).
* else.
* l_text = wd_assist->read_table_desc_for_lookup( <wa_detail>-field_lookup_table ).
* header->set_text( l_text ).
* endif.
endif.
endloop.
catch cx_root into o_except.
data: l_current_controller type ref to if_wd_controller,
l_message_manager type ref to if_wd_message_manager.
l_current_controller ?= wd_this->wd_get_api( ).
l_message_manager = l_current_controller->get_message_manager( ).
l_message_manager->report_exception(
message_object = o_except ).
endtry. -
Dynamic ALV with Static and Dynamic attributes
Hi All,
In my requirement we have some 5 static attributes and rest attributes needs needs to be dynamically created based upon the input selections. for eg my input for start date and end date is between 201023 to 201152 then weeks between this range should apear as dynamic columns.
i am able to create a dummy alv table display with out populating data into it but unable to set the data to it . Kindly help me in solving this issue.
Regards,
Sana.You might have created a dynamic node, bind the data to this node and after that use the SET_DATA method of ALV interface controller to set the data by passing the dynamically created node.
-
How to make cell coloring in dynamic ALV,I did it in normal internal tables.Any body can help me here?
Or can anybody tell me how to convert a field symbol to an internal table? as I have created a dynamic IT.
Thanks in advance.Thanks for u r quick replies,Now Iam not getting any error,the program getting executed without any error.But Iam not getting any colors,what might be the problem? Do I need to pass IS_layot to ALV_GRID FM ? I have not created any Layout though,here is my complete code :
TABLES : vbbe.
TYPE-POOLS : slis.
*& Data Declarations *
DATA : diff TYPE i VALUE 0,
maktx LIKE makt-maktx,
labst LIKE mard-labst.
DATA : BEGIN OF it_data OCCURS 0,
matnr LIKE vbbe-matnr,
mbdat LIKE vbbe-mbdat,
omeng LIKE vbbe-omeng,
END OF it_data,
wa_data LIKE LINE OF it_data.
DATA : g_tdref TYPE REF TO data,
g_wdref TYPE REF TO data.
DATA : dats LIKE vbbe-mbdat,
lvc_t_fieldcat TYPE lvc_t_fcat,
lvc_s_fieldcat TYPE lvc_s_fcat,
it_fldcat TYPE slis_t_fieldcat_alv,
wa_fldcat TYPE slis_fieldcat_alv.
FIELD-SYMBOLS : <it_dyn> TYPE STANDARD TABLE,
<wa_dyn>,
<dyn_field>.
*& Selection-Screen *
SELECTION-SCREEN BEGIN OF BLOCK blk1 WITH FRAME TITLE text-001.
SELECT-OPTIONS : s_mbdat FOR vbbe-mbdat OBLIGATORY.
PARAMETER p_werks LIKE mard-werks OBLIGATORY.
SELECTION-SCREEN END OF BLOCK blk1.
*& INITIALIZATION *
INITIALIZATION.
p_werks = '1200'.
*& Start-Of-Selection *
START-OF-SELECTION.
PERFORM f_build_lvc_and_slis.
PERFORM f_build_dynamic_it.
PERFORM f_get_data.
PERFORM f_get_fata_into_it.
PERFORM f_display_alv.
*& Form f_build_lvc
FORM f_build_lvc_and_slis.
*.................Build LVC Fieldcatalog...............................*
lvc_s_fieldcat-tabname = 'MSKA'.
lvc_s_fieldcat-col_pos = 1.
lvc_s_fieldcat-fieldname = 'WERKS'.
lvc_s_fieldcat-datatype = 'CHAR'.
lvc_s_fieldcat-intlen = '10'.
APPEND lvc_s_fieldcat TO lvc_t_fieldcat.
CLEAR : lvc_s_fieldcat.
lvc_s_fieldcat-tabname = 'MSKA'.
lvc_s_fieldcat-col_pos = 2.
lvc_s_fieldcat-fieldname = 'MATNR'.
lvc_s_fieldcat-datatype = 'CHAR'.
lvc_s_fieldcat-intlen = '18'.
APPEND lvc_s_fieldcat TO lvc_t_fieldcat.
CLEAR : lvc_s_fieldcat.
lvc_s_fieldcat-tabname = 'MAKT'.
lvc_s_fieldcat-col_pos = 3.
lvc_s_fieldcat-fieldname = 'MAKTX'.
lvc_s_fieldcat-datatype = 'CHAR'.
lvc_s_fieldcat-intlen = '10'.
APPEND lvc_s_fieldcat TO lvc_t_fieldcat.
CLEAR : lvc_s_fieldcat.
lvc_s_fieldcat-tabname = 'MARD'.
lvc_s_fieldcat-col_pos = 4.
lvc_s_fieldcat-fieldname = 'LABST'.
lvc_s_fieldcat-datatype = 'QUAN'.
lvc_s_fieldcat-intlen = '13'.
APPEND lvc_s_fieldcat TO lvc_t_fieldcat.
CLEAR : lvc_s_fieldcat.
lvc_s_fieldcat-tech = 'X'.
lvc_s_fieldcat-col_pos = 5.
lvc_s_fieldcat-fieldname = 'TCOLOR'.
lvc_s_fieldcat-ref_field = 'COLOR'.
lvc_s_fieldcat-ref_table = 'ZLVC_COL'.
lvc_s_fieldcat-scrtext_l = 'COLOR'.
APPEND lvc_s_fieldcat TO lvc_t_fieldcat.
CLEAR : lvc_s_fieldcat.
*.................Build SLIS Fieldcatalog..............................*
wa_fldcat-tabname = 'MSKA'.
wa_fldcat-col_pos = 1.
wa_fldcat-fieldname = 'WERKS'.
wa_fldcat-datatype = 'CHAR'.
wa_fldcat-seltext_m = wa_fldcat-seltext_l = wa_fldcat-seltext_s =
'Plant'.
wa_fldcat-intlen = '6'.
APPEND wa_fldcat TO it_fldcat.
CLEAR : wa_fldcat.
wa_fldcat-tabname = 'MSKA'.
wa_fldcat-outputlen = 15.
wa_fldcat-col_pos = 2.
wa_fldcat-fieldname = 'MATNR'.
wa_fldcat-datatype = 'CHAR'.
wa_fldcat-seltext_l = 'Material Number'.
wa_fldcat-intlen = '16'.
APPEND wa_fldcat TO it_fldcat.
CLEAR : wa_fldcat.
wa_fldcat-tabname = 'MAKT'.
wa_fldcat-outputlen = 23.
wa_fldcat-col_pos = 3.
wa_fldcat-fieldname = 'MAKTX'.
wa_fldcat-datatype = 'CHAR'.
wa_fldcat-seltext_l = 'Material Description'.
wa_fldcat-intlen = '20'.
APPEND wa_fldcat TO it_fldcat.
CLEAR : wa_fldcat.
wa_fldcat-tabname = 'MARD'.
wa_fldcat-col_pos = 4.
wa_fldcat-fieldname = 'LABST'.
wa_fldcat-datatype = 'QUAN'.
wa_fldcat-intlen = '13'.
wa_fldcat-seltext_m = wa_fldcat-seltext_l = wa_fldcat-seltext_s =
'x Stock'.
APPEND wa_fldcat TO it_fldcat.
CLEAR : wa_fldcat.
wa_fldcat-tech = 'X'.
wa_fldcat-col_pos = 5.
wa_fldcat-fieldname = 'TCOLOR'.
wa_fldcat-ref_fieldname = 'COLOR'.
wa_fldcat-ref_tabname = 'ZLVC_COL'.
wa_fldcat-seltext_l = 'COLOR'.
APPEND wa_fldcat TO it_fldcat.
CLEAR : wa_fldcat.
*.................Build Dynamic Fields for LVC and SLIS................*
DATA : d TYPE i,
col(6) TYPE n VALUE '0',
date TYPE dats,
day(8) TYPE c,
number(2) TYPE n VALUE '0'.
d = s_mbdat-high - s_mbdat-low + 1.
date = s_mbdat-low - 1.
DO d TIMES.
number = number + 1.
date = date + 1.
col = col + 1.
CONCATENATE 'x Day' number INTO day.
lvc_s_fieldcat-tabname = 'VBBE'.
lvc_s_fieldcat-col_pos = col + 5.
lvc_s_fieldcat-fieldname = date.
lvc_s_fieldcat-datatype = 'QUAN'.
lvc_s_fieldcat-intlen = '15'.
APPEND lvc_s_fieldcat TO lvc_t_fieldcat.
CLEAR : lvc_s_fieldcat.
wa_fldcat-tabname = 'VBBE'.
wa_fldcat-col_pos = col + 5.
wa_fldcat-fieldname = date.
wa_fldcat-datatype = 'QUAN'.
wa_fldcat-intlen = '15'.
wa_fldcat-seltext_l = day.
APPEND wa_fldcat TO it_fldcat.
CLEAR : wa_fldcat.
ENDDO.
ENDFORM. " f_build_lvc
*& Form f_build_dynamic_it
FORM f_build_dynamic_it .
CALL METHOD cl_alv_table_create=>create_dynamic_table
EXPORTING
it_fieldcatalog = lvc_t_fieldcat
IMPORTING
ep_table = g_tdref.
ASSIGN g_tdref->* TO <it_dyn>.
CREATE DATA g_wdref LIKE LINE OF <it_dyn>.
ASSIGN g_wdref->* TO <wa_dyn>.
ENDFORM. " f_build_dynamic_it
*& Form f_get_data
FORM f_get_data .
SELECT matnr mbdat omeng FROM vbbe INTO CORRESPONDING FIELDS OF TABLE
it_data WHERE mbdat IN s_mbdat AND
werks = p_werks.
DELETE it_data WHERE omeng = 0 .
SORT it_data BY matnr ASCENDING.
ENDFORM. " f_get_data
*& Form f_get_fata_into_it
FORM f_get_fata_into_it .
FIELD-SYMBOLS : <fs>,
<ta_color> TYPE table.
DATA : field(15) TYPE c,
col TYPE lvc_s_scol.
LOOP AT it_data INTO wa_data.
SELECT SINGLE maktx FROM makt INTO maktx WHERE matnr =
wa_data-matnr.
SELECT SINGLE labst FROM mard INTO labst WHERE matnr =
wa_data-matnr AND werks = p_werks.
diff = wa_data-mbdat - s_mbdat-low + 6.
ASSIGN COMPONENT 1 OF STRUCTURE <wa_dyn> TO <fs>.
<fs> = p_werks.
ASSIGN COMPONENT 2 OF STRUCTURE <wa_dyn> TO <fs>.
<fs> = wa_data-matnr.
ASSIGN COMPONENT 3 OF STRUCTURE <wa_dyn> TO <fs>.
<fs> = maktx.
ASSIGN COMPONENT 4 OF STRUCTURE <wa_dyn> TO <fs>.
<fs> = labst.
ASSIGN COMPONENT diff OF STRUCTURE <wa_dyn> TO <fs>.
<fs> = wa_data-omeng.
IF labst < wa_data-omeng.
col-fname = wa_data-mbdat.
col-color-col = '5' .
col-color-int = '1'.
ELSE.
col-fname = wa_data-mbdat.
col-color-col = '5' .
col-color-int = '0' .
ENDIF.
ASSIGN COMPONENT 'TCOLOR' OF STRUCTURE <wa_dyn> TO <ta_color>.
APPEND col TO <ta_color> .
APPEND <wa_dyn> TO <it_dyn>.
CLEAR <wa_dyn>.
ENDLOOP.
ENDFORM. " f_get_fata_into_it
*& Form f_display_alv
FORM f_display_alv .
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
* I_INTERFACE_CHECK = ' '
* I_BYPASSING_BUFFER = ' '
* I_BUFFER_ACTIVE = ' '
i_callback_program = sy-repid
* I_CALLBACK_PF_STATUS_SET = ' '
* I_CALLBACK_USER_COMMAND = ' '
* I_CALLBACK_TOP_OF_PAGE = ' '
* I_CALLBACK_HTML_TOP_OF_PAGE = ' '
* I_CALLBACK_HTML_END_OF_LIST = ' '
* I_STRUCTURE_NAME =
* I_BACKGROUND_ID = ' '
* I_GRID_TITLE =
* I_GRID_SETTINGS =
* IS_LAYOUT =
it_fieldcat = it_fldcat
* IT_EXCLUDING =
* IT_SPECIAL_GROUPS =
* IT_SORT =
* IT_FILTER =
* IS_SEL_HIDE =
* I_DEFAULT = 'X'
* I_SAVE = ' '
* IS_VARIANT =
* IT_EVENTS =
* IT_EVENT_EXIT =
* IS_PRINT =
* IS_REPREP_ID =
* I_SCREEN_START_COLUMN = 0
* I_SCREEN_START_LINE = 0
* I_SCREEN_END_COLUMN = 0
* I_SCREEN_END_LINE = 0
* IT_ALV_GRAPHICS =
* IT_HYPERLINK =
* IT_ADD_FIELDCAT =
* IT_EXCEPT_QINFO =
* I_HTML_HEIGHT_TOP =
* I_HTML_HEIGHT_END =
* IMPORTING
* E_EXIT_CAUSED_BY_CALLER =
* ES_EXIT_CAUSED_BY_USER =
TABLES
t_outtab = <it_dyn>
EXCEPTIONS
program_error = 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.
ENDFORM. " f_display_alv -
Hi,
One of the table column in my ALV table displays Sales order with line item separated by "-".
For Ex : 70000174 - 10.
The sales order number should be a link in the table. When we click on Sales order number it should display another view.
How can I make only sales order number as a link?
Please note: Line item number should not be a link.
It should appear as below in the table.
70000174 - 10
70000175 - 10
70000176 - 10
70000177 - 10
Thanks in advance,
PrathapHi,
Having concatenatedvalue into once column and showing link to part of cell is not possible. Try to have salesorder and lineitem in 2 columns, and provide the link for salesorder.
Let your cleint know that the above case(original post) is not possible.
One more thing, POPINS are not possible for ALV. Youcan use TABLE UI element for popins.
Regards,
Lekha. -
Hi friends
i need some help now , i created one ALV TABLE , and one node name as flighinfo and im retriving the 4 FIELDS ONLY from SFLIGHT TABLE
and i binded it to the Data node ALV context
but in the runtime the ALV TABLE DISPLAYS all the fields from the sflight table
what can i do for displaying only whateve i need ?
Thanks
Sankar.MHi Radhika thanks for your reply ,
i got the solution
Thanks
Sankar.M -
How to give color of particular cell in alv list display for dynamic table
Dear Experts,
i want to give color of a particular cell in alv list display (reuse_alv_list_display). Here i am passing data through dynamic table?Hi,
Se this:
DATA: lt_color TYPE lvc_t_scol WITH HEADER LINE.
DATA: BEGIN OF data_tab OCCURS 0.
tabcolor TYPE lvc_t_scol,
END OF data_tab.
* Befone ALV call
alv_layout-coltab_fieldname = 'TABCOLOR'.
* For each row in data_tab
REFRESH: lt_color.
CLEAR: lt_color.
lt_color-color-col = 6.
lt_color-color-int = 1.
lt_color-fname = FIELD1'.
APPEND lt_color.
lt_color-color-col = 2.
lt_color-color-int = 0.
lt_color-fname = 'FIELD2'.
APPEND lt_color.
data_tab-tabcolor[] = lt_color[].
append data_tab.
Best regards,
Leandro Mengue -
Create dynamic internal table with deep structure;cell coloring dynamic ALV
Hi,
My requirement is to do cell colouring for a dynamic ALV.
So I am creating a dynamic internal table using the following method.
CALL METHOD cl_alv_table_create=>create_dynamic_table
EXPORTING
it_fieldcatalog = i_fieldcatalog[]
IMPORTING
ep_table = i_output.
But how do I define field COLORS which should be again an internal table ?
Is there any other way for cell colouring?
Putting my problem in another way:
How do I create a dynamic internal table with one field as another internal table.
Quick replies are highly appreciated.
Thanks,
Nisha Vengal.halo Nisha
Before building the display table . you can add the field in the feild catalog right . This display table gets generated from the field catalog right
1 Create a global structute say ZEXTEND_FIELDCAT
2 Have fields like STYLE type lvc_t_styl
COLOR type LVC_T_SCOL.
3 Now you have to extend ur fieldcatalog
l_fieldcat-fieldname = COLOR'.
l_fieldcat-ref_field = 'COLOR'.
l_fieldcat-ref_table = 'ZEXTEND_FIELDCAT'.
APPEND l_fieldcat TO lt_field_catalog.
CLEAR l_fieldcat. -
Populating two dynamic internal tables and displaying the O/p as ALV
I want to develop a abap prototype program report for the SD document flow analysis...
There is a Fm : RV_ORDER_FLOW_INFORMATION in which if we pass the Sales order number it returns the flows as VBFA_TAB.
I need to populate two dynamic ITAB1 and ITAB2
the structure of ITAB1 should be like ColNm1....ColNmn
The values for ColNm1 will be Sales Order ColNm2 as Delivery or smthng else depending on field vbtyp_n.
ITAB 2 should have the corresponding values accly to ITAB1.
Then we need to display in ALV o/p.
The tables should be populated dynamically.
Can anybody throw some light on it and plz do write back with sample code to do the logic of it.Search in SDN with Dynamic internal tables.
you get lot of code samples and Discussions related to Dynamic internal tables.
you can also check with this class CL_ALV_TABLE_CREATE
Maybe you are looking for
-
Adobe Media Encoder Export Settings Window Dimensions Problem
Any help on this would be appreciated: I'm on a macbook pro, osx 10.6, using CS4 Web Premium. I used to have an external monitor hooked up which had much higher resolution, so when using Adobe Media Encoder I'd click the Settings button on a video to
-
some news for drivers os x mavericks and epson stylus photo px720wd ? the part "printer" is ok the part "scanner" is of duty because no driver found thanks
-
When I try to install flash player 13 I get a message Error: Failed to register
I get Error: Failed to register when installing flash player 13 on Internet 8 Windows XP. What is the solution? Anybody?
-
Installer won't initialize, "missing file"?
Hey all, I'm pounding my head against the wall here trying to install CS6 Design Standard on my Mac (OSX 10.7.3). I first tried to install last night, and everything seemed to be going just fine. The installer opened, I entered my serial number and s
-
What is Labview scripting?
What is LabVIEW scripting? I have seen it being mentioned on this and lavag forums? What can we do with it (that normal programming does not allow)? Where can I learn about it?