Display file attachments

Display file attachments

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)

    Requires Free Membership to View

    When you register, you will start receiving targeted emails from my award-winning team of editorial writers. Our goal is to keep you informed on the hottest topics and biggest challenges faced by SAP professionals today.

    Hannah Smalltree, Editorial Director

    By submitting your registration information to SearchSAP.com you agree to receive email communications from TechTarget and TechTarget partners. We encourage you to read our Privacy Policy which contains important disclosures about how we collect and use your registration and other information. If you reside outside of the United States, by submitting this registration information you consent to having your personal data transferred to and processed in the United States. Your use of SearchSAP.com is governed by our Terms of Use. You may contact us at webmaster@TechTarget.com.

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 first published in January 2003

Join the conversationComment

Share
Comments

    Results

    Contribute to the conversation

    All fields are required. Comments will appear at the bottom of the article.

    Disclaimer: Our Tips Exchange is a forum for you to share technical advice and expertise with your peers and to learn from other enterprise IT professionals. TechTarget provides the infrastructure to facilitate this sharing of information. However, we cannot guarantee the accuracy or validity of the material submitted. You agree that your use of the Ask The Expert services and your reliance on any questions, answers, information or other materials received through this Web site is at your own risk.