Application Development 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: 

What is meant by Defining Common Data Area ??

Former Member
0 Kudos

I have seen a code like this ....

DATA: BEGIN OF COMMON PART FM06LCS2,

( All the parameters /select-options are declared here)

END OF COMMON PART.

what is this ??? what for it is used ??????

My requirement is .....

To add one more Parameter in between this area.....

what all should i do???

Expecting your answers,

Thanks in advance

Cheers,

R.Kripa.

3 REPLIES 3

suresh_datti
Active Contributor
0 Kudos

Hi,

Did you check this <a href="http://help.sap.com/saphelp_47x200/helpdata/en/9f/db97c435c111d1829f0000e829fbfe/frameset.htm">SAP Help</a>

Regards,

Suresh Datti

Former Member
0 Kudos

Hi Kripa

Using COMMON PART, u can access/share the variables between different programs

for eg if you are using external subroutine, then in order to access the variables of the program in which this subroutine is defined..you can define the variables in COMMON PART

U have to define the COMMON PARTS in both the program so as to have access to variables

THanks

Former Member
0 Kudos

HI

GOOD

GO THROUGH THIS

For the sake of completeness, this section describes a technique that allows you to access the global data of the calling program from an external subroutine. To do this, you declare a common data area for the calling program and the program containing the subroutine. All interface work areas declared using TABLES and NODES behave like the common data area.

Like external subroutines themselves, you should use common data areas very sparingly. The rules for accessing common data areas can become very complicated if you call function modules from nested subroutines.

You declare a common data area in all programs concerned using the statement:

DATA: BEGIN OF COMMON PART [<name>],

END OF COMMON PART [<name>].

Between the two DATA statements, you declare all of the data you want to include in the common data area.

The common part declaration must be exactly the same in all of the programs in which you want to use it. It is therefore a good idea to put the declaration in an include program.

You can use several common parts in one program. In this case, you must assign a name <name> to each common part. If you only have one common part in each program, you do not have to specify a name. To avoid conflicts between programs that have different common part declarations, you should always assign unique names to common parts.

Assume an include program INCOMMON contains the declaration of a common part NUMBERS. The common part comprises three numeric fields: NUM1, NUM2, and SUM:

***INCLUDE INCOMMON.

DATA: BEGIN OF COMMON PART NUMBERS,

NUM1 TYPE I,

NUM2 TYPE I,

SUM TYPE I,

END OF COMMON PART NUMBERS.

The program FORMPOOL includes INCOMMON and contains the subroutines ADDIT and OUT:

PROGRAM FORMPOOL.

INCLUDE INCOMMON.

FORM ADDIT.

SUM = NUM1 + NUM2.

PERFORM OUT.

ENDFORM.

FORM OUT.

WRITE: / 'Sum of', NUM1, 'and', NUM2, 'is', SUM.

ENDFORM.

A calling program FORM_TEST includes INCOMMON and calls the subroutine ADDIT from the program FORMPOOL.

PROGRAM FORM_TEST.

INCLUDE INCOMMON.

NUM1 = 2. NUM2 = 4.

PERFORM ADDIT(FORMPOOL).

NUM1 = 7. NUM2 = 11.

PERFORM ADDIT(FORMPOOL).

This produces the following output:

Sum of 2 and 4 is 6

Sum of 7 and 11 is 18

The subroutines in the program FORMPOOL access the global data of the shared data area.

Assume a program FORMPOOL that contains two subroutines TABTEST1 and TABTEST2 as follows:

PROGRAM FORMPOOL.

TABLES SFLIGHT.

FORM TABTEST1.

SFLIGHT-PLANETYPE = 'A310'.

SFLIGHT-PRICE = '150.00'.

WRITE: / SFLIGHT-PLANETYPE, SFLIGHT-PRICE.

ENDFORM.

FORM TABTEST2.

LOCAL SFLIGHT.

SFLIGHT-PLANETYPE = 'B747'.

SFLIGHT-PRICE = '500.00'.

WRITE: / SFLIGHT-PLANETYPE, SFLIGHT-PRICE.

ENDFORM.

A program FORM_TEST calls TABTEST1 and TABTEST2 as follows:

PROGRAM FORM_TEST.

TABLES SFLIGHT.

PERFORM TABTEST1(FORMPOOL).

WRITE: / SFLIGHT-PLANETYPE, SFLIGHT-PRICE.

PERFORM TABTEST2(FORMPOOL).

WRITE: / SFLIGHT-PLANETYPE, SFLIGHT-PRICE.

THANKS

MRUTYUN