Skip to Content
0
Former Member
May 09, 2011 at 05:30 AM

Conditional Internal Table Assignment to Field-Symbol

900 Views

Hi Experts,

I have a code which has 2 internal tables on which either one of them should be assigned to a field-symbol for the LOOP AT syntax below:

DATA: i_temp   TYPE STANDARD TABLE OF t_temp WITH HEADER LINE,
            i_temp_2 LIKE STANDARD TABLE OF i_mat_ser WITH HEADER LINE.

    IF i_temp[ ] IS NOT INITIAL.
      ASSIGN i_temp TO <fs_temp>.

      CREATE DATA v_dref LIKE LINE OF <fs_temp>.
      ASSIGN v_dref->* TO <fs_temp1>.
    ELSE.
      ASSIGN i_temp_2 TO <fs_temp>.

      CREATE DATA v_dref LIKE LINE OF <fs_temp>.
      ASSIGN v_dref->* TO <fs_temp1>.
    ENDIF.
    LOOP AT i_temp2.
    ...
    LOOP AT <fs_temp> ASSIGNING <fs_temp1>.
      IF     <fs_temp1>-matnr = i_temp2-matnr
         AND <fs_temp1>-werks = i_temp2-werks
         AND <fs_temp1>-lgort = i_temp2-lgort.

However, it gives me "I_TEMP[] and <FS_TEMP> are type-incompatible."

I also tried this code:

     DATA: c_temp(6) TYPE c "i_temp"
      CREATE DATA v_table LIKE c_temp.
      ASSIGN v_dref->* TO <fs_temp1>. 

But it does not assign the structure type of the table to the field-symbol. Any ideas on these where any internal table can be assigned to the field-symbol?

Edited by: Matt on May 9, 2011 8:57 AM - added tags