Skip to Content

Offline approval

Hi,

I read many threads but no luck.

I have maintained Inbound settings, I am receiving emails in my SOIN, I see my exit which I have maintained in SO50 is getting called successfully, but the logic inside it isnt working as needed. Logic is it fetches the subject line and workitem id. If its for Approve or Reject 'A' or 'R' I use SAP FM SAP_WAPI_DECISION_COMPLETE where I pass key and workitem id.

But this logic isnt working.

Is there anything missing on configuration? or how do I debug the exit?

Thanks,

Aditya V

Add comment
10|10000 characters needed characters exceeded

  • Could you be a bit more precise than "the logic isn't working"?

  • Hi MP,

    inbound settings done, exit maintained in SO50.

    Inbound mail visible in SOIN, the exit basically checks subject of the in-mail. Subject contains workitem-id prefixed with 'A' or 'R' depending whether user clicked Approved or Reject thru mail.

    In the logic I call SAP_WAPI_DECISION_COMPLETE, where I pass workitem-id and key based on whether 'A' or 'R'.

    So ideally on successful execution of this FM, the WF will flow based on A or R.

    In SOIN trace, I see that the exit has been instantiated properly. But the WF doesnt flow further because of which PO isnt getting Released (if Approved) thru mail.

    Thanks,

    Aditya V

  • Get RSS Feed

4 Answers

  • Aug 16, 2017 at 12:56 PM

    Well, a user with only S_A.SCON doesn't have authorization to do WF stuff, so won't be able to.

    Needs the same auth as a dialog user performing the same action. You can either do a trace or set up a dialog test user to see what they need or just assign the generic WF-admin role.

    Add comment
    10|10000 characters needed characters exceeded

  • Aug 14, 2017 at 10:33 AM

    hi

    A and R are not valid, you need to get the approval node that is what you need to pass to function module as of below :

    * If the task is of type Decision (check the value )
    IF iv_action = 'A'.
    lv_decision = '0001'. "Approval Node
    ELSEIF iv_action = 'R'.
    lv_decision = '0002' ."Rejection Node
    ENDIF. ""Fin des Actions Pour OTHERS

    Call function 'SAP_WAPI_DECISION_COMPLETE'
    exporting
    workitem_id = ME->WIID
    LANGUAGE = SY-LANGU
    USER = IV_USER
    decision_key = LV_DECISION
    DO_COMMIT = 'X'
    DECISION_NOTE = IO_NOTE
    IMPORTING
    * RETURN_CODE =
    NEW_STATUS = RV_STATUS
    * TABLES
    * MESSAGE_LINES =
    * MESSAGE_STRUCT =
    .

    Cheers

    Stephane

    Add comment
    10|10000 characters needed characters exceeded

    • Hi

      If that is a release strategy you are trying to process then this is not a decision item (or you have made your own workflow and the step after approve is calling the release task (automatic) )

      When you are approving from the sap inbox the workitem it you are sent to a transaction then it is not a decision but the normal release step

      Else if this is realy a decision step :if in you sap inbox you have the workitem with a button approve or reject does the workflow change the status of the po (if no then it can not work either from the exit)

      If it is not a decision step

      Otherwise in your exit you need to have the following logic :

      IF iv_action = 'A'. "approve
      swc_clear_container lo_container .
      swc_set_element lo_container 'RelCode' lv_frgco.
      swc_call_method lo_po 'Release' lo_container.
      swc_clear_container lo_container .

      ELSEIF iv_action = 'R'. "reject
      swc_call_method lo_po 'ResetRelease' lo_container.

      To debug you need to have the user set up in SICF for processing the inbound mail temporarily as a dialog user and set up an external break point using this user.

      I hope this helps.

      Cheers

      Stephane

  • Aug 14, 2017 at 08:33 PM

    Log points are also a good way to investigate what's going on. The useful thing is that you can switch them on in other environments too. Or else it only takes a few minutes to add some code to write stuff out to a custom table:

    ...
    insert |Retrieved subject { subject_line } from email| to ZMYTESTLOG.
    ... insert |Parsed subject, answer = { answer }| to ZMYTESTLOG.

    You get the idea.

    By the way, I hope you are implementing a reasonable level of security around this, emails like this are very very very easy to fake if you're just using the standard SAP mail server.

    Add comment
    10|10000 characters needed characters exceeded

  • Aug 16, 2017 at 10:41 AM

    Hi All,

    thanks for hints, is it possible that this could be due to authorization issue. the system user that is assigned for Inbound has only S_A.SCON role. Should it have SAP_NEW or some other roles?

    Thanks,

    Aditya V

    Add comment
    10|10000 characters needed characters exceeded

    • Hi Aditya,

      Yes you technical user to process the mail shall certainly have a little more authorisation

      However function modules

      SAP_WAPI_WORKITEM_COMPLETE has import parameter ACTUAL_AGENT

      SAP_WAPI_DECISION_COMPLETE has import parameter USER

      If you are using these parameters with the user from which the inbound mail is coming then the action will be done by this user.

      So are you really using a decision step or are you using a user step (but not a decision => release method) ?

      Keep us informed of your progress

      Cheers

      Stephane