‎2008 May 29 5:28 PM
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
‎2008 May 29 5:31 PM
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.
‎2008 May 29 5:31 PM
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.
‎2008 May 30 8:24 AM
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
.
‎2008 May 30 9:16 AM
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