BAPI_DOCUMENT_CREATE2 with CHARACTERISTICVALUES
Hello
I'm trying to use the FM BAPI_DOCUMENT_CREATE2 filling the CHARACTERISTICVALUES table but i'm not sucessfull, anybody has an example or others?
The type of the characteristics is 017, values are stored in AUSP table but the characteristic is a date so is stored in a fixing point field named ATFLV (for example the date 20070915 is istored 2,007091500000000E+07)
Here is a sample program, hope it helps
*& Report ZPRUEBAINTERFASEPS
REPORT zpruebainterfaseps.
SELECTION-SCREEN: BEGIN OF BLOCK a1 WITH FRAME.
PARAMETERS: p_docu LIKE draw-doknr.
SELECTION-SCREEN: END OF BLOCK a1.
DATA: gv_documento LIKE draw-doknr,
gv_clase LIKE draw-dokar VALUE 'ZET',
gv_version LIKE draw-dokvr VALUE '00',
gv_part LIKE draw-doktl VALUE '000',
gv_descripcion LIKE drat-dktxt VALUE 'Descripcion de prueba',
gv_return LIKE bapiret2,
gv_ruta LIKE bapi_doc_files2-docfile VALUE 'C:\PRUEBA.XLS'.
DATA: gs_documentdata LIKE bapi_doc_draw2,
gt_characteristicvalues LIKE bapi_characteristic_values OCCURS 0 WITH HEADER LINE,
gt_classallocations LIKE bapi_class_allocation OCCURS 0 WITH HEADER LINE,
gt_documentfiles LIKE bapi_doc_files2 OCCURS 0 WITH HEADER LINE.
AT LINE-SELECTION.
SET PARAMETER ID 'CV1' FIELD p_docu.
SET PARAMETER ID 'CV2' FIELD gv_clase.
CALL TRANSACTION 'CV02N' AND SKIP FIRST SCREEN.
START-OF-SELECTION.
gv_documento = p_docu.
gs_documentdata-documenttype = gv_clase.
gs_documentdata-documentnumber = gv_documento.
gs_documentdata-documentversion = gv_version.
gs_documentdata-documentpart = gv_part.
gs_documentdata-description = gv_descripcion.
gt_characteristicvalues-classtype = '017'.
gt_characteristicvalues-classname = 'ZDMS_DT'.
gt_characteristicvalues-charname = 'ZFEFIPRE'.
gt_characteristicvalues-charvalue = '15092007'.
APPEND gt_characteristicvalues.
gt_classallocations-classtype = '017'.
gt_classallocations-classname = 'ZDMS_DT'.
APPEND gt_classallocations.
gt_documentfiles-wsapplication = 'ZXL'.
gt_documentfiles-docfile = 'C:\PRUEBA.XLS'.
gt_documentfiles-docfile = '/tmp/pruebafondo'.
gt_documentfiles-docpath = 'zficherointerfaseps'.
gt_documentfiles-storagecategory = 'DMS_C1_ST'.
gt_documentfiles-checkedin = 'X'.
APPEND gt_documentfiles.
CALL FUNCTION 'BAPI_DOCUMENT_CREATE2'
EXPORTING
documentdata = gs_documentdata
IMPORTING
return = gv_return
TABLES
characteristicvalues = gt_characteristicvalues
classallocations = gt_classallocations
documentfiles = gt_documentfiles.
IF gv_return-type CA 'AE'.
WRITE gv_return-message.
ELSE.
CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'
EXPORTING
wait = 'X'.
LOOP AT gt_documentfiles.
gt_documentfiles-checkedin = 'X'.
MODIFY gt_documentfiles.
ENDLOOP.
CALL FUNCTION 'BAPI_DOCUMENT_CHECKIN2'
EXPORTING
documenttype = gv_clase
documentnumber = gv_documento
documentpart = gv_part
documentversion = gv_version
HOSTNAME = ' '
STATUSINTERN = ' '
STATUSEXTERN = ' '
STATUSLOG = ' '
REVLEVEL = ' '
AENNR = ' '
PF_HTTP_DEST = ' '
PF_FTP_DEST = ' '
IMPORTING
RETURN =
TABLES
documentfiles = gt_documentfiles
COMPONENTS =
DOCUMENTSTRUCTURE =
CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'
EXPORTING
wait = 'X'.
FORMAT HOTSPOT ON.
WRITE: 'SE HA INTENTADO CREAR EL DOCUMENTO:' , p_docu.
FORMAT HOTSPOT OFF.
ENDIF.
Similar Messages
-
BAPI_DOCUMENT_CREATE2 - DMS upload
Hi,
I using BAPI_DOCUMENT_CREATE2 to upload a document in DMS server.
It is giving me error while uploading ' Error while checking in and storing: C:\file1.pdf '. I am upload files from front end.
I am using the DOCUMENTFILES parameter DOCPATH,DOCFILE and STORAGECATEGORY. I have also given the full file name in header documentdata DOCFILE1.
Regards,
Karthik.kHello,
I have the problem : I want to upload a file on my frontend in the server DMS.
The info record is ok and the file is attached but when i want to display the file PDF i have the error 26 254.
I'm using the BAPI "BAPI_DOCUMENT_CREATE2" with parameters :
documentdata-documenttype = 'ZBE'.
documentdata-documentnumber = 'TEST DMS14'.
documentdata-documentversion = '00'.
documentdata-documentpart = '000'.
documentdata-description = 'Document DMS Besace'.
documentdata-docfile1 = 'C:\test.pdf'.
documentdata-wsapplication1 = 'PDF'.
documentdata-datacarrier1 = 'SAP-SYSTEM'.
Thanks for your help. -
BAPI_DOCUMENT_CREATE2 / CHECKIN2 etc.
Dear fellows,
Does anyone know of a webblog or another site about calling the DMS-BAPIs from .NET Co ? I don't get them to run when checking-in / uploading the file..
These...
Bapi_Document_Checkoutview2 woes
problem with BAPI_DOCUMENT_CHECKOUTVIEW2 and 4.7
...are the only real sources I found about yet...
Could anyone please sum up some details he learned to know while creating the calls? Versions of librfc32.dll, saphttp.exe, etc....
Thanks a lot!
FlorianHello,
I have the problem : I want to upload a file on my frontend in the server DMS.
The info record is ok and the file is attached but when i want to display the file PDF i have the error 26 254.
I'm using the BAPI "BAPI_DOCUMENT_CREATE2" with parameters :
documentdata-documenttype = 'ZBE'.
documentdata-documentnumber = 'TEST DMS14'.
documentdata-documentversion = '00'.
documentdata-documentpart = '000'.
documentdata-description = 'Document DMS Besace'.
documentdata-docfile1 = 'C:\test.pdf'.
documentdata-wsapplication1 = 'PDF'.
documentdata-datacarrier1 = 'SAP-SYSTEM'.
Thanks for your help. -
BAPI_DOCUMENT_CREATE2 fails in Background
Hi everyone,
I wrote an ABAP-report calling BAPI 'BAPI_DOCUMENT_CREATE2'.
This ABAP has to create a document and upload files per FTP into DMS (Checkin)
Works Online fine (cause the BAPI avoids FTP as a GUI is online available) but miserably fails in background:
Message: RFC callback calls are not allowed in the ABAP...
This message comes from a failed call of the FM 'SYSTEM_START_REG_SERVER'
in the FM 'CV120_FTP_START_REG_SERVER' as described in an old thread (Error in Check in of Originals by BAPI In background)
Sample of the BAPI-call:
CALL FUNCTION 'BAPI_DOCUMENT_CREATE2'
EXPORTING
documentdata = documentdata
pf_ftp_dest = 'SAPFTPA'
IMPORTING
documenttype = documenttype
documentnumber = documentnumber
documentpart = documentpart
documentversion = documentversion
return = return
TABLES
documentdescriptions = documentdescriptions
objectlinks = objectlinks
* documentstructure = documentstructure.
* documentfiles = documentfiles
* documentstructure = documentstructure.
documentfiles = documentfiles.
I tried a lot, even in 2 steps (first create the doc per BAPI, second checkin per call of CVAPI_DOC_CHECKIN)
but in everycase, i always get the same problem...
Any help will greatly be appreciated : i daily and manually (ok, even if 1 report launch per day is sufficent) have to upload aprox.
2000 PDFs ...
Thanks in advance for answering...
Edited by: Guillaume Delorme on May 5, 2010 11:08 AMHi everyone,
Due to holidays, i gotta post under another account...
There was a logical mistake in my problem:
-> i thought i had to do the physical checkin of the files while or after the BAPI_DOCUMENT_CREATE2-call.
In my case, the content-server is reachable from the app-server as it's been defined in the AL11.
The content-server is directly defined in table TDWD with complete directorypath as a vault-server (NO DVA-VAULT).
The SAP-FBs do actually handle two cases for file-checkin that can suit my concern::
-> DVA-Vault?->FTP-Connect for filetransfer
-> No DVA-Vault? ->Local GUI-Upload for filetransfer
For background-processing fails always the GUI-Upload -> normal
I don't use any DVA-Vault -> i must do something else.
Solution: Ridiculously easy...
*-> FIRST :Physical Checkin over a stupid TRANSFER DATASET for the file.
*If OK:
*->SECOND: Call of BAPI_DOCUMENT_CREATE2 with reference to the transferred File
* ->Structure BAPI_DOC_DRAW2:
* -> Short Dataname in BAPI_DOC_DRAW2-docfile1
* -> Datacarrier in BAPI_DOC_DRAW2-datacarrier1 (actually the key for the VAULT-server)
* -> App.type in BAPI_DOC_DRAW2-wsapplication1.
* -> Description, Documentype, username, laboratory are must-fields with my customizing too.
* ->Internal Table BAPI_DOC_FILES2:
* -> Short Dataname in BAPI_DOC_FILES2-docfile
* -> Datacarrier in BAPI_DOC_FILES2-storagecategory (actually the key for the VAULT-server)
* -> App.type in BAPI_DOC_FILES2-wsapplication.
* -> no other fields required for this table
* ->(...)
*endif.
Now it runs fine every 5 minutes and i handle about 3000 documents a day...
I give points to Phillip van den Heever who reminded me the AL11-Setting and i mark this topic solved as soon as i can...
Thanks to everyone and greets,
Guillaume Delorme -
Bapi_Document_Create2: Check In Problem
Hi All,
we want to perform Transaction CV01n via FM.
I tried the BAPI_DOCUMENT_CREATE2 to to the Job but i cant find the correct Parameter to Check in Documents into the Archiv.
The Parameters lt_files-storagecategory = 'SAP-System' and lt_files-storagecategory = 'VAULT' are shown but the Archiv is missing.
I found the Destiation Link in Transactin OAC0 (Content repository), it has te Value XY and The Type is ARCHLINK.
Any Ideas on this toppic?
Best Regards
SRHi everyone,
Due to holidays, i gotta post under another account...
There was a logical mistake in my problem:
-> i thought i had to do the physical checkin of the files while or after the BAPI_DOCUMENT_CREATE2-call.
In my case, the content-server is reachable from the app-server as it's been defined in the AL11.
The content-server is directly defined in table TDWD with complete directorypath as a vault-server (NO DVA-VAULT).
The SAP-FBs do actually handle two cases for file-checkin that can suit my concern::
-> DVA-Vault?->FTP-Connect for filetransfer
-> No DVA-Vault? ->Local GUI-Upload for filetransfer
For background-processing fails always the GUI-Upload -> normal
I don't use any DVA-Vault -> i must do something else.
Solution: Ridiculously easy...
*-> FIRST :Physical Checkin over a stupid TRANSFER DATASET for the file.
*If OK:
*->SECOND: Call of BAPI_DOCUMENT_CREATE2 with reference to the transferred File
* ->Structure BAPI_DOC_DRAW2:
* -> Short Dataname in BAPI_DOC_DRAW2-docfile1
* -> Datacarrier in BAPI_DOC_DRAW2-datacarrier1 (actually the key for the VAULT-server)
* -> App.type in BAPI_DOC_DRAW2-wsapplication1.
* -> Description, Documentype, username, laboratory are must-fields with my customizing too.
* ->Internal Table BAPI_DOC_FILES2:
* -> Short Dataname in BAPI_DOC_FILES2-docfile
* -> Datacarrier in BAPI_DOC_FILES2-storagecategory (actually the key for the VAULT-server)
* -> App.type in BAPI_DOC_FILES2-wsapplication.
* -> no other fields required for this table
* ->(...)
*endif.
Now it runs fine every 5 minutes and i handle about 3000 documents a day...
I give points to Phillip van den Heever who reminded me the AL11-Setting and i mark this topic solved as soon as i can...
Thanks to everyone and greets,
Guillaume Delorme -
BAPI_DOCUMENT_CREATE2 problem with copying document-version
Hi experts!
I want to copy Documents from one Sap-System to another via RFC.
So I read the documents in the source-system with 'BAPI_DOCUMENT_GETDETAIL2' via RFC. then I want to insert the documents received in the target-system with BAPI_DOCUMENT_CREATE2.
The result is that from a document all part-documents are been copied, but only one (the first) version of a document-part.
my coding:
... for reading the documents
CALL FUNCTION 'BAPI_DOCUMENT_GETDETAIL2'
DESTINATION p_rfcdst
EXPORTING
documenttype = gs_draw-dokar
documentnumber = gs_draw-doknr
documentpart = gs_draw-doktl
documentversion = gs_draw-dokvr
getobjectlinks = 'X'
getcomponents = 'X'
getstatuslog = 'X'
getlongtexts = 'X'
getactivefiles = 'X'
getdocdescriptions = 'X'
getdocfiles = 'X'
getclassification = 'X'
getstructure = 'X'
getwhereused = 'X'
HOSTNAME = ' '
IMPORTING
documentdata = gs_doc_data
return = gs_return_get
TABLES
objectlinks = gt_obj_links
documentdescriptions = gt_doc_desc
longtexts = gt_long_texts
statuslog = gt_status_log
documentfiles = gt_doc_files
components = gt_comp
characteristicvalues = gt_char_val
classallocations = gt_class_alloc
documentstructure = gt_doc_struc
whereusedlist = gt_where_used.
my coding:
... for creating the documents
CALL FUNCTION 'BAPI_DOCUMENT_CREATE2'
EXPORTING
documentdata = gs_doc_data
IMPORTING
documenttype = gs_create-dokar
documentnumber = gs_create-doknr
documentpart = gs_create-doktl
documentversion = gs_create-dokvr
return = gs_return_create
TABLES
characteristicvalues = gt_char_val
classallocations = gt_class_alloc
documentdescriptions = gt_doc_desc
objectlinks = gt_obj_links
documentstructure = gt_doc_struc
documentfiles = gt_doc_files
longtexts = gt_long_texts
components = gt_comp.
Result:
eg. - Source Document
Document AUF/N4711/xxx/xx
Part Version Status Description
010 00 FR Cond.-010-00
011 00 FR Cond.-011-00
011 01 FR Vers-011-01
011 02 FR Vers-011-02
012 00 FR Cond.-012-00
Target Document
Document AUF/N4711/xxx/xx
Part Version Status Description
010 00 FR Cond.-010-00
011 00 FR Cond.-011-00
012 00 FR Cond.-012-00
Is there only the possibility to create one version of a document with BAPI_DOCUMENT_CREATE2 ?
Thanks in advance for helping me!
FranzHi Avinash,
a
Thanks for the reply.
I am able to create document number in IDES system. I am getting error development system while creating document number with the FM. Configuration settings and the test data are same for both IDES and Dev. system.
What could be the problem and how to rectify it.
Regards
SP Raj -
Create document in Background with BAPI_DOCUMENT_CREATE2
Hi,
how can i create a document with the BAPI_DOCUMENT_CREATE2 in background (not in dialog)?
I want to upload the original from my front-end (Path: C:\test.pdf).
If i use the paramter "pf_http_dest = SAPHTTP", it didn't work.
I don't want to upload the file from the applicationserver (not SAPHTTPA).
I am thankful for any solution?
Thanks in advance.
SebastianThe straight answer is that it doesn't work.
The only workaround I've used befor is having a shared network folder that both your user and the user running the SAP dialog service have access to. This does work, but you could argue it is a little messy.
That windows user is probably named SAPservice<SID> on the OS level (or equivalent for Linux).
Windows Operating System User Settings in an SAP System - SAP NetWeaver Security Guide - SAP Library
Share a folder and grant both acess. Afterwards you can run the bapi with the network path.
espen -
Bapi_document_create2 does not work correctly with attached file.
Hi all.
I hava a problem with bapi. I programmed below.
ls_docdata-documenttype = 'BBS'.
ls_docdata-description = 'JJW test'.
ls_file-documenttype = 'BBS'.
ls_file-ORIGINALTYPE = 1.
ls_file-storagecategory = 'ZSTW_KPRO'.
ls_file-wsapplication = 'TXT'.
ls_file-docfile = entity_filename.
append ls_file to lt_files.
CALL FUNCTION 'BAPI_DOCUMENT_CREATE2'
EXPORTING
documentdata = ls_docdata
PF_FTP_DEST = 'SAPFTP'
PF_HTTP_DEST = 'SAPHTTP'
IMPORTING
documenttype = lv_documenttype
documentnumber = lv_documentnumber
documentpart = lv_documentpart
documentversion = lv_documentversion
return = ls_return
tables
documentfiles = lt_files.
call function 'BAPI_TRANSACTION_COMMIT'.
If I don't attach the file, DIR is created but if attach some files, it does not work. What should I do??
regards.Hi,
You can use the below to attach the file from BSP to SAP. But it doesnt use the BAPI - 'BAPI_DOCUMENT_CREATE2'. It works perfectly for me. Let me know if you have any questions.
Note: This code put the file into SAP Directory "/userapps/master_data/" as well as it upload the file into Transaction WTY since i am using Business object:BUS2222. You may need to modify the Business object if you ahve the one, otherwise you can just put it into SAP DIR.
FUNCTION ZATTACH_CREATE.
*"*"Update function module:
*"*"Local interface:
*" IMPORTING
*" VALUE(FILE) TYPE SAPB-SAPFILES
*" VALUE(STR_FILE_CONTENT) TYPE XSTRING
*" VALUE(OBJECT_KEY) TYPE BAPIBDS01-OBJKEY
DATA: LOGICAL_SYSTEM TYPE BAPIBDS01-LOG_SYSTEM,
CLASSNAME TYPE BAPIBDS01-CLASSNAME,
CLASSTYPE TYPE BAPIBDS01-CLASSTYPE.
DATA: IT_FILES TYPE TABLE OF BAPIFILES,
IT_SIGNATURE TYPE TABLE OF BAPISIGNAT,
FILES TYPE BAPIFILES,
SIGNATURE TYPE BAPISIGNAT.
DATA: I_TOADD TYPE TOADD,
FILENAME_ALL TYPE SAPB-SAPFILES,
FILE_PATH TYPE SAPB-SAPFILES,
FILE_PATH_MEMORY(250) TYPE C, " path für SAP memory
FILE_PATH_LENGTH TYPE I, " length of the file_path
FILE_CONTENT_LENGTH TYPE I, " length of the file_CONTENT
FILE_NAME TYPE SAPB-SAPFILES,
FILE_EXTENSION TYPE TOADD-DOC_TYPE. " file-extension.
DATA: I_FILE_CONTENT TYPE TABLE OF BAPICONTEN.
DATA: WA_FILE_CONTENT TYPE BAPICONTEN,
STRING_CONTENT TYPE STRING,
STRING_CONTENT1 TYPE STRING.
DATA:
I_FILES TYPE TABLE OF BAPIFILES ,
I_SIGNATURE TYPE TABLE OF BAPISIGNAT ,
I_COMPONENTS TYPE TABLE OF BAPICOMPON ,
COMPONENTS TYPE BAPICOMPON ,
I_PROPERTIES TYPE TABLE OF SDOKPROPTY ,
I_PROPERTIES2 TYPE TABLE OF BAPIPROPER ,
I_PROPERTIES_DEL TYPE TABLE OF BAPIDPROPT ,
MIMETYPE TYPE TOADD-MIMETYPE,
COMPID TYPE BAPICOMPON-COMP_ID, " compid for popup
COMPID_FLAG(1) TYPE C, " compid can't be changed
MODIFY_FLAG(1) TYPE C, " document is modified
ATTRI_FLAG(1) TYPE C, " attri can't be changed
TITLE_FLAG(1) TYPE C, " titel of the popup
CANCEL_FLAG(1) TYPE C, " cancel button Yes/No
BUTTON_TEXT(10) TYPE C,
INFO_TEXT(100) TYPE C,
VERSION_NR TYPE BDN_CON-DOC_VER_NO, " version_nr for popup
VERSION_LANGU2 TYPE T002T-SPTXT, " language field in POPUP
VERSION_LANGU TYPE BDN_CON-LANGU," SPRAS language field
TITLE_TEXT(100) TYPE C, " title of the popup
DESCRIPTION TYPE BDN_CON-DESCRIPT. " descr. for popup
*FILENAME_ALL = fileUpload_event->file_name.
* Transfering into SAP File server.
FILE_CONTENT_LENGTH = XSTRLEN( STR_FILE_CONTENT ).
FILENAME_ALL = FILE .
STRING_CONTENT = STR_FILE_CONTENT.
DATA: OUT_LINES TYPE TABLE OF XSTRING.
CALL FUNCTION 'SCMS_XSTRING_TO_BINARY'
EXPORTING
BUFFER = STR_FILE_CONTENT
* APPEND_TO_TABLE = ' '
* IMPORTING
* OUTPUT_LENGTH =
TABLES
BINARY_TAB = I_FILE_CONTENT.
DELETE DATASET '/userapps/master_data/claim1.txt'.
OPEN DATASET '/userapps/master_data/claim1.txt' FOR APPENDING
IN TEXT MODE ENCODING DEFAULT.
* LOOP AT I_FILE_CONTENT INTO WA_FILE_CONTENT.
* TRANSFER STR_FILE_CONTENT TO '/userapps/master_data/claim1.txt'.
TRANSFER STRING_CONTENT TO '/userapps/master_data/claim1.txt'.
* ENDLOOP.
CLOSE DATASET '/userapps/master_data/claim1.txt'.
OPEN DATASET '/userapps/master_data/claim1.txt' FOR INPUT
IN TEXT MODE ENCODING DEFAULT.
READ DATASET '/userapps/master_data/claim1.txt' into STRING_CONTENT1.
* -- split filename -- *
DATA: LENGTH TYPE I.
DATA: PATH2(1200). " LIKE sapb-sapfiles.
DATA: L_FILE(1200),
L_DIR(1200),
L_DELIMITER TYPE C,
L_OFFSET TYPE I,
L_BYTES TYPE I,
L_DELIMITER_OFFSET TYPE I,
L_DELIMITER_BYTES TYPE I,
L_CHAR TYPE C,
L_PREVIOUS_CHAR TYPE C,
L_LAST_CHAR TYPE C.
PATH2 = FILENAME_ALL.
LENGTH = STRLEN( PATH2 ).
L_OFFSET = 0.
WHILE L_OFFSET < LENGTH.
L_LAST_CHAR = L_CHAR. "remember last character
L_BYTES = CHARLEN( PATH2+L_OFFSET ).
L_CHAR = PATH2+L_OFFSET(L_BYTES). "get current character
IF L_CHAR = '/' OR L_CHAR = '' OR L_CHAR = ':'.
IF L_DELIMITER IS INITIAL OR L_DELIMITER = ':'.
"Typically we deal with absolute paths, so the first
"delimiter is best. This allows for UNIX paths with
"'' in the directory or file name
L_DELIMITER = L_CHAR.
ENDIF.
IF L_CHAR = L_DELIMITER.
L_DELIMITER_OFFSET = L_OFFSET.
L_DELIMITER_BYTES = L_BYTES.
"remember character in front of delimiter:
L_PREVIOUS_CHAR = L_LAST_CHAR.
ENDIF.
ENDIF.
L_OFFSET = L_OFFSET + L_BYTES.
ENDWHILE.
IF NOT L_DELIMITER IS INITIAL.
L_OFFSET = L_DELIMITER_OFFSET + L_DELIMITER_BYTES.
L_FILE = PATH2+L_OFFSET.
IF L_PREVIOUS_CHAR = ':' OR L_DELIMITER = ':'.
"path ends with or after drive identifer, include the delimiter
L_DIR = PATH2(L_OFFSET).
ELSEIF NOT L_DELIMITER_OFFSET IS INITIAL.
"do not include a trailing delimiter for compatibility reasons
L_DIR = PATH2(L_DELIMITER_OFFSET).
ELSE.
CLEAR L_DIR.
ENDIF.
ELSE.
L_DIR = SPACE.
L_FILE = PATH2.
ENDIF.
FILE_PATH = L_DIR.
FILE_NAME = L_FILE.
* -- set new file_path to SAP memory -- *
FILE_PATH_LENGTH = STRLEN( FILE_PATH ).
IF FILE_PATH <> SPACE AND FILE_PATH_LENGTH < 250.
FILE_PATH_MEMORY = FILE_PATH.
SET PARAMETER ID 'OAP' FIELD FILE_PATH_MEMORY.
ELSE.
FILE_PATH_MEMORY = SPACE.
SET PARAMETER ID 'OAP' FIELD FILE_PATH_MEMORY.
ENDIF.
* -- data declaration ------------------------------------------------ *
DATA:
SINGLE_C TYPE C.
CLEAR: SINGLE_C.
LENGTH = STRLEN( FILE_NAME ).
IF LENGTH > 0.
WHILE LENGTH > 0.
SINGLE_C = FILE_NAME+LENGTH(1).
IF SINGLE_C CO '.'.
LENGTH = LENGTH + 1.
EXIT.
ELSE.
LENGTH = LENGTH - 1.
ENDIF.
ENDWHILE.
IF LENGTH > 0.
FILE_EXTENSION = FILE_NAME+LENGTH.
ELSE.
FILE_EXTENSION = SPACE.
ENDIF.
ELSE.
FILE_EXTENSION = SPACE.
ENDIF.
IF FILE_EXTENSION <> SPACE.
SET LOCALE LANGUAGE SY-LANGU.
TRANSLATE FILE_EXTENSION TO UPPER CASE. "#EC TRANSLANG
SET LOCALE LANGUAGE SPACE.
ENDIF.
* TR001++
DATA: I_TOADV TYPE TABLE OF TOADV.
DATA: WA_TOADV TYPE TOADV.
DATA: OBJECT TYPE SAEOBJART.
SELECT * FROM TOADV INTO CORRESPONDING FIELDS OF TABLE
I_TOADV WHERE STANDARD = 'X'.
DELETE I_TOADV WHERE AR_OBJECT CS 'BDS' OR AR_OBJECT CS 'ZSEST'.
READ TABLE I_TOADV INTO WA_TOADV WITH KEY DOC_TYPE = FILE_EXTENSION.
* -- get name and description for the document -- *
CLEAR: COMPID,
DESCRIPTION,
VERSION_NR,
MODIFY_FLAG,
COMPID_FLAG,
ATTRI_FLAG,
TITLE_FLAG.
COMPID_FLAG = ' '. " -> compid can't be changed
MODIFY_FLAG = 'S'. " -> popup in save modus
ATTRI_FLAG = 'X'. " -> attri's can be changed
COMPID = FILE_NAME.
VERSION_NR = '00000001'.
VERSION_LANGU2 = SY-LANGU.
TITLE_FLAG = '1'. " -> BDN
* -- get the mimetype of the docuclass -- *
*PERFORM MIMETYPE_GET(OAALL) USING FILE_EXTENSION
* CHANGING I_TOADD.
DATA: I_DOCUMENTCLASS TYPE TOADD-DOC_TYPE.
MOVE FILE_EXTENSION TO I_DOCUMENTCLASS.
SET LOCALE LANGUAGE SY-LANGU.
TRANSLATE I_DOCUMENTCLASS TO UPPER CASE. "#EC TRANSLANG
SET LOCALE LANGUAGE SPACE.
SELECT SINGLE * FROM TOADD INTO I_TOADD WHERE
DOC_TYPE EQ I_DOCUMENTCLASS.
IF SY-SUBRC NE 0. " nothing found -> default!
I_TOADD-DOC_TYPE = I_DOCUMENTCLASS.
I_TOADD-MIMETYPE = 'application/x-docType'. "#EC NOTEXT
ENDIF.
MOVE I_TOADD-MIMETYPE TO MIMETYPE.
* -- fill file and signature structure -- *
CLEAR: I_FILES, I_SIGNATURE.
REFRESH : I_FILES, I_SIGNATURE.
DESCRIPTION = FILE_NAME.
FILES-DOC_COUNT = 1.
FILES-DIRECTORY = FILE_PATH.
FILES-FILENAME = FILE_NAME.
FILES-MIMETYPE = MIMETYPE.
APPEND FILES TO I_FILES.
* -- fill components and signature structure -- *
COMPONENTS-DOC_COUNT = 1.
COMPONENTS-COMP_COUNT = 1.
COMPONENTS-MIMETYPE = MIMETYPE.
COMPONENTS-COMP_ID = FILE_NAME.
APPEND COMPONENTS TO I_COMPONENTS.
SIGNATURE-DOC_COUNT = 1.
SIGNATURE-PROP_NAME = 'BDS_DOCUMENTCLASS'.
SIGNATURE-PROP_VALUE = FILE_EXTENSION.
APPEND SIGNATURE TO I_SIGNATURE.
SIGNATURE-PROP_NAME = 'BDS_CONTREP'.
*IF BDS_DOCTYPE_LIST-CONTREP = SPACE.
SIGNATURE-PROP_VALUE = ' '. "#EC NOTEXT
*ELSE.
* I_SIGNATURE-PROP_VALUE = BDS_DOCTYPE_LIST-CONTREP.
*ENDIF.
APPEND SIGNATURE TO I_SIGNATURE.
SIGNATURE-PROP_NAME = 'BDS_DOCUMENTTYPE'.
SIGNATURE-PROP_VALUE = WA_TOADV-AR_OBJECT. "'ZSRVCXLS'."TR001+
APPEND SIGNATURE TO I_SIGNATURE.
SIGNATURE-PROP_NAME = 'DESCRIPTION'.
SIGNATURE-PROP_VALUE = DESCRIPTION.
APPEND SIGNATURE TO I_SIGNATURE.
SIGNATURE-PROP_NAME = 'LANGUAGE'.
SIGNATURE-PROP_VALUE = VERSION_LANGU.
APPEND SIGNATURE TO I_SIGNATURE.
CALL FUNCTION 'BDS_BUSINESSDOCUMENT_CREA_TAB'
EXPORTING
* LOGICAL_SYSTEM =
CLASSNAME = 'BUS2222' "classname_select
CLASSTYPE = 'BO'" classtype_select
CLIENT = SY-MANDT
OBJECT_KEY = OBJECT_KEY
BINARY_FLAG = 'X'
* IMPORTING
* OBJECT_KEY =
TABLES
SIGNATURE = I_SIGNATURE
COMPONENTS = I_COMPONENTS
CONTENT = I_FILE_CONTENT
* ASCII_CONTENT =
* EXCEPTIONS
* NOTHING_FOUND = 1
* PARAMETER_ERROR = 2
* NOT_ALLOWED = 3
* ERROR_KPRO = 4
* INTERNAL_ERROR = 5
* NOT_AUTHORIZED = 6
* OTHERS = 7
COMMIT WORK AND WAIT.
IF SY-SUBRC <> 0.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
* WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
ENDFUNCTION.
Message was edited by:
Raja T -
Problem with BAPI_DOCUMENT_CREATE2
HI,
I am creating document using FM BAPI_DOCUMENT_CREATE2. In IDES, i am able to create with new status. But i am getting an error message as 'The status set requires a previous status'.
What could be the problem? is it due to the additional pacthes? The patches version for development is 17 and for ides it is 10. If that is the issue, how to create document in Dev. server.
Thanks in advance
Regards,
SP RajHi Avinash,
a
Thanks for the reply.
I am able to create document number in IDES system. I am getting error development system while creating document number with the FM. Configuration settings and the test data are same for both IDES and Dev. system.
What could be the problem and how to rectify it.
Regards
SP Raj -
Issue with BAPI_DOCUMENT_CREATE2
Hi experts,
I have been facing an issue calling BAPI_DOCUMENT_CREATE2 from a third-party legacy based onto Java.
I am calling it to create a document based on DIR(Document Info Record) in DMS(Document Management System)
Before I do this I must have defined a document type like G08 within document class (TC:CL02).
This is an G08 document type example
[http://www.esnips.com/doc/27a59a9c-ce41-4873-ac94-079e5d1d1213/Configuracion047]
I created general characteristis when I defined this document class.
[http://www.esnips.com/doc/e7e0b379-0d8b-46ac-82d2-3a390ce662ce/Configuracion046]
I m not quite sure what is the structure I must to fill in the characteristics of my document type
e.g. For filling document type is the following:
DOCUMENTDATA.DOCUMENTTYPE
e.g. For BUSINESSPROCESS [http://www.esnips.com/doc/e7e0b379-0d8b-46ac-82d2-3a390ce662ce/Configuracion046]
I dont have a clue.
Thanks in advance of any info you can provide mehere was my problem:
it_clas-classtype = '017'.
it_clas-classname = 'DMS_FAB'.
append it_clas.
<b> it_ausp-classname = 'DMS_FAB'.
it_ausp-classtype = '017'.</b>
it_ausp-charname = 'DMS_TIPODOCFAB'.
it_ausp-charvalue = it_cdp_c-zztipodoc.
APPEND it_ausp. -
Want to create Document new version with BAPI_DOCUMENT_create2
Hi,
I want to create a document with new version with the help of existing document in DMS. In my development of module pool
i can add new file and also i can create new version of existing document. all this i can do from my Z-development.
When on initial time when there is no dicument exist BAPI creating new document correctly with attached files. also i am able to create a new version of that document if i am excuting applicatin from my PC. if this appication run from another system to generate new version BAPI is giving me Error.
i am passing below data in DOCUMENTFILES(table parameter of BAPI) for existing File which is available already in older version.
DOC_HEADER-DOCUMENTTYPE = 'ABC'
DOC_HEADER-DOCUMENTNUMBER = '456'
DOC_HEADER-DOCUMENTVERSION = '00'
DOC_HEADER-DOCUMENTPART = '000'
FWA_DOCFILE-STORAGECATEGORY = 'ZDMS'.
FWA_DOCFILE-WSAPPLICATION = PFX_EXT.
FWA_DOCFILE-DOCPATH = F_FILEPATH.
FWA_DOCFILE-CHECKEDIN = ''.
FWA_DOCFILE-ACTIVE_VERSION = 'X'.
FWA_DOCFILE-DOCUMENTTYPE = WA_COMDOC-DOKAR.
FWA_DOCFILE-DOCUMENTNUMBER = WA_COMDOC-DOCNR.
FWA_DOCFILE-DOCUMENTPART = WA_COMDOC-DOKTL.
FWA_DOCFILE-DOCUMENTVERSION = WA_COMDOC-DOKVR.
FWA_DOCFILE-APPLICATION_ID = WA_DOCFILE-APPLICATION_ID.
FWA_DOCFILE-FILE_ID = WA_DOCFILE-FILE_ID .
FWA_DOCFILE-DOCFILE = F_FILENAME.
APPEND FWA_DOCFILE TO FIT_DOCFILE.
I am passing all those data which i am getting from BAPI_DOCUMENT_GETDETAIL2 for existing attached file. Need help.use BAPI_DOCUMENT_CREATENEWVRS2 ..
-
Using BAPI_DOCUMENT_CREATE2 to create a document and checkin to VAULT
In a development we are using the function module BAPI_DOCUMENT_CREATE2
to create a document and check in the original file into the R/3 storage
system in one go (see subroutine below).
However, we got the requirement to use a Vault ("Tresor") as the storage
backend. Unfortunatly, just setting the documentfiles-storagecategory element to 'VAULT' results in 3 things:
- the document gets created OK
- the original file does NOT get checked in
- the error message "Original 1 wurde bereits eingecheckt und abgelegt" (...has already been checked in)
So please advise how to use the BAPI modules to achieve the checkin into
a Vault storage.
Could this have something to do with the undocumented documentfiles-originaltype element? What does this have to be set instead of the '1', thats working with SAP-SYSTEM storage?
*& Form l_create_doc_and_save
* text
* -->P_LG_IOTAB text
* <--P_YRAD_DOCFIELDSIOT text
*AP 001 ins
FORM l_create_doc_and_save
TABLES x_iotab STRUCTURE ccihs_am07iot
CHANGING x_yrad_docfields STRUCTURE yrad_docfieldsiot.
* create a new document in DMS with data from x_yrad_docfieldsiot
* and set the new document in x_iotab
DATA: l_files_tab LIKE bapi_doc_files2 OCCURS 0,
l_drat_tab LIKE bapi_doc_drat OCCURS 0.
DATA: l_docdata_wa LIKE bapi_doc_draw2,
l_files_wa LIKE bapi_doc_files2,
l_drat_wa LIKE bapi_doc_drat,
l_return_wa LIKE bapiret2.
DATA: l_doctype LIKE bapi_doc_draw2-documenttype,
l_docnumber LIKE bapi_doc_draw2-documentnumber,
l_docpart LIKE bapi_doc_draw2-documentpart,
l_docversion LIKE bapi_doc_draw2-documentversion.
*fill document data
CLEAR l_docdata_wa.
l_docdata_wa-documenttype = x_yrad_docfields-dokar.
l_docdata_wa-statusintern = x_yrad_docfields-statusintern.
* l_docdata_wa-documentnumber = x_yrad_docfields-doknr.
CLEAR l_files_wa.
* l_files_wa-storagecategory = lc_database. " 'SAP-SYSTEM'
l_files_wa-storagecategory = x_yrad_docfields-storagecategory.
l_files_wa-docfile = x_yrad_docfields-docpath.
l_files_wa-originaltype = '1'. " <--
l_files_wa-wsapplication = x_yrad_docfields-wsapplication.
APPEND l_files_wa TO l_files_tab.
CLEAR l_drat_wa.
l_drat_wa-language = lc_d. " 'DE'
l_drat_wa-description = x_yrad_docfields-description_de.
APPEND l_drat_wa TO l_drat_tab.
CLEAR l_drat_wa.
l_drat_wa-language = lc_e. " 'EN'
l_drat_wa-description = x_yrad_docfields-description_en.
APPEND l_drat_wa TO l_drat_tab.
CALL FUNCTION 'BAPI_DOCUMENT_CREATE2'
EXPORTING
documentdata = l_docdata_wa
* HOSTNAME =
* DOCBOMCHANGENUMBER =
* DOCBOMVALIDFROM =
* DOCBOMREVISIONLEVEL =
IMPORTING
documenttype = l_doctype
documentnumber = l_docnumber
documentpart = l_docpart
documentversion = l_docversion
return = l_return_wa
TABLES
* CHARACTERISTICVALUES =
* CLASSALLOCATIONS =
documentdescriptions = l_drat_tab
* OBJECTLINKS =
* DOCUMENTSTRUCTURE =
documentfiles = l_files_tab
* LONGTEXTS =
* COMPONENTS =
* error occured?
IF l_return_wa-type CA 'EA'.
ROLLBACK WORK.
MESSAGE ID '26' TYPE 'I' NUMBER '000'
WITH l_return_wa-message.
ELSE.
COMMIT WORK.
CLEAR x_iotab.
x_iotab-zzdokar = l_doctype.
x_iotab-zzdoknr = l_docnumber.
x_iotab-zzdokvr = l_docversion.
x_iotab-zzdoktl = l_docpart.
x_iotab-linemod = ic_linemode-insert.
IF sy-langu = lc_d.
x_iotab-zzdktxt = x_yrad_docfields-description_de.
ELSEIF sy-langu = lc_e.
x_iotab-zzdktxt = x_yrad_docfields-description_en.
ELSE.
x_iotab-zzdktxt = x_yrad_docfields-description_de.
ENDIF.
APPEND x_iotab.
CALL FUNCTION 'YRAD_LB34_SAVE_PEND_SET'
EXPORTING
i_flg_save_pend = true.
CLEAR x_yrad_docfields.
ENDIF.
ENDFORM. " l_create_doc_and_saveHi Frank,
Did you manage to figure out what the problem was?
Thank you.
Regards,
Bruno -
Bapi_document_create2 problem
Hi,
i face with a problem while using the bapi bapi_document_create2.
it adds the file path like '
Dogan\Main\Standards\0010415--P.pdf'
but i cannot open the file in cv02n.
And also it adds the material master elements but the description is not seen and when looked at with cv02n for material master, it asks me to 'Do you want to delete the object links? ', why i get this error?
The file is not on desktop, it is in another server and its path like that:
Dogan\Main\Standards\0010415--P.pdf'
Here is my sample code(i am trying to make it run):
(itabb is the internal table that i upload the file, tab-delimeted txt file.)
data:
lt_drad like standard table of BAPI_DOC_DRAD with header line,
data like BAPI_DOC_DRAW2,
dd like standard table of BAPI_DOC_DRAT with header line,
dfiles like standard table of BAPI_DOC_FILES2 with header line,
return like BAPIRET2.
clear:lt_drad,lt_drad[],data,dd,dfiles,dfiles[].
LOOP AT itabb.
CLEAR lt_drad.
lt_drad-objecttype = 'MARA'.
lt_drad-objectkey = itabb-matnr.
APPEND lt_drad.
data-DOCUMENTTYPE = itabb-dokar.
data-DOCUMENTNUMBER = itabb-doknr.
data-DOCUMENTVERSION = itabb-dokvr.
data-DOCUMENTPART = itabb-doktl.
data-DESCRIPTION = itabb-dktxt.
data-WSAPPLICATION1 = itabb-dappl.
data-DOCFILE2 = itabb-filep.
data-DATACARRIER2 = itabb-dttrg.
data-username = itabb-dwnam.
data-LABORATORY = itabb-labor.
dfiles-storagecategory = 'SAP-SYSTEM'.
dfiles-docfile = itabb-filep.
dfiles-wsapplication = itabb-dappl.
APPEND dfiles.
ENDLOOP.
sort:dfiles.
delete adjacent duplicates from dfiles.
data: dtype like BAPI_DOC_AUX-DOCTYPE,
dnumber like BAPI_DOC_AUX-DOCNUMBER.
CALL FUNCTION 'BAPI_DOCUMENT_CREATE2'
EXPORTING
DOCUMENTDATA = data
HOSTNAME =
DOCBOMCHANGENUMBER =
DOCBOMVALIDFROM =
DOCBOMREVISIONLEVEL =
CAD_MODE = ' '
PF_FTP_DEST = ' '
PF_HTTP_DEST = ' '
DEFAULTCLASS = 'X'
IMPORTING
DOCUMENTTYPE = dtype
DOCUMENTNUMBER = dnumber
DOCUMENTPART =
DOCUMENTVERSION =
RETURN = return
TABLES
CHARACTERISTICVALUES =
CLASSALLOCATIONS =
DOCUMENTDESCRIPTIONS = dd
OBJECTLINKS = lt_drad
DOCUMENTSTRUCTURE =
DOCUMENTFILES = dfiles
LONGTEXTS =
COMPONENTS =
CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'
EXPORTING
wait = 'X'.
endform.Hai....
As per the source code, i have checked there is no issue with that but check entry for
Dogan\Main\Standards\0010415--P.pdf' "
remove this line
data-DOCFILE2 = itabb-filep.
if required remove data-DATACARRIER2 = itabb-dttrg
add this line
dfiles-docfile = '
Dogan\Main\Standards\0010415--P.pdf'
if this not works, just revert me back.
Cheers
KHS -
BAPI_DOCUMENT_SETSTATUS after BAPI_DOCUMENT_CREATE2
Hi Guys,
I am trying to create a DMS document with BAPI_DOCUMENT_CREATE2, and then change the document status using BAPI_DOCUMENT_SETSTATUS but I get the error 'Document XXXXX does not exist' when I remove the BAPI_TRANSACTION_COMMIT after BAPI_DOCUMENT_CREATE2 and if I put it back I ge tthe error 'Document currently locked by USERNAME'. The document is being created successfully, but the change status is not working. Check out the following code:
CALL FUNCTION 'BAPI_DOCUMENT_ENQUEUE'
EXPORTING
DOCUMENTTYPE = lf_doctype
DOCUMENTNUMBER = lf_docnumber
DOCUMENTPART = lf_docpart
DOCUMENTVERSION = lf_docversion
* IMPORTING
* RETURN =
CALL FUNCTION 'BAPI_DOCUMENT_CREATE2'
EXPORTING
DOCUMENTDATA = ls_doc
* HOSTNAME =
* DOCBOMCHANGENUMBER =
* DOCBOMVALIDFROM =
* DOCBOMREVISIONLEVEL =
* CAD_MODE = ' '
* PF_FTP_DEST = ' '
* PF_HTTP_DEST = ' '
* DEFAULTCLASS = 'X'
IMPORTING
DOCUMENTTYPE = lf_doctype
DOCUMENTNUMBER = lf_docnumber
DOCUMENTPART = lf_docpart
DOCUMENTVERSION = lf_docversion
RETURN = ls_return
TABLES
CHARACTERISTICVALUES = lt_char
* CLASSALLOCATIONS =
DOCUMENTDESCRIPTIONS = lt_drat
* OBJECTLINKS = lt_drad
* DOCUMENTSTRUCTURE =
DOCUMENTFILES = lt_files
* LONGTEXTS =
* COMPONENTS =
IF ls_return-type CA 'EA'.
ROLLBACK WORK.
MESSAGE ID '26' TYPE 'I' NUMBER '000'
WITH ls_return-message.
ELSE.
CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'
* EXPORTING
* WAIT =
* IMPORTING
* RETURN =
ENDIF.
CALL FUNCTION 'BAPI_DOCUMENT_DEQUEUE'
EXPORTING
DOCUMENTTYPE = lf_doctype
DOCUMENTNUMBER = lf_docnumber
DOCUMENTPART = lf_docpart
DOCUMENTVERSION = lf_docversion
* IMPORTING
* RETURN =
CALL FUNCTION 'BAPI_DOCUMENT_ENQUEUE'
EXPORTING
DOCUMENTTYPE = lf_doctype
DOCUMENTNUMBER = lf_docnumber
DOCUMENTPART = lf_docpart
DOCUMENTVERSION = lf_docversion
* IMPORTING
* RETURN =
lf_statusextern = 'IW'.
lf_statusintern = 'IW'.
CALL FUNCTION 'BAPI_DOCUMENT_SETSTATUS'
EXPORTING
documenttype = lf_doctype
documentnumber = lf_docnumber
documentpart = lf_docpart
documentversion = lf_docversion
statusextern = lf_statusextern
statusintern = lf_statusintern
* statuslog = lf_statuslog
IMPORTING
return = lss_return.
IF lss_return-type CA 'EA'.
ROLLBACK WORK.
MESSAGE ID '26' TYPE 'I' NUMBER '000'
WITH lss_return-message.
ELSE.
CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'
* EXPORTING
* WAIT =
* IMPORTING
* RETURN =
ENDIF.
CALL FUNCTION 'BAPI_DOCUMENT_DEQUEUE'
EXPORTING
DOCUMENTTYPE = lf_doctype
DOCUMENTNUMBER = lf_docnumber
DOCUMENTPART = lf_docpart
DOCUMENTVERSION = lf_docversion
* IMPORTING
* RETURN =
Your assistance will be greatly appreciated.Hi,
After creation of Document via 'BAPI_DOCUMENT_CREATE2'
call FM
CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'
EXPORTING
WAIT = 'X' .
try to debug before going on with status change FM and check if the document is getting created or not i.e lf_docnumber
also, i would suggest that instead of going for separate FM " BAPI_DOCUMENT_SETSTATUS" u can set the status in FM
BAPI_DOCUMENT_CREATE2.
the import parameter "DOCUMENTDATA" has fields as STATUSEXTERN and STATUSINTERN. where u can pass the status values 'IW' etc.
Please let me know in case of any issues.
Regards,
Ravi Aswani -
BAPI_DOCUMENT_CREATE2 in Web Dynpro ABAP
Hi Friends,
I want to upload PDF file from my System and get it stored in content server Using WEB DYNPRO APPLICATION. I tried using it by calling the FM but its not uploading the file in the server.
Can i know the steps involved in uploading the file. I also created a custom Function Module and called this FM in WEB DYNPRO.
*"*"Local Interface:
*" IMPORTING
*" VALUE(DOCUMENTDATA) LIKE BAPI_DOC_DRAW2 STRUCTURE
*" BAPI_DOC_DRAW2
*" VALUE(BIN_CONTENT) TYPE XSTRING
*" EXPORTING
*" VALUE(DOCUMENTTYPE) LIKE BAPI_DOC_AUX-DOCTYPE
*" VALUE(DOCUMENTNUMBER) LIKE BAPI_DOC_AUX-DOCNUMBER
*" VALUE(DOCUMENTPART) LIKE BAPI_DOC_AUX-DOCPART
*" VALUE(DOCUMENTVERSION) LIKE BAPI_DOC_AUX-DOCVERSION
*" VALUE(RETURN) LIKE BAPIRET2 STRUCTURE BAPIRET2
*" TABLES
*" CHARACTERISTICVALUES STRUCTURE BAPI_CHARACTERISTIC_VALUES
*" OPTIONAL
*" CLASSALLOCATIONS STRUCTURE BAPI_CLASS_ALLOCATION OPTIONAL
*" DOCUMENTDESCRIPTIONS STRUCTURE BAPI_DOC_DRAT OPTIONAL
*" OBJECTLINKS STRUCTURE BAPI_DOC_DRAD OPTIONAL
*" DOCUMENTSTRUCTURE STRUCTURE BAPI_DOC_STRUCTURE OPTIONAL
*" DOCUMENTFILES STRUCTURE BAPI_DOC_FILES2 OPTIONAL
*" LONGTEXTS STRUCTURE BAPI_DOC_TEXT OPTIONAL
*" COMPONENTS STRUCTURE BAPI_DOC_COMP OPTIONAL
*..... Document data
data: ls_doc like bapi_doc_files2.
**..... Bapi return structure
data: ls_return like bapiret2.
**.... Originals that are checked in at the same time
data: lt_files like bapi_doc_files2 occurs 0 with header line.
data: tstampl like tzonref-tstampl, tstampl_c(21) type c,
file_name type localfile, msg(80) type c.
constants path_name type localfile value '/tmp/'.
constants log type localfile value '/tmp/logFO.txt'.
*Create document
describe table documentfiles lines sy-tfill.
if sy-tfill > 0.
clear ls_doc.
clear lt_files.
loop at documentfiles into ls_doc from 1 to 1.
open dataset log for output in text mode encoding default.
transfer ls_doc-wsapplication to log.
transfer ls_doc-description to log.
get time stamp field tstampl.
unpack tstampl to tstampl_c.
clear file_name.
concatenate path_name '/' sy-repid '_' 'ATT' tstampl_c '.' ls_doc-wsapplication into file_name.
condense file_name no-gaps.
transfer file_name to log.
open dataset file_name for output in binary mode message msg.
if sy-subrc = 0.
message a899(zz) with file_name msg 'SY-SUBRC:' sy-subrc.
endif.
transfer bin_content to file_name.
close dataset file_name.
transfer 'move data to lt_files' to log.
move:documentdata-documenttype to lt_files-documenttype,
documentdata-documentpart to lt_files-documentpart,
documentdata-documentversion to lt_files-documentversion,
ls_doc-description to lt_files-description,
'1' to lt_files-originaltype,
'Z_TEST_SAP' to lt_files-storagecategory,
ls_doc-wsapplication to lt_files-wsapplication,
file_name to lt_files-docfile,
'X' to lt_files-checkedin.
translate lt_files-wsapplication to upper case.
append lt_files.
** CLEAR ls_return.
transfer 'call BAPI_DOCUMENT_CREATE2' to log.
call function 'BAPI_DOCUMENT_CREATE2'
exporting
documentdata = documentdata
pf_http_dest = 'SAPHTTPA'
importing
documentnumber = documentnumber
documenttype = documenttype
documentversion = documentversion
documentpart = documentpart
return = return
tables
objectlinks = objectlinks
documentfiles = lt_files
exceptions
others = 1.
close dataset log.
endloop.
endif.
endfunction.
But i am getting short Dump stating File /tmp/logFO.txt is not open.
Can anyone help me with this issue..
Regards,
SantoshHello,
I'm facing the same issue, could you please tell me how did you solve your problem.
Thanks in advance for your help.
Maybe you are looking for
-
Prepare statement to insert a row that contains Blob column. Which way is correct?
When we make prepare statement to insert a row that contains Blob column. Which way is correct? And what is the difference? Does anyone know? 1. Preparestatement.setBlob(parameter number, blob type object) 2. Preparestatement.setBlob(param
-
Have a problem with table views
Hello there. I try to explain the problem. We have a viewset and some table views in it. Screeenshot: We scroll down to necessary table view. Screenshot: If we change a page on any table view or reveal list on this. It may take little time, but after
-
Why do my recurring calender entries keep getting deleted?
Good Morning People, I've got a user who can't create a recurring calendar entry (set to recur everyday) without the entry being deleted automatically a few seconds later, i've tried various things, managed settings, reboot the device, added the prof
-
Where is Java DB in JDK 6?
The Java DB documentation seems to tell us only that it's now in JDK 6. The JDK 6 documentation seems to tell us only that JDK 6 "co-bundles" Java DB. If the documentation answers my question, the answer is not easy to find. Attempting to follow the
-
All images appear in negative or x-ray
Hi I'm not sure what happened but everything(photos, internet, itunes...) in my display appears like a photo negative. Just as if you were to use the x-ray feature in photo booth for everything. I've tried the cplor sync utility and changing the disp