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: 

Message

Former Member
0 Kudos

I want to do something like the thing below but want to use an other table (EDIDS) with the fields STATXT, STAPA1, STAPA2, STAPA3, STAPA3. I am not really sure what the program below does and how to use it in my case. Can anyone please explain the code below and how I can use it?

MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno

WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4

INTO gv_msgtext.

1 ACCEPTED SOLUTION

former_member188685
Active Contributor
0 Kudos

[code] CLEAR IT_MESG.REFRESH IT_MESG.

DATA: T100 TYPE T100,

BUFFER(273).

LOOP AT IT_EDIDS INTO X_EDIDS WHERE STATUS = C_51.

SELECT SINGLE * FROM T100 INTO T100

WHERE SPRSL = SY-LANGU

AND ARBGB = X_EDIDS-STAMID

AND MSGNR = X_EDIDS-STAMNO.

IF SY-SUBRC = 0.

BUFFER = T100-TEXT.

ELSE.

BUFFER = TEXT-M00.

ENDIF.

  • at first &1/&2/&3/&4 or. $1/$2/$3/$4 replace

IF T100-TEXT CA '$1'.

REPLACE '$1' WITH X_EDIDS-STAPA1 INTO BUFFER.

ENDIF.

IF T100-TEXT CA '$2'.

REPLACE '$2' WITH X_EDIDS-STAPA2 INTO BUFFER.

ENDIF.

IF T100-TEXT CA '$3'.

REPLACE '$3' WITH X_EDIDS-STAPA3 INTO BUFFER.

ENDIF.

IF T100-TEXT CA '$4'.

REPLACE '$4' WITH X_EDIDS-STAPA4 INTO BUFFER.

ENDIF.

IF T100-TEXT CA '&1'.

REPLACE '&1' WITH X_EDIDS-STAPA1 INTO BUFFER.

ENDIF.

IF T100-TEXT CA '&2'.

REPLACE '&2' WITH X_EDIDS-STAPA2 INTO BUFFER.

ENDIF.

IF T100-TEXT CA '&3'.

REPLACE '&3' WITH X_EDIDS-STAPA3 INTO BUFFER.

ENDIF.

IF T100-TEXT CA '&4'.

REPLACE '&4' WITH X_EDIDS-STAPA4 INTO BUFFER.

ENDIF.

IF T100-TEXT CA '$'.

REPLACE '$' WITH X_EDIDS-STAPA1 INTO BUFFER.

REPLACE '$' WITH X_EDIDS-STAPA2 INTO BUFFER.

REPLACE '$' WITH X_EDIDS-STAPA3 INTO BUFFER.

REPLACE '$' WITH X_EDIDS-STAPA4 INTO BUFFER.

ENDIF.

IF T100-TEXT CA '&'.

REPLACE '&' WITH X_EDIDS-STAPA1 INTO BUFFER.

REPLACE '&' WITH X_EDIDS-STAPA2 INTO BUFFER.

REPLACE '&' WITH X_EDIDS-STAPA3 INTO BUFFER.

REPLACE '&' WITH X_EDIDS-STAPA4 INTO BUFFER.

ENDIF.

CONDENSE BUFFER.

MOVE BUFFER TO X_MESG.

APPEND X_MESG TO IT_MESG.

CLEAR X_MESG.

ENDLOOP.[/code]

please reward if it helps....

regards

vijay

13 REPLIES 13

former_member188685
Active Contributor
0 Kudos

[code] CLEAR IT_MESG.REFRESH IT_MESG.

DATA: T100 TYPE T100,

BUFFER(273).

LOOP AT IT_EDIDS INTO X_EDIDS WHERE STATUS = C_51.

SELECT SINGLE * FROM T100 INTO T100

WHERE SPRSL = SY-LANGU

AND ARBGB = X_EDIDS-STAMID

AND MSGNR = X_EDIDS-STAMNO.

IF SY-SUBRC = 0.

BUFFER = T100-TEXT.

ELSE.

BUFFER = TEXT-M00.

ENDIF.

  • at first &1/&2/&3/&4 or. $1/$2/$3/$4 replace

IF T100-TEXT CA '$1'.

REPLACE '$1' WITH X_EDIDS-STAPA1 INTO BUFFER.

ENDIF.

IF T100-TEXT CA '$2'.

REPLACE '$2' WITH X_EDIDS-STAPA2 INTO BUFFER.

ENDIF.

IF T100-TEXT CA '$3'.

REPLACE '$3' WITH X_EDIDS-STAPA3 INTO BUFFER.

ENDIF.

IF T100-TEXT CA '$4'.

REPLACE '$4' WITH X_EDIDS-STAPA4 INTO BUFFER.

ENDIF.

IF T100-TEXT CA '&1'.

REPLACE '&1' WITH X_EDIDS-STAPA1 INTO BUFFER.

ENDIF.

IF T100-TEXT CA '&2'.

REPLACE '&2' WITH X_EDIDS-STAPA2 INTO BUFFER.

ENDIF.

IF T100-TEXT CA '&3'.

REPLACE '&3' WITH X_EDIDS-STAPA3 INTO BUFFER.

ENDIF.

IF T100-TEXT CA '&4'.

REPLACE '&4' WITH X_EDIDS-STAPA4 INTO BUFFER.

ENDIF.

IF T100-TEXT CA '$'.

REPLACE '$' WITH X_EDIDS-STAPA1 INTO BUFFER.

REPLACE '$' WITH X_EDIDS-STAPA2 INTO BUFFER.

REPLACE '$' WITH X_EDIDS-STAPA3 INTO BUFFER.

REPLACE '$' WITH X_EDIDS-STAPA4 INTO BUFFER.

ENDIF.

IF T100-TEXT CA '&'.

REPLACE '&' WITH X_EDIDS-STAPA1 INTO BUFFER.

REPLACE '&' WITH X_EDIDS-STAPA2 INTO BUFFER.

REPLACE '&' WITH X_EDIDS-STAPA3 INTO BUFFER.

REPLACE '&' WITH X_EDIDS-STAPA4 INTO BUFFER.

ENDIF.

CONDENSE BUFFER.

MOVE BUFFER TO X_MESG.

APPEND X_MESG TO IT_MESG.

CLEAR X_MESG.

ENDLOOP.[/code]

please reward if it helps....

regards

vijay

0 Kudos

It is a little bit too complicated for me. Do you think you can begin to explain what the code I write mean?

0 Kudos

hi

what i did is i am displaying 51 status messages.

i am not able to capture the messages, i saw in table t100 all are $, &, palce holders..

sso i found this logic and replaced with the messages..

first loop the status table, and then select the record from t100 passing language,id,number and i will get the text, but in different format, to convert that i used 273 chars field and replaced it and concatenated the data to message table...

if any thing you just let me know...

i used for my requirement to capture all messages(with status 51)

regards

vijay

RichHeilman
Developer Advocate
Developer Advocate
0 Kudos

In some cases, programs fill those SY- fields with values and the message is issued. In you case, I would suggest using the function module MESSAGE_PREPARE to build you message text.

You can substitute your fields in the following function module. This will fill all of the variables in your message and give it back in the MESSAGE field



data: message(100) type c.

  call function 'MESSAGE_PREPARE'
       exporting
            language = sy-langu
            msg_id   = iEDIDS-STAMID   
            msg_no   = iEDIDS-STAMNO
            msg_var1 = iedids-STAPA1
            msg_var2 = iedids-STAPA2
            msg_var3 = iedids-STAPA3
            msg_var4 = iedids-STAPA4
       importing
            msg_text = message.


REgards,

Rich Heilman

Former Member
0 Kudos

Hi,

SY-MSGID => It is the message class name.

The class name that was defined using SE91.

SY-MSGTYP => It defines the types of messages like

W -> Warning message,

E -> Error Message,

I -> Information Message

A -> Abort message etc

SY-MSGNO => It is the message number that was defined

in the message class above created.

SY-MSGV1,MSGV2,MSGV3 => These are the variables from program point and Place holders that are defined in the SY-MSGNO. These variables information can be generated dynamically. Instead of those MSGV1,MSGV2... you can consider STATXT,STAPA1,STAPA2,STAPA3. But the Message Number(MSGNO) should have those many place holders.

gv_msgtext => the above content of values are passed into a text(gv_msgtext) as string with a meaning ful

sentence.

I hope it clears you .

Regards,

Gopinath Addepalli.

0 Kudos

Very good answear. But I really do not understand how I should do. Must I create a new message class or something or define anything?

0 Kudos

nothing needed,

select the records from edids which satisfies your condition.(in my case 51).

loop that table and

for each record select from t100

by passing lang,id,messageno from satus table and get the placeholders and replace the place holders and populate the messages to one message table.

if you want to know any thing please let me know...

regards

vijay

0 Kudos

Am I missing something here, wouldn't it be easier to call the function module MESSAGE_PREPARE to build the message with variables?

Regards,

Rich Heilman

0 Kudos

I really want to use the code I wrote but on my case. I do not know what is the best way, but that is the way I should do it.

0 Kudos

You have a message class, message number, and 4 variables. You problem is that you want to get the text of the message and put the variables into the message itself? Is this right? If so, then use MESSAGE_PREPARE, it does it all for you.

Regards,

Rich Heilman

0 Kudos

I think the best way for you is the tip of Rich. FM MESSAGE_PREPARE.

Alexandre Nogueira.

0 Kudos

i feel this is simpler.

LOOP AT IT_EDIDS INTO X_EDIDS WHERE STATUS = C_51.
      SELECT SINGLE * FROM T100 INTO T100
                                WHERE SPRSL = SY-LANGU
                                AND   ARBGB = X_EDIDS-STAMID
                                AND   MSGNR = X_EDIDS-STAMNO.

upto this any way you need to do, and after that any way the same logic will be executed by the FM MESSAGE_PREPARE.

so choose the code/fm any one will do..

choosing fm look will be good, but inside logic is the one which i mentioned..

regards

vijay

former_member188685
Active Contributor
0 Kudos

Since you are also using to display IDoc messages this is the best possible solution...

using that you can get the messages....

check it once..

regards

vijay