Application Development 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: 

FORMAT_MESSAGE

Former Member
0 Kudos

Hi,

what is the use of FM "FORMAT_MESSAGE"?

regards

BAlu

3 REPLIES 3

Former Member
0 Kudos

HI,

this function module is for for constructing a message by using the message class,message number and message variables.


  CALL FUNCTION 'FORMAT_MESSAGE'
    EXPORTING
      id      = it_messtab-msgid
      lang   = it_messtab-msgspra
      no     = it_messtab-msgnr
      v1     = it_messtab-msgv1
      v2     = it_messtab-msgv2
      v3     =  it_messtab-msgv3
      v4     =  it_messtab-msgv4
    IMPORTING
    msg    =  g_msg
  EXCEPTIONS
      OTHERS = 0. 

suppose here u r passing id(msg class) ZMSG_CLS and message number 000 it will read that message and place it in g_msg(imorting parameter) by replacing &1,&2,&3 and &4 in the message by it_messtab-msgv1, it_messtab-msgv2, it_messtab-msgv3 and it_messtab-msgv4(these variables we are exporting above) respectively

rgds,

bharat.

Former Member
0 Kudos

Hi Balu,

Using function module 'FORMAT_MESSAGE' you can capture the messages.

Here is a sample of the program code for that:

LOOP AT it_messtab.

CALL FUNCTION 'FORMAT_MESSAGE'

EXPORTING

id = it_messtab-msgid

lang = it_messtab-msgspra

no = it_messtab-msgnr

v1 = it_messtab-msgv1

v2 = it_messtab-msgv2

IMPORTING

msg = g_msg

EXCEPTIONS

OTHERS = 0.

IF it_messtab-msgtyp = 'S'.

it_sucess-sucess_rec = g_msg.

it_sucess-lifnr = it_header-lifnr." Based on your field

it_sucess-tabix = v_lines.

APPEND it_sucess.

ELSEIF it_messtab-msgtyp = 'E'.

it_error-error_rec = g_msg.

it_error-lifnr = it_header-lifnr.

it_error-tabix = v_lines.

APPEND it_error.

ELSE.

it_info-info_rec = g_msg.

it_info-lifnr = it_header-lifnr.

it_info-tabix = v_lines.

APPEND it_info.

ENDIF.

ENDLOOP.

Reward if helpful.

Thankyou,

Regards.

Former Member
0 Kudos