Application Development and Automation Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

field

Former Member
0 Likes
414

can anybody explain indetail what are meant by field symbols & field groups

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
392

FIELD-GROUPS fg

Field groups are used to group similar fields together into one name. Filed groups can be used in conjunction with

INSERT f1 f2 INTO fg

EXTRACT fg

SORT BY fg

LOOP ... ENDLOOP

INSERT f1 f2 INTO fg

The INSERT statement is used to create a field group dynamically by

inserting the fields into it.Only global data fields can be inserted and not

local data fields e.g. in FORM modules.

EXTRACT fg

This statement will combine all the fields in the fieldgroup and write them to a sequential dataset as a single record.

e.g. DATA: customer(14) TYPE C,

order(20) TYPE C,

quantity(5) TYPE N,

material(20) TYPE C.

FIELD-GROUPS: order , mat .

INSERT customer order INTO order. * insering two fields in the field

*group order

INSERT quantity material INTO mat .

customer = 'niraj visnoi'

order = '100001'

EXTRACT order. *writing the contents of field group

*order to dataset

material = '1004.'

quantity = 500.

EXTRACT mat.

customer = 'rahul'

order = '100002'

EXTRACT order.

material = '1006.'

quantity = 200.

EXTRACT mat.

SORT BY order. * sorting of sequential dataset by field group order

LOOP .

AT order .

WRITE: customer, order.

ENDAT.

AT mat.

WRITE: material,quantity.

ENDAT.

ENDLOOP.

FIELD-SYMBOL <fs>

The field symbols work similarly to pointers in C. They are used in conjunction with statement

ASSIGN f TO <fs> .

At runtime we can assign a field or structure to the field symbol , any changes or work can be done on the field symbol affecting directly the assigned field. The syntax of field symbol declaration is:

FIELD-SYMBOL <fs>.

Declares a field symbol <fs> which can be assigned any single field.

FIELD-SYMBOL <fs> TYPE /LIKE type.

Declares a field symbol <fs> which can be assigned any single field

which is of particular type.

FIELD-SYMBOL <fs> STRUCTURE s DEFAULT wa.

Declares a field symbol <fs> which will point to a structure(table) and the

default work area will be wa.

FIELD-SYMBOL <fs> TYPE LINE OF /LIKE LINE OF type.

Declares a field symbol <fs> which will have line type .

e.g. FIELD-SYMBOLS <fs>

TABLES kna1. * Customer master

SELECT .....

...

ASSIGN kna1-kunnr TO <fs>.

WRITE <fs>.

ASSIGN f TO <fs>

This will assign the field f to field symbol <fs>,now we can work with the field symbol instead of the field.

3 REPLIES 3
Read only

Former Member
0 Likes
393

FIELD-GROUPS fg

Field groups are used to group similar fields together into one name. Filed groups can be used in conjunction with

INSERT f1 f2 INTO fg

EXTRACT fg

SORT BY fg

LOOP ... ENDLOOP

INSERT f1 f2 INTO fg

The INSERT statement is used to create a field group dynamically by

inserting the fields into it.Only global data fields can be inserted and not

local data fields e.g. in FORM modules.

EXTRACT fg

This statement will combine all the fields in the fieldgroup and write them to a sequential dataset as a single record.

e.g. DATA: customer(14) TYPE C,

order(20) TYPE C,

quantity(5) TYPE N,

material(20) TYPE C.

FIELD-GROUPS: order , mat .

INSERT customer order INTO order. * insering two fields in the field

*group order

INSERT quantity material INTO mat .

customer = 'niraj visnoi'

order = '100001'

EXTRACT order. *writing the contents of field group

*order to dataset

material = '1004.'

quantity = 500.

EXTRACT mat.

customer = 'rahul'

order = '100002'

EXTRACT order.

material = '1006.'

quantity = 200.

EXTRACT mat.

SORT BY order. * sorting of sequential dataset by field group order

LOOP .

AT order .

WRITE: customer, order.

ENDAT.

AT mat.

WRITE: material,quantity.

ENDAT.

ENDLOOP.

FIELD-SYMBOL <fs>

The field symbols work similarly to pointers in C. They are used in conjunction with statement

ASSIGN f TO <fs> .

At runtime we can assign a field or structure to the field symbol , any changes or work can be done on the field symbol affecting directly the assigned field. The syntax of field symbol declaration is:

FIELD-SYMBOL <fs>.

Declares a field symbol <fs> which can be assigned any single field.

FIELD-SYMBOL <fs> TYPE /LIKE type.

Declares a field symbol <fs> which can be assigned any single field

which is of particular type.

FIELD-SYMBOL <fs> STRUCTURE s DEFAULT wa.

Declares a field symbol <fs> which will point to a structure(table) and the

default work area will be wa.

FIELD-SYMBOL <fs> TYPE LINE OF /LIKE LINE OF type.

Declares a field symbol <fs> which will have line type .

e.g. FIELD-SYMBOLS <fs>

TABLES kna1. * Customer master

SELECT .....

...

ASSIGN kna1-kunnr TO <fs>.

WRITE <fs>.

ASSIGN f TO <fs>

This will assign the field f to field symbol <fs>,now we can work with the field symbol instead of the field.

Read only

Former Member
0 Likes
392

hi

FIELD SYMBOL-.

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. (For more information, see Data References).

http://help.sap.com/saphelp_nw04/helpdata/en/fc/eb3860358411d1829f0000e829fbfe/content.htm

FIELD GROUP->

You can assign fields of different tables to one field group. In this way, you can treat fields of linked additional tables, additional structures and additional fields in the same way as true logical database fields.

To assign a field to a field group, proceed as follows:

Click on the field you want to select in the data source.

Use drag&drop to move the field into the field group of your choice.

or;

Click on the field and on the field group of your choice.

Choose the function Add fields to field groups or the relevant function from the context menu.

http://help.sap.com/saphelp_46c/helpdata/EN/d2/cb43f3455611d189710000e8322d00/content.htm

Regards,

Sankar

Read only

Former Member
0 Likes
392

Hi,

Field Symbols:

http://help.sap.com/saphelp_nw04/helpdata/en/fc/eb3860358411d1829f0000e829fbfe/content.htm

Field Symbols Examples:

http://www.sapgenie.com/abap/code/chap2401.txt

http://www.sapgenie.com/abap/code/chap2402.txt

http://www.sapgenie.com/abap/code/chap2403.txt

Field groups:

Field groups are used to group similar fields together into one name

Notes & Sample Code Using Field-Groups :

http://www.geocities.com/SiliconValley/Grid/4858/sap/ABAPCode/Fieldgroups.htm

this link will show about the FIELD-GROUPS,EXTRACT,FIELD-SYMBOL and ASSIGN statments.

http://sap.niraj.tripod.com/id26.html

***do rewards if usefull

vijay