14.01.2020 Views

ABAP_to_the_Future

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

14

Shared Memory

IF sy-subrc <> 0.

"At least remove the material on this server

CALL FUNCTION 'ZMM_SHM_INVALIDATE_MATERIAL'

EXPORTING

id_material = i_mara_new-matnr.

CONTINUE.

ENDIF.

ENDLOOP."Application Servers

Listing 14.9 User Exit on Material Save

The code in Listing 14.9 finds all the ap plication servers on the system and then

loops through them, each time performing an RFC to tell the application server to

update the shared memory object. If the program gets into trouble deleting a single

record, then it invalidates the whole area. In this way, the program can ensure

that when a record is changed, the change is propagated to all application servers.

Once again, this code does not directly change the data; it only deletes a record so

that it gets reloaded on the next read request.

Note

Cynics will still say that you’re going through a lot of effort to manually replicate what

SAP does in the normal course of events for buffered tables, which is why buffering

tables is still the preferred option if possible. Nonetheless, there are some situations

where table buffering just does not cut the mustard and shared memory neatly fills that

gap. (You will also notice that if there is some sort of massive system failure, then the

propagation will not work—but in such an event, this would be the least of your worries.)

You may recall that in Section 2.10 of Chapter 2 we talked about a new feature in

ABAP 7.4 called ABAP Messaging Channels, which sends messages between

application servers. This facility would seem ideally suited to shared objects,

because the object instances on the appl ication servers could send messages to

each other whenever one of them has i ts data changed. You would most likely

still want to delete the records in the other servers.

14.4.2 Short Dumps

When you use a new technology and ge t unexplained short dumps all over the

place, it can put you off in a hurry. All of the examples in this chapter have been

following the SAP party line, and when they cannot instantly attach a shared

652

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!