Excel to SAP Macro Example

Ok so here's an example of how to mass generate PDF's from PO placed on various Vendors. The entire code, if used on a VBA for Excel, does the task.
Can the VBA coding in SAP be edited so that instead of generating PDF's, it can be used to change Delivery and Stat date for a certain line item and save the PO? Like a mass Date Conversion on PO? Because thats very tedious task to accomplish sometimes.

Hi Kaustav,
See, the issue here is that your program is simulating human behavior. It is not asking SAP for details or field names, it is simply going to a point on the screen and performing the activity. It is just like a program we have in automation testing.
We have experience of  programing such stuffs in college days, but wont be a wise thing to encourage it here.
for making changes to delivery dates (for specific lines of PO where MEMASSPO wont work), i recommend you to follow the standard path of ABAP or LSMW in that matter
Regards
Vivek Singh

Similar Messages

  • How to upload data from excel to SAP using VB script or Macros

    Hi Guys,
    I want to make a macro enabled Excel sheet which  i can use to upload huge data on SAP . I read some discussion but didnt get anything. Please help me with a step by step document.

    Hi,
    Please refer below link.
    Need help from Excel and SAP expert! [SOLVED]
    http://visualbasic.ittoolbox.com/groups/technical-functional/vb-vba-l/call-transaction-in-sap-from-excel-vba-macro-and-download-alv-list-object-results-to-spreadsheet-3335996
    Regards,
    Rafi

  • Error message while upload excel file (with macro) to sap (iw28)

    While upload excel file to sap through iw28, i get error message (vb)
    u2022     i have to say that the excel file contain macro , with out the macro , work fine .
    u2022     The error display just in refresh command.
    the error message :
    Public Sub ALV_CUS_Exit()
    Dim objs As ChartObjects
    Dim obj As ChartObject
    Dim sheet As Worksheet
    Dim r As Range
    For Each sheet In Sheets
    Set objs = sheet.ChartObjects
    For Each obj In objs
    Set r = Sheets("RawData").UsedRange
    obj.Chart.SetSourceData Source:=r
    Next obj
    Next sheet
    End Sub

    hi,
    This is releated to the ABAP coding...There might be some ouput problem in the Abap list viewer...Pls check it with the ABAP consultant...
    Regards
    Priyanka.P

  • Downloaded data in Excel from SAP table data to have the macro and control?

    We know that in SE16 screen to display SAP table data, there is a menu item or button to download the table data to excel sheet, but in the excel sheet, the data is for display only and some calculation functions (e.g. sum) are not be able to be downloaded to the excel sheet as macro.
    Our customers would like us to see if there is a way that in the excel sheet with the download SAP table data, only some certain rows/columns of data are allowed to be changed by customers or in other words, other areas in the excel sheet should be frozen and users can not even insert a column and do the copy/paste rows/columns.  And also the original calculated column in SAP table (e.g., sum) would be in the corresponding column in the excel sheet, but with macro to do the same function (e.g., sum).  After the customers perform some changes in some allowed certain rows/columns in the excel file, then the changed data can be uploaded back to SAP.
    Wonder if there are such ABAP program to fullfill the above task to download SAP table data to an excel file and to make the downloaded data in the excel with only some certain row/columns to be changeable and all other areas frozen?
    Thanks and we will give you reward points for valuable answers!

    Hi,
    This scenario can be met with the FM : RH_START_EXCEL_WITH_DATA
    This is available in Older versions. Starts Excel with a macro.
    I have never tried using this FM.
    However, I came across : http://www.jt77.com/development1/programming-23850.html
    Showing the use of it.
    To get useful hints, also refer :
    1) Transaction : DWDM
    2) MS EXCEL as OLE Client : 
    http://help.sap.com/saphelp_nw04/helpdata/en/40/b297f3c32711d194ac00a0c94260a5/frameset.htm
    3) Read the content at any table + Defined Macros used to call Function Modules
    https://www.sdn.sap.com/irj/sdn/go/portal/prtroot/docs/library/uuid/c043d836-166c-2910-b99e-ae3633dec547
    Once you get a solution, would appreciate a mail to me @ <REMOVED BY MODERATOR>
    Cheers,
    Remi
    Edited by: Alvaro Tejada Galindo on Feb 29, 2008 5:41 PM

  • Excel macro example

    Hi,
    I have found in  LabVIEW in the Menu   Help --> Find Example-->Excel Macro Example     a possibility to crate an Excel sheet with a chart. But I cannot find the Sub VI (Set Cell Value with Range.vi) in this example. Can someone send it to me?

    Somebody posted the examples recently in this http://forums.ni.com/ni/board/message?board.id=170​&message.id=212255&query.id=467035 thread

  • Excel SAP Macros

    Hi Gurus,
    While downloading to Excel with XXL format our one user able to see the option "Excel SAP macros" but another is not.
    Is there any user specific settings for this?

    Hi,
    there is another button too.
    in security under "Vertrauenwürdige Herausgeber" set button "Zugriff auf Visual Basic-Projekt vertrauen".
    Sorry that's in german.
    Regards Dieter

  • Excel to SAP R/3

    Hi All,
    I need to create automation for uploading Excel data onto SAP R/3 using VBA.Have never done this before.Hence a few questions.
    1.Once SAP is installed what references do i need to put in the VB Editor under Tools->references in order to connect to SAP and use its objects?
    2.Can i achieve uploading of data from Excel using ODCBC.
    3.I searched the net for excel to SAP links and found a term called RFC functions.What is RFC.
    4.Do we need ABAP coding as well to achieve the same?
    If someone can help me with the code for uploading data from excel to SAP,it would be great.Any reply in this regard will be highly appreciated.
    Rgds

    okay, here we go. As said before, I'll post here a series of comments outlining the use of webservices in the office2003 family to interact with an NW ABAP backend.
    Specs: Office2003 with the Webservice Toolkit installed (Gregor's link; read the instructions carefully, especially make sure that you have the MSXML3.0-dll installed too); ABAP 6.40+ (I'll use a 7.0 system here); PHP5.2.0 with soap enabled for some quick tests;
    In this first and easiest example we will specify a report within a Word document and download the coding to the Word document.
    First we create the webservice on the backend, that is, a function module and let run the webservice wizard over it:
    FUNCTION ZTW_READ_REPORT.
    ""Lokale Schnittstelle:
    *"  IMPORTING
    *"     VALUE(PROGRAMM_NAME) TYPE  SY-REPID
    *"  EXPORTING
    *"     VALUE(LINES_OF_REPORT) TYPE  ZTW_TABLE_OF_CODE_LINES
    *"     VALUE(ERRORSTRING) TYPE  STRING
      errorstring = ''.
      refresh lines_of_report.
      read report programm_name into lines_of_report.
      if lines_of_report is initial.
        errorstring = 'No such report!'.
      endif.
    ENDFUNCTION.
    /code
    ZTW_TABLE_OF_CODE_LINES is a table based on the structure DDS02.
    Very simple, return the coding for a given report name or 'No such report!' in case it does not exist. RFC enable the FM!
    Next we run the webservice wizard and create a webservice ZTW_READ_Report and release it for the SOAP runtime.
    Now let's get the WSDL URL by selecting the webservice in transaction WSADMIN and clicking the WSDL button. A browser window opens and we copy the URL.
    Sidestep: Let's test the service in a PHP script run from the commandline (i.e. without webserver set up).
    <?
    $login    = "USER";
    $password = "PW123";
    $proxyhost = '111.222.333.444;
    $proxyport = 3128;
    // WSDL URL PL5
    $wsdlurl = "http://us4484.wdf.sap.corp:50084/sap/bc/srt/rfc/sap/ZTW_READ_REPORT?"
           . "sap-client=201&sap-user=" . $login . "&sap-password=" . $password . "&sap-language=DE&wsdl=1.1";
    $programm_name = $argv[1];
    try {
         $client = new SoapClient($wsdlurl,
           array(
           'proxy_host'  => $proxyhost,
           'proxy_port'  => $proxyport,
           'login'     => $login,
           'password'    => $password,
           'trace'       => true,
           'exceptions'     => true));
    catch(SoapFault $e) {
      echo 'Caught a Constructor Error: - ' . $e->faultstring;
    if (isset($client)) {
         try {
           $ra = $client->ZtwReadReport(array(
                'ProgrammName'         => $programm_name
         catch (SoapFault $e) {
           echo 'Caught an Error: - ' . $e->faultstring;
         if ($ra->Errorstring == "") {
         $node = $ra->LinesOfReport;
         foreach ($node as $val1) { //item
           foreach ($val1 as $val2) { //Line
                foreach ($val2 as $val3) { //Value
               echo $val3 . "
         else { echo $ra->Errorstring; }
    else { echo 'No client object!'; }
    ?>
    /code
    we can run this program from the (win) commandline with
    php scriptname.php reportname
    /code
    (make sure your php is on the path and that you're in the directory where your script is or use the full path name)
    Notice the full WSDL URL http://servername:50084/sap/bc/srt/rfc/sap/ZTW_READ_REPORT?sap-client=201&sap-user=USER&sap-password=PW123&sap-language=DE&wsdl=1.1";
    We'll need this URL in the next step.
    We open a MS Word Document and go to Tools|Macro|VisualBasic Editor. Inside the Editor we go to menu Tools and find an entry 'web service references' (unfortunately I've a German Version of Word at hand at the moment so I've got to guess a little, what the English menu entries might be called). If you do not find such an entry, your SOAP Toolkit installation did not work.
    Choosing this we get a dialog which, in the lower left corner allows to select 'webservice URL'. Enable this and enter the URL mentioned before. Click Search. If everything works, we get a description of our webservice in the right hand side box.
    Select the webservice found (mark the checkbox) and click 'Add'. This creates some VBA proxy classes representing your webservice.
    In the VisualBasic Editor they can be found on the left hand side box under Project|Class Modules. They are
    - clsof_Factory_ZTWREADREPORT
    - clsw_ZTWREADREPORTService
    - struct_D022S
    Let's have a look at clsw_ZTWREADREPORTService. In the comments at the start of the script we find an explanation about the originationg WSDL and something on the usage of this proxy.
    'Example:
    ' Dim ExampleVar as New clsws_ZTWREADREPORTService
    ' debug.print ExampleVar.wsm_ZtwReadReport("Example Input")
    /code
    Okay, all that's left to do, is to write a little Macro utilizing this proxy. Here we go:
    Insert a new module to your VBA project and create a subroutine inside.
    Sub read()
    Dim errorstring As String
    Dim lor As Variant
    Dim ExampleVar As New clsws_ZTWREADREPORTService
    Dim report_name As String
    report_name = InputBox("Report:")
    errorstring = ExampleVar.wsm_ZtwReadReport(report_name, lor)
    Selection.TypeText Text:="Report" & report_name
    Selection.TypeParagraph
    For i = LBound(lor) To UBound(lor)
        With Selection
          .Font.Name = "Arial monospaced for SAP"
          .Font.Size = 10
          .TypeText Text:=lor(i).Line & vbCrLf
        End With
    Next
    End Sub
    /code
    When executed (Tools|Macro|Macros->read), this macro pops up an input box, allowing you to enter a programme name, then downloads the coding of that report, formats it a little (10 pt Arial monospaced for SAP) and pastes it into our word document.
    Voilá, done.
    What have we learnt so far:
    - installing the SOAP toolkit into Office2003
    - testing a webservice using commandline PHP
    - creating webservice proxy functions in VBA
    - allow dynamic user interaction with the document (input box) and therefore subsequently with the webservice
    - calling a webservice from within an Office document (i.e. passing data to the ABAP Service & retrieving data from it)
    Basically, that is all you need to start. It works the same in every Office application. The better you know VBA now (especially the trilions of classes within the various applications) the fancier applications you can build. I'll try to chip in some ideas thereof in the next days.
    anton
    Message was edited by: Anton Wenzelhuemer
    Message was edited by: Anton Wenzelhuemer

  • Report using the feature of opening Excel in SAP.

    We are building a custom report using the feature of opening Excel in SAP.
    We need to do things like:
    Protect the worksheet, but leave some rows unprotected
    Freeze the windows
    Have any one ever used this feature before? Can any know how to do this?
    Thank you,
    PV

    No, no extra somewhere.  What it actually is, is that you are calling the methods of the application(sort of).  Here is an example application which does to the freeze panes.
    report zrich_0001.
    include ole2incl.
    data: e_sheet type ole2_object.
    data: e_appl  type ole2_object.
    data: e_work  type ole2_object.
    data: e_col1  type ole2_object.
    data: e_col2  type ole2_object.
    data: e_cols  type ole2_object.
    data: e_cell  type ole2_object.
    data: e_wind  type ole2_object.
    data: field_value(30) type c.
    parameters: p_file type localfile default 'C:RichTest.xls'.
    start-of-selection.
    * Start the application
      create object e_appl 'EXCEL.APPLICATION'.
      set property of e_appl 'VISIBLE' = 1.
    * Open the file
      call method of e_appl 'WORKBOOKS' = e_work.
      call method of e_work 'OPEN'
              exporting
                   #1 = p_file.
    * Write data to the excel file
      do 20 times.
    * Create the value
        field_value  = sy-index.
        shift field_value left deleting leading space.
        concatenate 'Cell' field_value into field_value separated by space.
    * Position to specific cell  in  Column 1
        call method of e_appl 'Cells' = e_cell
               exporting
                    #1 = sy-index
                    #2 = 1.
    * Set the value
        set property of e_cell 'Value' = field_value .
    * Position to specific cell  in  Column 2
        call method of e_appl 'Cells' = e_cell
               exporting
                    #1 = sy-index
                    #2 = 2.
    * Set the value
        set property of e_cell 'Value' = field_value .
    * Position to specific cell  in  Column 3
        call method of e_appl 'Cells' = e_cell
               exporting
                    #1 = sy-index
                    #2 = 3.
    * Set the value
        set property of e_cell 'Value' = field_value .
      enddo.
      call method of e_appl 'Columns' = e_col1
             exporting
                  #1 = 1.
      call method of e_appl 'Columns' = e_col2
              exporting
                  #1 = 2.
      call method of e_appl 'Range' = e_cols
              exporting
                #1 = e_col1
                #2 = e_col2.
      call method of e_cols 'Select' .
      get property of e_appl 'ActiveWindow' = e_wind.
      set property of  e_wind 'FreezePanes' = 1.
    ** Close the file
    *  call method of e_work 'close'.
    ** Quit the file
    *  call method of  e_appl  'QUIT'.
    *  free object e_appl.
    Regards,
    Rich Heilman

  • Excel to SAP using VBA

    I would like to know if there is any possible way of exporting data from excelt to SAP using VBA code. I was going through one of the blogs /people/kathirvel.balakrishnan2/blog/2006/05/09/data-upload-into-sap-from-microsoft-excel-150-vba-part
    where in the data was exported from excel to SAP with the help of table name. Can the same be done using trasaction codes in SAP? If so, how.
    Also, I would like to know,if I can record a particular session(as how we do for recording a macro in excel) and use the same recorded session for other entries too.
    Thanks a lot in advance.
    Regards,
    P.Yogesh

    Hello,
    Whatz impossible ??
    Yes you can export the data from excel to SAP using VBA, but you need to create fome RFC in SAP as well that will handle the data you will send.
    1. Create a RFC function in R/3 that will read a file from specific location and perform the respective transaction.
    2. Create your excel file with respective file format and call the RFC function in SAP passing the parameters as file name and other required details.
    3. SAP coding for RFC will be a single time activity and then onwads you can just create excel file for upload and use VBA code to initiate the RFC call.
    Hope this make some sence. Tell me if you have more queries.
    Regards,
    Vishal
    Reward points.. if helpful

  • Making and running excel or word macros

    i would like to make a excel or word macro and run it in labview, but
    i don´t want to run without view the code directly in labview because
    i will need to modify the code in order to do differents things
    depending of the choose that i can make when the program it´s running
    so the answer is: how can i see the macro code in labview in and excel
    or word application and how to run it?
    don´t answer the solution it´s easymacro.com, couse i am a student and
    i need to see the diagram in order to learn
    thanks!

    I think ActiveX is what you need, but you'll have to elaborate a bit to modify and run macros. Look at the examples shipped with LabVIEW about controlling Excel, and see how those work. After that, you'll see that almost anything can be done using ActiveX.
    Good luck

  • Integrated Excel and VB Macros...Problems

    Hi,
    We are running MAP transactions (RETAIL) that use integrated Excel for planning purposes. Once we open the transaction we have access to an excel application where we maintain data.
    The problem is that we are trying to use some complex VB macros to validate online entries, but we are facing problems if we call the Excel from SAP (The file runnning on its own works fine):
    - The events WORKBOOK.OPEN or AUTOOPEN do not seem to run. I need to run a macro when the workbook is started form SAP;
    - I've been getting runtime erros and some are related to this: ACTIVECELL = nothing (?).
    Have you found similar problems?
    Where can I find VB programing guidelines for Integrated Excel in SAP.
    Thanks
    Leonardo De Araujo

    Hi Tarun,
    you are in the wrong forum. You are using the R/3 based Retail solution, this is based on the CO Planningprocessor Excel integration, it is not based on SEM or
    BW-BPS. So you can not find the BPS predefined VBA macro exits.
    In the R/3 solution there exist no predefined VBA macro exits. But you can add your code more or less at the same 'events':
    - the backend triggers the SAP makros via Sub R3MacrosExecute() at each PAI, PBO cycle
    - Sub R3PutValuesEnd() is called when the system has filled Excel with data at the end of the PBO cycle; here you can do adjustments and add your macros
    - Sub R3GetRangesSingle is called at the beginning of the PAI cycle to the read the data from Excel and to do the transfer to the backend
    - active cell problem: SAP makros to not set a selection explicitly, you can do this in your makro, e.g. the first data cell or first input ready cell
    To implement a kind of 'validation' I suggest to trigger the check via Excel button; the problem is you can not control the PBO, PAI cycle from Excel, i.e. you can send error pop-up in Excel but you can not stop the PAI cycle. So you can not implement a real error handling.
    Regards,
    Gregor

  • Upload data from Excel to Sap-Crm

    Hi All,
    I need to upload data from EXCEL to SAP-CRM system.The problem is in crm there is no ALSM_EXCEL_INTO_INTERNAL_TABLE or corresponding function modules exist.Using GUI_UPLOAD I can upload data from excel to CRM but the main problem with this is it supports only 255 chars for entire line, in my excel file it contains more than 255 chars.Please help me out.

    Try the following :
    Class: CL_GUI_FRONTEND_SERVICES
    Method: GUI_UPLOAD
    Thanks
    <b>Allot points if this helps!</b>

  • Upload data from Excel into SAP CRM using webservices

    Hi,
               I want to upload the data from EXCEL into SAP CRM using a web  service, can anyone say me the process and also how to map the excel and the source code structures.
    Thanks,
    Sanju.

    Try the following :
    Class: CL_GUI_FRONTEND_SERVICES
    Method: GUI_UPLOAD
    Thanks
    <b>Allot points if this helps!</b>

  • How to upload data from excel to SAP and options to be used

    How to upload data from excel to SAP and options to be used
    thank you,
    Regards,
    Jagrut Bharatkumar shukla

    Hi Jagrut,
        You can use gui_upload.
    chk the sample program mentioned below.
    REPORT ZFTP .
    DATA: BEGIN OF I_FILE OCCURS 0,
    DATA(2000) TYPE C,
    END OF I_FILE.
    DATA: BEGIN OF I_FILE2 OCCURS 0,
    DATA(2000) TYPE C,
    END OF I_FILE2.
    DATA: W_COUNT TYPE I.
    PARAMETERS: P_FILEN TYPE STRING,
    P_FILE2 TYPE STRING,
    P_NUM(4) TYPE N..
    AT SELECTION-SCREEN ON VALUE-REQUEST FOR P_FILEN.
    PERFORM F_FILE_GET USING P_FILEN TEXT-G01.
    AT SELECTION-SCREEN ON VALUE-REQUEST FOR P_FILE2.
    PERFORM F_FILE_GET USING P_FILE2 TEXT-G01.
    START-OF-SELECTION.
    CALL FUNCTION 'GUI_UPLOAD'
    EXPORTING
    filename = P_FILEN
    FILETYPE = 'ASC'
    HAS_FIELD_SEPARATOR = 'X'
    HEADER_LENGTH = 0
    READ_BY_LINE = 'X'
    DAT_MODE = ' '
    CODEPAGE = ' '
    IGNORE_CERR = ABAP_TRUE
    REPLACEMENT = '#'
    CHECK_BOM = ' '
    VIRUS_SCAN_PROFILE =
    NO_AUTH_CHECK = ' '
    IMPORTING
    FILELENGTH =
    HEADER =
    tables
    data_tab = I_FILE
    IF SY-SUBRC <> 0.
    MESSAGE E024(Z1).
    ENDIF.
    LOOP AT I_FILE.
    W_COUNT = W_COUNT + 1.
    IF NOT W_COUNT > P_NUM.
    MOVE I_FILE TO I_FILE2.
    APPEND I_FILE2.
    ENDIF.
    ENDLOOP.
    CALL FUNCTION 'GUI_DOWNLOAD'
    EXPORTING
    BIN_FILESIZE =
    filename = P_FILE2
    FILETYPE = 'ASC'
    APPEND = ' '
    WRITE_FIELD_SEPARATOR = 'X'
    HEADER = '00'
    TRUNC_TRAILING_BLANKS = ' '
    WRITE_LF = 'X'
    COL_SELECT = ' '
    COL_SELECT_MASK = ' '
    DAT_MODE = ' '
    CONFIRM_OVERWRITE = ' '
    NO_AUTH_CHECK = ' '
    CODEPAGE = ' '
    IGNORE_CERR = ABAP_TRUE
    REPLACEMENT = '#'
    WRITE_BOM = ' '
    TRUNC_TRAILING_BLANKS_EOL = 'X'
    WK1_N_FORMAT = ' '
    WK1_N_SIZE = ' '
    WK1_T_FORMAT = ' '
    WK1_T_SIZE = ' '
    IMPORTING
    FILELENGTH =
    tables
    data_tab = I_FILE2
    FIELDNAMES =
    *& Form F_FILE_GET
    text
    -->P_P_FILEN text
    -->P_TEXT_G01 text
    FORM F_FILE_GET USING L_FILENA L_TEXT.
    CALL FUNCTION 'WS_FILENAME_GET'
    EXPORTING
    DEF_FILENAME = ' '
    DEF_PATH = ' '
    MASK = ',.,*.TXT.'
    MODE = 'O'
    TITLE = L_TEXT
    IMPORTING
    FILENAME = L_FILENA
    rc =
    EXCEPTIONS
    INV_WINSYS = 1
    NO_BATCH = 2
    SELECTION_CANCEL = 3
    SELECTION_ERROR = 4
    OTHERS = 5
    IF SY-SUBRC <> 0.
    MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
    WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
    ENDIF.
    Reward if helpful.
    Regards,
    Harini.S

  • EXCEL spreadsheet with MACROS

    WILL NUMBERS 2009 SUPPORT AN EXCEL SPREADSHEET WITH EMBEDDED MACROS?

    Looks like Excel will get macros back. This is from Wikipedia:
    Microsoft has announced that the Mac OS X version will also be released in 2010. Microsoft Office 2011 for Mac will include more robust enterprise support and greater feature parity with the Windows edition. An all-new version of Outlook with full Exchange support will return to the Mac for the first time since 2001 and replace Entourage[47], and Visual Basic for Applications (VBA, aka "macro" support) will return after being dropped in Office 2008[48][49]. There is no public beta for the Mac version,[50] however, a copy of Beta 2 (Build 14.0.0.100326) has been circulated among many Mac file sharing websites. [51]

Maybe you are looking for

  • Capture sharpening and  radius setting?

    While I am getting better at sharpening per the Fraser-Schewe approach, I certainly still have a lot to learn. I understand that landscape shots should usually have a radius in the range of 0.5 to 0.8 for capture sharpening (source + content) in ACR.

  • HT4914 Does itunes match support video streaming ?

    Hi everybody, do u know if itunes match support video streaming ?

  • Accrual process in SAP.

    Dear All, Could you please tell me how to make an invoice in SAP but the Account Receivable is only 95% from total sales (the remaining 5% is as accrual). Example :- A service job amounting INR 1 000 000 has completed in December 2008. Referring to c

  • Just need to load Positions for legacy MM deposits

    Just need some guidance for initializing only positions in SAP-TR. Only initializing the balance position, none of the previous interests will be brought over. Thanks, Rahul

  • Why don't my Mac connect to my WiFi all the time

    I have a 2 month old Mac and I love it when it connects to my WiFi. I have the pass words and all programed in and it dont want to connect when I fire it up all the time. HELP please!!