Thursday, July 19, 2007

Store Document / File to SAP

To store document / image in SAP, we can use Business Document Navigator.
To go to the Business Document Navigator, choose Office -> Business Documents -> Documents -> Find (transaction code : OAOR).

In the upper part of the screen, the relevant documents, sorted by document type (the document types in turn belong to specified application objects) are displayed in the tree. The lower left part of the screen contains tab pages with the functions Detailed display, Document information (version string), Keywords and Storing. On the right-hand side of the screen, you can display a selected document in-place.

A bundled document structured by Class Name, Class Type and object Key. We can add additional attributes for document, including key word, title, description.

To save and get file programmatically, here are the codes.

I split them into two program, store document and get document. Program to get and display document can be found in next post.
Program to store document:

* Store document in BDN

* -- connection table and the internal structure of the ITAB
DATA: BEGIN OF i_bds_conn OCCURS 10. " ITAB for the actual
INCLUDE STRUCTURE bdn_con. " document
DATA: objecttext LIKE toasp-objecttext,
objecttext2 LIKE toasd-objecttext,
objecttext3 LIKE toasr-objecttext,
ntext LIKE tojtt-ntext,
END OF i_bds_conn.
DATA: BEGIN OF bds_doctype_list OCCURS 10,
mandt TYPE mandt,
classname LIKE bapibds01-classname,
contrep LIKE i_bds_conn-contrep,
docuclass LIKE i_bds_conn-docuclass,
docuclass_text LIKE toasd-objecttext,
doc_type LIKE i_bds_conn-doc_type,
doc_type_text LIKE toasp-objecttext,
appl_type LIKE toadd-appl_type,
appl_type_text(50) TYPE c,
standard LIKE toadv-standard,
check_box LIKE toadv-standard,
END OF bds_doctype_list.
DATA: file_extension LIKE toadd-doc_type, " file-extension
i_files LIKE bapifiles OCCURS 1 WITH HEADER LINE,
i_signature LIKE bapisignat OCCURS 1 WITH HEADER LINE,
logical_system LIKE bds_conn00-log_system.

PARAMETERS: p_class LIKE bdn_con-classname OBLIGATORY,
p_objct LIKE bdn_con-objkey OBLIGATORY,
p_descr LIKE bdn_con-descript OBLIGATORY.


PERFORM create_doc_via_file.

* create a new document via file
FORM create_doc_via_file.
* -- data declaration ------------------------------------------------ *
DATA: classname_select LIKE bdn_con-classname,
classtype_select LIKE bdn_con-classtype,
objkey_select LIKE bdn_con-objkey,
mask(20) TYPE c,
answer TYPE c,
mimetype LIKE toadd-mimetype,
i_toadd LIKE toadd,
filename_all LIKE sapb-sapfiles,
file_path LIKE sapb-sapfiles,
file_path_memory(250) TYPE c, " path für SAP memory
file_path_length TYPE i, " length of the file_path
file_name LIKE sapb-sapfiles.

classname_select = p_class.
classtype_select = 'OT'.
objkey_select = p_objct.

IF sy-subrc <> 0. " no file_path found.
file_path = space.

CONCATENATE ',*.' '*' ',*.' '*' '.' INTO mask.
def_path = file_path
mask = mask
mode = 'O'
title = 'Select File to upload'
filename = filename_all
inv_winsys = 01
no_batch = 02
selection_cancel = 03
selection_error = 04.

IF sy-subrc = 3.
MESSAGE s012(sbds). " cancel file selection
ELSEIF sy-subrc <> 0 AND sy-subrc <> 3.
MESSAGE e011(sbds). " error during file selection

* -- split filename -- *
PERFORM split_path(oaall) USING filename_all file_path file_name.

* -- 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.
file_path_memory = space.
SET PARAMETER ID 'OAP' FIELD file_path_memory.

* -- check documentclass -- *
PERFORM get_file_extension USING file_name

* -- check file extension -- *
IF file_extension = space.
* -> if no docuclass is found from the document
* -> default docuclass from the doctype!
file_extension = bds_doctype_list-docuclass.

* -- get the mimetype of the docuclass -- *
PERFORM mimetype_get(oaall) USING file_extension
CHANGING i_toadd.
MOVE i_toadd-mimetype TO mimetype.

* -- fill file and signature structure -- *
CLEAR: i_files, i_signature.
REFRESH : i_files, i_signature.

i_files-doc_count = 1.
i_files-directory = file_path.
i_files-filename = file_name.
i_files-mimetype = mimetype.
APPEND i_files.

i_signature-doc_count = 1.
i_signature-prop_name = 'BDS_DOCUMENTCLASS'.
i_signature-prop_value = file_extension.
APPEND i_signature.
i_signature-prop_name = 'BDS_CONTREP'.
IF bds_doctype_list-contrep = space.
i_signature-prop_value = ' '. "#EC NOTEXT
i_signature-prop_value = bds_doctype_list-contrep.
APPEND i_signature.
i_signature-prop_name = 'BDS_DOCUMENTTYPE'.
i_signature-prop_value = bds_doctype_list-doc_type.
APPEND i_signature.
i_signature-prop_name = 'DESCRIPTION'.
i_signature-prop_value = p_descr.
APPEND i_signature.
i_signature-prop_name = 'LANGUAGE'.
i_signature-prop_value = sy-langu.
APPEND i_signature.

* -- create new document via KPro -- *
logical_system = logical_system
classname = classname_select
classtype = classtype_select
client = sy-mandt
object_key = objkey_select
files = i_files
signature = i_signature
internal_error = 1

WRITE:/ 'sy-subrc:',sy-subrc.

* try to get the extension of the uploaded file
FORM get_file_extension USING file_name file_extension.
* -- data declaration ------------------------------------------------ *
DATA: length TYPE i,
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.
length = length - 1.
IF length > 0.
file_extension = file_name+length.
file_extension = space.
file_extension = space.

IF file_extension <> space.



marge said...

Hi sir!
I am trying to run your program...How exactly do you know what to enter for the class name and object key? Do I need to create an application object first?

abap-gallery said...

Hi Marge,
When you are using transaction OAOR to store document manually, first you have to maintain table class in tcode SBDSV1. But if you use this program, you can enter antything for class name and object key without maintaining class.
To avoid confusion with SAP object I sugget you to use Z as prefix for class name and use document no as object key to make it easier to read / find.
For example, if you want to use it to store supporting document for sales order (table VBAK), use this :
classname: ZVBAK
object key:000XX (order number)

naved said...

Nice piece of code.

Is there a limitation on Number of zClasses I can create. I am planning to create one zclass and one zobjkey (1-1 relationship) for each record/document. These are not SAP std documents. They are created for every record. There will be about 1,000 records. Can I create 1,000 zclasses?


alionzo said...

Hi Naved,
No limitation, you can create 1000 classes. But, I suggest to create one class for one transaction to make it easier to maintain and better performance.

Anonymous said...

Good Day!
THis is out of your topic but maybe you could help me. Im developing a tool from excel vba with connection to sap. I already know how to connect (GUI).
But my problem is that I don't know the object names to point with. ex. Session.FindByID("wnd[0]/usr/?????") if Im gonna make use of the command box for instance.

alionzo said...

wow.. I never heard this technique before, can you share to me where to find the information on using how to use Session.FindID ?
We usually using BAPI / Remote Function Module to connect to SAP from VBA by using wdtfuncs.ocx .

sandeep said...

hi Sir!

i want to show the photo on the module pool screen which is to be fetched from the PC and will be stored in database with every record. please suggest me how can i do so.....

Sandeep Chauhan

alionzo said...

Hi Sandeep,

To figure out how SAP open program in SAP subscreen, open program LBDS_TOOLSF01, create breakpoint in routine "display_selected_document".

Then, goto TCode OAOR. Open image already uploaded, it will halt at break point created before.

SAP using object CL_GUI_HTML_VIEWER to open image in SAP screen.

Sorry I can give you the detail, but may be you can use google to search on term "CL_GUI_HTML_VIEWER"

Hope it help

Anonymous said...

i want to capture the screen shot of a SAP output into presentation server (any given path).How will that be possible.

Kind Regards,

Anonymous said...

Hi alionzo,

ur code is really helpful...
But By default document store in C:\Documents and Settings\abap1sap\SapWorkDir\
Can we change the path of storing document?

SAP Handbook said...

This is indeed useful. Pls. help me, i am not able to transport the documents uploaded in OAOR transaction code.
I have uploaded as
class name: ZALERT
Class type: OT
Object key: ZALERT

Thanks and Regards,
Ravi Kajaria.

Leviana said...

This application is to hard for me to use, I prefer a simple at that allow me to find blog related to Buy Generic Viagra fast.

VISHWAS said...

Hi ,
for saving file against employee.
i m following the steps as mention such as TC:SBDSV1,here i mention=>Class name:ZEMPCV,Class type:OT,DocuClass:BDS_LOC1,BDS_POC1,BDS_REC1,Object Name:ZEMPCV(i just mention Object name without ccreating it).after that i run program as mention 'ZAALGAL0002.i mention CLASS:ZEMPCV
OBJCT:ZEMPCV and descr:xyz.But i wil get output with sy-subrc = 1 . so pls guide me how to save file against employee.
thanks in advance

Anonymous said...

is it possible to store a document into the business document navigator from outside of sap, such as a email or a group of scanned files?

seventyros said...

For a Excellent Online Resource for SAP EP and SAP Web Dynpro ABAP, Visit Learn SAP Online

Anonymous said...

This is Gold Men, Thanks. I like to know how configure an external repository for the documents, if anyone have information about this matter please post-it

Thanks in advance

Juan Camilo

$HIV@ said...

Hi sir,

I have uploaded 2 images under same object-id in OAOR.. how to display the second image in the screen... i used the add_picture method of cl_dd_document .. but how to use index that,..

mani said...

Iam really satisfy by your information.
It's well-written, to the point, and relative to what I do.
I like it very much for giving information on
SAP ABAP Online Training


yektek training said...

Thanks for this post sravani

kits online said...

very nice article.Thanks for sharing the post..!
Ruby On Rails Online Training

Shri Veera said...

Thank you for sharing very informatics and useful post about very useful info.... Turbo-IVP (Invoice Validation Portal) and Turbo eSigner

QuickBooks Payroll Support Phone Number said...

QuickBooks Payroll Support Phone Number management quite definitely easier for accounting professionals. There are so many individuals who are giving positive feedback if they process payroll either QB desktop and online options.

steffan said...

QuickBooks Premier really is easy to make use of but errors may usually pop up during the time of installation, during the time of taking backup, while upgrading your software to your latest version etc. The support team at QuickBooks Help & Support is trained by well experienced experts that are making our customer care executives quite robust and resilient.

steffan said...

If you need the help or even the information about it, our company has arrived now to do business with you with complete guidance combined with demo. Connect to us anytime anywhere. Only just contact us at Quickbooks Payroll Support Number . Our experts professional have provided a lot of the required and resolve all type of issues related to payroll.

xpert said...

QuickBooks Support Phone Number was created to meet your every accounting needs and requirement with a great ease. This software grows along with your business and perfectly adapts with changing business environment. Everbody knows there are always two sides to a coin and QuickBooks isn't any different. This software also throws some errors in the long run. Sometimes it becomes rather difficult to understand this is with this error code or message. If that's the case you should call our QuickBooks Support to own in touch with our technical experts in order to search for the fix of error instantly.

xpert said...

In today’s scenario individuals have got really busy inside their lives and work. They want to grow and learn as many new things as they possibly can. This drive has initiated a feeling of awareness amongst individuals and thus they find approaches to invent alternatives for daily tasks. If you are a small business owner, you need to be aware of the fact that Payroll calculation does demands large amount of time and man force. Then came into existence QuickBooks Payroll and QuickBooks Tech Support team.

steffan said...

Quickbooks Support Number serving a wide range of users daily , quite possible you are going to hand up or need to wait for few years to connect aided by the Help Desk team . Relating to statics released by the Bing & Google search insights significantly more than 50,000 folks searching the net to find the Quickbooks tech support team Phone number on a regular basis and more than 2,000 quarries related to Quickbooks issues and errors .

QuickBooks Payroll Support said...

With exceptional features, QuickBooks Customer Support Number helps all of the forms of businesses with generating accounting reports, entries for almost any sale, transactions pertaining to banking, etc., with a lot of ease. And along side support for QuickBooks, it is less difficult to handle most of the tools of QuickBooks in a hassle-free manner.

QuickBooks Payroll Support Phone Number said...

QuickBooks Enterprise Support contact number is assisted by an organization this is certainly totally dependable. It is a favorite proven fact that QuickBooks Enterprise Support Phone Number has had about plenty of improvement

QuickBooks Payroll Support said...

QuickBooks Customer Support Number total package to create you clear of Financial accounting and back office worries any time to make sure you concentrate on your own expert area and yield potential development in business.

kevin32 said...

Our QuickBooks Enterprise Tech Support Number might have no difficulty in delivering the proper guidance which help with any issues and errors that users may have with QB Enterprise version.

jameswill11 said...

you should additionally get guidance and QuickBooks Enterprise Support Phone Number for the code that square measure obtainable 24/7. If for those who run into any QuickBooks errors or problems or would really like any facilitate, you’ll dial the direct line variety to achieve the QuickBooks specialists.

kevin32 said...

QuickBooks Tech Support Number Usa software package is developed in such a manner that it will provide you with the best account management reference to this era. However, you might face the matter along with your QuickBooks software and start looking for the solution.

kevin32 said...

Therefore we have designed a especially dedicated team of certified professionals at QuickBooks Tech Support Number that are in a position to understanding your issues and errors in minimum time along with the absolute most convenient way.

accountingwizards said...

Make Contact With Us. Consult a professional through live chat. Our QuickBooks customer care executives are here at any hour to go to you. Whatever channel you determine to call us, you will get an undivided focus on your trouble from our people. You will get a number of fixes here with only one ring. Why settle for less then? Call QuickBooks Tech Support Number, tell us your trouble and repair it.

accountingwizards said...

Are you currently scratching the head and stuck with your QuickBooks related issues, you may be just one click away from our expert tech support team for your QuickBooks related issues. We QuickBooks Tech Support Number, are leading tech support team provider for all of your QuickBooks related issues. Either it is day or night, we provide hassle-free technical support for QuickBooks and its particular associated software in minimum possible time. Our dedicated technical team is available for you to 24X7, 365 days a year to make sure comprehensive support and services twenty-four hours a day. We assure you the quickest solution of all of the your QuickBooks software related issues.

steffan said...

You may need advanced software. There must be a premier mix solution. Quickbooks Support often helps. Proper outsource is crucial. You'll discover updates in connection with tax table. This saves huge cost. All experts can take place. A team operates 24/7. You receive stress free. Traders become free. No one will blame you. The outsourced team will see all.

steffan said...

Here we will update you how you can obtain QuickBooks Enterprise Support Phone Number. QuickBooks is financial software that can help small enterprise, large business along with home users. This computer software will always make life simple for many if you're taking proper care of all of the financial expenses and savings.

QuickBooks Payroll Support Phone Number said...

QuickBooks Enterprise has almost eliminated the typical accounting process. Along with a wide range of tools and QucikBooks Enterprise Technical Support it provides a wide range of industry verticals with specialized

QuickBooks Payroll Support said...

So now you are becoming well tuned in to benefits of QuickBooks online payroll in your company accounting but because this premium software contains advanced functions that may help you along with your accounting task to complete, so you may face some technical errors when using the QuickBooks Payroll Support Phone Number solution. If that's so, Quickbooks online payroll support number provides 24/7 help to our customer.

rdsraftaar said...

QuickBooks Payroll has emerged one of the better accounting software that has had changed this is of payroll. Support for QuickBooks Payroll will be the team that provide you Quickbooks Payroll Support. This software of QuickBooks comes with various versions and sub versions. Online Payroll and Payroll for Desktop may be the two major versions and they're further bifurcated into sub versions. Enhanced Payroll and Full-service payroll are encompassed in Online Payroll whereas Basic, Enhanced and Assisted Payroll come under Payroll for Desktop.

QuickBooks Customer Service Phone Number said...

QuickBooks is the accounting software which is used by almost every business owner who has not much knowledge regarding the accounting department. QuickBooks Phone Number For Support Instead of wasting your time by using the software which is not effective, you should decide to install.

QuickBooks Payroll Support Phone Number said...

The QuickBooks Payroll has many awesome features that are good enough when it comes to small and middle sized business. QuickBooks Payroll Support Phone Number also offers a dedicated accounting package which include specialized features for accountants also.

QuickBooks Support Phone Number said...

You will just need to go to the official website of QuickBooks from where you can easily download the original version. For downloading QuickBooks Tech Support Phone Number software, You won’t have to get tensed about keeping the record of payroll system as this software will do it for you.

QuickBooks Payroll Support Phone Number said...

QuickBooks Enterprise Support channel available on a call at .You can quickly avail our other beneficial technical support services easily once we are merely a single call QuickBooks Enterprise Support Contact Number not you.

rdsraftaar said...

Our QuickBook Tech Support Phone Number channel- We comprehend the complexity and need using this accounting software in day to day life. You can’t watch out for more or less time for it to get a fix of each and every single QB error. Therefore we have designed a especially dedicated team of certified professionals at QuickBooks Support contact number that are able to understanding your issues and errors in minimum time as well as in probably the most convenient way. Dial our QuickBooks Support Phone Number and avail the top solution you will need.

rdsraftaar said...

Creating a set-up checklist for payment both in desktop & online versions is a vital task that needs to be shown to every QuickBooks user. Hope, you liked your internet site. If any method or technology you can not understand, if that's the case your better option is which will make call us at our QuickBooks Payroll Tech Support platform.

steffan said...

This technique is wonderful for a medium-sized company. You can find the absolute most wonderful financial tool. QuickBooks Payroll Support Number is present 24/7. You can actually call them anytime. The experts are thrilled to aid.

jameswill11 said...

If you’re encountering any kind of QuickBooks’ related problem, you could get all that problems solved just by making use of the QuickBook Support Phone Number.

quicksupportnumber247 said...

We are technical support team for ACCOUNTING (financial) SOFTWARE.If anyone has any kind of problem with any ACCOUNTING (financial) SOFTWARE like QUICKBOOKS,QUICKEN,SAGE,TURBOTAX.,Please dial our support number+1-855-686-6166 for instant help.

Quicken Support Phone Number

Quicken Support Number

Quicken Support

Quicken Technical Support Phone Number

Quicken Technical Support Number

Quicken Technical Support

QuickBooks Support Phone Number

QuickBooks Support Number

QuickBooks Support

QuickBooks Technical Support Phone Number

QuickBooks Technical Support Number

QuickBooks Technical Support

Sage Support Phone Number

Sage Support Phone Number USA

Sage Support Number

Sage Support

Sage Technical Support Phone Number

Sage Technical Support Number

Sage Technical Support

TurboTax Support Phone Number

TurboTax Support Number

TurboTax Support

Quickbooks Enhanced Payroll Customer Support said...

How to contact QuickBooks Payroll support?
Different styles of queries or QuickBooks related issue, then you're way in the right direction. You simply give single ring at our toll-free intuit QuickBooks Payroll Support Phone Number . we are going to help you right solution according to your issue. We work on the internet and can get rid of the technical problems via remote access not only is it soon seeing that problem occurs we shall fix the same.

Quickbooks support said...

Thanks a lot for sharing the content. Really a nice blog and great kind of information is provided by you. We provide quickbooks pro support phone number +1-800-901-6679.

HP Printer Support Number said...

Hewlett Packard or HP Printer Support Number is recognized as to be one of many top-notch brands that offer an array of electronic products, including printers, laptops, computers, and scanners.

QuickBooks Payroll Support said...

The web is stuffed with faux numbers WHO decision themselves the QuickBooks Support Provider. you’ll value more highly to dial their variety however that would be terribly risky. you’ll lose your QuickBooks Company file or the code itself. dig recommends dialing solely the authentic QuickBooks Customer Support Phone Number.

QuickBooks Support Phone Number said...

Simply store your prospects and vendors all information and so many more things. QuickBooks Support Number is obviously a great and well-known name because of its 100% accuracy, certainty, and reliability.

rdsraftaar said...

Our QuickBook Tech Support are terribly dedicated and might solve your entire issues without the fuss. In the event that you call, you are greeted by our client service representative when taking all of your concern he/she will transfer your preference into the involved department. The best part is the fact that not just you’ll prepare you to ultimately resolve your problems nevertheless you are often acquiesced by our technicians and he/she could well keep updating you concerning your problems. it's likely you have a whole information what the problem your package is facing.

xpert said...

The key intent behind QuickBooks Support number is to supply the technical help 24*7 so as with order to avoid wasting your productivity hours. This can be completely a toll-free QuickBooks client Service variety that you won’t pay any call charges. Of course, QuickBooks is the one the large choice of awesome package in the company world. The accounting the main many companies varies according to this package. You will find so many fields it covers like creating invoices, managing taxes, managing payroll etc. However exceptions are typical over, sometimes it creates the down sides and user wants QuickBooks Support Number.