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
The field symbols work similarly to pointers in C. They are used in conjunction with statement
ASSIGN f TO
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
Declares a field symbol
FIELD-SYMBOL
Declares a field symbol
which is of particular type.
FIELD-SYMBOL
Declares a field symbol
default work area will be wa.
FIELD-SYMBOL
Declares a field symbol
e.g. FIELD-SYMBOLS
TABLES kna1. * Customer master
SELECT .....
...
ASSIGN kna1-kunnr TO
WRITE
ASSIGN f TO
This will assign the field f to field symbol
TYPE-POOLS tp
Type-pools are used to declare a type pool to be used in the program.The specified type pool should already exists in the ABAP DICTONARY(SE11).Once the type pool has been declared we can use any of the constants and types declared in that type pool.
TYPE-POOL tp
Type-pool statement is used to create a type group in the ABAP dictionary.It is the first statement in the definition.The type group is used to declare constants and types and these must begin with the name of the type pool and underscore.
e.g. TYPE-POOL owntypes.
TYPES num TYPE P DECIMALS 2.
TYPES name(14) TYPE C.
To use these types in the abap program we have to use the statement
TYPE-POOLS .
e.g. TYPE-POOLS owntypes.
DATA customer TYPE owntypes_num.
DATA name TYPE owntypes_name.
No comments:
Post a Comment