2005 Dec 14 2:24 PM
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.
2005 Dec 14 2:27 PM
[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
2005 Dec 14 2:27 PM
[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
2005 Dec 14 2:29 PM
It is a little bit too complicated for me. Do you think you can begin to explain what the code I write mean?
2005 Dec 14 2:39 PM
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
2005 Dec 14 2:31 PM
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
2005 Dec 14 2:38 PM
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.
2005 Dec 14 2:43 PM
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?
2005 Dec 14 2:50 PM
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
2005 Dec 14 2:52 PM
2005 Dec 14 3:00 PM
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.
2005 Dec 14 3:03 PM
2005 Dec 14 3:04 PM
I think the best way for you is the tip of Rich. FM MESSAGE_PREPARE.
Alexandre Nogueira.
2005 Dec 14 3:10 PM
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
2005 Dec 14 2:41 PM
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