on 06-23-2010 8:28 PM
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
I used a deffierent approach
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Thanks for the reply, I already tested and we are able to pass on the data from the INPUT_CONTAINER of the FM SAP_WAPI_START_WORKFLOW. But my main concern how to grab the data from the webdynpro screen that user enters and then merge all the data in the three internal table to the final internal table lt_input_container.
Please advise.
Thanks,
Rajat Garg
Really not sure what you are trying to do, but here goes.
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
The above function would start the workflow task 'TSXXXXXXXXXX' (which of course does not exist). A real task or worflow template would have a number where the X's are.
If you were to find or create a workflow task, it would look something like this (starting workflow template 'WS92000017'.
CALL FUNCTION 'SAP_WAPI_START_WORKFLOW'
EXPORTING
task = 'WS92000017'
do_commit = 'X'
IMPORTING
return_code = l_subrc
workitem_id = l_workitem
TABLES
message_lines = lt_mess
input_container = lt_cont.
The data that you pass to the workflow container would be passed in the "input_container" TABLES parameter of the function call.
- Tim
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
87 | |
10 | |
10 | |
10 | |
7 | |
6 | |
6 | |
5 | |
5 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.