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: 

How to get message in realtime sent by another user using FM TH_POPUP?

Former Member
0 Kudos

I want to create a chat function between two SAP users.

1.User A send a message to user B by using TH_POPUP,

At the same time, the message is showed in screen as

'Send message'

2.User B get the message

->My problem is how to get the message in realtime which I want to show it in screen as 'Received message'.

Can anybody tell me how to get the message sent by using FM TH_POPUP in realtime?

7 REPLIES 7

Former Member
0 Kudos

Jing,

see the code

REPORT ZPOPUP .

**********************************************************

  • This program sends a message in a popup window to the

  • screens of the logged on users. This method is better,

  • then the SAP system message function, because the popup

  • window appears immediately (no dialog step is required),

  • and better, then the express mail method (the user can

  • not avoid it, no dialog step)

**********************************************************

DATA: MESSAGE(128) VALUE 'Test message'.

DATA: OPCODE TYPE X VALUE 2.

DATA: BEGIN OF USR_TABL OCCURS 10.

INCLUDE STRUCTURE UINFO.

DATA: END OF USR_TABL.

CALL 'ThUsrInfo' ID 'OPCODE' FIELD OPCODE

ID 'TAB' FIELD USR_TABL-SYS.

LOOP AT USR_TABL.

CALL FUNCTION 'TH_POPUP'

EXPORTING

CLIENT = SY-MANDT

USER = USR_TABL-BNAME

MESSAGE = MESSAGE

EXCEPTIONS

USER_NOT_FOUND = 1.

ENDLOOP.

Don't forget to reward if useful...

0 Kudos

thanks for your reply.

But what I want to do is,

User A and B execute the same program like "Z_CHAT" to chat.In the program 'Z_CHAT' FM TH_POPUP is used to send message.

1. A send a message 'Hello' to B

2. Message 'Hello' is popup to user B, and at the same time 'Hello' will be catched by program 'Z_CHAT' and displayed in screen. So after closed POPUP window , User B can find the message in the screen of 'Z_CHAT'

0 Kudos

One of the problems here is that each user in dialog mode is running essentially a totally separate process in a different address space.

I think the only way you could get something like this to work is to use some sort of central kernel module using a central memory area -- not a good idea for an application program really to have this type of access to what should be protected Operating System areas.

If you look at the code from transaction SM02 (System messages) program SAPMSEM1 you might be able to "clone" something . You could perhaps have something like a "mini-server" program running in the background to which users can send and receive messages - but if you crash your system - then that's your own affair.

You might also be able to use some part of the standard SAP send express mail where you receive a message on the screen and the note goes in the inbox. (transaction SBWP).

For chatting with users --especially if you are using Windows IMO there are zillions of better methods using Windows functionality instead.

Cheers

Jimbo

Former Member
0 Kudos

Hi There,

When u use the FM 'TH_POPUP' the other user will get a popup on his/her screen with the message.

Here is how u can use the FM.

In SE37, execute the FM TH_POPUP and enter the following details:

1. RFC Target System- Standard name of an RFC destination of the reciever system (user B system)

2. CLIENT- Client on which User B is logged in

3. USER- Login ID of User B

4. MESSAGE - message text u want to send to user B

After entering these details just execute!

Hope it helps.

Regards,

Sonal

0 Kudos

Hi there

This really isn't a "conversation" type program

1) What does the original user do after sending the message -- I'm not sure if there's a WAIT_FOR_REPLY and even if there were I'm not sure you'd want the original user to have a suspended session waiting for a reply.

2) What does the 2nd user do after receiving the message --if it's just thrown up on his screen then there isn't any mechanism to return a reply from USER A'S SESSION.

You need somehow to have a continually running process which will send a message for example to user B and create an event or do somethimg so that User B is bound to the same session that sends the original message.

2 different users running the same abap don't actually have any common link between them even on remote function calls.

You need to have a central process here that shares a message space between the users (i.e a kernel type module).

Classical Abap won't do (nor is it designed for) these types of processes.

You might be able to find something in some of the 'C' coded kernel calls but as I previously posted before you are far better off using Windows for this type of stuff. (Windows Messenger for example).

ABAP unfortunately is not designed as a multi user "re-entrant" programming language - nor was it intended to be.

Another possible get around is to use the workflow system. User A sends a message which raises an event. This then starts a workflow which transmits say message to user B and notifies him of a message waiting for him. User B can reply which again raises an event and triggers workflow routing the message / reply back to user A.

The response time won't be very good but at least it will work without tying up 2 user dialog sessions - but seriously guys I'd give up on this and just use Windows Messenger or equivalent system.

These type of programs depend on a central server for the message handling - you'd have to replicate this in ABAP -- and Im 120% sure it can't be done.

Cheers

Cheers

0 Kudos

Hi james, thanks for your reply.

For some reasons,I can't use any Chat soft,

and only SAP is connected between users.

so I try to create it by using ABAP.

As you said, I can't do it in realtime,

but I found a near-realtime way.

My solution is,

1.Use a Z-table to save message

2.Use GUI_TIMER to check the table every second

3.If new received message exist, display it in the screen.

Best Regards.

0 Kudos

Hi,

There is a chat as a Web Dynpro ABAP application : WDR_TEST_CHAT.

I am sure it will save you a lot of time (well, or not actually !).

Best regards,

Guillaume