Application Development 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: 

Need in output text file several empty fields between database fields

Former Member
0 Kudos

hi

i need to display some empty fields in the output txt file, in between teh normal database fields i am displaying

for eg if first field is f1 (1-10)

second is f2 (11-35)

third field is empty i need todisplay as (12-45)

and again f4 as (13-60) so on

such there are multiple fields in between dattabase field which just needs to be displayed as empty only and all fields should be seperated by space as showni above eg

regards

arora

1 ACCEPTED SOLUTION

Former Member
0 Kudos

HI Arora

If you declare as a structure and transfer this structure then you can get the EMPTY fields.

Also you can consider using the offset operations incase of downloading as a single string.

Check this example:

After executing the code, you can check the file via AL11.

parameters: p_file type filename.
types: begin of t_dat,
         bukrs type bukrs,
         sep(10) type c,
         butxt type butxt,
       end of t_dat.

data: it_dat type table of t_dat,
      wa_dat type t_dat.

select bukrs butxt into corresponding fields of table it_dat
       from t001.

translate p_file to lower case.
open dataset p_file for output in text mode encoding default.
if sy-subrc eq 0.
   loop at it_dat into wa_dat.
        transfer wa_dat to p_file.
   endloop.
   close dataset p_file.
endif.

Kind Regards

Eswar

Message was edited by:

Eswar Rao Boddeti

3 REPLIES 3

Former Member
0 Kudos

HI Arora

If you declare as a structure and transfer this structure then you can get the EMPTY fields.

Also you can consider using the offset operations incase of downloading as a single string.

Check this example:

After executing the code, you can check the file via AL11.

parameters: p_file type filename.
types: begin of t_dat,
         bukrs type bukrs,
         sep(10) type c,
         butxt type butxt,
       end of t_dat.

data: it_dat type table of t_dat,
      wa_dat type t_dat.

select bukrs butxt into corresponding fields of table it_dat
       from t001.

translate p_file to lower case.
open dataset p_file for output in text mode encoding default.
if sy-subrc eq 0.
   loop at it_dat into wa_dat.
        transfer wa_dat to p_file.
   endloop.
   close dataset p_file.
endif.

Kind Regards

Eswar

Message was edited by:

Eswar Rao Boddeti

Former Member
0 Kudos

Hi,

Pass the blank values in the internal table..

Check this example..

DATA: BEGIN OF ITAB OCCURS 0,

MATNR TYPE MATNR,

VBELN TYPE VBELN,

POSNR TYPE POSNR,

END OF ITAB.

ITAB-MATNR = 'ASDFAS'.

ITAB-POSNR = '000010'.

APPEND ITAB.

ITAB-MATNR = 'BBBBBB'.

ITAB-POSNR = '000030'.

APPEND ITAB.

CALL FUNCTION 'GUI_DOWNLOAD'

EXPORTING

filename = 'C:\TEST.TXT'

tables

data_tab = ITAB

EXCEPTIONS

FILE_WRITE_ERROR = 1

NO_BATCH = 2

GUI_REFUSE_FILETRANSFER = 3

INVALID_TYPE = 4

NO_AUTHORITY = 5

UNKNOWN_ERROR = 6

HEADER_NOT_ALLOWED = 7

SEPARATOR_NOT_ALLOWED = 8

FILESIZE_NOT_ALLOWED = 9

HEADER_TOO_LONG = 10

DP_ERROR_CREATE = 11

DP_ERROR_SEND = 12

DP_ERROR_WRITE = 13

UNKNOWN_DP_ERROR = 14

ACCESS_DENIED = 15

DP_OUT_OF_MEMORY = 16

DISK_FULL = 17

DP_TIMEOUT = 18

FILE_NOT_FOUND = 19

DATAPROVIDER_EXCEPTION = 20

CONTROL_FLUSH_ERROR = 21

OTHERS = 22

.

IF sy-subrc <> 0.

MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO

WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.

ENDIF.

Thanks,

Naren

0 Kudos

hi All

i have just declared empty field in the internal table structure and passed blank value in it

like wa_empty1 = ''.

is this ok ?

Arora