‎2008 Apr 16 11:56 AM
I created below BAPI, Passing User Name in import Parameter
and exporting et_return as string
et_return.
Hi Experts!!
While added in API Method Its giving me error as API Method String can be recognised....
Please help me out.
Thanks
Anee
FUNCTION ZBAPI_URL_PASSING .
*"----------------------------------------------------------------------
*"*"Local Interface:
*" IMPORTING
*" VALUE(P_USERNAME) TYPE SYST-UNAME OPTIONAL
*" EXPORTING
*" VALUE(ET_URLNAME) TYPE STRING
*" VALUE(ET_RETURN) LIKE BAPIRETURN STRUCTURE BAPIRETURN
*"----------------------------------------------------------------------
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.
IF P_USERNAME IS NOT INITIAL.
CONCATENATE 'http://90.0.4.100:8080/emp_dev/eva_quiz_user1.jsp?username=' P_USERNAME INTO ET_URLNAME.
else.
clear: message.
message-msgty = 'E'.
message-msgid = 'ZZ'.
message-msgno = '000'.
message-msgv1 = 'Username shouldnot be blank'.
PERFORM set_return_message USING message
CHANGING et_return.
ENDIF.
ENDFUNCTION.
FORM set_return_message USING value(p_message) LIKE message
CHANGING p_return LIKE bapireturn.
CHECK message IS NOT 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
only_2_char_for_message_id = 1
OTHERS = 2.
ENDFORM. "set_return_message
‎2008 Apr 16 11:59 AM
Try with a CHAR255 instead of string.
Regards,
Ravi kanth talagana
‎2008 Apr 16 12:04 PM
I am getting following error again.
Data type CHAR255 cannot be used for methods.
BAPI : Method does not define a RETURN parameter.
‎2008 Apr 16 12:51 PM
Hello Anee
I assume that you have registered your BAPI as method in the BOR and therefore you get these error messages.
Why data element CHAR255 is rejected I cannot tell you.
However, The second error message implies that you either have to rename your RETURN parameter (into RETURN) or you have not defined this EXPORTING parameter as RETURN parameter in the BOR settings. Each BAPI must have such a RETURN parameter.
Final remark: change the naming of the BAPI parameter to make their structure and function more transparent.
FUNCTION ZBAPI_URL_PASSING .
*"----------------------------------------------------------------------
*"*"Local Interface:
*" IMPORTING
*" VALUE(ID_USERNAME) TYPE SYST-UNAME OPTIONAL
*" EXPORTING
*" VALUE(ED_URLNAME) TYPE STRING
*" VALUE(ES_RETURN) LIKE BAPIRETURN STRUCTURE BAPIRETURN
*"----------------------------------------------------------------------
" NOTE:
" ID_ : I=importing, D=single data field
" ED_: E=exporting, D=single data field
" ES_:E=exporting, S=structure
Regards
Uwe
‎2008 Apr 16 1:16 PM
While adding in API Method its giving me following warning.
where as i added return as export.
BAPI &1: BAPI function module &2 has no return parameter.
when i proceed into next step.following error popup is coming.
ERROR:
Data type CHAR255 cannot be used for methods.
BAPI : Method does not define a RETURN parameter
complete revised code as
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 USING value(p_message) LIKE message
CHANGING p_return LIKE bapireturn.
CHECK message IS NOT 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
only_2_char_for_message_id = 1
OTHERS = 2.
ENDFORM. "set_return_message FUNCTION ZBAPI_URL_PASSING .
*"----------------------------------------------------------------------
*"*"Local Interface:
*" IMPORTING
*" VALUE(ID_USERNAME) TYPE SYST-UNAME OPTIONAL
*" EXPORTING
*" VALUE(ED_URLNAME) TYPE CHAR255
*" VALUE(ES_RETURN) LIKE BAPIRETURN STRUCTURE BAPIRETURN
*"----------------------------------------------------------------------
IF ID_USERNAME IS NOT INITIAL.
CONCATENATE 'http://90.0.4.100:8080/emp_dev/eva_quiz_user1.jsp?username=' ID_USERNAME INTO ED_URLNAME.
else.
clear: message.
message-msgty = 'E'.
message-msgid = 'ZZ'.
message-msgno = '000'.
message-msgv1 = 'Username shouldnot be blank'.
PERFORM set_return_message USING message
CHANGING ES_RETURN.
ENDIF.
ENDFUNCTION.
‎2008 Apr 16 1:27 PM
Hello Anee
Please validate your settings against the recommendations of the long text for message S&(537):
NA S&537
____________________________________________________
Short Text
BAPI &1: BAPI function module &2 has no return parameter
Diagnosis
The system checks that the RETURN parameter has been defined in both the
BOR and in the function module. The parameter must refer to one of the
BAPI return structures (all planned reference structures can be used for
BAPIs up to and including Release 4.6B; but from Release 4.6C only
BAPIRET2 can be used).
The BOR parameter must be type EXPORT (one line or multi-line) and the
function module parameter must be type EXPORT (if one line) or type
TABLE (if multi-line).
Procedure
Create a RETURN parameter for the function module. Also define the
reference of the BOR parameters to the function module parameter in the
BOR ("Name in function module").
Note that only incompatible changes can be made to BAPIs already
released and delivered.
Find out about enhancing or modifying BAPIs that have already been
delivered by calling the BAPI Explorer (Tools -> BusinessFramework ->
BAPI Explorer) and reading the project form "Project to change an
existing BAPI".
Further notes
For more information see the BAPI Programming Guide in the SAP Library
under CA-BFA.
Regards
Uwe