2007 May 29 5:55 AM
hi friends
wher we can use field sysmbles in real time applications?adv and disadv?
2007 May 29 6:03 AM
Hi
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.
for more info
http://help.sap.com/saphelp_nw04/helpdata/en/fc/eb3860358411d1829f0000e829fbfe/content.htm
Regards
Shiva
hi friends
wher we can use field sysmbles in real time applications?adv and disadv?
2007 May 29 6:03 AM
Hi
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.
for more info
http://help.sap.com/saphelp_nw04/helpdata/en/fc/eb3860358411d1829f0000e829fbfe/content.htm
Regards
Shiva
2007 May 29 6:06 AM
Hi,
Field symbols offer functionlity similar to pointers in other programming languages. It does not occupy memory for the data object, it points to the object that has been assigned to the field symbol. You use the assign command to relate to the data object. After the assign operation you can work with field symbol in the same way as with the object itself.
You define the field symbol as: field-symbols <fs>.
Consider this:
field-symbol <fs>.
data field value 'X'.
asssign field to <fs>.
The field symbol <fs> now inherits all the properties from the assigned field, and you can work with the field symbol in the same way as with the field itself.
Take a look at the examples given here for working with field symbols:
http://www.sapgenie.com/abap/code/chap2401.txt
http://www.sapgenie.com/abap/code/chap2402.txt
http://www.sapgenie.com/abap/code/chap2403.txt
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
Regards,
Priyanka.
2007 May 29 6:45 AM
hi elagam,
Fieldsymbol does'nt hold any value...
instead it maintain a reference to another variable...
that has been defined by parameter statement...
it works as a pointer...
definition :
field-symbols <fs>.
advantages of FS is u can directly assingn value
to variable ....
hope this will somewat clear ur doubt..
please reward points in case usefull....
regards,
prashant
2007 May 29 9:24 AM
Hi
Please go through the following link
http://help.sap.com/saphelp_nw04/helpdata/en/fc/eb3860358411d1829f0000e829fbfe/content.htm
2007 May 29 10:36 AM
Ravinder,
Field symbols are similar to pointers in C, ie, they point to real variables rather then being variables themselve. Using the field symbols you can access different variables dynamically.
For example if we have 2 variables v_a & v_b. If an implementation needs to assign a value 100 to v_a if v_flag = 'A' & to v_b if v_flag = 'B', we can code it as follows:
DATA: v_a type i,
v_b type i.......
FIELD SYMBOLS: <f1> type i.
......
IF v_flag = 'A'.
assign ('V_A') to <f1>.
ELSE.
assign ('V_B') to <f1>.
ENDIF.
IF <f1> IS ASSIGNED.
<f1> = 100.
ENDIF.
2007 May 29 1:46 PM
Do you want to squeeze more performance out of your Internal Table processing?The new ABAP object extensions in SAP require internal table definitions to look a little different. With this new style of definition comes many options for better performance like hash tables and sorted tables. The use of field symbols takes this performance concept one step further.
The new style of definition of internal tables usually doesn't include a header area for the internal table. Furthermore, ABAP Objects will not allow internal tables with header lines. For added performance, instead of declaring a work area--use a field symbol. The work area concept and header line format both require data to be moved from the internal table to the work area or header area. A field symbol is just a pointer that will point to the proper line of the itab. With field symbols, no data needs to be moved. The field symbol just stores the proper memory address to point at the right line. The field symbol can have structure and be made up of fields similar to a work area or header line. Because no data needs to be copied, processing is much faster.
The keys to the usage are:
1) Defining the table records and the field symbol in a similar type.
* just an ordinary standard table
TYPES: BEGIN OF it_vbak_line,
vbeln LIKE vbak-vbeln,
vkorg LIKE vbak-vkorg,
vtweg LIKE vbak-vtweg,
spart LIKE vbak-spart,
kunnr LIKE vbak-kunnr,
END OF it_vbak_line.
DATA: it_vbak TYPE TABLE OF it_vbak_line.
FIELD-SYMBOLS: <it_vbak_line> TYPE it_vbak_line.
* or as a screaming fast hash table for keyed reads
TYPES: BEGIN OF it_vbpa_line,
vbeln LIKE vbak-vbeln,
kunnr LIKE vbak-kunnr,
END OF it_vbpa_line.
DATA: it_vbpa TYPE HASHED TABLE OF it_vbpa_line
WITH UNIQUE KEY vbeln.
FIELD-SYMBOLS: <it_vbpa_line> TYPE it_vbpa_line.
2) In ITAB processing, utilize the ASSIGNING command.
* loop example
LOOP AT it_vbak ASSIGNING <it_vbak_line>.
* look at records--populate it_zpartner
* read example
READ TABLE it_vbpa ASSIGNING <it_vbpa_line>
WITH TABLE KEY vbeln = <it_vbak_line>-vbeln.
3) Refer to the field symbol's fields in the loop or after the read.
wa_zpartner-vkorg = <it_vbak_line>-vkorg.
wa_zpartner-vtweg = <it_vbak_line>-vtweg.
wa_zpartner-spart = <it_vbak_line>-spart.
wa_zpartner-kunag = <it_vbak_line>-kunnr.
wa_zpartner-kunwe = <it_vbpa_line>-kunnr.
See the code example below for further detail. The code was written in R/3 4.6C and should work for all 4.x versions.
Code
REPORT z_cnv_zshipto_from_hist NO STANDARD PAGE HEADING
LINE-SIZE 132
LINE-COUNT 65
MESSAGE-ID z1.
************************************************************************
* Program Name: ZSHIPTO from History Creation: 07/23/2003 *
* *
* SAP Name : Z_CNV_ZSHIPTO_FROM_HIST Application: SD *
* *
* Author : James Vander Heyden Type: 1 *
*______________________________________________________________________*
* Description : This program reads tables VBAK & VBPA and populates *
* ZPARTNER. ZPARTNER table is read in by ZINTSC06. ZINTSC06 updates *
* the ZSHIPTO relationships. *
*______________________________________________________________________*
* Inputs: Selection Screen *
* *
* Outputs: *
*______________________________________________________________________*
* External Routines *
* Function Modules: *
* Transactions : *
* Programs : *
*______________________________________________________________________*
* Return Codes: *
* *
*______________________________________________________________________*
* Ammendments: *
* Programmer Date Req. # Action *
* ================ ========== ====== ===============================*
* J Vander Heyden 07/23/2003 PCR Initial Build *
************************************************************************
*----------------------------------------------------------------------*
* DATA DICTIONARY TABLES *
*----------------------------------------------------------------------*
TABLES:
zpartner.
*----------------------------------------------------------------------*
* SELECTION SCREEN LAYOUT *
*----------------------------------------------------------------------*
PARAMETERS: p_load RADIOBUTTON GROUP a1 DEFAULT 'X',
p_deltab RADIOBUTTON GROUP a1.
SELECTION-SCREEN SKIP 2.
SELECT-OPTIONS: s_vkorg FOR zpartner-vkorg MEMORY ID vko OBLIGATORY
NO INTERVALS NO-EXTENSION,
s_vtweg FOR zpartner-vtweg MEMORY ID vtw OBLIGATORY
NO INTERVALS NO-EXTENSION,
s_spart FOR zpartner-spart MEMORY ID spa OBLIGATORY
NO INTERVALS NO-EXTENSION.
*----------------------------------------------------------------------*
* INTERNAL TABLES *
*----------------------------------------------------------------------*
TYPES: BEGIN OF it_vbak_line,
vbeln LIKE vbak-vbeln,
vkorg LIKE vbak-vkorg,
vtweg LIKE vbak-vtweg,
spart LIKE vbak-spart,
kunnr LIKE vbak-kunnr,
END OF it_vbak_line.
DATA: it_vbak TYPE TABLE OF it_vbak_line.
FIELD-SYMBOLS: <it_vbak_line> TYPE it_vbak_line.
TYPES: BEGIN OF it_vbpa_line,
vbeln LIKE vbak-vbeln,
kunnr LIKE vbak-kunnr,
END OF it_vbpa_line.
DATA: it_vbpa TYPE HASHED TABLE OF it_vbpa_line
WITH UNIQUE KEY vbeln.
FIELD-SYMBOLS: <it_vbpa_line> TYPE it_vbpa_line.
DATA: it_zpartner TYPE TABLE OF zpartner.
DATA: wa_zpartner TYPE zpartner.
*----------------------------------------------------------------------*
* STRUCTURES *
*----------------------------------------------------------------------*
*----------------------------------------------------------------------*
* VARIABLES *
*----------------------------------------------------------------------*
DATA: z_mode VALUE 'N',
z_commit TYPE i,
z_good TYPE i,
z_bad TYPE i.
*----------------------------------------------------------------------*
* CONSTANTS *
*----------------------------------------------------------------------*
*----------------------------------------------------------------------*
* SELECTION-SCREEN HELP *
*----------------------------------------------------------------------*
*----------------------------------------------------------------------*
* INITIALIZATION *
*----------------------------------------------------------------------*
INITIALIZATION.
*----------------------------------------------------------------------*
* AT LINE SELECTION *
*----------------------------------------------------------------------*
AT LINE-SELECTION.
*----------------------------------------------------------------------*
* AT SELECTION SCREEN *
*----------------------------------------------------------------------*
AT SELECTION-SCREEN.
*----------------------------------------------------------------------*
* START-OF-SELECTION *
*----------------------------------------------------------------------*
START-OF-SELECTION.
IF p_load = 'X'.
PERFORM select_records.
PERFORM process_itab.
ELSE.
PERFORM delete_table.
ENDIF.
*----------------------------------------------------------------------*
* END-OF-SELECTION *
*----------------------------------------------------------------------*
END-OF-SELECTION.
**********************************************************************
**********************************************************************
*&---------------------------------------------------------------------*
*& Form DELETE_TABLE
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
FORM delete_table.
DATA: w_answer.
CLEAR: w_answer.
CALL FUNCTION 'POPUP_TO_CONFIRM'
EXPORTING
titlebar = text-002
* DIAGNOSE_OBJECT = ' '
text_question = text-003
text_button_1 = text-004
icon_button_1 = 'ICON_OKAY'
text_button_2 = text-005
icon_button_2 = 'ICON_CANCEL'
default_button = '2'
display_cancel_button = ''
* USERDEFINED_F1_HELP = ' '
* START_COLUMN = 25
* START_ROW = 6
* POPUP_TYPE =
IMPORTING
answer = w_answer.
* TABLES
* PARAMETER =
* EXCEPTIONS
* TEXT_NOT_FOUND = 1
* OTHERS = 2
.
IF w_answer = 1.
DELETE FROM zpartner
WHERE vkorg IN s_vkorg
AND vtweg IN s_vtweg
AND spart IN s_spart.
MESSAGE i398(00) WITH 'Records deleted from table: '
sy-dbcnt
' '
' '.
ENDIF.
ENDFORM. " DELETE_TABLE
*&---------------------------------------------------------------------*
*& Form SELECT_RECORDS
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
FORM select_records.
* get vbaks
CLEAR: it_vbak.
SELECT vbeln vkorg vtweg spart kunnr
FROM vbak
INTO CORRESPONDING FIELDS OF TABLE it_vbak
WHERE vkorg IN s_vkorg
AND vtweg IN s_vtweg
AND spart IN s_spart
AND auart = 'TA'.
* get vbpa we's
CLEAR: it_vbpa.
SELECT *
FROM vbpa
INTO CORRESPONDING FIELDS OF TABLE it_vbpa
FOR ALL ENTRIES IN it_vbak
WHERE vbeln = it_vbak-vbeln
AND posnr = '000000'
AND parvw = 'WE'.
ENDFORM. " SELECT_RECORDS
*&---------------------------------------------------------------------*
*& Form PROCESS_ITAB
*&---------------------------------------------------------------------*
* attempt post goods issue for all entries.
*----------------------------------------------------------------------*
FORM process_itab.
LOOP AT it_vbak ASSIGNING <it_vbak_line>.
* look at records--populate it_zpartner
READ TABLE it_vbpa ASSIGNING <it_vbpa_line>
WITH TABLE KEY vbeln = <it_vbak_line>-vbeln.
IF sy-subrc = 0.
CLEAR: wa_zpartner.
wa_zpartner-mandt = sy-mandt.
wa_zpartner-vkorg = <it_vbak_line>-vkorg.
wa_zpartner-vtweg = <it_vbak_line>-vtweg.
wa_zpartner-spart = <it_vbak_line>-spart.
wa_zpartner-kunag = <it_vbak_line>-kunnr.
wa_zpartner-kunwe = <it_vbpa_line>-kunnr.
APPEND wa_zpartner TO it_zpartner.
ENDIF.
*
ENDLOOP.
SORT it_zpartner BY mandt vkorg vtweg spart kunag kunwe..
DELETE ADJACENT DUPLICATES FROM it_zpartner.
* do a mass table update.
INSERT zpartner FROM TABLE it_zpartner.
IF sy-subrc = 0.
MESSAGE s398(00) WITH 'Inserted records: ' sy-dbcnt.
ENDIF.
ENDFORM. " PROCESS_ITAB
Girish
| User | Count |
|---|---|
| 3 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 |