Skip to Content
author's profile photo Former Member
Former Member

subroutines & functionmodules

i want practise my self on subroutines & function modules with good in programming .give me programs/tell where can i found widevariety of programsto pracise workbench concepts other than abapdocu.

not theory i need programs to pracise with syntax.plz help me ,surely reward points will assign to every best answers.kindly help me friends.

Add a comment
10|10000 characters needed characters exceeded

Assigned Tags

Related questions

2 Answers

  • author's profile photo Former Member
    Former Member
    Posted on May 29, 2007 at 09:45 AM

    Hi Kumar,

    For Subroutine,

    http://help.sap.com/saphelp_erp2005/helpdata/en/d1/803279454211d189710000e8322d00/frameset.htm

    Check this thread.

    https://forums.sdn.sap.com/click.jspa?searchID=638501&messageID=2606221

    Function Module

    Function Modules are Global ABAP programs created by SAP for reusable purpose. They have IMPORT, EXPORT and TABLE parameters, and EXCEPTIONS to through when error occurs.

    You can create them from TCode SE37.

    Check the link -

    http://www.erpgenie.com/abap/bapi/example.htm

    Use the following procedure to create a function module

    1.From the ABAP/4 Development Workbench screen, press the Function Library button on the Application toolbar.

    2.Type the name of your function module in the Function Module field. The name must begin with Y_ or Z_.

    3.Press the Create button. The Function Module Create: Administration screen is shown

    4.Type the name of a function group in the Function Group field. The function group name must be four characters long and must begin with Y or Z.

    5.Type an S in the Application field. This field is used to indicate which function area uses the function module. Our functionality is not used by any functional area, it is simply an example, so any choice will do. (S indicates that the function module contains functionality needed by Basis.)

    6.Type a description of the function module in the Short Text field. The contents of this field are seen when displaying a list of function modules.

    Press the Save button on the Application toolbar.

    7.If the function group does not already exist, a pop-up informs you of that fact and asks you if you want to create it. Press the Yes button to create the function group. The Create Function Group dialog box appears. Type a description in the Short Text field and press the Save button. The Create Object Catalog Entry screen appears. Press the Local Object button. You are returned to the Function Module Change: Administration screen.

    8.Press the Source Code button on the Application toolbar. The Function Module Edit screen is displayed.

    9.Type the source code for your function module. Do not change the system-generated comment lines under any circumstances! Your function module might fail to operate if you do.

    10.Press the Save button on the Application toolbar. The message Program xxxxx saved appears in the status bar at the bottom of the window.

    11.Press the Back button on the Application toolbar. You are returned to the Function Library Initial screen.

    12.If you want to define import or export parameters, select the Import/Export Parameter Interface radio button. Press the Change pushbutton. You are shown the Import/Export Parameters screen (refer to Figure 19.6). Type the names of your parameters in the first column and enter any other desired characteristics for each parameter. When you are finished, press the Save button and then the Back button.

    13.Finally, to activate your function module, press the Activate button on the Application toolbar of the Function Library Initial Screen.

    Regards,

    Jayant

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on May 29, 2007 at 10:20 AM

    Hi,

    This is one of subroutines example:

    1)

    PROGRAM FORM_TEST.

    TABLES SFLIGHT.

    PERFORM TABTEST1.

    WRITE: / SFLIGHT-PLANETYPE, SFLIGHT-PRICE.

    PERFORM TABTEST2.

    WRITE: / SFLIGHT-PLANETYPE, SFLIGHT-PRICE.

    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.

    When you run the program, the following is displayed:

    A310 150.00

    A310 150.00

    B747 500.00

    A310 150.00

    The program creates a table work area SFLIGHT for the database table SFLIGHT.

    Different values are assigned to the table work area SFLIGHT in TABTEST1 and

    TABTEST2. While the values assigned in TABTEST1 are valid globally, the values

    assigned in TABTEST2 are only valid locally.

    2) with field symbol:

    DATA TEXT(5) VALUE 'Text1'.

    PERFORM ROUTINE.

    WRITE TEXT.

    FORM ROUTINE.

    FIELD-SYMBOLS <FS>.

    ASSIGN LOCAL COPY OF TEXT TO <FS>.

    WRITE <FS>.

    <FS> = 'Text2'.

    WRITE <FS>.

    ASSIGN TEXT TO <FS>.

    WRITE <FS>.

    <FS> = 'Text3'.

    ENDFORM.

    The output is:

    Text1 Text2 Text1 Text3

    3)

    PROGRAM FORM_TEST.

    DATA: NUM1 TYPE I,

    NUM2 TYPE I,

    RES TYPE P DECIMALS 2.

    NUM1 = 3. NUM2 = 4.

    PERFORM DIVIDE USING NUM1 NUM2 CHANGING RES.

    NUM1 = 5. NUM2 = 0.

    PERFORM DIVIDE USING NUM1 NUM2 CHANGING RES.

    NUM1 = 2. NUM2 = 3.

    PERFORM DIVIDE USING NUM1 NUM2 CHANGING RES.

    FORM DIVIDE USING N1 N2 CHANGING R.

    CHECK N2 NE 0.

    R = N1 / N2.

    WRITE: / N1, '/', N2, '=', R.

    ENDFORM.

    The produces the following output:

    3 / 4 = 0.75

    2 / 3 = 0.67

    In this example, the system leaves the subroutine DIVIDE during the second call

    after the CHECK statement because the value of N2 is zero.

    Function modules:

    1) display the help text.

    DATA: company TYPE s_carr_id,

    h(20) TYPE c,

    tlink TYPE TABLE OF tline.

    DESCRIBE FIELD company HELP-ID h.

    CALL FUNCTION 'HELP_OBJECT_SHOW'

    EXPORTING

    dokclass = 'DE'

    doklangu = sy-langu

    dokname = h

    TABLES

    links = tlink

    EXCEPTIONS

    object_not_found = 1

    sapscript_error = 2

    others = 3.

    IF sy-subrc <> 0.

    ...

    ENDIF.

    In this program, the field H receives the name of the data element S_CARR_ID. The

    function module HELP_OBJECT_SHOW displays the documentation for the data

    element in a dialog box.

    for more information check the following link:http://www.sapmaterial.com/material.html

    Regards,

    Bhaskar

    Add a comment
    10|10000 characters needed characters exceeded

Before answering

You should only submit an answer when you are proposing a solution to the poster's problem. If you want the poster to clarify the question or provide more information, please leave a comment instead, requesting additional details. When answering, please include specifics, such as step-by-step instructions, context for the solution, and links to useful resources. Also, please make sure that you answer complies with our Rules of Engagement.
You must be Logged in to submit an answer.

Up to 10 attachments (including images) can be used with a maximum of 1.0 MB each and 10.5 MB total.