Application Development Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 

How to: Pass data into structure typed workflow Container?

Former Member
0 Kudos
1,523

Hi gurus,

I'm now facing an issue when trying to pass data into a structure typed workflow Container. I've created a dictionary structure MAIN with several fields in it, but problems occur when trying to build it into workflow container.Pls see code below:

Data: ls_main type main. "MAIN:a custom structure in DDIC.

" move data into ls_main.

......

" Then build container from ls_main

swc_set_element container 'MAIN' ls_main.

Now the weird thing happens: There would be multiple entries in table container, each for a field in MAIN. When calling SAP_WAPI_START_WORKFLOW with this container, error would occur.

I've search SDN/WUG/Google and there was no meaningful answer, can someone pls help me out? Thanks in advance.

Regards

Luis

1 ACCEPTED SOLUTION

Former Member
0 Kudos
795

Hi,

<u>Look into the following :</u>

Reward if helpful.

Create a variable for the table.

If the container is used in a workflow binding, you must ensure that the table has the same data type reference as the container element defined in the container definition.

Assign values to the table.

Write the table into the container using the following macro instruction:

SWC_SET_TABLE <Container> <ContainerElement> <Value>.

Upper and lower case are not distinguished for the container element ID. If the container is used in the binding of a workflow, you must ensure that a container element of the same name is defined in the container definition.

To append a value to a table, you must first read the table from the container, then append the value, and finally write the table back into the container.

If the container element with this ID is not yet in the container, it is inserted into the container with its value. If there is already a container element with this ID in the container, the old value is overwritten with the new value.

Use the following macro :

Writing a multiline field value

<b>SWC_SET_TABLE <Container> <ContainerElement> <Value>.</b>

Regards

5 REPLIES 5

Former Member
0 Kudos
795

hi,

ev_container-element = 'Pernr'.

ev_container-value = PERNR.

append ev_container.

clear ev_container.

ev_container-element = 'Bizevntid'.

ev_container-value = WA-BUSEVNTID.

append ev_container.

clear ev_container.

ev_container-element = 'BE_Desc'.

ev_container-value = L_DESC.

append ev_container.

clear ev_container.

see this code, this method is better, try it once,

Thanks

Sankar

Former Member
0 Kudos
796

Hi,

<u>Look into the following :</u>

Reward if helpful.

Create a variable for the table.

If the container is used in a workflow binding, you must ensure that the table has the same data type reference as the container element defined in the container definition.

Assign values to the table.

Write the table into the container using the following macro instruction:

SWC_SET_TABLE <Container> <ContainerElement> <Value>.

Upper and lower case are not distinguished for the container element ID. If the container is used in the binding of a workflow, you must ensure that a container element of the same name is defined in the container definition.

To append a value to a table, you must first read the table from the container, then append the value, and finally write the table back into the container.

If the container element with this ID is not yet in the container, it is inserted into the container with its value. If there is already a container element with this ID in the container, the old value is overwritten with the new value.

Use the following macro :

Writing a multiline field value

<b>SWC_SET_TABLE <Container> <ContainerElement> <Value>.</b>

Regards

Former Member
0 Kudos
795

Hi Sankar & Zapper,

Thanks for your reply, I've fixed the problem.

Below is my code used to handle the structure, I gave up the macro SWC_SET_ELEMENT because it's creating multiple entries in container for a single structure. Instead, I concatenated all fields of the structure into the VALUE field and then there would be only one entry in container for my structure( its name was MAIN). In the concatenation, a dynamic assignment with field-symbols is used.


* Start of code
FIELD-SYMBOLS: <field> TYPE ANY.

* Create container for MAIN
MOVE main TO ls_main.
CLEAR: sy-index.
ls_input_container-element = 'MAIN'.
DO.
ASSIGN COMPONENT sy-index OF STRUCTURE ls_main TO <field>.
IF sy-subrc <> 0.
EXIT.
ENDIF.
* using REPLACE here brings up troubles.
TRANSLATE <field> USING ' ~'.
CONCATENATE ls_input_container-value <field>
INTO ls_input_container-value.
ENDDO.

TRANSLATE ls_input_container-value USING '~ '.
APPEND ls_input_container TO lt_input_container.
* End of code

<b>Please note</b>: AFAIK, the fields can only be CHAR typed. If there are TYPE I fields, problems would occur.

Hope this would be helpful in future searches on SDN over this problem.

Thank you all for you kind help and points have been distributed to you.

Best regards

Luis

0 Kudos
795

hi Luis,

can you pls explain the code that you had suggested below with my scenario:

my workflow container <b>itab_emp</b> is of custom DDIC structure <b>zemployee with 3 fields( empid,empname,empaddr).</b>

now how to fill the WF container<b> itab_emp</b> which is multiline with data and pass the container through SAP_WAPI_START_WORKFLOW.

Thanks,

Subba

0 Kudos
729

Excellent Solution ... I was not finding anywhere else .