Columns in a dynamic table
Hi guys!
I'm working with field symbols and dynamic tables and i have this code:
REPORT zpractica03.
PARAMETERS: p_tabla TYPE dd02l-tabname.
DATA: tabla_name TYPE dd02l-tabname,
tabla_generica TYPE REF TO data,
linea_generica TYPE REF TO data.
FIELD-SYMBOLS: <fs_tabla> TYPE ANY TABLE,
<fs_linea> TYPE ANY,
<fs_campo> TYPE ANY.
tabla_name = p_tabla.
CREATE DATA tabla_generica TYPE STANDARD TABLE OF (tabla_name).
ASSIGN tabla_generica->* TO <fs_tabla>.
CREATE DATA linea_generica TYPE (tabla_name).
ASSIGN linea_generica->* TO <fs_linea>.
SELECT *
INTO CORRESPONDING FIELDS OF TABLE <fs_tabla>
FROM (tabla_name).
DATA: lv_indice_campo TYPE sy-tabix,
lv_valor_campo.
LOOP AT <fs_tabla> INTO <fs_linea>.
CLEAR lv_indice_campo.
lv_indice_campo = sy-tabix.
ASSIGN COMPONENT lv_indice_campo OF STRUCTURE <fs_linea> TO <fs_campo>.
IF sy-subrc EQ 0.
MOVE <fs_campo> TO lv_valor_campo.
ENDIF.
ENDLOOP.
In the last step, I know that I need something like this in order to get one line and save the info in a workarea and then create an ALV :
Do n Times
ASSIGN COMPONENT lv_indice_campo OF STRUCTURE <fs_linea> TO <fs_campo>.
IF sy-subrc EQ 0.
MOVE <fs_campo> TO lv_valor_campo.
ENDIF.
Enddo.
What I don't know how to do is how can I get the number 'N' ? Can somebody explain me how can I get the number of the columns in a table that can be different any time that i run the program?
Thank you very much.
Gaby
Hello,
You can use the FM: DDIF_FIELDINFO_GET & pass the table name tabla_name.
It will return the table DFIES_TAB which will contain the column details. So before this:
Do n Times
lv_indice_campo = lv_indice_campo + 1.
ASSIGN COMPONENT lv_indice_campo OF STRUCTURE <fs_linea> TO <fs_campo>.
IF sy-subrc EQ 0.
MOVE <fs_campo> TO lv_valor_campo.
ENDIF.
Enddo.
Add this code:
DATA: LT_DFIES TYPE STANDARD TABLE OF DFIES.
CALL FUNCTION 'DDIF_FIELDINFO_GET'
EXPORTING
TABNAME = tabla_name
TABLES
DFIES_TAB = LT_DFIES
EXCEPTIONS
NOT_FOUND = 1
INTERNAL_ERROR = 2
OTHERS = 3.
IF SY-SUBRC = 0.
N = LINES ( LT_DFIES ).
ENDIF.
Else you can easily avoid this stuff by EXITing the DO...ENDDO loop.
Do.
lv_indice_campo = lv_indice_campo + 1.
ASSIGN COMPONENT lv_indice_campo OF STRUCTURE <fs_linea> TO <fs_campo>.
IF sy-subrc EQ 0.
MOVE <fs_campo> TO lv_valor_campo.
ELSE.
EXIT.
ENDIF.
Enddo.
Hope i am clear.
BR,
Suhas
Similar Messages
-
How to change the column postion in Dynamic Table
Folks,
I have an ess application which is creating dynamic table from dynamic node, I need to change one of the column position , please let me know how to do
Thanks,
Manishproblem solved
-
Summing values in dynamic table columns
I'm having some difficulty figuring out how to sum column
values in dynamic tables. In other words, I have created a dynamic
table (php/mysql). One column has a list of prices, and I need to
sum the list of prices. I know this is pretty simple stuff. Can
someone direct me to an example of the appropriate code?"firalivet" <[email protected]> wrote in
message
news:go1j76$d4l$[email protected]..
> One column
> has a list of prices, and I need to sum the list of
prices. I know
> this is
> pretty simple stuff.
There are several ways to do this, but a simple way is to
create a
variable to hold a running total and add the current price to
it when
you display each row. The following is a simplified example
of the
code:
<?php $total = 0; ?>
<?>php do { // this is the start of the repeat region
?>
<tr><td><?php echo
$row_recordsetName['price']; $total +=
$row_recordsetName['price']; ?></td></tr>
<?php } while ($row_recordsetName =
mysql_fetch_array($recordsetName)); // end of repeat region
?>
<tr><td><?php echo $total;
?></td></tr>
David Powers
Adobe Community Expert, Dreamweaver
http://foundationphp.com -
Issue in Dynamic table creation in userform
Hi all,
My userform displays a simpletable using an arraylist returned from the WF as data source. I have all the columns of this dynamic table displayed as labels.
Question:
Now I have added another new column to this table which I want to be editable (textfield) while the rest of the existing columns should be the same labels. How do I accomplish this task since the fieldloop for the table uses only a single arraylist?
this is how my code looks like
<FieldLoop for='abc'>
<expression>
<block>
<ref>List</ref>
</block>
</expression>
<Field name='tmptable'>
<Display class='SimpleTable'>
<Property name='noNewRow' value='true'/>
<Property name='border' value='0'/>
<Property name='align' value='center'/>
</Display>
<Field name='$(abc)'>
<Display class='Label' action='true'>
<Property name='value'>
<ref>abc</ref>
</Property>
</Display>
</Field>
</Field>
</FieldLoop>
thanks in advance
kpThat was pretty simple solution. I made a disable clause to the label control for the last column and instead displayed a textbox control.
thanks anyway -
Merging of cells of a dynamic table in adobe form
Hi,
I am trying to Merge 2 columns in a dynamic table in adobe form.The requirement is to merge column 3 and column 4 if column 4 is empty. I used the below javascript code in both "Form ready " and Initialize event of the row.
if (this.Cell4.rawValue == " ")
this.Cell3.colSpan = "2";
this.Cell4.presence = "hidden";
Note : Since above code was not working , i used the below code in my subform also but it did not returned desired output.
if(Table22.Row1.Cell1.rawValue == " ")
Table22.Row1.Cell3.colSpan = "2";
Table22.Row1.Cell4.presence = "hidden";
The problem is that in my dynamic table , its the second row where the requirement is fulfilled ie in the 2nd entry of my table the column4 is blank (the exact row number might change depending on input data).
is there a way to loop in the dynamic table and check if column 4 is empty for a particular row.
the above code does not help to fulfill my requirements. kindly help.
Thanks
AditiHello Aditi priya,
Hope you are doing good..
Please go through my recent blog..
http://scn.sap.com/community/interactive-forms-by-adobe/blog/2015/01/02/merging-internal-table-cells-dynamically-in-sap-adobe-forms-using-java-script-code
I hope you will find all answers from this blog..Reward if helpful...
Thanks & Regards,
B Raghu Prasad -
How to add dynamic ordered list in dynamic table?
Ok let say I have a dynamic table with 4 columns; 1) Name 2) Tel 3) Address 4) Occupation. I don't populate primary key id to the table but what I want to do is add another column to the dynamic table and label the header as No. or #. I want to make the column as list colum for my dynamic table. If the dynamic table displays 10 record (row) in a page the list row will automatically follow the number of rows. Then in the next page the list will continue from 20 and so on.
I use PHP so if it's not possible directly from dreamweaver and PHP solution is highly welcomed.
Thanks in advance!You just need to create a counter and populate the 'No.' with the current value of the counter.
> I want to make the column as list colum for my dynamic table.
Not sure what you mean by 'list column'. -
How to find the number of columns in an internal table DYNAMICALLY ?
Hi,
How to find the number of columns in an internal table DYNAMICALLY ?
Thanks and Regards,
saleem.Hi,
you can find the number of columns and their order using
the <b>'REUSE_ALV_FIELDCATALOG_MERGE'</b>
call function 'REUSE_ALV_FIELDCATALOG_MERGE'
EXPORTING
I_PROGRAM_NAME = sy-repid
I_INTERNAL_TABNAME = 'ITAB'
I_INCLNAME = sy-repid
changing
ct_fieldcat = IT_FIELDCAT
EXCEPTIONS
INCONSISTENT_INTERFACE = 1
PROGRAM_ERROR = 2
OTHERS = 3
if sy-subrc <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
endif
now describe your fieldcat . and find no of columns.
and their order also..
regards
vijay -
Use the value of a field as column-name of a dynamic table
Hi All
I have the following situation:
a) Internal table TB_ORDER_CONDITION ==> data: tb_order_condition type standard table of bapicond.
sample of the internal table TB_ORDER_CONDITION:
CONT_TYPE # CONDVALUE# CONDBASEVAL
ZR00 # 38.800000# 1.000000
ZR30 # 2.800000 # 0.000000
SKTO # 0.000000 # 57.8500000
b) dynamic-table <L_TABLE_II> has the following columns:
ZR00#ZR30#ICM3#IPS2 SKTO
c) I would like to move as below:
ZR00#ZR30# ICM3#IPS2# SKTO
38.800000#2.800000#57.8500000
Observation:
I used this symbol just to show the separationfrom one column from another.
Items a) and b) are OK. The problem is that I don't know how to make this move as showed in item c).
Could you please advise?
Thanks in advance.
GaiaHello,
Check the code snippet below:
FIELD-SYMBOLS: <wa_order_creation> TYPE bapicond,
<l_table_ii> TYPE STANDARD TABLE,
<l_wa_ii> TYPE ANY,
<l_fieldval> TYPE ANY.
SORT tb_order_condition BY itm_number. "Sort by Item Number
LOOP AT tb_order_condition ASSIGNING <wa_order_creation>.
* Add a record to the dynamic table for each item
AT NEW itm_number.
APPEND INITIAL LINE TO <l_table_ii> ASSIGNING <l_wa_ii>.
ENDAT.
ASSIGN COMPONENT <wa_order_creation>-cond_type
OF STRUCTURE <l_wa_ii> TO <l_fieldval>.
IF sy-subrc = 0.
<l_fieldval> = <wa_order_creation>-cond_value.
ENDIF.
ENDLOOP.
BR,
Suhas -
Dynamic table - some fields of different rows in one column
Hey guys,
i have the following problem:
i habe a itab with some data like:
name | id | date | number
pete | 1 | 27.07 | 2
pete | 1 | 28.07 | 2
pete | 1 | 30.07 | 2
ann | 1 | 28.07 | 3
ann | 2 | 30.07 | 2
the user can define a period of time, e.g. 28-29.07
so my dynamic table will consist of the "hard" columns name and id and the dynamic added columns for every day:
name | id | 28.07 | 29.07
that's what i already have!
so my problem is, that i have to read the data from the itab into the new dynamic table (field-symbol) like:
name | id | 28.07 | 29.07
pete | 1 | 2 | 2
ann | 1 | 3 | -
i hope you can understand what i want! please give me code sample or a example report!
many thanks in adance!
best regards,
ludwighey Asik, you have understand what i want!
here is my table:
http://img181.imageshack.us/my.php?image=wh20080916113004ym8.png
after the loop, the 4 rows should be in my field-symbol only one row (no sum)!
but after the loop, there are to many rows! only one row is needed!
Look at the screenshot:
http://img185.imageshack.us/my.php?image=wh20080916113547wl0.png
So the second row at column "tag20080801" should be initial and with the next loop, the next day "tag20080730" should be filled with the number!
LOOP AT LT_OUT INTO LS_OUT.
ASSIGN COMPONENT 'RESSOURCEN' OF STRUCTURE <FS_LINE> TO <fs_field>.
<fs_field> = 'Ressource'.
ASSIGN COMPONENT 'NAME' OF STRUCTURE <FS_LINE> TO <fs_field>.
<fs_field> = LS_OUT-name.
ASSIGN COMPONENT 'PROJEKT' OF STRUCTURE <FS_LINE> TO <fs_field>.
<fs_field> = LS_OUT-PROJECTID.
CONCATENATE 'DATE' LS_OUT-DATE INTO LF_DATE_COL.
ASSIGN COMPONENT LF_DATE_COL OF STRUCTURE <FS_LINE> TO <fs_field>.
<fs_field> = LS_OUT-COUNT.
COLLECT <FS_LINE> INTO <FS_TABLE>.
ENDLOOP.
the right output data should look like this:
Ressourcen | Ludwig Heinz | 20080702LHZ | 4 | 4 | 4 | 1 -
Hi All,
Suppose I have table, whose structure changes frequently on daily basis.
For eg. desc my_table gives you following column name on Day 1
SQL > desc my_table;
Output
Name
Age
Phone
On Day 2, two more columns are added, viz, Address and Salary.
SQL > desc my_table;
Output
Name
Age
Phone
Address
Salary
Now I want to create an Dynnamic RTF report which would fetch data from ALL columns from my_table on daily basis. For that I have defined a concurrent program with XML as output type and have attached a data template/data definition to it which takes in XML as input and gives final output of conc program in EXCEL layout. I am able to do this for constant number of columns, but dont know how to do it when the number of columns to be displayed changes dynamically.
For Day 1 my XML file should be like this.
<?xml version="1.0" encoding="UTF-8"?>
<dataTemplate name="XYZ" description="iExpenses Report" Version="1.0">
<dataQuery>
<sqlStatement name="Q2">
<![CDATA[
SELECT Name
,Age
,Phone
FROM my_table
]]>
</sqlStatement>
</dataQuery>
<dataStructure>
<group name="G_my_table" source="Q2">
<element name="Name" value="Name" />
<element name="Age" value="Age" />
<element name="Phone" value="Phone" />
</group>
</dataStructure>
</dataTemplate>
And my Day 1, EXCEL output from RTF template should be like this.
Name Age Phone
Swapnill 23 12345
For Day 2 my XML file should be like this. With 2 new columns selected in SELECT clause.
<?xml version="1.0" encoding="UTF-8"?>
<dataTemplate name="XYZ" description="iExpenses Report" Version="1.0">
<dataQuery>
<sqlStatement name="Q2">
<![CDATA[
SELECT Name
,Age
,Phone
,Address
,Salary
FROM my_table
]]>
</sqlStatement>
</dataQuery>
<dataStructure>
<group name="G_my_table" source="Q2">
<element name="Name" value="Name" />
<element name="Age" value="Age" />
<element name="Phone" value="Phone" />
<element name="Address" value="Address" />
<element name="Salary" value="Salary" />
</group>
</dataStructure>
</dataTemplate>
And my Day 2, EXCEL output from RTF template should be like this.
Name Age Phone Address Salary
Swapnill 23 12345 Madrid 100000
Now, I dont know below things.
Make the XML dynamic as in on Day 1 there must be 3 columns in the SELECT statement and on Day 2, 5 columns. I want to create one dynamic XML which should not be required to be changed if new columns are added in my_table. I dont know how to create this query and also create their corresponding elements below.
Make the RTF template dyanamic as in Day1 there must 3 columns in EXCEL output and on Day 2, 5 columns. I want to create a Dynamic RTF template which would show all the columns selected in Dynamic XML.I dont know how the RTF will create new XML tags and how it will know where to place it in the report. Means, I can create RTF template on Day 1, by loading XML data for 3 columns and placing 3 XML tags in template. But how will it create and place tags for new columns on Day 2?
Hope, you got my requirement, its a challenging one. Please let me know how I can implement the required solution using RTF dynamically without any manual intervention.
Regards,
Swapnil K.
Message was edited by: SwapnilKHi All,
I am able to fulfil above requirement. Now I am stuck at below point. Need your help!
Is there any way to UPDATE the XML file attached to a Data Definition (XML Publisher > Data Definition) using a standard package or procedure call or may be an API from backend? I am creating an XML dynamically and I want to attach it to its Data Definition programmatically using SQL.
Please let me know if there is any oracle functionality to do this.
If not, please let me know the standard directories on application/database server where the XML files attached to Data Definitions are stored.
For eg, /$APPL_TOP/ar/1.0/sql or something.
Regards,
Swapnil K. -
How to create Dynamic internal table with columns also created dynamically.
Hi All,
Any info on how to create a dynamic internal table along with columns(fields) also to be created dynamically.
My requirement is ..On the selection screen I enter the number of fields to be in the internal table which gets created dynamically.
I had gone thru some posts on dynamic table creation,but could'nt find any on the dynamic field creation.
Any suggestions pls?
Thanks
NaraI don't understand ...
something like that ?
* Form P_MODIFY_HEADER. *
form p_modify_header.
data : is_fieldcatalog type lvc_s_fcat ,
v_count(2) type n ,
v_date type d ,
v_buff(30).
* Update the fieldcatalog.
loop at it_fieldcatalog into is_fieldcatalog.
check is_fieldcatalog-fieldname+0(3) eq 'ABS' or
is_fieldcatalog-fieldname+0(3) eq 'VAL' .
move : is_fieldcatalog-fieldname+3(2) to v_count ,
p_perb2+5(2) to v_date+4(2) ,
p_perb2+0(4) to v_date+0(4) ,
'01' to v_date+6(2) .
v_count = v_count - 1.
call function 'RE_ADD_MONTH_TO_DATE'
exporting
months = v_count
olddate = v_date
importing
newdate = v_date.
if is_fieldcatalog-fieldname+0(3) eq 'ABS'.
concatenate 'Quantité 0'
v_date+4(2)
v_date+0(4)
into v_buff.
else.
concatenate 'Montant 0'
v_date+4(2)
v_date+0(4)
into v_buff.
endif.
move : v_buff to is_fieldcatalog-scrtext_s ,
v_buff to is_fieldcatalog-scrtext_m ,
v_buff to is_fieldcatalog-scrtext_l ,
v_buff to is_fieldcatalog-reptext .
modify it_fieldcatalog from is_fieldcatalog.
endloop.
* Modify the fieldcatalog.
call method obj_grid->set_frontend_fieldcatalog
exporting it_fieldcatalog = it_fieldcatalog.
* Refresh the display of the grid.
call method obj_grid->refresh_table_display.
endform. " P_MODIFY_HEADER -
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 -
Structure or tabletype out of dynamic table column
Hey Experts,
I have an internal table with dynamic content. In this internal table is a column with the names of tablefields in every line. Now I need to create another internal table or structure with these tablefields in the column as table structure. How can I do that?
I create the first internal table with:
data lt_ded_gc_alv type table of /sme/ded_gc_alv.
select * from /sme/ded_gc_alv into table lt_ded_gc_alv
where id = WD_THIS->GF_SALV_ID
AND xid = WD_COMP_CONTROLLER->cockpit.
This is part of a Web Dynpro for Abap method, but this is not important.
In the table lt_ded_gc_alv I have the column with the dynamic names of tablefields.
Thanks for your help.
Best regards,
IngmarHello,
Look at class CL_ABAP_TYPEDESCR and their subclasses. You need to use RTTS to define dynamic structures, please read this [https://www.sdn.sap.com/irj/sdn/go/portal/prtroot/docs/library/uuid/b332e090-0201-0010-bdbd-b735e96fe0ae].
Regards, -
Dynamic Column Names from one table and its corresponding values from another table
I have 2 tables. First tables gives the specification if a column is required or not. we have the 2nd table with the same column name where we provide the actual values.
I want to select all the required columns from the 1st table and retrieve the values for those from the 2nd table. Both this i want to achieve in a single select statement.This wil require a dynamic Query with a Pivot
DECLARE @ColsPivot as VARCHAR(MAX);
DECLARE @Query AS VARCHAR(MAX);
1. Retreive the ID for all required field
SET @ColsPivot = (SELECT STUFF((SELECT ',' + quotename(CAST([RequirementID] as varchar(3))) FROM [dbo].[Requirement] WHERE required=1 FOR XML PATH(''), TYPE).value('.', 'NVARCHAR(MAX)') ,1,1,''));
This will give you : [1],[2],[3],[8],[9],[14] for exemple.
2. Build your Query
SET @Query ='SELECT ClientID,'+@ColsPivot+''
FROM (
SELECT [ClientID],[RequirementID],[Value]
FROM dbo.RequirementValue
WHERE ClientID=@CliendID --Optional SP parameter
)src
PIVOT(
MAX(Value)
for [RequirementID] in ('+@ColsPivot+')
) p';
3. Exec(@Query); -
Need to create a dynamic caption(column name) in a dynamic table
Hi All,
I have created dynamic table .But the dynamic column is not showing.I have created two column name that is name and empId .I have tried with following code
IWDCaption nameCap=(IWDCaption)view.createElement(IWDCaption.class,"nameCap");
nameCap.setText("Name");
tabColumn1.setHeader((IWDCaption)nameCap);
IWDCaption addCap=(IWDCaption)view.createElement(IWDCaption.class,"addCap");
addCap.setText("Address");
tabColumn2.setHeader((IWDCaption)addCap);
I m getting internal server error...But When i m comented the above code i can able to see tha dynamic table withput column name..Can anyone help me
SumanHi
IWDTableColumn tabColumn1 = (IWDTableColumn)view.createElement(IWDTableColumn.class,"N_Co");
IWDTableColumn tabColumn2 = (IWDTableColumn)view.createElement(IWDTableColumn.class,"A_Co");
IWDInputField nameText = (IWDInputField)view.createElement(IWDInputField.class,"N_Text");
nameText.bindValue(attrib1);
tabColumn1.setTableCellEditor((IWDTableCellEditor)nameText);
IWDInputField addText = (IWDInputField)view.createElement(IWDInputField.class,"A_Text");
addText.bindValue(attrib2);
tabColumn2.setTableCellEditor((IWDTableCellEditor)addText);
<b>I need to see the column name.....</b>
for that i have written the following code...
while writting the following code i m getting internal server error
IWDCaption nameCap = (IWDCaption)view.createElement(IWDCaption.class,"nameCap");
nameCap.setText("contribution_area");
tabColumn1.setHeader((IWDCaption)nameCap);
IWDCaption addCap=(IWDCaption)view.createElement(IWDCaption.class,"addCap");
addCap.setText("SUM");
tabColumn2.setHeader((IWDCaption)addCap);
Maybe you are looking for
-
Vendor Return of Imported goods
Hi Sap Gurus, Can any body explain me the procedure to return the imported goods. is it necessary to generate ARE1/ARE3 reg. for return of imported goods? regards, abhay Edited by: Abhay Patil on Mar 26, 2008 11:04 AM
-
How to assign the default service package to the user in the command line ?
when i create use use the following command ,which service package is assigned to the user ,or in where can i set the default service package ,thanks for you! /opt/SUNWcomm/bin/commadmin user create -D admin -F John -l jdoe -L Doe -n jnpc.com.cn -p 8
-
Mass processing - Error when processing Java programs / VMC out of memory
When running a mass update background process that updates the status of a service order in CRM the job fails due to error 'Error when processing Java programs'. I checked the VMC (SM52) and noticed that there is an error about the VMC running out of
-
Notification center freezing when I make a tweet from it
It only freezes when i send a tweet anyone else know how to fix this?
-
Vector a photo?!?
Hey everybody...WhatsUp?! Listen, quick ?.... How can I convert a photo (.jpg) to vector based using Illustrator without losing quality? This is especially important because I've started printing a lot of large-format stuff, i.e. wall-scapes billboar