02-02-2007 1:49 PM
Hi experts,
I have to READ a itab into a workarea which is not type of the itab. The wa has one field more than the itab.
To makes it clear here are the definitions:
TYPES: BEGIN OF lab_dispo_struk,
lab_dispo_struk LIKE zmm_lab_dispo,
celltab TYPE LVC_T_STYL,
END OF lab_dispo_struk.
DATA: it_lab_dispo TYPE TABLE OF zmm_lab_dispo,
it_lab_dispo2 TYPE TABLE OF lab_dispo_struk
.
DATA:
wa_lab_dispo TYPE zmm_lab_dispo,
wa_lab_dispo2 LIKE LINE OF it_lab_dispo2
.
And here my itab-reading:
LOOP AT it_lvc_rows INTO ls_selected_line.
lf_row_index = ls_selected_line-index.
READ TABLE it_lab_dispo INDEX lf_row_index INTO wa_lab_dispo2.
APPEND wa_lab_dispo2 TO it_lab_dispo2.
ENDLOOP.
So it's not working because it_lab_dispo and wa_lab_dispo2 has different type. And this also don't work (of course):
READ TABLE it_lab_dispo INDEX lf_row_index INTO wa_lab_dispo.
APPEND wa_lab_dispo TO it_lab_dispo2.
So is it possible to make such an reading?? Do I have to make it with the ASSIGNING or WITH TABLE KEY?? Then please write some code-snipes.
Bytheway: it is not possible to extend the "it_lab_dispo" with the celltab-field. That would be come to much work, because there are so much other code to be fixed...
With my application I want to reproduce the BCALV_EDIT_02 in OO...
Regards,
Steffen
02-02-2007 1:56 PM
Hi Steffen,
Why can't you use the wa_lab_dispo for reading into?
LOOP AT it_lvc_rows INTO ls_selected_line.
lf_row_index = ls_selected_line-index.
READ TABLE it_lab_dispo INDEX lf_row_index INTO wa_lab_dispo.
if sy-subrc = 0.
wa_lab_dispo2-lab_dispo_struk = wa_lab_dispo.
APPEND wa_lab_dispo2 TO it_lab_dispo2.
endif.
ENDLOOP.
REgards,
Ravi
02-02-2007 1:56 PM
Hi Steffen,
Why can't you use the wa_lab_dispo for reading into?
LOOP AT it_lvc_rows INTO ls_selected_line.
lf_row_index = ls_selected_line-index.
READ TABLE it_lab_dispo INDEX lf_row_index INTO wa_lab_dispo.
if sy-subrc = 0.
wa_lab_dispo2-lab_dispo_struk = wa_lab_dispo.
APPEND wa_lab_dispo2 TO it_lab_dispo2.
endif.
ENDLOOP.
REgards,
Ravi
02-02-2007 2:02 PM
hmm cool it seems that this:
wa_lab_dispo2-lab_dispo_struk = wa_lab_dispo.
works well.
But what I don't understand is that the "lab_dispo_struk" isn't a field of the wa2! I thought that i declared the wa2 to itab2 which has the structur of lab_struk_dispo
wa_lab_dispo2 --> it_lab_dispo2 --> lab_dispo_struk
How ever it works well with your example...
regards,
Steffen
02-02-2007 2:08 PM
Hi Steffen,
"But what I don't understand is that the "lab_dispo_struk" isn't a field of the wa2! I thought that i declared the wa2 to itab2 which has the structur of lab_struk_dispo
"
wa_lab_dispo2 refers to it_lab_dispo2 which in trun refers to lab_dispo_struk
which does have a field lab_dispo_struk. What is the problem then?
Regards,
ravi
02-02-2007 2:26 PM
ah sorry my fault,
I thought with this coding:
TYPES: BEGIN OF lab_dispo_struk,
lab_dispo_struk LIKE zmm_lab_dispo,
celltab TYPE LVC_T_STYL,
END OF lab_dispo_struk.
the lab_dispo_struk has all<b> fields</b> of zmm_lab_dispo (trans.tab) <b>and</b> the extended field celltab
02-02-2007 1:57 PM
02-02-2007 2:05 PM
Hi Rich,
this don't work for me. The error: WA2 cannot be converted into WA!
Thanks
Regards
Steffen
02-02-2007 2:03 PM
Hello Steffen
Please make the following changes to your coding:
TYPES: BEGIN OF lab_dispo_struk,
lab_dispo_struk LIKE zmm_lab_dispo AS data,
celltab TYPE LVC_T_STYL,
END OF lab_dispo_struk.
I assume that it_lab_dispo2 is the itab for your ALV entries. Thus, simply use the DATA part of the ALV entries and fill your 2nd itab without the ALV-specific fields (i.e. CELLTAB).
LOOP AT it_lvc_rows INTO ls_selected_line.
lf_row_index = ls_selected_line-index.
READ TABLE it_lab_dispo2 INDEX lf_row_index INTO wa_lab_dispo2.
APPEND wa_lab_dispo2-data TO it_lab_dispo.
ENDLOOP.
Regards
Uwe