Skip to Content
0

GOS: How to create attachment from variable string ?

Sep 25, 2017 at 07:13 PM

190

avatar image
Former Member

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.

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

4 Answers

Ankit Maskara
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.

Share
10 |10000 characters needed characters left characters exceeded
Horst Keller
Sep 25, 2017 at 08:23 PM
0

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

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

This xml file should will save it in FB03 transaction.

0
Raymond Giuseppi
Sep 26, 2017 at 06:18 AM
0

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

Show 3 Share
10 |10000 characters needed characters left characters exceeded
Former Member

Hi Raymond.

I found this tutorial and entered this values in parameters:

p_bo  : BKPF
p_key : [bukrs][doc number][year]
p_url : www.sdn.sap.com

But in FB03 don't created my attachment.
0

Insure you pass correct internal values (some space, or leading zeroes) Also debug your code as the provided sample just catch the errors but don't return any message/clue on errors (from authorization failures to wrong parameter data or type)

1

Instead of BKPF, try passing FIPP and see

0
Jelena Perfiljeva
Oct 05, 2017 at 05:03 PM
0

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.

Share
10 |10000 characters needed characters left characters exceeded