GUI_DOWNLOAD Help
Hi all,
i am facing a problem in funtion module gui_download for downloading header.I have tried few tricks but nothing works.
1. i called function module twice in appending manner but it download the header but all the data comes in one row that also in differnet format(like:word specified format).
so can anyone plz help me in this problem.can anyone send me the sample code that shows how the function module should be used for downloading the header.
It will be great help if some one solve my query.
thanks
[email protected]
Hi Anu,
hope below links helps you
Export the report list to Excel Sheet
http://www.sapdevelopment.co.uk/file/file_updown.htm
or below is a sample programme which helps you upload and download
REPORT ytest5 LINE-SIZE 80
LINE-COUNT 65
NO STANDARD PAGE HEADING.
TABLES: dd02l, dd03l.
* selection screen
SELECTION-SCREEN BEGIN OF BLOCK b00 WITH FRAME TITLE text-b00.
SELECTION-SCREEN BEGIN OF BLOCK b01 WITH FRAME TITLE text-b01.
PARAMETERS: tabname LIKE dd02l-tabname OBLIGATORY.
SELECTION-SCREEN END OF BLOCK b01.
SELECTION-SCREEN BEGIN OF BLOCK b03 WITH FRAME TITLE text-b03.
PARAMETERS: path(30) TYPE c DEFAULT 'C:SAPWorkdir'.
SELECTION-SCREEN END OF BLOCK b03.
SELECTION-SCREEN BEGIN OF BLOCK b04 WITH FRAME TITLE text-b04.
PARAMETERS: p_exp RADIOBUTTON GROUP radi,
p_imp RADIOBUTTON GROUP radi,
p_clear AS CHECKBOX.
SELECTION-SCREEN END OF BLOCK b04.
SELECTION-SCREEN END OF BLOCK b00.
* data
DATA: q_return LIKE syst-subrc,
err_flag(1) TYPE c,
answer(1) TYPE c,
w_text1(62) TYPE c,
w_text2(40) TYPE c,
winfile(128) TYPE c,
w_system(40) TYPE c,
winsys(7) TYPE c,
zname(8) TYPE c,
w_line(80) TYPE c.
* internal tables
DATA : BEGIN OF textpool_tab OCCURS 0.
INCLUDE STRUCTURE textpool.
DATA : END OF textpool_tab.
* table for subroutine pool
DATA : itab(80) OCCURS 0.
* events
INITIALIZATION.
PERFORM check_system.
AT SELECTION-SCREEN ON tabname.
PERFORM check_table_exists.
START-OF-SELECTION.
PERFORM init_report_texts.
PERFORM request_confirmation.
END-OF-SELECTION.
IF answer = 'J'.
PERFORM execute_program_function.
ENDIF.
TOP-OF-PAGE.
PERFORM process_top_of_page.
* forms
* FORM CHECK_TABLE_EXISTS *
FORM check_table_exists.
SELECT SINGLE * FROM dd02l
INTO CORRESPONDING FIELDS OF dd02l
WHERE tabname = tabname.
CHECK syst-subrc NE 0.
MESSAGE e402(mo) WITH tabname.
ENDFORM.
* FORM INIT_REPORT_TEXTS *
FORM init_report_texts.
READ TEXTPOOL syst-repid
INTO textpool_tab LANGUAGE syst-langu.
LOOP AT textpool_tab
WHERE id EQ 'R' OR id EQ 'T'.
REPLACE '&1............................'
WITH tabname INTO textpool_tab-entry.
MODIFY textpool_tab.
ENDLOOP.
ENDFORM.
* FORM REQUEST_CONFIRMATION *
FORM request_confirmation.
* import selected, confirm action
IF p_imp = 'X'.
* build message text for popup
CONCATENATE 'Data for table'
tabname
'will be imported' INTO w_text1 SEPARATED BY space.
* check if delete existing selected, and change message text
IF p_clear = ' '.
w_text2 = 'and appended to the end of existing data'.
ELSE.
w_text2 = 'Existing Data will be deleted'.
ENDIF.
CALL FUNCTION 'POPUP_TO_CONFIRM_STEP'
EXPORTING
defaultoption = 'N'
textline1 = w_text1
textline2 = w_text2
titel = 'Confirm Import of Data'
cancel_display = ' '
IMPORTING
answer = answer
EXCEPTIONS
OTHERS = 1.
ELSE.
* export selected, set answer to yes so export can continue
answer = 'J'.
ENDIF.
ENDFORM.
* FORM EXECUTE_PROGRAM_FUNCTION *
FORM execute_program_function.
PERFORM build_file_name.
CLEAR: q_return,err_flag.
IF p_imp = 'X'.
PERFORM check_file_exists.
CHECK err_flag = ' '.
PERFORM func_import.
ELSE.
PERFORM func_export.
ENDIF.
ENDFORM.
* FORM BUILD_FILE_NAME *
FORM build_file_name.
MOVE path TO winfile.
WRITE '' TO winfile+30.
WRITE tabname TO winfile+31.
WRITE '.TAB' TO winfile+61(4).
CONDENSE winfile NO-GAPS.
ENDFORM.
* FORM CHECK_FILE_EXISTS *
FORM check_file_exists.
CALL FUNCTION 'WS_QUERY'
EXPORTING
filename = winfile
query = 'FE'
IMPORTING
return = q_return
EXCEPTIONS
OTHERS = 1.
IF syst-subrc NE 0 OR q_return NE 1.
err_flag = 'X'.
ENDIF.
ENDFORM.
* FORM func_export *
FORM func_export.
CLEAR itab. REFRESH itab.
APPEND 'PROGRAM SUBPOOL.' TO itab.
APPEND 'FORM DOWNLOAD.' TO itab.
APPEND 'DATA: BEGIN OF IT_TAB OCCURS 0.' TO itab.
CONCATENATE 'INCLUDE STRUCTURE'
tabname
'.' INTO w_line SEPARATED BY space.
APPEND w_line TO itab.
APPEND 'DATA: END OF IT_TAB.' TO itab.
CONCATENATE 'SELECT * FROM'
tabname
'INTO TABLE IT_TAB.' INTO w_line SEPARATED BY space.
APPEND w_line TO itab.
APPEND 'CALL FUNCTION ''WS_DOWNLOAD''' TO itab.
APPEND 'EXPORTING' TO itab.
CONCATENATE 'filename = ' ''''
winfile '''' INTO w_line SEPARATED BY space.
APPEND w_line TO itab.
APPEND 'filetype = ''DAT''' TO itab.
APPEND 'TABLES' TO itab.
APPEND 'DATA_TAB = IT_TAB.' TO itab.
APPEND 'DESCRIBE TABLE IT_TAB LINES sy-index.' TO itab.
APPEND 'FORMAT COLOR COL_NORMAL INTENSIFIED OFF.' TO itab.
APPEND 'WRITE: /1 syst-vline,' TO itab.
APPEND '''EXPORT'',' TO itab.
APPEND '15 ''data line(s) have been exported'',' TO itab.
APPEND '68 syst-index,' TO itab.
APPEND '80 syst-vline.' TO itab.
APPEND 'ULINE.' TO itab.
APPEND 'ENDFORM.' TO itab.
GENERATE SUBROUTINE POOL itab NAME zname.
PERFORM download IN PROGRAM (zname).
ENDFORM.
* FORM func_import *
FORM func_import.
CLEAR itab. REFRESH itab.
APPEND 'PROGRAM SUBPOOL.' TO itab.
APPEND 'FORM UPLOAD.' TO itab.
APPEND 'DATA: BEGIN OF IT_TAB OCCURS 0.' TO itab.
CONCATENATE 'INCLUDE STRUCTURE'
tabname
'.' INTO w_line SEPARATED BY space.
APPEND w_line TO itab.
APPEND 'DATA: END OF IT_TAB.' TO itab.
APPEND 'DATA: BEGIN OF IT_TAB2 OCCURS 0.' TO itab.
CONCATENATE 'INCLUDE STRUCTURE'
tabname
'.' INTO w_line SEPARATED BY space.
APPEND w_line TO itab.
APPEND 'DATA: END OF IT_TAB2.' TO itab.
APPEND 'CALL FUNCTION ''WS_UPLOAD''' TO itab.
APPEND 'EXPORTING' TO itab.
CONCATENATE 'filename = ' ''''
winfile '''' INTO w_line SEPARATED BY space.
APPEND w_line TO itab.
APPEND 'filetype = ''DAT''' TO itab.
APPEND 'TABLES' TO itab.
APPEND 'DATA_TAB = IT_TAB.' TO itab.
IF p_clear = 'X'.
CONCATENATE 'SELECT * FROM'
tabname
'INTO TABLE IT_TAB2.' INTO w_line SEPARATED BY space.
APPEND w_line TO itab.
APPEND 'LOOP AT IT_TAB2.' TO itab.
CONCATENATE 'DELETE'
tabname
'FROM IT_TAB2.' INTO w_line SEPARATED BY space.
APPEND w_line TO itab.
APPEND 'ENDLOOP.' TO itab.
APPEND 'COMMIT WORK.' TO itab.
ENDIF.
APPEND 'LOOP AT IT_TAB.' TO itab.
CONCATENATE 'MODIFY'
tabname
'FROM IT_TAB.' INTO w_line SEPARATED BY space.
APPEND w_line TO itab.
APPEND 'ENDLOOP.' TO itab.
APPEND 'DESCRIBE TABLE IT_TAB LINES sy-index.' TO itab.
APPEND 'FORMAT COLOR COL_NORMAL INTENSIFIED OFF.' TO itab.
APPEND 'WRITE: /1 syst-vline,' TO itab.
APPEND '''IMPORT'',' TO itab.
APPEND '15 ''data line(s) have been imported'',' TO itab.
APPEND '68 syst-index,' TO itab.
APPEND '80 syst-vline.' TO itab.
APPEND 'ULINE.' TO itab.
APPEND 'ENDFORM.' TO itab.
GENERATE SUBROUTINE POOL itab NAME zname.
PERFORM upload IN PROGRAM (zname).
ENDFORM.
* Form CHECK_SYSTEM
* Check users workstation is running
* WINDOWS 95, or WINDOWS NT.
* OS/2 uses 8.3 file names which are no good for
* this application as filenames created are 30 char
* same as table name.
* You could change the logic to only use the first 8 chars
* of the table name for the filename, but you could possibly
* get problems if users had exported already with a table
* with the same first 8 chars.
* As an alternate method you could request the user to input
* the full path including filename and remove the logic to
* build the path using the table name.
FORM check_system.
CALL FUNCTION 'WS_QUERY'
EXPORTING
query = 'WS'
IMPORTING
return = winsys.
IF winsys NE 'WN32_95'.
WRITE: 'Windows NT or Windows 95/98 is required'.
EXIT.
ENDIF.
ENDFORM. " CHECK_SYSTEM
* FORM PROCESS_TOP_OF_PAGE *
FORM process_top_of_page.
FORMAT COLOR COL_HEADING INTENSIFIED ON.
ULINE.
CONCATENATE syst-sysid
syst-saprl
syst-host INTO w_system SEPARATED BY space.
WRITE : AT /1(syst-linsz) w_system CENTERED.
WRITE : AT 1 syst-vline, syst-uname.
syst-linsz = syst-linsz - 11.
WRITE : AT syst-linsz syst-repid(008).
syst-linsz = syst-linsz + 11.
WRITE : AT syst-linsz syst-vline.
LOOP AT textpool_tab WHERE id EQ 'R'.
WRITE : AT /1(syst-linsz) textpool_tab-entry CENTERED.
ENDLOOP.
WRITE : AT 1 syst-vline, syst-datum.
syst-linsz = syst-linsz - 11.
WRITE : AT syst-linsz syst-tcode(004).
syst-linsz = syst-linsz + 11.
WRITE : AT syst-linsz syst-vline.
LOOP AT textpool_tab WHERE id EQ 'T'.
WRITE : AT /1(syst-linsz) textpool_tab-entry CENTERED.
ENDLOOP.
WRITE : AT 1 syst-vline, syst-uzeit.
syst-linsz = syst-linsz - 11.
WRITE : AT syst-linsz 'Page', syst-pagno.
syst-linsz = syst-linsz + 11.
WRITE : AT syst-linsz syst-vline.
ULINE.
FORMAT COLOR COL_HEADING INTENSIFIED OFF.
LOOP AT textpool_tab WHERE id EQ 'H'.
WRITE : AT /1(syst-linsz) textpool_tab-entry.
ENDLOOP.
ULINE.
ENDFORM.
if it helps you reward with points.
regards,
venu
Similar Messages
-
Problem in the local file download by gui_download,pls help!
hello,everyone,
when I use 'GUI_DOWNLOAD' to download file to my pc,the data in the file has some display problem,eg:'440006114002084000 'displayed as 4.40006E+17
when I enlarge the excel grid,then the '4.40006E+17 ' just not change to 440006114002084000,so does any know this problem?pls give me some help.
thank you in advance.Hi,
You need to change the content of the field in your internal table before you call gui_download.
Something like
constant: c_quote value `'`.
loop at data_tab assigning <fs_data>.
concatentate c_quote <fs_data>-ean into wa_ean.
<fs_data>-ean = wa_ean.
endloop.
This will change the field from, for example 123456 to '123456, which Excel will treat as text.
Regards,
Nick -
Problem in gui_download, plzzz help me
down load the data into flat file using gui_download.
but i want downloaded data into flate file with comma separater format.
plzz tell me the possible types of downloading formats like xl sheet, tab separater,$ separater and * separater.Hi Krianti,
You Con't download into flat file with comma separater with Gui_download function module ( by field separator = 'x' also), but you can with some logic
Use this logic:
1. Take one internal table with one field like
Data:
begin of itab occurs 0,
line(255),
end of itab.
2. Concatinate your fields with camma separater and asign to itab and append it ( it is in loop at your table)
3. download itab now by using gui_download
Plzz Reward if it is useful,
Mahi. -
hi
how i can insert header to download file like:
user name
system
and after this the data?
thanks
have a nice dayHI,
1) You can Download the header then apend the values to
that file
2)
[code]CALL FUNCTION GUI_DOWNLOAD
<b>EXPORTING*</b>
BIN_FILESIZE = FILENAME = gv_string FILETYPE = BIN* APPEND = * WRITE_FIELD_SEPARATOR = * HEADER = 00* TRUNC_TRAILING_BLANKS = * WRITE_LF = X* COL_SELECT = * COL_SELECT_MASK = * DAT_MODE = * CONFIRM_OVERWRITE = * NO_AUTH_CHECK = * CODEPAGE = * IGNORE_CERR = ABAP_TRUE* REPLACEMENT = #* WRITE_BOM = * TRUNC_TRAILING_BLANKS_EOL = X* WK1_N_FORMAT = * WK1_N_SIZE = * WK1_T_FORMAT = * WK1_T_SIZE = *
<b>IMPORTING* </b>
FILELENGTH =
<b>TABLES</b>
DATA_TAB = it_pdf*
<i><b>FIELDNAMES</b></i> =
<b>EXCEPTIONS</b>
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 . [code]
in the Tables if you have option to write the Headers .. bu using this you can insert the header names to the file
Thanks
Sudheer -
Need help: GUI_DOWNLOAD and tab-separated in between fields.
hello everyone,
this is the layout of the interface that i created:
sy-title
total records processed: XX
total records failed: XX
summary of the error
pernr<tab>name<tab>error message<tab>otherfieldshere
i wanted the error log to be saved locally thus, i have to use GUI_DOWNLOAD.
ok, here's the current parameters i supplied with my gui_download:
CALL FUNCTION 'GUI_DOWNLOAD'
EXPORTING
filename = v_file_string
filetype = 'ASC'
write_field_separator = 'X'
TABLES
data_tab = i_error_log
(exceptions not displayed)
the problem that i have is that, there is a difference between the error logs displayed after the execution and the error logs saved in my local directory.
i did find a way to resolve this BUT, i still need to refine it. also, the spaces between the fields seems not tab delimited, but separated by space.
to explain further here's the current error log that i have downloaded:
10000001<tab>10/23/2006<tab>01<tab>P<tab>11<tab>01
the header:
sy-title
total records processed: XX
total records failed: XX
summary of the error
is not included in the downloaded errorlog file.
i added some modification of my report to include it because, i want to to look exactly the same as of the errorlog generated/displyed after the execution.
the result looks as it is what i've expected BUT,
when i checked the spaces in between fields...
it is all separated by spaces... not tab.
here is the actual error log that i have obtained:
sy-title
total records processed: XX
total records failed: XX
summary of the error
pernr<space><space><space>name<space><space><space><space><space><space>error message<space><space>otherfieldshere
What i wanted to resolve is that, i want the error log to be tab delimited and not separated by space.
is this possible? if it is, any suggestion will truly be appreciated.Hi,
Please check your flat file i think it they have used the Three spaces instead of using a SINGLE TAB. between the fields.
Thanks & Regards,
Chandralekha. -
Urgent : help on gui_download
hi guys,
i am using gui_download to download file to a excel i have given field seperator as
" " empty. and the file type as asc. iwhen i download the file i am getting all the field clubbed into the excel in the first field only .also the output is in exponent format . how to get the output in seperate colums and to get without exponential format.
reward is sureCALL FUNCTION 'GUI_DOWNLOAD'
EXPORTING
BIN_FILESIZE =
filename = 'C:\Documents and Settings\nex44jc\Desktop\header.xls'
filetype = 'DAT'
APPEND = ' '
WRITE_FIELD_SEPARATOR = ' '
HEADER = '00'
TRUNC_TRAILING_BLANKS = ' '
WRITE_LF = 'X'
COL_SELECT = ' '
COL_SELECT_MASK = ' '
DAT_MODE = ' '
CONFIRM_OVERWRITE = ' '
NO_AUTH_CHECK = ' '
CODEPAGE = ' '
IGNORE_CERR = ABAP_TRUE
REPLACEMENT = '#'
WRITE_BOM = ' '
TRUNC_TRAILING_BLANKS_EOL = 'X'
WK1_N_FORMAT = ' '
WK1_N_SIZE = ' '
WK1_T_FORMAT = ' '
WK1_T_SIZE = ' '
IMPORTING
FILELENGTH =
TABLES
data_tab = it_header
FIELDNAMES =
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.
reward if helpfull. -
hi guys,
i am using gui_download to download file to a excel i have given field seperator as
" " empty. and the file type as asc. iwhen i download the file i am getting all the field clubbed into the excel in the first field only .also the output is in exponent format . how to get the output in seperate colums and to get without exponential format.
reward is surehi..
Check the below program :
REPORT Z4PG_EXTEND_MATERIAL
NO STANDARD PAGE HEADING
LINE-SIZE 150
MESSAGE-ID Z4.
TABLES :
mard, "#EC * " Storage Location Data for Material
marc. "#EC * " Plant Data for Material
INTERNAL TABLES DECLARATIONS
1. INTERNAL TABLE FOR MATERIALS THAT ARE MAINTAINED FOR lgort = '0001'
DATA : BEGIN OF it_mard OCCURS 0,
matnr LIKE mard-matnr, " Material No.
werks LIKE mard-werks, " Plant
lgort LIKE mard-lgort, " Storage Location
END OF it_mard.
2. INTERNAL TABLE TO STORE MATERIALS WHICH ARE ALREADY MAINTAINED FOR
*lgort = 'ABCD'.
DATA: BEGIN OF it_verify OCCURS 0,
matnr LIKE mard-matnr, " Material No.
werks LIKE mard-werks, " Plant
lgort LIKE mard-lgort, " Storage Location
dismm LIKE marc-dismm, " MRP type
END OF it_verify.
3. INTERNAL TABLE TO STORE MATERIALS WHICH HAS NO MRP TYPE ASSIGNED.
DATA: BEGIN OF it_marc OCCURS 0,
matnr LIKE marc-matnr, " Material No.
werks LIKE marc-werks, " Plant
dismm LIKE marc-dismm, " MRP type
END OF it_marc.
3. INTERNAL TABLE TO STORE MATERIALS WHICH ARE ALREADY MAINTAINED FOR
*lgort = 'ABCD'.
DATA: BEGIN OF it_error OCCURS 0, "#EC *
index TYPE I,
fname(25),
fval(30),
err_msg(40),
END OF it_error.
DATA: BEGIN OF it_error1 OCCURS 0, "#EC *
matnr LIKE mard-matnr,
type LIKE bapiret2-type,
id LIKE bapiret2-id,
message LIKE bapiret2-message,
END OF it_error1.
TABLES FOR FUNCTION - BAPI_MATERIAL_SAVEDATA
DATA: I_HEADDATA LIKE BAPIMATHEAD, " HEADER DATA
I_STORAGELOCATIONDATA LIKE BAPI_MARD, " STORAGE
*LOCATION SPECIFIC MATERIAL DATA
I_STORAGELOCATIONDATAX LIKE BAPI_MARDX, " Information on
*update for STORAGELOCATIONDATA
I_RETURN LIKE BAPIRET2, " RETURN FROM
*BAPI
I_RETURNMESSAGES LIKE BAPI_MATRETURN2 OCCURS 0 WITH
HEADER LINE.
SELECTION PARAMETERS
SELECTION-SCREEN BEGIN OF BLOCK MAIN WITH FRAME TITLE TEXT-001.
SELECT-OPTIONS s_matnr FOR mard-matnr. " Material Number
SELECTION-SCREEN END OF BLOCK MAIN.
SELECTION SCREEN VALIDATION.
AT SELECTION-SCREEN .
PERFORM validate_material.
START OF SELECTION
START-OF-SELECTION.
PERFORM extract_itmard.
PERFORM extract_itmarc.
PERFORM extract_itverify.
PERFORM verify_material.
PERFORM display_error_report.
*& Form extract_itmard
text
--> p1 text
<-- p2 text
form extract_itmard .
SELECT matnr werks lgort
FROM mard
INTO TABLE it_mard
WHERE matnr IN s_matnr AND
werks = 'RAPI' AND " Plant
lgort = 'RAPI' . " Storage Location
IF sy-subrc NE 0.
MESSAGE s114. " Success Message --> Data
Not Available
STOP.
ENDIF.
endform. " extract_itmard
*& Form extract_itmarc
text
--> p1 text
<-- p2 text
form extract_itmarc . "Fetch Materials for which the MRP
*Type is not maintained
SELECT matnr werks dismm
FROM marc
INTO TABLE it_marc
FOR ALL ENTRIES IN it_mard
WHERE matnr = it_mard-matnr AND
werks = it_mard-werks AND
dismm = ' '.
endform. " extract_itmarc
*& Form extract_itverify
text
--> p1 text
<-- p2 text
form extract_itverify . " Fetch All the Materials
which are already extended for the Storage Location
IF it_mard[] IS NOT INITIAL. "Check it_likp for not
null
SELECT matnr werks lgort
FROM mard
INTO TABLE it_verify
FOR ALL ENTRIES IN it_mard
WHERE matnr = it_mard-matnr AND
werks = 'RAPI' AND " For Plant
lgort = '0001'. " For Storage
Location
ELSE.
MESSAGE s114. "Success Message -->
Data Not Available
STOP.
ENDIF.
endform. " extract_itverify
*& Form verify_material
text
--> p1 text
<-- p2 text
FORM verify_material .
DATA: v_cnt TYPE I.
v_cnt = 1.
IF it_verify[] IS NOT INITIAL AND it_marc[] IS NOT INITIAL.
"Check it_likp for not null
SORT it_mard BY matnr.
SORT it_verify BY matnr.
ENDIF.
LOOP AT it_mard.
IF it_verify[] IS NOT INITIAL. " Check it_verify
for not null
READ TABLE it_verify WITH KEY matnr = it_mard-matnr BINARY
SEARCH. " Check Material is not extended
IF sy-subrc <> 0.
READ TABLE it_marc WITH KEY matnr = it_mard-matnr BINARY
SEARCH. " Check MRP Type for the Material is Maintained
IF sy-subrc <> 0.
PERFORM extend_material USING it_mard-matnr
" Extend Material
it_mard-werks.
ELSE.
it_error-index = v_cnt.
" Generate Error Report
it_error-fname = 'MATERIAL NO'.
it_error-fval = it_mard-matnr.
it_error-err_msg = 'MRP Type Not Maintained'.
APPEND it_error.
v_cnt = v_cnt + 1.
ENDIF.
ENDIF.
ELSE.
READ TABLE it_marc WITH KEY matnr = it_mard-matnr BINARY
SEARCH.
IF sy-subrc <> 0.
PERFORM extend_material USING it_mard-matnr
it_mard-werks.
ENDIF.
ENDIF.
ENDLOOP.
ENDFORM. " verify_material
*& Form extend_material
text
-->P_IT_MARD_MATNR text
-->P_IT_MARD_WERKS text
-->P_IT_MARD_LGORT text
FORM extend_material USING P_IT_MARD_MATNR TYPE mard-matnr
P_IT_MARD_WERKS TYPE mard-werks.
DATA: v_str(50).
CLEAR I_HEADDATA.
I_HEADDATA-MATERIAL = P_IT_MARD_MATNR.
I_HEADDATA-MRP_VIEW = 'X'.
CLEAR I_STORAGELOCATIONDATA.
CLEAR I_STORAGELOCATIONDATAX.
I_STORAGELOCATIONDATA-PLANT = P_IT_MARD_WERKS.
I_STORAGELOCATIONDATA-STGE_LOC = '0001'.
I_STORAGELOCATIONDATAX-PLANT = P_IT_MARD_WERKS.
I_STORAGELOCATIONDATAX-STGE_LOC = '0001'.
CALL FUNCTION 'BAPI_MATERIAL_SAVEDATA'
EXPORTING
headdata = i_headdata
CLIENTDATA =
CLIENTDATAX =
PLANTDATA =
PLANTDATAX =
FORECASTPARAMETERS =
FORECASTPARAMETERSX =
PLANNINGDATA =
PLANNINGDATAX =
STORAGELOCATIONDATA = i_storagelocationdata
STORAGELOCATIONDATAX = i_storagelocationdatax
VALUATIONDATA =
VALUATIONDATAX =
WAREHOUSENUMBERDATA =
WAREHOUSENUMBERDATAX =
SALESDATA =
SALESDATAX =
STORAGETYPEDATA =
STORAGETYPEDATAX =
FLAG_ONLINE = ' '
FLAG_CAD_CALL = ' '
NO_DEQUEUE = ' '
IMPORTING
RETURN = i_return
TABLES
MATERIALDESCRIPTION =
UNITSOFMEASURE =
UNITSOFMEASUREX =
INTERNATIONALARTNOS =
MATERIALLONGTEXT =
TAXCLASSIFICATIONS =
RETURNMESSAGES = i_returnmessages
PRTDATA =
PRTDATAX =
EXTENSIONIN =
EXTENSIONINX =
LOOP at i_returnmessages.
write: / i_returnmessages-message.
ENDLOOP.
v_str = 'Material No does not Exist'.
IF i_return-type = 'E'.
it_error1-matnr = P_IT_MARD_MATNR.
it_error1-type = i_return-type.
it_error1-id = i_return-id.
it_error1-message = v_str.
APPEND it_error1.
ELSEIF i_return-type = 'S'.
READ TABLE i_returnmessages WITH KEY TYPE = 'S' id = 'M3'.
IF sy-subrc = 0.
it_error1-matnr = P_IT_MARD_MATNR.
it_error1-type = i_return-type.
it_error1-id = i_return-id.
it_error1-message = i_returnmessages-message.
APPEND it_error1.
CLEAR it_error1.
ENDIF.
ENDIF.
REFRESH i_returnmessages.
CLEAR it_error1.
CLEAR i_return.
ENDFORM. " extend_material
*& Form display_error_report
text
--> p1 text
<-- p2 text
FORM display_error_report .
CALL FUNCTION 'GUI_DOWNLOAD'
EXPORTING
BIN_FILESIZE =
FILENAME = 'C:/Error1.txt'
FILETYPE = 'ASC'
APPEND = ' '
WRITE_FIELD_SEPARATOR = ' '
HEADER = '00'
TRUNC_TRAILING_BLANKS = ' '
WRITE_LF = 'X'
COL_SELECT = ' '
COL_SELECT_MASK = ' '
DAT_MODE = ' '
IMPORTING
FILELENGTH =
TABLES
DATA_TAB = it_error1
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.
CALL FUNCTION 'GUI_DOWNLOAD'
EXPORTING
BIN_FILESIZE =
FILENAME = 'C:/Error.txt'
FILETYPE = 'ASC'
APPEND = ' '
WRITE_FIELD_SEPARATOR = ' '
HEADER = '00'
TRUNC_TRAILING_BLANKS = ' '
WRITE_LF = 'X'
COL_SELECT = ' '
COL_SELECT_MASK = ' '
DAT_MODE = ' '
IMPORTING
FILELENGTH =
TABLES
DATA_TAB = it_error
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.
ENDFORM. " display_error_report
*& Form validate_material
text
--> p1 text
<-- p2 text
form validate_material .
IF NOT s_matnr[] IS INITIAL.
SELECT matnr
INTO mard-matnr
FROM mard
UP TO 1 ROWS
WHERE matnr IN s_matnr.
ENDSELECT.
IF SY-SUBRC <> 0.
MESSAGE E115 WITH 'Invalid' mard-matnr. " Error
Message-->Invalid Parameters
ENDIF.
ENDIF.
IF NOT s_matnr[] IS INITIAL.
SELECT matnr
INTO marc-matnr
FROM marc
UP TO 1 ROWS
WHERE matnr IN s_matnr.
ENDSELECT.
IF sy-subrc <> 0.
MESSAGE s114. "Success Message -->
Data Not Available
STOP.
ENDIF.
ENDIF.
endform. " validate_material
Some frums links
gui download
Sample code for FTP download
http://www.sapdevelopment.co.uk/file/file_updownpop.htm
<b>Reward points if useful</b>
Regards
Ashu -
Filename in gui_download and ws_download
Hi Friends..
if i using like this..
concatenate 'C:\'
syst-date
'.xls'
into mc_filename.
in program and gave the mc_filname as a filename in the function module.its working fine in ws_download but it was not working in gui_download function module.
so please give your valuable suggetion regarding this..
Thanks
GowrishankarHi Gowrishankar,
In WS_DOWNLOAD Function module Filename type is char but
In GUI_DOWNLOAD Function module Filename type is string.
so it is going to dump. first change the type of filename in your program
Plzz reward if it is helpful,
Mahi. -
How to get some character as a field separator while in GUI_DOWNLOAD ?
Hi Friends,
I have to download data from an internal table to a text file. The field separator
between the fields should be comms (,). So, after getting the data into internal table i'm calling the Function Module GUI_DOWNLOAD. Now using this function module can i insert a comma spearator between the fields, if not what is the other way to do it?Hi,
Its not possible to give the field separator as ',' directly with gui_download from you internal table.
Below is the example through which you can achieve the following,
this is a tested program and is working fine on the system....
so you can use the logic to achieve the following result.... hope this logic helps you to achieve your functionality....
DATA:
BEGIN OF fs,
col1(6) TYPE c,
col2(4) TYPE c,
col3 TYPE c,
END OF fs.
DATA :
BEGIN OF line,
line(255) TYPE c,
END OF line.
DATA: itab LIKE TABLE OF fs,
itab2 LIKE TABLE OF line.
DEFINE m_tab.
clear fs.
fs-col1 = &1.
fs-col2 = &2.
fs-col3 = &3.
append fs to itab.
END-OF-DEFINITION.
m_tab '006000' '0010' 'J'.
m_tab '006000' '0010' 'J'.
m_tab '006000' '0010' 'M'.
m_tab '006000' '0010' 'M'.
m_tab '006000' '0010' 'O'.
m_tab '006000' '0010' 'O'.
m_tab '006000' '0010' 'T'.
m_tab '006000' '0010' 'T'.
LOOP AT itab INTO fs.
CONCATENATE fs-col1
fs-col2
fs-col3
INTO line
SEPARATED BY ','.
APPEND line TO itab2.
ENDLOOP.
CALL FUNCTION 'GUI_DOWNLOAD'
EXPORTING
* BIN_FILESIZE =
filename = 'C:\filename.txt'
* FILETYPE = 'ASC'
* APPEND = ' '
* WRITE_FIELD_SEPARATOR = ' '
* HEADER = '00'
* TRUNC_TRAILING_BLANKS = ' '
* WRITE_LF = 'X'
* COL_SELECT = ' '
* COL_SELECT_MASK = ' '
* DAT_MODE = ' '
* CONFIRM_OVERWRITE = ' '
* NO_AUTH_CHECK = ' '
* CODEPAGE = ' '
* IGNORE_CERR = ABAP_TRUE
* REPLACEMENT = '#'
* WRITE_BOM = ' '
* TRUNC_TRAILING_BLANKS_EOL = 'X'
* WK1_N_FORMAT = ' '
* WK1_N_SIZE = ' '
* WK1_T_FORMAT = ' '
* WK1_T_SIZE = ' '
* WRITE_LF_AFTER_LAST_LINE = ABAP_TRUE
* SHOW_TRANSFER_STATUS = ABAP_TRUE
* IMPORTING
* FILELENGTH =
TABLES
data_tab = itab2
* FIELDNAMES =
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.
WRITE sy-subrc.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
* WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
Regards,
Siddarth -
How to give path at runtime in GUI_DOWNLOAD
Hi experts,
I have a below given parameter on the selection screen:
SELECTION-SCREEN: BEGIN OF BLOCK b5 WITH FRAME TITLE text-005.
PARAMETERS: p_path LIKE RLGRAP-FILENAME modif id ZF1.
SELECTION-SCREEN: END OF BLOCK b5.
I am using the FM GUI_DOWNLOAD in my report.
My requirement is that I need to pass the path given
in p_path in this FM, i.e. I need not hard code the path in the
FM parameter 'filename', but need to pass it at runtime.
How can this functionality be achieved?
Thanks,
Ajay.Hi Ajay,
check the below code i hope it will help you.
SELECTION-SCREEN BEGIN OF BLOCK upfile WITH FRAME TITLE text-009.
PARAMETERS: p_file TYPE rlgrap-filename OBLIGATORY. "Source file name
SELECTION-SCREEN END OF BLOCK upfile.
*AT SELECTION-SCREEN
Browse source file name
AT SELECTION-SCREEN ON VALUE-REQUEST FOR p_file.
PERFORM f_browse_file CHANGING p_file.
FORM f_browse_file CHANGING p_p_file.
DATA: it_l_filetab TYPE filetable,
wa_l_filetab TYPE file_table,
l_rc TYPE i.
CLEAR it_l_filetab.
Browsing file
CALL METHOD cl_gui_frontend_services=>file_open_dialog
CHANGING
file_table = it_l_filetab
rc = l_rc
EXCEPTIONS
file_open_dialog_failed = 1
cntl_error = 2
error_no_gui = 3
not_supported_by_gui = 4
OTHERS = 5.
IF sy-subrc IS NOT INITIAL.
MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ELSE.
READ TABLE it_l_filetab INTO wa_l_filetab INDEX 1.
IF sy-subrc IS INITIAL.
p_p_file = wa_l_filetab-filename.
ENDIF. " sy-subrc Read
ENDIF. " sy-subrc-call method
ENDFORM. " f_browse_file
START-OF-SELECTION.
*Upload File
PERFORM f110_upload_from_pc.
FORM f110_upload_from_pc .
DATA : lv_file TYPE rlgrap-filename.
DATA : l_files TYPE string,
l_ret TYPE abap_bool.
CLEAR it_file_data.
lv_file = p_file.
l_files = p_file.
CONSTANTS: c_tab TYPE c VALUE cl_abap_char_utilities=>horizontal_tab.
CALL FUNCTION 'GUI_UPLOAD'
EXPORTING
filename = l_files
filetype = 'ASC'
has_field_separator = c_tab
codepage = '6300'
READ_BY_LINE = 'X'
replacement = '-'
TABLES
data_tab = i_tab_order
EXCEPTIONS
file_open_error = 1
file_read_error = 2
no_batch = 3
gui_refuse_filetransfer = 4
invalid_type = 5
no_authority = 6
unknown_error = 7
bad_data_format = 8
header_not_allowed = 9
separator_not_allowed = 10
header_too_long = 11
unknown_dp_error = 12
access_denied = 13
dp_out_of_memory = 14
disk_full = 15
dp_timeout = 16
OTHERS = 17.
IF sy-subrc <> 0.
MESSAGE 'Error in upload'(008) TYPE 'I' DISPLAY LIKE 'E' .
LEAVE TO LIST-PROCESSING.
ENDIF.
ENDFORM. " f_UPLOAD_FROM_PC
I hopr this will helps you
Regards,
Tarun
Edited by: Devalla T Kumar on Dec 29, 2009 9:54 AM -
Looking for some assistancte in GUI_DOWNLOAD
Hi there,
See I have this exercise I have to do here. Basically I have to create a program that will download the contects of SBOOK to my pc. I have to use GUI_DOWNLOAD in this exercise. Also, the user will have to input the path and file name of the file to be downloaded to. I have place appropriate error message on the screen as well but I'm not sure how to do this.Being relatively new to this, I tried looking for some samples and this is what I came up so far.
REPORT ZISTANZS_TRNG_EX9C.
TABLES: SBOOK.
PARAMETERS: FILEINP(30) DEFAULT 'c:\TEMP\wee.txt' OBLIGATORY.
DATA: BEGIN OF ITAB OCCURS 100.
INCLUDE STRUCTURE SBOOK.
DATA: END OF ITAB.
CALL FUNCTION 'GUI_DOWNLOAD'
EXPORTING
FILENAME = FILEINP
FILETYPE = 'ASC'
write_field_separator = 'X'
TABLES
DATA_TAB = ITAB
EXCEPTIONS
FILE_OPEN_ERROR = 1
FILE_WRITE_ERROR = 2
OTHERS = 3.
Unfortunately, it doesn't work though. It keeps saying that my FILENAME is not the same data type as FILEINP? I'm asking for some assistance in how this can be properly solved? Any help would be appreciated /Hi,
Please refer the code below:
* File download, uses older techniques but achieves a perfectly
* acceptable solution which also allows the user to append data to
* an existing file.
PARAMETERS: p_file like rlgrap-filename.
* Internal table to store export data
DATA: begin of it_excelfile occurs 0,
row(500) type c,
end of it_excelfile.
DATA: rc TYPE sy-ucomm,
ld_answer TYPE c.
CALL FUNCTION 'WS_QUERY'
EXPORTING
query = 'FE' "File Exist?
filename = p_file
IMPORTING
return = rc.
IF rc NE 0. "If File alread exists
CALL FUNCTION 'POPUP_TO_CONFIRM'
EXPORTING
* TITLEBAR = ' '
* DIAGNOSE_OBJECT = ' '
text_question = 'File Already exists!!'
text_button_1 = 'Replace'
* ICON_BUTTON_1 = ' '
text_button_2 = 'New name'
* ICON_BUTTON_2 = ' '
* DEFAULT_BUTTON = '1'
* DISPLAY_CANCEL_BUTTON = 'X'
* USERDEFINED_F1_HELP = ' '
* START_COLUMN = 25
* START_ROW = 6
* POPUP_TYPE =
IMPORTING
answer = ld_answer
* TABLES
* PARAMETER =
EXCEPTIONS
text_not_found = 1
OTHERS = 2.
* Option 1: Overwrite
IF ld_answer EQ '1'.
CALL FUNCTION 'GUI_DOWNLOAD'
EXPORTING
* BIN_FILESIZE =
filename = p_file "File Name
filetype = 'ASC'
* IMPORTING
* FILELENGTH =
TABLES
data_tab = it_excelfile "Data table
EXCEPTIONS
file_write_error = 1
no_batch = 2
gui_refuse_filetransfer = 3
invalid_type = 4
OTHERS = 5.
IF sy-subrc <> 0.
MESSAGE i003(zp) WITH
'There was an error during Excel file creation'(200).
exit. "Causes short dump if removed and excel document was open
ENDIF.
* Option 2: New name.
ELSEIF ld_answer EQ '2'.
CALL FUNCTION 'DOWNLOAD'
EXPORTING
filename = p_file "File name
filetype = 'ASC' "File type
* col_select = 'X' "COL_SELECT
* col_selectmask = 'XXXXXXXXXXXXXXXXXXXXXXXXXX'
* "COL_SELECTMASK
filetype_no_show = 'X' "Show file type selection?
* IMPORTING
* act_filename = filename_dat
TABLES
data_tab = it_excelfile "Data table
* fieldnames =
EXCEPTIONS
file_open_error = 01
file_write_error = 02
invalid_filesize = 03
invalid_table_width = 04
invalid_type = 05
no_batch = 06
unknown_error = 07.
ENDIF.
ELSE. "File does not alread exist.
CALL FUNCTION 'GUI_DOWNLOAD'
EXPORTING
* BIN_FILESIZE =
filename = p_file "File name
filetype = 'ASC' "File type
* IMPORTING
* FILELENGTH =
TABLES
data_tab = it_excelfile "Data table
EXCEPTIONS
file_write_error = 1
no_batch = 2
gui_refuse_filetransfer = 3
invalid_type = 4
OTHERS = 5.
IF sy-subrc <> 0.
MESSAGE i003(zp) WITH
'There was an error during Excel file creation'(200).
exit. "Causes short dump if removed and excel document was open
ENDIF.
ENDIF.
Thanks,
Sriram Ponna. -
Use 3 internal table in GUI_Download
Hello expert,
i have 3 internal table: gt_header, gt_body and gt_footer. how can i used all 3 in gui_download fm. here is my sample code:
CALL FUNCTION 'GUI_DOWNLOAD'
EXPORTING
filename = gv_file_name
filetype = 'ASC'
TABLES
data_tab = gt_header.
here i can only pass one internal table.
Help please?Hi Hassim,
Maybe you can declare another internal table, with all fields is type C and length as you wanted.
Loop those three itabs, append to this new itab. then call this FM download.
regards,
Archer -
In gui_download FM can we input FILETYPE = 'WK1'
In gui_download FM can we use the filetype = 'wk1'. or it is going to support only BIN and ASC.
i want to upgraded ws_download to gui_download.in that ws_download filetype was 'WK1' .so how to give WK1 IN GUI_DOWNLOAD.
PLS ITS URGENTyou can use WK1 also
chk this help
'ASC' :
ASCII format. The table is transferred as text. The conversion exits are carried out. The output format additionally depends on the parameters CODEPAGE, TRUNC_TRAILING_BLANKS, and TRUNC_TRAILING_BLANKS_EOL.
'IBM' :
ASCII format with IBM codepage conversion (DOS). This format corresponds to the 'ASC' format when using target codepage 1103. This codepage is often used for data exchange by disc.
'DAT' :
Column-by-column transfer. With this format, the data is transferred as with ASC text. However, no conversion exists are carried out and the columns are separated by tab characters. This format creates files that can be uploaded again with gui_upload or ws_upload.
'DBF' :
The data is downloaded in dBase format. Because in this format the file types of the individual columns are included, import problems, for example, into Microsoft Excel can be avoided, especially when interpreting numeric values.
'WK1' :
The data is downloaded in Lotus 1-2-3 format.
'BIN' :
Binary format. The data is transferred in binary format. There is no formatting and no codepage conversion. The data is interpreted row by row and not formatted in columns. Specify the length of the data in parameter BIN_FILESIZE. The table should consist of a column of type X, because especially in Unicode systems the conversion of structured data into binary data leads to errors. -
Hi sap gurus can any body help me
REPORT ZFIR_GRIR_IPV
NO STANDARD PAGE HEADING
LINE-SIZE 120
MESSAGE-ID ZFI02.
TABLES: BSEG,BKPF.
TYPES: BEGIN OF A_FINAL,
BUKRS TYPE CHAR12,
HKONT_P TYPE CHAR18,
GJAHR TYPE CHAR11,
BELNR TYPE CHAR19,
BUDAT TYPE CHAR12,
WAERS TYPE CHAR8,
XBLNR TYPE CHAR20,
BLART TYPE CHAR13,
MONAT TYPE CHAR13,
DMBTR_P TYPE CHAR13,
KOSTL TYPE CHAR11,
PRCTR_P TYPE CHAR13,
HKONT_G TYPE CHAR18,
DMBTR_G TYPE CHAR13,
PRCTR_G TYPE CHAR13,
BUZID_G TYPE CHAR15,
END OF A_FINAL.
changes on 30 th may by dileep
TYPES: BEGIN OF IT_FINAL,
BUKRS TYPE BUKRS ,
HKONT TYPE HKONT,
BELNR TYPE BELNR_D,
DMBTR TYPE DMBTR ,
KOSTL TYPE KOSTL,
PRCTR TYPE PRCTR,
END OF IT_FINAL.
TYPES: BEGIN OF IT_FINAL1,
BUKRS TYPE BUKRS,
HKONT TYPE HKONT,
GJAHR TYPE GJAHR ,
BELNR TYPE BELNR_D,
BUDAT TYPE BUDAT,
WAERS TYPE WAERS ,
XBLNR TYPE XBLNR1,
BLART TYPE BLART,
MONAT TYPE MONAT,
DMBTR TYPE DMBTR,
KOSTL TYPE KOSTL,
PRCTR TYPE PRCTR,
END OF IT_FINAL1.
end of changes on 30 th may by dileep
TYPES: BEGIN OF P_FINAL,
BUKRS TYPE CHAR12,
DELIMITER_1 TYPE CHAR1,
HKONT_P TYPE CHAR18,
DELIMITER_2 TYPE CHAR1,
GJAHR TYPE CHAR11,
DELIMITER_3 TYPE CHAR1,
BELNR TYPE CHAR19,
DELIMITER_4 TYPE CHAR1,
BUDAT TYPE CHAR12,
DELIMITER_5 TYPE CHAR1,
WAERS TYPE CHAR8,
DELIMITER_6 TYPE CHAR1,
XBLNR TYPE CHAR20,
DELIMITER_7 TYPE CHAR1,
BLART TYPE CHAR13,
DELIMITER_8 TYPE CHAR1,
MONAT TYPE CHAR13,
DELIMITER_9 TYPE CHAR1,
DMBTR_P TYPE CHAR13,
DELIMITER_10 TYPE CHAR1,
KOSTL TYPE CHAR11,
DELIMITER_11 TYPE CHAR1,
PRCTR_P TYPE CHAR13,
DELIMITER_12 TYPE CHAR1,
HKONT_G TYPE CHAR18,
DELIMITER_13 TYPE CHAR1,
DMBTR_G TYPE CHAR13,
DELIMITER_14 TYPE CHAR1,
PRCTR_G TYPE CHAR13,
DELIMITER_15 TYPE CHAR1,
BUZID_G TYPE CHAR15,
END OF P_FINAL.
DATA: IT_BSEG TYPE STANDARD TABLE OF IT_FINAL INITIAL SIZE 0,
I_BSEG TYPE STANDARD TABLE OF IT_FINAL1 INITIAL SIZE 0,
I_FINAL TYPE STANDARD TABLE OF A_FINAL INITIAL SIZE 0 WITH HEADER LINE,
I_FINAL_P TYPE STANDARD TABLE OF P_FINAL INITIAL SIZE 0 WITH HEADER LINE,
W_FINAL_P TYPE P_FINAL,
W_BSEG1 TYPE BSEG,
WA_BSEG TYPE IT_FINAL OCCURS 0 WITH HEADER LINE,
W_BSEG TYPE IT_FINAL1 OCCURS 0 WITH HEADER LINE,
T_BSEG TYPE STANDARD TABLE OF BSEG INITIAL SIZE 0 WITH HEADER LINE,
W_FINAL TYPE A_FINAL,
F_YEAR TYPE BAPI0002_4-FISCAL_YEAR,
F_PERIOD TYPE BAPI0002_4-FISCAL_PERIOD,
RETURN1 TYPE BAPIRETURN1,
V_DATE TYPE CHAR8, " Date in YYYYMMDD format
V_PRESPATH TYPE STRING, " Path
V_APPPATH TYPE STRING, " Path
V_FILENAME(25) TYPE C, " File Name
V_PERIOD TYPE CHAR3, " Date for Posting Period
V_FSYEAR TYPE BDATJ, " Fiscal Year
L_TEXT TYPE CHAR1. " Hypen
CONSTANTS: C_TXT TYPE CHAR4 VALUE '.txt', " File Extension
C_TXT1 TYPE STRING VALUE 'txt', " File Type
C_FLAG_X TYPE CHAR1 VALUE 'X', " Flag
C_ASC TYPE FILETYPE VALUE 'ASC', " File type
C_DAT TYPE CHAR4 VALUE '.dat', " File Type
C_FLAG_1 TYPE CHAR1 VALUE '1', " Constant value
C_ZERO TYPE CHAR1 VALUE '0', " Constant
C_GLD(10) TYPE C VALUE 'GRIR021S', " Constant in file Path
C_DIR TYPE CHAR3 VALUE 'C:\', " Presentation Server path
C_FLAG_12 TYPE CHAR2 VALUE '12', " Constant value
C_PCFILE TYPE STRING VALUE 'PC File',
C_DELIMITER TYPE C VALUE '|'.
SELECTION-SCREEN BEGIN OF BLOCK B1 WITH FRAME TITLE TEXT-000.
*--- Selection Criteria
SELECT-OPTIONS: S_BUKRS FOR BSEG-BUKRS DEFAULT '012T', " Company Code
S_HKONT FOR BSEG-HKONT OBLIGATORY DEFAULT '4505001',
S_GJAHR FOR BKPF-GJAHR DEFAULT SY-DATUM+0(4),
S_MONAT FOR BKPF-MONAT DEFAULT SY-DATUM+4(2),
S_BELNR FOR BSEG-BELNR ,
S_BUDAT FOR BKPF-BUDAT ,
S_PRCTR FOR BSEG-PRCTR OBLIGATORY DEFAULT '12TOTH00',
S_BLART FOR BKPF-BLART OBLIGATORY DEFAULT 'RE'.
SELECTION-SCREEN END OF BLOCK B1.
SELECTION-SCREEN BEGIN OF BLOCK B2 WITH FRAME TITLE TEXT-001.
*--- Radio Buttons for chose the PC Path or App.. Server Path
SELECTION-SCREEN BEGIN OF LINE.
PARAMETERS:
RB_PFILE RADIOBUTTON GROUP RAD2 DEFAULT 'X' USER-COMMAND UCOMM1.
SELECTION-SCREEN COMMENT 5(27) TEXT-002 FOR FIELD RB_PFILE.
PARAMETERS:
P_PFILE LIKE RLGRAP-FILENAME LOWER CASE.
SELECTION-SCREEN END OF LINE.
SELECTION-SCREEN BEGIN OF LINE.
PARAMETERS:
RB_AFILE RADIOBUTTON GROUP RAD2.
SELECTION-SCREEN COMMENT 5(27) TEXT-003 FOR FIELD RB_AFILE.
PARAMETERS:
P_AFILE LIKE RLGRAP-FILENAME LOWER CASE. " Path for AS
SELECTION-SCREEN END OF LINE.
SELECTION-SCREEN END OF BLOCK B2.
AT SELECTION-SCREEN ON VALUE-REQUEST FOR P_PFILE.
*-- Select File name with Dialog Box
PERFORM SUB_GET_FILENAME CHANGING P_PFILE.
AT SELECTION-SCREEN ON VALUE-REQUEST FOR P_AFILE.
*--- Attach F4 HELP CORRESPONDING TO THE FIELD
PERFORM SUB_AP_F4.
AT SELECTION-SCREEN OUTPUT.
*--Modify screen parameters
PERFORM SUB_MODIFY_SCREEN.
AT SELECTION-SCREEN.
*--- Selection Screen validations for Company Code
PERFORM SUB_VALIDATION_BUKRS.
*--- Selection Screen validations for Chart of Accounts
PERFORM SUB_VALIDATION_HKONT.
*--- Selection Screen validations Fiscal Year
PERFORM SUB_VALIDATION_GJAHR.
*--- Selection Screen validations for Peiod
PERFORM SUB_VALIDATION_MONAT.
*--- Selection Screen validations for Company Code
PERFORM SUB_VALIDATION_BELNR.
*--- Selection Screen validations for Chart of Accounts
PERFORM SUB_VALIDATION_BUDAT.
*--- Selection Screen validations Fiscal Year
PERFORM SUB_VALIDATION_PRCTR.
*--- Selection Screen validations for Peiod
PERFORM SUB_VALIDATION_BLART.
START-OF-SELECTION
START-OF-SELECTION.
*--- Check whether filepath/name have been entered in the sel screen
PERFORM SUB_CHECK_FILEPATH.
*--- Prepare Final Internal Table.
PERFORM SUB_PREPARE_FINAL.
*--- Download data.
PERFORM SUB_DOWNLOAD_DATA .
*& Form sub_get_filename
text
<--P_PFILE Presentation server File name
FORM SUB_GET_FILENAME CHANGING P_FILE TYPE C.
DATA : L_FILENAME TYPE STRING, " For File Name
L_PATH TYPE STRING, " For Directory
L_FULLPATH TYPE STRING. " Full path
*--- For File Open Dialog Box
CALL METHOD CL_GUI_FRONTEND_SERVICES=>FILE_SAVE_DIALOG
EXPORTING
WINDOW_TITLE = C_PCFILE " Window Title
DEFAULT_EXTENSION = C_TXT1 " File Extn
PROMPT_ON_OVERWRITE = C_FLAG_X " Over write
CHANGING
FILENAME = L_FILENAME " File Name
PATH = L_PATH " File Path
FULLPATH = L_FULLPATH " Full Path
EXCEPTIONS
CNTL_ERROR = 1
ERROR_NO_GUI = 2
NOT_SUPPORTED_BY_GUI = 3
OTHERS = 4.
IF SY-SUBRC NE 0.
*--- Error in opening the file
MESSAGE E000.
ELSE.
CONCATENATE L_PATH
L_FILENAME
INTO P_FILE.
V_PRESPATH = L_PATH.
ENDIF.
ENDFORM. " sub_get_filename
*& Form sub_ap_f4
f4 help attched with application server
FORM SUB_AP_F4 .
*--- FM for to get the Application Server Path
IF RB_AFILE = C_FLAG_X.
CALL FUNCTION '/SAPDMC/LSM_F4_SERVER_FILE'
EXPORTING
DIRECTORY =
FILEMASK = C_ASC " File Extn
IMPORTING
SERVERFILE = P_AFILE " File Path
EXCEPTIONS
CANCELED_BY_USER = 1
OTHERS = 2.
IF SY-SUBRC NE 0.
*--- Error in opening the file
MESSAGE E000.
ENDIF.
ENDIF.
ENDFORM. " sub_ap_f4
*& Form sub_modify_screen
text
--> p1 text
<-- p2 text
FORM SUB_MODIFY_SCREEN .
*--- Selection screen Modifications
IF RB_PFILE = C_FLAG_X.
LOOP AT SCREEN.
IF SCREEN-NAME = 'P_PFILE' OR
SCREEN-NAME = '%_P_PFILE_%_APP_%-TEXT'.
SCREEN-ACTIVE = C_FLAG_1.
CONCATENATE C_DIR C_GLD V_DATE SY-UZEIT(4) C_TXT INTO P_PFILE.
MODIFY SCREEN.
ENDIF.
ENDLOOP.
ELSE.
LOOP AT SCREEN.
IF SCREEN-NAME = 'P_PFILE' OR
SCREEN-NAME = '%_P_PFILE_%_APP_%-TEXT'.
SCREEN-ACTIVE = C_ZERO.
MODIFY SCREEN.
ENDIF.
ENDLOOP.
ENDIF.
IF RB_AFILE = C_FLAG_X.
LOOP AT SCREEN.
IF SCREEN-NAME = 'P_AFILE' OR
SCREEN-NAME = '%_P_AFILE_%_APP_%-TEXT'.
SCREEN-ACTIVE = C_FLAG_1.
CONCATENATE '/Solectron/Data/' C_GLD V_DATE SY-UZEIT(4) C_DAT
INTO P_AFILE.
MODIFY SCREEN.
ENDIF.
ENDLOOP.
ELSE.
LOOP AT SCREEN.
IF SCREEN-NAME = 'P_AFILE' OR
SCREEN-NAME = '%_P_AFILE_%_APP_%-TEXT'.
SCREEN-ACTIVE = C_ZERO.
MODIFY SCREEN.
ENDIF.
ENDLOOP.
ENDIF.
IF RB_PFILE = C_FLAG_X.
LOOP AT SCREEN.
IF SCREEN-NAME = 'P_PFILE'.
SCREEN-ACTIVE = C_FLAG_1.
ENDIF.
IF SCREEN-NAME = 'P_AFILE'.
SCREEN-ACTIVE = C_ZERO.
ENDIF.
MODIFY SCREEN.
ENDLOOP.
ELSEIF RB_AFILE = C_FLAG_X.
LOOP AT SCREEN.
IF SCREEN-NAME = 'P_PFILE'.
SCREEN-ACTIVE = C_ZERO.
ENDIF.
IF SCREEN-NAME = 'P_AFILE'.
SCREEN-ACTIVE = C_FLAG_1.
ENDIF.
MODIFY SCREEN.
ENDLOOP.
ENDIF.
ENDFORM. " sub_modify_screen
*& Form sub_validation_bukrs
Validation For Company Code
FORM SUB_VALIDATION_BUKRS .
DATA: L_BUKRS TYPE BUKRS. " Company Code
IF S_BUKRS IS NOT INITIAL.
IF S_BUKRS-HIGH IS NOT INITIAL AND S_BUKRS-LOW IS INITIAL.
MESSAGE E006.
ELSE.
*--- Validation for chart of accounts
SELECT BUKRS " Company Code
FROM T001 UP TO 1 ROWS
INTO L_BUKRS
WHERE BUKRS IN S_BUKRS.
ENDSELECT.
IF SY-SUBRC NE 0.
*--- Invalid Company code
MESSAGE E001.
ENDIF.
ENDIF.
ENDIF.
ENDFORM. " sub_validation_bukrs
*& Form sub_validation_hkont
Validation For General Ledger Account
FORM SUB_VALIDATION_HKONT .
DATA: L_HKONT TYPE HKONT. " General Ledger Account
IF S_HKONT IS INITIAL.
MESSAGE E002.
ELSE.
IF S_HKONT-HIGH IS NOT INITIAL AND S_HKONT-LOW IS INITIAL.
MESSAGE E006.
ELSE.
*--- Validation for chart of accounts
SELECT SAKNR " General Ledger Account
FROM SKA1 UP TO 1 ROWS
INTO L_HKONT
WHERE SAKNR IN S_HKONT AND KTOPL = '1SLR'.
ENDSELECT.
IF SY-SUBRC NE 0.
*--- Invalid General Ledger Account
MESSAGE E003.
ENDIF.
ENDIF.
ENDIF.
ENDFORM. " sub_validation_hkont
*& Form sub_validation_gjahr
Validation For Fiscal Year
FORM SUB_VALIDATION_GJAHR .
DATA: L_GJAHR TYPE GJAHR. " Fiscal Year
IF S_GJAHR IS NOT INITIAL.
IF S_GJAHR-HIGH IS NOT INITIAL AND S_GJAHR-LOW IS INITIAL.
MESSAGE E006.
ENDIF.
ENDIF.
ENDFORM. " sub_validation_gjahr
*& Form sub_validation_monat
Validation For Fiscal period
FORM SUB_VALIDATION_MONAT .
DATA: L_MONAT TYPE MONAT. " Fiscal period
IF S_MONAT IS NOT INITIAL.
IF S_MONAT-LOW LE C_ZERO.
*--- Invalid Fiscal Period
MESSAGE E006.
ENDIF.
IF S_MONAT-HIGH GT C_FLAG_12.
*--- Invalid Fiscal Period
MESSAGE E007.
ENDIF.
ENDIF.
ENDFORM. " sub_validation_monat
*& Form sub_validation_belnr
Validation For Accounting Document Number
FORM SUB_VALIDATION_BELNR .
DATA: L_BELNR TYPE BELNR_D. " Accounting Document Number
IF S_BELNR IS NOT INITIAL.
IF S_BELNR-HIGH IS NOT INITIAL AND S_BELNR-LOW IS INITIAL.
MESSAGE E006.
ENDIF.
ENDIF.
ENDFORM. " sub_validation_belnr
*& Form sub_validation_budat
Validation For Posting Date
FORM SUB_VALIDATION_BUDAT .
DATA: L_BUDAT TYPE BUDAT. " Posting Date
IF S_BUDAT IS NOT INITIAL.
IF S_BUDAT-HIGH IS NOT INITIAL AND S_BUDAT-LOW IS INITIAL.
MESSAGE E006.
ENDIF.
ENDIF.
ENDFORM. " sub_validation_budat
*& Form sub_validation_prctr
Validation For Profit Center
FORM SUB_VALIDATION_PRCTR .
DATA: L_PRCTR TYPE PRCTR. " Profit Center
IF S_PRCTR IS INITIAL.
MESSAGE E010.
ELSE.
IF S_PRCTR-HIGH IS NOT INITIAL AND S_PRCTR-LOW IS INITIAL.
MESSAGE E006.
ELSE.
*--- Validation for chart of accounts
SELECT PRCTR " Profit Center
FROM CEPC UP TO 1 ROWS
INTO L_PRCTR
WHERE PRCTR IN S_PRCTR.
ENDSELECT.
IF SY-SUBRC NE 0.
*--- Invalid Profit Center
MESSAGE E011.
ENDIF.
ENDIF.
ENDIF.
ENDFORM. " sub_validation_prctr
*& Form sub_validation_blart
Validation For Document type
FORM SUB_VALIDATION_BLART .
DATA: L_BLART TYPE BLART. " Document type
IF S_BLART IS INITIAL.
MESSAGE E012.
ELSE.
IF S_BLART-HIGH IS NOT INITIAL AND S_BLART-LOW IS INITIAL.
MESSAGE E006.
ENDIF.
ENDIF.
ENDFORM. " sub_validation_blart
*& Form sub_check_filepath
Check user input for initial filename
FORM SUB_CHECK_FILEPATH .
IF RB_PFILE = C_FLAG_X.
IF P_PFILE IS INITIAL.
*--- The Local File Path can not be Empty
MESSAGE I014.
LEAVE LIST-PROCESSING.
ENDIF.
ELSEIF RB_AFILE = C_FLAG_X.
IF P_AFILE IS INITIAL.
*--- The App Server File Path can not be Empty
MESSAGE I015.
LEAVE LIST-PROCESSING.
ENDIF.
ENDIF.
ENDFORM. " sub_check_filepath
*& Form sub_prepare_final
append the required output data in to the internal table.
FORM SUB_PREPARE_FINAL.
changes on 30 th may by dileep
SELECT * FROM BSEG INTO TABLE I_BSEG WHERE HKONT IN S_HKONT AND "G/L Account
GJAHR IN S_GJAHR AND
PRCTR IN S_PRCTR AND "Profit Center
BLART IN S_BLART . "Document Type
SELECT BUKRS
HKONT
BELNR
DMBTR
KOSTL
PRCTR
FROM BSEG INTO TABLE IT_BSEG WHERE HKONT IN S_HKONT AND "G/L Account
PRCTR IN S_PRCTR. "Profit Center
LOOP AT IT_BSEG INTO WA_BSEG.
SELECT SINGLE GJAHR
BUDAT
WAERS
XBLNR
BLART
MONAT
INTO (W_BSEG-GJAHR,W_BSEG-BUDAT,W_BSEG-WAERS,W_BSEG-XBLNR,W_BSEG-BLART,W_BSEG-MONAT)
FROM BKPF WHERE BELNR = W_BSEG-BELNR AND
GJAHR IN S_GJAHR AND
BLART IN S_BLART . "Document Type
MOVE WA_BSEG-BUKRS TO W_BSEG-BUKRS.
MOVE WA_BSEG-HKONT TO W_BSEG-HKONT.
MOVE WA_BSEG-BELNR TO W_BSEG-BELNR.
MOVE WA_BSEG-DMBTR TO W_BSEG-DMBTR.
MOVE WA_BSEG-KOSTL TO W_BSEG-KOSTL.
MOVE WA_BSEG-PRCTR TO W_BSEG-PRCTR.
APPEND W_BSEG TO I_BSEG.
ENDLOOP.
changes on 30 th may by dileep
IF S_BUKRS IS NOT INITIAL.
SORT I_BSEG BY BUKRS ASCENDING.
DELETE I_BSEG WHERE NOT BUKRS IN S_BUKRS.
ENDIF.
IF S_MONAT IS NOT INITIAL.
SORT I_BSEG BY GJAHR MONAT ASCENDING.
IF S_MONAT-HIGH IS NOT INITIAL AND S_MONAT-LOW IS NOT INITIAL.
DELETE I_BSEG WHERE MONAT < S_MONAT-LOW OR MONAT > S_MONAT-HIGH.
ENDIF.
IF S_MONAT-HIGH IS INITIAL AND S_MONAT-LOW IS NOT INITIAL.
DELETE I_BSEG WHERE MONAT NE S_MONAT-LOW.
ENDIF.
ENDIF.
IF S_BELNR IS NOT INITIAL.
SORT I_BSEG BY BELNR ASCENDING.
DELETE I_BSEG WHERE NOT BELNR IN S_BELNR.
ENDIF.
IF S_BUDAT IS NOT INITIAL.
SORT I_BSEG BY BUDAT ASCENDING.
DELETE I_BSEG WHERE NOT BUDAT IN S_BUDAT.
ENDIF.
LOOP AT I_BSEG INTO W_BSEG.
MOVE W_BSEG-BUKRS TO W_FINAL-BUKRS.
MOVE W_BSEG-HKONT TO W_FINAL-HKONT_P.
MOVE W_BSEG-GJAHR TO W_FINAL-GJAHR.
MOVE W_BSEG-BELNR TO W_FINAL-BELNR.
MOVE W_BSEG-BUDAT TO W_FINAL-BUDAT.
MOVE W_BSEG-WAERS TO W_FINAL-WAERS.
MOVE W_BSEG-XBLNR TO W_FINAL-XBLNR.
MOVE W_BSEG-BLART TO W_FINAL-BLART.
MOVE W_BSEG-MONAT TO W_FINAL-MONAT.
MOVE W_BSEG-DMBTR TO W_FINAL-DMBTR_P.
MOVE W_BSEG-KOSTL TO W_FINAL-KOSTL.
MOVE W_BSEG-PRCTR TO W_FINAL-PRCTR_P.
SELECT SINGLE * FROM BSEG INTO W_BSEG1 WHERE BELNR = W_BSEG-BELNR AND "Document Type
BUZID = 'W' .
IF SY-SUBRC = 0.
MOVE W_BSEG1-HKONT TO W_FINAL-HKONT_G.
MOVE W_BSEG1-DMBTR TO W_FINAL-DMBTR_G.
MOVE W_BSEG1-PRCTR TO W_FINAL-PRCTR_G.
MOVE W_BSEG1-BUZID TO W_FINAL-BUZID_G.
ELSE.
EXIT.
ENDIF.
APPEND W_FINAL TO I_FINAL.
SORT I_FINAL BY BELNR ASCENDING.
ENDLOOP.
ENDFORM. " sub_prepare_final
*& Form sub_download_data
Download data
FORM SUB_DOWNLOAD_DATA .
DATA : V_PRD(2) TYPE N.
IF RB_PFILE = C_FLAG_X.
*--- Downloading To presentation server
V_PRESPATH = P_PFILE.
PERFORM SUB_DOWNLOAD_PRESSERVER.
ELSEIF RB_AFILE = C_FLAG_X.
*--- Downloading To Application server in Auto Mode
V_APPPATH = P_AFILE.
PERFORM SUB_DOWNLOAD_APPSERVER.
ENDIF.
ENDFORM. " sub_download_data
*& Form sub_download_presserver
text
FORM SUB_DOWNLOAD_PRESSERVER.
DATA: MESSAGE TYPE STRING.
IF I_FINAL[] IS INITIAL.
MESSAGE I016.
EXIT.
ELSE.
W_FINAL_P-BUKRS = 'Company Code'.
W_FINAL_P-DELIMITER_1 = '|'.
W_FINAL_P-HKONT_P = 'G/L Account Number'.
W_FINAL_P-DELIMITER_2 = '|'.
W_FINAL_P-GJAHR = 'Fiscal Year'.
W_FINAL_P-DELIMITER_3 = '|'.
W_FINAL_P-BELNR = 'A/c Document Number'.
W_FINAL_P-DELIMITER_4 = '|'.
W_FINAL_P-BUDAT = 'Posting Date' .
W_FINAL_P-DELIMITER_5 = '|'.
W_FINAL_P-WAERS = 'Currency'.
W_FINAL_P-DELIMITER_6 = '|'.
W_FINAL_P-XBLNR = 'Ref. Document Number'.
W_FINAL_P-DELIMITER_7 = '|'.
W_FINAL_P-BLART = 'Document Type'.
W_FINAL_P-DELIMITER_8 = '|'.
W_FINAL_P-MONAT = 'Fiscal Period'.
W_FINAL_P-DELIMITER_9 = '|'.
W_FINAL_P-DMBTR_P = 'Amount'.
W_FINAL_P-DELIMITER_10 = '|'.
W_FINAL_P-KOSTL = 'Cost Center'.
W_FINAL_P-DELIMITER_11 = '|'.
W_FINAL_P-PRCTR_P = 'Profit Center'.
W_FINAL_P-DELIMITER_12 = '|'.
W_FINAL_P-HKONT_G = 'G/L Account Number'.
W_FINAL_P-DELIMITER_13 = '|'.
W_FINAL_P-DMBTR_G = 'Amount'.
W_FINAL_P-DELIMITER_14 = '|'.
W_FINAL_P-PRCTR_G = 'Profit Center'.
W_FINAL_P-DELIMITER_15 = '|'.
W_FINAL_P-BUZID_G = 'Line Item Id'.
APPEND W_FINAL_P TO I_FINAL_P.
LOOP AT I_FINAL INTO W_FINAL.
W_FINAL_P-BUKRS = W_FINAL-BUKRS.
W_FINAL_P-DELIMITER_1 = '|'.
W_FINAL_P-HKONT_P = W_FINAL-HKONT_P.
W_FINAL_P-DELIMITER_2 = '|'.
W_FINAL_P-GJAHR = W_FINAL-GJAHR.
W_FINAL_P-DELIMITER_3 = '|'.
W_FINAL_P-BELNR = W_FINAL-BELNR.
W_FINAL_P-DELIMITER_4 = '|'.
W_FINAL_P-BUDAT = W_FINAL-BUDAT .
W_FINAL_P-DELIMITER_5 = '|'.
W_FINAL_P-WAERS = W_FINAL-WAERS.
W_FINAL_P-DELIMITER_6 = '|'.
W_FINAL_P-XBLNR = W_FINAL-XBLNR.
W_FINAL_P-DELIMITER_7 = '|'.
W_FINAL_P-BLART = W_FINAL-BLART.
W_FINAL_P-DELIMITER_8 = '|'.
W_FINAL_P-MONAT = W_FINAL-MONAT.
W_FINAL_P-DELIMITER_9 = '|'.
W_FINAL_P-DMBTR_P = W_FINAL-DMBTR_P.
W_FINAL_P-DELIMITER_10 = '|'.
W_FINAL_P-KOSTL = W_FINAL-KOSTL.
W_FINAL_P-DELIMITER_11 = '|'.
W_FINAL_P-PRCTR_P = W_FINAL-PRCTR_P.
W_FINAL_P-DELIMITER_12 = '|'.
W_FINAL_P-HKONT_G = W_FINAL-HKONT_G.
W_FINAL_P-DELIMITER_13 = '|'.
W_FINAL_P-DMBTR_G = W_FINAL-DMBTR_G.
W_FINAL_P-DELIMITER_14 = '|'.
W_FINAL_P-PRCTR_G = W_FINAL-PRCTR_G.
W_FINAL_P-DELIMITER_15 = '|'.
W_FINAL_P-BUZID_G = W_FINAL-BUZID_G.
APPEND W_FINAL_P TO I_FINAL_P.
CLEAR : W_FINAL_P, W_FINAL.
ENDLOOP.
ENDIF.
*---Downloading data to file on Presentation Server
CALL FUNCTION 'GUI_DOWNLOAD'
EXPORTING
FILENAME = V_PRESPATH
FILETYPE = 'ASC'
TABLES
DATA_TAB = I_FINAL_P
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.
*-- File can not be opened successfully
IF SY-SUBRC NE 0.
IF SY-BATCH EQ C_FLAG_X. " Stop Processing
MESSAGE E017. " File could not be opened
ELSE.
MESSAGE I017. " File could not be opened
LEAVE LIST-PROCESSING.
ENDIF.
ELSE.
CONCATENATE 'Data Successfully downloaded to the Specified Location' V_PRESPATH INTO MESSAGE SEPARATED BY SPACE.
MESSAGE MESSAGE TYPE 'S'.
ENDIF.
MODIFY SCREEN.
ENDFORM. " sub_download_presserver
*& Form sub_download_appserver
text
FORM SUB_DOWNLOAD_APPSERVER .
DATA: V_FILE TYPE STRING, " String
P_DMBTR TYPE CHAR20,
G_DMBTR TYPE CHAR20,
MESSAGE1 TYPE STRING.
IF I_FINAL[] IS INITIAL.
IF SY-BATCH EQ C_FLAG_X.
*--- File contains no data
MESSAGE E016 .
ELSE.
*--- File contains no data
MESSAGE I016 .
LEAVE LIST-PROCESSING.
ENDIF.
ENDIF.
*--- To Open The file in Application Server
OPEN DATASET V_APPPATH FOR OUTPUT IN TEXT MODE ENCODING DEFAULT.
IF SY-SUBRC NE 0.
*--- Display error message: "Could not open file"
IF SY-BATCH EQ C_FLAG_X.
*--- File contains no data
MESSAGE E016 .
ELSE.
*--- File contains no data
MESSAGE I016 .
LEAVE LIST-PROCESSING.
ENDIF.
ENDIF.
*--- Perform for building the Report header
CONCATENATE
'COMPANY_CODE'
'G/L_ACCOUNT_NUMBER'
'FISCAL_YEAR'
'A/C_DOCUMENT_NUMBER'
'POSTING_DATE'
'CURRENCY'
'REF_DOCUMENT_NUMBER'
'DOCUMENT_TYPE'
'FISCAL_PERIOD'
'AMOUNT'
'COSTCENTER'
'PROFIT_CENTER'
'G/L_ACCOUNT_NUMBER'
'AMOUNT'
'PROFIT_CENTER'
'LINE_ITEM_ID'
INTO V_FILE SEPARATED BY C_DELIMITER.
TRANSFER V_FILE TO V_APPPATH.
*--- Transfer the data to application Server
LOOP AT I_FINAL INTO W_FINAL.
P_DMBTR = W_FINAL-DMBTR_P.
G_DMBTR = W_FINAL-DMBTR_G.
CONCATENATE
W_FINAL-BUKRS
W_FINAL-HKONT_P
W_FINAL-GJAHR
W_FINAL-BELNR
W_FINAL-BUDAT
W_FINAL-WAERS
W_FINAL-XBLNR
W_FINAL-BLART
W_FINAL-MONAT
P_DMBTR
W_FINAL-KOSTL
W_FINAL-PRCTR_P
W_FINAL-HKONT_G
G_DMBTR
W_FINAL-PRCTR_G
W_FINAL-BUZID_G
INTO V_FILE SEPARATED BY C_DELIMITER.
TRANSFER V_FILE TO V_APPPATH.
IF SY-SUBRC NE 0.
Display error message: "Data could not be written at the location"
MESSAGE 'Data could not be written at the location' TYPE 'I'.
EXIT.
ENDIF.
CLEAR V_FILE.
ENDLOOP.
CLOSE DATASET V_APPPATH.
IF SY-SUBRC NE 0.
Display error message: "File could not be closed"
MESSAGE 'File could not be closed' TYPE 'I'.
EXIT.
ELSE.
CONCATENATE 'Data Successfully downloaded to the Specified Location' V_APPPATH INTO MESSAGE1 SEPARATED BY SPACE.
MESSAGE MESSAGE1 TYPE 'S'.
ENDIF.
ENDFORM. " sub_download_appserverHi sneha,
The report seems not belongs to SAP standard, And if would have belonged also, the ABAP community people can help you better, so it's gender suggestion to post this thread to ABAP community may with bit more details?
Best Of Luck!!
Update us to help you more, Reward points to help you better!!
Regards,
Shyamal -
Need to extend header length in Excel file being downloaded by GUI_DOWNLOAD
hello Experts,
I have written a program where the data from DSO is downloaded into Excel File which is being saved on my desktop.
Now, i am facing one problem with the length of header and the values.
For eg:
I have 15 cloumns and i have given description for each column ie header name. This header is being displayed only upto 255 characters. If the total length of all the columns header desc exceeds 255 char, then blank header is displayed further.
Same is the case with the values of the columns.
I am pasting the relevant code.
The code for displaying header and fields is:
Concatenate
'Sales Org'
'Sales Org Desc'
'Sales Dist'
'Sales Dist Desc'
'Sales Rep'
'Sales Rep Desc'
'Customer Number'
'Customer Desc'
'Billing Document'
'AGI Code No'
'AgiCode Desc'
'UCAGI Code No'
'UCAGI Code Desc'
'Design Code'
'CalMonth'
'CalYear'
'Billing Qty'
'ZDIF'
'ZE01'
'ZE13'
Into ls_contents-line SEPARATED BY lc_tab.
APPEND ls_contents TO lt_contents.
CLEAR ls_contents.
Loop at i_t_Table into wa_i_t_t_Table.
concatenate
wa_i_t_t_Table-/BIC/G00000574
wa_i_t_t_Table-salesorg_name
wa_i_t_t_Table-/BIC/G00000514
wa_i_t_t_Table-salesdist_name
wa_i_t_t_Table-/BIC/G00009361
wa_i_t_t_Table-SalesRep_name
wa_i_t_t_Table-/BIC/G00000466
wa_i_t_t_Table-Customer_name
wa_i_t_t_Table-/BIC/G00000464
wa_i_t_t_Table-/BIC/G00000001
wa_i_t_t_Table-agicode_name
wa_i_t_t_Table-/BIC/G00000002
wa_i_t_t_Table-UCagicode_name
wa_i_t_t_Table-/BIC/G00000005
wa_i_t_t_Table-CALMONTH2
wa_i_t_t_Table-CALYEAR
wa_i_t_t_Table-/BIC/G00001108
wa_i_t_t_Table-/BIC/G00021022
wa_i_t_t_Table-/BIC/G00021023
wa_i_t_t_Table-/BIC/G00021024
INTO ls_contents-line SEPARATED BY lc_tab.
*CONCATENATE ls_contents lv_hex1 INTO ls_contents.
APPEND ls_contents TO lt_contents.
CLEAR ls_contents.
ENDLOOP.
CALL FUNCTION 'GUI_DOWNLOAD'
EXPORTING
BIN_FILESIZE =
FILENAME = c_filename
FILETYPE = 'DAT'
APPEND = ' '
WRITE_FIELD_SEPARATOR = ' '
HEADER = '01'
TRUNC_TRAILING_BLANKS = ' '
WRITE_LF = 'X'
COL_SELECT = ' '
COL_SELECT_MASK = ' '
DAT_MODE = ' '
CONFIRM_OVERWRITE = ' '
NO_AUTH_CHECK = ' '
CODEPAGE = ' '
IGNORE_CERR = ABAP_TRUE
REPLACEMENT = '#'
WRITE_BOM = ' '
TRUNC_TRAILING_BLANKS_EOL = 'X'
WK1_N_FORMAT = '0'
WK1_N_SIZE = '20'
WK1_T_FORMAT = '0'
WK1_T_SIZE = '20'
WRITE_LF_AFTER_LAST_LINE = ABAP_TRUE
SHOW_TRANSFER_STATUS = ABAP_TRUE
IMPORTING
FILELENGTH =
TABLES
DATA_TAB = lt_contents
FIELDNAMES =
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.
Note: Gone through SDN where many things are suggested like to use parameter of GUI_DOWNLAOD ie "FIELDNAMES " which is disabled in my SAP version.
Please suggest how to make all the headers and the values of the fields properly.
Would appreciate immediate help.
Thanks in advance.
Regards
Lavanyasolved.
Maybe you are looking for
-
My Macbook pro Early 2008 is randomly slow at starting up and when I am backing up to my time capsule I am receiving the following message 'Time machine could not complete the backup. '' ''The backup disk image ''/Volumes/name time capsule/ my name M
-
Moving ipod library to 3 computers
I have 3 minis using the same computer and now I need to separate them to their own computer. I know I can move the music to a new computer but does this take the music out of the original computer? If so, how can I set up these 3 ipods to their own
-
Command line interface to "code cache" memory pool utilization
I need to monitor the usage of the "code cache" memory pool through a command-line interface, but it doesn't seem to me that the jstat tool is able to give me any information about this particular memory pool. Are there any other tools that is able t
-
BI Presentation Services Authentication Error
Hi, I am at my wits end in trying to solve this issue. I have installed obiee 11g on my laptop and am able to login to the BI Admin Tool and the enterprise manager and also the console. But I have been getting an authentication error when trying to l
-
Performance Comparisons of Coldfusion on Different OS
I was unsuccessful at finding any information on comparing performance and testing of Coldfusion on various platforms. Most of this depends on the JVM, correct? Has anyone done any testing like this to compare Coldfusion on Windows vs. Linux?