Application Development Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 

Get manual attachment from a report

mgbernardo
Participant
0 Kudos

Hi all,

I have a problem when trying to retrieve from a report the manual attachments of an SD invoice. Though I'm using a SD invoice, I guess is the same for any object.

I usually use this way to get attachments from objects:

1º ARCHIV_GET_CONNECTIONS -> Attachment info

2º ARCHIVOBJECT_GET_DT_VIA_TABLE or ARCHIVOBJECT_GET_TABLE -> Attachment data

3º Then download, email... or do whatever you want with the files.

My problem now is, if I go inside an invoice and create an attachment manually, then it does not show up on TOA01 or on FM ARCHIV_GET_CONNECTIONS.

Do you know a way to get these manual created attachments or at least where are they stored?

Thanks in advance,

Regards John

Edited by: John Smith on May 26, 2011 1:18 PM

1 ACCEPTED SOLUTION

Former Member
0 Kudos

Hi,

Use this FM -->

1.BDS_GOS_CONNECTIONS_GET

2. then use this to get the content SO_DOCUMENT_READ_API1

Regards,

Madhukar Shetty

2 REPLIES 2

Former Member
0 Kudos

Hi,

Use this FM -->

1.BDS_GOS_CONNECTIONS_GET

2. then use this to get the content SO_DOCUMENT_READ_API1

Regards,

Madhukar Shetty

0 Kudos

Hi Madhukar,

Thanks for the answer. That's exactly what I need.

After a while I finally managed to execute them correctly, I'll explain here:

1º Get the attachments info. In my case, as I told, are SD Invoices so class is VBRK

 CALL FUNCTION 'BDS_GOS_CONNECTIONS_GET'
  EXPORTING
*   LOGICAL_SYSTEM           =
    classname                = 'VBRK'
    objkey                   = 'sd invoice number'
*   CLIENT                   = SY-MANDT
  tables
    gos_connections          = it_gos_connections
* EXCEPTIONS
*   NO_OBJECTS_FOUND         = 1
*   INTERNAL_ERROR           = 2
*   INTERNAL_GOS_ERROR       = 3
*   OTHERS                   = 4. 

2º We recover the data of any of the attachments we got before:

From table gos_connections we use the field L0I0_ID to enter this next FM:


CALL FUNCTION 'SO_DOCUMENT_READ_API1'
  EXPORTING
    document_id                      =   it_gos_connections-L0I0_ID
*   FILTER                           = 'X '
* IMPORTING
*   DOCUMENT_DATA                    =
 TABLES
*   OBJECT_HEADER                    =
   OBJECT_CONTENT                   = it_object_content
*   OBJECT_PARA                      =
*   OBJECT_PARB                      =
*   ATTACHMENT_LIST                  =
*   RECEIVER_LIST                    =
*   CONTENTS_HEX                     =
* EXCEPTIONS
*   DOCUMENT_ID_NOT_EXIST            = 1
*   OPERATION_NO_AUTHORIZATION       = 2
*   X_ERROR                          = 3
*   OTHERS                           = 4. 

3º Now we got the data, we can do whatever we want. For example if we want to download it we can go like this:

we use the it_object_content from last FM for this next one.


CALL FUNCTION 'SO_OBJECT_DOWNLOAD'
 EXPORTING
*   BIN_FILESIZE           = 0
*   DEFAULT_FILENAME       = ' '
   FILETYPE               = 'BIN' "for PDF
   PATH_AND_FILE          = 'C:TEST '
*   EXTCT                  = ' '
   NO_DIALOG              = 'X'
*   CODEPAGE               =
* IMPORTING
*   FILELENGTH             =
*   F_CANCELLED            =
*   ACT_FILETYPE           =
*   ACT_FILENAME           =
  TABLES
    objcont                =  it_object_content 
* EXCEPTIONS
*   FILE_WRITE_ERROR       = 1
*   INVALID_TYPE           = 2
*   X_ERROR                = 3
*   KPRO_ERROR             = 4
*   OTHERS                 = 5. 

Regards

Edited by: John Smith on May 26, 2011 4:29 PM