Show dynamic columns in ALV table
I have a question that i need to create report in ALV
like this ...
i need to select doc date e.g. from 03.11.2007 to 05.02.2008
and the report is expected to show like this
SO# | cust | sales gp | 2007-11 order amt | 2007-12 order amt | 2008-01 order amt | 2008-02 order amt
____ |_____|________|________________|________________|________________|_________________
| | | | | |
something like that ....
the no. of period column which is depend on the range of selected doc date....
so how to do that ?!?!?
hi sky ,
use dynamic table as:-
Declaration for Dynamic Table:-
FIELD-SYMBOLS: <dyn_table> TYPE STANDARD TABLE,
<dyn_table1> TYPE STANDARD TABLE,
<dyn_wa1>,
<dyn_wa>.
FIELD-SYMBOLS: <l_fs_dyn> TYPE ANY,
<l_fs_bom> TYPE ANY.
*---Dynamic Internal Table
DATA: dy_table TYPE REF TO data,
dy_table1 TYPE REF TO data,
dy_line TYPE REF TO data.
Creation of Dynamic Internal Table:-
CALL METHOD cl_alv_table_create=>create_dynamic_table
EXPORTING
it_fieldcatalog = fcat (for which internal table needs to be built)
IMPORTING
ep_table = dy_table
EXCEPTIONS
generate_subpool_dir_full = 1
OTHERS = 2
IF sy-subrc <> 0.
ENDIF.
Population of Dynamic Internal Table:-
CLEAR: l_tabix,
w_tabix.
ASSIGN dy_table->* TO <dyn_table>.
CREATE DATA dy_line LIKE LINE OF <dyn_table>.
ASSIGN dy_line->* TO <dyn_wa>.
ASSIGN dy_table->* TO <dyn_table1>.
CREATE DATA dy_line LIKE LINE OF <dyn_table1>.
ASSIGN dy_line->* TO <dyn_wa1>.
LOOP AT it_parent.
l_tabix = sy-tabix.
LOOP AT fcat INTO ls_fcat TO 23."WHERE col_pos <= '19'.
ASSIGN COMPONENT ls_fcat-fieldname
OF STRUCTURE <dyn_wa> TO <l_fs_dyn>.
ASSIGN COMPONENT ls_fcat-fieldname
OF STRUCTURE it_parent TO <l_fs_bom>.
<l_fs_dyn> = <l_fs_bom>.
ENDIF.
ENDLOOP
Thanks & Regards,
Ruchi Tiwari
Similar Messages
-
halo fellow SAPiens,
i need to show dynamic columns for a particular material........the scenario is as follows....
1) there r 7 fixed columns describing the material...
2)when the material returns back to the plant for some reason , i need to insert a column which shows the date and reason(char) of return.
3)again after dispatching the material for some reason it comes back again a new column shld be displayed showin the date and reason(char).
4)if the material doesnt come back...the report shows only 7 columns.
any solution?try <a href="http://www.alvrobot.com.ar/home.php">here</a> ......its a useful tool for dealing with ALV
<b>reward points if useful</b> -
How to remove a column from alv table
Hi All
How to remove a specific column from alv table.?
Thanks & Regards
SUNFor delete u can follow the above post..
Fo making invisible :
data m_col type ref to cl_salv_wd_column.
m_col = alv_mode->IF_SALV_WD_COLUMN_SETTINGS->GET_COLUMN (' col1' ).
m_col->SET_VISIBILITY( '01' ). -
Hideing a Column in ALV Table which is Displaying the POWL Query data
Hi SDNers,
I want to hide a column of ALV Table which is displaying my POWL Query data in it and hideing should be based on the Role as well. i.e few of the role the column shoudl be hidden and few of the roles should have the Column visible.
waiting for the Valueble Answers.
Thanks & Regards,
GovinduHai Kris,
I took help from ur link and i declared a global attribute request_number.
and i created an event handler ON_ALV_INSERT and did the follwing coding for giving default value wen ever am inserting new row.
FIELD-SYMBOLS: <wa_row> LIKE LINE OF r_param->t_inserted_rows.
DATA bill_details TYPE REF TO zdom_bill_detail.
LOOP AT r_param->t_inserted_rows ASSIGNING <wa_row>.
bill_details ?= <wa_row>-r_value.
IF bill_details->REQ_NUMBER IS INITIAL.
DATA lo_nd_bill_detail TYPE REF TO if_wd_context_node.
DATA lo_el_bill_detail TYPE REF TO if_wd_context_element.
DATA ls_bill_detail TYPE wd_this->Element_bill_detail.
navigate from <CONTEXT> to <BILL_DETAIL> via lead selection
lo_nd_bill_detail = wd_context->get_child_node( name = wd_this->wdctx_bill_detail ).
lo_el_bill_detail = lo_nd_bill_detail->get_element( index = <wa_row>-index ).
lo_el_bill_detail->set_attribute(
EXPORTING
name = 'REQ_NUMBER'
value = wd_comp_controller->request_number
Wen am setting the value of wd_comp_controller->request_number to my context attribute am getting NULL object ref error.
lo_el_bill_detail->set_attribute(
name = `REQ_NUMBER`
value = wd_comp_controller->request_number ).
Pls give some suggestions,
Thanks in Advance,
Nalla.B -
Write protect a column in ALV Table
Hi All,
I have an ALV Table with few columns. Some of the columns has got check boxes. Now my question is, depending on the conditions i want to write protect a particular column. Could you tell me how to do it?
Thanks & Regards,
RaviHi Ravi,
By default the column of ALV table are in read only mode but you want them to based on certain contion them first make that column editable by using the following code
data l_table type ref to cl_salv_wd_config_table.
l_table = l_salv_wd_table->get_model( ).
DATA: lr_column_settings TYPE REF TO if_salv_wd_column_settings,
lr_input_field TYPE REF TO cl_salv_wd_uie_input_field.
lr_column_settings ?= l_table.
l_column = lr_column_settings->get_column( 'CARRID' ).
CREATE OBJECT lr_input_field EXPORTING value_fieldname = 'CARRID'.
l_column->set_cell_editor( lr_input_field ).
data: lr_table_settings type ref to if_salv_wd_table_settings.
lr_table_settings ?= l_table.
lr_table_settings->set_read_only( abap_false ).
Now create an event handler associated with the ON_CLICK event of alv and used the following code the made the column read only (based on condition)
data l_table type ref to cl_salv_wd_config_table.
l_table = l_salv_wd_table->get_model( ).
data: lr_table_settings type ref to if_salv_wd_table_settings.
lr_table_settings ?= l_table.
lr_table_settings->set_read_only( abap_false ).
I hope it helps.
You can also refer this article[Editing ALV in Web Dynpro for ABAP |https://www.sdn.sap.com/irj/servlet/prt/portal/prtroot/docs/library/uuid/3133474a-0801-0010-d692-81827814a5a1].
Regards
Arjun -
How to get one column of ALV table as dropdown by key.
Hi experts,
How can I get one column of ALV table as dropdown and editable. If user wants to change that column value he can just select from that dropdown and click on update button. Can I provide tool tip to that column as " Select from drop down to change the status "?
Please Help.
Thanks,
PratibhaYou just need to change the cell editor of that column in ALV.
So first get access to the alv model object (adjusting the code below for your ALV Component Usage name - mine was ALV_ADV):
DATA: l_ref_cmp_usage TYPE REF TO if_wd_component_usage.
l_ref_cmp_usage = wd_this->wd_cpuse_alv_adv( ).
IF l_ref_cmp_usage->has_active_component( ) IS INITIAL.
l_ref_cmp_usage->create_component( ).
ENDIF.
DATA l_salv_wd_table TYPE REF TO iwci_salv_wd_table.
l_salv_wd_table = wd_this->wd_cpifc_alv_adv( ).
DATA l_table TYPE REF TO cl_salv_wd_config_table.
l_table = l_salv_wd_table->get_model( ).
Then access the column object you want to change:
DATA l_column TYPE REF TO cl_salv_wd_column.
l_column = l_table->if_salv_wd_column_settings~get_column( 'REGION' ).
Then create the cell editor for DDLB and set it as the new cell editor for this column:
DATA ddlb TYPE REF TO cl_salv_wd_uie_dropdown_by_key.
create object ddlb
exporting
selected_key_fieldname = 'REGION'.
ddlb->set_tooltip( `Select from drop down to change the status` ).
l_column->set_cell_editor( ddlb ). -
Dear Experts,
I want to display dynamc columns in ALV, how it possible.
venkeycreate dynamic internal table from field catalog i m sending u some sample code hope it will help u.
FORM create_dynamic_itab.
Create dynamic internal table and assign to FS
CALL METHOD cl_alv_table_create=>create_dynamic_table
EXPORTING
it_fieldcatalog = it_fieldcat[]
IMPORTING
ep_table = dy_table.
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>.
ENDFORM. -
To increase dynamically columns in ALV report
hi everyone,
Could any one give me a sample code ,to increase columns in ALV report output dynamically as record increase, i need to increase columns so that i can keep all the years data of a particular project in one rowPlease refer to the code piece
*& Report ZTEST_DYNAMIC_ALV
REPORT ztest_dynamic_alv.
DATA: gt_fcat TYPE lvc_t_fcat,
gw_grid TYPE REF TO cl_gui_alv_grid.
SELECTION-SCREEN: BEGIN OF BLOCK b1 WITH FRAME TITLE text-s01.
PARAMETERS: p_number TYPE i.
SELECTION-SCREEN : END OF BLOCK b1.
** Start of Selection
START-OF-SELECTION.
*1) Create Base Catalog
PERFORM sub_create_base_catalog.
*2) Add additional fields
PERFORM sub_fill_addtional.
*3) Display output data.
PERFORM sub_display_output.
*& Form SUB_CREATE_BASE_CATALOG
* Create Base catalog for display
FORM sub_create_base_catalog .
CALL FUNCTION 'LVC_FIELDCATALOG_MERGE'
EXPORTING
i_structure_name = 'ZSTRCT'
CHANGING
ct_fieldcat = gt_fcat
EXCEPTIONS
inconsistent_interface = 1
program_error = 2
OTHERS = 3.
ENDFORM. " SUB_CREATE_BASE_CATALOG
*& Form SUB_FILL_ADDTIONAL
* text
FORM sub_fill_addtional .
DATA: lw_fcat TYPE lvc_s_fcat,
lw_from TYPE i,
lw_data TYPE REF TO data,
lw_fname TYPE stfna,
lw_index(2) TYPE n.
FIELD-SYMBOLS: <l_output> TYPE table.
DESCRIBE TABLE gt_fcat LINES lw_from.
DO p_number TIMES.
lw_from = lw_from + 1.
lw_index = sy-index.
CONCATENATE 'DYNA' lw_index INTO lw_fname SEPARATED BY '-'.
lw_fcat-col_pos = lw_from.
lw_fcat-fieldname = lw_fname.
lw_fcat-tabname = '1'.
lw_fcat-scrtext_l = lw_fcat-scrtext_m = lw_fcat-scrtext_s = lw_fname.
APPEND lw_fcat TO gt_fcat.
CLEAR lw_fcat.
ENDDO.
** Convert gt_fcat to internal table.
CALL METHOD cl_alv_table_create=>create_dynamic_table
EXPORTING
it_fieldcatalog = gt_fcat
IMPORTING
ep_table = lw_data
EXCEPTIONS
generate_subpool_dir_full = 1
OTHERS = 2.
IF sy-subrc = 0.
** Create the internal table form field catalog.
ASSIGN lw_data->* TO <l_output>.
** display the ALV data.
CREATE OBJECT gw_grid
EXPORTING
i_parent = cl_gui_container=>screen0
EXCEPTIONS
error_cntl_create = 1
error_cntl_init = 2
error_cntl_link = 3
error_dp_create = 4
OTHERS = 5.
IF sy-subrc = 0.
CALL METHOD gw_grid->set_table_for_first_display
CHANGING
it_outtab = <l_output>
it_fieldcatalog = gt_fcat
EXCEPTIONS
invalid_parameter_combination = 1
program_error = 2
too_many_lines = 3
OTHERS = 4.
IF sy-subrc = 0.
MESSAGE s000(zrak) WITH p_number 'DISPLAYED DYNAMICALLY'.
ENDIF.
ENDIF.
ENDIF.
ENDFORM. " SUB_FILL_ADDTIONAL
*& Form SUB_DISPLAY_OUTPUT
* text
FORM sub_display_output .
CALL SCREEN '9001'.
ENDFORM. " SUB_DISPLAY_OUTPUT
*& Module STATUS_9001 OUTPUT
* text
MODULE status_9001 OUTPUT.
SET PF-STATUS ' '.
SET TITLEBAR 'MAIN00'.
ENDMODULE. " STATUS_9001 OUTPUT
*& Module USER_COMMAND_9001 INPUT
* text
MODULE user_command_9001 INPUT.
CASE sy-ucomm.
WHEN 'BACK' OR
'CANC' OR
'%EX'.
SET SCREEN 0.
ENDCASE.
ENDMODULE. " USER_COMMAND_9001 INPUT -
Dynamic columns for ALV/classical
Hi friends,
I came across an issue where I need to create an output list based on the selection screen.
Example: In selection screen if user enters plant 1000 2000 3000 4000 .
I want the output table having columns 1000 2000 3000 4000 .
Please help me out how to accomplish this task. Is this functionality is possible with ALV..?
A sample code for this will really help me a lot .. or send me your valuable suggestions..
Thanks
Prasead KSearch sdn for [cl_alv_table_create=>create_dynamic_table|https://www.sdn.sap.com/irj/scn/advancedsearch?query=cl_alv_table_create%3d%3ecreate_dynamic_table&cat=sdn_all], there are already many threads and samples. Basically, you dynamically fill an ALV fieldcatalog, then use the method to create a dynamic internal table from this catalog, fill the internal table and display it.
Regards -
Multiple dynamic column in cross table
Hi all,
I have a cross table which stored the sale's quantity and amount.
The layout in view result likes below:
saler quantity1 quantity2 quantity3 quantitysummary amount1 amount2 amount3 amount4 amountsummary
S3 100 20
S2 50 30
S1 300 40
The layout in view structure likes below:
saler quantity quantitysummary amount amountsummary
S3 100 20
S2 50 30
S1 300 40
the quantity1...n and amount1...n columns is not fixed.the 2 columns is dynamic.
It's easy that only one column is dynamic,but now there are two columns is dynamic,I don't know how to achieve it.
Has anyone an idea how to accomplish this?
Thank you trying to help me!You cant do this on BO , you can add static columns but if you put some dynamic column in the left or right i turns dynamic...
Regards -
How to unhide the column in Alv table
Hi Experts,
Initially i have created webdynpro Alv table with 8 columns ,later i have added one more attribute/column to the node to display extra column
but in the output ,alv table not displaying the 9th column,Instead the column is getting hidden which i came to know clicking on settings in alv table output.If i make changes in Alv table settings it getting displaying,can anyone tell me how to unhide this field.
Regards
SandeshHi Sandesh,
It is possible that the user you are loggin in with, might have a layout saved.
You can try logging in with different user and see if its still hidden.
The explicit code to hide and unhide a column :
lo_alv_column->set_visible( if_wdl_core=>visibility_none ).
may be you can use the above code and make column visibility true(cahnge parameter).
Regards,
Tashi -
Showing Dynamic Columns in UWL
Hello guys
I m building a customized UWL using WDJ and the UWL API... Everything is working fine, except for one detail: I need to show a dynamic column created into swl1.
There is any way to do this? I looked for something into UWL APIs javadoc and didn't found nothing.....
ThanksHello guys
Thanks for you replies. I think that I was not clear in my question.....
I have already configured the UWL and created a simple application in WD....
The problem is that I need to bring an dynamic column created into swl1 transaction.... This column could be showed when you enter into R/3 inbox and select the "Change Layout" option, but this option is not avaliable into standard UWL. I tried to create an new application using the UWL API, but I couldnt access this column to....
The steps are showed at the follow prints: http://img33.imageshack.us/gal.php?g=swl1.jpg
Maybe this limitation is caused because the UWL is created to work with N types of workflows, so it could not be so specific ( Am I telling bullshit ?? ) .
Did you got my problem now... My English is poor, so maybe I cant expose my problems clearly.
Thanks -
Dynamic Column Header On Table Control
Dear Friend
How I can set Dynamic Column Header Text On Table Control
Regards
SupperkornJust set it to a global variable name, and then set the value of that global variable as needed, e.g. in your TOP include define "g_my_header(20) type c" and then use g_my_header in the "Table column header" definition in the Dynpro... and in your PBO code put a value in g_my_header.
Jonathan -
Dynamical columns in internal table
Hi all.
I need to make an internal table with dynamical columns(i have 3 static columns and the rest depends on the number of clients that i have in a month). If it's possible, how can i do it?
Can anyone please help.
Thanks & RegardsHi,
type-pools : abap.
field-symbols: <dyn_table> type standard table,
<dyn_wa>,
<dyn_field>.
data: dy_table type ref to data,
dy_line type ref to data,
xfc type lvc_s_fcat,
ifc type lvc_t_fcat.
selection-screen begin of block b1 with frame.
parameters: p_table(30) type c default 'T001'.
selection-screen end of block b1.
start-of-selection.
perform get_structure.
perform create_dynamic_itab. <b> *Creates a dyanamic internal table **</b>
perform get_data.
perform write_out.
form get_structure.
data : idetails type abap_compdescr_tab,
xdetails type abap_compdescr.
data : ref_table_des type ref to cl_abap_structdescr.
* Get the structure of the table.
ref_table_des ?=
cl_abap_typedescr=>describe_by_name( p_table ).
idetails[] = ref_table_des->components[].
loop at idetails into xdetails.
clear xfc.
xfc-fieldname = xdetails-name .
xfc-datatype = xdetails-type_kind.
xfc-inttype = xdetails-type_kind.
xfc-intlen = xdetails-length.
xfc-decimals = xdetails-decimals.
append xfc to ifc.
endloop.
endform.
form create_dynamic_itab.
<b>* Create dynamic internal table and assign to FS</b>
call method cl_alv_table_create=>create_dynamic_table
exporting
it_fieldcatalog = ifc
importing
ep_table = dy_table.
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>.
endform.
form get_data.
* Select Data from table.
select * into table <dyn_table>
from (p_table).
endform.
Write out data from table.
loop at <dyn_table> into <dyn_wa>.
do.
assign component sy-index
of structure <dyn_wa> to <dyn_field>.
if sy-subrc <> 0.
exit.
endif.
if sy-index = 1.
write:/ <dyn_field>.
else.
write: <dyn_field>.
endif.
enddo.
endloop.
Regards
Sudheer -
Hi Folks,
can any body please give some input on the follwoing.
i want to display material created by and material
created on for each material based on material selection
from selction screen dynamically.
like s_mat = 1, 2,3.
o/p must be
mat1 |creted by | creted on| mat2 |creted by | creted on|mat3 |creted by | creted on|
like if iam inputting 3 materials i need 3*3 = 9 columns in my alv grid o/p.
I have alreaady searched SDN I am not gettting any thing related to my requirement, please post some sample caode as I am new ot OOABAP.
Thanks,
Shwetha.
Moderator message : Not enough re-search before posting, specification dumping not allowed. Thread locked.
Edited by: Vinod Kumar on Nov 24, 2011 1:31 PMmethod handle_data_changed.
data: ls_good type lvc_s_modi,
li_diff type i,
value type p DECIMALS 3,
old_value type p DECIMALS 3,
lw_outtab1 type gt_tab.
clear value.
loop at er_data_changed->mt_good_cells into ls_good.
value = ls_good-value.
old_value = ls_good-value.
if value lt 0 or value gt 1.
MESSAGE 'Value is out of range' TYPE 'I'.
Read table gt_outtab1 into lw_outtab1 index ls_good-row_id .
perform show_alv.
clear ls_good.
ENDIF.
ENDCASE.
ENDLOOP.
I again created the table.. actually data is not changed in the internal table but still it shows the changed value in the alv grid. even in build the table again and call the refersh alv grid method..
Maybe you are looking for
-
I Bought 30 dollars worth of itune cards to redeem and its not working , it has been authorized at the register i have proof on my register receipt so i went back to store they wont do nothing , i have to deal with itunes for the problem ....so im ve
-
I am using Lightroom 5.7, 64 bit with Windows 7 Professional. For no apparent reason, I now get an error message when I export a photo, say a raw image to a JPG. However, the exported image seems to be OK. But now I notice that my LR directory of fol
-
Error is Receiver AS2 adaptor used for Idoc to AS2 scenario
Hello Experts, I am doing Idoc to AS2 B2B scenario where I am getting below error message in runtime workbench comm channel monitoring. Message processing failed. Cause: javax.resource.ResourceException: Fatal exception: com.sap.aii.af.ra.cci.XIRe
-
Can I convert a PDF to a Microsoft Word Document in Acrobat Pro?
Does Acrobat PRO have the tools to convert an existing PDF to a Microsoft Word Doc?
-
How can i calculate the values of the chars in a string
yeah, what was the method for that?