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

Calling a Form from a function

Hi,

I'm trying to modularise my code. I have a function which call some forms. But when I try and compile it, I keep getting Syntax errors, and I'm not sure how to get round them. The code is shown below.

FUNCTION z_fs_allocated_payment_clear.

DATA BEGIN OF bdcdtab OCCURS 1.

INCLUDE STRUCTURE bdcdata.

DATA END OF bdcdtab.

DATA BEGIN OF messtab OCCURS 10.

INCLUDE STRUCTURE bdcmsgcoll.

DATA END OF messtab.

DATA BEGIN OF ybsid OCCURS 1.

INCLUDE STRUCTURE bsid.

DATA END OF ybsid.

PERFORM ybsid_fill ybsid.

PERFORM bdcdtab_fill bdcdtab.

PERFORM call_transaction.

endfunction.

FORM bdcdtab_fill using bdcdtab.

CLEAR bdcdtab.

REFRESH bdcdtab.

*-- Felder des Startdynpros der Ausgleichstransaktion füllen------

bdcdtab-program = 'SAPMF05A'.

bdcdtab-dynpro = '0131'.

bdcdtab-dynbegin = 'X'.

bdcdtab-fnam = ' '.

bdcdtab-fval = ' '.

APPEND bdcdtab.

.

.

.

Endform.

FORM ybsid_fill changing ybsid.

ybsid-mandt = '800'.

ybsid-bukrs = '2000'.

ybsid-kunnr = '0000300730'.

  • ybsid-umsks =

  • ybsid-umskz =

  • ybsid-augdt =

  • ybsid-augbl =

ybsid-zuonr = 'V31'.

ybsid-gjahr = '2005'.

.

.

.

endform.

I've tried using "changing, using , tables" to no avail.

Thanks

Add a comment
10|10000 characters needed characters exceeded

Assigned Tags

Related questions

8 Answers

  • Best Answer
    author's profile photo Former Member
    Former Member
    Posted on Aug 03, 2005 at 11:23 AM

    hi sims, its not clear which all parameters you are using, so please do copy your total source code from the top till the bottom. then we can repeat the same fucntion module at our end too and can give you an appropriate solution,

    but as of now we are unable to know which bare you import paranmters or export parameters.

    thanks & regards,

    venugopal

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Aug 03, 2005 at 11:01 AM

    Hi Sims,

    Can you tell what is the syntax error which you are getting in your code.

    /Manik

    Add a comment
    10|10000 characters needed characters exceeded

  • Posted on Aug 03, 2005 at 11:03 AM

    Hi,

    If a subroutine has a parameter interface, you must supply values to all of the formal parameters in its interface when you call it. You list the actual parameters after the USING or CHANGING addition in the PERFORM statement.

    When you pass the values, the sequence of the actual parameters in the PERFORM statement is crucial. The value of the first actual parameter in the list is passed to the first formal parameter, the second to the second, and so on. The additions USING and CHANGING have exactly the same meaning. You only need to use one or the other. However, for documentary reasons, it is a good idea to divide the parameters in the same way in which they occur in the interface definition.

    Actual parameters can be any data objects or field symbols of the calling program whose technical attributes are compatible with the type specified for the corresponding formal parameter. When you specify the actual parameters, note that any that you pass by reference to a formal parameter, and any that you pass by value to an output parameter, can be changed by the subroutine. You should therefore ensure that only data objects that you want to be changed appear in the corresponding position of the actual parameter list.

    If a subroutine contains TABLES parameters in its interface, you must specify them in a TABLES addition of the PERFORM statement before the USING and CHANGING parameters. TABLES parameters are only supported to ensure compatibility with earlier releases, and should no longer be used.

    You can specify actual parameters with variable offset and length specifications. Offset specifications for actual parameters function as offset specifications for field symbols. You can select memory areas that lie outside the boundaries of the specified actual parameter.

    PROGRAM FORM_TEST.

    DATA: A1 TYPE P DECIMALS 3,

    A2 TYPE I,

    A3 TYPE D,

    A4 TYPE SPFLI-CARRID,

    A5 TYPE C.

    ...

    PERFORM SUBR USING A1 A2 A3 A4 A5.

    ...

    PERFORM SUBR CHANGING A1 A2 A3 A4 A5.

    ...

    PERFORM SUBR USING A1 A2 A3

    CHANGING A4 A5.

    ...

    FORM SUBR USING

    VALUE(F1) TYPE P

    VALUE(F2) TYPE I

    F3 LIKE A3

    CHANGING

    VALUE(F4) TYPE SPFLI-CARRID

    F5.

    ...

    ENDFORM.

    Add a comment
    10|10000 characters needed characters exceeded

  • Posted on Aug 03, 2005 at 11:09 AM

    Hi,

    Check this sample also.

    PERFORM bdc_dynpro USING 'SAPDM06Q' '0215'.

    FORM bdc_dynpro USING program dynpro.

    CLEAR w_bdcdata.

    w_bdcdata-program = program.

    w_bdcdata-dynpro = dynpro.

    w_bdcdata-dynbegin = 'X'.

    APPEND w_bdcdata TO i_bdcdata.

    ENDFORM.

    If you use 'Using','Changing','Tables' in form,then obviously you need to use the same in perform statement also.

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Aug 03, 2005 at 12:26 PM

    Hi Sims,

    While calling PERFORM ybsid_fill tables ybsid. This statement is incorrect cause you are using

    ....'FORM ybsid_fill changing ybsid structure ybsid.'

    Changing in the form call .. this is a conflicting rather i would suggest you to use it like this

    PERFORM YBSID_FILL CHANGING YBSID

    FORM YBSID....... CHANGING P_YBDID.

    "Not only you are passing the same internal table name you are also appending. Note while using tables, changing statements require the reference

    ENDFORM.

    There is the same problem with the PERFORM bdcdtab_fill TABLES bdcdtab. cause u have used the same name in the FORM call.

    Correct this and your code will work. it will not make any difference even it's via a FM call.

    /Manik

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Aug 03, 2005 at 12:41 PM

    In the FM code, you can not define any form routines.

    All form routines have to be part of the Function Group.

    Hope you are clear with this.

    If you try to do soemthing like.

    Function.

    <Code>

    end function.

    form

    ...

    endform.

    it will give u a syntax error.

    Remember to reward points to the replies that answered ur question.

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Aug 03, 2005 at 01:28 PM

    Hi Sims,

    You need to give a different name then 'bdcdtab' and as REICH said declare structure as well, though it not mandatory.

    USe this code instead

    PERFORM bdcdtab_fill tables bdcdtab.

    .

    .

    .

    FORM bdcdtab_fill tables p_bdcdtab structure bdcdtab

    CLEAR bdcdtab.

    REFRESH bdcdtab.

    *-- Felder des Startdynpros der Ausgleichstransaktion füllen------

    bdcdtab-program = 'SAPMF05A'.

    bdcdtab-dynpro = '0131'.

    I hope this will solve you problem

    /Manik

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Aug 04, 2005 at 12:02 PM

    Hi Sims,

    If you problem is solved. Then please click the * (star) button and reward points.

    /Manik

    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.