Download Sap script output in XL.

hi all,
can anybody plz tell me that is there any possibility to download SAP script output in editable XL format? actually i got a new requirement in my company so plz can anybody help me for this?
regards saurabh.

Hi, Below code used for convert output into PDF format. May be you can convert into XL.
In close form, collect output data into OTF format.
    call function 'CLOSE_FORM'
      TABLES
        otfdata                  = it_otfdata
      EXCEPTIONS
        unopened                 = 1
        bad_pageformat_for_print = 2
        send_error               = 3
        others                   = 4.
    if sy-subrc <> 0.
      PERFORM protocol_update.
      retcode = 1.
    endif.
  call function 'CONVERT_OTF'
    EXPORTING
      format                = c_pdf
    IMPORTING
      bin_filesize          = h_size
    TABLES
      otf                   = it_otfdata
      lines                 = it_pdf
    EXCEPTIONS
      err_max_linewidth     = 1
      err_format            = 2
      err_conv_not_possible = 3
      others                = 4.
  if sy-subrc <> 0.
   MOVE sy-subrc                 TO   h_retcode.
  endif.
  perform table_shift.
form table_shift.
  describe table it_pdf    lines  hltlines.
  DESCRIBE FIELD IT_PDF    LENGTH FLE1 in character mode.
  DESCRIBE FIELD X_OBJCONT LENGTH FLE2 in character mode.
  clear   x_objcont.
  refresh x_objcont.
  clear off1.
  clear hfeld.
  loop at it_pdf.
    htabix = sy-tabix.
    move it_pdf to hfeld+off1.
    if htabix = hltlines.
      fle1 = strlen( it_pdf ).
    endif.
    off1 = off1 + fle1.
    if off1 ge fle2.
      clear x_objcont.
      x_objcont = hfeld(fle2).
      append x_objcont.
      shift hfeld by fle2 places.
      off1 = off1 - fle2.
    endif.
    if htabix = hltlines.
      if off1 gt 0.
        clear x_objcont.
        x_objcont = hfeld(off1).
        append x_objcont.
      endif.
    endif.
  endloop.
endform.                    " TABLE_SHIFT

Similar Messages

  • To convert Sap Script output to PDF format and send it via email.

    Hi Friends,
    Could any one please tell me, how to convert the Sap Script output to PDF format and send it via email. If any one have the code, kindly mail me to [email protected]
    Thanks & Regards,
    John

    Plese check this sample code from other thread.
    REPORT zzz_jaytest .
    Types Declaration
    TYPES : BEGIN OF ty_pa0001,
    pernr TYPE pa0001-pernr,
    bukrs TYPE pa0001-bukrs,
    werks TYPE pa0001-werks,
    END OF ty_pa0001.
    Internal Table Declaration
    DATA : i_pa0001 TYPE STANDARD TABLE OF ty_pa0001, "For pa0001 Details
    i_otf TYPE STANDARD TABLE OF itcoo, "For OTF data
    i_content_txt TYPE soli_tab, "Content
    i_content_bin TYPE solix_tab, "Content
    i_objhead TYPE soli_tab,
    Work Area Declaration
    w_pa0001 TYPE ty_pa0001, "For pa0001 Details
    w_res TYPE itcpp, "SAPscript output
    "parameters
    w_otf TYPE itcoo, "For OTF
    w_pdf TYPE solisti1, "For PDF
    w_transfer_bin TYPE sx_boolean, "Content
    w_options TYPE itcpo, "SAPscript output
    "interface
    Variable Declaration
    v_len_in TYPE so_obj_len,
    v_size TYPE i.
    Constants Declaration
    CONSTANTS : c_x TYPE c VALUE 'X', "X
    c_locl(4) TYPE c VALUE 'LOCL', "Local Printer
    c_otf TYPE sx_format VALUE 'OTF', "OTF
    c_pdf TYPE sx_format VALUE 'PDF', "PDF
    c_printer TYPE sx_devtype VALUE 'PRINTER', "PRINTER
    c_bin TYPE char10 VALUE 'BIN', "BIN
    c_name TYPE string VALUE 'C:\ZZZ_JAYTEST.PDF',"Downloading
    "File Name
    c_form(11) TYPE c VALUE 'ZZZ_JAYTEST'. "Form Name
    START-OF-SELECTION.
    Selecting the records from pa0001
    SELECT pernr bukrs werks FROM pa0001
    INTO TABLE i_pa0001 UP TO 10 ROWS.
    Setting the options
    w_options-tdcopies = 1 ."Number of copies
    w_options-tdnoprev = c_x."No print preview
    w_options-tdgetotf = c_x."Return of OTF table
    w_options-tddest = c_locl."Spool: Output device
    Opening the form
    CALL FUNCTION 'OPEN_FORM'
    EXPORTING
    form = c_form
    device = c_printer
    language = sy-langu
    OPTIONS = w_options
    IMPORTING
    RESULT = w_res.
    LOOP AT i_pa0001 INTO w_pa0001.
    Writting into the form
    CALL FUNCTION 'WRITE_FORM'
    EXPORTING
    element = 'MAIN'
    window = 'MAIN'.
    ENDLOOP.
    Closing the form
    CALL FUNCTION 'CLOSE_FORM'
    IMPORTING
    RESULT = w_res
    TABLES
    otfdata = i_otf
    EXCEPTIONS
    unopened = 1
    bad_pageformat_for_print = 2
    send_error = 3
    spool_error = 4
    codepage = 5
    OTHERS = 6.
    IF sy-subrc <> 0.
    MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
    WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
    ENDIF.
    Converting OTF data to single line
    LOOP AT i_otf INTO w_otf.
    CONCATENATE w_otf-tdprintcom w_otf-tdprintpar
    INTO w_pdf.
    APPEND w_pdf TO i_content_txt.
    ENDLOOP.
    Converting to PDF Format
    CALL FUNCTION 'SX_OBJECT_CONVERT_OTF_PDF'
    EXPORTING
    format_src = c_otf
    format_dst = c_pdf
    devtype = c_printer
    CHANGING
    transfer_bin = w_transfer_bin
    content_txt = i_content_txt
    content_bin = i_content_bin
    objhead = i_objhead
    len = v_len_in
    EXCEPTIONS
    err_conv_failed = 1
    OTHERS = 2.
    v_size = v_len_in.
    Downloading the PDF File
    CALL FUNCTION 'GUI_DOWNLOAD'
    EXPORTING
    bin_filesize = v_size
    filename = c_name
    filetype = c_bin
    TABLES
    data_tab = i_content_bin.
    The extension is put the it_mailpack-obj_name parameter of 'SO_NEW_DOCUMENT_ATT_SEND_API1'.

  • Dispalying SAP script output in landscape format

    Hello All,
    Could anyone please tell me the step by step process to display a SAP Script output in landscape format?
    Also is it possible to display a column name in 2 lines if it does not fit into 1 line.
    Regards
    Indrajit.

    Hi,
    Here is the way to print the SAPSCRIPT in landscape ..
    Goto SE71, then give you layout name then press change, then press the Header button(CAP ICON), then you will get the Header infomation, then select the Basic Settings pushbutton, then there we have an option to Print the Layout in  Portrait format or Landscapr format, then select the LANDSCAPR format Radio button then activate it
    Regards
    Sudheer

  • Sending SAP Script output as a PDF attachment through mail

    Dear Guru,
    I am using SAP 4.0B version, DATABASE Oracle 8i, OS is sun solaris 7.5.
    I want to send SAP script output as a
    PDF attachement through mail.Please suggest a solution.
    Regards,
    Rajesh

    Hi Rajesh,
    In your print program, while calling OPEN_FORM, pass options-TDGETOTF = 'X'. This is used for returning print output in OTF format.
    Then in CLOSE_FORM, get the table OTFDATA returned from the function module. for example
    DATA: OTF_DATA LIKE ITCOO OCCURS 0 WITH HEADER LINE.
        CALL FUNCTION 'CLOSE_FORM'
          IMPORTING
            RESULT  = RESULT
          TABLES
            OTFDATA = OTF_DATA.
    now you can convert this OTF data to PDF using function module CONVERT_OTF
    Then send this data as attachment to a mail using function module SO_NEW_DOCUMENT_ATT_SEND_API1
    Regards,
    Komal.

  • Download SAP Script as MS word format

    Can we download SAP Script in MS word format? If so Please suggest me the way.

    I'm not very sure on how it can be achieved, but this can help you.
    Spool to word -> http://sap4.com/codigofuente/102/396.html

  • SAP Script output extra page is coming

    Dear friends
                             In my sap script output i m getting one extra page with empty main window. Even i have  not used NEW-PAGE Command,
    No Empty lines and window size also correct. Can anyone solute for this issue.
    Regards
    Balamurugan N

    Hi,
    check those details:
    1) In your SAPSCRIPT contains one page or two pages?
    2) In the sapscript check did u assign any nextpage as different page?
    Regards,
    Dhina..

  • Displaying Page number in all pages of sap script output

    Hi All,
    I have a issues in displaying page number in all pages of sap script output.
    I have created a seperate window just above main window to display page number.
    I have given &PAGE& in the layout editor.
    Now in the sap script output i am getting page number as 1 in all the pages page number is not changing for pages-2,3, etc..
    Can anybody tell me the reason for the same!
    In some other objects same syntax is working fine. For this object it is not working!
    Is there any setting changes!
    Thanks i
    Thanks,
    Deep.

    Hi,
    Just check the Page Counter of the Next or Second Page which you defined.
    First page
    Mode                     START
    Numbering Type           ARABIC
    Second Page
    Mode                     INC
    Numbering Type           ARABIC
    Regards
    Bala Krishna
    Edited by: Bala Krishna on Oct 17, 2008 11:23 AM

  • Regarding SAP Script Output validation in Layout set

    Hi All,
    I have a issue in SAP Script Output.
    I have a <b>Standard Print Program</b>. and layout set.
    I can do validations only in Layout set.
    The actual issue is i have a <b>internal table field</b> in <b>print program</b> that i am displaying in <b>layout set</b>. Now i want it to be subtracted with number <b>20</b>, since i can not edit code in <b>Print Program</b>. i want to subtract that internal table field with 20 in layout set itself.
    Can anybody tell me how can i solve this issue.
    <b>Note:</b>  I need to do calculation only in layout set.
    Can anybody give me the solution.
    Thanks in advance.
    Thanks & Regards,
    Rayeez.

    Hi,
    Thanks for that reply.
    so with <b>SUMMING</b> command i can do calculation.
    I am already having <b>i_tab1-sum</b> coming from print program and i have declared one symbol using
    DEFINE &v_val& = 20 in layout set.
    Then i want to subtract &v_val& with &i_tab1-sum&.
    using the follow syntax tell me wether syntax is correct or not.
    SUMMING &i_tab1-sum&-&v_val& INTO &i_tab1-sum&.
    will it work.
    once again thanks for that reply.
    Thanks & Regards,
    Rayeez.

  • Can we download SAP Script to a word document  ?

    Is it possible to download the SAP Script to a local Word documnet . and then is it possible to upload the Wrd Doc back to SAP SCript with a new Script name ..?

    Hi
    Hope it will help you.
    <REMOVED BY MODERATOR>
    want to Insert SAP ICONS into from SAP into Word document (OLE) .
    (1) Copy program DD_ADD_PICTURE into your own version called ZDD_ADD_PICTURE. Make sure
    you select all the checkboxes (including GUI Status and screens).
    (2) Paste the modified code at the end of this reply into your ZZ_ADD_PICTURE program.
    (3) Run ZZ_ADD_PICTURE for a range of Icons (e.g. enter Icon name ICON_IN* on the selection screen)
    (4) When you get the result list, type in ok-code EXPO directly in the ok-code
    field (you could also add a button for this function in the GUI status).
    (5) Download all the displayed icons as .gif files into a Windows folder
    that you have created to hold the icon .gif files (e.g. C:SAPICONS)
    (6) Now you can work with the icon files as you would any .gif file. (e.g. In a Word doc, use menu path
    Insert -> Picture -> From file.)
    Here is the code:
    REPORT dd_add_picture.
    TYPE-POOLS: sdydo.
    DATA: do TYPE REF TO cl_dd_document.
    DATA: is_displayed.
    TABLES: icont.
    DATA: BEGIN OF icontab OCCURS 0.
            INCLUDE STRUCTURE icon.
    DATA: END OF icontab.
    select-options: s_icon for icontab-name obligatory.
    SELECT * FROM icon INTO TABLE icontab WHERE locked NE 'X'
                        AND name in s_icon.
    Event Handler Definition, handling changes of GUI fonts, colors,...
    CLASS cl_my_event_handler DEFINITION.
      PUBLIC SECTION.
        METHODS:
          use_new_resources FOR EVENT resources_changed OF cl_gui_resources.
    ENDCLASS.
    DATA: my_handler TYPE REF TO cl_my_event_handler.
    CREATE OBJECT my_handler.
    Call Screen
    CALL SCREEN 100.
    *&      Module  STATUS_0100  OUTPUT
    MODULE status_0100 OUTPUT.
      IF is_displayed IS INITIAL.
        SET PF-STATUS 'BRP'.
        SET HANDLER my_handler->use_new_resources.
    create document
        CREATE OBJECT do.
    fill document
        PERFORM dd_add_icon USING do.
    merge document
        CALL METHOD do->merge_document.
    display document .
        CALL METHOD do->display_document
                           EXPORTING  container          = 'HTML'
                           EXCEPTIONS html_display_error = 1.
                                           " do some exception handling ...
        is_displayed = 'X'.
      ENDIF.
    ENDMODULE.                             " STATUS_0100  OUTPUT
    MODULE user_command_0100 INPUT.
      CASE sy-ucomm.
        WHEN 'BACK'.                       "Beenden
          LEAVE PROGRAM.
        WHEN 'PRN'.
          CALL METHOD do->print_document
                  EXPORTING reuse_control = 'X'.
        WHEN 'PRN_NEW'.
          DATA text TYPE sdydo_text_element.
          CALL METHOD do->initialize_document.
          text = 'Dies Dokument wurde speziell fürs Drucken erstellt!' &
                            ' Druckdatum: '(500).
          CALL METHOD do->add_text EXPORTING
                               text         = text
                               sap_fontsize = cl_dd_area=>large.
          WRITE sy-datum TO text DD/MM/YYYY.
          CALL METHOD do->add_text EXPORTING text = text .
          CALL METHOD do->new_line EXPORTING repeat = 2.
          PERFORM dd_add_icon USING do.
          CALL METHOD do->merge_document.
          CALL METHOD do->print_document.
        WHEN 'EXPO'.
          CALL METHOD do->export_document EXPORTING to_filesystem = 'X'.
      ENDCASE.
      CLEAR sy-ucomm.
    ENDMODULE.                             " USER_COMMAND_0100  INPUT
    *&      Form  DD_ADD_ICON
          text
    FORM dd_add_icon USING p_do TYPE REF TO cl_dd_document.
      DATA ta TYPE REF TO cl_dd_table_element.
      DATA col1 TYPE REF TO cl_dd_area.
      DATA col2 TYPE REF TO cl_dd_area.
      DATA col3 TYPE REF TO cl_dd_area.
      DATA text TYPE sdydo_text_element.
    set Heading
      text = ' Bilder in Dynamischen Dokumenten'(001).
      CALL METHOD p_do->add_text EXPORTING text = text
                                      sap_style = 'heading'.
      CALL METHOD p_do->new_line.
      CALL METHOD p_do->new_line.
      CALL METHOD p_do->add_table EXPORTING with_heading    = 'X'
                                          no_of_columns     = 3
                                          width             = '100%'
                                          IMPORTING table   = ta.
    set columns
      text = 'Ikone'(011).
      CALL METHOD ta->add_column EXPORTING heading  = text
                                 IMPORTING column   = col1.
    fill table
      LOOP AT icontab.
        SELECT SINGLE * FROM icont WHERE langu = sy-langu
                                   AND   id    = icontab-id.
        CALL METHOD col1->add_icon EXPORTING sap_icon = icontab-name
                                             sap_color = 'LIST_GROUP'.
      ENDLOOP.
    ENDFORM.                               " DD_ADD_ICON
    CLASS cl_my_event_handler IMPLEMENTATION.
    CLASS cl_my_event_handler IMPLEMENTATION.
      METHOD use_new_resources.
        IF is_displayed EQ 'X'.
    initialize document
          CALL METHOD do->initialize_document.
    fill document
          PERFORM dd_add_icon USING do.
    merge document
          CALL METHOD do->merge_document.
    display document
          CALL METHOD do->display_document
                              EXPORTING reuse_control        = 'X'
                                        reuse_registration   = 'X'.
        ENDIF.
      ENDMETHOD.
    ENDCLASS.
    Edited by: Alvaro Tejada Galindo on Feb 18, 2008 6:22 PM

  • Smartform/Sap script output to Text file/PDF/WORD

    Hi,
    I need to download/transfer the output of smartforms/sap script to text file/pdf file or word file.How do i do that?
    Do I need to create a new output device?
    thnx in advance
    chirantan

    Hi,
    Go through the following Code
    Mail a sapscript
    SAPscript: Autotmatically e-mail as PDF
    How to convert sapscript(Purchage order) inot pdf format & send in  mail
    Check the following Code
    REPORT ZRICH_0003.
    DATA: ITCPO LIKE ITCPO,
          TAB_LINES LIKE SY-TABIX.
    Variables for EMAIL functionality
    DATA: MAILDATA   LIKE SODOCCHGI1.
    DATA: MAILPACK   LIKE SOPCKLSTI1 OCCURS 2 WITH HEADER LINE.
    DATA: MAILHEAD   LIKE SOLISTI1 OCCURS 1 WITH HEADER LINE.
    DATA: MAILBIN    LIKE SOLISTI1 OCCURS 10 WITH HEADER LINE.
    DATA: MAILTXT    LIKE SOLISTI1 OCCURS 10 WITH HEADER LINE.
    DATA: MAILREC    LIKE SOMLREC90 OCCURS 0  WITH HEADER LINE.
    DATA: SOLISTI1   LIKE SOLISTI1 OCCURS 0 WITH HEADER LINE.
    PERFORM SEND_FORM_VIA_EMAIL.
          FORM  SEND_FORM_VIA_EMAIL                                      *
    FORM  SEND_FORM_VIA_EMAIL.
      CLEAR:    MAILDATA, MAILTXT, MAILBIN, MAILPACK, MAILHEAD, MAILREC.
      REFRESH:  MAILTXT, MAILBIN, MAILPACK, MAILHEAD, MAILREC.
    Creation of the document to be sent File Name
      MAILDATA-OBJ_NAME = 'TEST'.
    Mail Subject
      MAILDATA-OBJ_DESCR = 'Subject'.
    Mail Contents
      MAILTXT-LINE = 'Here is your file'.
      APPEND MAILTXT.
    Prepare Packing List
      PERFORM PREPARE_PACKING_LIST.
    Set recipient - email address here!!!
      MAILREC-RECEIVER = '[email protected]'.
      MAILREC-REC_TYPE  = 'U'.
      APPEND MAILREC.
    Sending the document
      CALL FUNCTION 'SO_NEW_DOCUMENT_ATT_SEND_API1'
           EXPORTING
                DOCUMENT_DATA              = MAILDATA
                PUT_IN_OUTBOX              = ' '
           TABLES
                PACKING_LIST               = MAILPACK
                OBJECT_HEADER              = MAILHEAD
                CONTENTS_BIN               = MAILBIN
                CONTENTS_TXT               = MAILTXT
                RECEIVERS                  = MAILREC
           EXCEPTIONS
                TOO_MANY_RECEIVERS         = 1
                DOCUMENT_NOT_SENT          = 2
                OPERATION_NO_AUTHORIZATION = 4
                OTHERS                     = 99.
    ENDFORM.
         Form  PREPARE_PACKING_LIST
    FORM PREPARE_PACKING_LIST.
      CLEAR:    MAILPACK, MAILBIN, MAILHEAD.
      REFRESH:  MAILPACK, MAILBIN, MAILHEAD.
      DESCRIBE TABLE MAILTXT LINES TAB_LINES.
      READ TABLE MAILTXT INDEX TAB_LINES.
      MAILDATA-DOC_SIZE = ( TAB_LINES - 1 ) * 255 + STRLEN( MAILTXT ).
    Creation of the entry for the compressed document
      CLEAR MAILPACK-TRANSF_BIN.
      MAILPACK-HEAD_START = 1.
      MAILPACK-HEAD_NUM = 0.
      MAILPACK-BODY_START = 1.
      MAILPACK-BODY_NUM = TAB_LINES.
      MAILPACK-DOC_TYPE = 'RAW'.
      APPEND MAILPACK.
    Creation of the document attachment
    This form gets the OTF code from the SAPscript form.
    If you already have your OTF code, I believe that you may
    be able to skip this form.  just do the following code, looping thru
    your SOLISTI1 and updating MAILBIN.
      PERFORM GET_OTF_CODE.
      LOOP AT SOLISTI1.
        MOVE-CORRESPONDING SOLISTI1 TO MAILBIN.
        APPEND MAILBIN.
      ENDLOOP.
      DESCRIBE TABLE MAILBIN LINES TAB_LINES.
      MAILHEAD = 'TEST.OTF'.
      APPEND MAILHEAD.
    Creation of the entry for the compressed attachment
      MAILPACK-TRANSF_BIN = 'X'.
      MAILPACK-HEAD_START = 1.
      MAILPACK-HEAD_NUM = 1.
      MAILPACK-BODY_START = 1.
      MAILPACK-BODY_NUM = TAB_LINES.
      MAILPACK-DOC_TYPE = 'OTF'.
      MAILPACK-OBJ_NAME = 'TEST'.
      MAILPACK-OBJ_DESCR = 'Subject'.
      MAILPACK-DOC_SIZE = TAB_LINES * 255.
      APPEND MAILPACK.
    ENDFORM.
         Form  GET_OTF_CODE
    FORM  GET_OTF_CODE.
      DATA: BEGIN OF OTF OCCURS 0.
              INCLUDE STRUCTURE ITCOO .
      DATA: END OF OTF.
      DATA: ITCPO LIKE ITCPO.
      DATA: ITCPP LIKE ITCPP.
      CLEAR ITCPO.
      ITCPO-TDGETOTF = 'X'.
    Start writing OTF code
      CALL FUNCTION 'OPEN_FORM'
           EXPORTING
                FORM     = 'ZTEST_FORM'
                LANGUAGE = SY-LANGU
                OPTIONS  = ITCPO
                DIALOG   = ' '
           EXCEPTIONS
                OTHERS   = 1.
      CALL FUNCTION 'START_FORM'
           EXCEPTIONS
                ERROR_MESSAGE = 01
                OTHERS        = 02.
      CALL FUNCTION 'WRITE_FORM'
           EXPORTING
                WINDOW        = 'MAIN'
           EXCEPTIONS
                ERROR_MESSAGE = 01
                OTHERS        = 02.
    Close up Form and get OTF code
      CALL FUNCTION 'END_FORM'
           EXCEPTIONS
                ERROR_MESSAGE = 01
                OTHERS        = 02.
      MOVE-CORRESPONDING ITCPO TO ITCPP.
      CALL FUNCTION 'CLOSE_FORM'
           IMPORTING
                RESULT  = ITCPP
           TABLES
                OTFDATA = OTF
           EXCEPTIONS
                OTHERS  = 1.
    Move OTF code to structure SOLI form email
      CLEAR SOLISTI1. REFRESH SOLISTI1.
      LOOP AT OTF.
        SOLISTI1-LINE = OTF.
        APPEND SOLISTI1.
      ENDLOOP.
    ENDFORM.
    Regards
    Sreeni

  • Sap script output to pdf

    Hi All,
    I have one report prg wich gives op in sap script.
    I want same output in pdf and have to save on hard disk.
    please suggest me wat procedure i have to follow.
    It's urgent

    A very common requirement for programmers writing ABAP code for printing using SAPScript Forms is to redirect output to a PDF (Adobe Acrobat) file. I struggled for a few days trying to find a solution to this. Though I found quite a few examples on the web, it was difficult figuring out which technique was optimal. This tip is borne out of these struggles.
    This is an example of how to use ABAP code to save output of a print routine using a SAPScript form into PDF format and also display it within the SAP frontend itself. This routine proves extremely useful to provide users the ability to save local copies of output and preview it within the user-friendly Acrobat Reader control, all without leaving the SAP frontend or your program. Since function modules are used, the code is portable and this technique can be used in any other ABAP program as well.
    Two function modules, Z_DS_CREATE_LOCAL_PDF_FILE and Z_DS_CALL_PDF_VIEWER need to be created. I have used a function group called Z5_DS_PDF for this purpose. The function group contains the ABAP objects code for declaration and implementation of a class that encapsulates the Acrobat application functionality. The function group also contains a screen '0901', that epresents our PDF viewer and one PBO and one PAI block for the same screen.
    Note: The following example has been stripped of essential error-handling for the sake of simplicity and the programmer is assumed to possess knowledge of creation of function groups, function modules, screens and SAPScript forms. ABAP objects or custom controls knowledge is not mandatory. Be patient when trying this out and follow all instructions thoroughly. The results will be worth the effort.
    Steps to follow to get this example running:
    1) Create a function group (Example : Z5_DS_PDF)
    2) Define the top include and place the code listed below into it (LZ5_DS_PDFTOP)
    3) Create screen '0901' in function group with three elements:
    a) Pushbutton CLOSE at the top with function code 'CLO' (this is to exit preview screen)
    b) Custom control container (Large- spanning entire screen) named MY_CONTAINER
    c) The customary OK code field called OK_CODE
    Note: The names of the elements should be exactly as described above
    4) Create one output and one input module in the flow logic of screen '0901' for which the code is provided below
    5) Define two function modules with the following signatures:
    a) FUNCTION Z_DS_CREATE_LOCAL_PDF_FILE
    EXPORTING
    REFERENCE(AFILENAME) LIKE RLGRAP-FILENAME
    TABLES
    OTF_LINES STRUCTURE ITCOO
    b) FUNCTION Z_DS_CALL_PDF_VIEWER
    IMPORTING
    VALUE(FILENAME) TYPE STRING
    Code is provided below.
    6) Compile and activate the function group
    7) Create a simple SAPScript form with one page and one window
    8) Define one element in the text for the main window called 'HELLO' and some static text in it
    9) Check and activate the form
    10) Create the example program (Example : Z5_DS_SCRIPT2PDF) with the below code
    11) Run the example
    NOTES: I tested this code in R/3 version 4.6C but it should work in all 4.6 setups. I'm pretty sure some of the ABAP objects code I have used may not work with R/3 4.0 versions and earlier. Also, it works perfectly only when Acrobat Reader is installed on the presentation server. I have checked it with Acrobat versions 4 and 5 but I haven't had the opportunity to check it with Acrobat Reader 6.
    Code
    Code inside top include LZ5_DS_PDFTOP of function group Z5_DS_PDF
    FUNCTION-POOL Z5_DS_PDF.                    "MESSAGE-ID ..
          CLASS CL_GUI_PDF  DEFINITION                                  *
    CLASS CL_GUI_PDF DEFINITION
      INHERITING FROM CL_GUI_CONTROL.
      PUBLIC SECTION.
        TYPES:
          COL_TYPE  TYPE INT4.
        METHODS:
          CONSTRUCTOR
            IMPORTING
              !PARENT            TYPE REF TO CL_GUI_CONTAINER
              VALUE(SHELLSTYLE)  TYPE I OPTIONAL
              VALUE(DISP_MODE)   TYPE I OPTIONAL
              VALUE(LIFE_TIME)   TYPE I OPTIONAL
              VALUE(NAME)        TYPE STRING OPTIONAL
            EXCEPTIONS
              CNTL_ERROR
              CNTL_INSTALL_ERROR.
        METHODS:
          LOADFILE
            IMPORTING
              VALUE(FILENAME) TYPE STRING
            EXCEPTIONS
              FILE_NOT_FOUND.
        METHODS:
          REFRESH.
        METHODS:
          DISPATCH REDEFINITION.
    ENDCLASS.
    DATA: MY_CONTAINER TYPE REF TO CL_GUI_CUSTOM_CONTAINER.
    DATA: MY_PDF TYPE REF TO CL_GUI_PDF.
    data: ok_code like sy-ucomm.
    data: file_name type string.
    custom control class implementation
    CLASS CL_GUI_PDF IMPLEMENTATION.
      METHOD CONSTRUCTOR.
        DATA:
          CTRL_NAME(80) TYPE C.
        IF NOT CL_GUI_OBJECT=>ACTIVEX IS INITIAL.
          CTRL_NAME = '{CA8A9780-280D-11CF-A24D-444553540000}'.
        ELSE.
          RAISE CNTL_ERROR.
        ENDIF.
        CALL METHOD SUPER->CONSTRUCTOR
          EXPORTING
            CLSID        = CTRL_NAME
            SHELLSTYLE   = SHELLSTYLE
            PARENT       = PARENT
            LIFETIME     = LIFE_TIME
            NAME         = NAME
          EXCEPTIONS
            CNTL_SYSTEM_ERROR = 1
            OTHERS            = 2.
        CASE SY-SUBRC.
          WHEN 1.
            RAISE CNTL_INSTALL_ERROR.
          WHEN 2.
            RAISE CNTL_ERROR.
        ENDCASE.
        CALL METHOD CL_GUI_CFW=>SUBSCRIBE
          EXPORTING
            REF = ME
            SHELLID = ME->H_CONTROL-SHELLID
          EXCEPTIONS
            OTHERS = 1.
        IF SY-SUBRC NE 0.
          RAISE CNTL_ERROR.
        ENDIF.
      ENDMETHOD.
      METHOD LOADFILE.
        CALL METHOD ME->CALL_METHOD
          EXPORTING
            METHOD = 'LoadFile'
            P_COUNT = 1
            P1      = FILENAME.
      ENDMETHOD.
      METHOD REFRESH.
        CALL METHOD ME->CALL_METHOD
          EXPORTING
            METHOD = 'Refresh'
            P_COUNT = 0.
      ENDMETHOD.
      METHOD DISPATCH.
        CALL METHOD CL_GUI_CFW=>FLUSH.
        IF SY-SUBRC NE 0.
          RAISE CNTL_ERROR.
        ENDIF.
      ENDMETHOD.
    ENDCLASS.
    End of code for LZ5_DS_PDFTOP
    Code for Function Module Z_DS_CREATE_LOCAL_PDF_FILE
    FUNCTION Z_DS_CREATE_LOCAL_PDF_FILE .
    ""Local interface:
    *"  EXPORTING
    *"     REFERENCE(AFILENAME) LIKE  RLGRAP-FILENAME
    *"  TABLES
    *"      OTF_LINES STRUCTURE  ITCOO
      DATA: PDF_LINES
      LIKE TLINE OCCURS 1000 WITH HEADER LINE,
       ARCH LIKE TOA_DARA, NO_LINES TYPE I.
      CALL FUNCTION 'CONVERT_OTF'
           EXPORTING
                FORMAT       = 'PDF'
           IMPORTING
                BIN_FILESIZE = NO_LINES
           TABLES
                OTF          = OTF_LINES
                LINES        = PDF_LINES.
      CALL FUNCTION 'DOWNLOAD'
           EXPORTING
                BIN_FILESIZE = NO_LINES
                FILENAME     = 'c:test.pdf'
                FILETYPE     = 'BIN'
           IMPORTING
                ACT_FILENAME = AFILENAME
           TABLES
                DATA_TAB     = PDF_LINES.
    ENDFUNCTION.
    End of Code for Z_DS_CREATE_LOCAL_PDF_FILE
    Code for Function Module Z_DS_CALL_PDF_VIEWER
    FUNCTION Z_DS_CALL_PDF_VIEWER .
    ""Local interface:
    *"  IMPORTING
    *"     VALUE(FILENAME) TYPE  STRING
      FILE_NAME = FILENAME.
      IF MY_CONTAINER IS INITIAL.
        CREATE OBJECT MY_CONTAINER
                  EXPORTING
                   CONTAINER_NAME              = 'MY_CONTAINER'.
        CREATE OBJECT MY_PDF
        EXPORTING
            NAME = 'MY_PDF'
            PARENT = MY_CONTAINER.
      ENDIF.
      CALL SCREEN 901. " Ensure screen is created as per instructions
    ENDFUNCTION.
    End of Code for Z_DS_CALL_PDF_VIEWER
    Flow Logic for screen '0901'
    PROCESS BEFORE OUTPUT.
      MODULE INIT.
    PROCESS AFTER INPUT.
      MODULE USER_COMMAND_0901.
    End of Flow Logic for screen '0901'
    PBO module INIT for screen '0901'
    MODULE init OUTPUT.
        call method my_pdf->loadfile
              exporting filename = file_name.
    ENDMODULE.                 " init  OUTPUT
    End of PBO module INIT for screen '0901'
    PAI module USER_COMMAND_901 for screen '0901'
    MODULE USER_COMMAND_0901 INPUT.
    case ok_code.
    when 'CLO'.
       set screen 0.
    endcase.
    ENDMODULE.                 " USER_COMMAND_0901  INPUT
    End of PAI module USER_COMMAND_901 for screen '0901'
    Example program Z5_DS_SCRIPT2PDF
    *& Report  Z5_DS_SCRIPT2PDF                                            *
    *& This report works only if the function modules                      *
    *& Z_DS_CREATE_LOCAL_PDF_FILE and Z_DS_CALL_PDF_VIEWER already exist   *
    *& Also use an already existing simple SAPScript Form that contains a  *
    *& window "MAIN" and rework printing code if necessary, remember to    *
    *& change the output device name in OPTIONS-TDDEST                     *
    REPORT  Z5_DS_SCRIPT2PDF.
    PARAMETERS: FORM LIKE RSSCF-TDFORM DEFAULT 'Z5_DS_HELLO2'. "your form
    DATA: OTF_LINES LIKE ITCOO OCCURS 1000 WITH HEADER LINE,
          OPTIONS TYPE ITCPO, FILENAME LIKE RLGRAP-FILENAME,
          FILENAME_S TYPE STRING.
    START-OF-SELECTION.
      OPTIONS-TDDEST = 'LP01'.
    Replace 'LP01' above with your default output device
      OPTIONS-TDCOPIES = 1.
      OPTIONS-TDGETOTF = 'X'. " the key to returning OTF data
    Open the SapScript Form with the name "form"                         *
      CALL FUNCTION 'OPEN_FORM'
           EXPORTING
                FORM         = FORM    " name of form (SE71)
                OPTIONS      = OPTIONS
                DIALOG       = ' '.
    Execute the element "HELLO" in window MAIN
    - Nothing happens if /E HELLO is not declared in MAIN
      CALL FUNCTION 'WRITE_FORM'
           EXPORTING
                ELEMENT = 'HELLO'  "execute element /E HELLO
                TYPE    = 'BODY'. "normal output
    Close the current SapScript Form
      CALL FUNCTION 'CLOSE_FORM'
           TABLES
                 OTFDATA      = OTF_LINES. " Retrieve all the OTF so far
    Code for PDF Formatting and creation of local File
      CALL FUNCTION 'Z_DS_CREATE_LOCAL_PDF_FILE'
           IMPORTING
                AFILENAME = FILENAME
           TABLES
                OTF_LINES = OTF_LINES.
      FILENAME_S = FILENAME.
    Code to launch Adobe Acrobat inplace in SAPGUI
      CALL FUNCTION 'Z_DS_CALL_PDF_VIEWER'
           EXPORTING
                FILENAME = FILENAME_S.
    End of example program Z5_DS_SCRIPT2PDF

  • How to change a SAP script output without changing Print Program

    Hi,
    I want to change output of standard PO report printing object. I have to change the ZSAPSCRIPT but I have to keep the print program intact. please give me ideas.

    Hi for that you have to do following.
    1. Create a ZPROGRAM
    2. Write a Perform in your SAP Script.
    3. Write Form inside it your ZPROGRAM.
    Hope this will help you.
    <i><b>Reward points for helpful ans.</b></i>

  • How to save sap script output in  pdf document

    hi abapers
    how to save the output of sap script in sap so that can retrieve the saved document later.
    i have to save the rcia output from sap script in pdf document in sap so that it can be retrieved later
    how to use dms

    PDF Creation + connection to DMS
    cheers
    Aveek

  • SAP Script output not displayed

    Hello,
    Print preview of purchase document does not show the output. Only "test print only" is displayed on all pages.
    I can see the data passed to SAP Script in debug. The print is created using output control, ( Save or create of PO ).
    What could be the possible reason for the same?
    Even if i try to use the option of "printing test" direct from script no text elements/language are displayed.. "test print only" is displayed.
    kindly help.

    Hi,
    I am not sure what your current support pack is. This sounds like the problem described in the SAP Note:
    1243485 - Unprinted variables and lines of a SAPscript form
    Can you apply the code correction of Note #1243485?
    Regards,
    Aidan

  • SAP Script Output in Arabic Language

    Hi,
    I am running Transaction FBCJ, I am getting the output in a SAP Script in English Language. I want the same output in Arabic Language.
    Please suggest me what do I need to do, in order to get the form output in Arabic Language?
    Thanks and Regards,
    Ishaq.

    Hi
    Have you created the Script form in ARABIC language or English Language
    While creating the form in SE71 you can create in your own language and see the outputs
    or use the SE63 for texts transformation into other languages.
    If the Arabic Language is activated in the system it should come.
    Reward points if useful
    Regards
    Anji

Maybe you are looking for

  • Error while deploying composite from JDeveloper11g

    Hi , Has anyone cme across this error while trying to deploy a composite form JDev11g PS1 ? 3:41:24 PM] Error deploying archive sca_FileConverter_rev1.1.jar to soa_server1 [LSPLMGMTCH:8001] [03:41:24 PM] HTTP error code returned [500] [03:41:24 PM] E

  • Problem With Policy Agent 2.2 for APACHE on WINDOWS !!!!

    I have been getting a nasty error for weeks configuring PolicyAgent 2.2 for Apache (tried 2.2.x and 2.0.x) on a Windows Server. After the configuring apache could not even start. I get the following error : Syntax error on line 1 of "C:/Sun/Access_Ma

  • Reading Text File from selection Screen and populating table (Urgent)

    Hi All, I have some requirment like i in my report i have to initial my Input feild from text file is it good to populate a internal table or range. I have three feild in a excel file that entry can more then 500 data example Matnr Date             D

  • Failed formatting

    Does anybody know what the following message means? "Formatting was not successful. The image exceeds the maximum allowed size for a dual-layer configuration. What does it mean by IMAGE? Thanks Javp powermac g5   Mac OS X (10.3.9)   dual 2 GHz, 2 GB

  • Wireless USB Connection

    What is the best Wireless USB Dongle on the market that is compatible with the BT Home Hub 20.0? - I have a remote desktop PC in a beroom upstairs and the HH2.0 Iis downstairs.