Sap_wapi_start_workflow

hi to all
in my workflow there is a multiline container element (ZCLAIM)which contain a structure
ZCLAIMREIQ
ZCLAIMEXPTYPE
ZCLAIMDATE
ZCLAIMBILLNO
ZCLAIMDESC
ZCLAIMAMT
Now via abap program i am initiating my workflow by fn mod
SAP_WAPI_START_WORKFLOW
in the input_container in want to pass the multiple values (around 3 to 10 values ) at a time.
can any one provide sample code how to pass multine container element into input_container

Hi this is my code , where i am trying to fill the data's into the workflow container element(MULTILINE)
NCLUDE <CNTAIN>.
data : WI_CONTAINER type swcont occurs 0 with header line.
  DATA: lt_simple_container TYPE STANDARD TABLE OF swr_cont
                               WITH HEADER LINE.
       data : zclaim type zclaim_test occurs 0 with header line.
data :    p_workitem TYPE sww_wiid,
          p_subrc    TYPE sysubrc.
zclaim-ZCLAIMREQID = '100'.
zclaim-ZCLAIMEXPTYPE = 'EXT'.
ZCLAIM-ZCLAIMDATE = '11022007'.
ZCLAIM-ZCLAIMBILLNO = '100'.
ZCLAIM-ZCLAIMDESC = 'SNACKS'.
ZCLAIM-ZCLAIMAMT = '100.02'.
APPEND ZCLAIM.
CLEAR ZCLAIM.
zclaim-ZCLAIMREQID = '101'.
zclaim-ZCLAIMEXPTYPE = 'EXT'.
ZCLAIM-ZCLAIMDATE = '11022007'.
ZCLAIM-ZCLAIMBILLNO = '100'.
ZCLAIM-ZCLAIMDESC = 'SNACKS'.
ZCLAIM-ZCLAIMAMT = '100.02'.
APPEND ZCLAIM.
CLEAR ZCLAIM.
zclaim-ZCLAIMREQID = '102'.
zclaim-ZCLAIMEXPTYPE = 'EXT'.
ZCLAIM-ZCLAIMDATE = '11022007'.
ZCLAIM-ZCLAIMBILLNO = '100'.
ZCLAIM-ZCLAIMDESC = 'SNACKS'.
ZCLAIM-ZCLAIMAMT = '100.02'.
APPEND ZCLAIM.
CLEAR ZCLAIM.
swc_set_table WI_CONTAINER 'ZCLAIM_TEST' ZCLAIM.
LOOP AT wi_container.
      MOVE-CORRESPONDING wi_container TO lt_simple_container.
      APPEND lt_simple_container.
    ENDLOOP.
CALL FUNCTION 'SAP_WAPI_START_WORKFLOW'
  EXPORTING
    TASK                      = 'WS95000008'
  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               = p_subrc
   WORKITEM_ID               =    p_workitem
  NEW_STATUS                =
TABLES
   INPUT_CONTAINER           = lt_simple_container
  MESSAGE_LINES             =
  MESSAGE_STRUCT            =
  AGENTS                    =
write : p_workitem ,p_subrc.
But its giving the return code 2 (which means input_container) is not properly set & no workitem is generated

Similar Messages

  • Error msg while starting WF using SAP_WAPI_START_WORKFLOW

    When I try to start one custom workflow using SAP_WAPI_START_WORKFLOW I am receiving a msg as “You are not of the possible agents“. So I tried to make the WF as generic task. Here I went through PFTC_CHG: pftc_chg and mevu option “<i>additional data-->agent assignment</i>” here I am getting one error popup as “<b>Entry in outbound table not found</b>”.
    Please help me out to resolve this and should be able to run WF from FM.

    Have you looked for OSS Notes (search for the message class and number)?
    And as always.... version and support package level is useful information.
    PS: when you receive error messages, post the message class and message number in addition to the message text. It allows people with different logon languages to reckognize the message.

  • Regarding how to pass the data from web dynpro to workflow

    hi gurus,
    how to pass the data from web dynpro to workflow.
    Regards
    vijay

    Check this [thread|SAP_WAPI_START_WORKFLOW;

  • How to pass the data from web dynpro to workflow.

    hi gurus,
    how to pass the data from web dynpro to workflow.
    Regards
    vijay

    Hi
    you can use function module
    data   ls_input_container  TYPE swr_cont.
    data   lt_input_container  TYPE TABLE OF  swr_cont.
    CALL FUNCTION 'SAP_WAPI_START_WORKFLOW'
        EXPORTING
          task            = ptask
        IMPORTING
          return_code     = lv_return_code
          new_status      = lv_new_status
        TABLES
          input_container = pinput_container
          message_lines   = lt_message_lines
          message_struct  = lt_message_struct.
    where you pass the data in imnternal table "pinput_container" as
      ls_input_container-element = 'KUNNR'.
      ls_input_container-value = ls_skna1-kunnr ."wd_this->lv_kunnr.
      APPEND ls_input_container TO lt_input_container .
      ls_input_container-element = 'CLUSER'.
      ls_input_container-value = lv_cluser.
      APPEND ls_input_container TO lt_input_container .
      ls_input_container-element = 'BUKRS'.
      ls_input_container-value = lv_bukrs. " youe value as per requirement.
      APPEND ls_input_container TO lt_input_container .
      ls_input_container-element = 'VKORG'.
      ls_input_container-value = ls_sknvv-vkorg. " youe value as per requirement
      APPEND ls_input_container TO lt_input_container .
      ls_input_container-element = 'VTWEG'.
      ls_input_container-value = ls_sknvv-vtweg. "youe value as per requirement.
      APPEND ls_input_container TO lt_input_container .
      ls_input_container-element = 'SPART'.
      ls_input_container-value = ls_sknvv-spart. "youe value as per requirement.
      APPEND ls_input_container TO lt_input_container .
    *Also Forgot to mention where ptask is your workflow ID *
    Regards,
    Arvind
    Edited by: Arvind Patel on May 14, 2010 7:38 AM

  • How to send data from a web dypro application using workflow

    Hi All,
    I am working on a web dynpro application where the user will enter the header and item details for a FI document to be posted. Once the user enters the data the workflow should initiate and should also send the data across to the approver to approve. To initiate the workflow I am using the function module 'SAP_WAPI_START_WORKFLOW' and it's working fine and generating a uniquw workflow item id. Now my main concern is how to send the data across from web dynpro application through the workflow. I have my data in three internal tables: 1. header table. 2. G/L table and 3. Currency table, I am capturing all this data from the web dypro screen entered by the user. Right now I have the following code in my web dypro application.
    METHOD execute_bapi_acc_document_post .
      DATA: return TYPE TABLE OF bapiret2.
      DATA: wa_return LIKE LINE OF return.
      DATA lo_bapi_acc_document_po TYPE REF TO if_wd_context_node.
      DATA lo_changing TYPE REF TO if_wd_context_node.
      DATA lo_accountgl TYPE REF TO if_wd_context_node.
      DATA lo_currencyamount TYPE REF TO if_wd_context_node.
      DATA lo_importing TYPE REF TO if_wd_context_node.
      DATA lo_documentheader TYPE REF TO if_wd_context_node.
      DATA lo_element TYPE REF TO if_wd_context_element.
      DATA lt_elements TYPE wdr_context_element_set.
      DATA ls_c_documentheader TYPE if_componentcontroller=>element_documentheader.
      DATA lt_c_accountgl TYPE if_componentcontroller=>elements_accountgl.
      DATA ls_c_accountgl LIKE LINE OF lt_c_accountgl.
      DATA lt_c_accountgl_cp TYPE if_componentcontroller=>elements_accountgl.
      DATA lt_c_currencyamount TYPE if_componentcontroller=>elements_currencyamount.
      DATA ls_c_currencyamount LIKE LINE OF lt_c_currencyamount.
      DATA lt_c_currencyamount_cp TYPE if_componentcontroller=>elements_currencyamount.
      DATA wa_c_currencyamount type bapiaccr09.
    CALL FUNCTION 'SAP_WAPI_START_WORKFLOW'
      EXPORTING
        TASK                      = 'TSXXXXXXXXXX'            
       USER                      = sy-uname
    IMPORTING
       RETURN_CODE               = L_RETURN_CODE
       WORKITEM_ID               = LV_WIID
    TABLES
    *   INPUT_CONTAINER           = lt_input_container
       MESSAGE_LINES             = lt_message_lines
       AGENTS                    = ls_agents
      lo_bapi_acc_document_po = wd_context->get_child_node( wd_this->wdctx_bapi_acc_document_po ).
      lo_changing = lo_bapi_acc_document_po->get_child_node( wd_this->wdctx_changing ).
      lo_accountgl = lo_changing->get_child_node( wd_this->wdctx_accountgl ).
      lo_currencyamount = lo_changing->get_child_node( wd_this->wdctx_currencyamount ).
      lo_importing = lo_bapi_acc_document_po->get_child_node( wd_this->wdctx_importing ).
      lo_documentheader = lo_importing->get_child_node( wd_this->wdctx_documentheader ).
      lo_element = lo_documentheader->get_element( ).
      lo_element->get_static_attributes(
        IMPORTING static_attributes = ls_c_documentheader ).
      lt_elements = lo_accountgl->get_elements( ).
      LOOP AT lt_elements[] INTO lo_element.
        lo_element->get_static_attributes( IMPORTING static_attributes = ls_c_accountgl ).
        INSERT ls_c_accountgl INTO TABLE lt_c_accountgl[].
      ENDLOOP.
      lt_c_accountgl_cp = lt_c_accountgl[].
      lt_elements = lo_currencyamount->get_elements( ).
      LOOP AT lt_elements[] INTO lo_element.
        lo_element->get_static_attributes( IMPORTING static_attributes = ls_c_currencyamount ).
        INSERT ls_c_currencyamount INTO TABLE lt_c_currencyamount[].
      ENDLOOP.
      lt_c_currencyamount_cp = lt_c_currencyamount[].
      READ TABLE lt_c_currencyamount INTO ls_c_currencyamount INDEX 2.
      ls_c_currencyamount-amt_doccur = ls_c_currencyamount-amt_doccur * '-1.0000'.
      MODIFY lt_c_currencyamount FROM ls_c_currencyamount INDEX 2.
      CALL FUNCTION 'BAPI_ACC_DOCUMENT_POST'
        EXPORTING
          documentheader = ls_c_documentheader
        TABLES
          accountgl      = lt_c_accountgl
          currencyamount = lt_c_currencyamount
          return         = return.
    ENDMETHOD.
    Please suggest.
    Thanks,
    Rajat
    I am not sure if this falls in webdynpro or workflow threads.. so I am posting it here also
    Edited by: rajatg on Jun 23, 2010 9:28 PM

    Dear Colleague,
    You have different method to send parameters to Workflow.
    1. Method
    Container Set Element
    DEFINE SWC_SET_ELEMENT.
      CALL FUNCTION 'SWC_ELEMENT_SET'
        EXPORTING
          ELEMENT   = &2
          FIELD     = &3
        TABLES
          CONTAINER = &1
        EXCEPTIONS
          OTHERS    = 1.
    END-OF-DEFINITION.
    Set the data into Workflow container
        SWC_SET_ELEMENT IT_CONTAINER 'parameter1' lv_parameter1.
    Start the Workflow
        CALL FUNCTION 'EWW_WORKFLOW_START'
          EXPORTING
            X_TASK          = 'WS90000001'   " your wf
          IMPORTING
            Y_WORKFLOW_ID   = WF_ID " your workitem id
          TABLES
            X_CONTAINER     = IT_CONTAINER
          EXCEPTIONS
            INVALID_TASK    = 1
            NO_ACTIVE_PLVAR = 2
            START_FAILED    = 3
            GENERAL_ERROR   = 4
            OTHERS          = 5.
    2. Method,
    You can also add your parameters direly to a container,
      DATA: lt_simple_container TYPE TABLE OF swr_cont,
            ls_simple_container TYPE swr_cont.
      ls_simple_container-element = 'parameter1'.
      ls_simple_container-value = lv_parameter1.
      APPEND ls_simple_container TO lt_simple_container.
      CALL FUNCTION 'SAP_WAPI_WRITE_CONTAINER'
        EXPORTING
          workitem_id      = WF_ID " your workitem id
          do_commit        = 'X'
        TABLES
          simple_container = lt_simple_container.
    Bulent.

  • How to change workflow for expired qualification in HR Module

    Hi,
    My question how to change workflow for expired qualification in HR Module.We need to when date is expired tcode OOQA that system will check and that time workflow should be triggred.
    I have serached sap help but i am not understand please below mention URL for SAP help
    Link: [http://help.sap.com/saphelp_47x200/helpdata/en/ee/f4c9cafbab11d29ea40000e8215202/frameset.htm]
    Please explain step by step how to trigrred workflow for expired qualification?
    Please this problem is high and try to solve it.
    Thx!
    Sachin

    Hi,
    Why do you want to trigger a wflow and what do you want to do with this trigger. Can you give more details of your exact requirements.
    But, if you are looking for how to trigger, you can write a small ABAP pgm and schedule it as a job every night. THis job basically reads the table P1000-ENDDA for expiry date and if it reached today, then you can either trigger the wflow with SAP_WAPI_START_WORKFLOW or use SAP_WAPI_CREATE_EVENT to raise your custom event(for Business Obj. BUS7018, i think this is your BO and there are no std events right now, so you will ahve to add your custom event by extending BUS7018 to ZBUS7018).
    Hope I am clear and this helps and if you need more details, reply.
    venu

  • "No administrator found for the task" in the front end

    Hi all,
    My issue is, whenever approval request is raised from the front end ( JAVA WEB-DYNPRO), it triggers the workflow through the "<b>sap_wapi_start_workflow</b>" and when the workflow proceeds to the first level of approval, the front end application provides the approver with <b>Approve</b> and <b>Reject</b> options.
    On click of approve, from the java webdynpro, the approve status is written in the container using "<b>sap_wapi_write_container</b>" and then a call is made to "<b>sap_wapi_workitem_complete</b>". Upon excution, the message line is "<b>No administrator found for the task</b>" and the return code is "<b>1</b>".
    But if we do the same steps from the backend (R/3), the workitem is getting completed without any such error.
    Please advice.
    Thanks.

    Hi Balaji,
    I think I have an answer for you.  This has happened with us when approving a WD java task using UWL (in our case for travel).  The key is the return code of 1.
    What has happened is this.  The return code actually comes from the function SWW_WI_STATUS_CHANGE_NEW which is called deep in the WAPI wrapper.  It means "infeasible_state_transition = 1".
    This is due to the fact that after updating the container, your wapi call from web dynpro tries to change the workitem from status of "Ready" to status "Completed".  This will not work.
    What you will have to do is call "SWW_WI_STATUS_CHANGE_NEW" to set the status to 'SELECTED' beofre setting the item to complete.
    The reason for this is that when you are executing from R3, the status change is done for you.  When calling from the WD, no reservation of the workitem occurs.
    Sorry about last night, I live well outside of town and the phone reception at my place is poor.
    Regards
    Gareth

  • How to trigger standard task manually in Process controlled workflow?

    Hi All,
    I would like to trigger a task mannually in BRF, process controlled workflow. My requirement is to send an approval notification to the approvers at the current approval level, at any instance by the requestor of the shopping cart. In that case, will it be possible to trigger the standard task 40007953 (SRM Shopping Cart Approval (1)) with the workitem of Shopping cart under consideration?
    I have tried searching for the same in SDN and other forums but most of the information was regarding application controlled workflows. None of those function modules seems to be working in PCW.
    Any pointers on how to trigger a standard task (using FM or code) in BRF(process controlled workflow) environment is also highly appreciated.
    Thanks,
    S.H@ri

    Hi,
    Use this FM [SAP_WAPI_START_WORKFLOW|http://www.sdn.sap.com/irj/scn/index?rid=/library/uuid/bb9100f8-0c01-0010-ac8e-e017351f3fc1].
    Regards,
    Surjith

  • List of BAPIs related to Workflow

    hello,
    I am currently working on a mobile application android my goal is to validate a workflow from a user that's why I want a list of BAPI with a link to the workflow
    thank you
    Moderator message: please do more research before asking, show what you have done yourself when asking.
    Edited by: Thomas Zloch on Jun 20, 2011 1:19 PM

    Hi,
    BAPI and FM related to Workflow -
    SAP_WAPI_START_WORKFLOW
    SAP_WAPI_CREATE_EVENT(latest)
    SWE_EVENT_CREATE (old)
    SAP_WAPI_CREATE_WORKLIST
    SAP_WAPI_GET_WORKITEM_DETAIL
    BAPI_CATIMESHEETMGR_INSERT
    SAP_WAPI_EXECUTE_WORKITEM
    BAPI_USER_GET_DETAIL
    Pls check the BAPI tcode in SAP for ore list of BAPIs related to workflow.
    Regards
    Lekha

  • How to populate the CONTAINER, when calling a WorkFlow Task via FM?

    Hello,
    I am trying to trigger an email notification to user's SAP Inbox, if Outbound IDOC got failed. I wrote the below code in the processing FM, but, i am stucked at populating the CONTAINER parameter of this Task, pls. let me know How/with What I have to populate the CONTAINER parameter of this FM?
    DATA: wa_input_container    TYPE swr_cont,
                wa_swr_messag       TYPE swr_messag,
                wa_swragent             TYPE swragent.
    * Fill Workflow element
          wa_input_container-element = '_WI_OBJECT_ID' .
          wa_input_container-value   = wa_idoc_control-docnum.
          APPEND wa_input_container TO itab_input_container.
    * Fill Email body
          wa_swr_messag-msg_type = 'E'.
          wa_swr_messag-line = 'Error'.
          APPEND wa_swr_messag TO itab_swr_messag.
          CALL FUNCTION 'SAP_WAPI_START_WORKFLOW'
            EXPORTING
              task               = 'TS00007989'
              language           = sy-langu
              user               = sy-uname
              start_asynchronous = 'X'
            IMPORTING
              return_code        = v_sy_subrc
            TABLES
              input_container     = itab_input_container
              message_lines      = itab_swr_messag
              agents                   = itab_swragent.
        ENDIF.
    Thank you.

    Hi,
    Pls refer below link.
    FM SAP_WAPI_START_WORKFLOW Exporting container without values

  • Mail to all the employess in the internal table.

    Hi Experts,
    I have a internal table where the employee IDs are saved.. I need to send a mail to all the employees in the internal table. How will i be able to send a mail from the function module SAP_WAPI_START_WORKFLOW? where will i pass the internal table values and what need to be put in the mail recepient part?
    Regards,
    Lavanya

    First, if you are ONLY sending e-mails, you need to look into solutions other than workflow.
    Still, since you already have the workflow, you can pass an internal table with a list of all e-mail addresses to the workflow:
    - Define a multiline container element (import parameter) in the workflow. You could utilize the current e-mail address field (just mark it as multiline.
    - Pass that multiline element as the recipient of the e-mail (you can click F4 on the recipient field and then select the blue-looking table field).

  • Best practice for workflow triggering from Web Dynpro UI

    Hello, workflow community!
    I'm working on a task which allow to trigger the workflow by clicking a button in Web Dynpro UI. As always, there are multiple ways to do that, for instance, to use SAP Workflow API (SAP_WAPI_START_WORKFLOW) or to raise an event upon the button click, which will be caught by workflow template.
    In my opinion, the optimal solution is to call FM, which will call ABAP-class, raising an event, which, in turn, will be caught by workflow template. In this case, FM will service kind of wrapper, where we can implement some additional checks if needed.
    But the question is what approach is the best practice — to raise an event or use SAP_WAPI_*?
    Thanks.

    let combine, use SAP_WAPI_CREATE_EVENT
    usually I would not recommend creating a workflow directly (SAP_WAPI_START_WORKFLOW) since when I look for workflows in a system I usually start from SWE2 (the event linkage) which uses events so the workflow you start by SAP_WAPI_START_WORKFLOW will not be seen there, also SWE2 gives you better control for starting the workflow, you can easily deactivate an event linkage. finding where you called the workflow by SAP_WAPI_START_WORKFLOW will be more difficult and deactivation will require a code change.
    so use events, and start them by SAP_WAPI_CREATE_EVENT
    Also pay attention that you have a check function module option in SWE2.

  • ABAP Objects with Workflows / Classes and Instances

    Hello,
    I am currently designing a workflow using an ABAP-Objects. So far I have been been able to get my Workflow to run with my class, but I have a couple of problems:
    - I am using the Function 'SAP_WAPI_START_WORKFLOW' to start other subflows, which enables me to decide which subflow to start at runtime. All of the subflows have standart importing-parameters in their containers, such as the key of my class. In each workflow I instantiate my class using a self-written method, which checks the table T_INSTANCES in my object, and then either returns the object reference to an existing instance or creates a new one. Obviously all of the subflows that I call from my main workflow should be able to find the instance. As far as I can see in their protocolls, this happens without any problems. The problem starts when I make changes to the instance. For example the changing of attributes (with setter methods) seems not to work. After the subflows are finished, in my main workflow, I do not see (with getter methods) any changes that has been made to the object. Is local persistence really limited to one workflow ?
    - My second problem is basically about the workflow container in workflow protocoll. In the same workflow, I can change the attributes of my object. Nevertheless, the protocoll always show the initial attribute, even though, my task with the getter-method returns the new value of the attribute.
    I appreciate any help and thanks a lot in advance.

    Hello Pauls,
    Thank you for your answer. I think we are misunderstanding each other. The problem occurs (I think) because my class is not a singleton class. Or am I mistaken ?
    When I directly start a subflow from my main workflow, then the instance that I have created in my main workflow is also visible to the subflow. As well as the static table which actually keeps track of the instances. So, in this case the subflows finds the instance and then can use the object as is.
    When I start a subflow from my main workflow using the function I mentioned above, then even though the same object key is used, there is a new instance. And the static table (I assume that you mean a static variable from type table, when you say "class table") is completely empty. In this case, my "new" instance is created which overwrites every attribute that I have set in the main workflow, before I started the subflow. More interestingly, my main workflow instantiates another new object, as soon as the subflow has finished. (I am using an event to wait for the subflow to finish.)
    On the other hand, I am not quite sure that I understood your approach with refresh and how it could help me. This method is not well documented anywhere, and all of the examples that I have found are about "leave it empty"
    As far as I understood, this method is called by the workflow between the steps, when an object is used. I slowly start to think that I need advanced information about Workflows and Memory Management.
    Thanks a lot again. Apparently, I am the only person who came across such a problem
    Greetz
    G.Fendoglu

  • Work flow in WD application

    Dear Experts,
    I have a output of web dynpro application where a column has an URL. My user requests to trigger workflow when he clicks the URL.
    I dont know how WDA integrated with work flow. Please could you explain some scenarios why Work flow is used in WDA and What is the role for it in WDA?
    Thanks in Advance.
    Regards,
    Venkat

    Hi Venkat,
    To start a workflow you can use function module SAP_WAPI_START_WORKFLOW.
    In your Web Dynpro app you can use a LinkToAction, then in the properties of the LinkToAction object go to Events section, you will see the OnAction event, click on the icon on the right side on the line where you see OnAction to create a new action, you can call it START_WORKFLOW, the corresponding event handler method will be added to the view controller called ONACTIONSTART_WORKFLOW.
    Then call the function module SAP_WAPI_START_WORKFLOW within the ONACTIONSTART_WORKFLOW method.
    Enjoy!
    Best regards... Lucio

  • Check for duplicate invoices and trigger a workflow

    Hello All,
        I have a requirement to check for duplicate invoices in AP(Accounts payable) and trigger a workflow when duplicate invoices are found. I a not sure how to do any of the above. Please  let me know if you have any information on:
    1) Checking for duplicate invoices in AP
    2) Trigger a workflow
    Are there any standard workflows that checks duplicate invoices?
    Thanks.
    --Mithun

    Hi MD,
    I doubt if system gives an error on FI side when a duplicate invoice is posted.
    I feel you would require a BAdi for it, where you can call your WF using FM SAP_WAPI_START_WORKFLOW.
    Hope it helps.
    Aditya
    P.S also ask your Func Consultants, if there are any settings in the Customization, where you could capture Inv Dt, Inv Amt, Vendor, Company code.
    Edited by: Aditya Varrier on Oct 15, 2008 9:38 AM

Maybe you are looking for