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: 

BAPI - Funtion module

devika1989
Discoverer
0 Kudos
633

Hi Experrts ,

I am doing an function module to get an data with Import parameters to get an oiutput parameters .

Here, If data saved in table ( will display the output in ET_return_04) , but If data NOT saved in table 'Error message as NO DATA RECORD' .Here i am getting both output parameters.

My requirement was 'If Success need to show ET_return_04(data) only and if Error message show the 'Message' only

How to achieve it..

 IF foreign_country IS NOT INITIAL.

    SELECT zm_country_name FROM zmm_foreign_cou INTO TABLE @DATA(lt_foreign)
        WHERE zm_country_code EQ @foreign_country-zm_country_code.
    IF lt_foreign IS NOT INITIAL .
      MOVE-CORRESPONDING lt_foreign TO et_return_04.
    ELSEIF lt_foreign IS INITIAL.
      MESSAGE 'No data found' TYPE 'E'.
    ENDIF.
  ENDIF.<br>
4 REPLIES 4

Sandra_Rossi
Active Contributor
535

You can't, both parameters are always returned.

The requirement is not about the function module itself, it's about the CALLING PROGRAM, what it should do with the returned parameters.

CALL FUNCTION '???'
  IMPORTING
    et_return_04 = et_return_04
    message      = message.
IF message IS INITIAL.
  " If Success need to show ET_return_04(data) only 
ELSE.
  " and if Error message show the 'Message' only
ENDIF.

devika1989
Discoverer
0 Kudos
535

Thanks response sandra.rossi.

I now , how to raise an error message.

But my requirement was

1.' If its success (Data saved in table) need to show the ET_RETURN Parameter.

2. I Error message (Date not saved in table) need to show the return message as 'No Data record found'.

But here if its is Success / Error both Parameter display (This should not appears)

Can we do this?

manfred_reinart
Product and Topic Expert
Product and Topic Expert
535

Please elaborate what you mean by 'need to show' and 'both Parameter display'.

As both parameters are part of the defined signature they are of course visible.

It is up to the caller to interpret them.

Sandra_Rossi
Active Contributor
535

Yes, please elaborate.

By the way, you do it incorrectly in your function module, maybe it's what is confusing you:

MESSAGE 'No data found' TYPE 'E'.

If the parameter MESSAGE is of type STRING or any type like CLIKE or less generic), it could be:

MESSAGE e001(00) WITH 'No data found'(001) '' '' '' INTO message.

(message 00001 is &1&2&3...)

I hope you understand now.