Download SAP Query Output to Local/ Network Folders in Background

Similar documents
POWL: Infoset Generation with Web Dynpro ABAP

Integration of Web Dynpro for ABAP Application in Microsoft Share Point Portal

Using Radio Buttons in Web Template

MDM Import Manager - Taxonomy Data (Attribute Text Values) Part 3

Linking Documents with Web Templates

How to Create Top of List and End of List of the ALV Output in Web Dynpro for ABAP

Transfer Material Attributes (Material Type) from R/3 to SAP GRC Global Trade Services (GTS)

Easy Lookup in Process Integration 7.1

Reading Enhanced DataSource fields for the Remote Cube

MDM Syndicator: Custom Items Tab

Displaying SAP Transaction as Internet Application in Portal

Replacement Path: Explained with an Illustrated Example

SDN Community Contribution

Data Extraction & DS Enhancement in SAP BI Step by Step

Step By Step: the Process of Selective Deletion from a DSO

How to Create View on Different Tables and Load Data through Generic Datasource based on that View

DB Connect with Delta Mechanism

Open Text DocuLink Configuration - To Access Documents which are Archived using SAP

Table Row Popup in Web Dynpro Component

How to Create and Schedule Publications from Crystal Reports

Step by Step Guide on How to Use Cell Definition in BEx Query

Extracting Missing Fields of Data Source Which Are Present In Their Extract Structure

Extraction of Hierarchy into Flat File from R/3 and Loading in BW System

Creating Custom SU01 Transaction Code with Display and Password Reset Buttons

Reporting Duplicate Entries

Information Broadcasting Part 3 Scheduling the First Report

Step by Step Procedure for DSO Creation

This article explains the steps to create a Move-in letter using Print Workbench and SAPScripts.

ecatt Part 6 System Data Container

Process Chain Log Deletion

Material Listing and Exclusion

Using Query Extract to Export Data from Business warehouse, With Pros and Cons Analyzed

Implementing Customer Exit Reporting Variables as Methods

SMT (Service Mapping Tool)

How to use Boolean Operations in the Formula as Subsidiary for IF Condition

How to Reference External JAR Files in Web Dynpro DC in SAP NW Portal 7.3

Freely Programmed Help- Web Dynpro

Step by Step Guide for PI Server Start and Stop Procedure

Triggering the Process Chains at Particular Date using Events

Step-By-Step guide to Virtual InfoCube Implementation

Maintaining Roles and Authorizations in BI7.0 - RSECADMIN

SAP BI BO Unit/Currency Logic for Unknown Units Case Study

How to Display Result Row in One Line While Reporting On Multiproviderer

Graphical Mapping Technique in SAP NetWeaver Process Integration

How to Work with F4 Input Help Effectively in BEX

Developing Crystal Reports on SAP BW

Database Statistics During ODS Activation

Limitation in BAPI Scheduling Agreement (SA) Create or Change

Web Dynpro: Coloring Table Conditionally

Setting up Connection between BW and R/3 for Data Load

Template Designer: Create Automatic PDF Documents for Attachment or Print Purpose

Purpose of Goods Receipt Message indicator in Purchase Orders

Step By Step Procedure to Implement Soap to JDBC Scenario

Role and Scope of ABAP in SAP BI

Recreating BIA Indexes to Address the Growth of Fact Index Table

Data Mining: Scoring (Linear Regression)

SAP BI Analysis Authorization (Customer Exit Variables)

Dynamically Enable / Disable Fields in Table Maintenance Generator

Currency Translation in SAP BI Step by step Guide

SAP BusinessObjects Translation Manager Functionality and Use

Standalone BW System Refresh

How to Configure User Status in mysap SRM

Creation of Alert Data Service VC model for the BI query exception using Information Broadcasting

Material Master Archiving in Simple Method

Add /Remove Links on ESS Home Page in Business Package 1.5

About ITAB Duplicate_Key (SAP lrsaods) Runtime Error

Explore to the Update Tab of Data Transfer Process in SAP BI 7.0

Generate Export Data Source

How to Default Variant Created for Report Developed In Report Painter/Writer

SDN Community Contribution

Step by Step Method for File Archival in BW

How to Extend an Outbound IDoc

Web Dynpro ABAP: Dynamic Table

ABAP HR: Standard Info Type Enhancement

Material Master Extension for New Plant

Web Dynpro ABAP: Changing ALV Contents and Saving in Database

Validity Table in SAP BW/BI

BPM Multi Line Container in Integration Process

SUP: Personalization Keys and Synchronize Parameter

SAP Net Weaver 400s BI 7.0For more information, visit the Business Intelligence homepage.

Data Mining: Decision Trees

Table Properties and Table Popin

Hierarchy in Business Objects with Expanded Hierarchy Logic

How to Create and Execute Dynamic Operating System Scripts With XI

ABAP Code - Recipients (Specific Format) SAP BW Process Chain

Comparison Terms and SPL Check Logic

Methods of Selecting BOM Variant Parts in Variant Configuration

Internationalization in WebDynpro ABAP Applications

Step by Step Guide How to Use BI Queries in Visual Composer

Exception Handling in Web Services exposed from an R/3 System

Totals in Adobe forms

Dialog Windows in WebDynpro ABAP Applications

How to Create Tables in MaxDB using SQL Studio

Implying Security on Business Object XI 3.1 Universe having SAP BW as Source

ABAP: Table Maintenance Events

All about Compression

Creation of Key Figures with Higher Decimal Place Precision

Custom Process types Remote Trigger and End Time

How to Create Business Graphics in Web Dynpro for ABAP

Creating, Configuring and Testing a Web Service Based on a Function Module

Transcription:

Download SAP Query Output to Local/ Network Folders in Background Applies to: SAP release where SQUE0001 enhancement (SMOD) available For more information, visit the ABAP homepage. Summary This article serves as a guide to download SAP Query output to network folder when executing the query in background. Author: Aditya Laud Company: nvidia Graphics Pvt. Ltd. Created on: 17 December 2010 Author Bio Aditya Laud is a SAP ABAP developer working with nvidia Graphics Pvt. Ltd in India. He is a member of the in house SAP Application, Development, Maintenance and Support team. 2010 SAP AG 1

Table of Contents Requirement... 3 Challenge with File Store... 3 Solution/ Approach... 3 Enhancement (SMOD) SQUE0001... 3 Enhancement (SMOD) Implementation... 3 Define download internal table... 4 Add header to download table... 4 Build body of download table... 4 Logic to determine download file location/ path... 5 Impact of Enhancement... 5 Related Content... 6 Copyright... 7 2010 SAP AG 2

Requirement Download SAP query output in XLS format to network folder when executing query in background. Challenge with File Store The File Store option for download has a pop up which requires user action, hence this option cannot be used in background run mode. Solution/ Approach Enhancement (SMOD) SQUE0001 This enhancement gives access to the SAP query result table DATATAB and the LISTDESC table which contains the headings for each column in DATATAB table. When this enhancement is activated (via project in CMOD) an additional radio button Private File is added to the Output Format section in query selection screen. When user selects this option and executes the query then this enhancement (user exit) is triggered from which the query result can be downloaded. Note: Private File option is displayed when SQUE0001 enhancement is activated & query is regenerated Enhancement (SMOD) Implementation To implement the enhancement create a project through CMOD transaction and create user exit include ZXQUEU01. This include has access to two tables viz. DATATAB and LISTDESC. DATATAB - internal table contains the SAP query result LISTDESC internal table contains the SAP query output header(s) o o FDESC contains the header text e.g. Material Number FPOS contains the position of the column in the output Since the user exit implementation needs to be generic DATATAB and LISTDESC would contain different columns and number of records (respectively) at run time hence the download table needs to be built at runtime. Following is an example for building a tab delimited internal table for downloaded to network folder: 2010 SAP AG 3

Define download internal table Create an internal table with single component TYPE STRING. The header and item columns would be concatenated with tab separator (CL_ABAP_CHAR_UTILITIES=>HORIZONTAL_TAB) into the download table component. Add header to download table Create the header line in download internal table from LISTDESC table by concatenating the FDESC field in LISTDESC into the download table string component. Example of LISTDESC table: Note: Only select those records from LISTDESC where LID (list ID) is equal to LIST_ID field which is an importing parameter to the user exit. Build body of download table To add the body (query result from DATATAB) to the download internal table LT_DOWNLOAD in tab delimited format use the following logic: For each record in DATATAB table loop through LISTDESC where LID = LIST_ID Assign component LISTDESC-FPOS of DATATAB structure to a field symbol this stores the FPOS component in the field symbol While looping through LISTDESC concatenate all components into a string variable separated by tab delimiter (CL_ABAP_CHAR_UTILITIES=>HORIZONTAL_TAB). At end of looping at LISTDESC for each record of DATATAB append the string to a download internal table (into which the header has already been added as explained in section Add header to download table) At end of looping at DATATAB the table is ready for downloading to data set Please take care to ensure the format of the DATATAB components is correct e.g. when dealing with DATE and CURR fields. Note: Since the DATATAB table is dynamic (depends on query being run) the above code is required to build final internal table for download. 2010 SAP AG 4

Download table to network folder Use the OPEN/ TRANSFER/ CLOSE dataset commands to download the internal table resulting from section Build body of download table to requested download file path. Note: Refer section Logic to determine download file location to determine requested download file path Logic to determine download file location/ path Below logic is designed to read the requested download file location from the File Store selection screen parameter in Output Format section of query. This approach avoids needing to maintain a Z table for reading the file s location from. The File Store option is as shown below where \\network\file.xls is entered. The selection screen parameter is %PATH. When the enhancement is triggered, the SAP query program is the calling program in the call stack, hence via field symbol, the %PATH variable can be read and used as the target file (for download). Code snippet for the same: Note: PROGRAM is an importing parameter for the user exit function which contains the SAP query program name Impact of Enhancement Since the enhancement is triggered ONLY when user selects the Private File radio button on the selection screen of SAP query there is no impact to existing reports or their reporting. To display the Private File mode (after implementing and activating the enhancement) the SAP query has to be regenerated. Note: To re-generate the SAP query go to transaction SQ00, select query in change mode and click SAVE 2010 SAP AG 5

Related Content http://help.sap.com/saphelp_40b/helpdata/fr/d2/cb477d455611d189710000e8322d00/content.htm https://cw.sdn.sap.com/cw/docs/doc-41323 For more information, visit the ABAP homepage. 2010 SAP AG 6

Disclaimer and Liability Notice This document may discuss sample coding or other information that does not include SAP official interfaces and therefore is not supported by SAP. Changes made based on this information are not supported and can be overwritten during an upgrade. SAP will not be held liable for any damages caused by using or misusing the information, code or methods suggested in this document, and anyone using these methods does so at his/her own risk. SAP offers no guarantees and assumes no responsibility or liability of any type with respect to the content of this technical article or code sample, including any liability resulting from incompatibility between the content within this document and the materials and services offered by SAP. You agree that you will not hold, or seek to hold, SAP responsible or liable with respect to the content of this document. 2010 SAP AG 7