11-29-2018 4:49 AM
Hello Experts,
work area 1: (deep structure)
from the above table i deleted first row. now i have 2nd row only. i.e., record
work area 2: (flat structure)
Now i want to move work area 1 value to work area 2.
I tried <wa2> = <wa1>, but it throws an error.
any suggestions please..
thanks in advance...
11-29-2018 5:31 AM
Hi Kabilarasan,
Move corresponding will not work in this case as the field names are different..
you need to read every single field and pass it to the target structure, for this you need to use assign component keyword. you can google and check in SAP Blogs and answers more on how to use this. example below:
FIELD-SYMBOLS: <ft_excel_data> TYPE ANY TABLE,
<ft_conv_data> TYPE STANDARD TABLE,
<fs_excel_data> TYPE any,
<fs_conv_data> TYPE any,
<fs_comp_excel> TYPE any,
<fs_comp_target> TYPE any.
LOOP AT <ft_excel_data> ASSIGNING <fs_excel_data>. " Internal Table Scenario
IF sy-tabix = 1. " First line is header, if you have header line
CONTINUE.
ENDIF.
" Target internal table <ft_conv_data>
APPEND INITIAL LINE TO <ft_conv_data> ASSIGNING <fs_conv_data>.
DATA(lv_flag) = abap_true.
WHILE lv_flag = abap_true.
DATA(lv_index) = sy-index.
* Read columnwise entries
ASSIGN COMPONENT lv_index OF STRUCTURE <fs_excel_data> TO <fs_comp_excel>.
IF <fs_comp_excel> IS NOT ASSIGNED.
lv_flag = abap_false.
* Exit the loop when a row ends
EXIT.
ELSE.
ASSIGN COMPONENT lv_index OF STRUCTURE <fs_conv_data> TO <fs_comp_target>.
<fs_comp_target> = <fs_comp_excel>.
ENDIF.
* Unassign field symbol
UNASSIGN: <fs_comp_excel>, <fs_comp_target>.
ENDWHILE.
ENDLOOP.
BR,
Mahesh
11-29-2018 5:31 AM
Hi Kabilarasan,
Move corresponding will not work in this case as the field names are different..
you need to read every single field and pass it to the target structure, for this you need to use assign component keyword. you can google and check in SAP Blogs and answers more on how to use this. example below:
FIELD-SYMBOLS: <ft_excel_data> TYPE ANY TABLE,
<ft_conv_data> TYPE STANDARD TABLE,
<fs_excel_data> TYPE any,
<fs_conv_data> TYPE any,
<fs_comp_excel> TYPE any,
<fs_comp_target> TYPE any.
LOOP AT <ft_excel_data> ASSIGNING <fs_excel_data>. " Internal Table Scenario
IF sy-tabix = 1. " First line is header, if you have header line
CONTINUE.
ENDIF.
" Target internal table <ft_conv_data>
APPEND INITIAL LINE TO <ft_conv_data> ASSIGNING <fs_conv_data>.
DATA(lv_flag) = abap_true.
WHILE lv_flag = abap_true.
DATA(lv_index) = sy-index.
* Read columnwise entries
ASSIGN COMPONENT lv_index OF STRUCTURE <fs_excel_data> TO <fs_comp_excel>.
IF <fs_comp_excel> IS NOT ASSIGNED.
lv_flag = abap_false.
* Exit the loop when a row ends
EXIT.
ELSE.
ASSIGN COMPONENT lv_index OF STRUCTURE <fs_conv_data> TO <fs_comp_target>.
<fs_comp_target> = <fs_comp_excel>.
ENDIF.
* Unassign field symbol
UNASSIGN: <fs_comp_excel>, <fs_comp_target>.
ENDWHILE.
ENDLOOP.
BR,
Mahesh
11-29-2018 10:54 AM
Hello maheshkumar.palavalli ,
from your code, that the <ft_excel_data> contains records and also the blank records.
is it possible to delete the blank records.
11-29-2018 11:29 AM