Field-symbols as pgae attributes?
Hi all,
i have the problem of including a page fragment two times in the same page. In this fragment i declare a field symbol. And when i try to compile the code it crashes.
I need to declare it somewhere, so that just one declaration have to take place. I suppose as a page attribute is the correct step. But i don't know how to do that. Could anyone help me or give me an other possible solution to my problem.
Hi,
In the assumption that you have defined a table called itab.
In your page:
<%FIELD-SYMBOLS <fs> TYPE ANY TABLE.%>
<%@ include file = "pagefrag.htm" %>
<%@ include file = "pagefrag.htm" %>
in your page frag:
<%ASSIGN itab TO <fs>.%>
That's it, it works fine.
Eddy
PS.
Put yourself on the SDN world map (http://sdn.idizaai.be/sdn_world/sdn_world.html) and earn 25 points.
Spread the wor(l)d!
Similar Messages
-
Field-symbols as class attribute
Hi Fellas,
Is there a way we can define a field-symbols as a class attribute ? My requirement is that i am dynamically constructing a structure at runtime in my model class and binding the component of this structure to my view fields. I am able to create the structure which is basically ref to cl_abap_structdescr and the problem is when i am binding to the model attribute, i need this to be a structure so that i can address the components as "//model/structure.component".
Please let me know how we can define a field-symbol as a class attribute.
Cheers,
Ram.Hi Ram,
Field-Symbol as class attribute is not possible. Your way to do this by REF TO DATA is the correct way for that.
By default data binding is only possible like this:
Simple field attribute
value=//<model>/<field name>
Structure attribute
value=//<model>/<structure name>.<field name>
Table attribute
value=//<model>/<table name>[<line index].<field name>
If you want to bind to your data reference you have to implement your own getter and setter methods. Read this <a href="http://help.sap.com/saphelp_nw70/helpdata/en/fb/fbb84c20df274aa52a0b0833769057/frameset.htm">http://help.sap.com/saphelp_nw70/helpdata/en/fb/fbb84c20df274aa52a0b0833769057/frameset.htm</a> for further information. In addition to that, you have to implement your own GET_M_S_xxx to return metadata of your structure. By doing all this it is possible to implement a completely dynamic data binding. In the view it looks like the regular Structure attribute: value=//<model>/<data-ref name>.<field name>
Regards,
Thilo -
Field symbols as Class Attributes
Hello Gurus,
Is anybody able to say to me if it is possible to declare field symbols as class attributes? As I can understand until now, this is not possible and we need to use some attribute with the "TYPE REF TO Data" to get the information we need. Correct?
Thanks,
Daniel.Ok, let me see if someone can give me some idea on how to improve my method:
Method: PREPARE_PTOOL_DATA
Parameters specification:
Parameter Type Typing Reference Type
PF_ANALYSIS Importing Type /SYM/SC_PT_ID_ANALYSIS_D
PF_ANAL_DESC Importing Type /SYM/SC_NM_DESC_ANALYSIS
PF_LOGIC Importing Type CHAR01
PF_MATERIAL Importing Type MATNR
PF_MAKTX Importing Type MAKTX
PT_DATA_COMPA Exporting Type /SYM/SC_TAB_PT_RESULT_CP
PT_CALC_ANALY Exporting Type /SYM/SC_TAB_PT_RESULT_CA
PT_DATA_MATERIAL1 Changing Type /SYM/SC_TAB_PROC_ALLERG_RESULT
PT_DATA_MATERIAL2 Changing Type /SYM/SC_TAB_PROC_ALLERG_RESULT
Source code:
From the /SYM/SC_CL_PROCESS_ALLERG_GEN class
Old version (but it is working)
METHOD prepare_ptool_data.
DATA: ls_data_material1 TYPE /sym/sc_s_proc_allerg_result,
ls_data_material2 TYPE /sym/sc_s_proc_allerg_result,
lf_index_material1 TYPE sy-tabix,
lf_index_material2 TYPE sy-tabix,
ls_result_cp TYPE /sym/sc_pt_result_cp,
ls_result_ca TYPE /sym/sc_pt_result_ca.
Prepare data for Data Comparison step
IF pt_data_compa IS REQUESTED.
LOOP AT pt_data_material1 INTO ls_data_material1.
lf_index_material1 = sy-tabix.
CLEAR ls_result_cp.
MOVE pf_analysis TO ls_result_cp-analysis.
MOVE pf_anal_desc TO ls_result_cp-desc_analysis.
MOVE ls_data_material1-algbe TO ls_result_cp-desc_property.
If Logic 'A', move the text from ls_data_material1 to original
material status
IF pf_logic EQ c_logic_a.
MOVE ls_data_material1-agsbe TO ls_result_cp-val_orig_matnr.
If Logic 'B', move the text from ls_data_material1 to "toy"
material status
ELSEIF pf_logic EQ c_logic_b.
MOVE ls_data_material1-agsbe TO ls_result_cp-val_toy_matnr.
ENDIF. " IF pf_logic EQ c_logic_a.
Read the lt_data_toy by the Allergen ID (ALGEN)
CLEAR ls_data_material2.
READ TABLE pt_data_material2 INTO ls_data_material2
WITH KEY algen = ls_data_material1-algen BINARY SEARCH.
IF sy-subrc EQ 0.
lf_index_material2 = sy-tabix.
If Logic 'A', move the text from ls_data_material2 to "toy°
material status
IF pf_logic EQ c_logic_a.
MOVE ls_data_material2-agsbe TO ls_result_cp-val_toy_matnr.
If Logic 'B', move the text from ls_data_material2 to original
material status
ELSEIF pf_logic EQ c_logic_b.
MOVE ls_data_material2-agsbe TO ls_result_cp-val_orig_matnr.
ENDIF. " IF pf_logic EQ c_a.
Delete record from lt_data_toy, index lf_index_toy
DELETE pt_data_material2 INDEX lf_index_material2.
ENDIF. " IF sy-subrc EQ 0.
APPEND ls_result_cp TO pt_data_compa.
Delete record from lt_data_orig, index lf_index_orig
DELETE pt_data_material1 INDEX lf_index_material1.
ENDLOOP. " LOOP AT lt_data_material1 INTO ls_data_material1.
ENDIF. " IF pt_data_compa IS REQUESTED.
Prepare data for Calculation Analysis step
IF pt_calc_analy IS REQUESTED.
LOOP AT pt_data_material1 INTO ls_data_material1.
lf_index_material1 = sy-tabix.
CLEAR ls_result_ca.
MOVE pf_material TO ls_result_ca-matnr.
MOVE pf_maktx TO ls_result_ca-maktx.
MOVE pf_analysis TO ls_result_ca-analysis.
MOVE pf_anal_desc TO ls_result_ca-desc_analysis.
MOVE ls_data_material1-algbe TO ls_result_ca-desc_property.
If Logic 'A', move the text from ls_data_material1 to original
material status
IF pf_logic EQ c_logic_a.
MOVE ls_data_material1-agsbe TO ls_result_ca-val_curr_stat.
If Logic 'B', move the text from ls_data_material1 to "toy"
material status
ELSEIF pf_logic EQ c_logic_b.
MOVE ls_data_material1-agsbe TO ls_result_ca-val_simul_stat.
ENDIF. " IF pf_logic EQ c_logic_a.
Read the lt_data_toy by the Allergen ID (ALGEN)
CLEAR ls_data_material2.
READ TABLE pt_data_material2 INTO ls_data_material2
WITH KEY algen = ls_data_material1-algen BINARY SEARCH.
IF sy-subrc EQ 0.
lf_index_material2 = sy-tabix.
If Logic 'A', move the text from ls_data_material2 to "toy°
material status
IF pf_logic EQ c_logic_a.
MOVE ls_data_material2-agsbe TO ls_result_ca-val_simul_stat.
If Logic 'B', move the text from ls_data_material2 to original
material status
ELSEIF pf_logic EQ c_logic_b.
MOVE ls_data_material2-agsbe TO ls_result_ca-val_curr_stat.
ENDIF. " IF pf_logic EQ c_a.
Delete record from lt_data_toy, index lf_index_toy
DELETE pt_data_material2 INDEX lf_index_material2.
ENDIF. " IF sy-subrc EQ 0.
APPEND ls_result_ca TO pt_calc_analy.
Delete record from lt_data_orig, index lf_index_orig
DELETE pt_data_material1 INDEX lf_index_material1.
ENDLOOP. " LOOP AT lt_data_material1 INTO ls_data_material1.
ENDIF. " IF pt_calc_analy IS REQUESTED.
ENDMETHOD.
As you can see, I am repeating almost the same code, just changing some items. I am not sure if I can use new parameters (ANY or ANY TABLE) but, my first idea to improve it was to use the field-symbols (and it works ok). The issue is that I have to repeat the assignment lines every same named method of the classes I am changing (I would like to do the assignment into a new method of the superclass). Do you think it is possible or should I give up and proceed with the assignments locally, for each same named method of each class?
Thanks,
Daniel. -
Very Urgent: how to define field symbols in class using se24 Points assured
hi all
I am new to abap oo programming. I am using se24 to build a class
where some methods have code which involves working with field sybmols but i am not able to figure out way for how to define field symbols in the attributes section.
I tried defining like : fld_sym type ref to dbtab-fld
but in the method implementation if i try to use it like assign fld to <fld_sym> there it says fld_sym is not defined as a field symbol.
So can anyone please guide me how to define field symbols in se24.
Also what should be the general steps while creating a class using se24.
Points assured
thanksHi
Global classes are like Global fun modules in which the Methods and code is already written and is mainly used for Reusability purpose.
Goto SE24 tcode and see the std global classes like
CL_ABAP_CHAR_UTILITIES
see the links
chk out the links below:
General Tutorial for OOPS
https://www.sdn.sap.com/irj/sdn/go/portal/prtroot/docs/library/uuid/e8a1d690-0201-0010-b7ad-d9719a415907
Have a look at these links for OO ABAP.
http://www.sapgenie.com/abap/OO/
http://help.sap.com/saphelp_nw04/helpdata/en/c3/225b5654f411d194a60000e8353423/content.htm
http://www.esnips.com/doc/375fff1b-5a62-444d-8ec1-55508c308b17/prefinalppt.ppt
http://www.esnips.com/doc/2c76dc57-e74a-4539-a20e-29383317e804/OO-abap.pdf
http://www.esnips.com/doc/5c65b0dd-eddf-4512-8e32-ecd26735f0f2/prefinalppt.ppt
http://www.allsaplinks.com/
http://www.sapgenie.com/abap/controls/index.htm
http://www.esnips.com/doc/2c76dc57-e74a-4539-a20e-29383317e804/OO-abap.pdf
http://www.esnips.com/doc/0ef39d4b-586a-4637-abbb-e4f69d2d9307/SAP-CONTROLS-WORKSHOP.pdf
http://help.sap.com/saphelp_erp2005/helpdata/en/ce/b518b6513611d194a50000e8353423/frameset.htm
SDN Series:
https://www.sdn.sap.com/irj/sdn/developerareas/abap?rid=/webcontent/uuid/35eaef9c-0b01-0010-dd8b-e3b0f9ed7ccb [original link is broken]
http://help.sap.com/printdocu/core/Print46c/en/data/pdf/BCABA/BCABA.pdf
Basic concepts of OOPS
https://www.sdn.sap.com/irj/sdn/go/portal/prtroot/docs/library/uuid/b6cae890-0201-0010-ef8b-f970a9c41d47
https://www.sdn.sap.com/irj/sdn/go/portal/prtroot/docs/library/uuid/1591ec90-0201-0010-3ba8-cdcd500b17cf
https://www.sdn.sap.com/irj/servlet/prt/portal/prtroot/com.sap.km.cm.docs/library/webas/abap/abap%20code%20samples/alv%20grid/abap%20code%20sample%20to%20display%20data%20in%20alv%20grid%20using%20object%20oriented%20programming.doc
http://www.henrikfrank.dk/abapuk.html
http://www.erpgenie.com/abap/OO/
Reward oints if useful,
Aleem. -
Hi,
its possible form internal table like this:
tabname | row | columnName | columnValue
t005 | 1 | land1 | AD
t005 | 1 | landk | AND
t005 | 1 | lnplz | 00
t005 | 2 | land1 | AS
t005 | 2 | landk | ND
t005 | 2 | lnplz | 01
to create internal table "t005" in this structure:
row| land1 | landk | lnplz | ...
1 | AD | AND | 00
2 | AS | ND | 01
(use field-symbols, or dynamic attribute declarations...)
thanks, mTry this...
Get the T005 data into internal table as first table...
tabname | row | columnName | columnValue
t005 | 1 | land1 | AD
t005 | 1 | landk | AND
t005 | 1 | lnplz | 00
t005 | 2 | land1 | AS
t005 | 2 | landk | ND
t005 | 2 | lnplz | 01
Now declare another internal table in the form...
row| land1 | landk | lnplz | ...
sort itab_t005 by tablename row.
now loop at itab_t005.
at new row.
clear itab_new.
endat.
if itab_t005-columename eq 'land1.
itab_new-land1 = itab_t005-columevalue.
endif.
the same for other two....
at end of row.
append itab_new.
endat.
endloop.
Hope this will solve ur porblem... -
Hi, can a field symbol be global in a static class?
Hello Kenneth
Please refer to the answer of Klaus Ziegler in the following thread
Re: Field symbols as Class Attributes
Regards
Uwe -
Accessing the attributes of a class using field symbols?
An option to pulll a variable into a user exit that otherwise would be out of reach is detailed [here|https://www.sdn.sap.com/irj/sdn/go/portal/prtroot/docs/library/uuid/208811b0-00b2-2910-c5ac-dd2c7c50c8e8]
Can a similar approach involving field symbols or otherwise, be used to pull in the attributes of a class into the exit? For now, I'm trying to access the A_FRONTEND_INDEX attribute of the class CL_HRXSS_REM.
any ideas?
~SureshHi,
Have you already tried (PROGRAM)(OBJECT)->A_FRONTEND_INDEX in your code? I prepared small testing scenario with two programs and it works.
REPORT zmv_test1.
FORM test.
FIELD-SYMBOLS: <fs> TYPE ANY.
ASSIGN '(ZMV_TEST2)zip->crc32_map' TO <fs>.
IF sy-subrc EQ 0.
<fs> = 'Test'.
ENDIF.
ENDFORM. "test
REPORT zmv_test2.
DATA: zip TYPE REF TO cl_abap_zip.
START-OF-SELECTION.
CREATE OBJECT zip.
PERFORM test IN PROGRAM zmv_test1.
Cheers, -
Assign Type conflict with field symbols
I have two tables tab1 & tab2, want to assign field values from tab1 to tab2 suing field symbols. Deatils are :
TYPES: BEGIN OF ty_tab1,
item1 TYPE char20,
item2 TYPE char20,
val1 type i,
val2 type i,
END OF ty_tab1,
BEGIN OF ty_tab2,
item1 TYPE char20,
item2 TYPE char20,
END OF ty_tab2.
DATA: it_tab1 TYPE TABLE OF ty_tab1,
it_tab2 TYPE TABLE OF ty_tab2.
FIELD-SYMBOLS <fs_tab1> TYPE ty_tab1.
<fs_tab2t> type ty_tab2.
LOOP AT it_tab1 assigning <fs_tab1>.
READ TABLE it_tab2 assigning <fs_tab2> WITH KEY item1 = <fs_tab1>-item1
item2 = <fs_tab1>-item2.
IF sy-subrc EQ 0.
ASSIGN COMPONENT 'ITEM1' OF STRUCTURE <fs_tab1> TO <fs_tab2>.
ASSIGN COMPONENT 'ITEM2' OF STRUCTURE <fs_tab1> TO <fs_tab2>.
endif.
endloop.
Getting error msg
You attempted to assign a field to a typed field symbol, but the field does not have the required type.
whats the reason of error.
Edited by: Matt on May 27, 2011 8:59 AM - added tagsTaken from example dump
A new value is to be assigned to the field "...", although this field is
entirely or partly protected against changes.
The following are protected against changes:
- Character literals or numeric literals
- Constants (CONSTANTS)
- Parameters of the category IMPORTING REFERENCE for functions and
methods
- Untyped field symbols not yet assigned a field using ASSIGN
- TABLES parameters if the actual parameter is protected against changes
- USING reference parameters and CHANGING parameters for FORMs, if the
actual parameter is protected against changes and
- Accesses using field symbols if the field assigned using ASSIGN is
protected (or partially protected, e.g. key components of an internal
table with the type SORTED or HASHED TABLE) against changes
- Accesses using references, if the field bound to the reference is
protected (or partially protected) against changes
- External write accesses to READ-ONLY attributes,
- Content of a shared object area instance accessed using a shared lock
(ATTACH_FOR_READ).
You likely fall in one of these cases. Check each and if still unsure please share your code so we can reproduce the error.
Regards
Marcin -
Hi all,
I want to declare a field symbol <fs> in a class, & to use it in different methods of the same class.
But in attributes of the class, how i declare field symbol in a class.
I m not able to do this...
<b>Pleas assist me..& have ur points.</b>
Regards,
pradeep phogatPradeep,
See this thread. It gives details about field symbol used in a standard class. This should give you some idea.
Re: Field Symbol
ashish -
Passing unassigned field symbols to a method
Hello Gurus,
I work with a field symbol in a method and after the work is finished i have to use it i my program that i call the method from.
The problem is that the field symbol gets assigned only in the method so i can`t get the field symbol as a changing parameter in my method because it is not assigned yet.
I thought that i can return the field symbol from the method after it has been assigned, but i don`t know how. The <fs> is a dynamic itab that i created within the method.
Can anyone help please ??Although already answered this code snippet might make it clearer
my_line is your data structure typically an itab structure.
For example
TYPES: BEGIN OF s_elements,
tabname type DD02L-tabname,
tabclass type dd02l-tabclass,
as4user type dd02L-as4user,
as4date type dd02l-as4date,
as4time type DD02l-as4time,
viewed(1) type c.
TYPES: END OF s_elements.
Data: my_line TYPE s_elements.
1) get the structure of your itab automatically so you can build an FCAT simply for any structure without the horrendous usual coding to manipulate and create FCATS.
CALL METHOD me->return_structure
EXPORTING
my_line = my_line.
You need to make a table ZOGT data available in the class definition either as an attribute if you are using the class builder SE24 or as DATA in the relevant class section.
data:
zog LIKE LINE OF lr_rtti_struc->components .
data:
zogt LIKE TABLE OF zog .
method RETURN_STRUCTURE.
lr_rtti_struc ?= cl_abap_structdescr=>describe_by_data( my_line ).
zogt[] = lr_rtti_struc->components.
endmethod.
Your structure details are now in table zogt.
Use this to build an FCAT.
CALL METHOD me->create_dynamic_fcat
IMPORTING
it_fldcat = it_fldcat.
method CREATE_DYNAMIC_FCAT.
LOOP AT zogt INTO zog.
CLEAR wa_it_fldcat.
wa_it_fldcat-fieldname = zog-name .
wa_it_fldcat-datatype = zog-type_kind.
wa_it_fldcat-inttype = zog-type_kind.
wa_it_fldcat-intlen = zog-length.
wa_it_fldcat-decimals = zog-decimals.
wa_it_fldcat-coltext = zog-name.
wa_it_fldcat-lowercase = 'X'.
APPEND wa_it_fldcat TO it_fldcat .
ENDLOOP.
endmethod.
Now having got your FCAT you can build your dynamic table.
CALL METHOD me->create_dynamic_table
EXPORTING
it_fldcat = it_fldcat
IMPORTING
dy_table = dy_table.
(dy_table is defined as ref to data)
method CREATE_DYNAMIC_TABLE.
CALL METHOD cl_alv_table_create=>create_dynamic_table
EXPORTING
it_fieldcatalog = it_fldcat
IMPORTING
ep_table = dy_table.
endmethod.
Now populate your dynamic table as per sample code here
field_symbols:
<dyn_table> TYPE STANDARD TABLE.
<dyn_wa>.
data: dy_line TYPE REF TO data.
FORM populate_dynamic_itab.
ASSIGN dy_table->* TO <dyn_table>.
CREATE DATA dy_line LIKE LINE OF <dyn_table>.
ASSIGN dy_line->* TO <dyn_wa>.
SELECT *
FROM DD02L
INTO CORRESPONDING FIELDS OF TABLE <dyn_table>
WHERE TABNAME LIKE 'ZHR%'.
ENDFORM.
Now you can display your grid and process your data.
CALL METHOD z_object->display_grid
EXPORTING
g_outtab = <dyn_table>
g_fldcat = it_fldcat
i_gridtitle = i_gridtitle
i_edit = i_edit
i_zebra = i_zebra
CHANGING
it_fldcat = it_fldcat
gt_outtab = <dyn_table>.
In the Method
method DISPLAY_GRID.
GET REFERENCE OF g_outtab INTO g_outtab1.
GET REFERENCE OF g_fldcat INTO g_fldcat1.
struct_grid_lset-edit = i_edit. "To enable editing
struct_grid_LSET-zebra = i_zebra.
struct_grid_lset-grid_title = i_gridtitle.
struct_grid_lset-ctab_fname = 'T_CELLCOLORS'.
struct_grid_lset-stylefname = 'CELLTAB'.
CALL METHOD grid1->set_ready_for_input
EXPORTING
i_ready_for_input = '1'.
CALL METHOD grid1->set_table_for_first_display
EXPORTING
is_layout = struct_grid_lset
CHANGING
it_outtab = gt_outtab
it_fieldcatalog = it_fldcat.
ENDMETHOD.
You can even easily code your own column names if you so wish in the application program.
Before calling the method that displays the grid encode the following macro.
DEFINE col_name.
read table it_fldcat into wa_it_fldcat index &1.
wa_it_fldcat-coltext = &2.
wa_it_fldcat-outputlen = &3.
modify it_fldcat from wa_it_fldcat index &1.
END-OF-DEFINITION.
Then have a subroutine in your application code something like this
Form name_columns.
Here before displaying you can change the field catalog to
adjust your own column names.
*col_name col-nr 'your name' output length.
col_name 1 'Table name' 30.
col_name 2 'Table class' 12.
col_name 3 'Changed By' 12.
col_name 4 ' On' 12.
col_name 5 ' At' 8.
col_name 6 'Act' 3.
i_gridtitle = 'HR ESS / ITS ZHR Tables - Double click to display'.
i_zebra = 'X'.
i_edit = ' '.
endform.
Hope this clears it up a bit.
Once you get this stuff working you can re-use 99% of the code for almost any structure making the whole process of OO ALV grid applications really simple.
Yoy only need as well a standard dynpro with a custom container on it (se51).
Cheers
jimbo -
Get_static_attributes_table: Field symbol error
Hi,
I'm trying to build a dynamic context node, edit the data and save the changes. Referring the link " http://www.sdn.sap.com/irj/scn/index?rid=/library/uuid/80a3de18-ee00-2d10-bfb3-946d7e00fd91 " which has similar solution.
But I'm facing the problem in on_data_check method in the call statement of get_static_attributes_table.
DATA : LO_ND_PROJECTS TYPE REF TO IF_WD_CONTEXT_NODE,
LO_EL_PROJECTS TYPE REF TO IF_WD_CONTEXT_ELEMENT.
FIELD-SYMBOLS : <FS_CONTEXT> TYPE STANDARD TABLE.
LO_ND_PROJECTS = WD_CONTEXT->GET_CHILD_NODE( NAME = 'NEW_NODE' ).
LO_EL_PROJECTS = LO_ND_PROJECTS->GET_ELEMENT( ).
CALL METHOD LO_ND_PROJECTS->GET_STATIC_ATTRIBUTES_TABLE
IMPORTING
TABLE = <FS_CONTEXT>.
When executing the application, I'm getting the error "Field symbol has not yet been assigned. "
Any pointers to resolve this?data : wa_param like line of r_param->t_modified_cells.
data : lo_nd_projects type ref to if_wd_context_node,
lo_el_projects type ref to if_wd_context_element.
field-symbols : <fs_context> type standard table,
<fs_context2> type any,
<fs_variable2> type any,
<fs_variable> type any.
lo_nd_projects = wd_context->get_child_node( name =
'NEW_NODE' ).
lo_el_projects = lo_nd_projects->get_element( ).
data : lt_dyn_table type ref to data,
lt_fieldcat type lvc_t_fcat,
lw_fieldcat like line of lt_fieldcat.
clear lt_fieldcat.
lw_fieldcat-fieldname = 'FLD1'.
lw_fieldcat-datatype = 'string'.
lw_fieldcat-outputlen = '24'.
lw_fieldcat-coltext = 'FLD1'.
lw_fieldcat-seltext = lw_fieldcat-coltext.
append lw_fieldcat to lt_fieldcat.
lw_fieldcat-fieldname = 'FLD2'.
lw_fieldcat-datatype = 'string'.
lw_fieldcat-outputlen = '24'.
lw_fieldcat-coltext = 'FLD2'.
lw_fieldcat-seltext = lw_fieldcat-coltext.
append lw_fieldcat to lt_fieldcat.
call method cl_alv_table_create=>create_dynamic_table
exporting
it_fieldcatalog = lt_fieldcat
importing
ep_table = lt_dyn_table
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 lt_dyn_table->* to <fs_context>.
call method lo_nd_projects->get_static_attributes_table
importing
table = <fs_context>.
loop at r_param->t_modified_cells into wa_param.
*Loop at changed entries and modify them in the dynamic internal table
read table <fs_context> index wa_param-index into <fs_context2>.
assign component wa_param-attribute of structure <fs_context2> to <fs_variable>.
assign wa_param-r_value->* to <fs_variable2>.
move <fs_variable2> to <fs_variable>.
Using Dynamic ALV with Web Dynpro ABAP with Editable Fields
Endloop.
lo_nd_projects = wd_context->get_child_node( name = u2018NEW_NODEu2019 ).
lo_el_projects = lo_nd_projects->get_element( ).
lo_nd_projects->bind_table( <fs_context> ). -
Is it possible to pass a field symbol as parameter from any method of view?
Hi
Is it possible to pass a field symbol as an importing parameter to teh globally declared attribute??While it is true that you can pass field symbols, they must be fully typed at the time you pass them and they will be passed by value, not by reference. If you want to pass generically typed variables use a data reference (TYPE REF TO) instead.
-
How to use field symbol in select
Hi,
CONCATENATE 'WTG0' LV_MON INTO LV_FNAME.
ASSIGN (LV_FNAME) TO <FS>.
SELECT SINGLE <FS> FROM COSP INTO LV_SAPRST
WHERE OBJNR = LV_OBJ AND GJAHR = LV_YEAR AND WRTTP = '4' AND KSTAR = GT_INOUT-SAKNR
Error message : Unknown column name "<FS>" . field list. . field list. field list.
actually , if i use if command, i can do, but i want to use simple code by fieldsymbol.
is it possible in select command?
Thanks in advance
BenjaminHi
Hope it will help you.
reward if help.
Field Symbols
Field symbols are placeholders or symbolic names for other fields. They do not physically reserve space for a field, but point to its contents. A field symbol cam point to any data object. The data object to which a field symbol points is assigned to it after it has been declared in the program.
Whenever you address a field symbol in a program, you are addressing the field that is assigned to the field symbol. After successful assignment, there is no difference in ABAP whether you reference the field symbol or the field itself. You must assign a field to each field symbol before you can address the latter in programs.
Field symbols are similar to dereferenced pointers in C (that is, pointers to which the content operator * is applied). However, the only real equivalent of pointers in ABAP, that is, variables that contain a memory address (reference) and that can be used without the contents operator, are reference variables in ABAP Objects.
All operations programmed with field symbols are applied to the field assigned to it. For example, a MOVE statement between two field symbols moves the contents of the field assigned to the first field symbol to the field assigned to the second field symbol. The field symbols themselves point to the same fields after the MOVE statement as they did before.
You can create field symbols either without or with type specifications. If you do not specify a type, the field symbol inherits all of the technical attributes of the field assigned to it. If you do specify a type, the system checks the compatibility of the field symbol and the field you are assigning to it during the ASSIGN statement.
Field symbols provide greater flexibility when you address data objects:
If you want to process sections of fields, you can specify the offset and length of the field dynamically.
You can assign one field symbol to another, which allows you to address parts of fields.
Assignments to field symbols may extend beyond field boundaries. This allows you to address regular sequences of fields in memory efficiently.
You can also force a field symbol to take different technical attributes from those of the field assigned to it.
The flexibility of field symbols provides elegant solutions to certain problems. On the other hand, it does mean that errors can easily occur. Since fields are not assigned to field symbols until runtime, the effectiveness of syntax and security checks is very limited for operations involving field symbols. This can lead to runtime errors or incorrect data assignments.
While runtime errors indicate an obvious problem, incorrect data assignments are dangerous because they can be very difficult to detect. For this reason, you should only use field symbols if you cannot achieve the same result using other ABAP statements.
For example, you may want to process part of a string where the offset and length depend on the contents of the field. You could use field symbols in this case. However, since the MOVE statement also supports variable offset and length specifications, you should use it instead. The MOVE statement (with your own auxiliary variables if required) is much safer than using field symbols, since it cannot address memory beyond the boundary of a field. However, field symbols may improve performance in some cases.
check the below links u will get the answers for your questions
http://help.sap.com/saphelp_nw04/helpdata/en/fc/eb3860358411d1829f0000e829fbfe/content.htm
http://www.sts.tu-harburg.de/teaching/sap_r3/ABAP4/field_sy.htm
http://searchsap.techtarget.com/tip/1,289483,sid21_gci920484,00.html
Syntax Diagram
FIELD-SYMBOLS
Basic form
FIELD-SYMBOLS <fs>.
Extras:
1. ... TYPE type
2. ... TYPE REF TO cif
3. ... TYPE REF TO DATA
4. ... TYPE LINE OF type
5. ... LIKE s
6. ... LIKE LINE OF s
7. ... TYPE tabkind
8. ... STRUCTURE s DEFAULT wa
The syntax check performed in an ABAP Objects context is stricter than in other ABAP areas. See Cannot Use Untyped Field Symbols ad Cannot Use Field Symbols as Components of Classes.
Effect
This statement declares a symbolic field called <fs>. At runtime, you can assign a concrete field to the field symbol using ASSIGN. All operations performed with the field symbol then directly affect the field assigned to it.
You can only use one of the additions.
Example
Output aircraft type from the table SFLIGHT using a field symbol:
FIELD-SYMBOLS <PT> TYPE ANY.
DATA SFLIGHT_WA TYPE SFLIGHT.
ASSIGN SFLIGHT_WA-PLANETYPE TO <PT>.
WRITE <PT>.
Addition 1
... TYPE type
Addition 2
... TYPE REF TO cif
Addition 3
... TYPE REF TO DATA
Addition 4
... TYPE LINE OF type
Addition 5
... LIKE s
Addition 6
... LIKE LINE OF s
Addition 7
... TYPE tabkind
Effect
You can define the type of the field symbol using additions 2 to 7 (just as you can for FORM parameters (compare Defining the Type of Subroutine Parameters). When you use the ASSIGN statement, the system carries out the same type checks as for USING parameters of FORMs.
This addition is not allowed in an ABAP Objects context. See Cannot Use Obsolete Casting for FIELD SYMBOLS.
In some cases, the syntax rules that apply to Unicode programs are different than those for non-Unicode programs. See Defining Types Using STRUCTURE.
Effect
Assigns any (internal) field string or structure to the field symbol from the ABAP Dictionary (s). All fields of the structure can be addressed by name: <fs>-fieldname. The structured field symbol points initially to the work area wa specified after DEFAULT.
The work area wa must be at least as long as the structure s. If s contains fields of the type I or F, wa should have the structure s or at least begin in that way, since otherwise alignment problems may occur.
Example
Address components of the flight bookings table SBOOK using a field symbol:
DATA SBOOK_WA LIKE SBOOK.
FIELD-SYMBOLS <SB> STRUCTURE SBOOK
DEFAULT SBOOK_WA.
WRITE: <SB>-BOOKID, <SB>-FLDATE.
Related
ASSIGN, DATA
Additional help
Declaring Field Symbols -
How to use field symbols in program
how to use field symbols can any one explain with example please..
Regards,
venki...Hi
Field Symbols
Field symbols are placeholders or symbolic names for other fields. They do not physically reserve space for a field, but point to its contents. A field symbol cam point to any data object. The data object to which a field symbol points is assigned to it after it has been declared in the program.
Whenever you address a field symbol in a program, you are addressing the field that is assigned to the field symbol. After successful assignment, there is no difference in ABAP whether you reference the field symbol or the field itself. You must assign a field to each field symbol before you can address the latter in programs.
Field symbols are similar to dereferenced pointers in C (that is, pointers to which the content operator * is applied). However, the only real equivalent of pointers in ABAP, that is, variables that contain a memory address (reference) and that can be used without the contents operator, are reference variables in ABAP Objects.
All operations programmed with field symbols are applied to the field assigned to it. For example, a MOVE statement between two field symbols moves the contents of the field assigned to the first field symbol to the field assigned to the second field symbol. The field symbols themselves point to the same fields after the MOVE statement as they did before.
You can create field symbols either without or with type specifications. If you do not specify a type, the field symbol inherits all of the technical attributes of the field assigned to it. If you do specify a type, the system checks the compatibility of the field symbol and the field you are assigning to it during the ASSIGN statement.
Field symbols provide greater flexibility when you address data objects:
If you want to process sections of fields, you can specify the offset and length of the field dynamically.
You can assign one field symbol to another, which allows you to address parts of fields.
Assignments to field symbols may extend beyond field boundaries. This allows you to address regular sequences of fields in memory efficiently.
You can also force a field symbol to take different technical attributes from those of the field assigned to it.
The flexibility of field symbols provides elegant solutions to certain problems. On the other hand, it does mean that errors can easily occur. Since fields are not assigned to field symbols until runtime, the effectiveness of syntax and security checks is very limited for operations involving field symbols. This can lead to runtime errors or incorrect data assignments.
While runtime errors indicate an obvious problem, incorrect data assignments are dangerous because they can be very difficult to detect. For this reason, you should only use field symbols if you cannot achieve the same result using other ABAP statements.
For example, you may want to process part of a string where the offset and length depend on the contents of the field. You could use field symbols in this case. However, since the MOVE statement also supports variable offset and length specifications, you should use it instead. The MOVE statement (with your own auxiliary variables if required) is much safer than using field symbols, since it cannot address memory beyond the boundary of a field. However, field symbols may improve performance in some cases.
check the below links u will get the answers for your questions
http://help.sap.com/saphelp_nw04/helpdata/en/fc/eb3860358411d1829f0000e829fbfe/content.htm
http://www.sts.tu-harburg.de/teaching/sap_r3/ABAP4/field_sy.htm
http://searchsap.techtarget.com/tip/1,289483,sid21_gci920484,00.html
Syntax Diagram
FIELD-SYMBOLS
Basic form
FIELD-SYMBOLS <fs>.
Extras:
1. ... TYPE type
2. ... TYPE REF TO cif
3. ... TYPE REF TO DATA
4. ... TYPE LINE OF type
5. ... LIKE s
6. ... LIKE LINE OF s
7. ... TYPE tabkind
8. ... STRUCTURE s DEFAULT wa
The syntax check performed in an ABAP Objects context is stricter than in other ABAP areas. See Cannot Use Untyped Field Symbols ad Cannot Use Field Symbols as Components of Classes.
Effect
This statement declares a symbolic field called <fs>. At runtime, you can assign a concrete field to the field symbol using ASSIGN. All operations performed with the field symbol then directly affect the field assigned to it.
You can only use one of the additions.
Example
Output aircraft type from the table SFLIGHT using a field symbol:
FIELD-SYMBOLS <PT> TYPE ANY.
DATA SFLIGHT_WA TYPE SFLIGHT.
ASSIGN SFLIGHT_WA-PLANETYPE TO <PT>.
WRITE <PT>.
Addition 1
... TYPE type
Addition 2
... TYPE REF TO cif
Addition 3
... TYPE REF TO DATA
Addition 4
... TYPE LINE OF type
Addition 5
... LIKE s
Addition 6
... LIKE LINE OF s
Addition 7
... TYPE tabkind
Effect
You can define the type of the field symbol using additions 2 to 7 (just as you can for FORM parameters (compare Defining the Type of Subroutine Parameters). When you use the ASSIGN statement, the system carries out the same type checks as for USING parameters of FORMs.
This addition is not allowed in an ABAP Objects context. See Cannot Use Obsolete Casting for FIELD SYMBOLS.
In some cases, the syntax rules that apply to Unicode programs are different than those for non-Unicode programs. See Defining Types Using STRUCTURE.
Effect
Assigns any (internal) field string or structure to the field symbol from the ABAP Dictionary (s). All fields of the structure can be addressed by name: <fs>-fieldname. The structured field symbol points initially to the work area wa specified after DEFAULT.
The work area wa must be at least as long as the structure s. If s contains fields of the type I or F, wa should have the structure s or at least begin in that way, since otherwise alignment problems may occur.
Example
Address components of the flight bookings table SBOOK using a field symbol:
DATA SBOOK_WA LIKE SBOOK.
FIELD-SYMBOLS <SB> STRUCTURE SBOOK
DEFAULT SBOOK_WA.
WRITE: <SB>-BOOKID, <SB>-FLDATE.
<b>Reward points for useful Answers</b>
Regards
Anji -
Hi,
Can any one give me clear idea of field symbols and their use in the programing?
i read some help docs but could not get it what exactly it means
Thanks,
RaviHi
Field Symbols
Field symbols are placeholders or symbolic names for other fields. They do not physically reserve space for a field, but point to its contents. A field symbol cam point to any data object. The data object to which a field symbol points is assigned to it after it has been declared in the program.
Whenever you address a field symbol in a program, you are addressing the field that is assigned to the field symbol. After successful assignment, there is no difference in ABAP whether you reference the field symbol or the field itself. You must assign a field to each field symbol before you can address the latter in programs.
Field symbols are similar to dereferenced pointers in C (that is, pointers to which the content operator * is applied). However, the only real equivalent of pointers in ABAP, that is, variables that contain a memory address (reference) and that can be used without the contents operator, are reference variables in ABAP Objects.
All operations programmed with field symbols are applied to the field assigned to it. For example, a MOVE statement between two field symbols moves the contents of the field assigned to the first field symbol to the field assigned to the second field symbol. The field symbols themselves point to the same fields after the MOVE statement as they did before.
You can create field symbols either without or with type specifications. If you do not specify a type, the field symbol inherits all of the technical attributes of the field assigned to it. If you do specify a type, the system checks the compatibility of the field symbol and the field you are assigning to it during the ASSIGN statement.
Field symbols provide greater flexibility when you address data objects:
If you want to process sections of fields, you can specify the offset and length of the field dynamically.
You can assign one field symbol to another, which allows you to address parts of fields.
Assignments to field symbols may extend beyond field boundaries. This allows you to address regular sequences of fields in memory efficiently.
You can also force a field symbol to take different technical attributes from those of the field assigned to it.
The flexibility of field symbols provides elegant solutions to certain problems. On the other hand, it does mean that errors can easily occur. Since fields are not assigned to field symbols until runtime, the effectiveness of syntax and security checks is very limited for operations involving field symbols. This can lead to runtime errors or incorrect data assignments.
While runtime errors indicate an obvious problem, incorrect data assignments are dangerous because they can be very difficult to detect. For this reason, you should only use field symbols if you cannot achieve the same result using other ABAP statements.
For example, you may want to process part of a string where the offset and length depend on the contents of the field. You could use field symbols in this case. However, since the MOVE statement also supports variable offset and length specifications, you should use it instead. The MOVE statement (with your own auxiliary variables if required) is much safer than using field symbols, since it cannot address memory beyond the boundary of a field. However, field symbols may improve performance in some cases.
check the below links u will get the answers for your questions
http://help.sap.com/saphelp_nw04/helpdata/en/fc/eb3860358411d1829f0000e829fbfe/content.htm
http://www.sts.tu-harburg.de/teaching/sap_r3/ABAP4/field_sy.htm
http://searchsap.techtarget.com/tip/1,289483,sid21_gci920484,00.html
Syntax Diagram
FIELD-SYMBOLS
Basic form
FIELD-SYMBOLS <fs>.
Extras:
1. ... TYPE type
2. ... TYPE REF TO cif
3. ... TYPE REF TO DATA
4. ... TYPE LINE OF type
5. ... LIKE s
6. ... LIKE LINE OF s
7. ... TYPE tabkind
8. ... STRUCTURE s DEFAULT wa
The syntax check performed in an ABAP Objects context is stricter than in other ABAP areas. See Cannot Use Untyped Field Symbols ad Cannot Use Field Symbols as Components of Classes.
Effect
This statement declares a symbolic field called <fs>. At runtime, you can assign a concrete field to the field symbol using ASSIGN. All operations performed with the field symbol then directly affect the field assigned to it.
You can only use one of the additions.
Example
Output aircraft type from the table SFLIGHT using a field symbol:
FIELD-SYMBOLS <PT> TYPE ANY.
DATA SFLIGHT_WA TYPE SFLIGHT.
ASSIGN SFLIGHT_WA-PLANETYPE TO <PT>.
WRITE <PT>.
Addition 1
... TYPE type
Addition 2
... TYPE REF TO cif
Addition 3
... TYPE REF TO DATA
Addition 4
... TYPE LINE OF type
Addition 5
... LIKE s
Addition 6
... LIKE LINE OF s
Addition 7
... TYPE tabkind
Effect
You can define the type of the field symbol using additions 2 to 7 (just as you can for FORM parameters (compare Defining the Type of Subroutine Parameters). When you use the ASSIGN statement, the system carries out the same type checks as for USING parameters of FORMs.
This addition is not allowed in an ABAP Objects context. See Cannot Use Obsolete Casting for FIELD SYMBOLS.
In some cases, the syntax rules that apply to Unicode programs are different than those for non-Unicode programs. See Defining Types Using STRUCTURE.
Effect
Assigns any (internal) field string or structure to the field symbol from the ABAP Dictionary (s). All fields of the structure can be addressed by name: <fs>-fieldname. The structured field symbol points initially to the work area wa specified after DEFAULT.
The work area wa must be at least as long as the structure s. If s contains fields of the type I or F, wa should have the structure s or at least begin in that way, since otherwise alignment problems may occur.
Example
Address components of the flight bookings table SBOOK using a field symbol:
DATA SBOOK_WA LIKE SBOOK.
FIELD-SYMBOLS <SB> STRUCTURE SBOOK
DEFAULT SBOOK_WA.
WRITE: <SB>-BOOKID, <SB>-FLDATE.
Regards
Anji
Maybe you are looking for
-
After upgrading to Lion can't get Boot Camp to work! Just get "The startup disk cannot be partitioned or restored to a single partition". Anytone?
-
Sharepoint 2010: prevent users from editing a list in the datasheet view
Hi, I have a sharepoint 2010 list that I need to prevent users to edit from the datasheet view. This is because I have edited the add item form on sharepoint designer and included some custom code. Moreover, I need to allow the users to view the list
-
Organizing Photos in a Slideshow
I am organizing photos by date within a large slide show that I am setting up in iPhoto 9. When I decide to add another photo it of course goes to the end of the slide show. How do I get each new photo up into the slide show where I want it without h
-
How to print full page rather than partial
Since my daughter used my computer to make and print labels, I can no longer print a full size page. When clicking on print the screen content contents shift left and The printer prints as shown on the shifted image. What do I do?
-
Data Passed into CT_DATA and written back successfully but not reflecting in cube
Hi, While executing through UJKT the log show data are written back successfully but those data's are not reflecting in cube. the sample log file is attached. Kindly help me to resolve this issue why new material with signdata 0 is not updating in cu