on 12-04-2008 8:54 AM
Dear Gurus,
Can any Explain about Sub routine? wht is use of it.
Thanks & Regards,
GSK
Hi GSK,
In addition to Amit's points I am giving some more points regarding u r question
Calling ABAP Subroutines: PERFORM
You can use the PERFORM command to call an ABAP subroutine
(form) from
any program, subject to the normal ABAP runtime
authorization
checking. You can use such calls to subroutines for
carrying out
calculations, for obtaining data from the database that is
needed at
display or print time, for formatting data, and so on.
PERFORM commands, like all control commands, are executed
when a
document is formatted for display or printing.
Communication between a
subroutine that you call and the document is by way of
symbols whose
values are set in the subroutine.
The system does not execute the PERFORM command within
SAPscript
replace modules, such as TEXT_SYMBOL_REPLACE or
TEXT_INCLUDE_REPLACE.
The replace modules can only replace symbol values or
resolve include
texts, but not interpret SAPscript control commands.
Syntax in a form window:
/: PERFORM <form> IN PROGRAM <prog>
/: USING &INVAR1&
/: USING &INVAR2&
......
/: CHANGING &OUTVAR1&
/: CHANGING &OUTVAR2&
......
/: ENDPERFORM
INVAR1 and INVAR2 are variable symbols and may be of any of
the four
SAPscript symbol types.
OUTVAR1 and OUTVAR2 are local text symbols and must
therefore be
character strings.
The ABAP subroutine called via the command line stated
above must be
defined in the ABAP report prog as follows:
FORM <form> TABLES IN_TAB STRUCTURE ITCSY
OUT_TAB STRUCTURE ITCSY.
...
ENDFORM.
The values of the SAPscript symbols passed with /: USING...
are now
stored in the internal table IN_TAB . Note that the system
passes the
values as character string to the subroutine, since the
field Feld
VALUE in structure ITCSY has the domain TDSYMVALUE (CHAR
80). See the
example below on how to access the variables.
The internal table OUT_TAB contains names and values of the
CHANGING
parameters in the PERFORM statement. These parameters are
local text
symbols, that is, character fields. See the example below
on how to
return the variables within the subroutine.
From within a SAPscript form, a subroutine GET_BARCODE in
the ABAP
program QCJPERFO is called. Then the simple barcode
contained there
('First page', 'Next page', 'Last page') is printed as
local variable
symbol.
Definition in the SAPscript form:
/: PERFORM GET_BARCODE IN PROGRAM QCJPERFO
/: USING &PAGE&
/: USING &NEXTPAGE&
/: CHANGING &BARCODE&
/: ENDPERFORM
/
/ &BARCODE&
Coding of the calling ABAP program:
REPORT QCJPERFO.
FORM GET_BARCODE TABLES IN_PAR STUCTURE ITCSY
OUT_PAR STRUCTURE ITCSY.
DATA: PAGNUM LIKE SY-TABIX, "page number
NEXTPAGE LIKE SY-TABIX. "number of next page
READ TABLE IN_PAR WITH KEY 'PAGE'.
CHECK SY-SUBRC = 0.
PAGNUM = IN_PAR-VALUE.
READ TABLE IN_PAR WITH KEY 'NEXTPAGE'.
CHECK SY-SUBRC = 0.
NEXTPAGE = IN_PAR-VALUE.
READ TABLE OUT_PAR WITH KEY 'BARCODE'.
CHECK SY-SUBRC = 0.
IF PAGNUM = 1.
OUT_PAR-VALUE = '|'. "First page
ELSE.
OUT_PAR-VALUE = '||'. "Next page
ENDIF.
IF NEXTPAGE = 0.
OUT_PAR-VALUE+2 = 'L'. "Flag: last page
ENDIF.
MODIFY OUT_PAR INDEX SY-TABIX.
ENDFORM.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Thanks to All
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi..
Check the link-http://help.sap.com/saphelp_47x200/helpdata/en/9f/db975c35c111d1829f0000e829fbfe/frameset.htm
Regds
MM
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi,
Subroutines are program specific. They are declared and used inside a single Program.
There are some stmts which gets repeated in the program. In that case we group these statements inside a form & endform and call it using perform stmt. It can be used only within the program.
Pls go through this link ..
[http://help.sap.com/saphelp_nw70/helpdata/en/ce/b518b6513611d194a50000e8353423/frameset.htm]
Rgds
San
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Dear GSK
Check this link
[Subroutines|http://help.sap.com/saphelp_47x200/helpdata/en/9f/db975c35c111d1829f0000e829fbfe/frameset.htm]
thanks
G. Lakshmipathi
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Dear GSK,
A subroutine is an internal modularization unit within a program, to which you can pass data using an interface. We use subroutines to encapsulate parts of your program, either to make the program easier to understand, or because a particular section of coding is used at several points in the program.The name of a Subroutine must be unique within the program (two programs can have different Subroutine with the same name). A Subroutine is intended to be called internal (from within the program, however you can call them external).
You can declare local data in a subroutine.After any local data declarations, you program the statements that are executed as part of the subroutine.Lifetime and visibility is limited to the moment the subroutine is called.
Types of Subroutines -
· Internal Subroutines: The source code of the internal subroutines will be in the same ABAP/4 program as the calling procedure (internal call).
· External Subroutines:External Subroutines are subroutines that are called from another program.
External Subroutines can be grouped into Subroutine Pools.
For more, please refer:
Best Regards,
Amit
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
107 | |
12 | |
11 | |
6 | |
5 | |
4 | |
4 | |
3 | |
3 | |
3 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.