How to create internal table dynamically based on a table entry
hi Experts,
I have table yprod_cat. It has product categories.
In my ABAP program I need to create internal table dynamically based on the number of entries in the table.
For example:
If the table has 3 entries for product category
1. Board
2. Micro
3. Syst
Then create three (3) internal tables.
i_board
i_micro
i_syst
How can we do this? Any sample code will be very usefull
Thanks & Regards
Gopal
Moderator Message: No sample codes can be given. Please search for them or work it!
Edited by: kishan P on Jan 19, 2011 4:22 PM
Our APEX version is 4.2We are using below SQL query to display radio groups dynamically..
SELECT APEX_ITEM.RADIOGROUP (1,deptno,'20',dname) dt
FROM dept
ORDER BY 1;
Created a form using SQL type and given abouve SQL query as source.. But when we run the page, there were no radio groups displayed in the page..
Below is the output of the query..
<input type="radio" name="f01" value="10" />ACCOUNTING
<input type="radio" name="f01" value="20" checked="checked" />RESEARCH
<input type="radio" name="f01" value="30" />SALES
<input type="radio" name="f01" value="40" />OPERATIONS
>
If Tabular Form:
Edit Region > Report Attributes > Edit Column > Change the Column type to "Standard Report Column"
If normal Page Item:
Edit Page Item > Security > Escape special characters=No.
Pl read the help on that page item to understand the security risk associated with =NO.
Cheers,
Edited by: Prabodh on Dec 3, 2012 5:59 PM
Similar Messages
-
How to create internal table for a structure in BSP
hi ,
I have created a Structure in BSP.I want to create an internal table for that Structure. But in my coding ie.
<% data: begin of itab_1 .
include type zuvendstr.
data:end of itab_1.
data wa_str like line of itab_1.
loop at itab_1 into wa_str. %>
<tr>
<td><%=wa_str-name%> </td>
<%endloop.%>
In this zuvendstr is Structure ,wa_str is workarea and itab_1 is an Internal table.But it is showinng an error that itab_1 is unknown.But we cannot define internal tables for an Structure in Page Attributes.So,please resolve how to create internal table for Structure in BSPSHi,
You can define itab_1 like this (assuming zuvendstr is a structure type):
DATA: itab_1 TYPE TABLE OF zuvendstr.
Regards,
Tanguy -
How to create internal table storing instances of ABAP class
Hi experts, any one knows how to create internal table storing instances of ABAP class or alternative to implement such function?
Hi
Please see below example from ABAPDOCU, this might help you.
Internal Table cnt_tab is used to store class objects.
Regards,
Vishal
REPORT demo_objects_references.
CLASS counter DEFINITION.
PUBLIC SECTION.
METHODS: set IMPORTING value(set_value) TYPE i,
increment,
get EXPORTING value(get_value) TYPE i.
PRIVATE SECTION.
DATA count TYPE i.
ENDCLASS.
CLASS counter IMPLEMENTATION.
METHOD set.
count = set_value.
ENDMETHOD.
METHOD increment.
ADD 1 TO count.
ENDMETHOD.
METHOD get.
get_value = count.
ENDMETHOD.
ENDCLASS.
DATA: cnt_1 TYPE REF TO counter,
cnt_2 TYPE REF TO counter,
cnt_3 TYPE REF TO counter,
cnt_tab TYPE TABLE OF REF TO counter.
DATA number TYPE i.
START-OF-SELECTION.
CREATE OBJECT: cnt_1,
cnt_2.
MOVE cnt_2 TO cnt_3.
CLEAR cnt_2.
cnt_3 = cnt_1.
CLEAR cnt_3.
APPEND cnt_1 TO cnt_tab.
CREATE OBJECT: cnt_2,
cnt_3.
APPEND: cnt_2 TO cnt_tab,
cnt_3 TO cnt_tab.
CALL METHOD cnt_1->set EXPORTING set_value = 1.
CALL METHOD cnt_2->set EXPORTING set_value = 10.
CALL METHOD cnt_3->set EXPORTING set_value = 100.
DO 3 TIMES.
CALL METHOD: cnt_1->increment,
cnt_2->increment,
cnt_3->increment.
ENDDO.
LOOP AT cnt_tab INTO cnt_1.
CALL METHOD cnt_1->get IMPORTING get_value = number.
WRITE / number.
ENDLOOP. -
How to create internal table dynamically?
hi all
I have a particular internal table in memory area( thru EXPORT TO MEMORY ID ....)
how can i create an internal table of this type in another program at runtime ?
this internal table need not be a data dictionary type.
i.e., i need to create an internal table of type which
is stored in a particular memory-id.
Regards,
Naveen........
nullHi,
Check this code :
TYPE-POOLS: slis.
FIELD-SYMBOLS: <t_dyntable> TYPE STANDARD TABLE,
<fs_dyntable>,
<fs_fldval> type any.
PARAMETERS: p_cols(5) TYPE c.
DATA: t_newtable TYPE REF TO data,
t_newline TYPE REF TO data,
t_fldcat TYPE slis_t_fldcat_alv,
t_fldcat TYPE lvc_t_fcat,
wa_it_fldcat TYPE lvc_s_fcat,
wa_colno(2) TYPE n,
wa_flname(5) TYPE c.
* Create fields .
DO p_cols TIMES.
CLEAR wa_it_fldcat.
move sy-index to wa_colno.
concatenate 'COL'
wa_colno
into wa_flname.
wa_it_fldcat-fieldname = wa_flname.
wa_it_fldcat-datatype = 'CHAR'.
wa_it_fldcat-intlen = 10.
APPEND wa_it_fldcat TO t_fldcat.
ENDDO.
* Create dynamic internal table and assign to FS
CALL METHOD cl_alv_table_create=>create_dynamic_table
EXPORTING
it_fieldcatalog = t_fldcat
IMPORTING
ep_table = t_newtable.
ASSIGN t_newtable->* TO <t_dyntable>.
* Create dynamic work area and assign to FS
CREATE DATA t_newline LIKE LINE OF <t_dyntable>.
ASSIGN t_newline->* TO <fs_dyntable>.
DATA it_fieldcatalog TYPE lvc_t_fcat.
DATA lr_table TYPE REF TO data.
FIELD-SYMBOLS <lt_table> TYPE table.
*-- Import the fieldcatalog
IMPORT it_fieldcatalog TO it_fieldcatalog
FROM MEMORY ID 'CREATE_DYNAMIC_TABLE'.
IF sy-subrc <> 0.
EXIT.
ENDIF.
*-- Create the dynamic table with the field catalog as structure
CALL METHOD cl_alv_table_create=>create_dynamic_table
EXPORTING
it_fieldcatalog = it_fieldcatalog
IMPORTING
ep_table = lr_table
EXCEPTIONS
generate_subpool_dir_full = 1
OTHERS = 2.
IF sy-subrc <> 0.
EXIT.
ENDIF.
*-- Convert the reference into a table
ASSIGN lr_table->* TO <lt_table>.
IF sy-subrc <> 0.
EXIT.
ENDIF.
*-- Export the created table so that the function module can import it
EXPORT lt_table FROM <lt_table>
TO MEMORY ID 'CREATE_DYNAMIC_TABLE'.
Regards
L Appana -
How to create internal fields dynamically
Hi,
I am getting the data from MARA table to an internal table. Now I have to show the data according to month wise, like if same material is created in may and just, i have to show that material in may and june like below.
material | may | june |
m1 | 10 | 5 |
m2 | 20 | 15 |
I have to show this report in ALV.
so how can i get the month columns dynamically for each month?
i.e., when month is changed it has to create a new month.
Plz suggest me.
Regards,
DhanunjayREPORT ztest.
*** Tables
DATA: LT_DATA type ref to DATA.
DATA: LT_FIELDCATALOG type LVC_T_FCAT.
*** Structure
DATA: LS_FIELDCATALOG type LVC_S_FCAT.
*** Data References
DATA: NEW_LINE type ref to data.
*** Field Symbols
FIELD-SYMBOLS: <FS_DATA> type ref to DATA,
<FS_1> type any table,
<FS_2>,
<FS_3>.
LS_FIELDCATALOG-FIELDNAME = 'MANDT'.
append LS_FIELDCATALOG to LT_FIELDCATALOG.
LS_FIELDCATALOG-FIELDNAME = 'CARRID'. "Fieldname
LS_FIELDCATALOG-INTTYPE = 'C'. "Internal Type C-> Character
append LS_FIELDCATALOG to LT_FIELDCATALOG.
LS_FIELDCATALOG-FIELDNAME = 'CONNID'.
LS_FIELDCATALOG-INTTYPE = 'N'.
append LS_FIELDCATALOG to LT_FIELDCATALOG.
LS_FIELDCATALOG-FIELDNAME = 'FLDATE'.
LS_FIELDCATALOG-INTTYPE = 'D'.
append LS_FIELDCATALOG to LT_FIELDCATALOG.
LS_FIELDCATALOG-FIELDNAME = 'PRICE'.
LS_FIELDCATALOG-INTTYPE = 'P'.
append LS_FIELDCATALOG to LT_FIELDCATALOG.
LS_FIELDCATALOG-FIELDNAME = 'CURRENCY'.
LS_FIELDCATALOG-INTTYPE = 'C'.
append LS_FIELDCATALOG to LT_FIELDCATALOG.
assign LT_DATA to <FS_DATA>.
call method cl_alv_table_create=>create_dynamic_table
exporting
it_fieldcatalog = LT_FIELDCATALOG
importing
ep_table = <FS_DATA>
exceptions
generate_subpool_dir_full = 1
others = 2
if sy-subrc <> 0.
endif.
*** So <FS_1> now points to our dynamic internal table.
assign <FS_DATA>->* to <FS_1>.
*** Next step is to create a work area for our dynamic internal table.
create data NEW_LINE like line of <FS_1>.
*** A field-symbol to access that work area
assign NEW_LINE->* to <FS_2>.
*** And to put the data in the internal table
select MANDT CARRID CONNID FLDATE PRICE CURRENCY
from SFLIGHT
into corresponding fields of table <FS_1>.
*** Access contents of internal table
loop at <FS_1> assigning <FS_2>.
assign component 1 of structure <FS_2> to <FS_3>.
write: / <FS_3>.
endloop. -
How to create internal table in Adobe form - SFP transaction?
How shd i create an internal table under Global data ???
Regards,
Gurmukh singhyou can create the inernal table using the table types.
assume you want to create the Inernal table of type SFLIGHT, then you can create in this way...under the global Defintions.
VARiABLE NAME Type Assignment Type name
IT_SFLIGHT TYPE SFLIGHT_TAB1
IT_VBAP TYPE VBAP_TT
you can populate these tables using the Initialization->Code Initialization.
for more details Check here..
https://www.sdn.sap.com/irj/sdn/adobe -
How to create PMCO table entries for few PM Order
Hi Experts
By a lack of Customizing we have used for few day a PM order type without the flelds AFKO-KLVARP and AFKO-KLVARI set.
For this missing setting no entris had been created during Creation and Confirmation in PMCO and PMCOQT tables.
Now I've filled teh fields with a Zreport on AFKO table, but now I need to create the PMCO* data using RIPMCO00 report.
Unfortunately it doesn't work. Is there a way to re-build this missing datas ???
Thanks for your help.
Claudio
Edited by: Claudio Carrara on Feb 15, 2012 3:48 PMRun the program RIPMCO00, has no effect because tables PMCO and PMCOQT are empty for these order.
This hapepns becuase when the Order was confirmed, teh fields AFKO-KLVARP and AFKO-KLVARI was null.
Now I've fixed these fiels, and I need to rebuild PMCO datas, burt report doesn't work because PMCO and PMCOQT tables are empty.
I need to create PMCO and PMCOQT entries in advance.
How I can proceed ???
Thanks
Claudio -
How to Create a Table Component Dynamically based on the Need
Hello all,
I have a problem i need to create dynamically tables based on the no of records in the database. How can i create the table object using java code.
Please help.Winston's blog will probably be helpful:
How to create a table component dynamically:
http://blogs.sun.com/roller/page/winston?entry=creating_dynamic_table
Adding components to a dynamically created table
http://blogs.sun.com/roller/page/winston?entry=dynamic_button_table
Lark
Creator Team -
How to delete a field from a Dynamically created internal table
Hi friends,
I have got a requirement in which, I will be entering the table name and Excel file from seletion-screen.
based on the Table I have entered in the selection-screen I need to create a dynamic internal table so that I can fill that Execel data into that internal table and later i using BDC i can I can fill the database table using SM30 transaction.
here. my problem is that, When I am creating internal table dynamically, MANDT filed is also getting created in the internal table.
please, help in deleteing the filed MANDT from the internal able.
following is the code which creates the dynamic internal table.
CREATE DATA dy_table TYPE TABLE OF (p_tabname).
assign dy_table->* to <dyn_table>.
please provide, if any sample code is available.
Regards,
Xavier.PHi,
You can use this logic,
While creating the Dynamic filed catalog try to avoid MANDT field.
Ex:
*Dynamic creation of a structure
CREATE DATA LP_STRUCT TYPE (V_TABLE).
ASSIGN LP_STRUCT->* TO <FS>.
*Fields Structure
OF_SDESCR ?= CL_ABAP_TYPEDESCR=>DESCRIBE_BY_DATA( <FS> ).
LOOP AT OF_SDESCR->COMPONENTS ASSIGNING <COMPONENTS>.
*Field MANDT not displayed
IF SY-TABIX = 1 AND <COMPONENTS>-NAME = 'MANDT'.
CONTINUE. " Next loop
ENDIF.
*Build Fieldcatalog
LS_LVC_CAT-FIELDNAME = <COMPONENTS>-NAME.
LS_LVC_CAT-REF_TABLE = V_TABLE.
APPEND LS_LVC_CAT TO LT_LVC_CAT.
CLEAR LS_LVC_CAT.
ENDLOOP. -
Can we create internal table dynamically ? how?
hi to all experts,
can we create internal table dynamically ? how?plz explain me with an example.Anybody with good example will be rewarded.it was asked in an interview what the answer for itHI
Yes you can create
see this
/people/rich.heilman2/blog/2005/07/27/dynamic-internal-tables-and-structures--abap
JUST USE THIS CODE AND DO THE ESSENTIAL CHANGES ACCORDING TO YOU
STEP: 1 - get backend field catalog (currently displayed alv)
CLEAR: tl_fieldcatalog. REFRESH: tl_fieldcatalog.
CALL METHOD w_grid->get_backend_fieldcatalog
IMPORTING
et_fieldcatalog = tl_fieldcatalog.
STEP: 2 - create a new fieldcatalog for dynamic internal table
CLEAR: sl_fieldcatalog.
CLEAR: t_outtab_fieldname. REFRESH: t_outtab_fieldname.
CLEAR: tl_fieldcatalog_new. REFRESH: tl_fieldcatalog_new.
CLEAR: t_download_fieldname. REFRESH: t_download_fieldname.
CLEAR: t_download_fieldheading. REFRESH: t_download_fieldheading.
LOOP AT tl_fieldcatalog INTO sl_fieldcatalog.
STEP: 2.1 - populate data in T_OUTTAB_FIELDNAME
APPEND sl_fieldcatalog-fieldname TO t_outtab_fieldname.
STEP: 2.2 - populate TL_FIELDCATALOG_NEW & T_DOWNLOAD_FIELDNAME
IF sl_fieldcatalog-no_out EQ ''.
IF sl_fieldcatalog-fieldname NE 'STATUS'
OR sl_fieldcatalog-fieldname NE 'MESG_STATUS'
OR sl_fieldcatalog-fieldname NE 'ZLOCK'
OR sl_fieldcatalog-fieldname NE 'T_PLANT'
OR sl_fieldcatalog-fieldname NE 'T_CSR'.
If field is COMM_PLANT, change its length
IF sl_fieldcatalog-fieldname EQ 'COMM_PLANT'.
sl_fieldcatalog-outputlen = 1800.
sl_fieldcatalog-intlen = 1800.
sl_fieldcatalog-dd_outlen = 1800.
ENDIF. "comm_plant
sl_fieldcatalog_new = sl_fieldcatalog.
APPEND sl_fieldcatalog_new TO tl_fieldcatalog_new.
APPEND sl_fieldcatalog-fieldname TO t_download_fieldname.
APPEND sl_fieldcatalog-scrtext_l TO t_download_fieldheading.
CLEAR: sl_fieldcatalog, sl_fieldcatalog_new.
ENDIF.
ENDIF.
ENDLOOP.
STEP: 3 - create dynamic internal table
FREE: ref_download.
CALL METHOD cl_alv_table_create=>create_dynamic_table
EXPORTING
I_STYLE_TABLE =
it_fieldcatalog = tl_fieldcatalog_new
IMPORTING
ep_table = ref_download
E_STYLE_FNAME =
EXCEPTIONS
generate_subpool_dir_full = 1
OTHERS = 2
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 ref_download->* TO <ft_download>.
CREATE DATA ref_wa LIKE LINE OF <ft_download>.
ASSIGN ref_wa->* TO <fs_download>.
STEP: 4 - populate data in dynamic internal table
LOOP AT t_outtab INTO wa_outtab.
LOOP AT t_download_fieldname.
ASSIGN COMPONENT t_download_fieldname OF STRUCTURE
<fs_download> TO <fs_download_field>.
IF t_download_fieldname-field EQ 'COMM_PLANT'.
STEP: 4.1 - get long text from database table
CLEAR: wal_table.
SELECT SINGLE * FROM zshaven_plnt_txt
INTO wal_table
WHERE vbeln = wa_outtab-vbeln
AND posnr = wa_outtab-posnr
AND del_no = wa_outtab-del_no
AND del_itm = wa_outtab-del_itm.
IF sy-subrc EQ 0.
STEP: 4.2 - break long-text into separate lines
CLEAR: tl_text. REFRESH: tl_text.
SPLIT wal_table-plant_comm
AT '~'
INTO TABLE tl_text.
STEP: 4.3 - Combine these separate lines with space in
between two lines
CLEAR: wal_text, final_text.
LOOP AT tl_text INTO wal_text.
IF final_text IS INITIAL.
final_text = wal_text.
ELSE.
CONCATENATE final_text '-' wal_text
INTO final_text.
REPLACE '-' WITH ' ' INTO final_text.
ENDIF.
ENDLOOP.
STEP: 4.4 - move long text to work-area
<fs_download_field> = final_text.
ENDIF. "subrc
ELSE. "t_download_fieldname
READ TABLE t_outtab_fieldname
WITH KEY field = t_download_fieldname-field.
ASSIGN COMPONENT t_outtab_fieldname-field OF STRUCTURE
wa_outtab TO <fs_outtab_field>.
<fs_download_field> = <fs_outtab_field>.
ENDIF.
ENDLOOP.
STEP: 4.5 - Move data from work-area to dynamic internal table
APPEND <fs_download> TO <ft_download>.
CLEAR: <fs_download>.
ENDLOOP.
STEP: 5 - download
CALL FUNCTION 'DOWNLOAD'
EXPORTING
filename = 'C:\zshaven.xls'
filetype = 'DAT'
filetype_no_show = 'X'
filetype_no_change = 'X'
TABLES
data_tab = <ft_download>
fieldnames = t_download_fieldheading
EXCEPTIONS
invalid_filesize = 1
invalid_table_width = 2
invalid_type = 3
no_batch = 4
unknown_error = 5
gui_refuse_filetransfer = 6
customer_error = 7
OTHERS = 8.
IF sy-subrc <> 0.
MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ENDIF. -
Appending column to an dynamically created internal table
Hi folks,
i have an dynamically created internal table <dyn_tab> which is based on a parameter p_table ( containing the table name ). now i want to add one more column to this <dyn_tab> table where i can store further information in. how can i do that ?
i appreciate your help!Hi,
Please check this sample program.
type-pools : abap.
field-symbols: <dyn_table> type standard table,
<dyn_wa>,
<dyn_field>.
data: dy_table type ref to data,
dy_line type ref to data,
xfc type lvc_s_fcat,
ifc type lvc_t_fcat.
selection-screen begin of block b1 with frame.
parameters: p_table(30) type c default 'T001'.
selection-screen end of block b1.
start-of-selection.
perform get_structure.
perform create_dynamic_itab.
form get_structure.
data : idetails type abap_compdescr_tab,
xdetails type abap_compdescr.
data : ref_table_des type ref to cl_abap_structdescr.
* Get the structure of the table.
ref_table_des ?=
cl_abap_typedescr=>describe_by_name( p_table ).
idetails[] = ref_table_des->components[].
loop at idetails into xdetails.
clear xfc.
xfc-fieldname = xdetails-name .
xfc-datatype = xdetails-type_kind.
xfc-inttype = xdetails-type_kind.
xfc-intlen = xdetails-length.
xfc-decimals = xdetails-decimals.
append xfc to ifc.
endloop.
*Add your new field(s) into table ifc here.
endform.
form create_dynamic_itab.
* Create dynamic internal table and assign to FS
call method cl_alv_table_create=>create_dynamic_table
exporting
it_fieldcatalog = ifc
importing
ep_table = dy_table.
assign dy_table->* to <dyn_table>.
* Create dynamic work area and assign to FS
create data dy_line like line of <dyn_table>.
assign dy_line->* to <dyn_wa>.
endform.
Regards,
Ferry Lianto -
Uploading data from excel file to a dynamically created internal table
Hi,
I have a requirement where i have to upload data from an excel file into a database table. I would be able to determine the structure of the table only at runtime based on the user input.. so i have created an internal table dynamically.
Could you please tell me if its possible to upload data from an excel file to the dynamically created internal table using any function modules?
I thought of doing this by declaring a generic internal table of one field and then uploading the *.csv file into it and then splitting it based on "," and then assigning it to the field symbol referencing the internal table.. but my file length exceeds 132 characters and i'm only able to get data of lenght 132 char's in my internal table ( generic one).
Could anyone please show me a way around this.
Thanks in advance,
HarshaSure, check this out.
report zrich_0002.
type-pools: slis.
field-symbols: <dyn_table> type standard table,
<dyn_wa>,
<dyn_field>.
data: it_fldcat type lvc_t_fcat,
wa_it_fldcat type lvc_s_fcat.
type-pools : abap.
data: new_table type ref to data,
new_line type ref to data.
data: iflat type table of string.
data: xflat type string.
data: irec type table of string with header line.
data: tabix type sy-tabix.
data: file type string.
selection-screen begin of block b1 with frame title text .
parameters: p_file type rlgrap-filename default 'c:Test.csv'.
parameters: p_flds type i.
selection-screen end of block b1.
start-of-selection.
* Add X number of fields to the dynamic itab cataelog
do p_flds times.
clear wa_it_fldcat.
wa_it_fldcat-fieldname = sy-index.
wa_it_fldcat-datatype = 'C'.
wa_it_fldcat-inttype = 'C'.
wa_it_fldcat-intlen = 10.
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>.
file = p_file.
call method cl_gui_frontend_services=>gui_upload
exporting
filename = file
changing
data_tab = iflat
exceptions
file_open_error = 1
file_read_error = 2
no_batch = 3
gui_refuse_filetransfer = 4
invalid_type = 5
no_authority = 6
unknown_error = 7
bad_data_format = 8
header_not_allowed = 9
separator_not_allowed = 10
header_too_long = 11
unknown_dp_error = 12
access_denied = 13
dp_out_of_memory = 14
disk_full = 15
dp_timeout = 16
others = 17.
loop at iflat into xflat.
clear irec. refresh irec.
split xflat at ',' into table irec.
loop at irec.
tabix = sy-tabix.
assign component tabix of structure <dyn_wa> to <dyn_field>.
<dyn_field> = irec.
endloop.
append <dyn_wa> to <dyn_table>.
endloop.
* Write out data from table.
loop at <dyn_table> into <dyn_wa>.
do.
assign component sy-index of structure <dyn_wa> to <dyn_field>.
if sy-subrc <> 0.
exit.
endif.
if sy-index = 1.
write:/ <dyn_field>.
else.
write: <dyn_field>.
endif.
enddo.
endloop.
Regards,
Rich Heilman -
How to convert internal table with dynamic fields to XML
Dear all,
I met a problem like the following:
The aim is to transform the following parameter to XML
IT_FIELD stores the dynamic filed name of the internal table,with these fields, the dynamic internal can be created by cl_abap_tabledescr=>create(it_field)
IT_VALUE stores the value of the internal table dynamically created with dynamic fields.
For example
IT_FIELD =>
line1: FIELD1
line2: FIELD2
line3: FIELD3,
three lines in this internal table.
dynamically created internal table structure FIELD1 FIELD2 FIELD3
And IT_VALUE=>
1 2 3 (First line)
11 22 33
two lines of data.
Do you have any idea about how to transform the IT_VALUE to XML here? And also the transformed XML to the IT_VALUE.( we may need remember IT_FIELD here for later XML to IT_VALUE.)
Hope I describe the problem clearly.
Any inputs will be appreciated.
Edited by: Max Tang on Jan 12, 2009 3:46 PM
Edited by: Max Tang on Jan 12, 2009 4:14 PMHi,
you need to implement a bit of coding for that.
With the 'do varying' statement abap provides a loop over those fields. Within this loop you can build up a new internal table with one entry for each period and amount.
kind regards
Siggi
PS: I am not very familiar with CO, but I guess there will be a standard extractor for that. -
How to fill internal table dynamically
Hi All,
how to fill internal table dynamically.
for example:
begin of itab occurs 0,
empid like pa0000-pernr,
empname like pa0001-ename,
grade(5),
end of itab.
now i want to append dynamically field itab-grade along with rest fields.
is this possible?? if yes kindly let me know how to do that.
Regards,
Kiran IHi kiran,
To fill and create and internal table dynamically you can use this code.
TYPE-POOLS: slis.
DATA: it_fcat TYPE slis_t_fieldcat_alv,
is_fcat LIKE LINE OF it_fcat.
DATA: it_fieldcat TYPE lvc_t_fcat,
is_fieldcat LIKE LINE OF it_fieldcat.
DATA: new_table TYPE REF TO data.
DATA: new_line TYPE REF TO data.
FIELD-SYMBOLS: <l_table> TYPE ANY TABLE,
<l_line> TYPE ANY,
<l_field> TYPE ANY.
is_fieldcat-fieldname = 'FIELD1'.
is_fieldcat-ref_field = 'MATNR'.
is_fieldcat-ref_table = 'MARA'.
APPEND is_fieldcat TO it_fieldcat.
is_fieldcat-fieldname = 'FIELD2'.
is_fieldcat-ref_field = 'SPRPS'.
is_fieldcat-ref_table = 'PA0001'.
APPEND is_fieldcat TO it_fieldcat.
is_fieldcat-fieldname = 'FIELD3'.
is_fieldcat-ref_field = 'BEGDA'.
is_fieldcat-ref_table = 'PA0002'.
APPEND is_fieldcat TO it_fieldcat.
Create a new Table
CALL METHOD cl_alv_table_create=>create_dynamic_table
EXPORTING
it_fieldcatalog = it_fieldcat
IMPORTING
ep_table = new_table.
Create a new Line with the same structure of the table.
ASSIGN new_table->* TO <l_table>.
CREATE DATA new_line LIKE LINE OF <l_table>.
ASSIGN new_line->* TO <l_line>.
Test it...
DO 40 times.
ASSIGN COMPONENT 'FIELD1' OF STRUCTURE <l_line> TO <l_field>.
<l_field> = '12345'.
ASSIGN COMPONENT 'FIELD2' OF STRUCTURE <l_line> TO <l_field>.
<l_field> = 'X'.
ASSIGN COMPONENT 'FIELD3' OF STRUCTURE <l_line> TO <l_field>.
<l_field> = '20030101'.
INSERT <l_line> INTO TABLE <l_table>.
ENDDO.
LOOP AT <l_table> ASSIGNING <l_line>.
ASSIGN COMPONENT 'field1' OF STRUCTURE <l_line> TO <l_field>.
WRITE / <l_line>.
ENDLOOP.
regards,
Aashish Garg -
How to create a table component dynamically in netbeans 6.0 (JSF 1.2)?
How to create a table component dynamically in netbeans 6.0 (JSF 1.2)?
This example http://developers.sun.com/jscreator/reference/techart/2/createTableDynamically.html works only with JSF 1.1.Please help my write correct code.
How to replace this strings for run example?
rowGroup.setValueBinding("sourceData", getApplication().createValueBinding("#{Page1.tripDataProvider}"));
staticText1.setValueBinding("text", getApplication().createValueBinding("#{currentRow.value['TRIP.TRIPID']}"));
Maybe you are looking for
-
How do I make my N82's sent folder hold more than ...
I have an N82 and use Lifeblog to organize my texts. I find being able to look back and search through old conversations very useful, but have one big problem: My phone's sent folder only holds 20 messages, so I have to keep syncronizing daily if I a
-
Adobe AIR Native installation + DRM issues.
Hello Friends, We are looking at creating an application for a client whom is very concerned about piracy. They have a third party application which essentially injects DRM code into an windows exe. We created a demo air app which in turn was convert
-
Feedback for Reader-Read Out Loud
For Adobe, I am surprised at the low level of quality of Adobe Reaader-Read Out Loud. It cannot pronounce simple words and sounds so robotic as to make the feature painful to use. Why read page headers instead of continuing with a paragraph? Why r
-
Any help would be appreciated
-
Hermes 650 system locks up with 2GB RAM, 1GB OK
I have a Hermes 650 system that keeps locking up when system is upgraded to 2GB RAM. System runs fine with 1GB RAM installed. I tried 2 different brands of 1GB sticks, but same problem.