on 04-28-2006 7:07 AM
hai every one,
can any one please tell how to use field symbols insted of work area,
pls sent a sample code.
gopan
HI
GOOD
CHECK OUT WITH FOLLOWING CODES
TYPES: BEGIN OF line,
col1 TYPE c,
col2 TYPE c,
END OF line.
DATA: wa TYPE line,
itab TYPE HASHED TABLE OF line WITH UNIQUE KEY col1,
key(4) TYPE c VALUE 'COL1'.
FIELD-SYMBOLS <fs> TYPE ANY TABLE.
ASSIGN itab TO <fs>.
READ TABLE <fs> WITH TABLE KEY (key) = 'X' INTO wa.
-
REPORT demo_field_symbols_type .
DATA: BEGIN OF line,
col1(1) TYPE c,
col2(1) TYPE c VALUE 'X',
END OF line.
FIELD-SYMBOLS <fs> LIKE line.
ASSIGN line TO <fs>.
MOVE <fs>-col2 TO <fs>-col1.
-
DATA: wa(10) VALUE '0123456789'.
DATA: BEGIN OF line1,
col1(3),
col2(2),
col3(5),
END OF line1.
DATA: BEGIN OF line2,
col1(2),
col2 LIKE sy-datum,
END OF line2.
FIELD-SYMBOLS: <f1> STRUCTURE line1 DEFAULT wa,
<f2> STRUCTURE line2 DEFAULT wa.
WRITE: / <f1>-col1, <f1>-col2, <f1>-col3,
/ <f2>-col1, <f2>-col2.
THANKS
MRUTYUN
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
field-symbols <th> type mara.
data it type table of mara.
loop at it assigning <th>.
*refer to <th>-matnr etc
endloop.
*or
read table it assigning <th> index 1.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi,
Please refer the code below.
Please mark helpful answer.
REPORT Z_AMIT_FIELD_SYMBOL_ITAB1 .
PARAMETERS : P_TAB1 TYPE C.
DATA: LT_USERS2 type standard table of usr02.
DATA: LT_USERS1 type standard table of usr01.
FIELD-SYMBOLS: <fs_itab> type standard table.
SELECT * into table LT_USERS1 FROM usr01.
SELECT * into table LT_USERS2 FROM usr02.
IF P_TAB1 eq 'X'.
ASSIGN LT_USERS1 to <fs_itab>.
ELSE.
ASSIGN LT_USERS2 to <fs_itab>.
ENDIF.
PERFORM TEST_FORM TABLES <fs_itab>.
&----
*& Form test_form
&----
Form routine that can accept any itab and will write all the
fields of that itab as output.
----
-->X_ITAB
----
FORM test_form TABLES X_ITAB .
FIELD-SYMBOLS: <fs_wa> type any.
FIELD-SYMBOLS: <fs_field> type any.
LOOP AT X_ITAB ASSIGNING <fs_wa>.
DO.
ASSIGN COMPONENT SY-index OF STRUCTURE <fs_wa> to <FS_FIELD>.
if SY-subrc ne 0.
exit.
endif.
WRITE : <fs_field>.
ENDDO.
WRITE :/.
ENDLOOP.
ENDFORM.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hai gopan
check with this document
Field-Symbols are place holders for existing fields.
A Field-Symbol does not physically reserve space for a field but points to a field, which is not known until run time of the program.
Field-Symbols are like Pointers in Programming language C .
Syntax check is not effective.
Syntax :
Data : v1(4) value abcd.
Field-symbols <fs>.
Assign v1 to <fs>.
Write:/ <fs>.
DATA: BEGIN OF LINE,
COL1 TYPE I,
COL2 TYPE I,
END OF LINE.
DATA ITAB LIKE SORTED TABLE OF LINE WITH UNIQUE KEY COL1.
FIELD-SYMBOLS <FS> LIKE LINE OF ITAB.
DO 4 TIMES.
LINE-COL1 = SY-INDEX.
LINE-COL2 = SY-INDEX ** 2.
APPEND LINE TO ITAB.
ENDDO.
READ TABLE ITAB WITH TABLE KEY COL1 = 2 ASSIGNING <FS>.
<FS>-COL2 = 100.
READ TABLE ITAB WITH TABLE KEY COL1 = 3 ASSIGNING <FS>.
DELETE ITAB INDEX 3.
IF <FS> IS ASSIGNED.
WRITE '<FS> is assigned!'.
ENDIF.
LOOP AT ITAB ASSIGNING <FS>.
WRITE: / <FS>-COL1, <FS>-COL2.
ENDLOOP.
The output is:
1 1
2 100
4 16
Thanks & regards
Sreenivasulu P
Message was edited by: Sreenivasulu Ponnadi
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi,
Refer this thread:
<a class="jive_macro jive_macro_message" href="" __jive_macro_name="message" modifiedtitle="true" __default_attr="261030"></a>
Refer this piece of code.
[code]DATA : BEGIN OF GT_ZCO001 OCCURS 0.
INCLUDE STRUCTURE ZCO001.
DATA: END OF GT_ZCO001.
DATA: BEGIN OF GT_FILE OCCURS 0,
ZCNTRY TYPE LAND1,
ZOLOC TYPE ZOLOC,
ZOLOC20 TYPE ZOLOC20,
ZOLOC40 TYPE ZOLOC40,
ZAWSYS TYPE LOGSYSTEM,
ZSTREET TYPE AD_STREET,
ZSTREET2 TYPE AD_STRSPP1,
ZPOSTAL_CODE TYPE AD_PSTCD1,
ZCITY TYPE AD_CITY1,
ZCOUNTRY TYPE ZLAND,
ZOBJ_SIGN TYPE ZOBJ_SIGN,
ZREF1 TYPE ZREF1,
ZREF2 TYPE ZREF2,
ZREF3 TYPE ZREF3,
ZREF4 TYPE ZREF4,
ZNOTE1 TYPE ZNOTE1,
ZNOTE2 TYPE ZNOTE2,
END OF GT_FILE.
*****************************************************************
*FIELD DECLARATIONS *
*****************************************************************
FIELD-SYMBOLS: <FS_ZCO001> TYPE ZCO001,
<FS_FILE> LIKE GT_FILE.
LOOP AT GT_FILE ASSIGNING <FS_FILE>.
<FS_ZCO001>-ZCNTRY = <FS_FILE>-ZCNTRY.
<FS_ZCO001>-ZOLOC20 = <FS_FILE>-ZOLOC20.
<FS_ZCO001>-ZOLOC40 = <FS_FILE>-ZOLOC40.
<FS_ZCO001>-ZAWSYS = <FS_FILE>-ZAWSYS.
<FS_ZCO001>-ZSTREET = <FS_FILE>-ZSTREET.
<FS_ZCO001>-ZSTREET2 = <FS_FILE>-ZSTREET2.
<FS_ZCO001>-ZPOSTAL_CODE = <FS_FILE>-ZPOSTAL_CODE.
<FS_ZCO001>-ZCITY = <FS_FILE>-ZCITY.
<FS_ZCO001>-ZCOUNTRY = <FS_FILE>-ZCOUNTRY.
<FS_ZCO001>-ZOBJ_SIGN = <FS_FILE>-ZOBJ_SIGN.
<FS_ZCO001>-ZREF1 = <FS_FILE>-ZREF1.
<FS_ZCO001>-ZREF2 = <FS_FILE>-ZREF2.
<FS_ZCO001>-ZREF3 = <FS_FILE>-ZREF3.
<FS_ZCO001>-ZREF4 = <FS_FILE>-ZREF4.
<FS_ZCO001>-ZNOTE1 = <FS_FILE>-ZNOTE1.
<FS_ZCO001>-ZNOTE2 = <FS_FILE>-ZNOTE2.
<FS_ZCO001>-ZCREATEDATE = SY-DATUM.
<FS_ZCO001>-ZCREATETIME = SY-UZEIT.
APPEND GT_ZCO001.
CLEAR GT_ZCO001.
ENDLOOP.
Regards,
Gayathri[/code]
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
hi,
I am not sure in which context you are asking about this.
These act as pointers to the data and improve the performance of the program
In case of a table work area
Generally you can find it here
http://help.sap.com/saphelp_nw04/helpdata/en/fc/eb387a358411d1829f0000e829fbfe/content.htm
Regards,
Ravi
Note :Please close the thread if the question is answered and mark all the helpful answers
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
94 | |
11 | |
10 | |
9 | |
9 | |
7 | |
6 | |
5 | |
4 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.