Application Development and Automation 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: 
Read only

Trigger a process(IDOC) when Data in Z-table updated

Former Member
0 Likes
1,885

Hi All,

I am working on an interface and the outbound IDOC from R/3 to XI needs to be triggered when a particular field value in a Z*table changes.

So far I am able to trigger the IDOC from the calling Z*prog which updates this table, but I need some exit, PAI etc which will get triggered only when the data in table is updated.

Current Flow chart:
Z-prog starts--->Updates a Z-table--->if sy-subrc=0--->I create an IDOC from the Z-prog itself

What I need:
Z-table is updated--->check if particular filed value changed--->Trigger IDOC

Is it possible to do this.

Many thanks

Shirin

1 ACCEPTED SOLUTION
Read only

ThomasZloch
Active Contributor
0 Likes
1,178

What process is updating the Z-Table?

SM30 maintenance? Then you can use table maintenance events.

Another Z-program? Then you can include the check and trigger there.

A standard SAP application? There is probably a user exit which can be used.

Unsure? Then you'll have to poll the table contents every x minutes and see if anything has changed...

Thomas

5 REPLIES 5
Read only

ThomasZloch
Active Contributor
0 Likes
1,179

What process is updating the Z-Table?

SM30 maintenance? Then you can use table maintenance events.

Another Z-program? Then you can include the check and trigger there.

A standard SAP application? There is probably a user exit which can be used.

Unsure? Then you'll have to poll the table contents every x minutes and see if anything has changed...

Thomas

Read only

0 Likes
1,178

Hi Thomas,

Thanks for the quick response. Yes it is possible to do it the way you have mentioned. In my case from Z-program.

I was wondering if its possible to trigger the idoc directly whenever table data is updated. Update could either be from a z-program/sm30 or through SE11-debug mode.

Quick one, will SM30 events as mentioned in ur mail, get triggered even if I update the table from a Z-program ?

Many thanks

Shirin

Read only

0 Likes
1,178

> I was wondering if its possible to trigger the idoc directly whenever table data is updated. Update could either be from a z-program/sm30 or through SE11-debug mode.

I can't think of a point where you could attach the required custom logic. Maybe somebody else can?

> will SM30 events as mentioned in ur mail, get triggered even if I update the table from a Z-program ?

I'm afraid, no.

Thomas

Read only

Former Member
0 Likes
1,178

Hi Shirin,

As my requirement is also similar to urs, working on an interface and the outbound IDOC from ECC 6.0 to XI needs to be triggered whenever table is updated(ztransaction saved). Can U share the code pls.

rgds,

balu

Read only

0 Likes
1,178

Hi Balu,

I am triggering my IDOCS from the Z*program itself.

The trigger point is when I have successfully updated the table (sy-subrc = 0).

Then I have used the code below to populate my IDOC. I have also maintained a distribution model, so that is the reason I pass only the idoc type in edidc segment and do not pass any port , receiver etc.

Hope you find the code useful.

Regards

Shirin

Reward points if this was helpful.


***********************
*Local Data Declaration
***********************
  DATA:  wa_msg_header TYPE zca_msg_header,
         wa_edidc      TYPE edidc,
         wa_edidd      TYPE edidd,
         i_edidc       TYPE edidc OCCURS 0,
         i_edidd       TYPE edidd OCCURS 0,
         wa_trailer    TYPE zca_gs_trailer,
         wa_count(10)  TYPE n,
         wa_allocation_response TYPE zca_allocation_response.

***********************
*Populate IDOC segments
***********************
* 1. Save the message type and the basic IDoc type* in the control segment
  MOVE 'ZMT_ALLOCATION_RESPONSE' TO wa_edidc-mestyp.
  MOVE 'ZGS_ALLOCATION_RESPONSE' TO wa_edidc-idoctp.


* 2. Populate the Genius specific Message Header 'ZCA_MSG_HEADER'
  wa_msg_header-source        = 'SOURCE_SYST'.
  wa_msg_header-destination   = 'DESTINATION-LS.
  wa_msg_header-message_id    = ''.  "Populate this in XI
  wa_msg_header-date_time     = ''.  "populate this in xi.
  wa_msg_header-message_typ   = 'I'.
  wa_msg_header-status        = 'S'.

  MOVE 'ZCA_MSG_HEADER' TO wa_edidd-segnam.
  MOVE wa_msg_header    TO wa_edidd-sdata.
  APPEND wa_edidd       TO i_edidd.
  CLEAR wa_edidd.

* 3 Populate the ALOCATION_RESPONSE segment
  CONCATENATE 'EXAM'
               sy-datum
               sy-uzeit
               INTO
               wa_allocation_response-uid.
* wa_allocation_response-uid                 =  i_set_number  .
  wa_allocation_response-set_number          =  i_set_number .
  wa_allocation_response-trigger             =  '1' .              "Always default to Allocation Change   .
  wa_allocation_response-next_a_exam         =  i_next_a_exam .
  wa_allocation_response-miles_to_a          =  i_miles_to_a .
  wa_allocation_response-next_b_exam         =  i_next_b_exam .
  wa_allocation_response-miles_to_b          =  i_miles_to_b.
  wa_allocation_response-next_major_exam     =  i_next_maj_exam  .
  wa_allocation_response-miles_to_major_exam =  i_miles_to_maj_exam .

  MOVE  'ZCA_ALLOCATION_RESPONSE' TO wa_edidd-segnam.
  MOVE   wa_allocation_response   TO wa_edidd-sdata.
  APPEND wa_edidd                 TO i_edidd.
  CLEAR  wa_edidd.

*4 Populate the Trailer record 'ZCA_TRAILER'
  wa_trailer-data_marker  = 'T'.
  wa_trailer-checksum     = wa_count.

  MOVE 'ZCA_TRAILER' TO wa_edidd-segnam.
  MOVE wa_trailer       TO wa_edidd-sdata.
  APPEND wa_edidd       TO i_edidd.
  CLEAR  wa_edidd.

* Check for distribution model and create the IDOC
  CALL FUNCTION 'MASTER_IDOC_DISTRIBUTE'
    EXPORTING
      master_idoc_control            = wa_edidc
    TABLES
      communication_idoc_control     = i_edidc
      master_idoc_data               = i_edidd
    EXCEPTIONS
      error_in_idoc_control          = 1
      error_writing_idoc_status      = 2
      error_in_idoc_data             = 3
      sending_logical_system_unknown = 4
      OTHERS                         = 5.

* No need for error handling here as the IDOC will be created and ststus record will
* mention the latest ststus including any error message.