‎2007 Jun 22 1:16 PM
Hi Folks,
I try to download all the Reports to a file with the following code.
But it selects only 1 record and then it stops with a runtime error.
REPORT Z_DOWNLOAD_REPORTS .
tables trdir.
DATA : BEGIN OF ITAB OCCURS 0,
F(72) TYPE C,
END OF ITAB.
select *
from trdir
where name like 'BA%'.
READ REPORT trdir-name INTO ITAB.
CALL FUNCTION 'GUI_DOWNLOAD'
EXPORTING
FILENAME = 'C:\PRG.TXT'
TABLES
DATA_TAB = ITAB.
endselect.
Thank you very much for the help.
Joerg
‎2007 Jun 22 1:24 PM
Hi,
your code has 2 errors. First of all the GUI_DOWNLOAD probably performs a commit work or something which in turn crash your program. Second since you are giving the same file name your file will be overwriten.
Do something like this.
data : begin of lt_name occurs 0,
name like trdir-name,
end of lt_name.
data: filename type string.
select name
from trdir into table lt_name
where name like 'BA%'.
loop at lt_name.
READ REPORT lt_name-name INTO ITAB.
filename = lt_name-name.
condense filename no-gaps.
concatenate ''C:\' filename '.txt' into filename.
condense filename no-gaps.
CALL FUNCTION 'GUI_DOWNLOAD'
EXPORTING
FILENAME = filename
TABLES
DATA_TAB = ITAB.
endloop.
Regards
Kostas
Message was edited by:
Kostas Tsioubris
‎2007 Jun 22 1:19 PM
Hi,
Dont put any FM call between SELECT and ENDSELECT.
What you can do instead use SELECT INTO TABLE and then
data: it_trdir type table trdir.
SELECT * FROM TRDIR INTO TABLE it_trdir where name like 'BA%'.
call the FM
CALL FUNCTION 'GUI_DOWNLOAD'
EXPORTING
FILENAME = 'C:\PRG.TXT'
TABLES
DATA_TAB = ITAB.
Regards,
Sesh
‎2007 Jun 22 1:20 PM
try removing the select end select loop. Instead, take all programs in to another internal table and loop at that internal table to read the program and download.
reward if it helps
krishna
‎2007 Jun 22 1:23 PM
Your GUI_DOWNLOAD statement is inside the select statement thats y , for each record it will excecute the GUI_DOWNLOAD fm. thts y one record is coming, the error is because of callin the fm in side the select statement.
regards
prabhu
‎2007 Jun 22 1:23 PM
Your GUI_DOWNLOAD statement is inside the select statement thats y , for each record it will excecute the GUI_DOWNLOAD fm. thts y one record is coming, the error is because of callin the fm in side the select statement.
regards
prabhu
reward if it is helpful
‎2007 Jun 22 1:24 PM
Hi,
your code has 2 errors. First of all the GUI_DOWNLOAD probably performs a commit work or something which in turn crash your program. Second since you are giving the same file name your file will be overwriten.
Do something like this.
data : begin of lt_name occurs 0,
name like trdir-name,
end of lt_name.
data: filename type string.
select name
from trdir into table lt_name
where name like 'BA%'.
loop at lt_name.
READ REPORT lt_name-name INTO ITAB.
filename = lt_name-name.
condense filename no-gaps.
concatenate ''C:\' filename '.txt' into filename.
condense filename no-gaps.
CALL FUNCTION 'GUI_DOWNLOAD'
EXPORTING
FILENAME = filename
TABLES
DATA_TAB = ITAB.
endloop.
Regards
Kostas
Message was edited by:
Kostas Tsioubris
‎2007 Jun 22 1:28 PM
since you put the same program in select loop. you ll get the last output of the FM in last pass of the loop.
so your approach shud be like this
1. make a select on table and populate the data in internal table
2. loop at itab into wa.
use FM using WA
Endloop.
3. Cheers.
‎2007 Jun 22 1:26 PM
Hi,
Remove the FM from Select... EndSelect.
Instead use
REPORT Z_DOWNLOAD_REPORTS .
tables trdir.
DATA : BEGIN OF ITAB OCCURS 0,
F(72) TYPE C,
END OF ITAB.
SELECT *
FROM TRDIR INTO TABLE ITAB
WHERE NAME LIKE 'BA%'.
CALL FUNCTION 'GUI_DOWNLOAD'
EXPORTING
FILENAME = 'C:\PRG.TXT'
TABLES
DATA_TAB = ITAB.
Reward points if useful,
Kiran
‎2007 Jun 22 2:06 PM