Add attachment to a document which is in adding mode in SAP SDK - sdk

I have developed an addon which adds scanned images to the invoice. If an invoice is added I have no problem, if it's in adding mode I can't allocate it because I don't have a DocEntry value which I need to pass.
Is it possible to add an attachment to a sales document in SDK which is in adding mode?

If you're using DI-API:
Wrap the document creation and attaching the file to the document within a single transaction (see the SDK documentation on the StartTransaction method on the company object). After adding the document (still within the transaction) get the new DocEntry back from the first update by calling GetNewObjectKey on the company object. You can then use this key in the attachment update, finally committing the whole transaction (with EndTransaction).
If you're using Service Layer:
You can't do it in one transaction without writing some server-side Javascript to call. See https://blogs.sap.com/2017/09/01/implementing-service-layers-script-engine/

Related

How can I turn spool requests into PDF files on the application server?

I'm currently doing Invoicing and Printing setup on a SAP demo system. I've managed to create Smart Forms based on the standard ones. The problem starts with printing using FPCOPARA transaction and LP01 as Output device. I was able to generate a spool (was able to view it as well) but not printed (no actual file).
I just want to have a file from that Smart Form stored in AL11 and be able to archive it later on. Do you have idea on how can I proceed with this?
Thanks
We actually have an inhouse-developed program for this exact task. I don't have permission to publish the sourcecode of the program, but it involves:
Reading the list of spool requests from database table TSP01
Using the function module RSTS_GET_ATTRIBUTES to obtain the type of the spool request.
Calling the function modules CONVERT_OTFSPOOLJOB_2_PDF or CONVERT_ABAPSPOOLJOB_2_PDF, depending on the type determined by the previous function module. They return a table containing the content of the spool request in the PDF format.
Writing the table returned by the previous function modules to a file using the ABAP statements OPEN DATASET and TRANSFER

Remove unused files from ActiveStorage+DirectUpload

Consider the following example:
I have a form that includes a multiple files input;
The input file uses ActiveStorage and DirectUpload to upload files automatically as soon as they are included;
After adding some files they are uploaded automatically;
I never click the submit button so those files are never used nor accessible anywhere;
Does Rails support some built-in mechanism for removing these files or is something we have to implement ourselves?
Seems rather trivial to perform a DoS by continuously uploading files until something breaks.
Update 1
Forgot to mention that the example I'm following uses a 3rd party library (Dropzone in this case) and follow the example from the official documentation.
According to the documentation after a file upload we inject a hidden input field with the id of the uploaded blob.
I think the answer of Chiperific is good, since DirectUpload is executed in the submit there is little time for the requests to fail.
I mention requests because as far as i understand it, the process is like this:
The user selects a file from his computer and fills the rest form.
DirectUpload uploads the file to the storage.
The backend receives the body and updates the attachment and either creates or updates a model.
So, what happens if the file upload is successful but model validation is not? you would end up with a file in the storage without his corresponding model or with dirty one.
More information here: https://github.com/rails/rails/issues/31985
The answer then is no, rails does not have a mechanism of removing this files automatically. I guess you could check if the model creation/update was successful and remove the file manually if not.
I think your premise is incorrect.
The input file uses ActiveStorage and DirectUpload to upload files automatically as soon as they are included;
According to the docs:
Active Storage, with its included JavaScript library, supports uploading directly from the client to the cloud.
and
That's it! Uploads begin upon form submission.
So the point of Direct Storage seems to be to bypass some Rails ActiveStorage things and go straight to the service. BUT, it still doesn't happen until the form is submitted.
The example on the non-edge docs shows the user clicking "Submit" before the files are actually uploaded.

Copy exchange 2013 rules using profman

I want to copy exiting profile rules and add them into new profile.
It is possible using the "profman.dll" ?
Profman library allows manipulating MAPI profiles, but not rules.
You can find your client-defined rules listed as associated content (hidden) for the Inbox folder. Try using MFCMAPI for exploring Outlook internals.
Not using Profman - the rules are stored in the Inbox and can be accessed using RDOExchangeMailboxStore.Rules collection. You can copy them one at a time adjusting the relevant folder entry ids as necessary.

Umbraco Database Query

I want to add a property for a document type in Umbraco. After that, I want to add content using the newly edited document type. Finally, I want to edit the property value of the content and save it into the database. I want to do this using a SQL command in SQL Server Management Studio, given that I have installed Umbraco and I can access the Umbraco database.
You shouldn't do these things directly in the database with Umbraco. In fact, part of your requirements (adding content) wouldn't display on the front end if you did it in the database, as doing so would not fire the events needed to add your new content to the site XML cache.
Ideally you should be doing this in code, using the API. You don't mention which version of Umbraco you're using, so I'll assume the latest (7). That being the case, you ca use the various service APIs to accomplish your requirements. You'd use the ContentType Service to create your new Document Type, and the Content Service to add the content of your new type.
For more information, refer to the Umbraco services reference page: here
As Tim says it's not a good idea to do this with SQL, an alternative solution is to do it with a package. An Umbraco package contains an XML document, it is also possible there to make an adjustment in the XML (if the goal is a generated change)

OpenXml SDK - Image Reuse

I am creating a Word document based on a template. The template contains a image in the header section which I would like to re-use elsewhere in the document.
The image is stored in the package -> word/media/myImage.jpeg so I need to somehow add a relationship to my each section that I wish to display the image again. I have attempted this successfuly manually, the question is how using the sdk 2.0.
Using the AddImagePart() method is useless as this just adds the image again which is silly as I only need one copy rather than several duplicates stored in the package.
Anyone shed some light?
My experience with the SDK 2.0 is primarily in SpreadsheetML, but assuming the same principles are used in WordprocessingML, you need to create a relationship to the existing ImagePart, by obtaining its ID (using the GetIdOfPart() method) and then calling the CreateRelationshipToPart() method on the part that will hold the secondary reference to it.
Best way is to open up the document in DocumentReflector.exe and have a look on the code generated
Eric has some blog posts about that http://blogs.msdn.com/ericwhite/

Resources