Skip to Content
0

How to create DMS Document using BAPI_DOCUMENT_CREATE2 by providing document number externally ????

May 03, 2017 at 10:13 AM

149

avatar image

Hello Everyone,

I have created bapi for DMS document using the document number providing externally..

and i maintained number range also in transaction DC10.

But whenever i create from se37 it allows me create document and while creating in program it doesn't allow me to create it show error " Document no doesn't lie within external number range " ??

code is as follow:

SPAN { font-family: "Courier New"; font-size: 12pt; color: #000000; background: #FFFFFF; } .L0S31 { font-style: italic; color: #808080; } .L0S32 { color: #3399FF; } .L0S33 { color: #4DA619; } .L0S52 { color: #0000FF; } .L0S55 { color: #800080; } .L0S70 { color: #808080; }


DATA: lv_ver TYPE DOKVR .
* CLEAR: LS_RETURN,ls_doc,lv_ver.

lv_ver = wa_tab-VERSION.


ls_doc-DOCUMENTTYPE = TEXT-001." 'VAP'
ls_doc-DOCUMENTNUMBER = WA_TAB-ref_no.
ls_doc-DOCUMENTVERSION = lv_ver.
ls_doc-DOCUMENTPART = TEXT-002." '000'
LS_DOC-DESCRIPTION = WA_TAB-DOC_NAME.
LS_DOC-USERNAME = SY-UNAME.


CLEAR LT_FILES.
* LT_FILES-ORIGINALTYPE = TEXT-003.
LT_FILES-STORAGECATEGORY = TEXT-004.
LT_FILES-DOCPATH = WA_TAB-PATH.
LT_FILES-DESCRIPTION = WA_TAB-DOC_NAME.

TRANSLATE EXT1 TO UPPER CASE.
CASE EXT1.
WHEN 'PDF'.
LT_FILES-WSAPPLICATION = 'PDF'.
WHEN 'XLS' OR 'XLSX'.
LT_FILES-WSAPPLICATION = 'XLS'.
WHEN 'DOC' OR 'DOCX'.
LT_FILES-WSAPPLICATION = 'WWI'.
WHEN 'TXT'.
LT_FILES-WSAPPLICATION = 'TXT'.
ENDCASE.

APPEND LT_FILES.

CLEAR LT_DRAT.
LT_DRAT-LANGUAGE = .'EN'
LT_DRAT-DESCRIPTION = 'VENDOR DOCUMENTS'.
APPEND LT_DRAT.

CALL FUNCTION 'BAPI_DOCUMENT_CREATE2'
EXPORTING
DOCUMENTDATA = LS_DOC
IMPORTING
DOCUMENTTYPE = lf_doctype
DOCUMENTNUMBER = lf_docnumber
DOCUMENTPART = lf_docpart
DOCUMENTVERSION = LF_DOCVERSION
RETURN = LS_RETURN
TABLES
DOCUMENTDESCRIPTIONS = LT_DRAT
DOCUMENTFILES = LT_FILES
.
IF LS_RETURN-TYPE CA 'EA'.
ROLLBACK WORK.
ELSE.
CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'
EXPORTING
WAIT = 'X'
.

dms
10 |10000 characters needed characters left characters exceeded
* Please Login or Register to Answer, Follow or Comment.

2 Answers

Best Answer
Christoph Hopf
May 03, 2017 at 01:21 PM
0

Hi,

it would be interesting what value you have in "WA_TAB-ref_no", where the parameter lf_docnumber is filled and how the number range is setup. The number range value can be found in transaction SNUM using object DOKUMENT.

Best regards,

Christoph

Show 1 Share
10 |10000 characters needed characters left characters exceeded

thanks for revert and i am developing the screen for vendor approving ,when i save this document then reference number is generated and i am providing this ref no as the dms document number while creating the bapi for the same.

lf_docnumber is not filled . I want this document number for change the DMS document for multiple file upload against same doc number.

Thanks,

dms1.png (26.5 kB)
dms.png (8.8 kB)
0
Christoph Hopf
May 04, 2017 at 05:57 AM
0

Hi again,

but when you not filling the document number field if you call the CREATE2 BAPI then the document number will be generated by the system (internally) based on the internal number range. So if you want to have an external number you have to fill this field.

Best regards,

Christoph

Show 2 Share
10 |10000 characters needed characters left characters exceeded

hello Christoph,

But lf_docnumber is importing parameter for bapi_document_create2 how can i pass this field to fm

and i have passed document number in

ls_doc-DOCUMENTNUMBER = WA_TAB-ref_no

where, ref_no is my external no

0

Hi,

but is there a value in "WA_TAB-ref_no" or not?

Because if you want to assign an external document number, the field DOCUMENTDATA-DOCUMENTNUMBER needs to be filled. Otherwise the number is generated internally.

Best regards,

Christoph

0