Application Development 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: 

move one work area to other work area using field symbol

former_member383962
Participant

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...

1 ACCEPTED SOLUTION

maheshpalavalli
Active Contributor
0 Kudos

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

3 REPLIES 3

maheshpalavalli
Active Contributor
0 Kudos

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

0 Kudos

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.

0 Kudos

You get all the data in your table right, just write the required code to skip that record while filling it or delete the final table after filling