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: 

File download

Former Member
0 Kudos

Hi

I am trying to download an internal table with 9 columns using the Function Module 'GUI_DOWNLOAD' my requirement is to download only 7 columns and drop the 1st and 2nd columnd during download.Can anyone please suggest a method of doing this.I have already tried giving the COL_SELECT and COL_SELECT_MASK options with a mask

' XXXXXXX' but this doesnt seem to be working.

Gaurav

19 REPLIES 19

Former Member
0 Kudos

Hi garuav,

1. one way is to define another internal table

with only required 7 columns, in the same sequence.

2. then download this table.

3. u can use

newitab[] = itab[]

for transferring the data.

regards,

amit m.

Former Member
0 Kudos

Hey Gaurav ,

if its not working the way you have stated , you can try out this.:

1. Create another internal table ,say itab2 , whihc will have the required 7 columns.

2. Transfer the contents of the 7 columns from the first internal table, say itab1 to the second internal table, itab2.

3. Then, call the function module , 'Gui_Download' and pass the second internal table, itab2.

This will fulfill your requirement.

Regards,

Kunal.

Note : please reward with points the useful answers.

Former Member
0 Kudos

Thanks for thoose insights folks but then the trasfer to another internal table would mean that I have run an extra loop which will hamper performance as my table is holidng a lot of data.I was wondering if anyone has tried the COL_SELECT_MASK method and can tell me what is wrong with it ??

0 Kudos

Hi again,

1.

No need to run LOOP.

2. just give

newitab[] = itab[].

3. it will copy the body,with the 7 columns.

regards,

amit m.

Former Member
0 Kudos

Hi Gaurav,

Is your file extension 'dat' or 'dbf' ? The documentation says that these options work only with these file extensions.

Regards,

Aniket

Please mark useful posts.

0 Kudos

Hi Aniket,

My filetype is 'DBF'.

Gaurav

Former Member
0 Kudos

Hi Amit,

It wont work if the two structures are not identical.

Gaurav.

0 Kudos

Hi again,

1. It will work FANTASTIC.

(I just tried it with T001 example)

(the field names,and the seqence needs to be same)

2. try this (just copy paste in new program)

report abc.

*----


data: itab like table of t001 with header line.

data : begin of mytab occurs 0,

mandt like t001-mandt,

bukrs like t001-bukrs,

end of mytab.

*----


select * from t001 into table itab.

*----


mytab[] = itab[].

break-point.

regards,

amit m.

0 Kudos

Amit,

"Newtab" and "ITab" are not mutually convertible.

In Unicode programs, "Newtab" must have the same structure

layout as "Itab", independent of the length of a Unicode

character.

This is the error it throws when I try to give the command newitab[] = itab1[].

Please advise.

Gaurav

0 Kudos

Hi again,

1. whats your itab declearation and the new itab declaration?

2. also try my code for testing only.

and check if it gives error ?

(it does not give here)

regards,

amit m.

0 Kudos

TYPES : BEGIN OF gty_recon_report,

mblnr LIKE mkpf-mblnr, "Material Documnt Number

mjahr LIKE mkpf-mjahr, "Fiscal year

matnr LIKE mara-matnr, "SAP Material Number

werks LIKE t001w-werks, "SAP Plant

lgort LIKE t001l-lgort, "SAP Storage Location

meins LIKE mara-meins, "SAP Base Unit of Measure

maktx LIKE makt-maktx, "SAP Material Description

erfmg LIKE mseg-erfmg, "Quantity

stprs LIKE mbew-stprs, "Unit Value

END OF gty_recon_report.

TYPES : BEGIN OF gt_downl_report,

matnr LIKE mara-matnr, "SAP Material Number

werks LIKE t001w-werks, "SAP Plant

lgort LIKE t001l-lgort, "SAP Storage Location

meins LIKE mara-meins, "SAP Base Unit of Measure

maktx LIKE makt-maktx, "SAP Material Description

erfmg LIKE mseg-erfmg, "Quantity

stprs LIKE mbew-stprs, "Unit Value

END OF gt_downl_report.

The two tables.

Gaurav.

0 Kudos

Hi gaurav,

1. this error comes in case of

numeric fields.

2. in your case.

*erfmg LIKE mseg-erfmg, "Quantity

*stprs LIKE mbew-stprs, "Unit Value

just comment out these two lines,

in the second itab.

and then it won't give error.

3. But in that case u will get only 5 columns.

4. so the last thing is that we may have to loop

and use move-corresponding to put data in new table.

regards,

amit m.

Former Member
0 Kudos

Hai Gaurav

Try with this Code

Tables : mara.

data : v_del type i.

data : itab like mara occurs 0 with header line.

select * up to 9 rows from mara into table itab where mtart = 'ROH'.

break-point 'scmdev'.

if sy-subrc = 0.

sort itab by matnr.

endif.

clear : V_del.

V_del = 1.

loop at itab.

delete itab index v_del.

exit.

endloop.

sort itab by matnr.

clear : V_del.

V_del = 1.

loop at itab.

delete itab index v_del.

exit.

endloop.

sort itab by matnr.

loop at itab.

write : / itab-matnr,

itab-mbrsh,

itab-mtart,

itab-meins.

endloop.

CALL FUNCTION 'GUI_DOWNLOAD'

EXPORTING

FILENAME = 'c:\mat_bdc.txt'

FILETYPE = 'ASC'

TABLES

DATA_TAB = itab.

Thanks & Regards

Sreenivasulu P

athavanraja
Active Contributor
0 Kudos

it should work with col_select and col_select_mask .

what are you passing in these fields.

Regards

Raja

0 Kudos

Hi Raja,

I am passing 'X' in COL_SELECT and

" XXXXXXX" in COL_SELECT_MASK

Gaurav

0 Kudos
have u given space like this ,give 2 spaces for 2 columns <b>'  XXXXXXX'</b>.

this will download last 7 columns

Message was edited by: Sekhar

0 Kudos

I have been using COL_SELECT and COL_SELECT_MASK with DAT file type successfully.

make a quick check

in col_select_mask

just hide the 2nd and 3rd column and try whether it works.

"X  XXXXXX" in COL_SELECT_MASK

this is to just test whether a blank at the starting position is causing problem

Regards

Raja

0 Kudos

Hi Raja,

If I change the filetype to DAT from DBF it seems to be working fine and the COL_SELECT_MASK also works.

I think the filetype DBF might be the reson,I think ill manage with this for the time.

Thank you all for your responses.

Gaurav

Former Member
0 Kudos

Hi Gaurav,

Here is a simple piece of code.


REPORT y_a_test .

TYPES: BEGIN OF student,
        name(10),
        rollno TYPE i,
        marks TYPE i,

       END OF student.

DATA: itab TYPE TABLE OF student,
wa LIKE LINE OF itab,
fname TYPE string.

fname = 'D:TEST.dat'.

CLEAR wa.
wa-name = 'sachin'.
wa-rollno = 10.
wa-marks = 75.

APPEND wa TO itab.

CLEAR wa.
wa-name = 'rahul'.
wa-rollno = 20.
wa-marks = 80.
APPEND wa TO itab.

CALL FUNCTION 'GUI_DOWNLOAD'
  EXPORTING
*   BIN_FILESIZE                  =
    filename                      = fname
*   FILETYPE                      = 'DAT'
*   APPEND                        = ' '
*   WRITE_FIELD_SEPARATOR         = ' '
*   HEADER                        = '00'
*   TRUNC_TRAILING_BLANKS         = ' '
*   WRITE_LF                      = 'X'
   col_select                    = 'X'
   col_select_mask               = ' XX'
*   DAT_MODE                      = ' '
* IMPORTING
*   FILELENGTH                    =
  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.

Seems to be working fine in this case

Regards,

Aniket

Please mark helpful answers.