Table with bith dynamic and non dynamic data
Hi all,
We have a report already developed. Now we need add some fields from some table which is dynamic in feature to the final report which is already there.
I need to know how come we can include the dynamic fields into the final internal table.
I tried declaring fieldsymbols inside the data stmt of the final internal table but it shows some syntax error.
Please help me.
Thanks
Check this sample code..
REPORT ztest_dynamic_code.
DATA: BEGIN OF it_tab OCCURS 0,
abc(3),
xyz(3),
pqr(3),
item,
END OF it_tab.
DATA: it_fieldcatalog TYPE lvc_t_fcat,
wa_fieldcat TYPE lvc_s_fcat.
DATA: i_dyntab TYPE REF TO data. " To create dyn.Itab
DATA:
w_dref TYPE REF TO data,
ind(2) TYPE n,
w_data TYPE REF TO data,
w_text(5),
w_grid TYPE REF TO cl_gui_alv_grid.
DATA: grid TYPE REF TO cl_gui_alv_grid,
cont TYPE REF TO cl_gui_custom_container.
FIELD-SYMBOLS: <t_itab> TYPE STANDARD TABLE,
<fs_wa> TYPE ANY,<fs> TYPE ANY.
DATA: in TYPE i.
*Data population
it_tab-abc = 'ABC'.
it_tab-xyz = 'XYZ'.
it_tab-pqr = 'PQR'.
DO 9 TIMES.
in = in + 1.
it_tab-item = in.
APPEND it_tab.
ENDDO.
*Field cat population.
wa_fieldcat-fieldname = 'ABC'.
wa_fieldcat-outputlen = 3.
wa_fieldcat-coltext = 'abc'.
APPEND wa_fieldcat TO it_fieldcatalog.
wa_fieldcat-fieldname = 'XYZ'.
wa_fieldcat-outputlen = 3.
wa_fieldcat-coltext = 'XYZ'.
APPEND wa_fieldcat TO it_fieldcatalog.
wa_fieldcat-fieldname = 'PQR'.
wa_fieldcat-outputlen = 3.
wa_fieldcat-coltext = 'pqr'.
APPEND wa_fieldcat TO it_fieldcatalog.
wa_fieldcat-fieldname = 'COLOR'.
wa_fieldcat-outputlen = 4.
wa_fieldcat-coltext = 'col'.
APPEND wa_fieldcat TO it_fieldcatalog.
ind = 1.
DO 9 TIMES.
CONCATENATE 'ITEM' ind INTO wa_fieldcat-fieldname.
CONCATENATE 'ITEM' ind INTO wa_fieldcat-coltext.
wa_fieldcat-outputlen = 1.
APPEND wa_fieldcat TO it_fieldcatalog.
CLEAR wa_fieldcat .
ind = ind + 1.
ENDDO.
*-Dynamic Table creation
CALL METHOD cl_alv_table_create=>create_dynamic_table
EXPORTING
it_fieldcatalog = it_fieldcatalog
IMPORTING
ep_table = i_dyntab.
ASSIGN i_dyntab->* TO <t_itab>.
CREATE DATA w_data LIKE LINE OF <t_itab>.
ASSIGN w_data->* TO <fs_wa>.
SORT it_tab BY abc xyz pqr.
CLEAR ind.
ind = 4.
*-Final Internal table as per Requirement
do 10 times.
LOOP AT it_tab.
ASSIGN COMPONENT 1 OF STRUCTURE <fs_wa> TO <fs>.
<fs> = it_tab-abc.
ASSIGN COMPONENT 2 OF STRUCTURE <fs_wa> TO <fs>.
<fs> = it_tab-xyz.
UNASSIGN <fs>.
ASSIGN COMPONENT 3 OF STRUCTURE <fs_wa> TO <fs>.
<fs> = it_tab-pqr.
UNASSIGN <fs>.
ASSIGN COMPONENT 4 OF STRUCTURE <fs_wa> TO <fs>.
*-You can assign the color conditionally also..
if sy-index = 4.
<fs> = 'C400'.
else.
<fs> = 'C600'.
endif.
UNASSIGN <fs>.
ASSIGN COMPONENT ind OF STRUCTURE <fs_wa> TO <fs>.
<fs> = it_tab-item.
UNASSIGN <fs>.
ind = ind + 1.
AT END OF pqr.
APPEND <fs_wa> TO <t_itab>.
* <fs_wa>-color = 'C600'.
ind = 4.
CLEAR <fs_wa>.
ENDAT.
ENDLOOP.
enddo.
*-Display
CALL SCREEN 100.
*& Module STATUS_0100 OUTPUT
* text
MODULE status_0100 OUTPUT.
DATA: layout TYPE lvc_s_layo.
CREATE OBJECT cont
EXPORTING
container_name = 'CONT'
EXCEPTIONS
cntl_error = 1
cntl_system_error = 2
create_error = 3
lifetime_error = 4
lifetime_dynpro_dynpro_link = 5
OTHERS = 6
IF sy-subrc NE 0.
MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ENDIF.
CREATE OBJECT grid
EXPORTING
i_parent = cont
EXCEPTIONS
error_cntl_create = 1
error_cntl_init = 2
error_cntl_link = 3
error_dp_create = 4
OTHERS = 5
IF sy-subrc NE 0.
MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ENDIF.
layout-INFO_FNAME = 'COLOR'.
grid->set_table_for_first_display(
EXPORTING
is_layout = layout
CHANGING
it_outtab = <t_itab>
it_fieldcatalog = it_fieldcatalog
EXCEPTIONS
invalid_parameter_combination = 1
program_error = 2
too_many_lines = 3
IF sy-subrc NE 0.
MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ENDIF.
ENDMODULE. " STATUS_0100 OUTPUT
Similar Messages
-
Internal table with Dynamic and Non dynamic fileds
Hi Experts,
How to get the internal table with Dynamic and Non-Dynamic Fields.
Could u please help me.
Thanks,
VarunHi,
Execute the below sample code or analyze it there is appropriate description provided.
*& Report ZTEST_PRM_DYN_ALV
REPORT ZTEST_PRM_DYN_ALV.
type-pools: slis.
field-symbols: <dyn_table> type standard table,
<dyn_wa>.
data: alv_fldcat type slis_t_fieldcat_alv,
it_fldcat type lvc_t_fcat.
selection-screen begin of block b1 with frame title text-001.
parameters: p_flds(5) type c.
selection-screen end of block b1.
start-of-selection.
*build the dynamic internal table
perform build_dyn_itab.
*write 5 records to the alv grid
do 5 times.
perform build_report.
enddo.
*call the alv grid.
perform call_alv.
*Build_dyn_itab
form build_dyn_itab.
data: new_table type ref to data,
new_line type ref to data,
wa_it_fldcat type lvc_s_fcat.
*Create fields .
clear wa_it_fldcat.
wa_it_fldcat-fieldname = 'name1'.
wa_it_fldcat-datatype = 'mara-matnr'.
wa_it_fldcat-intlen = 5.
append wa_it_fldcat to it_fldcat .
*clear wa_it_fldcat.
wa_it_fldcat-fieldname = sy-index.
wa_it_fldcat-datatype = 'CHAR'.
wa_it_fldcat-intlen = 5.
append wa_it_fldcat to it_fldcat .
do p_flds times.
clear wa_it_fldcat.
wa_it_fldcat-fieldname = sy-index.
wa_it_fldcat-datatype = 'CHAR'.
wa_it_fldcat-intlen = 6.
append wa_it_fldcat to it_fldcat .
enddo.
*Create dynamic internal table and assign to FS
call method cl_alv_table_create=>create_dynamic_table
exporting
it_fieldcatalog = it_fldcat
importing
ep_table = new_table.
assign new_table->* to <dyn_table>.
*Create dynamic work area and assign to FS
create data new_line like line of <dyn_table>.
assign new_line->* to <dyn_wa>.
endform.
*Form build_report
form build_report.
data: fieldname(20) type c.
data: fieldvalue(5) type c.
data: index(3) type c.
field-symbols: <fs1>.
do p_flds times.
index = sy-index.
*Set up fieldvalue
concatenate 'FLD' index into
fieldvalue.
condense fieldvalue no-gaps.
assign component index of structure <dyn_wa> to <fs1>.
<fs1> = fieldvalue.
enddo.
*Append to the dynamic internal table
append <dyn_wa> to <dyn_table>.
endform.
*CALL_ALV
form call_alv.
data: wa_cat like line of alv_fldcat.
*clear wa_cat.
wa_cat-fieldname = 'matnr'.
wa_cat-seltext_s = sy-index.
wa_cat-outputlen = '10'.
append wa_cat to alv_fldcat.
do p_flds times.
clear wa_cat.
wa_cat-fieldname = sy-index.
wa_cat-seltext_s = sy-index.
wa_cat-outputlen = '6'.
append wa_cat to alv_fldcat.
enddo.
*Call ABAP List Viewer (ALV)
call function 'REUSE_ALV_GRID_DISPLAY'
exporting
it_fieldcat = alv_fldcat
tables
t_outtab = <dyn_table>.
endform.
Hope this will help, reward if found usefull.
Cheers,
Ram. -
Retrieving spatial and non spatial data in one query
Hello. I am having slight difficulties using JDBC to retrieve both spatial and non spatial data in the same query. The following is code from a sample program of mine that retrives spatial data from spatial tables.
(In spatialquery geom is a geometry column and city is simply the name of the city):
try
Geometry geom = null;
String database = "jdbc:oracle:thin:@" + m_host + ":" + m_port + ":" + m_sid;
DriverManager.registerDriver(new oracle.jdbc.driver.OracleDriver());
con = (OracleConnection)DriverManager.getConnection(database, sUsername, sPassword);
GeometryAdapter sdoAdapter =
OraSpatialManager.getGeometryAdapter("SDO", "8.1.7", STRUCT.class, null, null, con);
String spatialquery = "SELECT a1.geom, a1.city \n" +
"FROM cities a1";
Statement stmt = con.createStatement();
OracleResultSet rs = (OracleResultSet) stmt.executeQuery(spatialquery);
int i = 0;
int noOfFeatures = 2;
while (rs.next())
for(i = 1; i <= noOfFeatures; i++)
STRUCT dbObject = (STRUCT)rs.getObject(i);
try
geom = sdoAdapter.importGeometry(dbObject);
catch(GeometryInputTypeNotSupportedException e)
System.out.println("Input Type not supported");
catch(InvalidGeometryException e)
System.out.println("Invalid geometry");
System.out.println(geom);
}//end while loop
This retrieves the sptial data fine, however when I attempt to retreive the non-spatial data I keep getting a "ClassCastException" error. I understand it is something to do with "STRUCT dbObject = (STRUCT)rs.getObject(i);" line. Can anyone tell me how to retrieve both spatial and non-spatial data in the one query using JDBC. I have tried nearly everything at this stage. Cheers joeTheresa A Radke
Posts: 20
OTN Member Since: Jul, 2001
retrieving spatial and non spatial in same query. May 23, 2003 12:02 AM
retrieving spatial and non spatial in same query. -
Problem creating a table with a subquery and a dblink
Hello!!
I have a little problem. When I create a table with a subquery and a dblink, for example:
CREATE TABLE EXAMPLE2 AS SELECT * FROM EXAMPLE1@DBLINK
the table definition is changed. Fields with a type of CHAR or VARCHAR2 are created with a size three times bigger than the original table in the remote database. Field of type DATE and NUMBER are not changed. For example if the original table, in the database 1, has a field of type CHAR(1) it is create in the local database with a type of CHAR(3), and a VARCHAR2(5) field is created with VARCHAR2(15).
Database 1 has a WE8DEC character set.
Database 2 has a AL32UTF8 character set.
Could it be related to the difference in character sets?
What can I do to make Oracle use the same table definition when creating a table in this way?
Thanks!!That is related to character sets, and probably necessary if you want all the data in the remote table to be able to fit in the new table.
When you declare a column VARCHAR2(5), by default, you're allocating 5 bytes of storage. In a single-byte character set, which I believe WE8DEC is, that also happens to equate to 5 characters. In a multi-byte character set like AL32UTF8, though, 1 character may require up to 3 bytes of storage, so you'd need to allocate 15 bytes to store that data. That's what's going on here.
You could still store all the data if you create the table locally by explicitly requesting 5 characters of storage by declaring the column VARCHAR2(5 CHAR). You could also set the NLS_LENGTH_SEMANTICS parameter to CHAR rather than BYTE before creating the table, but I believe that both of these will only apply when you're explicitly defining columns as part of your CREATE TABLE. I don't believe either will apply to CTAS statements.
Justin -
Collect in an internal table with keys plant and material
Hi ,
I have an output internal table with material , plant and var quantitites .
I would like to use Collect statement and sum the quantities but do it by plant and material .
How do I specify that i want to do it on plant or material ?
Thanks !hi here is an example like urs..
DATA: BEGIN OF seats,
carrid TYPE sflight-carrid,
connid TYPE sflight-connid,
seatsocc TYPE sflight-seatsocc,
END OF seats.
DATA seats_tab LIKE HASHED TABLE OF seats
WITH UNIQUE KEY carrid connid.
SELECT carrid connid seatsocc
FROM sflight
INTO seats.
COLLECT seats INTO seats_tab.
ENDSELECT.
check for help..
http://www.sts.tu-harburg.de/teaching/sap_r3/ABAP4/collect.htm
regards,
venkat -
Crystal 2011 linking table with a String and a Number
Hello,
I am able to retrieve the data I want with the following SQL Query in SQL: If I try to create it in Crystal 2011 APPLRUNN is a string and CNTBTCH is a number. Is there a way I can link these two fields if one is a string and the other is a number ?
SELECT
ENADV.APPLRUNN, ENPBD.CNTBTCH,
ENPBD.DOCNBR
FROM
ENADV INNER JOIN
ENPBD ON ENADV.APPLRUNN = ENPBD.CNTBTCH
Thanks,
DebbieHi Debbie,
You cannot linking table with a string and a number. I have given a example query:
SELECT
ENADV.APPLRUNN, ENPBD.CNTBTCH,
ENPBD.DOCNBR
FROM
ENADV INNER JOIN
ENPBD ON
ENADV.APPLRUNN = ENPBD.APPLRUNN or ENADV.CNTBTCH = ENPBD.CNTBTCH
I modify last sentense because one table primary key is equal to another table Foreign key i.e
one table ID field = another table ID field or one table NAME field = another table Name field.
Please understand my intenction and check linking fields in tables.
Thanks,
DJ -
How to create a table with datatype blob and insert a pdf file (ravi)
how to create a table with datatype blob and insert a pdf file,
give me the explain asap
1.create the table?
2.insert the pdffiles into tables?
3.how to view the files?
Thanks & Regards
ravikumar.k
Edited by: 895044 on Dec 5, 2011 2:55 AM895044 wrote:
how to create a table with datatype blob and insert a pdf file,
give me the explain asapPerhaps you should read...
{message:id=9360002}
especially point 2.
We're not just sitting here waiting to answer your question as quickly as possible for you. -
TO DRAW A TABLE WITH MULTIPLE ROWS AND MULTIPLE COLOUMNS IN FORM
Hi,
How to draw a table with multiple rows and columns seperated by lines in form printing?check this
http://sap-img.com/ts003.htm
Regards
Prabhu -
SAP and Non-SAP data to Xcelsius
Hi Experts,
I m new to Xcelsius and i a m currently working on Xcelsius project, i need help on approach to bring both SAP and Non-SAP data to Xcelsius. Here the scenario goes on....
Total 6 plants are there, out of 6, 4 plants are on SAP and other 2 plants are on Non-SAP (Excel)
The requirement is to develop a dashboard to see all the plants details (both SAP and Non-SAP)
The approach i suggested for SAP: ECC --> BW --> InfoProvider --> Query --> QaaWS --> Xcelsius
For non-sap, data is available in excel, so we can bring that data directly to xcelsius, but problem is how to make it dynamaic because data in excel changes daily.
So my doubt is, if i develop a universe on excel files, then how to combine both SAP and Non-SAP universes. Is Data Federator is required for this or is there any approach to bring both SAP and Non-SAP data to Xcelsius.
Can any one help me on this
Thanks & Regards
Ramakrishna Kamurthyhi
Another approach which i have used in the past is to have data in XML format, placed on a web server. When my data changes daily, i just export my data from excel or whatever source into the XML format..
Use the XML data connector to bring into xcelsius.
thanks.. hope this helps
regards
Jeff. -
I HAVE A SOURCE TABLE WITH 10 RECORDS AND TARGET TABLE 15 RECORDS. MY QUESTION IS USING WITH THE TABLE COMPARISON TRANSFORM .I WANT TO DELETE UNMATCHED RECORDS FROM THE TARGET TABLE ?? HOW IT IS ??
Hi Kishore,
First identify deleted records by selecting "Detect deleted rows from comparison table" feature in Table Comparison
Then Use Map Operation with Input row type as "delete" and output row type as "delete" to delete records from target table. -
Suggestions for JSF table with sortale columns and Pagination
Hi,
My JSF application needs a table with sortable columns and also pagination.
Thank you.Just add a bunch of commandlinks and/or commandbuttons at the right locations and invoke the appropriate logic in the backing bean.
You can find some useful insights in this article: [http://balusc.blogspot.com/2006/06/using-datatables.html]. -
Do I need to purchase an iPad with cellular to use imaps or can I purchase an iPad with wifi only and use the data connection on my iPhone.
My aim is to have maps on the bigger iPad screen.the wifi version don't have an gps chip
-
Table containing 'Valid From' and 'Valid To' dates -- tcode SU01
Hi All,
I want to know the Table containing 'Valid From' and 'Valid To' dates -- In tcode SU01 ---Tab Logon Data there are 'Valid From' and 'Valid To' dates. I want to know the table(s) where this info is stored.
thanks
NavedLooks like you have two userids. Login to SDN using your userid that created the post and assign the points. If you don't see the radio button then change your original post to a question.
Message was edited by: Prakash Singh -
How can I unlock the copy protection of songs that I've acquired some years ago with an old - and non existing anymore - account? Can I link the songs to my new account or do I have to purchase them again?
If you're in the US, you will be able to use iTunes Match for $25 a year to remove copy protection in a few months: http://www.apple.com/icloud/features/
If you're not, you can't. You can authorise iTunes with the old account in addition to your current account, so all your songs will play, but I'm not sure what will happen if you try to sync them to an iPod. -
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.
Maybe you are looking for
-
Problem Connecting external display
I Have a MacBook Pro 13" from early 2011, 2.3ghz Core i5, 4Gb RAM, Intel HD Graphics 3000 384mb with OSx 10.7.4 (11E53) I'm having some trouble connecting external displays via the ThunderBolt port using a MiniDisplay Port to VGA adapter. I have to g
-
Hi All, I want to learn ABAP-HR, So can anyone provide me the material...... IT's very Urgent........ Regards, Dhruv Shah
-
Struts database result set storage structure
Hi all. I am working on a struts application that will return results from a database. The question that I am currently uncertain of is how I should be storing the information from the database. I had thought about using a datastructure to store all
-
HELP--Problem iMovie 11 quitting in import
Hello---I've created a few DVDs using iMovie and then iDVD. This time I'm having all kinds of problems. iMovie keeps crashing during import, or won't import, or freezes import. I've searched for solutions online and in other apple support threads
-
Photo management application with KISS metadata backend?
what i'm looking for: a photo management application built around the concept of tags, which aims for efficiency in usage and a simple metadata backend: * allow non-destructive edits (keep original file easily available) * make it easy to launch edit