2007 May 31 2:29 AM
Hi all,
I have declared an internal table in the following way.
tyeps: begin of tys_sample,
a(9),
b(9),
end of tys_sample.
data: gt_sample type standard table of tys_sample,
gs_sample type tys_sample.
made some operations on the internal table and appended with data, now I need to transfer this internal table content into a dataset.
Did in the following way.
open dataset gv_file for input in text mode " gv_file contains the file path.
transfer gt_sample to dataset gv_file.
while doing syntax check for this program I am getting an error that GT_sample is not an internal table.
I can efford to loop the internal table into work area and pass the work are to the file.
Please let me know the answer. It is urgent.
Thanks in advance.
Regards,
Mungala.
Hi all,
I have declared an internal table in the following way.
tyeps: begin of tys_sample,
a(9),
b(9),
end of tys_sample.
data: gt_sample type standard table of tys_sample,
gs_sample type tys_sample.
made some operations on the internal table and appended with data, now I need to transfer this internal table content into a dataset.
Did in the following way.
open dataset gv_file for input in text mode " gv_file contains the file path.
transfer gt_sample to dataset gv_file.
while doing syntax check for this program I am getting an error that GT_sample is not an internal table.
I can efford to loop the internal table into work area and pass the work are to the file.
Please let me know the answer. It is urgent.
Thanks in advance.
Regards,
Mungala.
2007 May 31 2:32 AM
decalre one varaibel as string
data v_data type string.
loop at gt_sample.
concatenate gt_sample-fld1 ',' gt_sample-fld2 into v_data.
transfer v_data to dataset gv_file.
endloop.
2007 May 31 2:56 AM
You must loop the internal table into a work area and transfer the work area.
tyeps: begin of tys_sample,
a(9),
b(9),
end of tys_sample.
data: gt_sample type standard table of tys_sample,
gs_sample type tys_sample.
open dataset gv_file for input in text mode " gv_file contains the file path.
loop at gt_sample into gs_sample.
transfer gs_sample to gv_file.
endloop.
close dataset gv_file.
Regards,
Rich Heilman
2007 May 31 4:03 AM
Hi Praveen.
*Change your syntax like this.
LOOP AT gt_sample INTO gs_sample.
TRANSFER gs_sample TO gv_file.
ENDLOOP.
Reward points to all useful answers.
Regards,
SaiRam
2007 May 31 4:08 AM
hi Praveena,
do this way ...
tyeps: begin of tys_sample,
a(9),
b(9),
end of tys_sample.
data: gt_sample like tys_sample occurs 0 with header line,
gs_sample type tys_sample.
open dataset gv_file for input in text mode " gv_file contains the file path.
loop at gt_sample into gs_sample.
transfer gs_sample to gv_file.
endloop.
close dataset gv_fileRegards,
Santosh
2007 May 31 4:11 AM
Hey praveena,
There is no direct way to move internal table directly to a file. You will have to loop through each record.
IF you dont wanna move records to work area then, define header line for internal table:
tyeps: begin of tys_sample,
a(9),
b(9),
end of tys_sample.
data: gt_sample type standard table of tys_sample <b>WITH HEADER LINE</b>
gs_sample type tys_sample.
open dataset gv_file for input in text mode " gv_file contains the file path.
loop at GT_SAMPLE.
<b>transfer gt_sample to gv_file</b>.
ENDLOOP.
2025 Sep 05 5:14 PM - edited 2025 Sep 05 5:55 PM
Hi,
Yes can transfer whole internal table to dataset without loop
first convert your internal as CSV using method (cl_ilm_stor_mon_csv_converter ). It will convert multiple column table into single column (CSV separated) row by row it converts.
Now move csv converted data to internal table (string type). Then concatenate all the lines of CSV to single string and convert as XSTRING with UTF-8. Then Transfer single string to open dataset.
DATA: lt_csv TYPE ilm_stor_mon_csv_t_csv_data,
lt_tab TYPE TABLE OF string,
lv_bigstring TYPE string,
lv_xstr TYPE xstring.
"internal table to CSV table
lo_csv->if_ilm_stor_mon_csv_converter~set_delimiter(
EXPORTING
iv_delimiter = ',' ).
lo_csv->if_ilm_stor_mon_csv_converter~data_to_csv(
EXPORTING
iv_data = lt_internal_table
iv_header = abap_true
IMPORTING
et_csv = lt_csv ).
"string table
lt_tab = VALUE #( FOR row IN lt_csv ( row-dataline ) ).
"Concatenate the internal table into one string separated by newline
CONCATENATE LINES OF lt_tab INTO lv_bigstring SEPARATED BY cl_abap_char_utilities=>newline.
"Convert to XSTRING in UTF-8
lv_xstr = cl_bcs_convert=>string_to_xstring(
iv_string = lv_bigstring
iv_codepage = 'UTF-8' ).
"Write in one shot
OPEN DATASET lv_txt_file FOR OUTPUT IN BINARY MODE.
IF sy-subrc = 0.
TRANSFER lv_xstr TO lv_txt_file.
CLOSE DATASET lv_txt_file.
ENDIF.This CONCATENATE will handle 35Lakh lines of internal table.
Regards,
Kalaislevan S.
2025 Sep 08 6:59 PM
Nice find. Of course when I go to use it the constructor has the below.
"==============================================
" As of the release of NetWeaver 7.50 SPS04
" is the ILM Store Monitor obsolete
RAISE EXCEPTION TYPE cx_ilm_stor_mon_runtime
EXPORTING
textid = cx_ilm_stor_mon_runtime=>obsolete.
"==============================================
The (as usual) terrible SAP documentation states that it is obsolete w/o suggesting a replacement.
WTFrig is wrong w/SAP managers that they ship code as such? Sad thing is it appears to work actually.
| User | Count |
|---|---|
| 6 | |
| 2 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 |