sap alv excel inplace with with macro recording

Upload: suresh

Post on 14-Apr-2018

261 views

Category:

Documents


1 download

TRANSCRIPT

  • 7/27/2019 SAP ALV Excel Inplace With With Macro Recording

    1/15

    This article is about SAP Excel inPlace funtionality with Macro recording.Withthis users can add calculation fields to standard/custom ALV reports , convert topivot table etc with out no additional programming.This additional formulacalculation can be saved as an layout in SAP .

    SAP ALV Excel Inplace with Macro recording

    Pre-requisites:

    SAP NetWeaver ABAP 7.0 and above with SAP GUI 7.20 and MSExcel2007/2010 installed in front end computer

    Purpose

    This article explains how we can make use of MS Excel Inplace functionality in the SAPALV toolbar with macro

    recording to avoid repetitive tasks such as adding custom calculation field in thestandard /Custom/ Query reports

    Intended Audience

    SAP Consultants/Users

    Table of Contents

    Introduction

    General Settings to enable macro in Excel 2007

    Addition of a custom field in ALV report using Excel Inplace and Macro

    SummaryRelated Content

    Introduction

    It is quite often that we have downloaded the standard/custom SAP ALV report as Excel

    documentto the front-end computer and added some calculation fields, converting to pivot table

    etc. These repetitive

    tasks in Excel can be recorded as an Excel macro and we can upload this excel layoutcontaining macro to

  • 7/27/2019 SAP ALV Excel Inplace With With Macro Recording

    2/15

    SAP as a new ALV layout, so that, when you run the report/selecting the layout,

    immediately the output will

    be displayed as Excel with the repetitive task automatically executed. With this we canavoid building of Custom

    fields (derived fields) in standard / Custom / Query report and save lot of time.

    General Settings to enable macro in Excel 2007

    When we run the Excel in place functionality in the SAP ALV, by default, the data willnot get automatically

    transferred to Excel. For that we have to do some macro security settings. Following

    screen shots explainshow to enable a macro in excel 2007. After activating this we have to close Excel and run

    Excel in place

    functionality once again. Then the data can be seen in Excel. Excel In place will also

    work in MSExcel 2010

    and MSExcel 2003 with Latest GUI (7.20 advisable) + patches installed at frond endcomputer

    Step 1: Select Excel options

  • 7/27/2019 SAP ALV Excel Inplace With With Macro Recording

    3/15

    Step 2: Go to Trust center settings

    Step3: Go to Macro Settings and select details as per following screen shot.

    Addition of a custom field in ALV report using Excel Inplace and Macro

    E.g. Adding Rejection% column in standard report (E.g. t-code COID)

  • 7/27/2019 SAP ALV Excel Inplace With With Macro Recording

    4/15

    In the standard report transaction COID we want to add a Rejection % column. Either we

    can

    do it by ABAP code or download the report to excel and do a formula calculation. Butthere is

    an easier method than writing code in Enhancement spot/Exits/download to achieve this.

    Following screen shots explain step by step methods to run a macro along Excel in placefunctionality.

    Step 1: Select Excel in place functionality in the ALV.

    Normally in standard /custom report we can also see Excel Inplace functionality like this.

    Step 2: After seeing the data in Excel go to RawData tab

  • 7/27/2019 SAP ALV Excel Inplace With With Macro Recording

    5/15

    Step 3: Now go to view tab and select Record Macro.

    Step 4: Give the name for the macro and assign a shortcut key (Ctrl + Shift + L)

  • 7/27/2019 SAP ALV Excel Inplace With With Macro Recording

    6/15

    Step 5: Write the formula in the cell as shown. Also leave one cell for heading.

    (It is better to put the Heading after the formula calculation otherwise we have to re-adjust the macro code)

    Eg (ROUND(h2/e2*100,2) which will give you rejection percentage rounded upto 2

    decimal place

    Step 6: Double click/drag outside cell selection, so that this makes the formula applicablefor the entire column

  • 7/27/2019 SAP ALV Excel Inplace With With Macro Recording

    7/15

    .

    Step 7: After formula, enter the heading for the column (eg. Rejection %)

    Step 8: Apply borders for the column if needed and do necessary formatting

    Step 9: Stop recording the macro as shown below. Now the tasks that we have done fromstep 5 to

    step 8 has been recorded as macro named RejectionPer (see Step 4).

  • 7/27/2019 SAP ALV Excel Inplace With With Macro Recording

    8/15

    Step 10: Now you can see the recorded macro in View Macros.

    Step 11: Save the Excel in the front end computer

  • 7/27/2019 SAP ALV Excel Inplace With With Macro Recording

    9/15

    Step 12: Now select change layout to upload the excel macro (alv_macro_eample.xls) in

    front end machine to SAP .

  • 7/27/2019 SAP ALV Excel Inplace With With Macro Recording

    10/15

    Step 13: Now go to the view tab and select Microsoft Excel and use Upload to BDSoption

    Step 14: Select the excel file we saved in the desktop and upload

  • 7/27/2019 SAP ALV Excel Inplace With With Macro Recording

    11/15

    Step 15: Save this layout by selecting the template we have just uploaded.

  • 7/27/2019 SAP ALV Excel Inplace With With Macro Recording

    12/15

    Step 16. Now go out of the report and run the report and select the layout we have saved.

  • 7/27/2019 SAP ALV Excel Inplace With With Macro Recording

    13/15

    Step 17: You can run the macro by pressing the shortcut Ctrl+Shift+L(we assigned it in

    Step 4) or go to view tab and run the macro manually.

  • 7/27/2019 SAP ALV Excel Inplace With With Macro Recording

    14/15

    Step 18: We can see the output now as below

    We can automatically run the macro when we select the Raw Data tab in the Excel .Forthis, Edit the macro and put below

    piece of code in ThisWorkbook ->Workbook->SheetActivate method (as shown below).

    If Sh.Name = RawData Then

    Module1.RejectionPer

    End If

  • 7/27/2019 SAP ALV Excel Inplace With With Macro Recording

    15/15

    Summary

    All the above tasks we can easily do within couple of minutes. If we consider enhancingthe standard report and transporting

    it through the landscapes to PRD or downloading it to excel and do the activities, this

    functionality saves a lot of time for the consultants/Users.

    Try to record some Pivot table with charts and start exploring.

    Related Content