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

Handling 2 messages in a function module

Former Member
0 Likes
1,402

Hi ,

I have a requirement where I need to trigger 2 messages if sy-subrc fails in a Function Module.

-


Function module GET_JOB_RUNTIME_INFO

IMPORTING

JOB名(JOBNAME)= P_WK_JOBNM

Error(SY-SUBRC <> 0)

Result message output

(EN) Total : &1, Success : &2, Error : &3

Type: u2019Su2019

&1:u20190u2019 &2:u20190u2019 &3:u20190u2019

Perform error handling(->Error Handling:030)

-


Error Handling 30: Error Handling as ABEND

Show message (message type u2018Eu2019)

(EN)Error was found in function module. Function module: &1 Returned value: &2 &3

&1:'GET_JOB_RUNTIME_INFO'

&2: Exception No

I have written the code in the following way.

CALL FUNCTION 'GET_JOB_RUNTIME_INFO'

IMPORTING

  • EVENTID =

  • EVENTPARM =

  • EXTERNAL_PROGRAM_ACTIVE =

  • JOBCOUNT =

JOBNAME = l_job_name

  • STEPCOUNT =

EXCEPTIONS

NO_RUNTIME_INFO = 1

OTHERS = 2

.

IF sy-subrc <> 0.

message s010(zmm) with c_zero c_zero c_zero.

message e001(zmm) display like 'A'.

ENDIF.

But the above code is not working fine. Only the second message ie [message e001(zmm) display like 'A' ] is being displayed.

In debugging mode the cursor is passing to the first message but still it is not being displayed.

Can any one help me in solving this problem

Thanks in advance,

Indira

8 REPLIES 8
Read only

Former Member
0 Likes
1,275

First message is getting overlapped with the second message.

Try to combine the two messages into one.

Read only

0 Likes
1,275

Hi Harsh,

Thanks for replying. But I can not concatenate the two messages. Both the messages are to be displayed individually.

Read only

Former Member
0 Likes
1,275

Both the Messages have to be triggered independently.

Read only

0 Likes
1,275

Hi,

As you need to display multiple messages, declare a table parameters of type BAPIRET2 and append the messages to this table parameter.

Regards,

Swarna Munukoti.

Read only

0 Likes
1,275

Hi,

Thanks for the reply.

But how can I pass the place holders to Bapiret2 structure

Read only

0 Likes
1,275

Hi,

Use this function Module:

CALL FUNCTION 'BALW_BAPIRETURN_GET2'

EXPORTING

TYPE = <Message Type - E or S>

CL = <Mesage Class>

NUMBER = <Message Number>

PAR1 = <variable1>

PAR2 = <variable2>

PAR3 = <variable3>

PAR4 = <variable4>

IMPORTING

RETURN = return_msg

.

return_msg is of type BAPIRET2

Regards,

Swarna Munukoti

Read only

Former Member
0 Likes
1,275

Hi,

Change the first message type from S to I.

IF sy-subrc 0.

message i010(zmm) with c_zero c_zero c_zero.

message e001(zmm) display like 'A'.

ENDIF.

Regards,

Ginu

Read only

kesavadas_thekkillath
Active Contributor
0 Likes
1,275

check this sample code

here gt_return is of type bapiret2_t




    MOVE <fs_bank_details>-bankkey TO gv_msg_par1. 
    MOVE <fs_bank_details>-bankname TO gv_msg_par2.
    PERFORM fm_format_message USING gc_msgno083
                                    gc_e.


FORM fm_format_message  USING    pv_msgno TYPE sy-msgno
                                 pv_type TYPE bapi_mtype.

  DATA:ls_return TYPE bapiret2.

  CLEAR: ls_return.

  CALL FUNCTION 'BALW_BAPIRETURN_GET2'
    EXPORTING
      type   = pv_type   "Message type
      cl     = gc_bp     "Message class
      number = pv_msgno  "Message No
      par1   = gv_msg_par1 "value for place holder1
      par2   = gv_msg_par2 "value for place holder2
    IMPORTING
      return = ls_return.

  IF ls_return IS NOT INITIAL.
    APPEND ls_return TO gt_return.
  ENDIF.

ENDFORM.                    " FM_FORMAT_MESSAGE