How to run a excel sheet macro using RH_START_EXCEL_WITH_DATA

Hi All,
I have found out one FM, RH_START_EXCEL_WITH_DATA,
To run the excel sheet marco from the ABAP editor.
DATA_FILENAME
DATA_PATH_FLAG
DATA_ENVIRONMENT
DATA_TABLE
MACRO_FILENAME
MACRO_PATH_FLAG
MACRO_ENVIRONMENT
WAIT
DELETE_FILE
I found these parameters in the FM,
which I need to pass,
Any code sample...
Any hint...
Thanks,
Kalyan Chandramouli

hi
good
check with this report.
REPORT Z_DISPLAY_IDOC_AND_DATA line-size 275.
This tool reads an existing Idoc and dispays the contents in a       *
spreadsheet format. The spreadsheet (MS-EXCEL) will be automatically *
created if D_EXCEL = 'X'.                                            *
data: idoc_control like EDIDC,
      NUMBER_OF_DATA_RECORDS like sy-dbcnt,
      NUMBER_OF_STATUS_RECORDS like sy-dbcnt,
      INT_EDIDS like edids occurs 0 with header line,
      INT_EDIDD like edidd occurs 0 with header line.
TYPE-POOLS :  LEDID.
data: STRUCT_TYPE TYPE  LEDID_STRUCT_TYPE ,
      IDOC_STRUCT TYPE  LEDID_T_IDOC_STRUCT,
      SEGMENTS TYPE  LEDID_T_SEGMENT,
      SEGMENT_STRUCT TYPE  LEDID_T_SEGMENT_STRUCT,
      excel_tab(2000) occurs 0 with header line.
parameter: DOCNUM like edidc-docnum obligatory, ""Idoc Number
           sap_rel like SY-SAPRL default SY-SAPRL obligatory,
           pi_ver like EDI_VERREC-VERSION default '3' obligatory,
           d_excel as checkbox default 'X'. ""Download ?
start-of-selection.
  perform read_idoc.
  perform process_idoc.
  if d_excel = 'X'.
    perform download_to_excel.
  endif.
end-of-selection.
FORM read_idoc.
  CALL FUNCTION 'IDOC_READ_COMPLETELY'
       EXPORTING
            DOCUMENT_NUMBER          = docnum
       IMPORTING
            IDOC_CONTROL             = idoc_control
            NUMBER_OF_DATA_RECORDS   = NUMBER_OF_DATA_RECORDS
            NUMBER_OF_STATUS_RECORDS = NUMBER_OF_STATUS_RECORDS
       TABLES
            INT_EDIDS                = INT_EDIDS
            INT_EDIDD                = INT_EDIDD
       EXCEPTIONS
            DOCUMENT_NOT_EXIST       = 1
            DOCUMENT_NUMBER_INVALID  = 2
            OTHERS                   = 3.
  IF SY-SUBRC <> 0.
    MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
            WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
  ENDIF.
ENDFORM.                    "" read_idoc
FORM process_idoc.
  perform read_idoc_structure.
  perform display_data_records.
ENDFORM.                    "" process_idoc
FORM display_data_records.
  data: PE_seg_HEADER like EDI_SAPI01,
        segname like EDI_IAPI12-SEGMENTTYP,
        prev_segname like EDI_IAPI12-SEGMENTTYP value ' ',
        pt_fields2 like EDI_IAPI12 occurs 0 with header line,
        PT_FVALUES2 like EDI_IAPI14 occurs 0 with header line,
        byte_first type i,
        byte_last type i,
        field_val(50),
        tmp_str(15),
        tmp_str3(15),
        seg_repeats type i value 0,
        tmp_str2(15),
        tab_cr(1) type x value '09',
        tot_ctr type i value 0,
        ctr type i value 0,
        msg(40) type c.
  data: IDOC_STRUCT_wa TYPE  LEDID_IDOC_STRUCT.
  sort int_edidd by segnum.
  describe table int_edidd lines tot_ctr.
  loop at int_edidd.
    move int_edidd-segnam to segname.
    clear msg.
    concatenate 'Reading segment ' segname
                into msg separated by space.
    if tot_ctr <> 0.
      ctr = ( 100 * sy-tabix ) / tot_ctr.
    endif.
    CALL FUNCTION 'SAPGUI_PROGRESS_INDICATOR'
         EXPORTING
              PERCENTAGE = ctr
              TEXT       = msg.
    add 1 to seg_repeats.
    clear tmp_str2.
    if int_edidd-segnam <> prev_segname.
      seg_repeats = 1.
      clear: pe_seg_header, pt_fields2, pt_fvalues2.
      refresh: pt_fields2, pt_fvalues2.
      CALL FUNCTION 'SEGMENT_READ_COMPLETE'
           EXPORTING
                PI_SEGTYP                 = segname
                PI_RELEASE                = sap_rel
                PI_VERSION                = pi_ver
           IMPORTING
                PE_HEADER                 = pe_seg_header
           TABLES
                PT_FIELDS                 = pt_fields2
                PT_FVALUES                = pt_fvalues2
           EXCEPTIONS
                SEGMENT_UNKNOWN           = 1
                SEGMENT_STRUCTURE_UNKNOWN = 2
                OTHERS                    = 3.
      IF SY-SUBRC <> 0.
        MESSAGE ID SY-MSGID TYPE 'I' NUMBER SY-MSGNO
                WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
      ENDIF.
      prev_segname = int_edidd-segnam.
    endif.
    read table idoc_struct into idoc_struct_wa with key
                           segment_type = int_edidd-segnam.
    if sy-subrc = 0.
      IF IDOC_STRUCT_WA-SYNTAX_ATTRIB-MUSTFL = 'X'.
        TMP_STR = 'Mandatory'.                  ""Mandatory
      ELSE.
        TMP_STR = 'Optional'.                  ""Optional
      ENDIF.
      if IDOC_STRUCT_wa-SEGMENT_TYPE_ATTRIB-QUALIFIER = 'X'.
        tmp_str3 = 'Qualified'.
      else.
        tmp_str3 = 'Non-Qualified'.
      endif.
      shift IDOC_STRUCT_wa-SYNTAX_ATTRIB-OCCMAX
                                 left deleting leading '0'.
      move seg_repeats to tmp_str2.
      condense: IDOC_STRUCT_wa-SYNTAX_ATTRIB-OCCMAX, tmp_str2.
      concatenate tmp_str2 'of'  IDOC_STRUCT_wa-SYNTAX_ATTRIB-OCCMAX
          into tmp_str2 separated by space.
      write :/ IDOC_STRUCT_wa-SEGMENT_TYPE,
           tmp_str,
           TMP_STR3,
           tmp_str2,
           IDOC_STRUCT_wa-SYNTAX_ATTRIB-HLEVEL,
           IDOC_STRUCT_wa-SEGMENT_TYPE_ATTRIB-plast,
           IDOC_STRUCT_wa-SEGMENT_TYPE_ATTRIB-DESCRP.
      if d_excel = 'X'.
        concatenate 'Segment Name' tab_cr
                    'Mand / Opt ' tab_cr
                    'Qual / non-Qual' tab_cr
                    'Seq of Max' tab_cr
                    'Level' tab_cr
                    'Owner' tab_cr
                    'Description'
                    into excel_tab.
        append excel_tab.
        concatenate IDOC_STRUCT_wa-SEGMENT_TYPE tab_cr
              tmp_str tab_cr
              TMP_STR3 tab_cr
              tmp_str2 tab_cr
              IDOC_STRUCT_wa-SYNTAX_ATTRIB-HLEVEL tab_cr
              IDOC_STRUCT_wa-SEGMENT_TYPE_ATTRIB-plast tab_cr
              IDOC_STRUCT_wa-SEGMENT_TYPE_ATTRIB-DESCRP
              into excel_tab.
        append excel_tab.
        concatenate tab_cr
                    'Field Nma' tab_cr
                    'Type' tab_cr
                    'Length' tab_cr
                    'Byte From' tab_cr
                    'Byte To' tab_cr
                    'Description' tab_cr
                    'Value' tab_cr
                    'Qualifier Meaning'
                    into excel_tab.
        append excel_tab.
      endif.
    endif.
    sort pt_fields2 by field_pos.
    byte_first = 0.
    loop at pt_fields2.
      clear: field_val.
      byte_last = pt_fields2-EXTLEN.
      write int_edidd-sdata+byte_first(byte_last) to
            field_val left-justified.
      shift pt_fields2-EXTLEN left deleting leading '0'.
      shift pt_fields2-byte_first left deleting leading '0'.
      shift pt_fields2-byte_last left deleting leading '0'.
      write:/ '   ', pt_fields2-fieldname,
              pt_fields2-datatype,
              pt_fields2-EXTLEN,
              pt_fields2-byte_first ,
              pt_fields2-byte_last,
              pt_fields2-descrp,
              field_val.
      read table pt_fvalues2 with key fieldname = pt_fields2-fieldname
                    fldvalue_l = field_val.
      add byte_last to byte_first.
      if sy-subrc = 0.
        write : pt_fvalues2-descrp.
      else.
        clear pt_fvalues2-descrp.
      endif.
      if d_excel = 'X'.
        concatenate tab_cr pt_fields2-fieldname tab_cr
                pt_fields2-datatype tab_cr
                pt_fields2-EXTLEN tab_cr
                pt_fields2-byte_first tab_cr
                pt_fields2-byte_last tab_cr
                pt_fields2-descrp tab_cr
                field_val tab_cr
                pt_fvalues2-descrp
                into excel_tab.
        append excel_tab.
      endif.
    endloop.
  endloop.
ENDFORM.                    "" display_data_records
FORM read_idoc_structure.
  data: idoctype type LEDID_IDOCTYPE.
  if not idoc_control-cimtyp is initial.
    STRUCT_TYPE = 'E'. ""Extended
    idoctype = idoc_control-cimtyp.
  else.
    STRUCT_TYPE = 'B'. ""Basic
    idoctype = idoc_control-idoctp.
  endif.
  CALL FUNCTION 'IDOC_TYPE_COMPLETE_READ'
       EXPORTING
            RELEASE              = sap_rel
            STRUCT_TYPE          = STRUCT_TYPE
            IDOCTYPE             = idoctype
            VERSION              = pi_ver
      IMPORTING
           IDOC_TYPE            = idoctype
       TABLES
            IDOC_STRUCT          = idoc_struct
            SEGMENTS             = segments
            SEGMENT_STRUCT       = segment_struct
       EXCEPTIONS
            IDOCTYPE_UNKNOWN     = 1
            IDOCSTRUCT_UNKNOWN   = 2
            SEGMENT_DATA_MISSING = 3
            ILLEGAL_STRUCT_TYPE  = 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.
ENDFORM.                    "" read_idoc_structure
FORM download_to_excel.
  data: name like RLGRAP-FILENAME.
  shift docnum left deleting leading '0'.
  concatenate docnum '-' idoc_control-idoctp '.xls'
              into name.
  CALL FUNCTION 'RH_START_EXCEL_WITH_DATA'
   EXPORTING
     DATA_NAME                 = name
     DATA_TYPE                 = 'ASC'
     WAIT                      = ' '
   TABLES
     DATA_TAB                  = excel_tab
   EXCEPTIONS
     NO_BATCH                  = 1
     EXCEL_NOT_INSTALLED       = 2
     WRONG_VERSION             = 3
     INTERNAL_ERROR            = 4
     INVALID_TYPE              = 5
     CANCELLED                 = 6
     DOWNLOAD_ERROR            = 7
     OTHERS                    = 8
  IF SY-SUBRC <> 0.
    MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
            WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
  ENDIF.
ENDFORM.                    "" download_to_excel
reward point if helpful.
thanks
mrutyun^

Similar Messages

  • How export report into excel sheet automatically using SSRS 2010?

    Hi,
    I have created many reports using SQL Server Data Tool 2010 and at my work, we are using active batch to ran reports every month.
    Now question is, my boss want me to set up reports such a way that when active batch is ran, reports should be exported into excel sheet automatically with the default values given for parameters at some specific folder location. How can I export report
    into excel sheet automatically when active batch is executed?
    Please help me on this. Thanks for the help in advance.
    Vicky

    Check this:
      CALL FUNCTION 'GUI_DOWNLOAD'
        EXPORTING
          filename                = 'C:/test.xls'
          filetype                = 'ASC'
          write_field_separator   = 'X'
        TABLES
          data_tab                = t_output
    Regards.

  • How can i create  excel sheet with multiple tabs using utl file?

    how can i create excel sheet with multiple tabs using utl file?
    any one help me?

    Jaggy,
    I gave you the most suitable answer on your own thread yesterday
    Re: How to Generating Excel workbook with multiple worksheets

  • How to import pictures into excel sheet without using report generation

    Dear Friends
    I want to know how to import the picture or picture file into excel sheet without using report generation..
    kindly come up with any suggestions or example code
    Regards
    Karthick
    Solved!
    Go to Solution.

    Thank you Rajesh 
    i am going through that vi
    Rajesh Nair wrote:
    Please go through below link
    http://zone.ni.com/devzone/cda/epd/p/id/3638
    Eventhough one subVI is missing i think it will be usefull for you.
    Regards
    Rajesh R.Nair
    Rajesh Nair wrote:
    Please go through below link

  • How to append in excel sheet using Java

    Can anybody help me out in figuring out as how to append in already existing excel sheet using Java.
    I am able to to write in the existing excel sheet using HSSF but is not able to append the data row wise.
    So plz tell me how to do the same.

    Manisha_7 wrote:
    Thnx for the link......No problem.
    but i alsot wanted to know if apart from using poi there is a way to append the data in excel sheet like using JExcel.Don't know. JExcel is also not apart of Java's core API.

  • How to convert an excel sheet as pdf  and sent mail?

    Hi,
    I have to open an excel file from report and display a value in a cell, based on that value in excel, macros will automatically trigger and the remaining data will fill in excel sheet.
    This sheet i need to convert as pdf and sent as attachment to mail.
    Regards,
    Shree

    Hi,
    I know how to do with word documents using OLE.  But i dont know how to work with Excel sheets.
    I have worked on word documents like displaying data in word document from SAP and saving it into local system.
    But here my requirement is i need to pass pernr to a cell in an Excel sheet, based on pernr in excel some macros will trigger and fill the details. After that, the filled sheet i need to convert as pdf and sent as mail.
    Regards,
    Shree.

  • How can I change excel column header using Labile.

    Dear Experts,
                          How can i change excel column header using LabVIEW.
    Thanks for any and all help!
    M.S.Sivaraj.
    Sivaraj M.S
    CLD

    As I said in my previous post, column headers in Excel are merely row 1 cells. May be I missing something here, so please be more explicit with your question.
    I guess you are using the Excel Report tools, and you want to modify an existing sheet. From my limited experience with the Excel Report tools, it is not possible to open an existing woorkbook (except as template...), so the answer to your question should be "Forget it"...
    The work around is to use the example I pointed for you before, and either to write the whole new colum headers as a string array, starting in A1, or to write a single string to a given cell in row 1.
    Hope this helps 
    Chilly Charly    (aka CC)
             E-List Master - Kudos glutton - Press the yellow button on the left...        

  • How to store an excel sheet in oracle database

    How can I store excel sheet into oracle.

    Or you could use Heterogenous Services to treat Excel as an external database:
    1- Go to Control Panel>Administrative Tools>Data Sources (ODBC)>System DSN and create a data source with appropriate driver. Name it EXCL.
    2- In %ORACLE_HOME%\Network\Admin\Tnsnames.ora fie add entry:
    EXCL =
    (DESCRIPTION =
    (ADDRESS_LIST =
    (ADDRESS = (PROTOCOL = TCP)(HOST = 10.12.0.24)(PORT = 1521))
    (CONNECT_DATA =
    (SID = EXCL)
    (HS = OK)
    Here SID is the name of data source that you have just created.
    3- In %ORACLE_HOME%\Network\Admin\Listener.ora file add:
    (SID_DESC =
    (PROGRAM = hsodbc)
    (SID_NAME = <hs_sid>)
    (ORACLE_HOME = <oracle home>)
    under SID_LIST_LISTENER like:
    SID_LIST_LISTENER =
    (SID_LIST =
    (SID_DESC =
    (SID_NAME = PLSExtProc)
    (ORACLE_HOME = d:\ORA9DB)
    (PROGRAM = extproc)
    (SID_DESC =
    (GLOBAL_DBNAME = ORA9DB)
    (ORACLE_HOME = d:\ORA9DB)
    (SID_NAME = ORA9DB)
    (SID_DESC =
    (PROGRAM = hsodbc)
    (SID_NAME = EXCL)
    (ORACLE_HOME = D:\ora9db)
    Dont forget to reload the listener
    c:\> lsnrctl reload
    4- In %ORACLE_HOME%\hs\admin create init<HS_SID>.ora. For our sid EXCL we create file initexcl.ora.
    In this file set following two parameters:
    HS_FDS_CONNECT_INFO = excl
    HS_FDS_TRACE_LEVEL = 0
    5- Now connect to Oracle database and create database link with following command:
    SQL> CREATE DATABASE LINK excl
    2 USING 'excl'
    3 /
    Database link created.
    Now you can perform query against this database like you would for any remote database.
    SQL> SELECT table_name FROM all_tables@excl;
    TABLE_NAME
    DEPT
    EMP

  • How i can load excel sheet into a table in oracle through pl/sql procedure

    Hi,
    How i can load excel sheet into a table in oracle through pl/sql procedure or a pl/sql block. Excel sheet is saved on my c or d drive on my machine. In xls format.

    Depending on how big your spreadsheet is and how frequently you want to do this you might want to contruct insert statements in excel, then run these. I have done this to load a few hundred rows for a one off test on dev.
    e.g. if you have values 1 and 'a' in you spread sheet and want to insert them in to table xxx col1 & 2:
    | /|   A   |   B   |    C
    |1 |col1   |col2   |
    |2 |      1|a      |="insert into xxx ("&$A$1&","&B1&") values ("&A2&",'"&B2&"');"then paste the contents of colum C
    insert into xxx (col1,col2) values (1,'a');into sqlplus or a script.

  • How to spool in excel sheet of table with 1561828 records

    how to spool in excel sheet of table with 1561828 records
    i think excel got only 65l limit?
    COUNT(*)
    1561828
    i am using windows box...any suggestions?

    Raman wrote:
    means excel 2007 can hold 15,61,828 records ? can i give like spool filename.xls?You can name the spool file anything you want, but surely you realize that naming it 'filename.xls' doesn't make it an xls file. A name is just a name. There are industry standards on certain names indicating certain file formats, but the name doesn't make it that format.

  • Uploading an excel sheet data using Oracle APEX 3.2

    Hi All,
    Please help me out to upload excel sheet data using oracle APEX 3.2.
    Am following the steps mentioned in the below link, but even after that am getting an error saying no data found
    http://avdeo.com/2008/05/21/uploading-excel-sheet-using-oracle-application-express-apex/
    Please help me to proceed further.
    Regards,
    Sakthi

    Hi Andy,
    Thank you very much for looking into my thread.
    Actually i followed everything that is been mentioned in "http://avdeo.com/2008/05/21/uploading-excel-sheet- using-oracle-application-express-apex/" and i got a successful result.
    But, with the above process I can only upload a .csv format excel and not a .xls format excel file.
    Thats where i got stucked and unable to find any clue on how to move further to achieve in uploading .xls file.
    It would be very great if you guide me through in this process.
    Shiva

  • How to report on balance sheet accounts using 0EC_PCA_3

    Hi Experts,
    How to report on balance sheet accounts using 0EC_PCA_3
    Thanks
    nagini

    Hi,
    IF you want to see the accumulated balances you need to select the period from 0 to 12.
    EX: you want to open the report up to period 6th 2009 and want see the figures including the carryforward balances from 2008.
    then in selection screen select the from period = 0  and to period =6.
    hope its helpful
    thanks,

  • How to run the oracle application cleint using static ip or domain please e

    How to run the oracle application cleint using static ip or domain please explain me.
    i am not able to run oracle forms in client machine how to run it please explain me
    Please give me detail regarding that
    any body please help me.
    my mail id::::: [email protected]

    You did not mention exactly which Forms version you are using so it will be difficult to offer specific help. However, you did mention Forms 9i. ALL "9i" releases were desupported long ago, so find software or documentation are becoming more difficult.
    Here is the Deployment Guide for Forms 10.1.2
    http://download.oracle.com/docs/cd/B19375_07/doc/frs/forms/B14032_03/toc.htm
    Here are some technical reference for Forms 9.0.x
    http://www.oracle.com/technology/products/forms/techlisting9i.html

  • How to uplaod multiple excel sheets in a program

    Hi gurus,
    Can anyone suggest me
    how to upload multiple excel sheets in program.( not in OOPS)
    my excel sheets has 5 sheets like sheet1, sheet2, sheet3 ....like this..
    Thanks & Regards
    kalyan.

    swc_container it_event_container.                       
    swc_create_container it_event_container.                 
    CALL FUNCTION 'SWW_WI_CONTAINER_READ'
                EXPORTING
                  wi_id                    = wd_id
                TABLES
                  wi_container             = it_event_container
                EXCEPTIONS
                  container_does_not_exist = 1
                  read_failed              = 2
                  OTHERS                   = 3.
    if sy-subrc = 0.
    READ TABLE it_event_container WITH KEY element = 'name of your workflow container element'.
                IF sy-subrc = 0.
                  w_variable= it_event_container-value.
                ENDIF.
    endif.
    Regards
    Kedar

  • How to Run scenario from the web using HTTP web page?

    Hi guys
    Please let me know How to Run scenario from the web using HTTP web page?
    Regards
    Janakiram

    Hi Janakiram,
    ODI provides web based UI for running the scenarios using Metadata Navigator (read only of ur ODI components) and Lighweight designer (u can edit the mapping here).
    Please explore how to install metadata navigator in ODI and have a look at ODI Setup document for more information.
    Thanks,
    Guru

Maybe you are looking for

  • Sending in Mail doesn't work, Entourage does, Why?

    Sending emails in Apple's Mail doesn't work, yet Microsoft Entourage does, Why? This is the conversation I've been having with my server tech, and they can't find the reason why I can send mail in Microsoft Entourage no problem, yet Apple Mail receiv

  • IPOD 30 GB Video issues.....

    I have two videos, bought from Itunes, on my IPOD. I purchased another video and it will play in my 'Purchased' folder, but when I try to move/copy it to a Video folder, where the other two video's are stored, it has the file, but it's blank....nothi

  • Portal 7.1 + Access Manager in realm mode

    OS Solaris SPARC 9. Components already installed: SJES Directory Server + SJES5 Web Server + SJES5 Access Manager (configured in realm mode with 'Configure now' option selected). Web Server is listenin on port 8088. It is said in "SJES5 Installation

  • Canon 350XT: Which driver to use to read the card?

    http://146.184.121.145/inetCA/en/serviceDetail/method/load/id/45/sid/7/mid/0002200146/type/S This page does not show what each is used for.   WIA Driver 5.6.0 for Windows XP > WA560EN seems to be obvious.  But it didn't work. Why don't they list what

  • Photo Template Problems

    When I visit my site, and click on a photo or do the slide show, the photos popping up are not the most current version. If I click on the door picture, and enlarged cat picture opens! What is going on? And, the last few times I have published, the c