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 Groups

Former Member
0 Likes
872

hi,

can anyone tell me in brief what is field group and how is it related to extracts? and what is record types in that?

i just have a brief idea of field groups as i went thru the SDN search.

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
842

Hi Poonam,

An extract dataset consists of a sequence of records. These records may have different structures. All records with the same structure form a record type. You must define each record type of an extract dataset as a field group, using the FIELD-GROUPS statement.

FIELD-GROUPS <fg>.

This statement defines a field group <fg>. A field group combines several fields under one name. For clarity, you should declare your field groups at the end of the declaration part of your program.

A field group does not reserve storage space for the fields, but contains pointers to existing fields. When filling the extract dataset with records, these pointers determine the contents of the stored records.

You can also define a special field group called HEADER:

FIELD-GROUPS HEADER.

This group is automatically placed before any other field groups when you fill the extract. This means that a record of a field group <fg> always contains the fields of the field group HEADER. When sorting the extract dataset, the system uses these fields as the default sort key.

Regards,

Swapna.

7 REPLIES 7
Read only

Former Member
0 Likes
842

Hi Poonam,

Field groups are groups similar fileds together in one name. Field groups works in conjuction with

INSERT ,

EXTRACT,

SORT BY,

LOOP

ENDLOOP.

EXTRACT : This will combine all the fields in filed groups & write them in a sequential dataset in a single record.

Read only

Former Member
0 Likes
842

REPORT ZSPFLI LINE-SIZE 132 LINE-COUNT 65(3)

NO STANDARD PAGE HEADING.

TABLES:SPFLI,SCARR, SFLIGHT, SBOOK.

SELECT-OPTIONS: MYCARRID FOR SPFLI-CARRID.

FIELD-GROUPS: HEADER, SPFLI_FG, SFLIGHT_FG, SBOOK_FG.

INSERT:

SPFLI-CARRID

SPFLI-CONNID

SFLIGHT-FLDATE

SBOOK-BOOKID

INTO HEADER,

SPFLI-CARRID

SPFLI-CONNID

SPFLI-CITYFROM

SPFLI-AIRPFROM

SPFLI-CITYTO

SPFLI-AIRPTO

SPFLI-DEPTIME

SCARR-CARRNAME

INTO SPFLI_FG,

SFLIGHT-FLDATE

SFLIGHT-SEATSMAX

SFLIGHT-SEATSOCC

SFLIGHT-PRICE

INTO SFLIGHT_FG,

SBOOK-BOOKID

SBOOK-CUSTOMID

SBOOK-CUSTTYPE

SBOOK-SMOKER

INTO SBOOK_FG.

SELECT * FROM SPFLI WHERE CARRID IN MYCARRID.

SELECT SINGLE * FROM SCARR WHERE CARRID = SPFLI-CARRID.

EXTRACT SPFLI_FG.

SELECT * FROM SFLIGHT

WHERE CARRID = SPFLI-CARRID AND CONNID = SPFLI-CONNID.

EXTRACT SFLIGHT_FG.

SELECT * FROM SBOOK

WHERE CARRID = SFLIGHT-CARRID AND

CONNID = SFLIGHT-CONNID AND FLDATE = SFLIGHT-FLDATE.

EXTRACT SBOOK_FG.

CLEAR SBOOK.

ENDSELECT.

CLEAR SFLIGHT.

ENDSELECT.

CLEAR SPFLI.

ENDSELECT.

SORT.

LOOP.

AT SPFLI_FG.

FORMAT COLOR COL_HEADING.

WRITE: / SCARR-CARRNAME,

SPFLI-CONNID, SPFLI-CITYFROM,

SPFLI-AIRPFROM, SPFLI-CITYTO, SPFLI-AIRPTO, SPFLI-DEPTIME.

FORMAT COLOR OFF.

ENDAT.

AT SFLIGHT_FG.

WRITE: /15 SFLIGHT-FLDATE, SFLIGHT-PRICE, SFLIGHT-SEATSMAX,

SFLIGHT-SEATSOCC.

ENDAT.

AT SBOOK_FG.

WRITE: /30 SBOOK-BOOKID, SBOOK-CUSTOMID,

SBOOK-CUSTTYPE, SBOOK-SMOKER.

ENDAT.

ENDLOOP.

Read only

Former Member
0 Likes
843

Hi Poonam,

An extract dataset consists of a sequence of records. These records may have different structures. All records with the same structure form a record type. You must define each record type of an extract dataset as a field group, using the FIELD-GROUPS statement.

FIELD-GROUPS <fg>.

This statement defines a field group <fg>. A field group combines several fields under one name. For clarity, you should declare your field groups at the end of the declaration part of your program.

A field group does not reserve storage space for the fields, but contains pointers to existing fields. When filling the extract dataset with records, these pointers determine the contents of the stored records.

You can also define a special field group called HEADER:

FIELD-GROUPS HEADER.

This group is automatically placed before any other field groups when you fill the extract. This means that a record of a field group <fg> always contains the fields of the field group HEADER. When sorting the extract dataset, the system uses these fields as the default sort key.

Regards,

Swapna.

Read only

Former Member
0 Likes
842
Read only

Former Member
0 Likes
842

hi,

If there is no field group specified after EXTRACT, then the field group header is implicitly added.

At the first execution of the EXTRACT-statement of a program, the extract dataset is created and the first line added. After execution of an EXTRACT-statement, it is not allowed to incorporate other fields to the specified field group field_group with the INSERT statement. If you do so, an uncatchable exception will be raised at the next EXTRACT-statement for the same field group.

EXTRACT [ header | field_group ].

Read only

Former Member