2006 Jul 10 3:49 PM
Hello,
I was trying to define an internal table in such a way that say 'string_a (tab_sign) string_b' I have, and I used split statement to split them into an internal table with 2 columns that are both of type string.
However, when I tried to read the internal table of index 1, i always ended up getting the last line of the record instead of the first one. May I know why that happen? Thanks a lot!
Regards,
anyi
2006 Jul 10 4:06 PM
Hi,
Try using Read gt_inbound into wa_inbound index 1.
Best regards,
Prashant
PS : Check in debug mode whether the internal table is populated correctly
Hello,
I was trying to define an internal table in such a way that say 'string_a (tab_sign) string_b' I have, and I used split statement to split them into an internal table with 2 columns that are both of type string.
However, when I tried to read the internal table of index 1, i always ended up getting the last line of the record instead of the first one. May I know why that happen? Thanks a lot!
Regards,
anyi
2006 Jul 10 3:50 PM
2006 Jul 10 3:57 PM
Err...the problem is I just want to read the first record that was taken in w.r.t. the original order, with no sorting...
any suggestions?
Thanks!
anyi
2006 Jul 10 3:59 PM
2006 Jul 10 4:02 PM
Sure, sorry
FORM PC_SSL_UPLOAD TABLES P_UPLOAD_DATA
USING WA_UPLOAD_DATA STRUCTURE WA_UPLOAD_DATA.
LOOP AT LT_UPLOAD_DATA INTO WA_UPLOAD_DATA.
SPLIT WA_UPLOAD_DATA-DATA AT CL_ABAP_CHAR_UTILITIES=>HORIZONTAL_TAB
INTO:
WA_INBOUND-REC_TYPE
WA_INBOUND-DATA,
TABLE GT_INBOUND.
APPEND WA_INBOUND TO GT_INBOUND.
ENDLOOP.
ENDFORM. "PC_SSL_UPLOAD
This is the code used to split the internal table
READ TABLE GT_INBOUND INDEX 1 INTO WA_INBOUND.
This is the code used to read the table
And the first line always ends up to be the last line from the internal table where the .txt file was loaded into.
Thanks!
Anyi
2006 Jul 10 4:12 PM
Did you mean to be looping at P_UPLOAD_DATA instead of LT_UPLOAD_DATA?
2006 Jul 10 4:18 PM
> Did you mean to be looping at P_UPLOAD_DATA instead
> of LT_UPLOAD_DATA?
Nope, P_UPLOAD_DATA is where I load the txt from and LT_UOPLOAD_DATA is where I load the file into.
Thanks for the comments.
Anyi
2006 Jul 10 4:26 PM
FORM PC_SSL_UPLOAD TABLES P_UPLOAD_DATA
USING WA_UPLOAD_DATA STRUCTURE WA_UPLOAD_DATA.
LOOP AT LT_UPLOAD_DATA INTO WA_UPLOAD_DATA.
SPLIT WA_UPLOAD_DATA-DATA AT CL_ABAP_CHAR_UTILITIES=>HORIZONTAL_TAB
INTO
WA_INBOUND-REC_TYPE
WA_INBOUND-DATA.
APPEND WA_INBOUND TO GT_INBOUND.
clear wa_inbound.
ENDLOOP.
ENDFORM. "PC_SSL_UPLOAD
READ TABLE GT_INBOUND INDEX 1 INTO WA_INBOUND.
Do as above.
Regards,
ravi
2006 Jul 10 3:54 PM
hi anyi,
sort the internal table .
and in read stmt give...
read itab with key.. binary search.
2006 Jul 10 3:58 PM
Hi,
The syntax is :
read table it_tab into wa_tab index 1.
Best regards,
Prashant
PS. Please paste the code if in case the problem is not solved
2006 Jul 10 4:06 PM
Hi,
Try using Read gt_inbound into wa_inbound index 1.
Best regards,
Prashant
PS : Check in debug mode whether the internal table is populated correctly
2006 Jul 10 4:17 PM
I checked my input internal table, it does work properly, also I changed the code that Prashant has suggested. However, the problem seems that each time the loop runs, the previous line in the internal table was overwritten, instead of getting stored in the actual internal table. Any more suggestions?
Anyi
2006 Jul 10 4:23 PM
I'm thinking you need to remove the TABLE from your SPLIT statement.
2006 Jul 10 4:30 PM
Really smart guy, thanks a lot Matt.
> I'm thinking you need to remove the TABLE from your
> SPLIT statement.
2006 Jul 10 4:33 PM
2006 Jul 10 4:06 PM
you are not sorting the table before u read it. Try doing that once.
2006 Jul 10 4:07 PM
Hi Anyi,
Add(in bold) the Following in the FORM.
FORM pc_ssl_upload TABLES p_upload_data
USING wa_upload_data STRUCTURE wa_upload_data.
<b>SORT lt_upload_data BY rec_type.</b>
LOOP AT lt_upload_data INTO wa_upload_data.
SPLIT wa_upload_data-data AT cl_abap_char_utilities=>horizontal_tab
INTO:
wa_inbound-rec_type
wa_inbound-data,
TABLE gt_inbound.
APPEND wa_inbound TO gt_inbound.
<b> CLEAR wa_inbound.</b>
ENDLOOP.
ENDFORM. "PC_SSL_UPLOAD
Then try reading.
Regards,
Arun Sambargi.
2006 Jul 10 4:21 PM
Err...I do believe in the previous post, I mentioned that I would like to have the order of the code as the way it is (i.e., the way it was loaded from p_upload_data), and not in any other order.
Thanks!
Anyi
> Hi Anyi,
>
> Add(in bold) the Following in the FORM.
>
>
> FORM pc_ssl_upload TABLES p_upload_data
> USING wa_upload_data STRUCTURE
> upload_data STRUCTURE wa_upload_data.
>
> <b>SORT lt_upload_data BY rec_type.</b>
>
> LOOP AT lt_upload_data INTO wa_upload_data.
> SPLIT wa_upload_data-data AT
> a AT cl_abap_char_utilities=>horizontal_tab
> INTO:
> wa_inbound-rec_type
> wa_inbound-data,
> TABLE gt_inbound.
> APPEND wa_inbound TO gt_inbound.
>
> <b> CLEAR wa_inbound.</b>
>
> ENDLOOP.
>
> ENDFORM. "PC_SSL_UPLOAD
>
> >
> Then try reading.
>
> Regards,
> Arun Sambargi.
Err...I do
2006 Jul 10 4:33 PM
HI,
Try this
LOOP AT lt_upload_data INTO wa_upload_data.
SPLIT wa_upload_data-data AT
a AT cl_abap_char_utilities=>horizontal_tab
INTO:
wa_inbound-rec_type
wa_inbound-data,
table lit_temp.
append lines of lit_temp to gt_inbound.
APPEND wa_inbound TO gt_inbound.
CLEAR wa_inbound.
ENDLOOP.
2006 Jul 10 4:26 PM
Hi
for not to disturb the original order we can do it by below coding:
data : l_lines type i.
describe table gt_inbound lines into l_lines.
READ TABLE GT_INBOUND INDEX l_lines INTO WA_INBOUND.
2006 Jul 10 4:33 PM
Hi
you need to remove the table parameter.
either you need to used only fields or table.
| User | Count |
|---|---|
| 4 | |
| 2 | |
| 2 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 |