Application Development and Automation 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: 
Read only

Function Module Parameters problem

former_member295881
Contributor
0 Likes
2,764

Hello Experts!

Iu2019m trying to write a PERFORM but having problems with its parameters.

The signature of the FORM / ENDFORM are as follows.

form SET_RETURN_MESSAGE USING VALUE(P_MESSAGE) LIKE MESSAGE

CHANGING P_RETURN LIKE BAPIRETURN.

Now Iu2019m not sure according to this FORM / ENDFORM how should I write my perform. As for now I wrote like this:

Perform SET_RETURN_MESSAGE.

And Iu2019m having error message about parameters saying:

Different number of parameters in FORM and PERFORM (routine:

SET_RETURN_MESSAGE, number of formal parameters: 2, number of actual

parameters: 0).

Iu2019m new with Function Modules and not sure how to provide the correct parameters:

Also it will be great if someone able to tell me how should I use these types u2018FMu2019, where Iu2019ve to pass the parameters.

Thanks.

1 ACCEPTED SOLUTION
Read only

former_member295881
Contributor
0 Likes
2,098

Hi Avinash,

Thank you & all others for such a great help. Iu2019m having just 1 last problem then looks like everything else is fine. Parameter p_return problem is been solved but p_message is creating problem. Iu2019ve tried it with 2 different ways and have 2 different types of error.

1st type:

Perform SET_RETURN_MESSAGE USING 'p_message'

CHANGING p_return.

ERROR:

Include LZAD_CO_BAPIF01

The literal "'p_message'" is not type-compatible with the formal

parameter "P_MESSAGE". -

2nd type:

Perform SET_RETURN_MESSAGE USING p_message

CHANGING p_return.

ERROR:

Include LZAD_CO_BAPIF01

In PERFORM or CALL FUNCTION "SET_RETURN_MESSAGE", the actual parameter "P_MESSAGE" is incompatible with the formal parameter "P_MESSAGE".

12 REPLIES 12
Read only

Former Member
0 Likes
2,098

Hi

Try this :

Option 1:

form SET_RETURN_MESSAGE USING VALUE(P_MESSAGE) LIKE MESSAGE

CHANGING P_RETURN LIKE BAPIRETURN.

endform.

Call you perform also with same number of parametre:

Perform SET_RETURN_MESSAGE using 'p_message'

changing i_return.

Option2:

form SET_RETURN_MESSAGE .

*Do your coding here with passing any parameters.

endform.

Call you perform also with same number of parametre:

Perform SET_RETURN_MESSAGE .

Check this link for more info on subroutines:

http://help.sap.com/saphelp_nw70/helpdata/en/9f/db978335c111d1829f0000e829fbfe/content.htm

Regards

Neha

Edited by: Neha Shukla on Nov 27, 2008 9:25 PM

Read only

Former Member
0 Likes
2,098

HI

try this way this will remove the error...

Perform SET_RETURN_MESSAGE USING p_message

CHANGING p_return.

Read only

Former Member
0 Likes
2,098

Hi,

As the error says..

U should have the same number of parameters from your perform to your form..

say :

data : hi type c value 1,

bye type c value 2.

perform write using hi bye.

then my form will have.

form hi1 bye1. "where hi1 = hi and bye1 = bye.

write : hi ,

bye.

endform.

your output wil be

1 2.

for ur scenario try as wat Avinash said....

One more to be added these are not FM's .

Pls check in se37 for FM's .

eg: GUI_download.

Thanks and Regards,

Sai

Edited by: Saikumar on Nov 27, 2008 9:47 PM

Edited by: Saikumar on Nov 27, 2008 9:49 PM

Read only

former_member295881
Contributor
0 Likes
2,098

Hi Neha & Avinash,

Thanks for both of you for the quick reply. Iu2019ve tried both ways as you guys suggested:

Perform SET_RETURN_MESSAGE using 'p_message'

changing i_return.

Perform SET_RETURN_MESSAGE USING p_message

CHANGING p_return.

But looks like there is something wrong with the CHANGING parameter. It is complaing that u2018i_returnu2019 is unknown. Do Iu2019ve to define it in my top?

Once again here is the complete FORM/ENDFORM.

FORM set_return_message USING value(p_message) LIKE message

CHANGING value(p_return) LIKE bapireturn..

CHECK NOT message IS INITIAL.

CALL FUNCTION 'BALW_BAPIRETURN_GET'

EXPORTING

type = p_message-msgty

cl = p_message-msgid

number = p_message-msgno

par1 = p_message-msgv1

par2 = p_message-msgv2

par3 = p_message-msgv3

par4 = p_message-msgv4

  • LOG_NO = ' '

  • LOG_MSG_NO = ' '

IMPORTING

bapireturn = p_return

EXCEPTIONS

OTHERS = 1.

ENDFORM. " SET_RETURN_MESSAGE

Read only

Former Member
0 Likes
2,098

HI,

Yes you need to decalre all the variable which you pass through the Perfrom statement.

Edited by: avinash kodarapu on Nov 27, 2008 10:47 PM

Read only

Former Member
0 Likes
2,098

Yes i_return must be same type as of p_return.I think you that one.

Read only

former_member295881
Contributor
0 Likes
2,097

Hi Avinash,

Here is the error:

[Include LZAD_CO_BAPIF01

Field "I_RETURN" is unknown. It is neither in one of the specified

tables nor defined by a "DATA" statement].

(Here is my top module)

LZAD_CO_BAPITOP

FUNCTION-POOL zad_co_bapi. "MESSAGE-ID ..

TYPES:

BEGIN OF type_tj02t,

istat LIKE tj02t-istat,

txt04 LIKE tj02t-txt04,

txt30 LIKE tj02t-txt30,

END OF type_tj02t.

DATA:

*declarations for TABLE parameter

t_bapistat LIKE zbapi_ad_stat OCCURS 0,

g_bapistat LIKE zbapi_ad_stat,

*Table for object texts

t_tj02t TYPE type_tj02t OCCURS 0,

g_tj02t TYPE type_tj02t.

  • Structure for return messages

DATA:

BEGIN OF message,

msgty LIKE sy-msgty,

msgid LIKE sy-msgid,

msgno LIKE sy-msgno,

msgv1 LIKE sy-msgv1,

msgv2 LIKE sy-msgv2,

msgv3 LIKE sy-msgv3,

msgv4 LIKE sy-msgv4,

END OF message.

&----


*& Form SET_RETURN_MESSAGE

&----


  • This routine is used for setting the BAPI return message.

*

  • The routine is a standard routine for BAPIs that handles the message

  • structure for the BAPIRETURN structure. It has been copied from the

  • BAPI Company Code Getlist

----


  • --> p1 text

  • <-- p2 text

----


FORM set_return_message USING value(p_message) LIKE message

CHANGING p_return LIKE bapireturn.

CHECK NOT message IS INITIAL.

CALL FUNCTION 'BALW_BAPIRETURN_GET'

EXPORTING

type = p_message-msgty

cl = p_message-msgid

number = p_message-msgno

par1 = p_message-msgv1

par2 = p_message-msgv2

par3 = p_message-msgv3

par4 = p_message-msgv4

  • LOG_NO = ' '

  • LOG_MSG_NO = ' '

IMPORTING

bapireturn = p_return

EXCEPTIONS

OTHERS = 1.

ENDFORM. " SET_RETURN_MESSAGE

(Here is my subprogram)

LZAD_CO_BAPIF01

&----


*& Include LZAD_CO_BAPIF01 *

&----


*perform SET_RETURN_MESSAGE.

Perform SET_RETURN_MESSAGE USING 'p_message'

CHANGING i_return.

Read only

0 Likes
2,097

HI,

Need to declare the i_returns in top include.

DATA : i_return type bapireturn.

Read only

0 Likes
2,097

Hi

If I_RETURN is export paramenter of your fm, u should considere is not a global data, so it can't be seen in subroutine like a form.

Or u use a global data in order to transfer the value from subroutine to export parameter or you go to EDIT->INTERFACE->GLOBALIZE PARAMETERS

Max

Read only

former_member295881
Contributor
0 Likes
2,101

Hi Avinash,

Thank you & all others for such a great help. Iu2019m having just 1 last problem then looks like everything else is fine. Parameter p_return problem is been solved but p_message is creating problem. Iu2019ve tried it with 2 different ways and have 2 different types of error.

1st type:

Perform SET_RETURN_MESSAGE USING 'p_message'

CHANGING p_return.

ERROR:

Include LZAD_CO_BAPIF01

The literal "'p_message'" is not type-compatible with the formal

parameter "P_MESSAGE". -

2nd type:

Perform SET_RETURN_MESSAGE USING p_message

CHANGING p_return.

ERROR:

Include LZAD_CO_BAPIF01

In PERFORM or CALL FUNCTION "SET_RETURN_MESSAGE", the actual parameter "P_MESSAGE" is incompatible with the formal parameter "P_MESSAGE".

Read only

0 Likes
2,097

HI,

FORM set_return_message USING value(p_message) LIKE message

CHANGING value(p_return) LIKE bapireturn..

You need to declare the p_message inthe top include with same type which you have provided in Form statement.

Read only

former_member295881
Contributor
0 Likes
2,097

Thanks alot Avinash & all others too. its works finally.