How to define an itab including a field-symbols
*Please see below code, I define a field-symbols structure <wa>:
FIELD-SYMBOLS: <wa> TYPE ANY.
data: wa type ref to data.
create data wa type (p_table).
assign wa-> to <wa>.
My question is after <wa> get assigned, if I want to define a new internal table or structure which should include <wa>, like below:
data: begin of itab occurs 0.
include structure <wa>.
data: status type c.
data: end of itab.
But it doesn't work. How can I do that?
Thank you very much!
Hi Yu,
Just check with this example, u will get a good idea.
PROGRAM ZMAIN.
DATA: BEGIN OF STR,
A VALUE 'a',
B VALUE 'b',
C VALUE 'c',
D VALUE 'd',
END OF STR,
CN(5) VALUE 'D'.
FIELD-SYMBOLS <FS> TYPE ANY.
DO 3 TIMES.
ASSIGN COMPONENT SY-INDEX OF
STRUCTURE STR TO <FS>.
IF SY-SUBRC <> 0. EXIT. ENDIF.
WRITE <FS>.
ENDDO.
ASSIGN COMPONENT CN OF STRUCTURE STR TO <FS>.
WRITE <FS>.
2.
TYPES: BEGIN OF comp,
f1 TYPE string,
f2 TYPE i,
END OF comp.
DATA: BEGIN OF stru,
k1 TYPE comp,
k2 TYPE comp,
k3 TYPE comp,
k4 TYPE comp,
END OF stru.
FIELD-SYMBOLS: TYPE comp.
ASSIGN stru-k1 TO RANGE stru.
DO 4 TIMES.
ASSIGN INCREMENT 1 TO .
ENDDO.
PROGRAM P1MAIN.
TABLES TRDIR.
DATA NAME(30) VALUE 'TFDIR-PNAME'.
FIELD-SYMBOLS <F> TYPE ANY.
MOVE 'XYZ_PROG' TO TRDIR-NAME.
PERFORM U IN PROGRAM P1SUB.
ASSIGN (NAME) TO <F>.
WRITE <F>.
CALL FUNCTION 'EXAMPLE'.
PROGRAM P1SUB.
TABLES TFDIR.
FORM U.
FIELD-SYMBOLS <F> TYPE ANY.
DATA NAME(30) VALUE 'TRDIR-NAME'.
ASSIGN TABLE FIELD (NAME) TO <F>.
WRITE <F>.
MOVE 'FCT_PROG' TO TFDIR-PNAME.
ENDFORM.
FUNCTION-POOL FUN1.
FUNCTION EXAMPLE.
DATA NAME(30) VALUE 'TRDIR-NAME'.
FIELD-SYMBOLS <F> TYPE ANY.
ASSIGN (NAME) TO <F>.
IF SY-SUBRC = 0.
WRITE <F>.
ELSE.
WRITE / 'TRDIR-NAME cannot be reached'.
ENDIF.
ENDFUNCTION.
PROGRAM P1MAIN.
TABLES TRDIR.
MOVE 'XYZ_PROG' TO TRDIR-NAME.
CALL FUNCTION 'EXAMPLE'.
FUNCTION-POOL FUN1.
FUNCTION EXAMPLE.
DATA NAME(30) VALUE 'TRDIR-NAME'.
FIELD-SYMBOLS <FS> TYPE ANY.
ASSIGN LOCAL COPY OF MAIN
TABLE FIELD (NAME) TO <FS>.
IF SY-SUBRC = 0.
WRITE <FS>.
ELSE.
WRITE / 'Cannot find TRDIR-NAME'.
ENDIF.
ENDFUNCTION.
Regards,
Kumar
Similar Messages
-
How to assign ranges ( select-option)to field symbol
Hi ,
I have following scenario
ranges : r_test1 for agr_1251,
r_test2 for agr_1251.
In runtime i am getting which range i have to populate in a field v_rname.for now let it me v_rname = 'r_test2'
i want to assign (v_rname ) to <field -symbol> ie is range to field symbol.
and i want to update the <field -symbol>-sign ='I'
<field -symbol>-LOW ='some value'
append <field -symbol>.
This is the logic i want to follow, for this how should i have to declare the field symbol ? I couldn't assign a range to field symbol . Please help me.
thanks
MuraliTry this
FIELD-SYMBOLS : <field_symbol> TYPE ANY TABLE.
ASSIGN (v_rname) to <field_symbol>.
<field -symbol>-sign ='I'
<field -symbol>-LOW ='some value'
append <field -symbol>.
This should work because your range is a table.
Hope this helps you. -
How to check data type of the field symbol at run time
Hi,
My code is as following:
LOOP AT <fs> ASSIGNING <wa_covp_ext>.
ASSIGN COMPONENT 86 OF STRUCTURE <wa_covp_ext> TO <f_zzname>.
IF sy-subrc = 0.
ASSIGN COMPONENT 158 OF STRUCTURE <wa_covp_ext> TO <f_pernr>.
IF sy-subrc = 0.
SELECT SINGLE sname INTO <f_zzname> FROM pa0001
WHERE pernr = <f_pernr>
AND endda GE sy-datum
AND begda LE sy-datum.
ENDIF.
ENDIF.
ENDLOOP.
This query is giving dump when <f_zzname> is type P length 8 and decimals 2, because it tries to put PA0001-sname into it which is type C length 30. So I want to check the type of <f_zzname> before the select statement. If it is character 30, then I will write the select statement else not.
How to check data type of the field symbol at run time? If it's not possible, then can somebody suggest a workaround? Thanks.check this ...
write describe statement ...
field-symbols : <f_zzname> .
data : sname like pa0001-sname,
typ(10).
assign sname to <f_zzname>.
describe field <f_zzname> type typ.
write : typ. <-- typ contains character type in this case ..
U can check if typ is of character(C) if so .. write the select statement ... -
IMG - View maintenance - How to define generic length of a field?
Hi there,
within a viewcluster I want to define one field length generic dependet of an entry within another view of the viewcluster.
Have anybody an idea how to solve this issue of generic field length?
Kind regards, KathrinRe: 2 or more update views same dynpro o screen
-
How to delete a particular record in field symbol
Hi,
i am declaring field symbol type any table i, i want delete a particular record in that filed symbol.
How to do that.Hello Himam,
It is not possible to delete directly from <itab> as it is of generic type.
But you can do loop at <itab> ASSIGNING <wa> and then you can clear content of <wa> this will delete
the line from internal table.
Thanks,
Augustin. -
How to build a internal table of field symbols.
Hi,
I want to build a internal table, which consists of several field symbols. Each field symbol points to an entry of other internal tables. All of these tables have different structure definition. How can I implement it. If it is possible, it can save a lot of table query time.
I will be very appreciate for your help.
Best Regards, Junhello jun
i hope the following example give the some idea to build internal table fileds with differen field symbol data types.
FIELD-SYMBOLS:<f1> type any,<f2> TYPE ANY.
data:BEGIN OF itab,
t1 type i value 10,
t2(30) type c value 'john',
t3 type p DECIMALS 3 value '4.7658',
END OF itab.
ASSIGN itab to <f1>.
DO 3 TIMES.
ASSIGN COMPONENT sy-index OF STRUCTURE <f1> TO <f2>.
WRITE <f2>.
ENDDO.
types:begin of it_line,
i1 type i,
t1 type string,
p1 type p DECIMALS 3,
end of it_line.
data:itab1 type table of it_line.
FIELD-SYMBOLS:<f1>.
ASSIGN itab1 to <f1>.
and also u can refer the following links
1-> http://help.sap.com/saphelp_wp/helpdata/en/fc/eb387a358411d1829f0000e829fbfe/content.htm
2--> http://help.sap.com/saphelp_nw70/helpdata/en/fc/eb3923358411d1829f0000e829fbfe/content.htm
Thanks&Regards
sreenivas p -
How to copy the structure of a Field Symbol?
Hi,
I have a requirement where in a dynamic Internal table is supposed to be created. I have created that dynamic table using the class method cl_alv_table_create=>create_dynamic_table. Here I have a structure in the field symbol. My requirement is how do I create a internal table with the structure that is there in the field symbol?...
and i'm unable to refer to the field that is dynamically created in the field symbol.
Like,
<gfs_tab>-pernr = itab-pernr.
in the above stmt the field pernr is created in the field symbol dynamically.
Thanks,
Deepak.Hi Matt,
my objective is to create an internal table with structure that i have obtained in <gfs_tab> .
other than the pernr, there are many fields dynamically generated.
say if I have generated the following structure in <gfs_tab> :
pernr ename1 day1 day2 day3
then I want to create an internal table with the above structure so that my internal table will have fields:
1) pernr
2) ename1
3) day1
4) day2
5) day3
for each execution of the report there will be different structure generated in <gfs_tab> depending upon the inputs that I give.
Thanks,
Deepak. -
How to fill Dynamic work area or field symbol?
HI All,
I have created dynamic work area(field symbol) by using following code. Now I want to fill the work area with values which are there in other internal table.
* Create dynamic internal table/structure
call method cl_alv_table_create=>create_dynamic_table
exporting
it_fieldcatalog = it_fieldcat
importing
ep_table = dyn_table.
assign dyn_table->* to <fs_table>.
* Create dynamic work area and assign to Field Symbol
create data dyn_line like line of <fs_table>.
assign dyn_line->* to <fs_wa>.
My <FS_WA> contains:
ROW1
ROW2
ROW3
ROW4 as fields in it without having any data.
I have other internal table.. where I have FIELDS and Data like following:
FIELD1 FIELD2 FIELD3
ID1 ROW1 A1
ID1 ROW2 A2
ID1 ROW3 A3
ID1 ROW4 A4
ID2 ROW1 B1
ID2 ROW2 B2
ID2 ROW3 B3
ID3 ROW1 C4
Important thing that I have to share with you is... Source table of my Internal table and Source structure to create my dynamic table are same.
This dynamic table has fields... with "FIELD2" values.
Thanks,
Naveen.ICreate a dynamic internal table
CALL METHOD cl_alv_table_create=>create_dynamic_table
EXPORTING
it_fieldcatalog = lt_fcat
IMPORTING
ep_table = lt_dy_table.
Create dynamic work area and assign to FS
ASSIGN lt_dy_table->* TO <fs_dyn_table>.
CREATE DATA lt_dy_line LIKE LINE OF <fs_dyn_table>.
ASSIGN lt_dy_line->* TO <fs_dyn_wa>.
Define WA
CREATE DATA dref TYPE (iv_struc_name).
ASSIGN dref->* TO <fs_final>.
Populate dynamic table from the file
OPEN DATASET iv_path FOR INPUT IN TEXT MODE ENCODING DEFAULT.
IF sy-subrc = 0.
DO.
READ DATASET iv_path INTO ls_str.
IF sy-subrc <> 0.
ev_failed = abap_true.
EXIT.
ENDIF.
SPLIT ls_str AT ';' INTO TABLE lt_dyn_tab. " columns
LOOP AT lt_dyn_tab INTO ls_dyn_tab.
READ TABLE lt_struc_fld INTO ls_struc_fld INDEX sy-tabix.
IF sy-subrc EQ 0.
MOVE ls_struc_fld-fieldname TO ls_fieldname.
ASSIGN COMPONENT ls_fieldname OF STRUCTURE <fs_dyn_wa> TO <fs_val>.
IF sy-subrc = 0.
<fs_val> = ls_dyn_tab.
ENDIF.
ASSIGN COMPONENT ls_fieldname OF STRUCTURE <fs_final> TO <fs_val>.
IF sy-subrc = 0.
<fs_val> = ls_dyn_tab.
ENDIF.
ENDIF.
ENDLOOP.
APPEND <fs_dyn_wa> TO <fs_dyn_table>.
APPEND <fs_final> TO et_table.
UNASSIGN: <fs_val>.
ENDDO.
ENDIF.
CLOSE DATASET iv_path. -
Sort itab by using field symbol
All,
I have a field symbol that pointing to a field value in work area of an internal table i_sort ( For example work area that contains the field name having a value MATNR' ( this decides only at runtime) )
My requirement is i need to sort another table for example i_tab (structure same as records in i_sort) using this field symbol.
Any Info?
a®Hi,
Check the below report sorting table VBAP based on field VBELN dynamically.
Let me know if u need any clarification.
REPORT ZTEST1.
tables: dd03l.
field-symbols: <fs1> type any,
<fs2> type any.
data:
wa_1 type vbak,
w_index type sy-index.
data:
itab like standard table of vbap,
ftab like standard table of dd03l.
select * from vbap into table itab
up to 10 rows.
select single * from vbak into wa_1 where vbeln ne space.
assign wa_1-vbeln to : <fs1>,
<fs2>.
do.
assign component sy-index of structure wa_1 to <fs1>.
if <fs1> = <fs2>.
w_index = sy-index.
exit.
endif.
enddo.
select *
from DD03L
into table ftab
where TABNAME eq 'VBAK'.
sort ftab by position.
read table ftab with key position = w_index into dd03l.
sort itab by (dd03l-FIELDNAME).
Thanks,
- Ram -
How to check the length of a field symbol value
hi all,
i have a problem with string function, i have assined table fields to a field symbol in a loop i want check the length of the assigned fields symbol value in every loop . i have written like ,,,,,len = strlen( <fs>). then i am getting the length of the field label what i ahve assigned to fiels symbol not the field value lenght ,
please advise me on this,
thanks,
sreI think you're on the right track. This should work:
data: len type i.
data: begin of itab OCCURS 1,
a type string value '1',
b type string value '12',
c type string value '123',
end of itab.
FIELD-SYMBOLS: <fs> type ANY.
do 3 times.
assign component sy-index of STRUCTURE itab to <fs>.
len = strlen( <fs> ).
enddo. -
How to get values from dynamically populated field symbol
Hi all,
I am having a field symbol <fs_table> type standard table, which is getting populated dynamically.
CALL METHOD cl_alv_table_create=>create_dynamic_table
EXPORTING
it_fieldcatalog = i_fieldcat[]
IMPORTING
ep_table = is_eptab.
ASSIGN is_eptab->* TO <fs_table> .
After the ALV display i am making some changes in the ALV and getting a new internal table <fst_table>,which is having changed values.
Now the problem is that i am not able to get the changed values from <fst_table> as it is not of any structure type and cant associate it with any field like we do in normal internal table and work areas like, wa-fieldname.
All the fields are dynamic.
Regards,
AnantHello Anant
You have to access to access the fields of your dynamic outtab dynamically as well.
DATA: ls_fcat TYPE lvc_s_fcat.
FIELD-SYMBOLS:
<ls_struc> TYPE any,
<ld_fld> TYPE any.
LOOP AT <fs_table> ASSIGNING <ls_struc>.
LOOP AT i_fieldcat INTO ls_fcat.
ASSIGN COMPONENT ls_fcat-fieldname OF STRUCTURE <ls_struc> TO <ld_fld>.
... " do processing
ENDLOOP.
ENDLOOP.
Regards
Uwe -
How to pass dynamic name to a field-symbol?
Hi All,
I have a requirement like I need to create dynamic internal table with dynamic name. Say like,
Create a new Table
CALL METHOD cl_alv_table_create=>create_dynamic_table
EXPORTING
it_fieldcatalog = it_fieldcat_fin[]
IMPORTING
ep_table = new_table.
IF sy-subrc EQ 0.
Create a new Line with the same structure of the table.
ASSIGN new_table->* to <b>(<fs_table>)</b>.
In the above code, (<fs_table>) is a variable. Actually it is in the loop, so that first time it comes, it has to create an internal table with name as <fs_01>, next time <fs_02> and so on. Hope I am clear.
Please help me. I am sure that i will mark the helpful answers.DATA: DREF TYPE REF TO DATA,WA_REF TYPE REF TO DATA.
FIELD-SYMBOLS: <TEMP_TAB> TYPE TABLE, <TEMP_WA> TYPE ANY.
*& Form DYNAMIC_TABLE
text
--> p1 text
<-- p2 text
FORM DYNAMIC_TABLE.
CALL METHOD CL_ALV_TABLE_CREATE=>CREATE_DYNAMIC_TABLE
EXPORTING
IT_FIELDCATALOG = LT_LVCFIELDCAT
IMPORTING
EP_TABLE = DREF.
ASSIGN dref->* TO <TEMP_TAB>.
ENDFORM. " DYNAMIC_TABLE
the above is the procedure to create dynamic internal tables.
now <TEMP_TAB> points to the contents of the table table in DREF.
field symbol it self is meant for dynamic.
then y r u using (<fs_table>).
when everytime the same fieldsymbol is pointing to new contents, y u need new name everytime?
i mean as the data is not static, so what is the use of naming a field symbol every time?.
if u want to store the data in an internal table with a name,
then u can do like below,
data: tabname type string, i type i.
concatenate '<fs_' i into tabname.
"let i be the variable which stores the internal tables count
"MOVE <temp_tab> to tabname. -
How to update the value inside a field symbol ?
ASSIGN COMPONENT 'MENGE' OF STRUCTURE <fs_line> TO <fs_field>.
<fs_field> = itab_stpo-menge.
COLLECT <fs_line> INTO <fs_table>.
.processing some code......
ASSIGN COMPONENT 'MENGE' OF STRUCTURE <fs_line> TO <fs_field>.
<fs_field> = ( itab_stpo-menge * itab_plpo-vgw03 ).
COLLECT <fs_line> INTO <fs_table>.
Hi, guys,
May i know is there a way to update the value in inside a field symbol?
I feel hard to figure out the way to solve this situation. Kindly give me some help or perhaos tell me other altenative way to do it also can.
Thanks in advance.
Edited by: Jiansi Lim on Apr 25, 2008 8:09 PMhi check this...
For a structured data object s, you can use the statement
ASSIGN COMPONENT comp OF STRUCTURE s TO FS.
Here the comp is the component name or its index number in the structure.
Find the following sample code -
DATA: BEGIN OF LINE,
COL1 TYPE I VALUE '11',
COL2 TYPE I VALUE '22',
COL3 TYPE I VALUE '33',
END OF LINE.
DATA COMP(5) VALUE 'COL3'.
FIELD-SYMBOLS: <F1>, <F2>, <F3>.
ASSIGN LINE TO <F1>.
ASSIGN COMP TO <F2>.
DO 3 TIMES.
ASSIGN COMPONENT SY-INDEX OF STRUCTURE <F1> TO <F3>.
WRITE <F3>.
ENDDO.
ASSIGN COMPONENT <F2> OF STRUCTURE <F1> TO <F3>.
WRITE / <F3>.
The output is:
11 22 33
33
I need to update one field in Internal table
regards,
venkat -
How to dynamically assign type to a field-symbol?
Hi,
I have two fields in one table, one for field name and one for table name. These can be fields in different
tables. I need to fetch value of this field in that table. So the type of this variable can change dynamically.
I am trying to assign type of this field dynamically to a field-symbol. I have to use this field symbol in a
select statement. Currently it is showing a dumb, as the field type is dec7. For some other types it is
working fine.
Regards,
SunilHi all,
I have the same problem.
I tried with your helps but i can't fix them.
A message is raised "Field <fs_bet> unknown" when i used code below
FIELD-SYMBOLS: <fs_bet> TYPE any.
DATA: c_bet TYPE string.
DATA it_0008 type STANDARD TABLE OF pa0008 WITH HEADER LINE.
DO 40 TIMES.
CONCATENATE 'BET0' index into c_bet.
ASSIGN (c_bet) to <fs_bet> CASTING TYPE pad_amt7s .
select * from pa0008 into it_0008
where <fs_bet> = '1000'
and pernr = 32.
append it_0008.
ENDSELECT.
ENDDO.
Please help me to solve it.
Thanks so much,
Sophie Tran -
How to define the format for numeric field ?
Hello
I have Amount field and I would to define the format to be ( XX.XXX,000 )
How can I do this ??
I'm new in ADF and need your help ..
rgrds
Edited by: moh3li_pal on Mar 1, 2010 8:05 AMi have the same problem i try with pattern "###,###.##" but the application adf is the inverse "###.###,##" , this a bug or the pattern errornious.??Hi Joaquin. This is not a bug, although this is a little difficult to explain without face-to-face communication :D The confusing thing here is the difference between the 'special pattern characters' and actual output characters (which are chosen based on your locale).
If you check the Java DecimalFormat class (which provides the rules for formatting) you'll see the following:
Using , in the pattern = Grouping separator
Using . in the pattern = Decimal separator or monetary decimal separator
According to your locale, the grouping separator is '.' and the decimal separator is ','. So the pattern you have specified does dictate that you should get the result you have found.
You either need to change your locale settings (best option) or cheat by switching the , and . in your pattern.
Maybe you are looking for
-
I shut down my macbook and now while applications such as safari have been open for awhile, even while active, will automatically minimize and it take me back to the desktop. How do I fix this?
-
Can multiple iPhones share one iTunes without syncing the phones together? We just got new iPhones and set up seperate apple id's, but don't know if we can both sync to our existing iTunes without linking our phones together (contacts, apps, etc) ???
-
first time to the discussion forum. Like I stated in the title, I use to be able to have all my photo albums sync to my iphone. I did something and now it only allows me to "sync photos from..." and it only allows me to chose from 1 of my folders and
-
Issue in Mapping Tuples in Syndicator
Hi, I am not able to map the Tuple ( Multivalued) to the target fields in Syndicator. Currently in XSD the target field is kept as unbounded Kindly tell the settings which needs to be done at the XSD Regards, Antony
-
How to setup Printer style in application(11i)
I got below request from user.How to setup print style. ==================================================== Please setup the print Style "Portrait - For T4A Paper" for the TOR-PAY1-4100 and noprint printers in OAHP. I am trying to print paper T4A's