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

interface

Former Member
0 Likes
579

Hi,

I need to write data from a internal table to a flat/unix file with records with TAB space. how do i make this pls

my code is as below

OPEN DATASET p_flnam FOR OUTPUT IN TEXT MODE.

*---if the file is not opened display this message

IF sy-subrc NE 0.

MESSAGE i208 WITH 'Error in opening Server file'.

ELSE.

LOOP AT t_sat INTO wa_sat.

TRANSFER wa_sat TO p_flnam.

ENDLOOP.

CLOSE DATASET p_flnam.

*---if the file is not closed display this message

IF sy-subrc NE 0.

MESSAGE i208 WITH 'Error in closing Server file'.

ENDIF.

ENDIF.

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
557

DATA: file TYPE string VALUE `flights.dat`,

wa TYPE spfli.

FIELD-SYMBOLS TYPE x.

OPEN DATASET file FOR OUTPUT IN BINARY MODE.

SELECT *

FROM spfli

INTO wa.

ASSIGN wa TO CASTING.

TRANSFER TO file.

ENDSELECT.

CLOSE DATASET file.

For TAB Space you concatenate the wa_sat with tab and TRANSFER it.. tht's the only way....

3 REPLIES 3
Read only

Former Member
0 Likes
557

U can do like this:


CONSTANTS: CON_TAB TYPE X VALUE '09'.
  OPEN DATASET P_FILE FOR OUTPUT IN TEXT MODE.
  IF SY-SUBRC = 0.
LOOP AT G_T_OUTTAB.
        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.
 TRANSFER OUTPUT TO P_FILE.
 ENDLOOP.
 CLOSE DATASET P_FILE.

If useful reward.

Vasanth

Read only

Former Member
0 Likes
557

Hi,

<b>data : l_string type string.</b>

OPEN DATASET p_flnam FOR OUTPUT IN TEXT MODE.

*---if the file is not opened display this message

IF sy-subrc NE 0.

MESSAGE i208 WITH 'Error in opening Server file'.

ELSE.

LOOP AT t_sat INTO wa_sat.

<b>concatenate wa_sat-field1

wa_sat-field2

wa_sat-field3

into l_string

separated by cl_abap_char_utilities=>horizontal_tab.</b>

<b>TRANSFER l_string TO p_flnam.</b>

ENDLOOP.

CLOSE DATASET p_flnam.

*---if the file is not closed display this message

IF sy-subrc NE 0.

MESSAGE i208 WITH 'Error in closing Server file'.

ENDIF.

ENDIF.

Best regards,

Prashant

Read only

Former Member
0 Likes
558

DATA: file TYPE string VALUE `flights.dat`,

wa TYPE spfli.

FIELD-SYMBOLS TYPE x.

OPEN DATASET file FOR OUTPUT IN BINARY MODE.

SELECT *

FROM spfli

INTO wa.

ASSIGN wa TO CASTING.

TRANSFER TO file.

ENDSELECT.

CLOSE DATASET file.

For TAB Space you concatenate the wa_sat with tab and TRANSFER it.. tht's the only way....