cancel
Showing results for 
Search instead for 
Did you mean: 

FM SAP_WAPI_START_WORKFLOW Exporting container without values

Former Member
0 Kudos

Hi Experts,

I have used the FM SAP_WAPI_START_WORKFLOW in a BAdI so that it would trigger the workflow WS65400029, which is used in the rejection of a PR. The implementation is such that a popup appears when an approver clicks the reject button in ME54N, so that he/she can enter a reason for the rejection. Once he saves, the workflow is triggered and sends a notification to the inbox of the creator (initiator) of the PR. The notification also contains the reason for the rejection as well.

Now the container of the PR Object is empty, so that , PR number does not appear in the heading of the mail notification e.g. 'Purchase Requisition rejected', instead of 'Purchase Requisition 10000130 rejected'. How can I make the number appear? The text entered by the approver does appear in the notification.

Thanks in Advance,

Darlington

Accepted Solutions (0)

Answers (3)

Answers (3)

Former Member
0 Kudos

I think you have to pass the pass the Purchase Recquisition object into the FM. I think you have to use the SWC_CREATE_OBJECT and then instantiate this object and pass this into Workflow.

Thanks

Arghadip

Former Member
0 Kudos

Thanks, Arghadip.

I can't use SWC_CREATE_OBJECT in the BAdI because it keeps on saying "SWC_CREATE_OBJECT is not defined" even if I put the INCLUDE <CNTN01>. Even if I pass the PR object into the FM, how then do I determine the text in the element lt_cont and export it to the workflow if I dont pass lt_cont to the FM?

Please help.

Regards

Darlington

former_member185167
Active Contributor
0 Kudos

Hello,

I think you have to rethink this whole process.

You talk about the rejection of a PR. Is this already happening in a workflow? If yes, there is no need

(and little point) in starting a new workflow just for the rejection, you would be better off adding a

step which asks the user for comments.

regards

Rick Bakker

Hanabi Technology

Former Member
0 Kudos

Thanks, Rick.

Yes, there is a workflow that is running for the rejection purpose i.e. WS65400029. Basically, it contains a single step where I have the description being sent to the notification delivered to the creator saying 'Your PR XXXXX has been rejected by XXXXX', which is the notification that is also supposed to contain the comment as well.

So, you suggest that I add another step before the step 'Overall step refused'? That means creating a task which calls a method which calls the FM GET_COMMENT right? Does the method have to be created in a completely new BO or in the BUS2105 BO? How does the next step get the comments?

Regards,

Darlington

Former Member
0 Kudos

Use this FM inside a method OF BO BUS2105 and then populate this in the Workflow container and use it. Another thing I once saw in PR or PO you can directly add some rejection note in the transaction itself. You can just find that note and use it in your SAP Workflow.

Thanks

Arghadip

Former Member
0 Kudos

Thanks, Arghadip.

Which method would you suggest in BUS2105? Should I create a new one? Where exactly can I find the rejection note in the transaction ME54N or which transaction?

Regards,

Darlington

bpawanchand
Active Contributor
0 Kudos

What I would like to suggest is

First of all do not disturb the standard BOR BUS2015, you can use different BO in the same workflow instance , so I think you create a entirely a separate BOR which have only onle method and in that method you call the FM POPUP_GET_VALUES to this Fm you have to pass Title of the comment screen and in the tables parameter you mention a table name and field which has enough size to hold the comment text this is jus to make it know that the type of the comment , that's all it will not store in the table.

Now release the BOR and implement it and call this method in a task and insert this task in a Activity step in the Rejection branch of the Decision step,

Once the agent rejects then the next step will pop up the screen or as per your requirement you can insert before or after the decision step.

Former Member
0 Kudos

Thanks, Pavan.

I have done as you suggested, I put an activity step before the step that sends the 'PR XXXXXX Rejected' step but it seems the workflow is only ending there and there is no popup that appears when the 'reject' button is pressed. Remember, the workflow in question is WS65400029. The method I added is:

BEGIN_METHOD POPUPGETVALUES CHANGING CONTAINER.
DATA:
      NOVALUECHECK(255),
      POPUPTITLE(255),
      STARTCOLUMN(255),
      STARTROW(255),
      RETURNCODE(255),
      FIELDS LIKE SVAL OCCURS 0.
  SWC_GET_ELEMENT CONTAINER 'NoValueCheck' NOVALUECHECK.
  IF SY-SUBRC <> 0.
    MOVE SPACE TO NOVALUECHECK.
  ENDIF.
  SWC_GET_ELEMENT CONTAINER 'PopupTitle' POPUPTITLE.
  SWC_GET_ELEMENT CONTAINER 'StartColumn' STARTCOLUMN.
  IF SY-SUBRC <> 0.
    MOVE '5' TO STARTCOLUMN.
  ENDIF.
  SWC_GET_TABLE CONTAINER 'Fields' FIELDS.
  CALL FUNCTION 'POPUP_GET_VALUES'
    EXPORTING
      NO_VALUE_CHECK = NOVALUECHECK
      POPUP_TITLE = POPUPTITLE
      START_COLUMN = STARTCOLUMN
      START_ROW = STARTROW
    IMPORTING
      RETURNCODE = RETURNCODE
    TABLES
      FIELDS = FIELDS
    EXCEPTIONS
      ERROR_IN_FIELDS = 9001
      OTHERS = 01.
  CASE SY-SUBRC.
    WHEN 0.            " OK
    WHEN 9001.         " ERROR_IN_FIELDS
      EXIT_RETURN 9001 sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
    WHEN OTHERS.       " to be implemented
  ENDCASE.
  SWC_SET_ELEMENT CONTAINER 'Returncode' RETURNCODE.
  SWC_SET_TABLE CONTAINER 'Fields' FIELDS.
END_METHOD.

Is there any problem here? In the binding there are errors that say 'Mandatory import element 'POPUPTITLE' is not (explicitly) provided' and 'Mandatory import element 'FIELDS' is not (explicitly) provided'. Anything you detect here?

Regards,

Darlington

bpawanchand
Active Contributor
0 Kudos
BEGIN_METHOD POPUPGETVALUES CHANGING CONTAINER.
DATA:
      NOVALUECHECK(255),
      POPUPTITLE(255),
      STARTCOLUMN(255),
      STARTROW(255),
      RETURNCODE(255),
      FIELDS LIKE SVAL OCCURS 0.
  SWC_GET_ELEMENT CONTAINER 'NoValueCheck' NOVALUECHECK. " <-----
  IF SY-SUBRC  0.
    MOVE SPACE TO NOVALUECHECK.
  ENDIF.
  SWC_GET_ELEMENT CONTAINER 'PopupTitle' POPUPTITLE. " <----
  SWC_GET_ELEMENT CONTAINER 'StartColumn' STARTCOLUMN. " <----
  IF SY-SUBRC  0.
    MOVE '5' TO STARTCOLUMN.
  ENDIF.
  SWC_GET_TABLE CONTAINER 'Fields' FIELDS.
  CALL FUNCTION 'POPUP_GET_VALUES'
    EXPORTING
      NO_VALUE_CHECK = NOVALUECHECK
      POPUP_TITLE = POPUPTITLE
      START_COLUMN = STARTCOLUMN
      START_ROW = STARTROW
    IMPORTING
      RETURNCODE = RETURNCODE
    TABLES
      FIELDS = FIELDS
    EXCEPTIONS
      ERROR_IN_FIELDS = 9001
      OTHERS = 01.
  CASE SY-SUBRC.
    WHEN 0.            " OK
    WHEN 9001.         " ERROR_IN_FIELDS
      EXIT_RETURN 9001 sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
    WHEN OTHERS.       " to be implemented
  ENDCASE.
  SWC_SET_ELEMENT CONTAINER 'Returncode' RETURNCODE.
  SWC_SET_TABLE CONTAINER 'Fields' FIELDS.
END_METHOD.

instead of importing form the workflow conatiner you can call the FM like this

data:
       lv_comment  type char250,
      ls_fields  type  SVAL.

CALL FUNCTION 'POPUP_GET_VALUES'
    EXPORTING
           POPUP_TITLE = 'Comment On Decision'
     IMPORTING
      RETURNCODE = RETURNCODE
    TABLES
      FIELDS = FIELDS
    EXCEPTIONS
      ERROR_IN_FIELDS = 9001
      OTHERS = 01.
  CASE SY-SUBRC.
    WHEN 0.            " OK
        read table FIELDS into ls_fields INDEX 1.
      lv_comment = ls_fields-value.
    WHEN 9001.         " ERROR_IN_FIELDS
      EXIT_RETURN 9001 sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
    WHEN OTHERS.       " to be implemented
  ENDCASE.

swc_set_element container '<name of container element in task>'  lv_comment.  " ----< 

Former Member
0 Kudos

The popup is still not appearing.

How can I use a simpler FM like 'GET_COMMENT' to implement the same thing? I am stuck.

Thanks for your assistance,

Darlington

bpawanchand
Active Contributor
0 Kudos
data:
       lv_comment  type char250,
      ls_fields  type  SVAL.

 ls_fields-tabname = '<name of the table>'.
ls_fields-fieldname = '<name of the field which has enough size to store the data>'.
APPEND ls_fields  TO FIELDS.    "  < -------- This you missed


CALL FUNCTION 'POPUP_GET_VALUES'
    EXPORTING
           POPUP_TITLE = 'Comment On Decision'
     IMPORTING
      RETURNCODE = RETURNCODE
    TABLES
      FIELDS = FIELDS
    EXCEPTIONS
      ERROR_IN_FIELDS = 9001
      OTHERS = 01.
  CASE SY-SUBRC.
    WHEN 0.            " OK
        read table FIELDS into ls_fields INDEX 1.
      lv_comment = ls_fields-value.
    WHEN 9001.         " ERROR_IN_FIELDS
      EXIT_RETURN 9001 sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
    WHEN OTHERS.       " to be implemented
  ENDCASE.
 
swc_set_element container '<name of container element in task>'  lv_comment.  " ----<

as i said in my previous post this is just to say the screen that it what type the value the user is gogin to enter in the note it is working in my system.

and you can do one more thing as you have already created a separate BOR for executing this FM so in the DECISION step you hvae a METHODS tab under that tab in the first section you include this method, this is one more option.

Former Member
0 Kudos

Hi, Pavan.

Could you please tell me which workflow you used for the rejection? I have been using WS65400034 but I haven't been able to solve the issue.

Regards,

Darlington

saumya_govil
Active Contributor
0 Kudos

Hi Darlington,

I hope you are passing the Purchase Requisition object to the workflow.

If not, check the FM call and pass the BO to the workflow.

Also check in the workflow container if the values of the PR are being correctly fetched.

You can check this info in the workflow log.

Regards,

Saumya

Former Member
0 Kudos

Hi Experts,

The only object I am passing to the FM SAP_WAPI_START_WORKFLOW is the object containing the rejection text, lt_cont. How can I pass the PR object? Do I need to call the FM again, with the PR object as the INPUT_CONTAINER?

Here is the code in the BAdI:

METHOD if_ex_me_commtmnt_req_re_c~check_relev.
*  INCLUDE <swfcntn01>.
*  INCLUDE <CNTN01>.

  DATA : l1(72) TYPE c,
         l2(72) TYPE c.

  DATA : lt_cont TYPE TABLE OF swr_cont.
  DATA : ls_cont TYPE  swr_cont.

  CLEAR: l1,l2.

  IF sy-ucomm = 'MESAVE' OR
     sy-ucomm = 'OK'.

    EXIT.

  ELSE.


    CALL FUNCTION 'GET_COMMENT'
      EXPORTING
        ref               = '123'
*   IM_VALUE          = ' '
     IMPORTING
       tech_name         = l1
       description       = l2
     EXCEPTIONS
       cancelled         = 1
       OTHERS            = 2
              .
    IF sy-subrc <> 0.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
*         WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
    ENDIF.

    ls_cont-element = 'l2'.
    ls_cont-value = l2.
    Append ls_cont TO lt_cont.
    .

    CALL FUNCTION 'SAP_WAPI_START_WORKFLOW'
      EXPORTING
        TASK                 = 'WS65400029'
*   LANGUAGE                  = SY-LANGU
*   DO_COMMIT                 = 'X'
*   USER                      = SY-UNAME
*   START_ASYNCHRONOUS        = ' '
*   DESIRED_START_DATE        =
*   DESIRED_START_TIME        =
*   DESIRED_START_ZONLO       = SY-ZONLO
*   IFS_XML_CONTAINER         =
* IMPORTING
*   RETURN_CODE               =
*   WORKITEM_ID               =
*   NEW_STATUS                =
       TABLES
       INPUT_CONTAINER           = lt_cont
*   MESSAGE_LINES             =
*   MESSAGE_STRUCT            =
*   AGENTS                    =
    .
  ENDIF.


ENDMETHOD.

former_member185167
Active Contributor
0 Kudos

Hello,

Good idea to start a new thread.

Are you passing the Purchase Req object to SAP_WAPI_START_WORKFLOW?

regards

Rick Bakker

Hanabi Technology