Application Development and Automation 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: 
Read only

SPlit Dynamic Table data (FIeldsymbol) ?

Former Member
0 Likes
2,417

Hello All,

I have a dynamic internal Table in the form of a Field Symbol.

Now I need to split the fields of this fieddsymbols data at each field separated by a ' ; '.

and then pass the content to a character type variable.

Can anyone tell me how to achieve this ?

Regards,

Deepu.K

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
1,001

Hello,

Try this:


DATA itab TYPE TABLE OF string.

FIELD-SYMBOLS:
  <tab>   TYPE ANY TABLE,
  <wa>    TYPE ANY,
  <field> TYPE ANY.

    LOOP AT <tab> ASSIGNING <wa>.
      DO.
        ASSIGN COMPONENT sy-index OF STRUCTURE <wa> TO <field>.
        IF sy-subrc = 0.
         SPLIT <field> AT ';' INTO  TABLE itab. 
        ELSE.
          EXIT.
        ENDIF.
      ENDDO.
    ENDLOOP.

In itab each field separated by ; will be a line,

Regards.

3 REPLIES 3
Read only

Former Member
0 Likes
1,002

Hello,

Try this:


DATA itab TYPE TABLE OF string.

FIELD-SYMBOLS:
  <tab>   TYPE ANY TABLE,
  <wa>    TYPE ANY,
  <field> TYPE ANY.

    LOOP AT <tab> ASSIGNING <wa>.
      DO.
        ASSIGN COMPONENT sy-index OF STRUCTURE <wa> TO <field>.
        IF sy-subrc = 0.
         SPLIT <field> AT ';' INTO  TABLE itab. 
        ELSE.
          EXIT.
        ENDIF.
      ENDDO.
    ENDLOOP.

In itab each field separated by ; will be a line,

Regards.

Read only

0 Likes
1,001

Hello David,

I have written the following code to get the data from my field-symbol table into a char field separated by ' ; '.


* From the Dynamic Table get the content into a char field separated by ';'
  CLEAR lv_line.
  LOOP AT <dyn_table> ASSIGNING <dyn_wa>.
    DO.
      ASSIGN COMPONENT sy-index OF STRUCTURE <dyn_wa> TO <fs_split>.
      IF sy-subrc = 0.
        CONCATENATE lv_line <fs_split> INTO lv_line SEPARATED BY ';'.
        IF lv_line+0(1) = ';'.
          lv_line+0(1) = ' '.
          CONDENSE lv_line NO-GAPS.
        ENDIF.
*        TRANSFER lv_line TO p_lv_file.
      ELSE.
        EXIT.
      ENDIF.
    ENDDO.
    TRANSFER lv_line TO p_lv_file.
  ENDLOOP.

But when the concatenate statement is facing a TYPE P field it's going for a dump saying :


The current statement only supports character-type data objects.

In statement
   "CONCATENATE"
the argument "<FS_SPLIT>" can only take a character-type data object.

In this case, the operand "<FS_SPLIT>" has the non-character type "P".

How to overcome this situation ?

Regards,

Deepu.K

.

Read only

0 Likes
1,001

Hello All,

I solved the issue.

I checked the field type using the DESCRIBE FIELD Syntax

and when it is type P I unpacked it into a Char variable and then proceeded.

Here is the code :


* From the Dynamic Table get the content into a char field separated by ';'
  CLEAR lv_line.
  LOOP AT <dyn_table> ASSIGNING <dyn_wa>.
    DO.
      ASSIGN COMPONENT sy-index OF STRUCTURE <dyn_wa> TO <fs_dyn_line>.
      IF sy-subrc = 0.
        CLEAR lv_data_type.
        DESCRIBE FIELD <fs_dyn_line> TYPE lv_data_type.
        IF lv_data_type = 'P'.
          UNPACK <fs_dyn_line> TO lv_char.
          CONCATENATE lv_line lv_char INTO lv_line SEPARATED BY ';'.
        ELSE.
          CONCATENATE lv_line <fs_dyn_line> INTO lv_line SEPARATED BY ';'.
          IF lv_line+0(1) = ';'.
            lv_line+0(1) = ' '.
            CONDENSE lv_line NO-GAPS.
          ENDIF.
        ENDIF.
      ELSE.
        EXIT.
      ENDIF.
    ENDDO.
    TRANSFER lv_line TO p_lv_file.
    CLEAR lv_line.
  ENDLOOP.

Regards,

Deepu.K