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: 

issue on apllication server download

Former Member
0 Kudos

Hi all,

I have got this issue on download of a file in the UNIX application server.

I have to display the file in an excel format with tab delimiter between the fields.

i have declared the internal table as

DATA : BEGIN OF i_unix_header OCCURS 0,

lifnr(10) TYPE c ,

tab1 type x value '09',

banks(12) TYPE c,

tab2 type x value '09',

bankl(15) TYPE c,

tab3 type x value '09',

bankn(18) TYPE c,

tab4 type x value '09',

bvtyp(15) TYPE c,

tab5 type x value '09',

bkref(20) TYPE c,

tab6 type x value '09',

banka(60) TYPE c,

END OF i_unix_header.

where the 'tab1...' is the tab delimiter and using the 'open dataset , transfer commands to transfer the data in the internal table to the unix path.;

But this does not provide the tab space and the next field starts from the end of the prior field w/o space in the output , when checked through tcode AL11.

Any other wayz.Pls post.

Thanks,

stock

1 ACCEPTED SOLUTION

Former Member
0 Kudos

Hi Stock,

I suggest you not to use the tab in the internal table ..

Concatinate the contents of using field seperator..

DATA : BEGIN OF i_unix_header OCCURS 0,

lifnr(10) TYPE c ,

banks(12) TYPE c,

bankl(15) TYPE c,

bankn(18) TYPE c,

bvtyp(15) TYPE c,

bkref(20) TYPE c,

banka(60) TYPE c,

END OF i_unix_header.

Data: Begin of jtab occurs 0,

line(256),

end of jtab.

Data: wa_jtab like line of jtab.

loop at i_unix_header.

concatenate i_unix_header-lifnr i_unix_header-banks i_unix_header-banks1.. into wa_jtab seperated by CL_ABAP_CHAR_UTILITIES=>HORIZONTAL_TAB.

append wa_jtab to jtab

endloop.

now transfer jtab to file..

Hope that helps

Regards,

Tanveer.

Please mark helpful answers

Message was edited by: Tanveer Shaikh

9 REPLIES 9

Former Member
0 Kudos

Hi Stock,

I suggest you not to use the tab in the internal table ..

Concatinate the contents of using field seperator..

DATA : BEGIN OF i_unix_header OCCURS 0,

lifnr(10) TYPE c ,

banks(12) TYPE c,

bankl(15) TYPE c,

bankn(18) TYPE c,

bvtyp(15) TYPE c,

bkref(20) TYPE c,

banka(60) TYPE c,

END OF i_unix_header.

Data: Begin of jtab occurs 0,

line(256),

end of jtab.

Data: wa_jtab like line of jtab.

loop at i_unix_header.

concatenate i_unix_header-lifnr i_unix_header-banks i_unix_header-banks1.. into wa_jtab seperated by CL_ABAP_CHAR_UTILITIES=>HORIZONTAL_TAB.

append wa_jtab to jtab

endloop.

now transfer jtab to file..

Hope that helps

Regards,

Tanveer.

Please mark helpful answers

Message was edited by: Tanveer Shaikh

former_member181962
Active Contributor
0 Kudos

Hi ,

Declare your internal table without any tabs.

Once you have the data in your internal table,

open dataset <dsn>.....

Loop at itab.

concatenate itab-field1

itab-field2 itab-field3...

into v_string

separated by CL_ABAP_CHAR_UTILITIES=>HORIZONTAL_TAB.

transfer v_string to <dsn>.

endloop.

close dataset.

Regards,

Ravi

Note: Please reward if it helps.

Former Member
0 Kudos

Hi stock,

You can refer to this code .

<b>Here I have taken data from a database table zkunal3 into the internal table itab and then put the contents of this table into the application server (dsn) . The contents are separated by space. Finally i have opened the file , dsn , to read the contents and they are separated by space.</b>

REPORT zkun_file2 .

TABLES : zkunal3.

DATA:

dsn(20) TYPE c VALUE 'test.dat',

rec(80) TYPE c.

DATA : BEGIN OF itab OCCURS 0.

INCLUDE STRUCTURE zkunal1.

DATA : END OF itab.

SELECT * FROM zkunal3 INTO TABLE itab.

<b>OPEN DATASET dsn FOR OUTPUT IN TEXT MODE ENCODING DEFAULT.</b>

" opens a file for writing; if the file is not thr in the working direct

"ory it will create one with the same name.

LOOP AT itab.

<b>concatenate itab-fname itab-lname itab-place into rec separated by space

.</b>

TRANSFER rec TO dsn.

rec = ''.

ENDLOOP.

CLOSE DATASET dsn.

rec = ''.

<b>OPEN DATASET dsn FOR INPUT IN TEXT MODE ENCODING DEFAULT.</b>

" opens the file for reading only.

IF sy-subrc = 0.

message i005(zmsg_kunal).

ENDIF.

WHILE sy-subrc = 0.

WRITE / rec. READ DATASET dsn INTO rec.

ENDWHILE.

CLOSE DATASET dsn.

Regards,

Kunal.

<b>Note : Zkunal3 contains three fields fname , lname and place .</b>

Former Member
0 Kudos

I tried to use CL_ABAP_CHAR_UTILITIES=>HORIZONTAL_TAB but it vgives a syntax error.

0 Kudos

Hi Stock,

No need to decare the tab field in the output table.

Please check the below code,


*--Data Structure For Employee Details
TYPES: BEGIN OF tp_final,
         OBJID(20),  " Object ID
         REFID(20),  " Object ID
         VARYF(30),  " Variation Field for File PLOG
       END OF tp_final.
*--Types declaration for UNIX content
TYPES: BEGIN OF tp_body,
        data(250) TYPE c,   " Body
       END OF tp_body.
DATA: 
*--Internal table declaration for Employee Details
      dt_final TYPE STANDARD TABLE OF tp_final,
*--Internal table declaration for UNIX file
      dt_body  TYPE STANDARD TABLE OF tp_body WITH HEADER LINE.


*       Populate file 
  loop at dt_final into ds_final.
    concatenate ds_final-objid
                CL_ABAP_CHAR_UTILITIES=>HORIZONTAL_TAB
                ds_final-refid
                CL_ABAP_CHAR_UTILITIES=>HORIZONTAL_TAB
       into dt_body.
    append dt_body.
    clear  dt_body.
  endloop.

  IF NOT dt_body[] IS INITIAL.
    concatenate dg_filename
                '_'
                sy-datum into dg_filename.
*--Open data set
    OPEN DATASET dg_filename FOR OUTPUT IN TEXT MODE encoding default.
    IF sy-subrc <> 0.
      WRITE :/2 'Cannot open '(005), dg_filename .
    ELSE.
*--Transfer data
      LOOP AT dt_body.
        TRANSFER dt_body TO dg_filename.
      ENDLOOP.
*--Close data set
      CLOSE DATASET dg_filename.
      WRITE :/2 'Output file created as'(006), dg_filename.
    ENDIF.
  ENDIF.



 

hope this will help you.

Thanks&Regards,

Siri.

Former Member
0 Kudos

Hi sri,

As I said the CL_ABAP_CHAR_UTILITIES=>HORIZONTAL_TAB gives me syntax erroras " Class CL_ABAP_CHAR_UTILITIES=>HORIZONTAL_TAB is not known".

0 Kudos

Then you directly declare the tab as constant and do

liek below.

constants : <b>c_tab type x value '09'</b>. " which is equivalent to CL_ABAP_CHAR_UTILITIES=>HORIZONTAL_TAB.

loop at dt_final into ds_final.

concatenate ds_final-objid

<b>c_tab</b>

ds_final-refid

<b>c_tab</b>

into dt_body.

append dt_body.

clear dt_body.

endloop.

Message was edited by: Srilatha T

0 Kudos

<b>data: tab type x value '09'.</b>

open dataset <dsn>.....

Loop at itab.

concatenate itab-field1

itab-field2 itab-field3...

into v_string

separated by <b>TAB</b>.

transfer v_string to <dsn>.

endloop.

close dataset.

Regards,

ravi

0 Kudos

Hi Stock,

since you are in older versions, you cannot use that class. but you can go with Hexa values, as suggested by Srilatha and Ravi in the above posts.

Regards

vijay