Default file path on application server ?
Can you tell me what is the file path of the file 'dataset' in the below code? I think it is stored in application server but not sure of the path. Is there any default path for such things?
Thank you very much!
report Z_test_BDC1
no standard page heading line-size 255.
include bdcrecx1.
parameters: dataset(132) lower case.
DO NOT CHANGE - the generated data section - DO NOT CHANGE ***
If it is nessesary to change the data section use the rules:
1.) Each definition of a field exists of two lines
2.) The first line shows exactly the comment
'* data element: ' followed with the data element
which describes the field.
If you don't have a data element use the
comment without a data element name
3.) The second line shows the fieldname of the
structure, the fieldname must consist of
a fieldname and optional the character '_' and
three numbers and the field length in brackets
4.) Each field must be type C.
Generated data section with specific formatting - DO NOT CHANGE ***
data: begin of record,
data element: KUN16
KUNNR_001(016),
data element: KTOKD
KTOKD_002(004),
data element: NAME1_GP
NAME1_003(035),
data element: SORTL
SORTL_004(010),
data element: ORT01_GP
ORT01_005(035),
data element: LAND1_GP
LAND1_006(003),
data element: SPRAS
SPRAS_007(002),
data element: PSTLZ
PSTLZ_008(010),
data element: LZONE
LZONE_009(010),
end of record.
End generated data section ***
start-of-selection.
perform open_dataset using dataset.
perform open_group.
do.
read dataset dataset into record.
if sy-subrc <> 0. exit. endif.
perform bdc_dynpro using 'SAPMF02D' '0107'.
perform bdc_field using 'BDC_CURSOR'
'RF02D-KTOKD'.
perform bdc_field using 'BDC_OKCODE'
'/00'.
perform bdc_field using 'RF02D-KUNNR'
record-KUNNR_001.
perform bdc_field using 'RF02D-KTOKD'
record-KTOKD_002.
perform bdc_dynpro using 'SAPMF02D' '0110'.
perform bdc_field using 'BDC_CURSOR'
'KNA1-SORTL'.
perform bdc_field using 'BDC_OKCODE'
'/00'.
perform bdc_field using 'KNA1-NAME1'
record-NAME1_003.
perform bdc_field using 'KNA1-SORTL'
record-SORTL_004.
perform bdc_field using 'KNA1-ORT01'
record-ORT01_005.
perform bdc_field using 'KNA1-LAND1'
record-LAND1_006.
perform bdc_field using 'KNA1-SPRAS'
record-SPRAS_007.
perform bdc_field using 'KNA1-PSTLZ'
record-PSTLZ_008.
perform bdc_dynpro using 'SAPMF02D' '0120'.
perform bdc_field using 'BDC_CURSOR'
'KNA1-LZONE'.
perform bdc_field using 'BDC_OKCODE'
'=UPDA'.
perform bdc_field using 'KNA1-LZONE'
record-LZONE_009.
perform bdc_transaction using 'VD01'.
enddo.
perform close_group.
perform close_dataset using dataset.
FORM OPEN_DATASET USING P_DATASET.
OPEN DATASET P_DATASET
FOR INPUT IN TEXT MODE
ENCODING DEFAULT.
IF SY-SUBRC <> 0.
WRITE: / TEXT-E00, SY-SUBRC.
STOP.
ENDIF.
ENDFORM.
Thanks Ashish.
Similar Messages
-
Convert file path in application server as link
How can we convert file path in application server as link to send email.
Thanks
SureshYour app server folders have a mappable location on your network, e.g,
server\path\filename. Use an HTML anchor tag and build the link with code. You'd be better off storing files on a file server (write to a mapped location from the app server) and link to there (same process). -
File path for application server file
Hi All,
I have a file 'abc.doc' stored on the application sever.
I want to crate a document using the BAPI_DOCUMENT_CREATE and store this file
What is the file path that I need to pass into the bapi.
Please help
Warm Regards
Sunil Kumar.Hello Sunil
You are right. That's the file path you should specify. It looks like your application server is running on UNIX platform. You can use transaction AL11 to locate your file and specify the file path in normal unix format. If this doesnt work, you can try prefixing your file path with "file:// ".
Cheers
Anand -
Want to know the file path for application server in upload program
Iam doing upload program(i,e)uploading from application server,iam getting run time error while executing the following piece of code
"OPEN DATASET '/usr/sap/SPE/DVEBMGS00/work/ZPSPAR35_PERS_UP.txt' FOR OUTPUT
IN TEXT MODE
ENCODING DEFAULT."
if the above code is wrong can u mention the correct one.hi,
<b>Note: 699267</b>
<b>Symptom</b>
a) When downloading to the application server a short dump occurs with the error 'UC_OBJECTS_NOT_CHARLIKE'.
b) When downloading to a presentation server from an SAP system running on Unicode, only half the data is actually transferred to the downloaded file.
or
*)When downloading from an SAP system running on an application server with an EBCDIC-type code page, an incorrect code '0A' is written for the LINE FEED character
<b>
Pre-requisite</b>
a) The output file is opened 'in text mode' which does not allow to write non-character-like structures to the file via the TRANSFER command.
b) The file is downloaded in the internal representation which uses two bytes per character in a Unicode system. The number of bytes to download is determined from the number of characters in the SAP system, however.
or
*)The code of the LINE FEED character is incorrectly programmed.
<b>
Solution:</b>
You need to put some support packs attached with this note. For that you definitely need to ask YOUR FRIENDS WHO HAVE AN S-USER id at your WORK PLACE.
<b>Note: 879598</b>
<b>Reason and Prerequisites</b>
The file is downloaded in the internal representation which uses two bytes per character in a Unicode system. The number of bytes to download is determined from the number of characters in the SAP system. Hence when the download happens the data has to be converted to the required format.
<b>Solution</b>
Apply the corresponding support package or manually implement the changes described in the correction instructions.
Hope this helps.
Regards
ak.
PS: Reward useful answers with points. -
Various ways to place a File in the Application Server.
Hi all,
What are the various ways to place a file in the application Server.
Please classify them as shown below.
1. Use of ABAP Code.
2. Without the use of ABAP code.
RegardsHi
<b>1. Use of ABAP Code.</b>
by writing code like this
REPORT ZSD_EXCEL_INT_APP.
parameter: file_nm type localfile.
types : begin of it_tab1,
f1(20),
f2(40),
f3(20),
end of it_tab1.
data : it_tab type table of ALSMEX_TABLINE with header line,
file type rlgrap-filename.
data : it_tab2 type it_tab1 occurs 1,
wa_tab2 type it_tab1,
w_message(100) TYPE c.
at selection-screen on value-request for file_nm.
CALL FUNCTION 'KD_GET_FILENAME_ON_F4'
EXPORTING
* PROGRAM_NAME = SYST-REPID
* DYNPRO_NUMBER = SYST-DYNNR
* FIELD_NAME = ' '
STATIC = 'X'
* MASK = ' '
CHANGING
file_name = file_nm
EXCEPTIONS
MASK_TOO_LONG = 1
OTHERS = 2
IF sy-subrc <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
start-of-selection.
refresh it_tab2[].clear wa_tab2.
file = file_nm.
CALL FUNCTION 'ALSM_EXCEL_TO_INTERNAL_TABLE'
EXPORTING
filename = file
i_begin_col = '1'
i_begin_row = '1'
i_end_col = '10'
i_end_row = '35'
tables
intern = it_tab
EXCEPTIONS
INCONSISTENT_PARAMETERS = 1
UPLOAD_OLE = 2
OTHERS = 3
IF sy-subrc <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
loop at it_tab.
case it_tab-col.
when '002'.
wa_tab2-f1 = it_tab-value.
when '004'.
wa_tab2-f2 = it_tab-value.
when '008'.
wa_tab2-f3 = it_tab-value.
endcase.
at end of row.
append wa_tab2 to it_tab2.
clear wa_tab2.
endat.
endloop.
data : p_file TYPE rlgrap-filename value 'TEST3.txt'.
OPEN DATASET p_file FOR OUTPUT IN TEXT MODE ENCODING DEFAULT.
*--- Display error messages if any.
IF sy-subrc NE 0.
MESSAGE e001(zsd_mes).
EXIT.
ELSE.
*---Data is downloaded to the application server file path
LOOP AT it_tab2 INTO wa_tab2.
TRANSFER wa_tab2 TO p_file.
ENDLOOP.
ENDIF.
*--Close the Application server file (Mandatory).
CLOSE DATASET p_file.
loop at it_tab2 into wa_tab2.
write : / wa_tab2-f1,wa_tab2-f2,wa_tab2-f3.
endloop.
Here is a pseudo code for what you are looking for-
OPEN DATASET P_FLPTH FOR OUTPUT IN TEXT MODE ENCODING DEFAULT.
IF SY-SUBRC eq 0.
LOOP AT LT_TAB INTO LS_TAB.
TRANSFER LS_TAB TO P_FLPTH.
ENDLOOP.
CLOSE DATASET P_FLPTH.
if sy-batch = 'X'.
write:/ 'File uploaded successfully'.
else.
message sXXX with 'File uploaded successfully'.
endif.
Else.
if sy-batch = 'X'.
write:/ 'Error in File upload'.
else.
message sxxx with 'Error in File upload'.
endif.
LEAVE PROGRAM.
ENDIF.
<b>2. Without the use of ABAP code.</b>
CG3Y -
Appl to Presentation server
<b>Reward if useful</b> -
Create a Document with an original file stored on application server
Hello,
I start with document managment system : i am able to create new document (CV01N) manually, add a local file and check-in this file.
Now we need to store file which are stored on the SAP Application Server.
Firstly, in the GUI of transaction CV01N, i don't know how to browse file on application server. All files i can't attach as original, are files i can access from my computer.
Is it possible to access also on application server files ?
Moreover, i have to define function module which have to
- Create a document (DMS)
- Attach an orginial file which is stored on application server
- Check-in the file
This function module will be called from a web application
I define this kind of function and run it correctly with a local file (stored on my computer) : i call BAPI "BAPI_DOCUMENT_CREATE2" and "BAPI_DOCUMENT_CHECKIN2"
But i don't how to do with a file stored on application server. I see also note 504692 and try a program like ZZUZTEST_TEST_CHECKIN which use FM CVAPI_DOC_CHECKIN but it return an error Error uploading E:\usr\sap\TD1\DVEBMGS00\data\FACTURE.txt" (this path and file exist on application server and is really the file i want to checkin)
Please could you confirm what i search, is possible or not.
If possible, could help me with some explanations and guidelines and perhaps a sample ?
Thank you very much.
Regards,
Eric
The function used
FUNCTION Z_TEST_CHECKIN.
Checkin the first original of a document info record *
from the application server and/or in the background *
data : w_host like BAPI_DOC_AUX-HOSTNAME.
data: lf_line(255).
data: ls_draw like DRAW,
ls_message_cvapi like messages,
lt_files_cvapi type standard table of CVAPI_DOC_FILE,
lt_files_cvapi_header like CVAPI_DOC_FILE.
data: lt_originals LIKE cvapi_doc_file OCCURS 0 WITH HEADER LINE,
vo_originals LIKE cvapi_doc_file OCCURS 0 WITH HEADER LINE.
ls_draw-dokar = 'ZFT'.
ls_Draw-doknr = '0000000000000004500000032'.
ls_Draw-dokvr = '00'.
ls_Draw-doktl = '000'.
Read Originals contained in the document info record
CALL FUNCTION 'CVAPI_DOC_GETDETAIL'
EXPORTING
pf_batchmode = 'X'
pf_hostname = ' '
pf_dokar = ls_draw-dokar
pf_doknr = ls_draw-doknr
pf_dokvr = ls_draw-dokvr
pf_doktl = ls_draw-doktl
pf_active_files = 'X'
IMPORTING
psx_draw = ls_draw
TABLES
pt_files = vo_originals
EXCEPTIONS
not_found = 1
no_auth = 2
error = 3
OTHERS = 4.
IF sy-subrc <> 0.
WRITE 'Error returned by CVAPI_DOC_GETDETAIL'. "#EC NOTEXT
EXIT.
ENDIF.
Check if we can really access the file from the application server
read table vo_originals index 1.
open dataset vo_originals-filename for input in text mode ENCODING DEFAULT.
if not sy-subrc is initial.
message e500(26) with vo_originals-filename 'not found'.
endif.
read dataset vo_originals-filename into lf_line.
if not sy-subrc is initial.
message e500(26) with vo_originals-filename 'read error'.
endif.
lt_originals = vo_originals.
lt_originals-STORAGE_CAT = 'SAP-SYSTEM'.
append lt_originals.
w_host = sy-host.
CALL FUNCTION 'CVAPI_DOC_CHECKIN'
EXPORTING
PF_DOKAR = ls_draw-dokar
PF_DOKNR = ls_draw-doknr
PF_DOKVR = ls_draw-dokvr
PF_DOKTL = ls_draw-doktl
PS_DOC_STATUS =
PF_FTP_DEST = 'SAPFTPA'
PF_HTTP_DEST = 'SAPHTTPA'
*PF_HOSTNAME = w_host
PS_API_CONTROL =
PF_REPLACE = ' '
PF_CONTENT_PROVIDE = 'SRV'
IMPORTING
PSX_MESSAGE = ls_message_cvapi
TABLES
PT_FILES_X = lt_originals
PT_COMP_X =
PT_CONTENT =
IF ls_message_cvapi-msg_type CA 'EA'.
ROLLBACK WORK.
MESSAGE ID '26' TYPE 'I' NUMBER '000'
WITH ls_message_cvapi-msg_txt.
ELSE.
COMMIT WORK and wait.
ENDIF.
ENDFUNCTION.This is a bit tricky. I spent lots of hours about this .
You have to set PF_HOSTNAME with your name of your AS and gives the path to the file on the server.
You wrote
*PF_HOSTNAME = w_host
But beware: if you have more thän one AS you have to fix one AS for upload or you have to find the servers name of the file. A better way can be to share one folder by each AS.
You also have to decide between HTTP or FTP.
You wrote:
PF_FTP_DEST = 'SAPFTPA'
PF_HTTP_DEST = 'SAPHTTPA'
You must define only one ! Then you have to check your settings in SM59 about working right.
Pls rate, if this was helpful.
Regards,
Markus -
:-) How can we change the default file path for Bank file ( dmee ) ?
Hi All,
We encounter a problem.
Electronic bank file ( created after a F110 run ) are created, in an automatic way to the DIR_TEMP directory. ( On the SAP server )
How can we change the default file path for Bank files ( dmee ) ?
We'd like to specify another path.
Thx for your help.
ErwanHello,
Make sure that you have created the directory in transaction code AL11 with the help of basis consultants.
You can link your PC directory to the application server.
You can maintain the path whether your file needs to get saved in OBPM4 against your DMEE structure example GB_BACS etc.
If you do not maintain any path in OBPM4, then the file gets saved to temporary directory. If you give the directory path name in OBPM4, then the file gets saved to that directory with numbers 0001, 0002, 0003 etc till it reaches 9999 and reset from the beginning.
If you give the path as well as file name as ABCD, then the file gets generated to that directory folder with ABCD0001, ABCD0002, ABCD0003 etc. till it reaches ABCD9999 and reset from the beginning.
Hope this solves your problem.
Regards,
Ravi -
How to see the file at the application server
HI TO ALL SDNERS ,
THIS IS MY CODE WHERE TO CHECK THE DOWNLOADED FILE AT THE APPLICATION SERVER.IN TCODE AL11 I HAVE SEEN THERE IS NO FILE GETTING CREATED.WHEN TRANSFERRING THE SY-SUBRC VALUE IS ZERO.
Program Name : ZME11_BDC.
Title : PURCHASE INFORMATION RECORD LOAD PROGRAM
Program Objective : THIS PROGRAM READS IN THE PURCHASE
INFORMATION FILE. IT CREATES A BDC SESSION TO
USE TO LOAD THE PURCHASE INFORMATION RECORDS
INTO SAP using the ME11 Transaction.
REPORT ZME11_BDC no standard page heading MESSAGE-ID ZHNC line-size 55.
constants declaration
constants: c_x value 'X',
c_sess type apqi-groupid value 'zcustomer',
c_xd01 type tstc-tcode value 'ME11'.
DECLARING VARIABLES
DATA: V_MSG(255),
V_ERREC TYPE I,"NO OF FAILED RECORDS
V_LINES."NO OF RECORDS
FLAG DECLARATIONS
DATA: FG_DATA_EXIST VALUE 'X',"CHECK FOR DATA
FG_SESSION_OPEN VALUE ''.
STRUCTURES AND INTERNAL TABLE DECLARATIONS
TYPES :BEGIN OF TY_PIR,
LIFNR TYPE EINA-LIFNR,
MATNR TYPE EINA-MATNR,
EKORG TYPE EINE-EKORG,
WERKS TYPE EINE-WERKS,
VERKF TYPE EINA-VERKF,"sales person
TELF1 TYPE EINA-TELF1,"telephone
URZLA TYPE EINA-URZLA,"country
REGIO TYPE EINA-REGIO,"region
APLFZ(5),"plan deleivery time
EKGRP TYPE EINE-EKGRP,"purchase group
NORBM(13),
NETPR(13),
END OF TY_PIR.
DATA : IT_PIR TYPE TABLE OF TY_PIR,
WA_PIR LIKE LINE OF IT_PIR.
DATA: BEGIN OF IT_BDCDATA.
INCLUDE STRUCTURE BDCDATA.
DATA END OF IT_BDCDATA.
DATA : BEGIN OF IT_BDCMSG.
INCLUDE STRUCTURE BDCMSGCOLL.
DATA END OF IT_BDCMSG.
SELECTION SCREEN
SELECTION-SCREEN BEGIN OF BLOCK B1 WITH FRAME TITLE TEXT-001.
PARAMETER : FNAME TYPE RLGRAP-FILENAME.
SELECTION-SCREEN END OF BLOCK B1.
AT SELECTION ON VALUE REQUEST
AT SELECTION-SCREEN ON VALUE-REQUEST FOR FNAME.
CALL FUNCTION 'F4_FILENAME'
EXPORTING
PROGRAM_NAME = SYST-CPROG
DYNPRO_NUMBER = SYST-DYNNR
FIELD_NAME = ' '
IMPORTING
FILE_NAME = FNAME.
START OF SELECTION
START-OF-SELECTION.
PERFORM F_GET_DATA USING FNAME
CHANGING IT_PIR.
PERFORM F_GENERATE_DATASET USING FNAME
CHANGING IT_PIR WA_PIR.
*& Form F_GET_DATA
text
-->P_V_FNAME text
<--P_IT_PIR text
FORM F_GET_DATA USING P_FNAME LIKE FNAME
CHANGING P_IT_PIR LIKE IT_PIR.
DATA: LV_FILE TYPE STRING.
LV_FILE = FNAME.
CALL FUNCTION 'GUI_UPLOAD'
EXPORTING
FILENAME = LV_FILE
FILETYPE = 'DAT'
HAS_FIELD_SEPARATOR = 'X'
HEADER_LENGTH = 0
READ_BY_LINE = 'X'
DAT_MODE = ' '
CODEPAGE = ' '
IGNORE_CERR = ABAP_TRUE
REPLACEMENT = '#'
CHECK_BOM = ' '
IMPORTING
FILELENGTH =
HEADER =
TABLES
DATA_TAB = P_IT_PIR
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 ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
IF P_IT_PIR IS INITIAL.
FG_DATA_EXIST = ''.
ENDIF.
ENDFORM. " F_GET_DATA
*& Form F_GENERATE_DATASET
text
-->P_V_FNAME text
<--P_IT_PIR text
FORM F_GENERATE_DATASET USING P_V_FNAME LIKE FNAME
CHANGING P_IT_PIR LIKE IT_PIR
P_WA_PIR LIKE WA_PIR.
MESSAGE I001(ZHNC).
*OPENING FILE AT THE APPLICATION SERVER FOR WRITING
OPEN DATASET FNAME FOR OUTPUT IN TEXT MODE ENCODING DEFAULT.
IF SY-SUBRC EQ 0.
MESSAGE I002(ZHNC).
LOOP AT P_IT_PIR INTO P_WA_PIR.
SPLIT P_WA_PIR AT '*' INTO P_WA_PIR-LIFNR
P_WA_PIR-MATNR
P_WA_PIR-EKORG
P_WA_PIR-WERKS
P_WA_PIR-VERKF
P_WA_PIR-TELF1
P_WA_PIR-URZLA
P_WA_PIR-REGIO
P_WA_PIR-APLFZ
P_WA_PIR-EKGRP
P_WA_PIR-NORBM.
*TRANSFER THE FILE FROM INTERNAL TABLE TO APPLICATION SERVER
MESSAGE I003(ZHNC).
TRANSFER P_WA_PIR TO FNAME.
ENDLOOP.
*CLOSING THE FILE AT THE APPLICATION SERVER
CLOSE DATASET FNAME.
ENDIF.Hello,
I made a similar program. You can have a look at it.
*& Form write_to_app_server
text
--> p1 text
<-- p2 text
FORM write_to_app_server.
To get filename
PERFORM get_filename.
To write into the application server
OPEN DATASET g_filename_with_path FOR OUTPUT IN TEXT MODE.
IF sy-subrc = 0.
LOOP AT <l_table> INTO <l_line>.
TRANSFER <l_line> TO g_filename_with_path.
ENDLOOP.
CLOSE DATASET g_filename_with_path.
ELSE.
CLOSE DATASET g_filename_with_path.
ENDIF.
To send mail
PERFORM send_mail.
ENDFORM. " write_to_app_server
*& Form get_filename
text
--> p1 text
<-- p2 text
FORM get_filename.
DATA : l_log_path TYPE filepath-pathintern
VALUE 'Y28M_DOWNLOADS_BACKGROUND' .
CALL FUNCTION 'FILE_GET_NAME_USING_PATH'
EXPORTING
client = sy-mandt
logical_path = l_log_path
operating_system = sy-opsys
file_name = p_fname
IMPORTING
file_name_with_path = g_filename_with_path
EXCEPTIONS
path_not_found = 1
missing_parameter = 2
operating_system_not_found = 3
file_system_not_found = 4
OTHERS = 5.
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. " get_filename
You may find it useful.
Regards,
Karuna. -
File from the Application server
Hi gurus,
I am working on a scenario where I need to get a file from the application server and for this I need to ask user to enter the location and that too at the selection screen and then I need to read this location using open data set and read data set in my program , once I am done with this I need to do some other validations. so can you please help me out how to achieve this.
Thanks
Rajeev GuptaHi
Declare the selection screen with file as parameter so that the user enter the application server file..
the use the OPEND DATASET as mentioned in below code and process
Refer this:
http://help.sap.com/saphelp_nw04/helpdata/en/fc/eb3ca6358411d1829f0000e829fbfe/frameset.htm
ABAP code for uploading a TAB delimited file into an internal table. See code below for structures.
*& Report ZUPLOADTAB * &----
*& Example of Uploading tab delimited file *
REPORT zuploadtab .
PARAMETERS: p_infile LIKE rlgrap-filename
OBLIGATORY DEFAULT '/usr/sap/'..
DATA: ld_file LIKE rlgrap-filename.
*Internal tabe to store upload data
TYPES: BEGIN OF t_record,
name1 like pa0002-VORNA,
name2 like pa0002-name2,
age type i,
END OF t_record.
DATA: it_record TYPE STANDARD TABLE OF t_record INITIAL SIZE 0,
wa_record TYPE t_record.
*Text version of data table
TYPES: begin of t_uploadtxt,
name1(10) type c,
name2(15) type c,
age(5) type c,
end of t_uploadtxt.
DATA: wa_uploadtxt TYPE t_uploadtxt.
*String value to data in initially.
DATA: wa_string(255) type c.
constants: con_tab TYPE x VALUE '09'.
*If you have Unicode check active in program attributes then you will
*need to declare constants as follows:
*class cl_abap_char_utilities definition load.
*constants:
con_tab type c value cl_abap_char_utilities=>HORIZONTAL_TAB.
*START-OF-SELECTION
START-OF-SELECTION.
ld_file = p_infile.
OPEN DATASET ld_file FOR INPUT IN TEXT MODE ENCODING DEFAULT.
IF sy-subrc NE 0.
ELSE.
DO.
CLEAR: wa_string, wa_uploadtxt.
READ DATASET ld_file INTO wa_string.
IF sy-subrc NE 0.
EXIT.
ELSE.
SPLIT wa_string AT con_tab INTO wa_uploadtxt-name1
wa_uploadtxt-name2
wa_uploadtxt-age.
MOVE-CORRESPONDING wa_uploadtxt TO wa_upload.
APPEND wa_upload TO it_record.
ENDIF.
ENDDO.
CLOSE DATASET ld_file.
ENDIF.
*END-OF-SELECTION
END-OF-SELECTION.
*!! Text data is now contained within the internal table IT_RECORD
Display report data for illustration purposes
loop at it_record into wa_record.
write:/ sy-vline,
(10) wa_record-name1, sy-vline,
(10) wa_record-name2, sy-vline,
(10) wa_record-age, sy-vline.
endloop.
Regards
Anji -
How to set default file path while downloading alv output
Hi,
Can anyone tell me that how to set default file path while downloading the ALV output to system using Local file button on tool bar.
Please look below screenshots:
Kindly help me resolve it.
Thanks in advance.
Regards,
Ashutosh KataraThis information initial value is (maybe) stored in Windows Register (register.exe) at Software\SAP\SAPGUI Front\SAP Frontend Server\Filetransfer -> PathDownload, you can read it thru class CL_GUI_FRONTEND_SERVICES method GET_UPLOAD_DOWNLOAD_PATH and update it thru method REGISTRY_SET_VALUE. (Else there may be some parameter ID to force data, but I'm no longer sure)
Regards,
Raymond -
File upload to application server
hi,
i wanna upload a CSD file into the application server is there any FM to do these.
while the program is executed i wanna check whether it is being executed in the foreground or background,if the report is executed is executed in the background a CSD file has to be generated.
its urgent and surely pionts are granted.1) if it is one time only then u can make use of transaction CG3Y and CG3Z to download/upload fiel frm or to application server.
0r
2) refer this code to donwload/upload file on Aserver
REPORT ZGILL_AS message-id rp .
tables: pa0001,pa0002.
select-options s_pernr for pa0001-pernr no intervals MODIF ID XYZ.
parameters: p_dwnld AS CHECKBOX ,
p_upld AS CHECKBOX DEFAULT 'X'.
parameters: P_DSNI(75) TYPE C MODIF ID ABG DEFAULT
'/usr/local/sapdata/amit.dat' LOWER CASE.
data: begin of itab occurs 0,
pernr(8),
sp1(1) value ',',
werks(4),
sp2(1) value ',',
persg(1),
sp3(1) value ',',
persk(2),
end of itab.
data: s_eof(3).
start-of-selection.
if p_upld = 'X'.
OPEN DATASET P_DSNI FOR OUTPUT IN LEGACY TEXT MODE.
PERFORM FETCH_DATA.
STOP.
elseif p_dwnld = 'X'.
OPEN DATASET P_DSNI FOR INPUT IN LEGACY TEXT MODE.
IF SY-SUBRC NE 0.
MESSAGE E016 WITH
'Error opening seq. file, RC:' SY-SUBRC.
EXIT.
ENDIF.
CLEAR S_EOF.
DO.
PERFORM FETCH_file.
IF S_EOF EQ 'YES'. stop. ENDIF.
ENDDO.
endif.
END-OF-SELECTION.
if itab[] is not initial.
perform print_file1 tables itab.
else.
write:/ 'No records exists'.
endif.
*& Form FETCH_DATA
text
--> p1 text
<-- p2 text
FORM FETCH_DATA .
SELECT * FROM PA0001 WHERE PERNR IN S_PERNR.
MOVE-CORRESPONDING PA0001 TO ITAB.
TRANSFER ITAB TO P_DSNI.
APPEND ITAB.
ENDSELECT.
CLOSE DATASET P_DSNI.
ENDFORM. " FETCH_DATA
*& Form FETCH_file
text
--> p1 text
<-- p2 text
FORM FETCH_file .
READ DATASET P_DSNI INTO itab.
append itab.
clear itab.
IF SY-SUBRC NE 0.
S_EOF = 'YES'. EXIT.
ENDIF.
ENDFORM. " FETCH_file
*& Form print_file1
text
-->P_ITAB text
FORM print_file1 tables P_ITAB structure itab .
write:/2 'EmpNo',
14 'Personnel Area',
34 'Emp Group',
47 'Emp SubGroup'.
skip 1.
loop at p_itab.
write:2 p_itab-pernr,
14 p_itab-werks,
34 p_itab-persg,
47 p_itab-persk.
skip 1.
endloop.
ENDFORM. " print_file1
3) for ur third requirement make use of sy-batch field. -
File transfer into application server
Hi folks.
I need to retrieve header records from table MCHB and RESB and transfer it into file.
Again for the corresponding header record, i need to transfer item records retrived from table MKOL and LFA1 as well.
One file each is to be create per plant.
But,i am not able to get item data into file.
My coding....
LOOP AT i_mchb INTO wa_mchb.
l_clabs = wa_mchb-clabs.
SHIFT l_clabs LEFT DELETING LEADING space.
Summarize requirement quantity
LOOP AT i_resb INTO wa_resb.
wa_sum-charg = wa_resb-charg.
wa_sum-bdmng = wa_resb-bdmng.
COLLECT wa_sum INTO i_sum.
SORT i_sum BY charg.
ENDLOOP.
READ TABLE i_sum INTO wa_sum WITH KEY charg = wa_mchb-charg.
IF sy-subrc EQ 0.
l_bdmng = wa_sum-bdmng.
SHIFT l_bdmng LEFT DELETING LEADING space.
ENDIF.
Calculation on Available quantity
l_avqty = l_bdmng - l_clabs.
SHIFT l_avqty LEFT DELETING LEADING space.
AT NEW werks.
*Creation of file
PERFORM sub_create_file.
Open File on the application server for processing
OPEN DATASET g_file_name FOR OUTPUT IN TEXT MODE
ENCODING DEFAULT.
IF sy-subrc NE 0.
*Display error message
MESSAGE i055 WITH g_file_name.
" Error in opening file
LEAVE LIST-PROCESSING.
ENDIF.
ENDAT.
Transfering data to file
CONCATENATE c_header "Header indentification
wa_mchb-matnr " Material number
wa_mchb-werks " Plant
wa_mchb-lgort " Storage location
wa_mchb-charg " Batch number
l_clabs " Valuated stock-unrestricted use
l_bdmng " Requirement quantity
l_avqty " Avalable quantity.
INTO l_record.
TRANSFER l_record TO g_file_name.
CLEAR: l_clabs,
l_bdmng,
l_avqty,
l_record.
READ TABLE i_mkol INTO wa_mkol WITH KEY matnr = wa_mchb-matnr
werks = wa_mchb-werks
lgort = wa_mchb-lgort
charg = wa_mchb-charg
BINARY SEARCH.
IF sy-subrc EQ 0.
l_tabix = sy-tabix.
LOOP AT i_mkol INTO wa_mkol FROM l_tabix.
*Population of consignment stock-unrestricted use
l_slabs = wa_mkol-slabs.
SHIFT l_slabs LEFT DELETING LEADING space.
READ TABLE i_lfa1 INTO wa_lfa1 WITH KEY lifnr = wa_mkol-lifnr.
sy-subrc check not done
CONCATENATE c_item " Item identification
l_slabs
" Consignment stock-unrestricted use
wa_mkol-lifnr " Vendor account number
wa_lfa1-name1 " Vendor name
INTO l_record.
TRANSFER l_record TO g_file_name.
CLEAR: l_slabs,
l_record.
ENDLOOP.
ENDIF.
AT END OF werks.
Close File
CLOSE DATASET g_file_name.
CLEAR g_file_name.
ENDAT.
ENDLOOP.Hi,
Yes thats correct. When using AT NEW. The field in internal table after the WERKS field will have ASTERSIK .
So before AT NEW. Assign the work area to another work area. Eg.
WA_mchb1 = wa_mchb.
Later on i.e. After ENDAT use everywhere WA_MCHB1 and not not WA_MCHB.
This will solve the problem.
wa_sum-charg = wa_resb-charg.
wa_sum-bdmng = wa_resb-bdmng.
COLLECT wa_sum INTO i_sum.
SORT i_sum BY charg.
ENDLOOP.
READ TABLE i_sum INTO wa_sum WITH KEY charg = wa_mchb-charg.
IF sy-subrc EQ 0.
l_bdmng = wa_sum-bdmng.
SHIFT l_bdmng LEFT DELETING LEADING space.
ENDIF.
Calculation on Available quantity
l_avqty = l_bdmng - l_clabs.
SHIFT l_avqty LEFT DELETING LEADING space.
<b>clear wa_mchb_new.</b>
<b>wa_mchb_new = wa_mchb.</b>
AT NEW werks.
*Creation of file
PERFORM sub_create_file.
Open File on the application server for processing
OPEN DATASET g_file_name FOR OUTPUT IN TEXT MODE
ENCODING DEFAULT.
IF sy-subrc NE 0.
*Display error message
MESSAGE i055 WITH g_file_name.
" Error in opening file
LEAVE LIST-PROCESSING.
ENDIF.
ENDAT.
Transfering data to file
CONCATENATE c_header "Header indentification
<b>wa_mchb_new-matnr " Material number
wa_mchb_new-werks " Plant
wa_mchb_new-lgort " Storage location
wa_mchb_new-charg " Batch number</b>l_clabs " Valuated stock-unrestricted use
l_bdmng " Requirement quantity
l_avqty " Avalable quantity.
INTO l_record.
TRANSFER l_record TO g_file_name.
CLEAR: l_clabs,
l_bdmng,
l_avqty,
l_record.
READ TABLE i_mkol INTO wa_mkol WITH KEY matnr = <b>wa_mchb_new-matnr
werks = wa_mchb_new-werks
lgort = wa_mchb_new-lgort
charg = wa_mchb_new-charg</b>BINARY SEARCH.
IF sy-subrc EQ 0.
l_tabix = sy-tabix.
LOOP AT i_mkol INTO wa_mkol FROM l_tabix.
*Population of consignment stock-unrestricted use
l_slabs = wa_mkol-slabs.
SHIFT l_slabs LEFT DELETING LEADING space.
READ TABLE i_lfa1 INTO wa_lfa1 WITH KEY lifnr = wa_mkol-lifnr.
sy-subrc check not done
CONCATENATE c_item " Item identification
l_slabs
" Consignment stock-unrestricted use
wa_mkol-lifnr " Vendor account number
wa_lfa1-name1 " Vendor name
INTO l_record.
TRANSFER l_record TO g_file_name.
CLEAR: l_slabs,
l_record.
ENDLOOP.
ENDIF.
AT END OF werks.
Close File
CLOSE DATASET g_file_name.
CLEAR g_file_name.
ENDAT.
ENDLOOP.
Best regards,
Prashant
PS : Please reward all helpful answers
Message was edited by: Prashant Patil
Message was edited by: Prashant Patil -
How to get creation date of a file created in application server?
Dear experts ,
I have some txt files in a particular path in application server .Suppose path is - \\PMICHSAPLA30\INTERFACE\\BCD\CO\OTC\SALES_RPT\test.txt.
I want to fetch the creation date of this txt file - test.txt . I tried with fm - ADS2KIPUPL_GET_FILE_ATTRIBUTES , but this will give proper out put.
I need to get file creation date. If today I am creating file - abc.txt, so according to this file I should get today's date as creation date.
Please suggest me.BEGIN OF ty_file,
line(400) TYPE c, "File names
END OF ty_file,
This is the structure declaration.
l_v_unixcom would be ls -l \\PMICHSAPLA30\INTERFACE\\BCD\CO\OTC\SALES_RPT\test.txt
now call
CALL 'SYSTEM' ID 'COMMAND' FIELD l_v_unixcom
ID 'TAB' FIELD i_file[].
and see contents of i_file[] it should have the details, post results so we can help further -
Missing CRLF in file created on application server
Hello,
We have a requisite to create a file on the Application Server (AS/400) with CRLF at the end of every record. The records are stored in this structure:
- OUTPUT: CHAR655, text to export;
- LENGTH: NUMC4, length of the record (text to export).
To create the file I have the following code:
open dataset lv_filename
for output in text mode
encoding default
with windows linefeed.
loop at pt_output into ls_output.
try.
clear lv_length.
lv_length = ls_output-length.
transfer ls_output-output to lv_filename
length lv_length.
catch cx_root into gv_oref.
* TODO
endtry.
endloop.
I have two problems:
1º When I open the file in Notepad++ the records should have 500 caracters (lv_length = 500), but it has 502;
2º Only LF appears, not CRLF.
Can anyone help me please?
Regards.Hello,
Strangest thing, when I test it with 255 characters it works fine (CR+LF):
clear lv_string.
ls_output-output+254(1) = cl_abap_char_utilities=>cr_lf.
lv_string = ls_output-output+0(255).
transfer lv_string to lv_filename
length 255.
When I try with 256 characters it doesn't work, at the end of each record I can only find LF:
clear lv_string.
ls_output-output+255(1) = cl_abap_char_utilities=>cr_lf.
lv_string = ls_output-output+0(256).
transfer lv_string to lv_filename
length 256.
Don't understand why...
Regards. -
Renaming a file on the application server
Hi all,
I create a file on the Application server which I want to rename means a program.
I would like to add the system stamptime at the time the program is running.
sample:
original name:
file.csv
final name:
file_20060626123000.csv
does somebody have an ABAP program to do that ? other ideas?
Thanks in advance,
FedeXThanks for the answers,
I do not what I doing wrong in my sample....
I am using this logical path and logical file in an InfoSpoke..
and I get the error:
"could not open file on application server"
My definitions are:
Logical PATH : Z_PATH_TEST
Syntax Group ->UNIX
<P=DIR_HOME>/<FILENAME>
( I am sure DIR_HOME is set correcty on SAP Directories)
Logical FILE NAME : Z_NAME_TEST
Physical Name :File1_<DATE>.csv
Data Format : ASC
Logical Path: Z_PATH_TEST
What could be wrong here?... Thanks again
FedeX
Maybe you are looking for
-
IPod touch + iTunes = Not recognizing software
I ordered an iPod touch a few days ao and when it arrived today, I naturally attempted to sync it to iTunes. However, the moment I plugged it into the USB port, iTunes popped up with an error-type warning stating 'This iPod cannot be used because the
-
(For Each) component in OSB
I am trying to use "For-Each" component to loop through the bulk message to be de-bulked and publish individual messages from the loop. However the loop does not execute multiple times. It goes through the for-each component only once. The bulk messa
-
Since last Friday, Type tool is VERY slow in InDesign CS6 8.0.1
Since last Friday, any time I try to switch to the Type tool or using the Type tool try to switch from one text box to another I get the spinning wheel icon and the Control Panel goes blank for 30 to 60 seconds. Double-clicking acts like single-click
-
wat is the correct syntax for open cursor?do anyone provide sample code for it?
-
We have three authors, who will be developing help on three different machines. How many Robohelp Server licenses do we need to purchase? Do we need just one, or one for each machine (3 in total)?