2009 Mar 18 12:54 PM
Hi,
Is there a FM or some other approach in SAP which could convert all the field records of a internal table to a string fomat into another internal table.
For e.g
Internal table IT_TAB has four field F1,F2,F3 & F4 with data d1,d2,d3 and d4
This after conversion will look like d1#d2#d3#d4 under 1 field in another internal table.
I tried FM 'SAP_CONVERT_TO_TEX_FORMAT', which is doing the same, but will not work with non unicode elements.
Regards,
Prashant,
2009 Mar 18 1:01 PM
Feel free to use the code:
PERFORM fr_format_error_file TABLES gt_error gt_file. "gt_error is the table with data gt_file is the flat str. table FORM fr_format_error_file TABLES p_final_table
p_output_file.
IF NOT gv_error LT 1.
DATA : lf_buf TYPE string,
lf_line TYPE string,
co_line_feed TYPE c VALUE cl_abap_char_utilities=>cr_lf.
FIELD-SYMBOLS : <fs_record> TYPE ANY,<fs_comp> TYPE ANY.
LOOP AT p_final_table ASSIGNING <fs_record>.
DO.
ASSIGN COMPONENT sy-index OF STRUCTURE <fs_record> TO <fs_comp>.
IF sy-subrc <> 0.
EXIT.
ENDIF.
lf_buf = <fs_comp>.
IF sy-index = 1.
lf_line = lf_buf.
ELSE.
CONCATENATE lf_line lf_buf INTO lf_line SEPARATED BY c_sep. "check what field separator you need
ENDIF.
CLEAR lf_buf.
ENDDO.
CONCATENATE lf_line co_line_feed INTO lf_line.
APPEND lf_line TO p_output_file.
CLEAR lf_line.
ENDLOOP.
ENDIF.
ENDFORM. " FR_FORMAT_ERROR_FILE
Hi,
Is there a FM or some other approach in SAP which could convert all the field records of a internal table to a string fomat into another internal table.
For e.g
Internal table IT_TAB has four field F1,F2,F3 & F4 with data d1,d2,d3 and d4
This after conversion will look like d1#d2#d3#d4 under 1 field in another internal table.
I tried FM 'SAP_CONVERT_TO_TEX_FORMAT', which is doing the same, but will not work with non unicode elements.
Regards,
Prashant,
2009 Mar 18 12:59 PM
hi,
hi,
This can be achieved in the following steps
1) Declare a field symbols <itab> type standard table.
2) Assign your internal table to this field symbols.
3) Assign the field symbols to your required internal table, say table with one column.
Thanks
Sharath
2009 Mar 18 1:01 PM
Feel free to use the code:
PERFORM fr_format_error_file TABLES gt_error gt_file. "gt_error is the table with data gt_file is the flat str. table FORM fr_format_error_file TABLES p_final_table
p_output_file.
IF NOT gv_error LT 1.
DATA : lf_buf TYPE string,
lf_line TYPE string,
co_line_feed TYPE c VALUE cl_abap_char_utilities=>cr_lf.
FIELD-SYMBOLS : <fs_record> TYPE ANY,<fs_comp> TYPE ANY.
LOOP AT p_final_table ASSIGNING <fs_record>.
DO.
ASSIGN COMPONENT sy-index OF STRUCTURE <fs_record> TO <fs_comp>.
IF sy-subrc <> 0.
EXIT.
ENDIF.
lf_buf = <fs_comp>.
IF sy-index = 1.
lf_line = lf_buf.
ELSE.
CONCATENATE lf_line lf_buf INTO lf_line SEPARATED BY c_sep. "check what field separator you need
ENDIF.
CLEAR lf_buf.
ENDDO.
CONCATENATE lf_line co_line_feed INTO lf_line.
APPEND lf_line TO p_output_file.
CLEAR lf_line.
ENDLOOP.
ENDIF.
ENDFORM. " FR_FORMAT_ERROR_FILE
2009 Mar 18 1:02 PM
hi,
Apart from the above post,
you can also try using function module
SOTR_SERV_TABLE_TO_STRING.
SO_TAB_TO_STRING
COPY_CTAB_TO_STRING
Thanks
Sharath
2009 Mar 18 1:06 PM
hi
try this :
TYPES: BEGIN OF ty_asn_head,
f1 type.. ,
f2 type ... ,
f3 type ...
END OF ty_asn_head.
TYPES: BEGIN OF ty_finalstr,
str TYPE string,
END OF ty_finalstr.
DATA: it_asn_head TYPE STANDARD TABLE OF ty_asn_head ,
wa_asn_head TYPE ty_asn_head ,
it_finalstr TYPE STANDARD TABLE OF ty_finalstr,
wa_finalstr TYPE ty_finalstr.
loop at it_asn_head into wa_asn_head .
CONCATENATE wa_asn_head-f1 wa_asn_head-f2 wa_asn_head-f3 into wa_finalstr-str separated by space .
append wa_finalstr into it_finalstr.
ennloop .
regards
sachhi
| User | Count |
|---|---|
| 6 | |
| 3 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 |