‎2007 Apr 09 4:15 PM
Hello All, I am new to ABAP so please forgive this basic question. The below is a snippet of code I have in a ABAP Proxy.
Here is a snippet of my code:
DATA: ls_item TYPE ZSHOPPING_CART_IN_BBP_PDS_SC_I.
DATA: i_item TYPE TABLE OF bbp_pds_sc_item_icu.
DATA: w_item TYPE bbp_pds_sc_item_icu.
....
LOOP AT input-I_ITEM-item INTO ls_item.
CLEAR w_item.
w_item-guid = v_item_guid.
w_item-parent = v_header_guid.
w_item-description = ls_item-description.
w_item-number_int = ls_item-number_int.
w_item-category = ls_item-category.
w_item-category_id = ls_item-category_id.
w_item-product_type = ls_item-product_type.
APPEND w_item TO i_item.
ENDLOOP.
-
The structure input-I_ITEM-item is an input from a ABAP Proxy. This all works great if I feed in only 1 line item to proxy, but if I send in two line items the result is i_item has line item 1 twice, and I get nothing for line item2. It is almost like the the loop runs twice but the ls_item stays on line 1. I am sure I am missing something simple.
‎2007 Apr 09 5:04 PM
‎2007 Apr 09 4:19 PM
‎2007 Apr 09 4:27 PM
Hi Suresh,
I added the CLEAR ls_item. after the Append but I still get record 1 twice.
Cheers,
J
‎2007 Apr 09 4:41 PM
I_ITEM seems to be a structure and NOT LINE TYPE.
Rajesh - You are right. CLEAR clears header area.
Thanks,
SKJ
‎2007 Apr 09 4:21 PM
Try clearing like this:
LOOP AT input-I_ITEM-item INTO ls_item.
CLEAR w_item.
w_item-guid = v_item_guid.
w_item-parent = v_header_guid.
w_item-description = ls_item-description.
w_item-number_int = ls_item-number_int.
w_item-category = ls_item-category.
w_item-category_id = ls_item-category_id.
w_item-product_type = ls_item-product_type.
APPEND w_item TO i_item.
<b>CLEAR i_item.</b>
ENDLOOP.
Thanks,
SKJ
‎2007 Apr 09 4:26 PM
Hi SKJ,
If we clear an internal table with out header line(i_item) then the contents of the table will get deleted. Correct me if I'm wrong.
‎2007 Apr 09 4:29 PM
Hi SKJ,
When I add CLEAR i_item. I get no lines outputted.
Cheers,
J
‎2007 Apr 09 4:31 PM
Hi,
Check if the internal table <b>input-I_ITEM-item</b> has two different rows..
Thanks,
Naren
‎2007 Apr 09 4:40 PM
Here is a snippet of the XML I am sending to ABAP proxy:
<I_ITEM>
<item>
<GUID>00000000000000000000000000055556</GUID>
<PARENT>00000000000000000000000000055555</PARENT>
<NUMBER_INT>0000000001</NUMBER_INT>
<DESCRIPTION>Proxy Test Line</DESCRIPTION>
<CATEGORY>268CA1C5BB9965449BED8C9B49484999</CATEGORY>
<CATEGORY_ID>03000</CATEGORY_ID>
<PRODUCT_TYPE>01</PRODUCT_TYPE>
</item>
<item>
<GUID>00000000000000000000000000055557</GUID>
<PARENT>00000000000000000000000000055555</PARENT>
<NUMBER_INT>0000000002</NUMBER_INT>
<DESCRIPTION>Proxy Test Line 2</DESCRIPTION>
<CATEGORY>268CA1C5BB9965449BED8C9B49484999</CATEGORY>
<CATEGORY_ID>03000</CATEGORY_ID>
<PRODUCT_TYPE>01</PRODUCT_TYPE>
</item>
</I_ITEM>
‎2007 Apr 09 4:33 PM
Hi Joe,
check the values of the fields
ls_item-description,
ls_item-number_int,
ls_item-category,
ls_item-category_id,
ls_item-product_type in debugging,
ensure that they are different for the 2 line items.
‎2007 Apr 09 4:56 PM
Hi All, Maybe this will help. When I remove all clear statements and move the APPEND w_item TO i_item outside the ENDLOOP, it writes only the second line from input-I_ITEM-item. So this shows I have two lines but seems to be a problem with my routine moving to next line. Not sure hope this helps.
Cheers,
j
‎2007 Apr 09 5:04 PM
‎2007 Apr 11 3:49 PM
Hi Rich,
Looks like you are correct in that because I am not passing the item-guid as a unique value both records are using the same guid resulting in the record showing as duplicates. I will work through the logical and determine what is wrong, but it looks like it is not an issue with moving through the loop.
Thanks Everyone,
J