Skip to Content
avatar image
Former Member

GOS: How to create attachment from variable string ?

Hi folks.

I want to create a xml file from string variable, this string have xml content. I found this method to save any document in FB03 but selecting a local file:

CALL METHOD obj_gos->create_attachment

I want to create a xml file but with my variable content.

Thanks in advance.

Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

4 Answers

  • Sep 27, 2017 at 04:05 AM
    -1

    Hi,

    What I understand is you have a variable which has XML data and you need to create an attachment from it.

    Can you try using CL_GOS_API->INSERT_AL_ITEM.

    Pass the Object details (InstanceId, CategoryId and TypeId) in IS_OBJECT and contents(Filename, AttachmentCategory, Filesize, Content_X, etc.) in IS_ATTCONT and check.

    Add comment
    10|10000 characters needed characters exceeded

  • Sep 25, 2017 at 08:23 PM

    Simply open a file with OPEN DATASET in BINARY MODE and TRANSFER your string?

    Add comment
    10|10000 characters needed characters exceeded

  • Sep 26, 2017 at 06:18 AM

    Try creating document from your xml string with SO_DOCUMENT_INSERT and attach it to FI document with CL_BINARY_RELATION=>CREATE_LINK.

    Add comment
    10|10000 characters needed characters exceeded

  • Oct 05, 2017 at 05:03 PM

    I'm guessing your goal is not to create a "file" but to create a GOS attachment. Those are different things, technically.

    FWIW I've dissected the whole GOS process in this blog a while ago. I wouldn't just copy-paste the code since the blog is just very old but the concept explanation is still valid, I believe.

    I've used very similar code (again, years ago) to create a program that reads a file into XSTRING variable and then creates a GOS attachment with that data. It works for PDF and XML, code is exactly the same (only the extension is different) since we're dealing with binary data.

    1. cl_document_bcs=>xstring_to_solix to convert XSTRING to SOLIX type internal table

    2. FM SO_FOLDER_ROOT_ID_GET

    3. SO_DOCUMENT_INSERT_API1 (contents_hex = SOLIX type table from step 1; folder_id from step 2)

    4. FM BINARY_RELATION_CREATE_COMMIT

    Again - I'm not saying you must use these exact FMs (check the class Raymond mentioned instead). This is just an example of what works in our rather old system to outline the steps needed.

    Add comment
    10|10000 characters needed characters exceeded