on 11-17-2008 1:01 PM
Dear Friends,
For testing i was writing a program which is reading data from a db table and i am attaching its text file to newly created DMS. this below program created the DMS dcoument and shows the attachment but it is not opening it and giving message "File TEST.TXT could not be accessed"
REPORT z_file2.
DATA: fname(40),
w_line TYPE i VALUE 1.
DATA:
BEGIN OF fs_flight,
carrid LIKE sflight-carrid,
connid LIKE sflight-connid,
fldate LIKE sflight-fldate,
END OF fs_flight.
DATA:
t_flight LIKE
TABLE OF
fs_flight.
SELECT-OPTIONS:
s_carrid FOR fs_flight-carrid,
s_connid FOR fs_flight-connid.
fname = 'TEST.TXT'.
SELECT * INTO CORRESPONDING FIELDS OF TABLE t_flight FROM sflight WHERE carrid IN s_carrid AND connid IN s_connid.
IF t_flight IS NOT INITIAL.
OPEN DATASET fname FOR OUTPUT IN TEXT MODE ENCODING DEFAULT.
LOOP AT t_flight INTO fs_flight.
TRANSFER fs_flight TO fname.
ENDLOOP.
IF sy-subrc EQ 0.
WRITE: 'File Opened On Apps Server'.
ELSE.
WRITE: 'File could not be opened'.
ENDIF.
CLOSE DATASET fname.
ENDIF.
DATA: documentdata TYPE bapi_doc_draw2,
documentdatax TYPE bapi_doc_drawx2,
characteristicvalues TYPE bapi_characteristic_values,
classallocations TYPE bapi_class_allocation,
bapiret2 TYPE bapiret2,
ls_longtexts TYPE bapi_doc_text,
file_location TYPE bapi_doc_files2,
lit_file_location TYPE TABLE OF bapi_doc_files2.
DATA: it_classallocations TYPE TABLE OF bapi_class_allocation,
it_characteristicvalues TYPE TABLE OF bapi_characteristic_values,
lit_longtexts TYPE TABLE OF bapi_doc_text,
lv_docno TYPE bapi_doc_aux-docnumber.
documentdata-documenttype = 'ZTS'.
documentdatax-documenttype = 'X'.
documentdata-description = 'lv_name_org' .
documentdatax-description = 'X'.
file_location-wsapplication = 'TXT'.
file_location-docpath = ''.
file_location-docfile = 'TEST.TXT'.
APPEND file_location TO lit_file_location.
CALL FUNCTION 'BAPI_DOCUMENT_CREATE2'
EXPORTING
documentdata = documentdata
HOSTNAME =
DOCBOMCHANGENUMBER =
DOCBOMVALIDFROM =
DOCBOMREVISIONLEVEL =
CAD_MODE = ' '
PF_FTP_DEST = ' '
PF_HTTP_DEST = ' '
IMPORTING
DOCUMENTTYPE =
documentnumber = lv_docno
DOCUMENTPART =
DOCUMENTVERSION =
return = bapiret2
TABLES
CHARACTERISTICVALUES =
CLASSALLOCATIONS =
DOCUMENTDESCRIPTIONS =
OBJECTLINKS =
DOCUMENTSTRUCTURE =
documentfiles = lit_file_location
LONGTEXTS =
COMPONENTS =
.
CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'
EXPORTING
wait = '1'.
regards,
Satyawan
Satyawan,
I think the problem is that you are trying to create the file in the SAP app server and the SAP DMS storage doesn't upload file from the app server in the way you have programmed it.
I would go about it in the following way,
1. Download the contents as a text file using ws_download on to the local.
2. Build reference to this file location and upload using the BAPI FM.
The first part and the last part of your program is ok.
Try this and let me know the results,
Sojan
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Satyawan,
I also urge you to look into the FM documentation of this BAPI and especially the DOCUMENTFILES documentation by going to Goto option in the transaction SE37.
Sojan
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
100 | |
11 | |
11 | |
6 | |
6 | |
5 | |
4 | |
3 | |
3 | |
3 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.