Skip to Content
avatar image
Former Member

Attach a document to VA02 - Background

Hello !

I really need your help. I have a scenario where I have to attach a PDF document to VA02.

I managed to make it work in dialog mode, but in my scenario I have to make it work in background.

The file will come to SAP via RFC in a lraw field. Then I have to get this file and attach it to VA02.

This is the guide I used to make it work in dialog mode. Attach File to Standard Trasaction VA02 Using Function Module SO_DOCUMENT_REPOSITORY_MANAGER

Thanks ! If you need any more information, please let me know.

Obs.: My problem is running in background. Any option is welcome. Save the file to a unix folder and upload, or read it straight from the table and attach, etc...

Thales Schmidt

Add comment
10|10000 characters needed characters exceeded

  • Follow
  • Get RSS Feed

3 Answers

  • Best Answer
    Oct 19, 2015 at 02:07 PM

    Hi.

    You can try this:

    Use SO_SOLIXTAB_TO_SOLITAB to convert your RAW data do SOLITAB.

    Use FM SO_CONVERT_CONTENTS_BIN to convert your binary data

    Use FM SO_FOLDER_ROOT_ID_GET to get your folder root data

    Compile your objdata like this:

    ls_obj_data-objsns = 'O'.

    ls_obj_data-objla = sy-langu.

    ls_obj_data-objdes = p_desc.

    lv_offset = STRLEN( p_file ) - 3.

    ls_obj_data-file_ext = p_file+lv_offset(3).

    ls_obj_data-objlen = LINES( it_content ) * 255.




    Call FM SO_OBJECT_INSERT to feed your object attachment.


    With folder data from SD_FOLDER_ROOT_ID_GET, call BINARY_RELATION_CREATE_COMMIT to generate link between attachment and document


    You should get your goal.


    Hope to help

    Bye

    Add comment
    10|10000 characters needed characters exceeded

    • Former Member

      Old post, but just for anyone looking at this going forward, the object length is calculated incorrectly and you might get corrupt files this way. When you calculate the length don't just take the number of lines * 255 as the last line might not (and most likely won't) have a length of 255. So use :

      ls_obj_data-objlen = ( lines( it_content ) - 1 ) * 255 + strlen( it_content[ lines( it_content ) ]-line ).

  • avatar image
    Former Member
    Oct 19, 2015 at 02:09 PM

    Hi Thales,

    When you say file will come to SAP via RFC in a lraw field, what exactly do you mean? Iraw field contains file data or file path? if it contains file data, then is there any field that contains file path as well?

    You simply have to follow three steps

    1) Identify physical location of file on SAP application server.

    2) Convert it to the format that can uploaded as an attachment.

    3) Call 'SO_DOCUMENT_REPOSITORY_MANAGER' as mentioned in the above link.

    If physical location of file could not be identified in the program & if you only have data, then you can simply create a file from the data and save it at a particular location on application server. Then you can pickup same file from application server and load it using same FM. Does that make sense?

    Thanks & Regards,

    Tejas Asodekar

    Add comment
    10|10000 characters needed characters exceeded

  • avatar image
    Former Member
    Oct 19, 2015 at 04:40 PM

    Thanks ! It's solved !

    Add comment
    10|10000 characters needed characters exceeded