cancel
Showing results for 
Search instead for 
Did you mean: 

How to pass value from EXIT to method

vijy_mukunthan
Active Contributor
0 Kudos

Hi friends

1) My requirement is that when the person change the amount field in TRIP t-code i need to send a mail to the manager. So i found a exit FIT0002 here when ever the traveler change the amount i am setting the flag as x when he change and y when no amount is changed in exit. I did export to memory id and in my method i did import from memory id. But this is not performing gud. If at a time many users apply the trip and changes the advance the flag is not getting set. I checked in the log. No flag is set its empty no x nor y. After clearing the buffer SWU_OBUF. Again all the users applied the trip then the flag is set and every manager got the mail. But why this is happening?. Is there any other way to achieve it. I want to get the flag value to my method. Is there any other work around.

2) I tried with SAP_WAPI_WRITE_CONTAINER directly getting the value and writing to the workflow container its not correct way since i need to write commit work. But the exit itself does commit.

3) I tried with SET/GET parameter but i don't no how to divert my flow from my method to exit when i use SET/GET parameters.

Can any one throw some light on this issue.

Regards

vijay

Accepted Solutions (1)

Accepted Solutions (1)

surjith_kumar
Active Contributor
0 Kudos

Hi,

Don't Use Export memory, for Travel, Many people will access so this won't work fine.

You better refer the database, in the user exit are you able to get emp. Pernr , Trip no. & current Amount. If yes, fetch the previous amount from the Table and check it and send the email.

Regards,

Surjith

vijy_mukunthan
Active Contributor
0 Kudos

Hi surjit

In my workflow ultimately i am setting the flag. I dont worry about the how much amount he has entered. I want to know only he has entered amount or not. In that exit there is table parameter were i can compare the amounts if the amount is different am setting the flag. This is my code in the exit

DATA : SUM LIKE FTPT_REQ_ADVANCE-VORSC,

ADVANCE LIKE PTRV_SHDR,

FLAG TYPE C.

DATA : KEY(35) TYPE C.

SELECT SUM( VORSC ) FROM FTPT_REQ_ADVANCE INTO SUM

WHERE PERNR = PERSONNEL_NUMBER AND REINR = TRIP_NUMBER .

READ TABLE TRIP_SUMS INTO ADVANCE WITH KEY REINR = TRIP_NUMBER .

CLEAR FLAG.

IF ADVANCE-SUM_ADVANC = SUM.

FLAG = 'Y'.

ELSE.

FLAG = 'X'.

ENDIF.

from this flag am exporting to my method. If the import and export wont work fine then tell some other way to set my flag. In other commond.

Regards

vijay

bpawanchand
Active Contributor
0 Kudos

If you are able to get the workitem ID then try to use the below code snippet and check because even Iam setting some value back to the workitem container



DATA :
      w_wiid      TYPE             sww_wiid     VALUE   'XXXX',
      w_ref       TYPE REF TO      if_swf_run_wim_internal,
      w_ref_cnt   TYPE REF TO      if_wapi_workitem_context,
      w_wi_ref    TYPE REF TO      if_swf_ifs_parameter_container,
      ls_agent    TYPE             swr_wihdr.

TRY.
    CALL METHOD cl_swf_run_wim_factory=>find_by_wiid
      EXPORTING
        im_wiid     = w_wiid
      RECEIVING
        re_instance = w_ref.
  CATCH cx_swf_run_wim_enq_failed .
  CATCH cx_swf_run_wim_read_failed .
  CATCH cx_swf_run_wim .
ENDTRY.

CALL METHOD w_ref->get_workitem_context
  RECEIVING
    re_ctx = w_ref_cnt.

CALL METHOD w_ref_cnt->get_wi_container
  RECEIVING
    re_container = w_wi_ref.

TRY.
    CALL METHOD w_wi_ref->set             " Setting the Value Back to WORKITEM CONTAINER
      EXPORTING
        name       = lc_result
        value      = lv_value        
      IMPORTING
        returncode = lv_return.
  CATCH cx_swf_cnt_cont_access_denied .
  CATCH cx_swf_cnt_elem_access_denied .
  CATCH cx_swf_cnt_elem_not_found .
  CATCH cx_swf_cnt_elem_type_conflict .
  CATCH cx_swf_cnt_unit_type_conflict .
  CATCH cx_swf_cnt_elem_def_invalid .
  CATCH cx_swf_cnt_container .
ENDTRY.

vijy_mukunthan
Active Contributor
0 Kudos

Hi pavan

I cannot use this way because workflow is not triggered in this exit. After this exit only workflow triggers. So i cannot get the workitem id in this eixt. So i cannot use this way. Any other way.

Regards

vijay

former_member190818
Active Contributor
0 Kudos

Hi Vijay,

Instead of setting flag as X or Y, you can insert in ztable and get values in your method from this table and delete the entry after that.

Regards,

JMB

vijy_mukunthan
Active Contributor
0 Kudos

Hi JMB

Finally i need to do that way only. I am just enquiring is there any other way.

Regards

vijay

Answers (1)

Answers (1)

imthiaz_ahmed
Active Contributor
0 Kudos

Instead of updating the flag and then exporting it to memory at it has more chances of failures, store the old amount data in database either Z table or some other option. In the method check this old amount with the new amount.

Regards, IA