2006 Jul 05 5:53 AM
Hi All,
We have a requirement wherein we have to download an internal table containing Sales order data onto the Application server in text format.
I have populated the internal table with the necessary Sales order data for given sales order.
please guide me as to how can this be achieved.
Thanks in advance,
Sharat.
2006 Jul 05 6:01 AM
try this one
this is sample code only.
<b>
open dataset filename for output in text mode encoding utf-8.
if sy-subrc ne '0'.
message e398(00) with 'File' filename 'cannot be opened' .
"File & cannot be opened
endif.
clear wa_data.
loop at <l_table> assigning <l_line>.
do. "Max no of fields
assign component sy-index of structure <l_line> to <l_field>.
if sy-subrc ne 0.
exit.
endif.
clear lstring.
lstring = <l_field>.
read table i_table index sy-index.
if i_table-inttype = 'D'. "Date field.
if lstring = '00000000' or lstring is initial.
clear lstring.
else.
concatenate lstring+0(4) '-' lstring+4(2)
'-' lstring+6(2) into lstring.
endif.
endif.
if sy-index = 1.
wa_data = lstring.
else.
concatenate wa_data '|' lstring into wa_data.
endif.
condense wa_data .
enddo.
transfer wa_data to filename.
clear wa_data.
endloop.
close dataset filename.</b>
Regards
Prabhu
Hi All,
We have a requirement wherein we have to download an internal table containing Sales order data onto the Application server in text format.
I have populated the internal table with the necessary Sales order data for given sales order.
please guide me as to how can this be achieved.
Thanks in advance,
Sharat.
2006 Jul 05 5:55 AM
2006 Jul 05 5:57 AM
Hi Sharat,
<b>Use OPEN DATASET, TRANSFER and CLOSE DATASET statements</b> to place internal table on to Application server.
Try with this code.
DATA P_AFILE LIKE FILENAME-FILEINTERN.
*-- Open Dataset
OPEN DATASET P_AFILE FOR INPUT IN TEXT MODE ENCODING DEFAULT.
IF SY-SUBRC EQ 0.
DO.
*-- Read Dataset and Populate Input file data to Internal Table
READ DATASET P_AFILE INTO IT_RECORD.
IF SY-SUBRC EQ 0.
APPEND IT_RECORD.
CLEAR IT_RECORD.
ELSE.
EXIT.
ENDIF.
ENDDO.
ELSE.
MESSAGE 'Input File not found'(100) TYPE 'I'.
LEAVE LIST-PROCESSING.
ENDIF.
ENDIF.
*-- Close Dataset
CLOSE DATASET P_AFILE.
Thanks,
Vinay
2006 Jul 05 5:57 AM
Sharat,
You can make use of OPEN DATA SET.
See the example code for downloading to application server here--> http://abap4.tripod.com/Upload_and_Download_ABAP_Source_Code.html
Also see the help @ http://abap4.tripod.com/Upload_and_Download_ABAP_Source_Code.html
\rgds,
TM.
2006 Jul 05 5:57 AM
Hi Sharat,
Step 1.
Use the FM GUI_DOWNLOAD and download that internal table as TXT file on your presentation server(PC).
Step 2.
Run transaction CG3Z and put your txt file in the source file on front end and any file name in the target file on application server.
That file will be created on the application server and the data will be transferred to the file on the application server.
Message was edited by: mukesh kumar
2006 Jul 05 6:01 AM
try this one
this is sample code only.
<b>
open dataset filename for output in text mode encoding utf-8.
if sy-subrc ne '0'.
message e398(00) with 'File' filename 'cannot be opened' .
"File & cannot be opened
endif.
clear wa_data.
loop at <l_table> assigning <l_line>.
do. "Max no of fields
assign component sy-index of structure <l_line> to <l_field>.
if sy-subrc ne 0.
exit.
endif.
clear lstring.
lstring = <l_field>.
read table i_table index sy-index.
if i_table-inttype = 'D'. "Date field.
if lstring = '00000000' or lstring is initial.
clear lstring.
else.
concatenate lstring+0(4) '-' lstring+4(2)
'-' lstring+6(2) into lstring.
endif.
endif.
if sy-index = 1.
wa_data = lstring.
else.
concatenate wa_data '|' lstring into wa_data.
endif.
condense wa_data .
enddo.
transfer wa_data to filename.
clear wa_data.
endloop.
close dataset filename.</b>
Regards
Prabhu
2006 Jul 05 6:32 AM
Hi,
OPEN DATASET <p_file> FOR OUTPUT IN TEXT MODE
ENCODING NON-UNICODE IGNORING CONVERSION ERRORS.
LOOP AT <ITAB> INTO <WORK AREA>.
Transfer <WORK AREA> TO <p_file>.
ENDLOOP.
CLOSE DATASET <p_file>.
Regs,
Venkat Ramanan
2006 Jul 05 6:57 AM
Hi,
when i use OPEN DATASET <p_file> FOR OUTPUT IN TEXT MODE
ENCODING NON-UNICODE IGNORING CONVERSION ERRORS. its giving a run time error as
UC_OBJECTS_NOT_CHARLIKE
Only character-type data objects are supported at the argument
position "f" for the statement
"TRANSFER f TO ...".
In this case, the operand "f" has the non-character-type "TY_OUTPUT". The
current program is flagged as a Unicode program. In the Unicode context,
type X fields are seen as non-character-type, as are structures that
contain non-character-type components.
-
The internal table i am writing to the file has non-char types also..
when i tried writing the file in binary mode it was successful.
Is there any workaround for this ?
2006 Jul 05 7:04 AM
Hi Sharat,
If you are working with UNICODE enabled system then change your ENCODING clause to DEFAULT in OPEN DATASET statement.
OPEN DATASET <p_file> FOR OUTPUT IN TEXT MODE
<b>ENCODING DEFAULT.</b>
Thanks,
Vinay
2006 Jul 05 6:07 PM
HI SHARAT,
GIVE
<b>OPEN DATASET <p_file> FOR OUTPUT IN TEXT MODE
ENCODING DEFAULT.</b>
2006 Jul 14 9:43 AM
HI Sarat!
see the oss note number 886613!
or use the example code above extracted from the note.
data: l_record(1000) type c. field-symbols: <l_record> type x, <l_progtree> type x.
[...]
OPEN DATASET L_FILE FOR OUTPUT IN TEXT MODE
encoding default.
>>> Unicode changes (end) <<<
IF SY-SUBRC <> 0.
MESSAGE A....
ENDIF.
[...]
assign l_record to <l_record> casting.
loop at it_progtree.
assign it_progtree to <l_progtree> casting.
<l_record> = <l_progtree>.
transfer l_record to l_file.
endloop.
[...]
close data set
mark the point!
2006 Jul 05 7:12 AM
Hi Sharat,
Consider this program I have explained with comments.
REPORT ztest.
*--Internal table Declaration
DATA : t_data TYPE STANDARD TABLE OF t000,
wa_data TYPE t000.
DATA : w_message(100) TYPE c.
*--Get the Application Server File path from user
PARAMETERS : p_file TYPE rlgrap-filename.
START-OF-SELECTION.
SELECT * FROM t000 INTO TABLE t_data .
*--- The file mentioned in the application server file path is created
OPEN DATASET p_file FOR OUTPUT IN TEXT MODE ENCODING DEFAULT MESSAGE w_message.
IF sy-subrc NE 0.
MESSAGE w_message TYPE 'E'.
EXIT.
ELSE.
*---Data is downloaded to the file path
LOOP AT t_data INTO wa_data.
TRANSFER wa_data TO p_file.
ENDLOOP.
ENDIF.
*--Close the Application server file(Mandatory) .
CLOSE DATASET p_file.
IF sy-subrc NE 0.
MESSAGE 'Error closing the File' TYPE 'E'.
EXIT.
ELSEIF sy-subrc IS INITIAL.
WRITE : 'File saved in the location' , p_file.
ENDIF.
Regards,
Arun Sambargi.
Message was edited by: Arun Sambargi
2006 Jul 14 9:45 AM
Hello,
U can use the code
FORM DOWNLOAD_DATA.
DATA: OUTPUT TYPE STRING,
L_F_NETWR(21) TYPE C,
L_F_ERDAT_OR(10),
L_F_ERDAT_IN(10),
L_F_ERDAT_DE(10),
L_F_POSID LIKE PRPS-POSID.
OPEN DATASET P_FILE FOR OUTPUT IN TEXT MODE.
IF SY-SUBRC = 0.
LOOP AT G_T_OUTTAB.
CLEAR L_F_NETWR.
WRITE: G_T_OUTTAB-NETWR TO L_F_NETWR,
G_T_OUTTAB-ERDAT_OR TO L_F_ERDAT_OR,
G_T_OUTTAB-ERDAT_IN TO L_F_ERDAT_IN,
G_T_OUTTAB-ERDAT_DE TO L_F_ERDAT_DE.
CALL FUNCTION 'CONVERSION_EXIT_ABPSP_OUTPUT'
EXPORTING
INPUT = G_T_OUTTAB-PS_PSP_PNR
IMPORTING
OUTPUT = L_F_POSID.
IF NOT P_TAB IS INITIAL.
CONCATENATE G_T_OUTTAB-VBELN
G_T_OUTTAB-POSNR
G_T_OUTTAB-VKBUR
L_F_POSID
G_T_OUTTAB-BSTKD
L_F_NETWR
L_F_ERDAT_OR
L_F_ERDAT_IN
G_T_OUTTAB-VBELN_IN
L_F_ERDAT_DE
G_T_OUTTAB-VBELN_DE
INTO OUTPUT
SEPARATED BY CON_TAB.
ELSE.
CONCATENATE G_T_OUTTAB-VBELN
G_T_OUTTAB-POSNR
G_T_OUTTAB-VKBUR
L_F_POSID
G_T_OUTTAB-BSTKD
L_F_NETWR
L_F_ERDAT_OR
L_F_ERDAT_IN
G_T_OUTTAB-VBELN_IN
L_F_ERDAT_DE
G_T_OUTTAB-VBELN_DE
INTO OUTPUT
SEPARATED BY P_TRZEI.
ENDIF.
TRANSFER OUTPUT TO P_FILE.
CLEAR L_F_NETWR.
ENDLOOP.
ELSE.
MESSAGE E041(S9) WITH P_FILE.
ENDIF.
CLOSE DATASET P_FILE.
ENDFORM. " DOWNLOAD_DATA
If useful reward points.
Regards,
Vasanth
2006 Jul 14 9:52 AM
Hai Sarat
Go through the following Code
data: v_hex type x,
v_bit type n.
open dataset file_name for input in binary mode encoding default.
do.
read dataset file_name into v_hex.
if sy-subrc ne 0.
close dataset file_name
exit.
endif
do 8 times.
get bit sy-index of v_hex into v_bit.
write v_bit no-gap.
enddo.
enddo.
Regards
Sreenivasulu P
| User | Count |
|---|---|
| 4 | |
| 2 | |
| 2 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 |