Problem solve Get help with specific problems with your technologies, process and projects.

Display file attachments

Do you have any requirements to print the filenames of the attached files from a document? This tip explains how.

Do you have any requirements to print the filenames of the attached files from a document such as Purchase Order...

or other SAP objects on a SAPscript or SmartForms? When you attached a PC document to your Purchase Order, Purchase Contract, RFQ etc., these file attachment documents are not part of the object tables hierarchy. In the case of PO, they are not in PO tables such as EKKO, EKPO, EKBE, etc. Instead, they are part of the SAP Office framework. So in order to get this information, which is associated to a particular object, you need to go through different tables. The example below pertains to a Purchase Order document, however, it can be modified to accommodate other objects. Just change the OBJTYPE-column value in SRRELROLES table. You can take a look at your object types in Business Object Builder (SWO1). The code was written in 4.6c but has successfully tested on 4.7 as well.


REPORT yeb_get_file_attachment.

***************************************************
* This program will get the filenames of the
* attached files in a Purchase Order.
********************************************************

PARAMETERS:     p_ponbr(10) TYPE c.

TABLES: srrelroles.
DATA: w_roleid(22)  TYPE c,
      w_objkey(70)  TYPE c,
      w_foltp(3)    TYPE c,
      w_folyr(2)    TYPE c,
      w_folno(12)   TYPE c,
      w_doctp(3)    TYPE c,
      w_docyr(2)    TYPE c,
      w_docno(12)   TYPE c,
      w_objdes(50)  TYPE c.

TYPES: BEGIN OF ty_binrel,
         roleb(22) TYPE c,
       END OF ty_binrel.

DATA: it_binrel       TYPE TABLE OF ty_binrel.
DATA: w_roleb         LIKE LINE OF it_binrel.


* Get role id
SELECT roleid
  FROM srrelroles
  INTO w_roleid
  WHERE objkey  = p_ponbr        "Purchase Order nbr
    AND objtype = 'BUS2012'.     "Purchase Order object

ENDSELECT.
IF sy-subrc = 4.
  MESSAGE i899(f2)
  WITH 'No File Attachments for ' p_ponbr.
ENDIF.


* Get role ids given the primary role id
SELECT role_b
  FROM srgbinrel
  INTO TABLE it_binrel
  WHERE role_a   = w_roleid
    AND breltyp IN ('NOTE', 'URL', 'ATTA').

* Get object key from SRRELROLES using role B
LOOP AT it_binrel INTO w_roleb.

  SELECT SINGLE objkey
    FROM srrelroles
    INTO w_objkey
    WHERE roleid   = w_roleb.


* Prepare key fields for SOOD table
*  w_foltp = w_objkey(3).
*  w_folyr = w_objkey+3(2).
*  w_folno = w_objkey+5(12).
  w_doctp = w_objkey+17(3).
  w_docyr = w_objkey+20(2).
  w_docno = w_objkey+22(12).

  SELECT SINGLE objdes
    FROM sood
    INTO w_objdes
    WHERE objtp = w_doctp
      AND objyr = w_docyr
      AND objno = w_docno.

  WRITE: / w_objdes.
ENDLOOP.

This was last published in January 2003

Dig Deeper on SAPscript and Smart Forms

PRO+

Content

Find more PRO+ content and other member only offers, here.

Start the conversation

Send me notifications when other members comment.

By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy

Please create a username to comment.

-ADS BY GOOGLE

SearchManufacturingERP

SearchOracle

SearchDataManagement

SearchAWS

SearchBusinessAnalytics

SearchCRM

SearchContentManagement

SearchFinancialApplications

Close