2005 Nov 11 7:43 AM
Hello,
can anyone give egs of using PERFORM and FORM statement. what do these statements do actually.
thanks.
2005 Nov 11 8:14 AM
See this sample for PERFORM ... USING...CHANGING
DATA : c1 TYPE i, c2 TYPE i, res TYPE i.
c1 = 1.
c2 = 2.
<b>PERFORM sum USING c1 c2 CHANGING res.</b>
WRITE:/ res.
*&---------------------------------------------------------------------
**& Form sum
*&---------------------------------------------------------------------
** text
*----------------------------------------------------------------------
form sum using p_c1 p_c2 changing value(p_res).
p_res = p_c1 + p_c2.
endform. " sumNote the difference between the above and below perform.
DATA : c1 TYPE i, c2 TYPE i, res TYPE i.
c1 = 1.
c2 = 2.
<b>data: subroutinename(3) VALUE 'SUM'.
PERFORM (subroutinename) IN PROGRAM Y_JJTEST1 USING c1 c2 CHANGING res</b>.
WRITE:/ res.
*&----
**& Form sum
*&----
text
*----
form sum using p_c1 p_c2 changing value(p_res).
p_res = p_c1 + p_c2.
endform. " sum
ANother sample for simple perform
PERFORM HELP_ME.
...
FORM HELP_ME.
...
ENDFORM.
***********************************
<b>... TABLES itab1 itab2 ...</b>
TYPES: BEGIN OF ITAB_TYPE,
TEXT(50),
NUMBER TYPE I,
END OF ITAB_TYPE.
DATA: ITAB TYPE STANDARD TABLE OF ITAB_TYPE WITH
NON-UNIQUE DEFAULT KEY INITIAL SIZE 100,
BEGIN OF ITAB_LINE,
TEXT(50),
NUMBER TYPE I,
END OF ITAB_LINE,
STRUC like T005T.
...
PERFORM DISPLAY TABLES ITAB
USING STRUC.
FORM DISPLAY TABLES PAR_ITAB STRUCTURE ITAB_LINE
USING PAR like T005T.
DATA: LOC_COMPARE LIKE PAR_ITAB-TEXT.
WRITE: / PAR-LAND1, PAR-LANDX.
...
LOOP AT PAR_ITAB WHERE TEXT = LOC_COMPARE.
...
ENDLOOP.
ENDFORM.
Hope this helps.
Reward points if this helps u.
Hello,
can anyone give egs of using PERFORM and FORM statement. what do these statements do actually.
thanks.
2005 Nov 11 7:49 AM
FORM - Keyword to define your subroutine.
PERFORM - Keyword to call your subroutine.
Form <Form Name>
Code that you want the form to do.
Endform.
Place where you want to call the subroutine -
PERFORM <Form name>.
Regards,
Ravi
Note : Award points for the posts that help you.
2005 Nov 11 7:53 AM
Ravi,
As u aware of Modularisation programming.
As part of that ..the follwing comes..
INCLUDES
SUBROUTINES
FUNCTIONMDOULES
MACROS...
PERFORM AND FORM are the keywords used to defind and call subroutines.
syntax:
FORM srot1.
subroutine definition.
ENDFORM.
IF u want call this sroutine...then u have to use...
PERFORM srot1.
It's just same concept FUNCTION IN C language.
Hope u r clear...
i will give an example
suppose u want to display addition of two numbers.
FORM add.
res = v1 + v2.
ENDFORM.
PERFORM add.
then this code calls this routine and prints the result.
Note: res,v1,v2 are to be declared in the program...
Kindly reward points if this helps you
regards,
Raj.
2005 Nov 11 7:53 AM
hi,
form are like subroutines.
and in abap perform is used to call the form .
syntax:
form formname value(arg1)
arg2
changing arg2.
perform formname 5
p1
changing arg2.
in this for the first parameter you are just sending the value of the parameter
second parameter your sending the reference of the value
so any change in the form reflects the sent argument .
for third parameter it will change the value after coming out the form.
examle:
start-of-selection.
perform display .
form display.
write:/ 'hi iamin display form'.
endform.
2005 Nov 11 8:14 AM
See this sample for PERFORM ... USING...CHANGING
DATA : c1 TYPE i, c2 TYPE i, res TYPE i.
c1 = 1.
c2 = 2.
<b>PERFORM sum USING c1 c2 CHANGING res.</b>
WRITE:/ res.
*&---------------------------------------------------------------------
**& Form sum
*&---------------------------------------------------------------------
** text
*----------------------------------------------------------------------
form sum using p_c1 p_c2 changing value(p_res).
p_res = p_c1 + p_c2.
endform. " sumNote the difference between the above and below perform.
DATA : c1 TYPE i, c2 TYPE i, res TYPE i.
c1 = 1.
c2 = 2.
<b>data: subroutinename(3) VALUE 'SUM'.
PERFORM (subroutinename) IN PROGRAM Y_JJTEST1 USING c1 c2 CHANGING res</b>.
WRITE:/ res.
*&----
**& Form sum
*&----
text
*----
form sum using p_c1 p_c2 changing value(p_res).
p_res = p_c1 + p_c2.
endform. " sum
ANother sample for simple perform
PERFORM HELP_ME.
...
FORM HELP_ME.
...
ENDFORM.
***********************************
<b>... TABLES itab1 itab2 ...</b>
TYPES: BEGIN OF ITAB_TYPE,
TEXT(50),
NUMBER TYPE I,
END OF ITAB_TYPE.
DATA: ITAB TYPE STANDARD TABLE OF ITAB_TYPE WITH
NON-UNIQUE DEFAULT KEY INITIAL SIZE 100,
BEGIN OF ITAB_LINE,
TEXT(50),
NUMBER TYPE I,
END OF ITAB_LINE,
STRUC like T005T.
...
PERFORM DISPLAY TABLES ITAB
USING STRUC.
FORM DISPLAY TABLES PAR_ITAB STRUCTURE ITAB_LINE
USING PAR like T005T.
DATA: LOC_COMPARE LIKE PAR_ITAB-TEXT.
WRITE: / PAR-LAND1, PAR-LANDX.
...
LOOP AT PAR_ITAB WHERE TEXT = LOC_COMPARE.
...
ENDLOOP.
ENDFORM.
Hope this helps.
Reward points if this helps u.
2005 Nov 11 8:24 AM
| User | Count |
|---|---|
| 4 | |
| 2 | |
| 2 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 |