Problem in accessing field symbols passed as parameters to subroutine
Hi,
I have different internal tables/structures,i am populating those tables dynamically using field symbols. If i put that logic in perform, i am getting error while accessing the field symbol insdie the form.
For ex: My code looks like below.
tab1 is my int table, fs1 is my work area,
declared <fs1> as
data: <fs1> type fs1. <fs1> is my structure type.
perform populate tables tab1
using <fs1>
fs1.
form populate tables p_tab
using p_fs
p_wa.
assign p_wa to p_fs.
endform.
i am getting the error in the assign stmt
logic without form...endform is
assign fs1 to <fs1>
logic was working fine wihtout perform.
Regards,
sowjanya
Hi Sowjanya,
Try this one, Hope it will solve your issue
REPORT ztest_fs_create.
DATA: gt_final TYPE STANDARD TABLE OF pernr_d,
wa_final TYPE pernr_d.
NODES pernr.
TABLES pa0001.
FIELD-SYMBOLS: <tab> TYPE pernr-pernr.
GET pernr.
ASSIGN pernr-pernr TO <tab>.
PERFORM get_pernr USING <tab>.
END-OF-SELECTION.
LOOP AT gt_final INTO wa_final.
WRITE:/1 wa_final.
ENDLOOP.
*& Form gt_pernr
text
-->P_TAB text
FORM get_pernr USING p_tab TYPE any.
APPEND p_tab TO gt_final.
ENDFORM. "gt_pernr
Cheers
Pavan
Similar Messages
-
Problem in assigning field symbol to a nested internal table
Hi All,
I have searched the forum but could not find a solution to this problem. I have a requirement where I need to define an internal table within an internal table, so I have used pointer within the outer internal table(itab2) which point to the inner table. However, I am facing problem while assigning the pointer.
data: begin of struct1 occurs 0,
fld3(10) type C,
end of struct1.
data: begin of itab2 occurs 0,
fld1(10) type C,
fld2(10) type C,
p_inner like ref to struct1,
end of itab2.
field-symbols <inner_table> type any.
I want to assign "itab2->p_inner->* " to "<inner_table>".
However, the following statement is Not working:
assign itab2->p_inner->* to <inner_table>.
I want to fill the values within fields fld1, fld2 and fld3 and append it in itab2.
The final table should be like:
ITAB2:
fld1 fld2 fld3
aa bb cc
dd
ee
11 22 33
44
55
I have tried many other ways too but could not suceed, please help.
Thanks,
Vishal.Thanks Matt,
But how do I append the values within this internal table ??
When I am using the following code:
ls_wa-fld3 = 'A'.
ls_wa-t_in-fld1 = 'B'.
ls_wa-t_in-fld2 = 'C'.
ls_wa-t_in-fld1 = 'D'.
ls_wa-t_in-fld2 = 'E'.
append ls_wa to lt_tab.
Its giving an error that:
The data object "LS_WA" does not have a component called "T_IN-FLD1".
I wanted the values to be appended in the following way in lt_tab:
fld3 fld1 fld2
A B C
D E
Please help. -
Problem with slis_t_specialcol_alv Field Symbol Assignment
I have created a dynamic internal table (runtime determined number of columns) to contain data to be displayed in an ALV. Ive also made ensured that the last column of the dynamic itab is of type <b>'slis_t_specialcol_alv'</b> and named <b>CINFO</b> to contain color information for that particular row. In the code below the dynamic itab is pointed to by field symbol <dyn_table> while the work area for it would be <dyn_wa>.
Somewhere down the line I attempt to assign the CINFO component of the current row of the itab to a field symbol called <fs_cinfo> typed as slist_t_specialcol_alv (Same as CINFO).
I used the code:
ASSIGN COMPONENT 'CINFO' OF STRUCTURE <dyn_wa> TO <fs_cinfo>.
This gives me the runtime error:
<i>Type conflict in the ASSIGN statement in the program "ZHRR001_TEMMATRIX".
You attempted to assign a field to a typed field symbol,
but the field does not have the required type. </i>
I am unsure why this happens as both the component CINFO and FS <fs_cinfo> are of type slist_t_specialcol_alv.
For some odd reason though during debugging, I took a look at the <dyn_wa> structure and the component type of CINFO was displayed as C???
Here is the relevant portion of code (creation of dynamic itab and attempting to assign <fs_cinfo>)
FIELD-SYMBOLS: <dyn_table> TYPE STANDARD TABLE,
<dyn_wa>.
FIELD-SYMBOLS: <fs_cinfo> TYPE slist_t_specialcol_alv.
DATA: lw_cinfo TYPE slis_specialcol_alv.
DATA: li_fldcat TYPE lvc_t_fcat,
lw_fldcat TYPE lvc_s_fcat.
*Create internal table fields (they will be called Field1, Field2, etc)
*Last column will be named 'CINFO' to contain row color information
DO l_alvcolumncount TIMES.
index = sy-index.
IF index <> l_alvcolumncount.
CLEAR lw_fldcat.
CONCATENATE 'Field' index INTO lw_fldcat-fieldname .
CONDENSE lw_fldcat-fieldname NO-GAPS.
lw_fldcat-datatype = 'STRING'.
* lw_fldcat-intlen = 5.
APPEND lw_fldcat TO li_fldcat .
ELSE.
CLEAR lw_fldcat.
lw_fldcat-fieldname = 'CINFO'.
CONDENSE lw_fldcat-fieldname NO-GAPS.
lw_fldcat-datatype = 'slis_t_specialcol_alv'.
APPEND lw_fldcat TO li_fldcat.
ENDIF.
ENDDO.
* Create dynamic internal table and assign to FS
CALL METHOD cl_alv_table_create=>create_dynamic_table
EXPORTING
it_fieldcatalog = li_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>.
ASSIGN COMPONENT 'CINFO' OF STRUCTURE <dyn_wa> TO <fs_cinfo>.
* Color this cell
lw_cinfo-fieldname = fieldname.
lw_cinfo-color-col = 6.
APPEND lw_cinfo TO <fs_cinfo>.
Message was edited by: Sow Yong WongHello Sow
There is a big problem in the program: you are mixing types used for FM-based ALV (SLIS_...) and ABAP-OO based ALV (LVC_...).
For ABAP-OO based row colouring you have to define your itab like this:
TYPES: ty_s_outtab.
INCLUDE TYPE kna1. " just an example
TYPES: rowcolor(4) TYPE c.
TYPES: END OF ty_s_outtab.
TYPES: ty_t_outtab TYPE STANDARD TABLE of ty_s_outtab
WITH DEFAULT KEY.
In the layout (LVC_S_LAYO) you have to set <b>ls_layout-info_fname = 'ROWCOLOR'</b>.
ROWCOLOR has to be filled according to <b>Cxyz</b> whereas
- x = color
- y = inverse on/off
- z = intensified on/off
For documentation please refer to <a href="https://www.sdn.sap.comhttp://www.sdn.sap.comhttp://www.sdn.sap.com/irj/servlet/prt/portal/prtroot/docs/library/uuid/e8a1d690-0201-0010-b7ad-d9719a415907">An Easy Reference to ALV Grid Control</a>
Regards
Uwe -
Problem related to field-Symbol?
HI All,
I am writting the below coding, Please tell me whether the Field Symbol will act as a table or not as I want to append a lot of data to field symbol. Please tell me is there any problem in the code.
LOOP AT lt_vepoequi_keys into ls_vepoequi_keys.
READ TABLE lt_vekp ASSIGNING <ls_vekp_str> with key
matnr = ls_vepoequi_keys-matnr.
IF sy-subrc = 0.
<ls_vekp_str>-stoff = ls_vepoequi_keys-stoff.
<ls_vekp_str>-sonum = ls_vepoequi_keys-sonum.
<ls_vekp_str>-lagkl = ls_vepoequi_keys-lagkl.
<ls_vekp_str>-lagkt = ls_vepoequi_keys-lagkt.
endif.
endloop.Hi Abhinav,
you have internal table (say it_employee) with fields name,age,senior_category.
now when you loop this internal table you will need workarea.
loop at it_employee into wa_employee.
if wa_employee-age > 60.
wa_employee-senior_category = 'YES'.
else.
wa_employee-senior_category = 'NO'.
endif.
modify it_employee from wa_employee.
endloop.
now one use of Field-symbols is : when internal table is huge and when you loop with workarea and modify internal table each time, it takes time. So if we use Field-symbols performance would increase.
loop at it_employee assigning into <fs_employee>.
if <fs_employee>-age > 60.
<fs_employee>-senior_category = 'YES'.
else.
<fs_employee>-senior_category = 'NO'.
endif.
endloop.
Now you see in the above code, i have not used modify statement because when i loop internal table, the field symbol points directly to the memory of internal table.
So during loop if i assign any value to the field symbol then it directly changes the internal table value, so there wont be any need to use modify statement.
Hope you are clear with this example....
Regards
Sajid -
Problem after assigning field-symbol in read statement...
Hello Experts,
I want to use a universal field-symbol in reading my internal tables so
I can avoid declaring multiple work areas. Here is my code:
FIELD-SYMBOLS: <fs_any> type any.
READ TABLE lt_orderadm_h INDEX 1 ASSIGNING <fs_any>.
Now when I try to insert this code:
IF NOT <fs_any>-object_id IS INITIAL.
ENDIF.
It says that <fs_any> has no structure and therefore no component called object_id.
I think that I need to use assign component for this but I don't know the code.
Thank you guys and take care!Hi
DATA : WA_ITORDERADM_H LIKE LINE OF IT_ORDERADM_H.
**Try to assign the work area rather type any**
FIELD-SYMBOLS: <fs_any> type WA_ITORDERADM_H.
READ TABLE lt_orderadm_h INDEX 1 ASSIGNING <fs_any>.
Now when I try to insert this code:
IF NOT <fs_any>-object_id IS INITIAL.
ENDIF.
Check this program
This works for me
Simple program.
TYPES: BEGIN OF NAME,
NEXTNAME(10),
FIRSTNAME(10),
LASTNAME(10),
END OF NAME.
FIELD-SYMBOLS <F> TYPE NAME.
DATA: LINE(30).
LINE = 'JOHN SMITH SHRI'.
ASSIGN LINE TO <F> CASTING.
WRITE: / 'Lastname:', <F>-LASTNAME,
'Firstname:', <F>-FIRSTNAME,
'Nextname :', <F>-NEXTNAME
Award points if helpful
Thanks
VENKI -
Problem in using Field Symbols in HIDE statement
Hi All,
I am working in an Upgrade project ( from 4.6B to ECC 5.0 ). In a program I found few warnings on HIDE statement because they have used Field Symbols in HIDE statement.
The warning is " HIDE on a field symbol is dangerous, but the formal parameter "" is not ".
and the piece of code is
SET EXTENDED CHECK OFF.
HIDE: flg_pick_up, <s1>, <s2>, <s3>, <s4>, <s5>, z_feld_ind.
CLEAR flg_pick_up.
SET EXTENDED CHECK ON.
all the field symbols are of type ANY. SO can any one help in removing those warnings.
Please reply me as soon as possible.
With Regards,
Amarnath SinganamalaHi amarnath,
1. Why do u want to remove
the warning ?
2. This warning (and not an error)
is a GENUINE warning,
which the system wants the user to make aware of.
3. By doing some xyz,
even if u may be able to hide the warning,
the warning may be hidden (for display purpose only),
but,
the warning will still be there inside the system.
4. I think u should ignore the warning,
(if there are no other repurcussions).
regards,
amit m. -
Problem with DESCRIBE field-symbol statement?
Hi
I havw written following querry but it's showing error. My doubt is there any resctriction field symbols in DESCRIBE query.
i wrote
describe field <a> type typ length in character mode.
Is that syntax correct?When you use the Describe statement with the field symbols, it will do the describe on the field which was assigned to it.
Like:
FIELD-SYMBOLS: <fs> TYPE ANY.
DATA: l_char TYPE char10.
l_char = 'TEST'.
ASSIGN l_char TO <fs>.
DATA: l_len TYPE i.
DESCRIBE FIELD <fs> LENGTH l_len IN CHARACTER MODE.
write: / '<fs>:', <fs>.
WRITE: / 'Length', l_len.
Here descirbe gives the property of the L_CHAR because it was assigned to field symbol <FS>.
Regards,
Naimesh Patel -
Problem with the field-symbols
Hi all,
i am unable to delete the data in the internal table.
i am sending the code.
BEGIN OF t_oprtn,
budat LIKE afru-budat,
vornr LIKE afru-vornr,
grund LIKE afru-grund,
gmein LIKE afru-gmein,
gmnga LIKE afru-gmnga,
expfl(1),
END OF t_oprtn,
FIELD-SYMBOLS: <fs_collect> TYPE STANDARD TABLE.
FIELD-SYMBOLS: <fs_wa_collect> TYPE ANY.
CREATE DATA i_collect TYPE STANDARD TABLE OF t_oprtn
WITH DEFAULT KEY.
CREATE DATA wa_collect TYPE t_oprtn.
ASSIGN i_collect->* TO <fs_collect>.
ASSIGN wa_collect->* TO <fs_wa_collect>.
SELECT abudat avornr agrund aarbid astokz darbpl a~aufnr
bplnbez cmaktx agmnga agmein
INTO TABLE i_final
FROM afru AS a INNER JOIN afko AS b
ON aaufnr = baufnr
INNER JOIN makt AS c
ON bplnbez = cmatnr
INNER JOIN crhd AS d
ON aarbid = dobjid
WHERE a~budat IN s_budat
LOOP AT i_final INTO wa_final.
MOVE-CORRESPONDING wa_final TO <fs_wa_collect>.
COLLECT <fs_wa_collect> INTO <fs_collect>.
ENDLOOP
how to write a delete statement for - <fs_collect>.
Plz tell me the delete statement where GMNGA is '0'. " GMNGA IS A CONFIRM QUANTITY.
Plz reply its urgent.
Edited by: hari prasad on May 30, 2008 1:15 PM
Edited by: hari prasad on May 30, 2008 1:20 PMTry:
field-symbols: <f_temp> type any.
loop at <fs_collect> assigning <fs_wa_collect>.
assign component 'GMNGA' of structure <fs_wa_collect> to <f_temp>.
if <f_temp> is initial.
delete <fs_collect>.
endif.
endloop.
regards,
S. Chandramouli.
Edited by: Chandramouli Subburathinam on May 30, 2008 5:08 PM -
Problem with FIELD SYMBOL upgrading from 46c to ECC6.0
Hi people... i'm having big trouble making an upgrade from 4.6c to ECC6.0 with this portion of code of Z's programm.
In the line
ASSIGN (w_field) TO <fs_field>.
i don't see any assigment, so <fs_field> remains empty, when enters into firts IF conditions it is TRUE, then go into second IF condition, it is FALSE, and finally assing
<fs_field> = '/'.
, at this point i have a DUMP telling me MOVE_TO_LIT_NOTALLOWED_NODATA
I'm try any way of definition, assigment, but always i have a DUMP.
Someone can give a hand with this issue!
Thanks in advance!!!
This is the full code from the FORM with the problem.
* FORM GRABA *
* --> VALUE(P_TABLE) *
FORM graba USING value(p_table) TYPE c.
DATA:
w_field(60),
w_dd03l TYPE dd03l.
FIELD-SYMBOLS <fs_field>.
CLEAR w_flag.
CASE p_table.
WHEN 'BGR00'.
d_bgr00-group = w_batin.
d_bgr00-mandt = sy-mandt.
d_bgr00-usnam = sy-uname.
d_bgr00-xkeep = 'X'.
d_bgr00-nodata = '/'.
d_bgr00-stype = 0.
TRANSFER d_bgr00 TO w_fname.
WHEN 'BBKPF'.
LOOP AT gt_dd03l INTO w_dd03l WHERE tabname EQ p_table.
CONCATENATE
'd_'
w_dd03l-tabname
w_dd03l-fieldname
INTO w_field.
ASSIGN (w_field) TO <fs_field>.
IF <fs_field> IS INITIAL OR <fs_field> EQ '/'.
IF w_dd03l-fieldname EQ 'TBNAM'.
<fs_field> = p_table.
ELSE.
<fs_field> = '/'.
ENDIF.
ELSE.
w_flag = 'X'.
ENDIF.
ENDLOOP.
TRANSFER d_bbkpf TO w_fname.
WHEN 'BBSEG'.
LOOP AT gt_dd03l INTO w_dd03l WHERE tabname EQ p_table.
CONCATENATE
'd_'
w_dd03l-tabname
w_dd03l-fieldname
INTO w_field.
ASSIGN (w_field) TO <fs_field>.
IF <fs_field> IS INITIAL OR <fs_field> EQ '/'.
IF w_dd03l-fieldname EQ 'TBNAM'.
<fs_field> = p_table.
ELSE.
<fs_field> = '/'.
ENDIF.
ELSE.
w_flag = 'X'.
ENDIF.
ENDLOOP.
TRANSFER d_bbseg TO w_fname.
ENDCASE.
ENDFORM.
Edited by: Matt on Dec 15, 2008 5:03 PM - Made subject more informativeGentlemen:
The problem around this statement:
ASSIGN (w_field) TO <fs_field>
is explained as follows:
1. In ABAP language, there are two ways for assigning a new value to a field-symbol.
- Sentence: ASSIGN (values) TO <my_field_symbol>.
In this case, the <my_field_symbol> receives from (w_field) the data type and value content of this variable. So, we keep that a FSymbol is assigned and, at the same time, receives an initial value.
- Sentence: <my_field_symbol> = '/' or <my_field_symbol> = my_var.
In this way, we only pass the content of the variable next to = sign. But before this, the field-symbol must had been assigned (using ASSIGN statement), in another case, the compiler raises an exception.
Following the example of Federico... I think he tried to assign a field like this (please, supose the program imports the structure of a database table with a standard function, into a internal table which is looped by the work area w_field ):
- If w_field contains 'BKPF-WERKS', so sentence ASSIGN will affect the field symbol, passing to this the data type and current content of table field BKPF-WERKS.
- If w_field contains 'BKPF-.INCLUDE': *the column .INCLUDE obviously is not associated with a data type... so our statement ASSIGN... TO... never pass any data type or value to our field-symbol. So that, this field is never initialized properly, and when inmmediately you try to execute something like this: <my_field_symbol> = '/', the game (program) is over.. XD
I hope this post was helpful for anyone...
Best Regards!!
RRG
ABAPer(u) - EVOLution -
Hi!
I have a problem with a field-symbol like this:
DATA: gt_coep_ext TYPE kaep_t_coep_ext.
field-symbols <gt_data> type table.
ASSIGN gt_coep_ext TO <gt_pos_data>
This field symbol is used in the FM REUSE_ALV_GRID_DISPLAY as output table. I need add two fields in this <gt_data>. Is there any way to add new fields in the <gt_data> structure.
Thanks!!Create your one Fieldcat
Global data declaration ***
TYPE-POOLS: SLIS.
<types: ... . " user definded types>
DATA: GT_FIELDCAT TYPE SLIS_T_FIELDCAT_ALV.
DATA: G_REPID LIKE SY-REPID.
DATA: GT_OUTTAB TYPE <UD_STRUCT> OCCURS 0 WITH HEADER LINE.
<data: ... . " user specific data>
Initialization field catalog ***
INITIALIZATION.
G_REPID = SY-REPID.
PERFORM FIELDCAT_INIT USING GT_FIELDCAT[].
Data selection ***
START-OF-SELECTION.
PERFORM SELECT_DATA TABLES GT_OUTTAB.
Display list ***
END-OF-SELECTION.
CALL FUNCTION 'REUSE_ALV_LIST_DISPLAY'
EXPORTING
I_CALLBACK_PROGRAM = G_REPID
IT_FIELDCAT = GT_FIELDCAT[]
TABLES
T_OUTTAB = GT_OUTTAB.
FORMS ***
FORM FIELDCAT_INIT USING RT_FIELDCAT TYPE SLIS_T_FIELDCAT_ALV.
DATA: LS_FIELDCAT TYPE SLIS_FIELDCAT_ALV.
DATA: POS TYPE I VALUE 1.
Initialize keyfield(s)
CLEAR LS_FIELDCAT.
LS_FIELDCAT-COL_POS = POS.
LS_FIELDCAT-FIELDNAME = <GT_OUTTAB_FIELD_NAME>.
LS_FIELDCAT-REF_FIELDNAME = <DDIC_REF_FIELD_NAME>.
LS_FIELDCAT-REF_TABNAME = <DDIC_REF_TABLE_NAME>.
LS_FIELDCAT-KEY = 'X'. " sets key field
APPEND LS_FIELDCAT TO RT_FIELDCAT.
Initialize normal field(s)
POS = POS + 1.
clear ls_fieldcat.
ls_fieldcat-col_pos = pos.
LS_FIELDCAT-FIELDNAME = <GT_OUTTAB_FIELD_NAME>.
LS_FIELDCAT-REF_FIELDNAME = <DDIC_REF_FIELD_NAME>.
LS_FIELDCAT-REF_TABNAME = <DDIC_REF_TABLE_NAME>.
APPEND LS_FIELDCAT TO RT_FIELDCAT.
Initialize hidden field(s)
POS = POS + 1.
clear ls_fieldcat.
ls_fieldcat-col_pos = pos.
LS_FIELDCAT-FIELDNAME = <GT_OUTTAB_FIELD_NAME>.
LS_FIELDCAT-REF_FIELDNAME = <DDIC_REF_FIELD_NAME>.
LS_FIELDCAT-REF_TABNAME = <DDIC_REF_TABLE_NAME>.
LS_FIELDCAT-NO_OUT = 'X'. " sets hidden field
APPEND LS_FIELDCAT TO RT_FIELDCAT.
ENDFORM. " fieldcat_init
FORM SELECT_DATA TABLES RT_OUTTAB LIKE GT_OUTTAB[].
<user specific data selection>
ENDFORM. " select_data -
Problem trying to create FIELD SYMBOLS in BADI.
Hi guys!
I'm trying to create a Field Symbol in method CHECK of BADI me_process_req_cust (well, I'm working on a Z implementation).
The problem is that I'm trying to create a FIELD SYMBOL and when I check the syntaxsis, I receive the next error:
Clase ZCL_IM_MM_PURREQ_UPDATE,Método IF_EX_ME_PROCESS_REQ_CUST~CHECK
Names may only consist of the characters "A-Z", "0-9" and "_". In
addition, they may not begin with a number.
This is the code:
FIELD-SYMBOLS: <sy-mereq> TYPE mereq3328-afnam.
Any idea????
Thanks in advance!
BetHi Silveria,
The problem lies in
FIELD-SYMBOLS: <sy-mereq> TYPE mereq3328-afnam.
instead of that it should be something like this
FIELD-SYMBOLS: <sy_mereq> TYPE mereq3328-afnam.
With your code you will be getting a syntax error saying sy-mereq is not defined,as it will be looking for the mereq in the system fields.
Regards
Abhinab Mishra -
How to pass field symbol or table from one view to another view in abap web dynpro?
I am creating an Inbound Outbound ALV report in ABAP Web Dynpro. However at selection-screen I have select options and fetching is done at view2. Problem is we can pass parameter using inbound outbound parameters but how to pass internal table or field-symbols from one view to another view? I made use of Assistance Class too but its not very clear to me. Please give me some example or code to sort this problem out.
I am creating an Inbound Outbound ALV report in ABAP Web Dynpro. However at selection-screen I have select options and fetching is done at view2. Problem is we can pass parameter using inbound outbound parameters but how to pass internal table or field-symbols from one view to another view? I made use of Assistance Class too but its not very clear to me. Please give me some example or code to sort this problem out.
-
How to access dynamic fields in a field symbol
hi
how do i access the dynamic fields created in side a field-symbol....
wht i mean is i have a table, whose workarea i assign to field symbol. but this table is runtime, altough i have debugged and found the values in this table, I want to accees the field symbol in a generic way.
say the table has 3 fields now fld1 fld2 and fld3 so i want to access the field symbol <fs> as <fs>-(name) where name can be anything fld1 or fld2 whichever i assign....
thanks. Let me know if you have any further questions.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 a field symbol before you can address it in a program.
Field symbols are similar to de-referenced pointers in the C programming language (that is, pointers to which the content operator * is applied). In ABAP, data references represent a real equivalent to pointers in the sense of variables that contain a memory address and can be used without the contents operator.
All operations programmed with field symbols are applied to the field assigned to it. A MOVE statement between two field symbols, for example, assigns the contents of the field assigned to another source field symbol to the field assigned to the target field symbol. The field symbols themselves point to the same fields after the MOVE statement as they did before the MOVEstatement.
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 during the field assignment whether the assigned field matches the type of field symbol.
Field symbols provide greater flexibility when you address data objects:
· You can assign one field symbol to another, which allows you to address subfields.
· 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 properties than those of the field assigned to it (casting).
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. 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.
To declare a field symbol, use the statement
FIELD-SYMBOLS .
For field symbols, the angle brackets are part of the syntax. They identify field symbols in the program code.
If you do not specify any additions, the field symbol.
in a static ASSIGN and:
ASSIGN (dobj) TO from the second loop pass onwards. -
Hi Friends,
In my FM, i want to pass field symbol back to my main program for further use. How can i achieve the same.
In my source code section of FM,
FIELD-SYMBOLS: <t_dyntable> TYPE STANDARD TABLE,
<fs_dyntable>,
<fs_fldval> TYPE ANY,
<fs_col1>,<fs_col2>.
DATA : t_newtable TYPE REF TO data,t_newline TYPE REF TO data,t_fldcat TYPE lvc_t_fcat.
CALL METHOD cl_alv_table_create=>create_dynamic_table
EXPORTING
it_fieldcatalog = t_fldcat
IMPORTING
ep_table = t_newtable
EXCEPTIONS
generate_subpool_dir_full = 1
OTHERS = 2.
ASSIGN t_newtable->* TO <t_dyntable>.
CREATE DATA t_newline LIKE LINE OF <t_dyntable>.
i want to pass <t_dyntable> back to my prg but i am not getting how to pass it and where to write it.
Please guide me.
Thanks and Regards,
GauravHi Naimesh,
Thanks for the reply.
Finally i understood what you guys wanted me to do.I did exactly the same but the problem remains the same.
when my control get back to subroutine it works fine, i mean upto
ASSIGN r_dyntab->* TO <t_dyntable>
,it works fine.But when the control gets over from FM and process the next statement
clear <t_dyntable>.
then the <t_dyntable> says it is not yet assigned. I want to access <t_dyntable> as main dynamic table for further process.
i have added code for your reference.
Thanks and Regards,
Gaurav
Report Zcallingprg.
DATA : t_newtable TYPE REF TO data,t_newline TYPE REF TO data,t_fldcat TYPE lvc_t_fcat.
DATA : wa_it_fldcat TYPE lvc_s_fcat,wa_colno(2) TYPE n,wa_flname(5) TYPE c,G_DISCONT.
data : num2(2).
DATA: rest TYPE i.
DATA: task(8) TYPE c value '1'.
FIELD-SYMBOLS: <t_dyntable> TYPE STANDARD TABLE,
<fs_dyntable>,
<fs_fldval> TYPE ANY,
<fs_col1>,<fs_col2>.
DO 100 TIMES.
rest = sy-index MOD 36.
IF rest = 0.
task = task + 1.
ENDIF.
CALL FUNCTION 'ZTEST_NEW_TASK' STARTING NEW TASK task
EXPORTING
num2 = 2.
ENDDO.
clear <t_dyntable>.
FORM get_dyn_tab CHANGING r_dyntab TYPE REF TO data.
ASSIGN r_dyntab->* TO <t_dyntable>.
ENDFORM.
code of FM
CALL METHOD cl_alv_table_create=>create_dynamic_table
EXPORTING
it_fieldcatalog = t_fldcat
IMPORTING
ep_table = r_newtab
EXCEPTIONS
generate_subpool_dir_full = 1
OTHERS = 2.
*ASSIGN r_newtab->* TO <t_dyntable>.
PERFORM get_dyn_tab(ztemp5) USING r_newtab. -
Passing Field Symbols in subroutines
Hi all,
Can any body tell me how to pass field symbols in a suboutine and will that effect orignal value of that symbl if i change it in subroutine.
Any Help will be awarded.
<b>Sachin</b>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
Maybe you are looking for
-
How to attach PDF file to product catalog in Internet Sales R/3
Hi Experts, We are implementing SAP E-Commerce (Internet Sales) for mySAP ERP or SAP R/3, release 5.0. I need to attach a PDF file to the product in the product catalog of the Web Shop. Some where in the documentation I have read that itu2019s possib
-
Yosemite time machine file restore problem
I'm trying to restore some files (iPhone backups) in OS X Yosemite, but am encountering a problem. I can locate the files I need in Time Machine. When I hit restore the 'Star Wars' UI exits as I would expect, and the 'preparing to copy files' dialogu
-
PHP and Actionsripting...
Hey fellow Flash friends... I have a flash banner that I have sitting on my gaming clans website I did. The forums are PHP and when ever anyones views a new topic or post of does anything to refresh the browser it reloads the movie and plays again. I
-
Changes in Retroactive account time date not possible error
Hi This employee is joined on date 20.01.1969 after that this employee prejoin on 09/04/2009 and we are trying to change the join date by using transaction code PA41. i am getting the below error message. 'Change in earliest retroactive accounting d
-
Help on how to treat the \' string ?
Hi, i have a string which i have to save it to a file. It happens that the string can contains \' (2 chars = \ and ' ) I save it to a file performing: try { FileOutputStream fos = new FileOutputStream(aFileName); Writer out = new OutputStreamWriter(f