Dynamic ALV Table Ouput
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.
Similar Messages
-
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 .. -
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 -
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. -
How to create Dynamic Internal table in ALV?
Hi all,
I have to create a ALV report based on dynamic internal table. The requirement is that when I enter the months in my selection screen I should get the data relevant to those many months only. For eg if in selection I have given January to March, I should get an ALV output with columns from January to March only.
Please help me with the coding part as I find it a bit confusing.
Please reply immediately.
Regards,
Bhavani.Hi BHAVANI,
first you have to prapare a field catalog [(see this)|http://help.sap.com/saphelp_470/helpdata/en/52/5f060de02d11d2b47d006094192fe3/frameset.htm]
and than you can use a Method cl_alv_table_create=>create_dynamic_table
I hope that help a little.
Regards Bogdan -
Embeding ALV table in dynamically created view container UI element
Hi ,
I created a view container UI element dynamically .that is working fine . I am using standard ALV component . Now i want to embed ALV table in View container UI element dynamically > please help me in this .
Thanks in advance ,
Vijay vorsuHi,
I am not sure how to do add an ALV table dynamically but you can have a look at this blog which talks about creating and adding a TABLE ui element dynamically. And TABLE UI element may solve your problem.
http://mamma1360.blog.163.com/blog/static/314740992008127115551165/
Thanks,
Abhishek -
How to populate field catalogue fields in ALV using dynamic internal table
Hi All,
Please let me know how to populate field catalogue fields in ALV using dynamic internal table.
I have created <dyn_table> using code below.
CALL METHOD cl_alv_table_create=>create_dynamic_table
EXPORTING
it_fieldcatalog = g_t_ifc
it_fieldcatalog = g_t_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>.
Now this <dyn_table> has fields like idoc no.,creation date ,
segment field 1, segment field 2 etc..Now idoc no.,creation date are static fields from table EDIDC. And segment field 1, segment field 2 etc are dynamic fields from table EDSAPPL.
In my ALV report I am getting the final layout properly but I am unable to move values to corresponding fields in the final layout shown.Please let me know how to populate these fields from different tables.
I tried this way but its not working.
SORT g_t_edid4 BY docnum.
LOOP AT g_t_edidc INTO g_r_edidc.
READ TABLE g_t_edid4 into g_r_edid4
WITH KEY docnum = g_r_edidc-docnum
BINARY SEARCH.
IF sy-subrc = 0.
<dyn_wa> = g_r_edid4-sdata.
MOVE-CORRESPONDING g_r_edid4 to <dyn_wa>.
CLEAR g_r_edid4.
ENDIF.
MOVE-CORRESPONDING g_r_edidc to <dyn_wa>.
APPEND <dyn_wa> TO <dyn_table>.You have to assign each field to field symbol and then assign the value to that field symbol and asssign that field symbol to workarea field symbol.
LOOP AT g_t_edidc INTO g_r_edidc.
READ TABLE g_t_edid4 into g_r_edid4
WITH KEY docnum = g_r_edidc-docnum
BINARY SEARCH.
IF sy-subrc = 0.
ASSIGN COMPONENT 'SDATA' OF STRUCTURE <DYN_WA> TO <DYN_FLD>.
<DYN_FLD> = g_r_edid4-sdata.
" <dyn_wa> = g_r_edid4-sdata.
" Assign each fields like this.
" MOVE-CORRESPONDING g_r_edid4 to <dyn_wa>.
CLEAR g_r_edid4.
ENDIF.
" MOVE-CORRESPONDING g_r_edidc to <dyn_wa>.
APPEND <dyn_wa> TO <dyn_table>.
Regards,
Naimesh Patel -
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 -
Subtotals in dynamic internal table using alv grid
hi experts i have created one dynamic table. The requirement is to display the subtotals in the output using reuse_alv_grid.
Dynamic itab (field-symbols) and ALV event BEFORE_LINE_OUTPUT
the above is the thread related and could any one please provide the sample code for this task.
can any one post the solution for that.
rewards points will be awarded.
khazi* ASSINING STRUCTURE FOR FILD CATLOGS
DATA: DYN_TABLE TYPE REF TO DATA,
DYN_LINE TYPE REF TO DATA,
LS_FIELDCAT TYPE LVC_S_FCAT,
LT_FIELDCAT TYPE LVC_T_FCAT.
LOOP AT LT_DMTAB INTO LS_DMTAB.
CLEAR LS_FIELDCAT.
LS_FIELDCAT-FIELDNAME = LS_DMTAB-SDATE .
LS_FIELDCAT-DATATYPE = 'DEC'.
LS_FIELDCAT-INTTYPE = 'P'.
LS_FIELDCAT-INTLEN = '16' .
LS_FIELDCAT-DECIMALS = '03'.
LS_FIELDCAT-JUST = 'C'.
APPEND LS_FIELDCAT TO LT_FIELDCAT.
ENDLOOP.
*& For grouping the table rows for Under Line
LS_FIELDCAT-FIELDNAME = 'ULFIELD' .
LS_FIELDCAT-DATATYPE = 'INT'.
LS_FIELDCAT-INTTYPE = 'P'.
LS_FIELDCAT-INTLEN = '2' .
LS_FIELDCAT-DECIMALS = ''.
APPEND LS_FIELDCAT TO LT_FIELDCAT.
"* Create dynamic internal table and assign to Field-Symbol
CALL METHOD CL_ALV_TABLE_CREATE=>CREATE_DYNAMIC_TABLE
EXPORTING
IT_FIELDCATALOG = LT_FIELDCAT
IMPORTING
EP_TABLE = DYN_TABLE.
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 DYN_TABLE->* TO <LT_AREA_F>.
"* Create dynamic work area and assign to Field Symbol
CREATE DATA DYN_LINE LIKE LINE OF <LT_AREA_F>.
ASSIGN DYN_LINE->* TO <LS_AREA_F>.
You check in Field cat level you will get Check Sub total field will exist
Thanks and regards
Jogu -
Problem in Dynamic ALV - inserting values in proper field of a table.
Hi gurus,
As per the user requirement I need to create a dynamic alv report. The fields will be display according to the period entered.
I have already build the alv and it is working fine. But My questio is how can I append data into internal table in its proper field.
suppose I have enter period 1 to 3 in selection screen. Then my table structure will be
JAN | FEB | MAR
Upto this is is working fine, fields are generated dynamically , but how can I insert data only in perticular field.
like
itab-JAN = 001.
itab-FEB = 002.
itab-MAR = 003.
append itab
JAN | FEB | MAR
001 002 003
Please give me a solution of that. waiting for reply.hI,
loop at <dyn_table> assigning <wa>.
lv_count = 001.
*perform get_short_tet of month in a varibale say lv_var
assign component LV_VAR of structure <wa> to <dyn_field1>.
<dyn_field1> = lv_count.
lv_count = lv_count + 1.
endloop.
Regards,
mrunal
Edited by: Mrunal Shyamkant Patki on Nov 5, 2009 10:53 AM
Edited by: Mrunal Shyamkant Patki on Nov 5, 2009 10:54 AM -
Passing dynamic internal table into ALV
I have made one ALV report where i had created one button 'GENERATE'. ON CLICKING THIS BUTTON the data in the ALV report is downloaded to excel file.
i have used this:-
CALL METHOD cl_gui_frontend_services=>file_save_dialog
EXPORTING
window_title = l_title
default_extension = 'XLS'
initial_directory = 'C:\'
CHANGING
filename = filename
path = path
fullpath = fullpath
user_action = user_action
EXCEPTIONS
cntl_error = 1
error_no_gui = 2
not_supported_by_gui = 3
OTHERS = 4.
IF sy-subrc <> 0.
EXIT.
ENDIF.
Check which button is pressed
IF user_action <> cl_gui_frontend_services=>action_ok.
EXIT.
ENDIF.
Download error data collected from the internal table
CALL METHOD cl_gui_frontend_services=>gui_download
EXPORTING
filename = fullpath
filetype = 'ASC'
write_field_separator = '#'
codepage = '4103'
write_bom = c_true
CHANGING
data_tab = gi_final
EXCEPTIONS
file_write_error = 1
no_batch = 2
gui_refuse_filetransfer = 3
invalid_type = 4
no_authority = 5
unknown_error = 6
header_not_allowed = 7
separator_not_allowed = 8
filesize_not_allowed = 9
header_too_long = 10
dp_error_create = 11
dp_error_send = 12
dp_error_write = 13
unknown_dp_error = 14
access_denied = 15
dp_out_of_memory = 16
disk_full = 17
dp_timeout = 18
file_not_found = 19
dataprovider_exception = 20
control_flush_error = 21
not_supported_by_gui = 22
error_no_gui = 23
OTHERS = 24.
If selection is successful
IF sy-subrc EQ 0.
MESSAGE s004 . " File created successfully
ELSE.
MESSAGE i005 . " File is not created successfully
ENDIF.
In the table i have passed the internal table . this is working fine.
<b>But,
The problem is if i want to display the data in diferent layout based on selection screen criteria the data downloaded are same as default layout.
how to pass a dynamic internal table in the
CALL METHOD cl_gui_frontend_services=>gui_download</b>Hi ,
here is the Program for Download
REPORT yrs_download_transport_request.
PARAMETERS:
p_reqest TYPE trkorr OBLIGATORY,
p_folder(255) TYPE c LOWER CASE, p_sepr OBLIGATORY.
DATA:
folder TYPE string,
retval LIKE TABLE OF ddshretval WITH HEADER LINE,
fldvalue LIKE help_info-fldvalue,
transdir TYPE text255,
filename(255),
trfile(20) TYPE c,
datatab TYPE TABLE OF text8192 WITH HEADER LINE,
len TYPE i,
flen TYPE i.
TYPE-POOLS: sabc, stms, trwbo.
INITIALIZATION.
CONCATENATE sy-sysid 'K*' INTO p_reqest.
IF sy-opsys = 'Windows NT'.
p_sepr = ''.
ELSE.
p_sepr = '/'.
ENDIF.
* CALL FUNCTION 'WSAF_BUILD_SEPARATOR'
* IMPORTING
* separator = p_sepr
* EXCEPTIONS
* separator_not_maintained = 1
* wrong_call = 2
* wsaf_config_not_maintained = 3
* OTHERS = 4.
* IF sy-subrc NE 0.
* MESSAGE s001(00)
* WITH
* 'Unable to find out the separator symbol for the system.'(011).
* ENDIF.
AT SELECTION-SCREEN ON VALUE-REQUEST FOR p_reqest.
DATA:
tt_system TYPE TABLE OF tmscsys WITH HEADER LINE,
es_selected_request TYPE trwbo_request_header,
es_selected_task TYPE trwbo_request_header,
iv_organizer_type TYPE trwbo_calling_organizer,
is_selection TYPE trwbo_selection.
iv_organizer_type = 'W'. is_selection-reqstatus = 'R'.
CALL FUNCTION 'TR_PRESENT_REQUESTS_SEL_POPUP'
EXPORTING
iv_organizer_type = iv_organizer_type
is_selection = is_selection
IMPORTING
es_selected_request = es_selected_request
es_selected_task = es_selected_task.
p_reqest = es_selected_request-trkorr.
AT SELECTION-SCREEN ON VALUE-REQUEST FOR p_folder.
DATA: title TYPE string.
title = 'Select target folder'(005).
CALL METHOD cl_gui_frontend_services=>directory_browse
EXPORTING
window_title = title
CHANGING
selected_folder = folder
EXCEPTIONS
cntl_error = 1
error_no_gui = 2
OTHERS = 3.
CALL FUNCTION 'CONTROL_FLUSH'
EXCEPTIONS
cntl_system_error = 1
cntl_error = 2
OTHERS = 3.
p_folder = folder.
AT SELECTION-SCREEN ON p_reqest.
DATA: request_info TYPE stms_wbo_request,
request_infos TYPE stms_wbo_requests.
REFRESH request_infos.
CALL FUNCTION 'TMS_MGR_READ_TRANSPORT_REQUEST'
EXPORTING
iv_request = p_reqest
iv_header_only = 'X'
IMPORTING
et_request_infos = request_infos
EXCEPTIONS
read_config_failed = 1
table_of_requests_is_empty = 2
system_not_available = 3
OTHERS = 4.
IF sy-subrc <> 0.
MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ENDIF.
CLEAR request_info.
READ TABLE request_infos INTO request_info INDEX 1.
IF sy-subrc NE 0
OR request_info-e070-trkorr IS INITIAL.
MESSAGE e398(00) WITH 'Request'(006) p_reqest 'not found'(007).
ELSEIF request_info-e070-trstatus NE 'R'.
MESSAGE e398(00)
WITH 'You must release request'(008)
request_info-e070-trkorr
'before downloading'(009).
ENDIF.
START-OF-SELECTION.
folder = p_folder.
CONCATENATE p_reqest+3(7) '.' p_reqest(3) INTO trfile.
CALL FUNCTION 'RSPO_R_SAPGPARAM'
EXPORTING
name = 'DIR_TRANS'
IMPORTING
value = transdir
EXCEPTIONS
error = 0
OTHERS = 0.
PERFORM copy_file USING 'cofiles' trfile.
trfile(1) = 'R'.
PERFORM copy_file USING 'data' trfile.
trfile(1) = 'D'.
PERFORM copy_file USING 'data' trfile.
* FORM copy_file *
* --> SUBDIR * * --> FNAME *
FORM copy_file USING subdir fname.
DATA:
auth_filename TYPE authb-filename,
gui_filename TYPE string.
CONCATENATE transdir subdir fname
INTO filename
SEPARATED BY p_sepr.
REFRESH datatab.
CLEAR flen.
auth_filename = filename.
CALL FUNCTION 'AUTHORITY_CHECK_DATASET'
EXPORTING
activity = sabc_act_read
filename = auth_filename
EXCEPTIONS
no_authority = 1
activity_unknown = 2
OTHERS = 3.
IF sy-subrc <> 0.
FORMAT COLOR COL_NEGATIVE.
WRITE: / 'Read access denied. File'(001),
filename.
FORMAT COLOR OFF. EXIT.
ENDIF.
OPEN DATASET filename FOR INPUT IN BINARY MODE.
IF sy-subrc NE 0.
FORMAT COLOR COL_TOTAL.
WRITE: / 'File open error'(010), filename.
FORMAT COLOR OFF. EXIT.
ENDIF.
DO.
CLEAR len.
READ DATASET filename INTO datatab LENGTH len.
flen = flen + len.
IF len > 0. APPEND datatab. ENDIF.
IF sy-subrc NE 0.
EXIT.
ENDIF.
ENDDO.
CLOSE DATASET filename.
CONCATENATE p_folder '' fname INTO gui_filename.
CALL METHOD cl_gui_frontend_services=>gui_download
EXPORTING
bin_filesize = flen
filename = gui_filename
filetype = 'BIN'
CHANGING
data_tab = datatab[]
EXCEPTIONS
file_write_error = 1
no_batch = 2
gui_refuse_filetransfer = 3
invalid_type = 4
no_authority = 5
unknown_error = 6
header_not_allowed = 7
separator_not_allowed = 8
filesize_not_allowed = 9
header_too_long = 10
dp_error_create = 11
dp_error_send = 12
dp_error_write = 13
unknown_dp_error = 14
access_denied = 15
dp_out_of_memory = 16
disk_full = 17
dp_timeout = 18
file_not_found = 19
dataprovider_exception = 20
control_flush_error = 21
OTHERS = 24.
IF sy-subrc = 0.
WRITE: / 'File'(002), filename, 'downloaded. Length'(003), flen.
ELSE.
FORMAT COLOR COL_NEGATIVE.
WRITE: / 'File download error. Filename:'(004), filename.
FORMAT COLOR OFF.
ENDIF.
ENDFORM. "copy_file
Reward points if it is usefull....
Girish -
ALV Table and dynamic new column
Hi,
I have a ALV table with tree in one column (reccuring context value).
I would like dynamically to add new columns. I know the method of IF_WD_CONTEXT_NODE_INFO->ADD_NEW_CHILD_NODE, but this is used in another posts/blogs where whole table is generated dynamically. I have a table already and just want to add a new column.
Is that possible?
Thank you on advance, cheers.Under normal circumstances you could use the Context API method ADD_ATTRIBUTE to create a dynamic attirubte:
http://help.sap.com/saphelp_nw70ehp1/helpdata/en/af/cb744176cb127de10000000a155106/frameset.htm
Unfortunately this is not compatible with the ALV. The ALV only supports static attributes. Therefore you will need to build up an entire RTTI based structure in memory and then dynamically re-create the entire context. This is a similar example:
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.
loop at field_details assigning <wa_detail>.
* build a structure description from the list of single fields
comp-name = <wa_detail>-field_code.
comp-type ?= cl_abap_datadescr=>describe_by_name( 'STRING' ). "Replace with your dataType
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 ). -
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. -
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 -
ALV rows to column dynamic internal table
Hello People ,
I am stuck in a report which displays an output in ALV as follows :-
bukrs | kntyp | konto | knfix | period | element | emeng | emein
1000 | 10 | 1100 | berlin | 11.2011 | AG | 0.148 | kgAG
1000 | 10 | 1100 | berlin | 11.2011 | AU | 0.104 | kgAU
1000 | 10 | 1100 | berlin | 11.2011 | GA | 0.207 | kgGA
And this table has many values corresponding to element AG,AU and GA respectively . For example , there would be many element AG's with many "EMENG" values . Similarly for AU and GA .
MY question :- I am asked to make AG , AU , GA as 3 different fields which should show the value "EMENG" under respective elements . Like :-
bukrs | kntyp | konto | knfix | period | AG | AU | GA | emein
1000 | 10 | 1100 | berlin | 11.2011 | 0.148 | 0.104 | 0.207 | kgAG
That should be my output . ( elements replaced by AG , AU and GA which comes from a Metal table ZXXXX where
metal no. 1 = AU
metal no. 2 = AG
metal no. 3 = GA
If there is any metal added to it would be metal no. 4 ,5,6,7 .... so on ) and then that should be added as a field in our report .. So that has to be DYNAMIC .
I am unable to move on with problem . Pls suggest ? I am pasting my report here ...
FORM select_table_gt_bb CHANGING p_gt_bb.
TABLES : zpam_as .
DATA : i_zpam_as TYPE TABLE OF zpam_as ,
wa_zpam_as LIKE LINE OF i_zpam_as ,
i_tcurr TYPE TABLE OF tcurr ,
wa_tcurr LIKE LINE OF i_tcurr,
zt_as TYPE TABLE OF zpam_as.
SELECT * FROM zpam_as INTO TABLE gt_as
WHERE bukrs EQ bukrs
AND kntyp IN kntyp
AND konto IN konto
AND knfix IN knfix
AND buper IN buper
AND element IN element
AND ameng IN ameng
AND ashkz IN ashkz
AND emeng IN emeng
AND eshkz IN eshkz
AND emein IN emein.
SELECT * FROM zpam_tcurr INTO TABLE gt_tcurr.
IF sy-subrc IS INITIAL.
LOOP AT gt_tcurr INTO gw_tcurr.
SELECT * FROM tcurr INTO wa_tcurr WHERE fcurr = gw_tcurr-fcurr AND
tcurr = tcurr.
ENDSELECT.
APPEND wa_tcurr TO i_tcurr.
DELETE ADJACENT DUPLICATES FROM i_tcurr.
ENDLOOP.
ENDIF.
IF i_tcurr IS NOT INITIAL.
LOOP AT gt_as INTO gw_as.
CLEAR sy-subrc.
LOOP AT i_tcurr
INTO wa_tcurr
WHERE fcurr = gw_as-emein.
gw_as-tcurr = wa_tcurr-tcurr.
gw_as-ukurs = wa_tcurr-ukurs.
gw_as-total = abs( gw_as-emeng ) * wa_tcurr-ukurs.
APPEND gw_as TO zt_as.
ENDLOOP.
IF sy-subrc <> 0.
gw_as-tcurr = 'None'.
gw_as-ukurs = ''.
gw_as-total = ''.
APPEND gw_as TO zt_as.
ENDIF.
ENDLOOP.
REFRESH gt_as.
LOOP AT zt_as INTO gw_as.
APPEND gw_as TO gt_as.
ENDLOOP.
ENDIF.
ENDFORM.
Priority normalized
Edited by: Rob Burbank on Dec 28, 2011 3:44 PMHey,
But after understanding my question correctly , you sure that dynamic internal table is the solution for it ?
Maybe you are looking for
-
How to create objects dynamically (with dynamic # of parameters)
I need to create a set of objects based on a definition from an XML file (obtained from the server) and add them to my scene. I understand how to create the object using getDefinitionByName (and the limitations regarding classes needing to be referen
-
Sorry to all of you with probably the same problem but i can't find solution. Anyway i'm trying to write simple WD which will make in target system user. I'm using BAPI_CREATE_USER FM. I did everything like in ohter examples of consuming transaction
-
How to edit stored procedure from sqlplus ?
Hi, Can anyone advise how to edit stored procedure from sqlplus ? Many thanks.
-
HT2476 how do you delete an aplication form my laptop
i wish to delete an aplication from my macbook pro
-
I have recently installed CS3. Now whenever I try to open a PDF on a webpage I just get a error box saying Adobe PDF viewer cant open the file. How can I revert Safari to open PDF files in Preview again?