Dynamic Table with ALV
Hello.
My WD Application should offer a editable ALV Table View.
The structure and content of the table is only known at runtime. How can I use the ALV dynamically, so that I also can detemine the cells properties (dropdown, data type, ...) at runtime.
Does anybody know some examples using ALV?
Thanks and kind regards.
Carola
P.S: what are the advantages to use ALV instead of a table UI element?
Hi Carola,
Try going through this [thread|https://www.sdn.sap.com/irj/sdn/go/portal/prtroot/docs/library/uuid/4c70444a-0801-0010-7688-9e4bd844b783] for info about using an ALV Table with Dynamic Context Nodes.
The ALV provides many useful built in features without the need for any additional programming effort. These are:
Sorting
Filtering
Selecting rows
Scrolling up/down
Exporting to Microsoft Excel
Exporting to PDF
The Settings link can be used to open a dialog box, which allows you to adapt
additional settings:
Hiding columns
Defining sorting columns and sorting direction
Defining complex filters
Changing table display settings
Defining settings for PDF export
These settings can be saved and used as the user's default display variant.If the Web Dynpro application is started in Customizing mode (adding sap-config-mode=X to the URL), the settings can be saved for all users. In addition, the settings can be added to a transport request using a Customizing task.
Regards,
Uday
Similar Messages
-
Dynamic table with alv rows & colums
Hey,
How to create dynamic internal table with alv grid rows & columns with data .TYPE-POOLS : abap.
FIELD-SYMBOLS: <f_dyn_table> TYPE STANDARD TABLE,
<f_dyn_wa>.
DATA: t_dy_table TYPE REF TO data,
dy_line TYPE REF TO data,
wa_xfc TYPE lvc_s_fcat,
t_ifc TYPE lvc_t_fcat.
*get the structure
DATA: $field TYPE lvc_fname,
$counter(2) TYPE n.
DATA: $output_field(25) TYPE c,
$fld_len TYPE i.
FIELD-SYMBOLS: <f_out_field> TYPE ANY.
DATA : $t_idetails TYPE abap_compdescr_tab,
$wa_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( c_struc ).
$t_idetails[] = $ref_table_des->components[].
LOOP AT $t_idetails INTO $wa_xdetails.
CLEAR: wa_xfc, $output_field, $fld_len.
wa_xfc-fieldname = $wa_xdetails-name .
wa_xfc-datatype = $wa_xdetails-type_kind.
wa_xfc-inttype = $wa_xdetails-type_kind.
IF $wa_xdetails-type_kind EQ 'C'
OR $wa_xdetails-type_kind EQ 'N'.
CONCATENATE 'WA_OUTTAB' '-' $wa_xdetails-name
INTO $output_field.
ASSIGN ($output_field) TO <f_out_field>.
IF <f_out_field> IS ASSIGNED.
DESCRIBE FIELD <f_out_field> LENGTH $fld_len
IN CHARACTER MODE.
wa_xfc-intlen = $fld_len.
ENDIF.
ELSE.
wa_xfc-intlen = $wa_xdetails-length.
ENDIF.
wa_xfc-decimals = $wa_xdetails-decimals.
APPEND wa_xfc TO t_ifc.
CLEAR $wa_xdetails.
ENDLOOP.
here if you have any other fields to be added to the dynamic structure based on your requirement, you can add then and apped them to t_ifc. There is a special handling for unicode conversion- so for the numc and char fields the length is passed in a different mothed.
create dynamic internal table and assign to fs*
CALL METHOD cl_alv_table_create=>create_dynamic_table
EXPORTING
it_fieldcatalog = t_ifc
i_length_in_byte = 'X'
IMPORTING
ep_table = t_dy_table
EXCEPTIONS
generate_subpool_dir_full = 1
OTHERS = 2.
IF sy-subrc <> 0.
ELSE.
ASSIGN t_dy_table->* TO <f_dyn_table>.
create dynamic work area and assign to fs
CREATE DATA dy_line LIKE LINE OF <f_dyn_table>.
ASSIGN dy_line->* TO <f_dyn_wa>.
ENDIF.
*move the data into <f_dyn_wa> and then append this to output table <f_dyn_table>.
example:-
IF <f_dyn_wa> IS ASSIGNED AND <f_dyn_table> IS ASSIGNED.
MOVE-CORRESPONDING wa_outtab TO <f_dyn_wa>.
APPEND <f_dyn_wa> TO <f_dyn_table>.
endif.
Edited by: Krishna Adabala on Dec 2, 2008 7:57 AM -
Dynamic table with field type table
Hi,
I´m using "cl_alv_table_create=>create_dynamic_table" to create a dynamic table for ALV Grid.
But...I need to use colors in ALV, then I need to declare a field type LVC_S_SCOL in dynamic table from "cl_alv_table_create=>create_dynamic_table".
How can I declare this in fieldcat?
The code:
Creating dynamic table
DATA: table_agrup TYPE REF TO data,
line_agrup TYPE REF TO data.
CALL METHOD cl_alv_table_create=>create_dynamic_table
EXPORTING
it_fieldcatalog = t_fieldcat
IMPORTING
ep_table = table_agrup
EXCEPTIONS
generate_subpool_dir_full = 1
OTHERS = 2.
ASSIGN table_agrup->* TO .
Printing ALV
CALL METHOD obj_grid->set_table_for_first_display
EXPORTING
is_variant = w_variant
i_save = 'A'
is_layout = w_layout
CHANGING
it_outtab =
it_fieldcatalog = t_fieldcat
it_sort = t_sort
EXCEPTIONS
invalid_parameter_combination = 1
program_error = 2
too_many_lines = 3
OTHERS = 4.
Thanks.It is not possible with the METHOD cl_alv_table_create=>create_dynamic_table to include another table inside that newly generated table.
I have tried to do it with the code and I got the dynamic table created after at the end of the program.
In the code,
<DYN_TABLE> has same effect as your <table> variable
<DYN_WA> has same effect as your <HEADER>
REPORT ZTEST_NP_DYNAMIC.
DATA: DY_TABLE TYPE REF TO DATA,
DY_LINE TYPE REF TO DATA.
FIELD-SYMBOLS: <DYN_TABLE> TYPE STANDARD TABLE,
<DYN_WA>,
<DYN_FIELD>.
FIELD-SYMBOLS: <FS> TYPE ANY.
* To generate the Dyanmic table with the COLOR
DATA: LS_SOURCE TYPE STRING.
DATA: LT_SOURCE LIKE STANDARD TABLE OF LS_SOURCE WITH HEADER LINE.
DATA: L_NAME LIKE SY-REPID.
DATA: L_MESSAGE(240) TYPE C,
L_LINE TYPE I,
L_WORD(72) TYPE C.
DATA: L_FORM(30) TYPE C VALUE 'TABLE_CREATE'.
LT_SOURCE = 'REPORT ZTEST_SUBROUTINE_POOL.'.
APPEND LT_SOURCE.
LT_SOURCE = 'FORM TABLE_CREATE USING I_FS TYPE ANY.'.
APPEND LT_SOURCE.
LT_SOURCE = 'DATA: BEGIN OF LT_GENTAB OCCURS 0.'.
APPEND LT_SOURCE.
LT_SOURCE = 'DATA: BUKRS TYPE BUKRS. '.
APPEND LT_SOURCE.
LT_SOURCE = 'DATA: BKTXT TYPE BKTXT. '.
APPEND LT_SOURCE.
* you can add your fields here.....
LT_SOURCE = 'DATA: COLOR TYPE lvc_t_scol. '.
APPEND LT_SOURCE.
LT_SOURCE = 'DATA: END OF LT_GENTAB.'.
APPEND LT_SOURCE.
LT_SOURCE = 'DATA: POINTER TYPE REF TO DATA.'.
APPEND LT_SOURCE.
LT_SOURCE = 'CREATE DATA POINTER LIKE STANDARD TABLE OF LT_GENTAB.'.
APPEND LT_SOURCE.
LT_SOURCE = 'I_FS = POINTER.'.
APPEND LT_SOURCE.
LT_SOURCE = 'ENDFORM. '.
APPEND LT_SOURCE.
L_NAME = 'ZTEST_SUBROUTINE_POOL'.
CATCH SYSTEM-EXCEPTIONS GENERATE_SUBPOOL_DIR_FULL = 9.
GENERATE SUBROUTINE POOL LT_SOURCE NAME L_NAME
MESSAGE L_MESSAGE LINE L_LINE WORD L_WORD. "#EC CI_GENERATE
ENDCATCH.
IF NOT L_MESSAGE IS INITIAL.
MESSAGE E000(0K) WITH L_MESSAGE L_LINE L_WORD.
ENDIF.
ASSIGN DY_TABLE TO <FS>.
PERFORM (L_FORM) IN PROGRAM (L_NAME) USING <FS>.
ASSIGN DY_TABLE->* TO <DYN_TABLE>.
* Create dynamic work area and assign to FS
CREATE DATA DY_LINE LIKE LINE OF <DYN_TABLE>.
ASSIGN DY_LINE->* TO <DYN_WA>.
Write: 'bye'.
Regards,
Naimesh Patel -
Hello everybody,
im tried to create a dynamic table with cl_alv_table_create=>create_dynamic_table, but that doesnt work for the table i need. I need a table with a changing number of columns of type "type ref to CL_DD_INPUT_ELEMENT", but the fieldcat only takes normal Data-Types.
So my question is, is there any way to create a dynamic table or structure with components of type ref to CL_DD_INPUT_ELEMENT?
Thank you very much for any help.
CheersI generally use Factory methods of RTTS classes to create dynamic tables. Check my reply (Step 1) in this thread getting column headers dynamically from input parameters in alv..
-
Show dynamic table in ALV grid
Hi !
how do I show a dynamic table in ALV GRID ?
I used the following commands:
call method cl_alv_table_create=>create_dynamic_table
exporting
it_fieldcatalog = it_fieldcat[]
importing
ep_table = gt_new_table.
assign gt_new_table->* to <l_table>.
create data gs_new_line like line of <l_table>.
assign gs_new_line->* to <l_line>.
I added records into the table
Now I got a dynamic table.
How do I show it in ALV GRID ?
thanks
AdiHi,
Check these links
Re: Dynamic table
http://sap.ittoolbox.com/code/d.asp?a=s&d=3038
http://www.sap4.com/codigo-138.html
http://www.sapassist.com/code/d.asp?a=s&d=3365
There is an example in the report BCALV_TABLE_CREATE
report BCALV_TABLE_CREATE.
data: ok_code like sy-ucomm,
g_container type scrfname value 'BCALV_GRID_DEMO_0100_CONT1',
grid1 type ref to cl_gui_alv_grid,
g_custom_container type ref to cl_gui_custom_container.
data: gt_fieldcat type lvc_t_fcat.
data: gp_table type ref to data.
field-symbols: <gt_table> type table.
parameters: n type i.
if n > 100.
message a000(0k) with 'N <= 100'.
endif.
perform fieldcat_build.
call method cl_alv_table_create=>create_dynamic_table
exporting it_fieldcatalog = gt_fieldcat
importing ep_table = gp_table.
assign gp_table->* to <gt_table>.
perform fill_table.
call screen 100. -
Dynamic Table with two columns
Hi!
i have to create a Dynamic Table with two columns having 5-5 links each with some text...... three links r based on certain conditions....they r visible only if condition is true...
if the links r not visible in this case another links take it's place & fill the cell.
links/text is coming from database.
i am using Struts with JSP IDE netbeans
Please help me
BuntyIndiai wanna do something like this
<div class="box_d box_margin_right">
<ul class="anchor-bullet">
<c:forEach items="${data.faqList}" var="item" varStatus="status"
begin="0" end="${data.faqListSize/2-1}">
<li>${item}</li>
</c:forEach>
</ul>
</div>
<div class="box_d">
<ul class="anchor-bullet">
<c:forEach items="${data.faqList}" var="item" varStatus="status"
begin="${data.faqListSize/2}" end="${data.faqListSize}">
<li>${item}</li>
</c:forEach>
</ul>
</div>
wanna divide table in two columns....if one link got off due to condition other one take it's position...
I have created a textorderedlist
Bunty -
Dynamic table with dynamic drop-down list values
Hi,
I need to display a dynamic table with 2 columns on an interactive form.
My Context is defined as below:
Root
StudentData 0..n
StudentName
StudentCourses 0..n
Text
Value
The 1st column should display student name, 2nd column should display student courses. The courses will be different for each student. I populated the context properly. I checked it by printing them. My DDL is bound to "Student Courses".
When there is one row -> The DDL is populated with the courses of student 1 (as there is only one).
When there are more rows -> The DDLs for all the students are populated with all the courses of all the students.
I want to see the data populated like:
TEXTFIELD DROP-DOWN LIST
Student 1------Student1-Course1
Student1-Course2
Student1-Course3
Student 2------Student2-Course1
Student2-Course2
Student2-Course3
I tried to do this in plain web dynpro using SVS.. it is also working similarly.
I have set the singleton property of nodes "StudentData" and "StudentCourses" to false.
Could any one tell me where I am going wrong?
Thanks
RamRam,
I'm not sure how much this will help, but I know I had the same problem as you when I tried to get a similar thing working, but I can't remember which of the many changes I made fixed the problem, so I'll just show you my code and perhaps you can see if anything is different than yours.
Here's where I'm creating my dropdown - in my case EastNew_RegOut is the same as your StudentData, and RateTypeDropValues is the same as your StudentCourses (the comments in the code are not meant to sound bossy to you, this is actually an example piece of code that other developers in my company "steal", so I have to put very specific instructions in there!):
int nodeSize = wdContext.nodeEastNew_RegOut().size();
for (int i = 0; i < nodeSize; i++) {
//create an element called "table", that's the element at i. So, basically it's a row. Maybe I should have
//called it "row" instead of table.
IPublicDeviceExchange.IEastNew_RegOutElement table = (IPublicDeviceExchange.IEastNew_RegOutElement)wdContext.nodeEastNew_RegOut().getElementAt(i);
//this line of code just executes an rfc that finds out what rates need to be in the dropdown for this particular row
executeRateTypeDropdown(rateCategory, table.getNum(), wdContext.currentEastNew_MeterOutElement().getReggrp());
//clear out what's already in there before we re-populate it.
table.nodeRateTypeDropValues().invalidate();
//now, I'm looping through all the values in the *actual* rate type dropdown (the one that's an RFC, populated by the above "execute" method)
for (int j = 0; j < wdContext.nodeEastRatetype_DropdownOut().size(); j++) {
//for each element in the *actual* Rate type dropdown, I'm going to create an element in my node that I created
//and set the values from the *actual* one as the values in my node.
IPublicDeviceExchange.IRateTypeDropValuesElement element = wdContext.createRateTypeDropValuesElement();
IPublicDeviceExchange.IEastRatetype_DropdownOutElement rateTypeOut = (IPublicDeviceExchange.IEastRatetype_DropdownOutElement)wdContext.nodeEastRatetype_DropdownOut().getElementAt(j);
element.setText(rateTypeOut.getText());
element.setValue(rateTypeOut.getRatetype());
//here's another key - notice how I don't say wdContext.nodeRateTypeDropValues() - it's the one that's
//directly off that table I created earlier - the thing that's essentially a row in my newReg table.
//So, what I'm doing here is adding that new element I created to the dropdown FOR THAT ROW!
//(btw, if you're trying to duplicate this, and this method does not exist for your "table" object, it's
//probably because you didn't listen to me above and you didn't create your node with the singleton property
//set to false.)
table.nodeRateTypeDropValues().addElement(element);
As for my layout... my table is bound to the EastNew_RegOut node, and the column with the dropdown is bound to RateTypeDropValues.Value (that's probably obvious, but there you have it anyway)
Finally, in my context, EastNew_RegOut is singleton = true (I was surprised about this, actually, I would have assumed it was false) with a selection of 0..1 and RateTypeDropValues has singleton set to false with a selection of 0..1
I hope that helps to some degree!
Jennifer -
Dynamic table with drop down lists
I have a Dynamic table with a header row, Section and footer row.
Section has the following cells(columns): Cell1 (drop down with locations), button (to remove row), CCode (Color Code RAL), CName (color name).
I'm starting with 1 row.
now what I want to do is, when they select in CCode e.g. RAL 1003 (rawValue "1") then in CName the name "signal yellow" (rawValue "1") should appear.
I'm using javascript
My first problem is how do I know which value is chosen, because this isn't working:
if (this.rawValue == 1)
xfa.host.messageBox('Today')
and second how do I set the value in CName
because this only sets it in the first CName cell:
xfa.form.DataSheet.TechnicalInformation.Markings.THatchPatterns.Section.CName.rawValue = '1';
Please help me, I'm totally lostsolved the problem, instead on change event put script on exit event.
and the following line does the trick:
xfa.resolveNode("THatchPatterns.Section[" + this.parent.index + "]").CCode.rawValue = this.rawValue -
Hi, I am new to livecycle and wondering if there is any sample for setting up the dynamic table with XML schema so I can access the data through workbench's xpath. thanks.
Ivor,
Take a look at the samples shipped with Designer. For 8.2.1 release take a look at
C:\Program Files\Adobe\LiveCycle Designer ES\8.2\EN\Samples\Forms\Purchase Order\Schema\Schema\Purchase Order.xsd
and the form samples.
Otherwise, forward a request to [email protected] I would be happy to send you a sample XDP with a dynamic table and a schema.
Steve -
Dynamic Table with repeating Subform
Hello,
I am maiking a form which has a Dynamic Table with a repeating Subform. The repeating subform has a dropdown list field which has three options for the user to pic. "LABOR", "EQUIPT.", & "MATL."
The way I want the form to work is the user will choose which item they want to add to the form with the dropdown list. Whatever amount they put into the "Amount" column will go to the corresponding total "LABORTotal", "EQUIPTTotal", & "MATLTotal"
The repeating Subform is basically the Row1, but I have the table split up into subforms because of issues I had eariler with the form. The repeating subform title is "detail".
I cannot get the sums for the 3 items to go into the corresponding totals field. This is the script that I have for the labor total field:
form1.total.LABORTotal::calculate - (JavaScript, client)
var nAmount = xfa.resolveNodes("detail[*].Table1.Row1.AMOUNT");
var nItem = xfa.resolveNodes("detail[*].Table1.Row1.ITEM");
var nSum = 0;
for (var i=0; i<nAmount.length; i++)
if (nItem.item[i].rawValue == "LABOR")
nSum = nSum + nAmount.item(i).rawValue;
This.rawValue = nSum;
I am not familiar with loop scripting or var scripting so I know I am getting it wrong somewhere.
I would greatly appreciate any help!
ThanksOkay,
Here is your form back to you: https://acrobat.com/#d=IA67zcTBrWlnpcYS234*XQ.
The issue wasn't the script. If you select the dropdown and go to the Object > Binding palette, you will see you had ticked "Specify values" and these were set to 1, 2 and 3.
This meant that if the user selected LABOR, the value of the dropdown was "1" and NOT "LABOR". This was throwing the if statement.
I deselected the specify values and it worked as expected.
Hope that helps,
Niall -
Dynamic table with radio buttons
I need to load a dynamic table with radio buttons that allow
the user to select an item in the table. I need to have it add a
radio button with a unique identifier for each table item.
For example: the table will load all of the seminars
locations available in a certain state, the radio button will allow
the user to select the city in which they would like to attend and
that value will get passed to the registration page. The value of
each radio button would be equal to the location_id in the database
for each of the locations in the table (The table includes the
date, day, venue, address, hotel info, etc. details for each city.)
When I add dynamic radio buttons and set the value to the
location_id in the database, it allows the user to select multiple
radio buttons. I cannot find any information on how to
resolve.....??
Any help is appreciated.beanieboo wrote:
> I need to load a dynamic table with radio buttons that
allow the user to select
> an item in the table. I need to have it add a radio
button with a unique
> identifier for each table item.
>
> For example: the table will load all of the seminars
locations available in a
> certain state, the radio button will allow the user to
select the city in which
> they would like to attend and that value will get passed
to the registration
> page. The value of each radio button would be equal to
the location_id in the
> database for each of the locations in the table (The
table includes the date,
> day, venue, address, hotel info, etc. details for each
city.)
>
> When I add dynamic radio buttons and set the value to
the location_id in the
> database, it allows the user to select multiple radio
buttons. I cannot find
> any information on how to resolve.....??
> Any help is appreciated.
Give each radio button the same name
<input type="radio" name=theLocation" value="<?php
$recordset['location_id'] ?>">
Mick -
Dynamic table with header locked and vertical scrollbar problem.
Hi,
I have created a dynamic table with header locked.The sample code is as below.
<div style="width:910px ; overflow-x : scroll">
<h:panelgrid ...for header populated by binding to pagecode/>
<div style="width:910px ; height:200px ; overflow-y : scroll">
<h:panelgrid ...for data populated by binding to pagecode/>
</div>
</div>
The above piece of code serves the purpose.
There is an overflow in both x as well as y directions and scrollbars appear.But the y scrollbar can be seen only when the x-scrollbar is moved to the extreme right.
Does anyone have a solution so that both the scrollbars can be seen as soon as the table loads without the need to move x to the extreme right to see y?wa_layout-grid_title = text-039.
wa_layout-sel_mode = 'A'.
APPEND wa_layout TO gs_layout.
wa_layout-grid_title = text-039.
wa_layout-sel_mode = 'A'.
APPEND wa_layout TO gs_layout.
wa_layout-grid_title = text-039.
wa_layout-sel_mode = 'A'.
APPEND wa_layout TO gs_layout.
CALL METHOD gr_alvgrid1->set_table_for_first_display
EXPORTING
is_layout = gs_layout
CHANGING
it_fieldcatalog = it_fieldcatalog1[]
it_outtab = <l_table>.
i am using like but its not accepting more than one line header in is_layout, is there any possibility to take like this.
Regards,
Mallikarjuna. -
Dynamic Table with Random Records
What I am trying to do is select random records from a table
and display them in a dynamic table with max columns set to 3 and
the 4th record to be on a new row. Below is what I have right now
and it works to randomly pick records but has no function to set
columns in a table. If there is an easier way feel free to let me
know. I have tried various ways to do this but none seem to work.
<CFQUERY NAME="getItems" DATASOURCE="absi">
SELECT catfit.*, modcats.*, prodmat.*, prod.* FROM catfit,
modcats,
prodmat, prod WHERE prodmat.prodid=catfit.prodid And
catfit.catid=modcats.catid
ORDER BY modl ASC </cfquery>
<cfif getItems.recordCount>
<cfset showNum = 3>
<cfif showNum gt getItems.recordCount>
<cfset showNum = getItems.recordCount>
</cfif>
<cfset itemList = "">
<cfloop from="1" to="#getItems.recordCount#"
index="i">
<cfset itemList = ListAppend(itemList, i)>
</cfloop>
<cfset randomItems = "">
<cfset itemCount = ListLen(itemList)>
<cfloop from="1" to="#itemCount#" index="i">
<cfset random = ListGetAt(itemList, RandRange(1,
itemCount))>
<cfset randomItems = ListAppend(randomItems, random)>
<cfset itemList = ListDeleteAt(itemList,
ListFind(itemList, random))>
<cfset itemCount = ListLen(itemList)>
</cfloop>
<cfloop from="1" to="#showNum#" index="i">
<cfoutput>
<table width="205" border="0" align="left"
cellpadding="0" cellspacing="0">
<tr>
<td width="235" height="116"> <div
align="center"><img
src="../Products/ProductPictures/#getitems.pic[ListGetAt(randomItems,
i)]#" width="100"></div></td>
</tr>
<tr>
<td
class="ProdTitle">#getitems.brand[ListGetAt(randomItems,
i)]# #getitems.modl[ListGetAt(randomItems, i)]#</td>
</tr>
<tr>
<td
class="paragraph">$#getitems.prc[ListGetAt(randomItems,
i)]#</td>
</tr>
<tr>
<td><A
href="../Products/details.cfm?prodid=#getItems.prodid[ListGetAt(randomItems,
i)]#" class="linkcontact">more
info</a></td>
</tr>
<tr>
<td> </td>
</tr>
</table>
</cfoutput>
</cfloop>
</cfif>To start a new row after 3 records, do something like this.
<table>
<tr>
<cfoutput query="something">
<td>#data#<td>
<cfif currentrow mod 3 is 0>
</tr><tr>
</cfoutput>
</tr>
</table>
You should also know that your approach is very inefficient
in that you are bringing in to cold fusion more data than you need.
First of all you are selecting every field from 3 tables when you
don't appear to be using all of them. Second, you are selecting
every record and you only want to use 3. There are better ways out
there, but they are db specific and you did not say what you are
using. -
Sum for Dynamic Fields in a Dynamic Table with Field Symbol
Hi All,
I currently have an report which I am looking to update with some totals. The information is currently output in an ALV which is fed data from a dynamic table defined with a field symbol. The modification that needs to be applied is a summation per currency code where each of the fields to be summed is a dynamically named field at runtime. I am now just looking to see if anyone has any recommendations on how to obtain these totals it would be appreciated. I have no problem doing the leg work in piecing the solution together but am just stuck on which approach I should be investigating here. I have looked into several options but do to the fact that the totals are for dynamic fields in a dynamic table and it is a field symbol I am having some difficulties thinking of the easiest approach to obtain these totals.
Below is a simple sample of what the report currently looks like and what we are looking to add.
====================================================================================
As-Is Report:
DETAILED DATA ALV
Company Code | Plant | 2006 Total | 2007 Total | 2008 Total | CURRENCY
0001 | ABCD | 1,500 | 1,200 | 1,700 | USD
0001 | BCDE | 2,300 | 4,100 | 3,600 | GBP
0003 | DBCA | 3,200 | 1,600 | 6,200 | USD
Addition 1:
TOTALS PER CURRENCY
Currency | 2006 Total | 2007 Total | 2008 Total |
USD | 4,700 | 2,800 | 7,900 |
GBP | 2,300 | 4,100 | 3,600 |
Addition 2:
CONVERSIONS TO USD
| 2006 Curr | 2006 USD | 2008 Curr | 2006 USD |
USD | 4,700 USD | 4,700 USD | 7,900 USD | 7,900 USD |
GBP (1.5GBP/1 USD) | 2,300 GBP | 1,150 USD | 2,300 GBP | 1,800 USD |
====================================================================================
Any recommendations will be appreciated.Hi,
We cannot use the key word SUM in the loop at assigning statement.
The way i see is
When you are creating the first dynamic internal table , create one more with the structure below:
Currency | 2006 Total | 2007 Total | 2008 Total |
Then while populating the data into first itab,also move the contents to the second itab using collect statement. -
Hello experts,
is it possible to call an ALV via ( class cl_salv or fm REUSE_ALV_GRID_DISPLAY) with a dynamic table?
This dynamic table has for example one fix column for the material number and dynamic colums for additional data.
One material has 1 additional column, the other material has two additional columns.
So i need an ALV with 3 columns material add_data1 add_data2 (add_data2 of material one is empty this is ok).
To build an itab which can handle this is possible i know.Hello Benjamin,
Maybe you already found a solution for this, but if not (or for others looking for a solution), here is a sample program that creates, fills, and displays a dynamic table:
report ztpar_dynamic_salv.
parameters: p_colnr type i default 3.
start-of-selection.
perform execute.
form execute.
data t_table type ref to data.
** create dynamic table
perform create_dynamic_table using p_colnr
changing t_table.
** fill dynamic table
perform fill_dynamic_table changing t_table.
** display dynamic table
perform display_table using t_table.
endform.
form create_dynamic_table using colnr type i
changing table type ref to data.
data: lo_field type ref to cl_abap_typedescr,
lo_struct type ref to cl_abap_structdescr,
lo_table type ref to cl_abap_tabledescr.
data: t_comp type cl_abap_structdescr=>component_table,
l_comp like line of t_comp.
lo_field ?= cl_abap_typedescr=>describe_by_name( 'CHAR10' ).
do p_colnr times.
move sy-index to l_comp-name.
concatenate 'COLUMN' l_comp-name into l_comp-name.
condense l_comp-name no-gaps.
l_comp-type ?= lo_field.
append l_comp to t_comp.
enddo.
lo_struct = cl_abap_structdescr=>create( p_components = t_comp p_strict = space ).
lo_table = cl_abap_tabledescr=>create( lo_struct ).
create data table type handle lo_table.
endform.
form fill_dynamic_table changing table type ref to data.
field-symbols: <fs_table> type standard table,
<fs_line> type any,
<fs_field> type any.
assign table->* to <fs_table>.
do 5 times.
append initial line to <fs_table> assigning <fs_line>.
do.
assign component sy-index of structure <fs_line> to <fs_field>.
if sy-subrc ne 0.
exit.
endif.
<fs_field> = sy-index.
enddo.
enddo.
endform.
form display_table using i_table type ref to data.
data lo_alv type ref to cl_salv_table.
field-symbols <fs_tab> type any table.
assign i_table->* to <fs_tab>.
try.
cl_salv_table=>factory(
importing
r_salv_table = lo_alv
changing
t_table = <fs_tab> ).
catch cx_salv_msg.
message 'Cannot display result!' type 'E'.
endtry.
lo_alv->display( ).
endform.
Best regards,
Tanguy
Maybe you are looking for
-
Please help...
-
Moving library to a new PC, Vista, and going mad....
hi everyne.... loosing my head here could do with some help. buy a new pc and i want to transfer my ipod library from the old one.....backed it up in an external hard drive, connected drive to new pc... all working fine. Follow apple hints, create de
-
Tax and Salesman Object?
Hey all, i want to update all the tax and salesmen entries over the SAP object. Which object should i use for the tax groups and the Salespersons, because over the SAPbobsCOM i cannot use the SalesPersons object. Thanks:) Maggie
-
Can i use my american ipad to skype via wifi in europe
My ipad is purchased in the US but am travelling to France and Belgium. Can I still do face time with friends in the US via wifi?
-
Recovering Time Machine after backups were deleted
The event I will describe occurred from an incomplete operation. Hindsight is 20/20. After the mistake, I stopped using the Time Machine drive. Fearing that my Time Machine drive (1 TB) was becoming full, I proceeded to delete some backups between th