Application Development and Automation 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: 
Read only

Code question

Former Member
0 Likes
679

Hi,

There are 2 structures (source and target structures). I appended 3 fields to the target structure and trying to populate these key figure fields from some key figure fields in the source structure. I executed this code and i extracted the data into a flat file. No values are populated for the 3 appended fields. Please let me know the problem in the code.

method IF_EX_OPENHUB_TRANSFORM~TRANSFORM.

data: l_s_data_in type /bic/cyytest_is,

l_s_data_out type /bic/czytest_is.

clear e_t_data_out.

loop at i_t_data_in into l_s_data_out.

l_s_data_out-/bic/ykf1 = l_s_data_in-/bic/yvvps2 +

l_s_data_in-/bic/yvvps4.

l_s_data_out-/bic/ykf2 = l_s_data_in-/bic/yvvps1 +

l_s_data_in-/bic/yvvps3.

l_s_data_out-/bic/ykf3 = l_s_data_in-/bic/yvvadb +

l_s_data_in-/BIC/yvvcpa..

insert l_s_data_out into table e_t_data_out.

endloop.

endmethod.

Thanks

1 ACCEPTED SOLUTION
Read only

RichHeilman
Developer Advocate
Developer Advocate
0 Likes
650

The problem is that you are reading into a workarea, but trying to use values from the IN table. Try changing like so.



loop at i_t_data_in into l_s_data_out.

l_s_data_out-/bic/ykf1 = l_s_data_OUT-/bic/yvvps2 +
l_s_data_OUT-/bic/yvvps4.

l_s_data_out-/bic/ykf2 = l_s_data_OUT-/bic/yvvps1 +
l_s_data_OUT-/bic/yvvps3.

l_s_data_out-/bic/ykf3 = l_s_data_OUT-/bic/yvvadb +
l_s_data_OUT-/BIC/yvvcpa..

insert l_s_data_out into table e_t_data_out.

endloop.


When you say....

loop at i_t_data_in into l_s_data_out.

the values from I_T_DATA_IN are moved to L_S_DATA_OUT for each iteration of the loop. So I_S_DATA_IN is never being filled, this is why the values are not being added together.

Regards,

Rich Heilman

Message was edited by:

Rich Heilman

5 REPLIES 5
Read only

RichHeilman
Developer Advocate
Developer Advocate
0 Likes
651

The problem is that you are reading into a workarea, but trying to use values from the IN table. Try changing like so.



loop at i_t_data_in into l_s_data_out.

l_s_data_out-/bic/ykf1 = l_s_data_OUT-/bic/yvvps2 +
l_s_data_OUT-/bic/yvvps4.

l_s_data_out-/bic/ykf2 = l_s_data_OUT-/bic/yvvps1 +
l_s_data_OUT-/bic/yvvps3.

l_s_data_out-/bic/ykf3 = l_s_data_OUT-/bic/yvvadb +
l_s_data_OUT-/BIC/yvvcpa..

insert l_s_data_out into table e_t_data_out.

endloop.


When you say....

loop at i_t_data_in into l_s_data_out.

the values from I_T_DATA_IN are moved to L_S_DATA_OUT for each iteration of the loop. So I_S_DATA_IN is never being filled, this is why the values are not being added together.

Regards,

Rich Heilman

Message was edited by:

Rich Heilman

Read only

0 Likes
650

Hi Rich,

Sorry, this reply was in response to your first reply. I will try according to your second reply and let you know.

But, the fields yvvps2, yvvps4, yvvps1, yvvps3, yvvadb and yvvcpa are available only in the IN structure. They are not available in the OUT structure

Thanks

Message was edited by:

Sachin Guptha

Second Reply

Read only

0 Likes
650

Then I think the second sample code is what you need.

Regards,

Rich Heilman

Read only

0 Likes
650

Hi Rich,

It worked. Thanks a lot.

Regards

Message was edited by:

Sachin Guptha

Read only

RichHeilman
Developer Advocate
Developer Advocate
0 Likes
650

If the structures of L_S_DATA_IN and L_S_DATA_OUT are not the same, then maybe this is a better solution.



loop at i_t_data_in into l_s_data_in.

move-corresponding l_s_data_in to l_s_data_out.

l_s_data_out-/bic/ykf1 = l_s_data_in-/bic/yvvps2 +
l_s_data_in-/bic/yvvps4.

l_s_data_out-/bic/ykf2 = l_s_data_in-/bic/yvvps1 +
l_s_data_in-/bic/yvvps3.

l_s_data_out-/bic/ykf3 = l_s_data_in-/bic/yvvadb +
l_s_data_in-/BIC/yvvcpa..

insert l_s_data_out into table e_t_data_out.

endloop.

Regards,

Rich Heilman