Convert report to MsWord

can i convert report to MSWORD97/2000
How can i do that? Please make your answers in steps (first,second....etc).
null

hello,
you can use the destination format RTF to create a word-compatible outout.
run your report with DESTFORMAT=RTF
regards,
the oracle reports team

Similar Messages

  • Converting report to PDF and mailing

    Hi every one,
    I've gone through various threads and i'm aware of the Functional module's used to
    convert the report to pdf and mail it back.Like CONVERT_OTFSPOOLJOB_2_PDF, CONVERT_OTF_2_PDF and for mailing we have SEND_NEW_DOCUMENT_ATT_SEND_API1.
    I've worked with this but my problem is i'm not able to convet the report output to pdf.When i'm doing this i'm getting the output of my functional module converted to pdf like the number of header and item records available for the given data in the selection screen.
    Since all the threads i've gone through is converting the single internal table which has the output to pdf.
    But i've got the REUSE_ALV_HIERSQL_LIST_DISPLAY, hierarchial report which as known has got two internal tables.How to the same to this kind of report....More over is it possible to convert report to pdf in online without transfering it to spool and getting the spool id to convert it to pdf.........
    Any help or suggestions will surely be rewarded......
    Thanks in Advance.....

    Here is the complete code for you;
    It Converts spool request into PDF document and emails it.
    <b>http://www.sapdevelopment.co.uk/reporting/rep_spooltopdf.htm</b>
    Regards,
    Vishal

  • Convert report from SAP to Excel

    Hi All,
    How to convert report from SAP to Excel.Here now taking default text(.txt) format.But we want defualt taking (.xls) format only.
    Regards
    Usha

    hi usha
    u can even export the text in txt format and later right click and open with excel , u wont be able to directly import it into excel as it is not giving u any option to upload in excel directly
    Regards,
    Manish

  • Converting Report into excel file

    Hello everybody
    i want to convert report output into excel format(in csv format) without using
    delimeted feature of Reports 6i. how can i do it.I have done it in Forms 6i using
    text_io package, but i'm unable to find exact query after running report.
    Thx in advance
    v k ravi (Noida,India)

    can you send me a copy of your rdf?
    tks....
    Hi Ravi
    its so simple. send a test mail to [email protected]
    i will send u the rdf.
    Thank you
    Sasi

  • How to convert report to PDF format

    Hi,
    Please let me know the procedure to convert reports into PDF format.
    Thanks in Advance
    Irfan Hussain

    Refer these links
    http://www.sap-img.com/bc037.htm
    http://www.members.tripod.com/abap4/Save_Report_Output_to_a_PDF_File.html
    <b>CONVERT_ABAPSPOOLJOB_2_PDF</b> FM convert abap spool output to PDF

  • Convert report from 4.6c to 4.0b

    I want to convert report from 4.6c to 4.0B ..can somebody tell me the steps or coding i shud do for that.The output shud b same of that report.
    How can I do that??

    hi hARISH,
    what I would do is to copy the report into 4.0B (one to one) and would do a syntax check. If there are errors, I would correct. Of course if such FMs are called which don't exist in 4.0B you could be in trouble and have to look for a workaround.
    hope this helps
    ec
    Message was edited by:
            Eric Cartman

  • Convert report writer to report painter

    Hi,
    Please advice how to convert report writer to report painter.
    I have used GR31 to create a report writer but I need to convert it to a report painter as in GRR3.

    Hi!
    Fortunately report writer programs are ABAP programs. You can figure out their names in the following way:
    GR55 - Enter the name of the report group, you wanted to modify - press F8.
    On the selection screen choose Environment - Technical data, you'll see the program names here.
    They seem like this:
    GPCV74T2WBUPA9V6K6M86563YM7040
    GPCXBUYEUX830Y0CQQTVVO0FLRZ040
    GPCZGL3QTILGRM5IXB1JL6UR8XR040
    GPCT2ENQXQHBJLQ0DMEKGMBSBGF040
    Simply copy them... But don't forget, after you copy the report, all change in the GR55 will not get into the copyed programs.
    Regards
    Tamá

  • Convert reports 2.5 to 6i

    can i convert reports 2.5 to 6i directly by recompling?
    thanx
    Ganpat

    Ganapathy,
    You just have to open the 2.5 report into 6i report builder and it will do the conversion part and then you can compile and create the executables, and you are good to go.
    -Amandeep

  • Parameters into Answer Report and MsWord

    Hi,
    I'm try to invoque a Answer Report in MsWord, by Oracle Publisher, and i need to create a template.
    So, i have a principal document and this document have a subtemplate. I need insert into the Template
    one chart designed with Answer's tools, but this chart needs to receive a parameter to deploy the information
    into a cicle for example:
    group 1
    text 1
    text 2
    text 3
    group 2
    text 4
    text 5
    I don't know how the chart receive an in parameter?, because the chart don't allow to manipulate into MsWord...
    Thank's for your help!
    Sandra M. Salazar J.

    Hi,
    The following solution works for sharing parameters in CR Designer 2008. However, I am not sure if this can work with CR4E Designer. Request you to perform the mentioned steps in  CR4E :
    1.  Click a main report with surbreport
    2.  Create a parameter in main report
    3. Right-Click  on subreport and select "Change Subreport Links"
    4. Select 'Parameter' in Available Fields -> Fields to link to
    5. Click Ok
    6. Click Edit Subreport and drag the parameter field in the 'Details' section of your subreport.
    Now run the main report, it will ask you for a prompt. The same parameter will be displayed in your subreport.
    Hope this works for your cause.
    Regards,
    Shreyans

  • How to convert report into alvgrid please hepl

    how to convert report into alvgrid please hepl

    BALVSD01 check this program u will know r see below code
    sample prog
    REPORT  ZMAT11                                  .
    TYPE-POOLS : slis.
    TABLES : mkpf,
             mseg,
             t001w,
             t001l.
    TYPES : BEGIN OF ty_t001w,
              werks TYPE t001w-werks,
              name1 TYPE t001w-name1,
            END OF ty_t001w,
            BEGIN OF ty_makt,
              matnr TYPE makt-matnr,
              maktx TYPE makt-maktx,
            END OF ty_makt,
            BEGIN OF ty_t001l,
              lgort TYPE t001l-lgort,
              lgobe TYPE t001l-lgobe,
            END OF ty_t001l.
    DATA :  BEGIN OF it_mat OCCURS 0,
            mblnr LIKE mseg-mblnr,
            zeile LIKE mseg-zeile,
            mjahr LIKE mseg-mjahr,
            bldat LIKE mkpf-bldat,
            budat LIKE mkpf-budat,
            bwart LIKE mseg-bwart,
            matnr LIKE mseg-matnr,
            maktx LIKE makt-maktx,
            erfmg LIKE mseg-erfmg,
            erfme LIKE mseg-erfme,
            werks LIKE mseg-werks,
            name1 LIKE t001w-name1,
            lgort LIKE mseg-lgort,
            lgobe LIKE t001l-lgobe,
            umwrk LIKE mseg-umwrk,
            name2 LIKE t001w-name1,
            umlgo LIKE mseg-umlgo,
            lgobe1 LIKE t001l-lgobe,
            END OF it_mat.
    DATA : it_t001w TYPE TABLE OF ty_t001w
                     WITH HEADER LINE,
           it_makt TYPE TABLE OF ty_makt
                   WITH HEADER LINE,
           it_t001l TYPE TABLE OF ty_t001l
                    WITH HEADER LINE.
    DATA : ls_layout TYPE slis_layout_alv,
           it_fcat TYPE slis_t_fieldcat_alv ,
           wa_fcat TYPE slis_fieldcat_alv,
           lh TYPE slis_t_listheader,
           ls TYPE slis_listheader,
           it_events TYPE slis_t_event  ,
           ls_event TYPE slis_alv_event ,
           w_var TYPE i.
    DATA : l_date(10).
    DATA : l_date1(20),
           ztabix LIKE sy-tabix.
    DATA : l_repid LIKE trdir-name.
    l_repid = 'ZMAT11'.
    SELECTION-SCREEN BEGIN OF BLOCK b1 WITH FRAME TITLE text-001.
    SELECT-OPTIONS : s_werks FOR mseg-werks,
                     s_lgort FOR mseg-lgort,
                     s_umwrk FOR mseg-umwrk,
                     s_umlgo FOR mseg-umlgo,
                     s_bwart FOR mseg-bwart,
                     s_budat FOR mkpf-budat,
                     s_mjahr FOR mkpf-mjahr.
    SELECTION-SCREEN END OF BLOCK b1.
    AT SELECTION-SCREEN.
      SELECT SINGLE * FROM t001w INTO t001w
                              WHERE werks IN s_werks.
      IF sy-subrc <> 0.
        MESSAGE e000(8i) WITH 'Enter a Valid Supplying Plant'.
      ENDIF.
      SELECT SINGLE * FROM t001w INTO t001w
                              WHERE werks IN s_umwrk.
      IF sy-subrc <> 0.
        MESSAGE e000(8i) WITH 'Enter a Valid Receiving Plant'.
      ENDIF.
      SELECT SINGLE * FROM t001l INTO t001l
                              WHERE lgort IN s_lgort.
      IF sy-subrc <> 0.
        MESSAGE e000(8i) WITH 'Enter a Valid Supplying St.Loc'.
      ENDIF.
      SELECT SINGLE * FROM t001l INTO t001l
                              WHERE lgort IN s_umlgo.
      IF sy-subrc <> 0.
        MESSAGE e000(8i) WITH 'Enter a Valid Receiving St.Loc'.
      ENDIF.
    START-OF-SELECTION.
      ls-typ = 'H'.
      ls-info = 'Material Document List'.
      APPEND ls TO lh.
      ls-typ = 'S'.
      WRITE: sy-datum TO l_date USING EDIT MASK '__/__/____'.
      CONCATENATE 'DATE :' l_date INTO l_date1 SEPARATED BY space.
      ls-info = l_date1.
      APPEND ls TO lh.
      PERFORM field_cat.
      PERFORM f001_get_data.
    END-OF-SELECTION.
      IF it_mat[] IS INITIAL.
        MESSAGE i000(8i) WITH 'No data Found'(m01).
        EXIT.
      ENDIF.
      PERFORM process_data.
      PERFORM display_data.
    *&      Form  f001_get_data
          text
    -->  p1        text
    <--  p2        text
    FORM f001_get_data .
      SELECT amblnr azeile amjahr abwart a~matnr
               aerfmg aerfme awerks algort aumwrk aumlgo
               b~budat
               b~bldat INTO CORRESPONDING FIELDS OF TABLE it_mat
                       FROM mseg AS a
                 INNER JOIN mkpf AS b
                    ON amblnr = bmblnr
                   AND amjahr = bmjahr
                 CLIENT SPECIFIED
              WHERE a~mandt EQ sy-mandt
                AND a~werks IN s_werks
                AND a~lgort IN s_lgort
                AND a~umwrk IN s_umwrk
                AND a~umlgo IN s_umlgo
                AND a~bwart IN s_bwart
                AND b~budat IN s_budat
                AND b~mjahr IN s_mjahr.
      IF sy-subrc = 0.
        SELECT matnr maktx INTO TABLE it_makt FROM makt
        CLIENT SPECIFIED
        FOR ALL ENTRIES IN it_mat
        WHERE mandt EQ sy-mandt
          AND matnr = it_mat-matnr.
      ENDIF.
      SELECT werks name1 INTO TABLE it_t001w FROM t001w
      CLIENT SPECIFIED
      WHERE mandt EQ sy-mandt.
      IF sy-subrc <> 0.
        MESSAGE i000(8i) WITH 'No Plant Found'(m02).
      ENDIF.
      SELECT lgort lgobe INTO TABLE it_t001l FROM t001l
      CLIENT SPECIFIED
      WHERE mandt EQ sy-mandt.
      IF sy-subrc <> 0.
        MESSAGE i000(8i) WITH 'No Storage Location Found'(m03).
      ENDIF.
    ENDFORM.                    " f001_get_data
    *&      Form  field_cat
          text
    -->  p1        text
    <--  p2        text
    FORM field_cat .
      wa_fcat-col_pos = w_var.
      wa_fcat-tabname = 'IT_MAT'.
      wa_fcat-fieldname = 'MBLNR'.
      wa_fcat-key = 'X'.
      wa_fcat-hotspot = 'X'.
      wa_fcat-ref_fieldname = 'MBLNR'.
      wa_fcat-ref_tabname = 'MSEG'.
      wa_fcat-seltext_m = 'Material Doc'.
      APPEND wa_fcat TO it_fcat.
      CLEAR wa_fcat.
      ADD 1 TO w_var.
      wa_fcat-col_pos = w_var.
      wa_fcat-tabname = 'IT_MAT'.
      wa_fcat-fieldname = 'ZEILE'.
      wa_fcat-ref_fieldname = 'ZEILE'.
      wa_fcat-ref_tabname = 'MSEG'.
      wa_fcat-seltext_m = 'Item No'.
      APPEND wa_fcat TO it_fcat.
      CLEAR wa_fcat.
      ADD 1 TO w_var.
      wa_fcat-col_pos = w_var.
      wa_fcat-tabname = 'IT_MAT'.
      wa_fcat-fieldname = 'MJAHR'.
      wa_fcat-ref_fieldname = 'MJAHR'.
      wa_fcat-ref_tabname = 'MSEG'.
      APPEND wa_fcat TO it_fcat.
      CLEAR wa_fcat.
      ADD 1 TO w_var.
      wa_fcat-col_pos = w_var.
      wa_fcat-tabname = 'IT_MAT'.
      wa_fcat-fieldname = 'BWART'.
      wa_fcat-ref_fieldname = 'BWART'.
      wa_fcat-ref_tabname = 'MSEG'.
      wa_fcat-seltext_m = 'Mvmt Type'.
      APPEND wa_fcat TO it_fcat.
      CLEAR wa_fcat.
      ADD 1 TO w_var.
      wa_fcat-col_pos = w_var.
      wa_fcat-tabname = 'IT_MAT'.
      wa_fcat-fieldname = 'BLDAT'.
      wa_fcat-ref_fieldname = 'BLDAT'.
      wa_fcat-ref_tabname = 'MKPF'.
      wa_fcat-seltext_m = 'Document Date'.
      APPEND wa_fcat TO it_fcat.
      CLEAR wa_fcat.
      ADD 1 TO w_var.
      wa_fcat-col_pos = w_var.
      wa_fcat-tabname = 'IT_MAT'.
      wa_fcat-fieldname = 'BUDAT'.
      wa_fcat-ref_fieldname = 'BUDAT'.
      wa_fcat-ref_tabname = 'MKPF'.
      wa_fcat-seltext_m = 'Posting Date'.
      APPEND wa_fcat TO it_fcat.
      CLEAR wa_fcat.
      ADD 1 TO w_var.
      wa_fcat-col_pos = w_var.
      wa_fcat-tabname = 'IT_MAT'.
      wa_fcat-fieldname = 'MATNR'.
      wa_fcat-ref_fieldname = 'MATNR'.
      wa_fcat-ref_tabname = 'MSEG'.
      wa_fcat-seltext_m = 'Material No'.
      APPEND wa_fcat TO it_fcat.
      CLEAR wa_fcat.
      ADD 1 TO w_var.
      wa_fcat-col_pos = w_var.
      wa_fcat-tabname = 'IT_MAT'.
      wa_fcat-fieldname = 'MAKTX'.
      wa_fcat-ref_fieldname = 'MAKTX'.
      wa_fcat-ref_tabname = 'MAKT'.
      wa_fcat-seltext_m = 'Material Description'.
      APPEND wa_fcat TO it_fcat.
      CLEAR wa_fcat.
      ADD 1 TO w_var.
      wa_fcat-col_pos = w_var.
      wa_fcat-tabname = 'IT_MAT'.
      wa_fcat-fieldname = 'ERFMG'.
      wa_fcat-ref_fieldname = 'ERFMG'.
      wa_fcat-ref_tabname = 'MSEG'.
      wa_fcat-seltext_m = 'Quantity'.
      wa_fcat-do_sum = 'X'.
      APPEND wa_fcat TO it_fcat.
      CLEAR wa_fcat.
      ADD 1 TO w_var.
      wa_fcat-col_pos = w_var.
      wa_fcat-tabname = 'IT_MAT'.
      wa_fcat-fieldname = 'ERFME'.
      wa_fcat-ref_fieldname = 'ERFME'.
      wa_fcat-ref_tabname = 'MSEG'.
      wa_fcat-seltext_m = 'Uom'.
      APPEND wa_fcat TO it_fcat.
      CLEAR wa_fcat.
      ADD 1 TO w_var.
      wa_fcat-col_pos = w_var.
      wa_fcat-tabname = 'IT_MAT'.
      wa_fcat-fieldname = 'WERKS'.
      wa_fcat-seltext_m = 'Supplying Plant'.
      APPEND wa_fcat TO it_fcat.
      CLEAR wa_fcat.
      ADD 1 TO w_var.
      wa_fcat-col_pos = w_var.
      wa_fcat-tabname = 'IT_MAT'.
      wa_fcat-fieldname = 'NAME1'.
      wa_fcat-seltext_m = 'S.Plnt Desc.'.
      APPEND wa_fcat TO it_fcat.
      CLEAR wa_fcat.
      ADD 1 TO w_var.
      wa_fcat-col_pos = w_var.
      wa_fcat-tabname = 'IT_MAT'.
      wa_fcat-fieldname = 'LGORT'.
      wa_fcat-seltext_m = 'Supplying St.Loc'.
      APPEND wa_fcat TO it_fcat.
      CLEAR wa_fcat.
      ADD 1 TO w_var.
      wa_fcat-col_pos = w_var.
      wa_fcat-tabname = 'IT_MAT'.
      wa_fcat-fieldname = 'LGOBE'.
      wa_fcat-seltext_m = 'Su.St.Loc Desc.'.
      APPEND wa_fcat TO it_fcat.
      CLEAR wa_fcat.
      ADD 1 TO w_var.
      wa_fcat-col_pos = w_var.
      wa_fcat-tabname = 'IT_MAT'.
      wa_fcat-fieldname = 'UMWRK'.
      wa_fcat-seltext_m = 'Receiving Plant'.
      APPEND wa_fcat TO it_fcat.
      CLEAR wa_fcat.
      ADD 1 TO w_var.
      wa_fcat-col_pos = w_var.
      wa_fcat-tabname = 'IT_MAT'.
      wa_fcat-fieldname = 'NAME2'.
      wa_fcat-seltext_m = 'R.Plnt Desc.'.
      APPEND wa_fcat TO it_fcat.
      CLEAR wa_fcat.
      ADD 1 TO w_var.
      wa_fcat-col_pos = w_var.
      wa_fcat-tabname = 'IT_MAT'.
      wa_fcat-fieldname = 'UMLGO'.
      wa_fcat-seltext_m = 'Receiving St.Loc'.
      APPEND wa_fcat TO it_fcat.
      CLEAR wa_fcat.
      ADD 1 TO w_var.
      wa_fcat-col_pos = w_var.
      wa_fcat-tabname = 'IT_MAT'.
      wa_fcat-fieldname = 'LGOBE1'.
      wa_fcat-seltext_m = 'Re.St.Loc Desc.'.
      APPEND wa_fcat TO it_fcat.
      CLEAR wa_fcat.
      ADD 1 TO w_var.
    ENDFORM.                    " field_cat
    *&      Form  process_data
          text
    -->  p1        text
    <--  p2        text
    FORM process_data .
      LOOP AT it_mat.
        ztabix = sy-tabix.
        READ TABLE it_makt WITH KEY matnr = it_mat-matnr.
        IF sy-subrc = 0.
          it_mat-maktx = it_makt-maktx.
        ENDIF.
        IF it_mat-bwart+2(1) = '2'.
          it_mat-erfmg = - ( it_mat-erfmg ).
        ENDIF.
        READ TABLE it_t001w WITH KEY werks = it_mat-werks.
        IF sy-subrc = 0.
          it_mat-name1 = it_t001w-name1.
        ENDIF.
        READ TABLE it_t001w WITH KEY werks = it_mat-umwrk.
        IF sy-subrc = 0.
          it_mat-name2 = it_t001w-name1.
        ENDIF.
        READ TABLE it_t001l WITH KEY lgort = it_mat-lgort.
        IF sy-subrc = 0.
          it_mat-lgobe = it_t001l-lgobe.
        ENDIF.
        READ TABLE it_t001l WITH KEY lgort = it_mat-umlgo.
        IF sy-subrc = 0.
          it_mat-lgobe1 = it_t001l-lgobe.
        ENDIF.
        MODIFY it_mat INDEX ztabix .
      ENDLOOP.
    ENDFORM.                    " process_data
    *&      Form  display_data
          text
    -->  p1        text
    <--  p2        text
    FORM display_data .
      CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
       EXPORTING
              I_INTERFACE_CHECK                 = ' '
              I_BYPASSING_BUFFER                = ' '
              I_BUFFER_ACTIVE                   = ' '
               i_callback_program                = l_repid
              I_CALLBACK_PF_STATUS_SET          = ' '
               i_callback_user_command           = 'LINE'
               i_callback_top_of_page            = 'TOP'
              I_CALLBACK_HTML_TOP_OF_PAGE       = ' '
              I_CALLBACK_HTML_END_OF_LIST       = ' '
              I_STRUCTURE_NAME                  =
              I_BACKGROUND_ID                   = ' '
              I_GRID_TITLE                      =
              I_GRID_SETTINGS                   =
              IS_LAYOUT                         =
               it_fieldcat                       = it_fcat
              IT_EXCLUDING                      =
              IT_SPECIAL_GROUPS                 =
              IT_SORT                           =
              IT_FILTER                         =
              IS_SEL_HIDE                       =
              I_DEFAULT                         = 'X'
              I_SAVE                            = ' '
              IS_VARIANT                        =
              it_events                         =
              IT_EVENT_EXIT                     =
              IS_PRINT                          =
              IS_REPREP_ID                      =
              I_SCREEN_START_COLUMN             = 0
              I_SCREEN_START_LINE               = 0
              I_SCREEN_END_COLUMN               = 0
              I_SCREEN_END_LINE                 = 0
              IT_ALV_GRAPHICS                   =
              IT_HYPERLINK                      =
              IT_ADD_FIELDCAT                   =
              IT_EXCEPT_QINFO                   =
              I_HTML_HEIGHT_TOP                 =
              I_HTML_HEIGHT_END                 =
            IMPORTING
              E_EXIT_CAUSED_BY_CALLER           =
              ES_EXIT_CAUSED_BY_USER            =
              TABLES
                t_outtab                          = it_mat
            EXCEPTIONS
              PROGRAM_ERROR                     = 1
              OTHERS                            = 2
      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.                    " display_data
    *&      Form  TOP
          text
    FORM top.
      CALL FUNCTION 'REUSE_ALV_COMMENTARY_WRITE'
        EXPORTING
          it_list_commentary       = lh
      I_LOGO                   =
      I_END_OF_LIST_GRID       =
    ENDFORM.                    "TOP

  • Convert Report Program to PDF file

    Hi All,
    I need example of converting Report program to PDF file.
    I am beginner so please give simple example to understand it properly ..
    Please write the description along with the code so that i can understand it...
    no long long programs please.
    Thanks.
    Raj

    Hi,
    report zabap_2_pdf.
    *-- Enhancements: only allow to be run with variant.  Then called
    *-- program will be transparent to users
    *-- TABLES
    tables:
      tsp01.
    *-- STRUCTURES
    data:
      mstr_print_parms like pri_params,
      mc_valid(1)      type c,
      mi_bytecount     type i,
      mi_length        type i,
      mi_rqident       like tsp01-rqident.
    *-- INTERNAL TABLES
    data:
      mtab_pdf    like tline occurs 0 with header line,
      mc_filename like rlgrap-filename.
    *-- SELECTION SCREEN
    parameters:
      p_repid like sy-repid, " Report to execute
      p_linsz like sy-linsz default 132, " Line size
      p_paart like sy-paart default 'X_65_132'.  " Paper Format
    start-of-selection.
    concatenate 'c:'
                p_repid
                '.pdf'
      into mc_filename.
    *-- Setup the Print Parmaters
      call function 'GET_PRINT_PARAMETERS'
       exporting
         authority= space
         copies   = '1'
         cover_page                   = space
         data_set = space
         department                   = space
         destination                  = space
         expiration                   = '1'
         immediately                  = space
         in_archive_parameters        = space
         in_parameters                = space
         layout   = space
         mode     = space
         new_list_id                  = 'X'
         no_dialog= 'X'
         user     = sy-uname
       importing
         out_parameters               = mstr_print_parms
         valid    = mc_valid
       exceptions
         archive_info_not_found       = 1
         invalid_print_params         = 2
         invalid_archive_params       = 3
         others   = 4.
    *-- Make sure that a printer destination has been set up
    *-- If this is not done the PDF function module ABENDS
      if mstr_print_parms-pdest = space.
        mstr_print_parms-pdest = 'LOCL'.
      endif.
    *-- Explicitly set line width, and output format so that
    *-- the PDF conversion comes out OK
      mstr_print_parms-linsz = p_linsz.
      mstr_print_parms-paart = p_paart.
      submit (p_repid) to sap-spool without spool dynpro
                       spool parameters mstr_print_parms
                       via selection-screen
                       and return.
    *-- Find out what the spool number is that was just created
      perform get_spool_number using sy-repid
                 sy-uname
        changing mi_rqident.
    *-- Convert Spool to PDF
      call function 'CONVERT_ABAPSPOOLJOB_2_PDF'
        exporting
          src_spoolid= mi_rqident
          no_dialog  = space
          dst_device = mstr_print_parms-pdest
        importing
          pdf_bytecount                  = mi_bytecount
        tables
          pdf        = mtab_pdf
        exceptions
          err_no_abap_spooljob           = 1
          err_no_spooljob                = 2
          err_no_permission              = 3
          err_conv_not_possible          = 4
          err_bad_destdevice             = 5
          user_cancelled                 = 6
          err_spoolerror                 = 7
          err_temseerror                 = 8
          err_btcjob_open_failed         = 9
          err_btcjob_submit_failed       = 10
          err_btcjob_close_failed        = 11
          others     = 12.
    call function 'DOWNLOAD'
         exporting
              bin_filesize            = mi_bytecount
              filename                = mc_filename
              filetype                = 'BIN'
         importing
              act_filename            = mc_filename
         tables
              data_tab                = mtab_pdf.
    *       FORM get_spool_number *
    *       Get the most recent spool created by user/report              *
    *  -->  F_REPID               *
    *  -->  F_UNAME               *
    *  -->  F_RQIDENT             *
    form get_spool_number using f_repid
         f_uname
                    changing f_rqident.
      data:
        lc_rq2name like tsp01-rq2name.
      concatenate f_repid+0(8)
                  f_uname+0(3)
        into lc_rq2name separated by '_'.
      select * from tsp01 where  rq2name = lc_rq2name
      order by rqcretime descending.
        f_rqident = tsp01-rqident.
        exit.
      endselect.
      if sy-subrc ne 0.
        clear f_rqident.
      endif.
    endform." get_spool_number
    Regards
    Sudheer

  • Formate Conversion: From Reports to Msword Format

    Hi all
    I am using oracle 9i reports. I generate one report and the out put in rtf format. when run this report and get the out put in file and can see by double click on it and its going open in Msword automatically. my problem start when i run this report from the forms using the run_report object and then suing web.show_documents to see the report in word. its working fine but every time it ask me the editor where i have to open this file. so i have to select Msword then its open. My all users can not do this one. so is there any way that it should be open automatically with out asking.
    here is my code
    WEB.SHOW_DOCUMENT('/reports/rwservlet/getjobid'||substr(v_rep,instr(v_rep,'_',-1)+1)|| '?'||'server=' || :global.reportserver,'_blank');          
    and in my report object property i have set all the property that the format is rtf
    Thanks

    I believe that is not possible. When getting a RTF document from a web site, Internet Explorer always asks you if you want to open or save the file. The file cannot be viewed directly in IE. That has to do with the fact that MS Word has to convert the RTF file first before it can be displayed.
    There may be IE plugins on Internet that can directly view RTF files in the browser, but I'm not sure.
    Another option is to use PDF instead of RTF. PDF can be viewed directly in the browser.

  • Convert data to MSWORD, MSEXCEL or PDF

    Hi,
    I have a requirement of sending SAP std report output as an attachment via email. I am thinking of using SUBMIT TO MEMORY or SPOOL and then get the data from there and convert and send as file attachment using SO_DOCUMENT_SEND_API1 or class CL_BCS. The file is required to be sent as MSWORD or MSEXCEL or PDF which can be decided by having a parameter on selection screen..
    But I am not sure on how to convert data after retrieving it back from Memory or spool. There are a few function modules to convert. Can anyone give me the names please in each case like
    For Spool to PDF function CONVERT_ABAPSPOOLJOB_2_PDF can be used
    For Spool to Excel ?
    For Spool to Word ?
    For memory to PDF ?
    For memory to Word ?
    For memory to Excel ?
    Regards,
    Vin

    Hi,
    I just had the same reuirement and i did it few days back . here is the code ...juz modify it accordingly.
    The program will send my ABAP report as a PDF attachment to the USER>
    REPORT  ZRMM0055  NO STANDARD PAGE HEADING
                      MESSAGE-ID ZZ
                      LINE-SIZE 255
                      LINE-COUNT 65.
                        TABLES DECLARATION                               *
    TABLES : MARD,          " Storage Location Data for Material
             MARC,          " Plant Data for Material
             MSEG,
             SSCRFIELDS.    " Fields on selection screens
                       Internal Tables declaration.                      *
    *---Internal Table to hold the MARD table data
    DATA : BEGIN OF IT_MARD OCCURS 0,
           MATNR LIKE MARD-MATNR,          " Material Number
           WERKS LIKE MARD-WERKS,          " Plant
           LGORT LIKE MARD-LGORT,          " Storage Location
           LMINB LIKE MARD-LMINB,          " Reorder Point
           LABST LIKE MARD-LABST,          " Stock at storage loc
           END OF IT_MARD.
    *---Internal table to hold data from MSEG, MKPF, MAKT
    DATA : BEGIN OF IT_MSEG OCCURS 0,
           MATNR LIKE MARD-MATNR,          " Material Number
           WERKS LIKE MARD-WERKS,          " Plant
           LGORT LIKE MARD-LGORT,          " Storage Location
           MENGE LIKE MSEG-MENGE,          " Quantity
           MEINS LIKE MSEG-MEINS,          " UOM
           LIFNR LIKE MSEG-LIFNR,          " Account Number of Vendor
           SHKZG LIKE MSEG-SHKZG,          " Credit/Debit Indicator
           EBELN LIKE EKPO-EBELN,
           MENGE1 LIKE EKPO-MENGE,         " Open PO qty
           EINDT LIKE EKET-EINDT,
           DISPO LIKE MARC-DISPO,          " MRP controller
           EKGRP LIKE MARC-EKGRP,          " Purchasing Group
           MAKTX LIKE MAKT-MAKTX,
           END OF IT_MSEG.
    *----Internal table to hold the data from EKPO and EKET table
    DATA : BEGIN OF IT_EKPO OCCURS 0,
           EBELN LIKE EKPO-EBELN,          " PO document
           EBELP LIKE EKPO-EBELP,          " Item
           MATNR LIKE MARD-MATNR,          " Material Number
           WERKS LIKE MARD-WERKS,          " Plant
           LGORT LIKE MARD-LGORT,          " Storage Location
           MENGE LIKE EKPO-MENGE,          " Quantity
           EINDT LIKE EKET-EINDT,          " Delivery Date
           END OF IT_EKPO.
    *--Internal Table to hold the final data
    DATA : BEGIN OF IT_FINAL OCCURS 0,
           MATNR LIKE MARD-MATNR,          " Material Number
           MAKTX LIKE MAKT-MAKTX,          " Material Description
           LMINB LIKE MARD-LMINB,          " Reorder Point
           MEINS LIKE MSEG-MEINS,          " UOM
           LABST LIKE MARD-LABST,          " On hand inventory at storageloc
           TOT_LABST LIKE MARD-LABST,      " Total On hand at plant
           ISSUE LIKE MSEG-MENGE,          " YTD issue
           RECEIPT LIKE MSEG-MENGE,        " YTD receipts
           DISPO LIKE MARC-DISPO,          " MRP controller
           EKGRP LIKE MARC-EKGRP,          " Purchasing Group
           MENGE LIKE EKPO-MENGE,          " Open PO Quantity
           EINDT LIKE EKET-EINDT,          " Next Delivery Date
           LIFNR LIKE MSEG-LIFNR,          " Vendor
           EBELN LIKE MSEG-EBELN,          " PO number
           END OF IT_FINAL.
    *----Internal table to hold YTD data
    DATA : BEGIN OF IT_YTD OCCURS 0,
           MENGE LIKE MSEG-MENGE,
           MEINS LIKE MSEG-MEINS,
           SHKZG LIKE MSEG-SHKZG,
           END OF IT_YTD.
    DATA : BEGIN OF X_MSEG,
           MBLNR LIKE MSEG-MBLNR,
           MJAHR LIKE MSEG-MJAHR,
           MATNR LIKE MARD-MATNR,          " Material Number
           WERKS LIKE MARD-WERKS,          " Plant
           LGORT LIKE MARD-LGORT,          " Storage Location
           MENGE LIKE MSEG-MENGE,          " Quantity
           MEINS LIKE MSEG-MEINS,          " UOM
           LIFNR LIKE MSEG-LIFNR,          " Account Number of Vendor
           SHKZG LIKE MSEG-SHKZG,          " Credit/Debit Indicator
           EBELN LIKE EKPO-EBELN,
           MENGE1 LIKE EKPO-MENGE,         " Open PO Qty
           EINDT LIKE EKET-EINDT,
           DISPO LIKE MARC-DISPO,          " MRP controller
           EKGRP LIKE MARC-EKGRP,          " Purchasing Group
           MAKTX LIKE MAKT-MAKTX,
           END OF X_MSEG.
    DATA: V_LMINB(16) TYPE C,
          S_LABST(16) TYPE C,
          V_TOT_LABST(16) TYPE C,
          S_ISSUE(16) TYPE C,
          S_RECEIPT(16) TYPE C,
          V_MENGE(16) TYPE C,
          V_EINDT(8) TYPE C.
    DATA: T_PDF LIKE TLINE OCCURS 100 WITH HEADER LINE.
                    VARIABLES DECLARATION                                *
    DATA : V_SUM TYPE MSEG-MENGE,      " Variable for adding GI's to Stock
           V_TEMP TYPE MSEG-MENGE,      " Variable for adding GI's to Stock
           V_TABIX TYPE SY-TABIX,      " Loop count
           V_ISSUE LIKE MSEG-MENGE,    " Variable for calculating YTD issues
           V_RECEIPT LIKE MSEG-MENGE,  " Var for Calculating YTD Receipts
           V_LABST LIKE MARD-LABST,    " Var for Total On hand inv at plant
           V_MJAHR LIKE MSEG-MJAHR,    " Variable for holding the Year
           f_color.
    *----Declaration to send Email
    DATA: IT_PDF          LIKE TLINE      OCCURS 10 WITH HEADER LINE,
          IT_XI_PDF       LIKE TLINE      OCCURS 0  WITH HEADER LINE,
          IT_HTML         LIKE SOLISTI1   OCCURS 0  WITH HEADER LINE,
          IT_XI_TEMP      LIKE BAPIQCMIME OCCURS 0  WITH HEADER LINE,
          IT_XI_MIME(255) TYPE C          OCCURS 0  WITH HEADER LINE.
    DATA:
       LS_DOCDATA    TYPE SODOCCHGI1,
       LT_OBJPACK    TYPE TABLE OF SOPCKLSTI1 WITH HEADER LINE,
       LT_OBJHEAD    TYPE TABLE OF SOLISTI1   WITH HEADER LINE,
       LT_OBJTXT     TYPE TABLE OF SOLISTI1   WITH HEADER LINE,
       LT_OBJBIN     TYPE TABLE OF SOLISTI1   WITH HEADER LINE,
       LT_RECLIST    TYPE TABLE OF SOMLRECI1  WITH HEADER LINE,
       LT_LISTOBJECT TYPE TABLE OF ABAPLIST   WITH HEADER LINE,
       LT_LISTOBJECTLN(1000) TYPE C,
       L_TAB_LINES TYPE I,
       L_ATT_TYPE  LIKE SOODK-OBJTP.
    DATA: IT_OBJPACK LIKE SOPCKLSTI1 OCCURS 2 WITH HEADER LINE.
    Internal table for Single List with Column Length 255
    DATA : IT_OBJBIN LIKE SOLISTI1 OCCURS 10 WITH HEADER LINE.
    Internal table for Single List with Column Length 255
    DATA : IT_OBJTXT LIKE SOLISTI1 OCCURS 10 WITH HEADER LINE.
    Internal table for Structure of the API Recipient List
    DATA : IT_RECLIST LIKE SOMLRECI1 OCCURS 5 WITH HEADER LINE.
    Structure of the API Recipient List
    DATA: X_DOC_CHNG LIKE SODOCCHGI1.
                            SELECTION-SCREEN                             *
    SELECTION-SCREEN BEGIN OF BLOCK S1 WITH FRAME TITLE TEXT-001.
    PARAMETERS:
    P_WERKS  LIKE MARD-WERKS OBLIGATORY.     " Plant
    SELECT-OPTIONS:
    S_BUKRS  for mseg-bukrs,                 " Company  code
    S_LGORT  FOR MARD-LGORT OBLIGATORY,      " Storage Location
    S_MATNR  FOR MARD-MATNR,                 " Material Number
    S_DISPO  FOR MARC-DISPO,                 " MRP Controller
    S_DATE   FOR SY-DATUM DEFAULT SY-DATUM OBLIGATORY.  " Date Range
    SELECTION-SCREEN END OF BLOCK S1.
    SELECTION-SCREEN BEGIN OF BLOCK S2 WITH FRAME TITLE TEXT-002.
    PARAMETERS:
    P_MAIL  TYPE C AS CHECKBOX.                " Mail to user Group
    SELECT-OPTIONS:
    S_UNAME FOR SY-UNAME NO INTERVALS.         " Usergroup id
    SELECTION-SCREEN END OF BLOCK S2.
                         Initialization
    INITIALIZATION.
    AT S E L E C T I O N - S C R E E N
    AT SELECTION-SCREEN.
      CHECK SSCRFIELDS-UCOMM EQ 'ONLI'.
      PERFORM VALIDATE_MAIL.
      PERFORM VALIDATE_DATA.
                        START-OF-SELECTION                               *
    START-OF-SELECTION.
      PERFORM FETCH_DATA.
                         END-OF-SELECTION                                *
    END-OF-SELECTION.
      IF NOT IT_FINAL[] IS INITIAL.
        PERFORM DOWNLOAD_DISPLAY_REPORT.
      ENDIF.
                         TOP-OF-PAGE                                *
    TOP-OF-PAGE.
    PERFORM PAGE_HEADER.
    *&      Form  Fetch_DATA
          Pick data
    FORM FETCH_DATA .
      DATA : V_EBELN LIKE EKPO-EBELN,
             V_EBELP LIKE EKPO-EBELP,
             V_MENGE LIKE EKPO-MENGE,
             V_EINDT LIKE EKET-EINDT,
             V_DISPO LIKE MARC-DISPO,
             V_EKGRP LIKE MARC-EKGRP,
             V_MAKTX LIKE MAKT-MAKTX.
    *----Select data from MARD Table
      SELECT MATNR                  " Material Number
             WERKS                  " Plant
             LGORT                  " Storage Location
             LMINB                  " Reorder Point Level
             LABST                  " Stock with unrestricted use
             INTO TABLE IT_MARD
             FROM MARD
             WHERE MATNR  IN S_MATNR AND
                   WERKS  = P_WERKS . "AND
                  LGORT  IN S_LGORT.
                   D~LMINB <> SPACE .
      IF SY-SUBRC = 0.
        LOOP AT IT_MARD.
          CLEAR : V_EBELN, V_EBELP, V_MENGE, V_EINDT.
    *---select data from EKPO table
          SELECT EBELN
                 EBELP
                 MENGE
                 UP TO 1 ROWS
                 FROM EKPO
                 INTO (V_EBELN, V_EBELP, V_MENGE)
                 WHERE MATNR = IT_MARD-MATNR AND
                       WERKS = IT_MARD-WERKS AND
                       LGORT = IT_MARD-LGORT AND
                       BUKRS IN S_BUKRS AND
                       ELIKZ = SPACE.
          ENDSELECT.
          IF SY-SUBRC = 0.
            X_MSEG-EBELN = V_EBELN.
            X_MSEG-MENGE1 = V_MENGE.
            SELECT EINDT
                   UP TO 1 ROWS
                   FROM EKET
                   INTO V_EINDT
                   WHERE EBELN = V_EBELN AND
                         EBELP = V_EBELP.
            ENDSELECT.
            IF SY-SUBRC = 0.
              X_MSEG-EINDT = V_EINDT.
            ENDIF.
          ENDIF.
    *---Select Data from MARC table.
          CLEAR : V_DISPO, V_EKGRP.
          SELECT DISPO
                 EKGRP
                 UP TO 1 ROWS
                 FROM MARC
                 INTO (V_DISPO, V_EKGRP)
                 WHERE MATNR = IT_MARD-MATNR AND
                       WERKS = IT_MARD-WERKS AND
                       DISPO IN S_DISPO.
          ENDSELECT.
          IF SY-SUBRC = 0.
            X_MSEG-DISPO = V_DISPO.
            X_MSEG-EKGRP = V_EKGRP.
          else.
          continue.
          ENDIF.
    *---select Material Description from MAKT
          CLEAR V_MAKTX.
          SELECT SINGLE MAKTX
                 FROM MAKT
                 INTO V_MAKTX
                 WHERE MATNR = IT_MARD-MATNR AND
                       SPRAS = SY-LANGU.
          IF SY-SUBRC = 0.
            X_MSEG-MAKTX = V_MAKTX.
          ENDIF.
    *----Select data from MSEG Table
          SELECT MBLNR
                 MJAHR
                 MATNR                  " Material Number
                 WERKS                  " Plant
                 LGORT                  " Storage Location
                 MENGE                  " Quantity
                 MEINS                  " UOM
                 LIFNR                  " Account No of Vendor
                 SHKZG                  " Credit/Debit Indicator
                 FROM MSEG
                 INTO X_MSEG
                 WHERE MATNR = IT_MARD-MATNR AND
                       WERKS = IT_MARD-WERKS AND
                       LGORT = IT_MARD-LGORT AND
                       BUKRS IN S_BUKRS.
    *---Subroutine to check whether the document is in the given date range
            PERFORM CHECK_DATE.
          ENDSELECT.
        ENDLOOP.
      ELSE.
        STOP.
      ENDIF.
    *----Select YTD receipts and Issues to date from MSEG
      CLEAR : V_MJAHR, V_ISSUE, V_RECEIPT.
      IF S_DATE[] IS NOT INITIAL.
        V_MJAHR = S_DATE+3(4).
      ELSE.
        V_MJAHR = SY-DATUM+0(4).
      ENDIF.
      SELECT MENGE
             MEINS
             SHKZG
             FROM MSEG
             INTO TABLE IT_YTD
             WHERE WERKS = P_WERKS AND
                   MJAHR = V_MJAHR.
    *--Calculating YTD receipts and Issues
      IF SY-SUBRC = 0.
        LOOP AT IT_YTD.
          IF IT_YTD-SHKZG = 'S'.
            V_ISSUE = V_ISSUE + IT_YTD-MENGE.
          ELSE.
            V_RECEIPT = V_RECEIPT + IT_YTD-MENGE.
          ENDIF.
        ENDLOOP.
        IT_FINAL-ISSUE = V_ISSUE.
        IT_FINAL-RECEIPT = V_RECEIPT.
      ENDIF.
    *-----Logic for printing the material
      LOOP AT IT_MSEG.
        V_TABIX = SY-TABIX.
        AT NEW MATNR.
    *----Logic for calculation of Total On hand inv at plant.
    *---Sum of all MARD-LABST.
          CLEAR V_LABST.
          LOOP AT IT_MARD WHERE MATNR = IT_MSEG-MATNR.
            V_LABST = V_LABST + IT_MARD-LABST.
          ENDLOOP.
          IT_FINAL-TOT_LABST = V_LABST.
        ENDAT.
        AT NEW LGORT.
          CLEAR : V_SUM.
        ENDAT.
        READ TABLE IT_MARD WITH KEY MATNR = IT_MSEG-MATNR
                                    WERKS = IT_MSEG-WERKS
                                    LGORT = IT_MSEG-LGORT.
        IF SY-SUBRC = 0 AND IT_MARD-LMINB > 0.
    *---Logic for adding/Subtracting GR/GI
          IF V_TABIX = 1.
            IF IT_MSEG-SHKZG = 'S'.
              V_TEMP = IT_MARD-LABST + IT_MSEG-MENGE.
            ELSE.
              V_TEMP = IT_MARD-LABST - IT_MSEG-MENGE.
            ENDIF.
          ENDIF.
          IF IT_MARD-LABST < IT_MARD-LMINB.  "Stock < Reorder Point
    *---Check for any goods receipts on the given day. SHKZG = 'S'
            IF IT_MSEG-SHKZG = 'S' .
              IF V_TABIX = 1.
                V_SUM = V_TEMP.
              ELSE.
                V_SUM = V_SUM + IT_MSEG-MENGE.
              ENDIF.
              IF V_SUM < IT_MARD-LMINB.
                IT_FINAL-MATNR = IT_MARD-MATNR.
                IT_FINAL-MAKTX = IT_MSEG-MAKTX.
                IT_FINAL-LMINB = IT_MARD-LMINB.
                IT_FINAL-MEINS = IT_MSEG-MEINS.
                IT_FINAL-LABST = IT_MARD-LABST.
                IT_FINAL-DISPO = IT_MSEG-DISPO.
                IT_FINAL-EKGRP = IT_MSEG-EKGRP.
                IT_FINAL-LIFNR = IT_MSEG-LIFNR.
                IT_FINAL-ISSUE = V_ISSUE.
                IT_FINAL-RECEIPT = V_RECEIPT.
                IT_FINAL-TOT_LABST = V_LABST.
                IT_FINAL-EBELN = IT_MSEG-EBELN.
                IT_FINAL-MENGE = IT_MSEG-MENGE1.
                IT_FINAL-EINDT = IT_MSEG-EINDT.
                APPEND IT_FINAL.
                CLEAR IT_FINAL.
              ENDIF.
            ELSE.
    *--- If there is no Goods receipt mov't type on the given day, then
    *---add all the goods issues to the storage location stock.
    *---Goos Receipt = 'S' , Goods Issue = 'H'.
              IF V_TABIX = 1.
                V_SUM = V_TEMP.
              ELSE.
                V_SUM = V_SUM - IT_MSEG-MENGE.
              ENDIF.
              IF V_SUM < IT_MARD-LMINB.
                IT_FINAL-MATNR = IT_MARD-MATNR.
                IT_FINAL-MAKTX = IT_MSEG-MAKTX.
                IT_FINAL-LMINB = IT_MARD-LMINB.
                IT_FINAL-MEINS = IT_MSEG-MEINS.
                IT_FINAL-LABST = IT_MARD-LABST.
                IT_FINAL-DISPO = IT_MSEG-DISPO.
                IT_FINAL-EKGRP = IT_MSEG-EKGRP.
                IT_FINAL-LIFNR = IT_MSEG-LIFNR.
                IT_FINAL-ISSUE = V_ISSUE.
                IT_FINAL-RECEIPT = V_RECEIPT.
                IT_FINAL-TOT_LABST = V_LABST.
                IT_FINAL-EBELN = IT_MSEG-EBELN.
                IT_FINAL-MENGE = IT_MSEG-MENGE1.
                IT_FINAL-EINDT = IT_MSEG-EINDT.
                APPEND IT_FINAL.
                CLEAR IT_FINAL.
              ENDIF.
            ENDIF.
          ENDIF.
        ENDIF.
      ENDLOOP.
    ENDFORM.                    " Fetch_DATA
    *&      Form  check_date
          text
    FORM CHECK_DATE .
      DATA: LV_BLDAT LIKE MKPF-BLDAT.
      SELECT SINGLE BLDAT
             FROM MKPF
             INTO LV_BLDAT
             WHERE MBLNR = X_MSEG-MBLNR AND
                   MJAHR = X_MSEG-MJAHR AND
                   BLDAT IN S_DATE.
      IF SY-SUBRC = 0.
        MOVE : X_MSEG-MATNR TO IT_MSEG-MATNR,
               X_MSEG-WERKS TO IT_MSEG-WERKS,
               X_MSEG-LGORT TO IT_MSEG-LGORT,
               X_MSEG-MENGE TO IT_MSEG-MENGE,
               X_MSEG-MEINS TO IT_MSEG-MEINS,
               X_MSEG-LIFNR TO IT_MSEG-LIFNR,
               X_MSEG-SHKZG TO IT_MSEG-SHKZG,
               X_MSEG-EBELN TO IT_MSEG-EBELN,
               X_MSEG-MENGE1 TO IT_MSEG-MENGE1,
               X_MSEG-EINDT TO IT_MSEG-EINDT,
               X_MSEG-DISPO TO IT_MSEG-DISPO,
               X_MSEG-EKGRP TO IT_MSEG-EKGRP,
               X_MSEG-MAKTX TO IT_MSEG-MAKTX.
        APPEND IT_MSEG.
        CLEAR IT_MSEG.
      ENDIF.
    ENDFORM.                    " check_date
    *&      Form  PAGE_HEADER
         To Print page header and other details
    FORM PAGE_HEADER .                                          "#EC CALLED
    *---Page header
      ULINE AT /1(150).
      FORMAT COLOR COL_BACKGROUND INTENSIFIED ON .
      WRITE:/ 'Run Date:'(t08), SY-DATUM, 50 'Stanley Works'(t07),
             110 'Page No:'(t09), SY-PAGNO LEFT-JUSTIFIED.
      WRITE:/ 'Run Time:'(t10), SY-UZEIT, 47 SY-TITLE, 110 SY-UNAME.
      WRITE:/ 'Source  :'(t11), SY-SYSID, 110 SY-CPROG .
      ULINE AT /1(150).
      WRITE :/1 'Safety Stock Report for Plant :'(t13),P_WERKS.
    ENDFORM.                    "PAGE_HEADER
    *&      Form  VALIDATE_DATA
          Subroutine to Validate selection screen data
    FORM VALIDATE_DATA .
      DATA V_TEMP(20) TYPE C.                                   "#EC NEEDED
    *--Validation for Plant.
      CLEAR V_TEMP.
      SELECT SINGLE WERKS
             INTO V_TEMP
             FROM T001W
             WHERE WERKS = P_WERKS.
      IF SY-SUBRC NE 0.
        MESSAGE E001(ZZ) WITH 'Invalid Plant'(t03).             "#EC *
      ENDIF.
    *--Validation for Storage Location.
      CLEAR V_TEMP.
      IF NOT S_LGORT[] IS INITIAL.
        SELECT LGORT INTO V_TEMP UP TO 1 ROWS
               FROM T001L
               WHERE LGORT IN  S_LGORT.
        ENDSELECT.
        IF SY-SUBRC NE 0.
          MESSAGE E001(ZZ) WITH 'Invalid Storage Location'(t04).
        ENDIF.
      ENDIF.
    *--Validation for Material Number.
      CLEAR V_TEMP.
      IF NOT S_MATNR[] IS INITIAL.
        SELECT MATNR
               INTO V_TEMP
               UP TO 1 ROWS
               FROM MARA
               WHERE MATNR IN S_MATNR.
        ENDSELECT.
        IF SY-SUBRC NE 0.
          MESSAGE E001(ZZ) WITH 'Invalid Material Number'(t05).
        ENDIF.
      ENDIF.
    *--Validation for MRP controller.
      CLEAR V_TEMP.
      IF NOT S_DISPO[] IS INITIAL.
        SELECT  DISPO INTO V_TEMP UP TO 1 ROWS
                FROM T024D
                WHERE DISPO IN S_DISPO.
        ENDSELECT.
        IF SY-SUBRC NE 0.
          MESSAGE E001(ZZ) WITH 'Invalid MRP Controller'(t06).
        ENDIF.
      ENDIF.
    ENDFORM.                    " VALIDATE_DATA
    *&      Form  validate_mail
          Validate user id
    FORM VALIDATE_MAIL .
      IF P_MAIL = 'X' AND S_UNAME[] IS INITIAL.
        MESSAGE E001(ZZ) WITH 'Enter User Mail id'(t01).
      ENDIF.
    ENDFORM.                    " validate_mail
    *&      Form  SEND_MAIL
         Send email to SAP inbox
    FORM SEND_MAIL .
    Structures and internal tables for the send data
      DATA: OBJPACK LIKE SOPCKLSTI1 OCCURS 2  WITH HEADER LINE,
            OBJHEAD LIKE SOLISTI1   OCCURS 1  WITH HEADER LINE,
            OBJBIN  LIKE SOLISTI1   OCCURS 0  WITH HEADER LINE,
            OBJTXT  LIKE SOLISTI1   OCCURS 10 WITH HEADER LINE,
            RECLIST LIKE SOMLRECI1  OCCURS 5  WITH HEADER LINE.
      DATA: DOC_CHNG LIKE SODOCCHGI1,
            TAB_LINES LIKE SY-TABIX.
    Data for the status output after sending
      DATA: SENT_TO_ALL LIKE SONV-FLAG.
      CLEAR: IT_RECLIST, IT_RECLIST[],
             IT_OBJTXT , IT_OBJTXT[],
             IT_OBJPACK, IT_OBJPACK[],
             IT_OBJBIN , IT_OBJBIN[],X_DOC_CHNG.
      LOOP AT IT_HTML.
        OBJBIN-LINE = IT_HTML-LINE.
        APPEND OBJBIN.
        CLEAR OBJBIN.
      ENDLOOP.
    Create the document which is to be sent
      DOC_CHNG-OBJ_NAME  = 'List'(012).
      DOC_CHNG-OBJ_DESCR = 'Mail'(m05).
    Heading
      OBJTXT-LINE = 'Safety Stock Report attached'(014).
      APPEND OBJTXT.
      CLEAR OBJTXT.
    Size
      DESCRIBE TABLE OBJTXT LINES TAB_LINES.
      READ TABLE OBJTXT INDEX TAB_LINES.
      DOC_CHNG-DOC_SIZE = ( TAB_LINES - 1 ) * 255 + STRLEN( OBJTXT ).
    Fill the fields of the packing_list for the main document:
      CLEAR OBJPACK-TRANSF_BIN.
    The document needs no header (head_num = 0)
      OBJPACK-HEAD_START = 1.
      OBJPACK-HEAD_NUM = 0.
    Body
      OBJPACK-BODY_START = 1.
      OBJPACK-BODY_NUM = TAB_LINES.
      OBJPACK-DOC_TYPE = 'RAW'(m02).
      APPEND OBJPACK.
    Create the attachment (the list itself)
      DESCRIBE TABLE OBJBIN LINES TAB_LINES.
    Fill the fields of the packing_list for the attachment:
      OBJPACK-TRANSF_BIN = 'X'.
    Header
      OBJPACK-HEAD_START = 1.
      OBJPACK-HEAD_NUM = 0.
    Body
      OBJPACK-BODY_START = 1.
      OBJPACK-BODY_NUM = TAB_LINES.
      OBJPACK-DOC_TYPE = 'PDF'(m01).
      OBJPACK-OBJ_NAME = 'Attachment'(m03).
      OBJPACK-OBJ_DESCR = 'Mail with pdf Attachment'(018).
      OBJPACK-DOC_SIZE = TAB_LINES * 255.
      APPEND OBJPACK.
    *-Fill the mail recipient list
      LOOP AT S_UNAME.
        RECLIST-RECEIVER = S_UNAME-LOW.
        RECLIST-REC_TYPE = 'B'.
        APPEND RECLIST.
        CLEAR: RECLIST.
      ENDLOOP.
    *-Send the document by calling the SAPoffice API1 module for sending
    *-documents with attachments
      CALL FUNCTION 'SO_NEW_DOCUMENT_ATT_SEND_API1'
        EXPORTING
          DOCUMENT_DATA              = DOC_CHNG
          PUT_IN_OUTBOX              = 'X'
          COMMIT_WORK                = 'X'
        IMPORTING
          SENT_TO_ALL                = SENT_TO_ALL
        TABLES
          PACKING_LIST               = OBJPACK
          OBJECT_HEADER              = OBJHEAD
          CONTENTS_BIN               = OBJBIN
          CONTENTS_TXT               = OBJTXT
          RECEIVERS                  = RECLIST
        EXCEPTIONS
          TOO_MANY_RECEIVERS         = 1
          DOCUMENT_NOT_SENT          = 2
          OPERATION_NO_AUTHORIZATION = 4
          OTHERS                     = 99.
      CASE SY-SUBRC .
        WHEN 0.
          MESSAGE s001 WITH 'Mail has been sent successfully'(003).
        WHEN OTHERS.
          MESSAGE s001 WITH 'Problem in sending the mail'(004).
      ENDCASE.
    ENDFORM.                    " SEND_MAIL
    *&      Form  download_display_report
          Download and dispaly report
    FORM DOWNLOAD_DISPLAY_REPORT .
      DATA: X_PARAMS TYPE PRI_PARAMS,
            V_VALID.
      CALL FUNCTION 'GET_PRINT_PARAMETERS'
        EXPORTING
          IMMEDIATELY    = ' '
          LAYOUT         = 'X_65_255'
          NO_DIALOG      = 'X'
        IMPORTING
          OUT_PARAMETERS = X_PARAMS
          VALID          = V_VALID.
      IF V_VALID <> SPACE.
        NEW-PAGE PRINT ON PARAMETERS X_PARAMS NO DIALOG.
        PERFORM DISPLAY_REPORT.
        NEW-PAGE PRINT OFF.
        PERFORM CONV_TO_PDF_DOWNLOAD.
      ENDIF.
      PERFORM DISPLAY_REPORT.
    ENDFORM.                    " download_display_report
    *&      Form  DISPLAY_REPORT
          Display the report
    FORM DISPLAY_REPORT .
    ULINE AT /0(204).
      write:/1 sy-vline no-gap, (10)'Material'(032),
             sy-vline no-gap, (40)'Description'(031),
             sy-vline no-gap, (15)'Reorder pt'(030),
             sy-vline no-gap, (03)'BUn'(029),
             sy-vline no-gap, (13)'OnHandQty'(023),
             sy-vline no-gap, (13)'OnHandPlnt'(024),
             sy-vline no-gap, (13)'YTD issues'(025),
             sy-vline no-gap, (13)'YTD Receipts'(026),
             sy-vline no-gap, (08)'MRPcntrl'(027),
             sy-vline no-gap, (04)'POgrp'(028),
             sy-vline no-gap, (13)'POqty'(019),
             sy-vline no-gap, (10)'NextDelvDt'(020),
             sy-vline no-gap, (10)'Vendor'(021),
             sy-vline no-gap, (10)'PO#'(022),
             sy-vline no-gap.
    ULINE AT /0(204).
    loop at it_final.
      PERFORM COLOR_SWAP.
      write:/1 sy-vline no-gap, (10)it_final-matnr,
             sy-vline no-gap, (40)it_final-maktx,
             sy-vline no-gap, (15)it_final-lminb,     "#EC UOM_IN_MES
             sy-vline no-gap, (03)it_final-meins,
             sy-vline no-gap, (13)it_final-labst,     "#EC UOM_IN_MES
             sy-vline no-gap, (13)it_final-tot_labst, "#EC UOM_IN_MES
             sy-vline no-gap, (13)it_final-issue,     "#EC UOM_IN_MES
             sy-vline no-gap, (13)it_final-receipt,   "#EC UOM_IN_MES
             sy-vline no-gap, (08)it_final-dispo,
             sy-vline no-gap, (04)it_final-ekgrp,
             sy-vline no-gap, (13)it_final-menge,     "#EC UOM_IN_MES
             sy-vline no-gap, (10)it_final-eindt,
             sy-vline no-gap, (10)it_final-lifnr,
             sy-vline no-gap, (10)it_final-ebeln,
             sy-vline no-gap.
    endloop.
    ULINE AT /0(204).
    skip 2.
    WRITE:/ '******End of Report*******'.
    ENDFORM.                    " DISPLAY_REPORT
    *&      Form  CONV_TO_PDF_DOWNLOAD
          Convert to PDF
    FORM CONV_TO_PDF_DOWNLOAD .
      DATA: V_NUMBYTES TYPE I,
            V_SPOOLNO TYPE TSP01-RQIDENT.
      CLEAR   IT_PDF.
      REFRESH IT_PDF.
      WAIT UP TO 2 SECONDS.
      V_SPOOLNO = SY-SPONO.
      CALL FUNCTION 'CONVERT_ABAPSPOOLJOB_2_PDF'
        EXPORTING
          SRC_SPOOLID   = V_SPOOLNO
          NO_DIALOG     = ' '
        IMPORTING
          PDF_BYTECOUNT = V_NUMBYTES
        TABLES
          PDF           = IT_PDF.
      IF SY-SUBRC = 0.    "#EC *
        PERFORM PAGE_FORMAT.
      ENDIF.
    ENDFORM.                    " CONV_TO_PDF_DOWNLOAD
    *&      Form  page_format
       Format the page
    FORM PAGE_FORMAT .
      DATA : L_LINES       TYPE I,
             L_TEMP(500)   TYPE C,
             L_OFFSET      TYPE P,
             L_LINESLEN(2) TYPE P,
             L_MIMELEN(2)  TYPE P,
             L_TABIX       LIKE SY-TABIX.
      CLEAR : IT_XI_PDF,
              IT_XI_TEMP.
      REFRESH : IT_XI_PDF,
                IT_XI_TEMP.
      IT_XI_PDF[] = IT_PDF[].
    Reformat the line to 255 characters wide (code from SAP)
      CLEAR: L_TEMP, L_OFFSET, IT_XI_TEMP.
      DESCRIBE TABLE IT_XI_PDF   LINES  L_LINES.
      DESCRIBE FIELD IT_XI_PDF   LENGTH L_LINESLEN IN CHARACTER MODE.
      DESCRIBE FIELD IT_XI_TEMP  LENGTH L_MIMELEN IN CHARACTER MODE.
      LOOP AT IT_XI_PDF.
        L_TABIX = SY-TABIX.
        MOVE IT_XI_PDF TO L_TEMP+L_OFFSET.
        IF L_TABIX = L_LINES.
          L_LINESLEN = STRLEN( IT_XI_PDF ).
        ENDIF.
        L_OFFSET = L_OFFSET + L_LINESLEN.
        IF L_OFFSET GE L_MIMELEN.
          CLEAR IT_XI_TEMP.
          IT_XI_TEMP = L_TEMP(L_MIMELEN).
          APPEND IT_XI_TEMP.
          SHIFT L_TEMP BY L_MIMELEN PLACES.
          L_OFFSET = L_OFFSET - L_MIMELEN.
        ENDIF.
        IF L_TABIX = L_LINES.
          IF L_OFFSET GT 0.
            CLEAR IT_XI_TEMP.
            IT_XI_TEMP = L_TEMP(L_OFFSET).
            APPEND IT_XI_TEMP.
          ENDIF.
        ENDIF.
      ENDLOOP.
      CLEAR : IT_XI_MIME,
              IT_XI_MIME[].
      LOOP AT IT_XI_TEMP.
        IT_XI_MIME(255) = IT_XI_TEMP-LINE.
        APPEND IT_XI_MIME.
        CLEAR  IT_XI_MIME.
      ENDLOOP.
    Final Data
      CLEAR : IT_HTML,
              IT_HTML[].
      IT_HTML[] = IT_XI_MIME[].
    For sending mail
      PERFORM SEND_MAIL .
    ENDFORM.                    " page_format
    Form        : color_swap
    Description : Subroutine for color
    form color_swap.
    if flag is set
      if f_color eq 'X'.
        clear f_color.
    switch off the intensity
        format color col_normal intensified off.
      else.
    if flag is not set.
        f_color = 'X'.
    switch on the intensity
        format color col_normal intensified on.
      endif.
    endform.                    " color_swap

  • Problem in converting report output to pdf

    Hi,
    I'm managing to get the spool id and other requirements but could'nt get the output of the program converted to pdf format.When i'm trying to do this i'm getting the pdf format of the functional module which retrievs the header and item records and displays the numbers records in the header and item like for eg. header records 8 and item records 10 this its displaying in the format in which we get our funtional module output when we give some data into it.....
    Can any one please tell me how to solve this for ur information i'm using hierarchail squential report with multiple reports in the same report.............
    for instance i'm using the following coding please find the bug......
    PARAMETER: p_email1 LIKE somlreci1-receiver
                                        DEFAULT '[email protected]',
               p_sender LIKE somlreci1-receiver
                                        DEFAULT '[email protected]',
               p_delspl  AS CHECKBOX.
    *DATA DECLARATION
    DATA: gd_recsize TYPE i.
    Spool IDs
    TYPES: BEGIN OF t_tbtcp.
            INCLUDE STRUCTURE tbtcp.
    TYPES: END OF t_tbtcp.
    DATA: it_tbtcp TYPE STANDARD TABLE OF t_tbtcp INITIAL SIZE 0,
          wa_tbtcp TYPE t_tbtcp.
    Job Runtime Parameters
    DATA: gd_eventid LIKE tbtcm-eventid,
          gd_eventparm LIKE tbtcm-eventparm,
          gd_external_program_active LIKE tbtcm-xpgactive,
          gd_jobcount LIKE tbtcm-jobcount,
          gd_jobname LIKE tbtcm-jobname,
          gd_stepcount LIKE tbtcm-stepcount,
          gd_error    TYPE sy-subrc,
          gd_reciever TYPE sy-subrc.
    DATA:  w_recsize TYPE i.
    DATA: gd_subject   LIKE sodocchgi1-obj_descr,
          it_mess_bod LIKE solisti1 OCCURS 0 WITH HEADER LINE,
          it_mess_att LIKE solisti1 OCCURS 0 WITH HEADER LINE,
          gd_sender_type     LIKE soextreci1-adr_typ,
          gd_attachment_desc TYPE so_obj_nam,
          gd_attachment_name TYPE so_obj_des.
    Spool to PDF conversions
    DATA: gd_spool_nr LIKE tsp01-rqident,
          gd_destination LIKE rlgrap-filename,
          gd_bytecount LIKE tst01-dsize,
          gd_buffer TYPE string.
    Binary store for PDF
    DATA: BEGIN OF it_pdf_output OCCURS 0.
            INCLUDE STRUCTURE tline.
    DATA: END OF it_pdf_output.
    CONSTANTS: c_dev LIKE  sy-sysid VALUE 'DEV',
               c_no(1)     TYPE c   VALUE ' ',
               c_device(4) TYPE c   VALUE 'LOCL'.
    *START-OF-SELECTION.
    START-OF-SELECTION.
    Write statement to represent report output. Spool request is created
    if write statement is executed in background. This could also be an
    ALV grid which would be converted to PDF without any extra effort
      WRITE 'Hello World'.
      new-page.
      commit work.
      new-page print off.
      IF sy-batch EQ 'X'.
        PERFORM get_job_details.
        PERFORM obtain_spool_id.
    Alternative way could be to submit another program and store spool
    id into memory, will be stored in sy-spono.
    *submit ZSPOOLTOPDF2
           to sap-spool
           spool parameters   %_print
           archive parameters %_print
           without spool dynpro
           and return.
    Get spool id from program called above
    IMPORT w_spool_nr FROM MEMORY ID 'SPOOLTOPDF'.
        PERFORM convert_spool_to_pdf.
        PERFORM process_email.
        if p_delspl EQ 'X'.
          PERFORM delete_spool.
        endif.
        IF sy-sysid = c_dev.
          wait up to 5 seconds.
          SUBMIT rsconn01 WITH mode   = 'INT'
                          WITH output = 'X'
                          AND RETURN.
        ENDIF.
      ELSE.
        SKIP.
        WRITE:/ 'Program must be executed in background in-order for spool',
                'request to be created.'.
      ENDIF.
          FORM obtain_spool_id                                          *
    FORM obtain_spool_id.
      CHECK NOT ( gd_jobname IS INITIAL ).
      CHECK NOT ( gd_jobcount IS INITIAL ).
      SELECT * FROM  tbtcp
                     INTO TABLE it_tbtcp
                     WHERE      jobname     = gd_jobname
                     AND        jobcount    = gd_jobcount
                     AND        stepcount   = gd_stepcount
                     AND        listident   <> '0000000000'
                     ORDER BY   jobname
                                jobcount
                                stepcount.
      READ TABLE it_tbtcp INTO wa_tbtcp INDEX 1.
      IF sy-subrc = 0.
        message s004(zdd) with gd_spool_nr.
        gd_spool_nr = wa_tbtcp-listident.
        MESSAGE s004(zdd) WITH gd_spool_nr.
      ELSE.
        MESSAGE s005(zdd).
      ENDIF.
    ENDFORM.
          FORM get_job_details                                          *
    FORM get_job_details.
    Get current job details
      CALL FUNCTION 'GET_JOB_RUNTIME_INFO'
           IMPORTING
                eventid                 = gd_eventid
                eventparm               = gd_eventparm
                external_program_active = gd_external_program_active
                jobcount                = gd_jobcount
                jobname                 = gd_jobname
                stepcount               = gd_stepcount
           EXCEPTIONS
                no_runtime_info         = 1
                OTHERS                  = 2.
    ENDFORM.
          FORM convert_spool_to_pdf                                     *
    FORM convert_spool_to_pdf.
      CALL FUNCTION 'CONVERT_ABAPSPOOLJOB_2_PDF'
           EXPORTING
                src_spoolid              = gd_spool_nr
                no_dialog                = c_no
                dst_device               = c_device
           IMPORTING
                pdf_bytecount            = gd_bytecount
           TABLES
                pdf                      = it_pdf_output
           EXCEPTIONS
                err_no_abap_spooljob     = 1
                err_no_spooljob          = 2
                err_no_permission        = 3
                err_conv_not_possible    = 4
                err_bad_destdevice       = 5
                user_cancelled           = 6
                err_spoolerror           = 7
                err_temseerror           = 8
                err_btcjob_open_failed   = 9
                err_btcjob_submit_failed = 10
                err_btcjob_close_failed  = 11
                OTHERS                   = 12.
      CHECK sy-subrc = 0.
    Transfer the 132-long strings to 255-long strings
      LOOP AT it_pdf_output.
        TRANSLATE it_pdf_output USING ' ~'.
        CONCATENATE gd_buffer it_pdf_output INTO gd_buffer.
      ENDLOOP.
      TRANSLATE gd_buffer USING '~ '.
      DO.
        it_mess_att = gd_buffer.
        APPEND it_mess_att.
        SHIFT gd_buffer LEFT BY 255 PLACES.
        IF gd_buffer IS INITIAL.
          EXIT.
        ENDIF.
      ENDDO.
    ENDFORM.
          FORM process_email                                            *
    FORM process_email.
      DESCRIBE TABLE it_mess_att LINES gd_recsize.
      CHECK gd_recsize > 0.
      PERFORM send_email USING p_email1.
    perform send_email using p_email2.
    ENDFORM.
          FORM send_email                                               *
    -->  p_email                                                       *
    FORM send_email USING p_email.
      CHECK NOT ( p_email IS INITIAL ).
      REFRESH it_mess_bod.
    Default subject matter
      gd_subject         = 'Subject'.
      gd_attachment_desc = 'Attachname'.
    CONCATENATE 'attach_name' ' ' INTO gd_attachment_name.
      it_mess_bod        = 'Message Body text, line 1'.
      APPEND it_mess_bod.
      it_mess_bod        = 'Message Body text, line 2...'.
      APPEND it_mess_bod.
    If no sender specified - default blank
      IF p_sender EQ space.
        gd_sender_type  = space.
      ELSE.
        gd_sender_type  = 'INT'.
      ENDIF.
    Send file by email as .xls speadsheet
      PERFORM send_file_as_email_attachment
                                   tables it_mess_bod
                                          it_mess_att
                                    using p_email
                                          'Example .xls documnet attachment'
                                          'PDF'
                                          gd_attachment_name
                                          gd_attachment_desc
                                          p_sender
                                          gd_sender_type
                                 changing gd_error
                                          gd_reciever.
    ENDFORM.
          FORM delete_spool                                             *
    FORM delete_spool.
      DATA: ld_spool_nr TYPE tsp01_sp0r-rqid_char.
      ld_spool_nr = gd_spool_nr.
      CHECK p_delspl <> c_no.
      CALL FUNCTION 'RSPO_R_RDELETE_SPOOLREQ'
           EXPORTING
                spoolid = ld_spool_nr.
    ENDFORM.
    *&      Form  SEND_FILE_AS_EMAIL_ATTACHMENT
          Send email
    FORM send_file_as_email_attachment tables it_message
                                              it_attach
                                        using p_email
                                              p_mtitle
                                              p_format
                                              p_filename
                                              p_attdescription
                                              p_sender_address
                                              p_sender_addres_type
                                     changing p_error
                                              p_reciever.
      DATA: ld_error    TYPE sy-subrc,
            ld_reciever TYPE sy-subrc,
            ld_mtitle LIKE sodocchgi1-obj_descr,
            ld_email LIKE  somlreci1-receiver,
            ld_format TYPE  so_obj_tp ,
            ld_attdescription TYPE  so_obj_nam ,
            ld_attfilename TYPE  so_obj_des ,
            ld_sender_address LIKE  soextreci1-receiver,
            ld_sender_address_type LIKE  soextreci1-adr_typ,
            ld_receiver LIKE  sy-subrc.
    data:   t_packing_list like sopcklsti1 occurs 0 with header line,
            t_contents like solisti1 occurs 0 with header line,
            t_receivers like somlreci1 occurs 0 with header line,
            t_attachment like solisti1 occurs 0 with header line,
            t_object_header like solisti1 occurs 0 with header line,
            w_cnt type i,
            w_sent_all(1) type c,
            w_doc_data like sodocchgi1.
      ld_email   = p_email.
      ld_mtitle = p_mtitle.
      ld_format              = p_format.
      ld_attdescription      = p_attdescription.
      ld_attfilename         = p_filename.
      ld_sender_address      = p_sender_address.
      ld_sender_address_type = p_sender_addres_type.
    Fill the document data.
      w_doc_data-doc_size = 1.
    Populate the subject/generic message attributes
      w_doc_data-obj_langu = sy-langu.
      w_doc_data-obj_name  = 'SAPRPT'.
      w_doc_data-obj_descr = ld_mtitle .
      w_doc_data-sensitivty = 'F'.
    Fill the document data and get size of attachment
      CLEAR w_doc_data.
      READ TABLE it_attach INDEX w_cnt.
      w_doc_data-doc_size =
         ( w_cnt - 1 ) * 255 + STRLEN( it_attach ).
      w_doc_data-obj_langu  = sy-langu.
      w_doc_data-obj_name   = 'SAPRPT'.
      w_doc_data-obj_descr  = ld_mtitle.
      w_doc_data-sensitivty = 'F'.
      CLEAR t_attachment.
      REFRESH t_attachment.
      t_attachment[] = it_attach[].
    Describe the body of the message
      CLEAR t_packing_list.
      REFRESH t_packing_list.
      t_packing_list-transf_bin = space.
      t_packing_list-head_start = 1.
      t_packing_list-head_num = 0.
      t_packing_list-body_start = 1.
      DESCRIBE TABLE it_message LINES t_packing_list-body_num.
      t_packing_list-doc_type = 'RAW'.
      APPEND t_packing_list.
    Create attachment notification
      t_packing_list-transf_bin = 'X'.
      t_packing_list-head_start = 1.
      t_packing_list-head_num   = 1.
      t_packing_list-body_start = 1.
      DESCRIBE TABLE t_attachment LINES t_packing_list-body_num.
      t_packing_list-doc_type   =  ld_format.
      t_packing_list-obj_descr  =  ld_attdescription.
      t_packing_list-obj_name   =  ld_attfilename.
      t_packing_list-doc_size   =  t_packing_list-body_num * 255.
      APPEND t_packing_list.
    Add the recipients email address
      CLEAR t_receivers.
      REFRESH t_receivers.
      t_receivers-receiver = ld_email.
      t_receivers-rec_type = 'U'.
      t_receivers-com_type = 'INT'.
      t_receivers-notif_del = 'X'.
      t_receivers-notif_ndel = 'X'.
      APPEND t_receivers.
      CALL FUNCTION 'SO_DOCUMENT_SEND_API1'
           EXPORTING
                document_data              = w_doc_data
                put_in_outbox              = 'X'
                sender_address             = ld_sender_address
                sender_address_type        = ld_sender_address_type
                commit_work                = 'X'
           IMPORTING
                sent_to_all                = w_sent_all
           TABLES
                packing_list               = t_packing_list
                contents_bin               = t_attachment
                contents_txt               = it_message
                receivers                  = t_receivers
           EXCEPTIONS
                too_many_receivers         = 1
                document_not_sent          = 2
                document_type_not_exist    = 3
                operation_no_authorization = 4
                parameter_error            = 5
                x_error                    = 6
                enqueue_error              = 7
                OTHERS                     = 8.
    Populate zerror return code
      ld_error = sy-subrc.
    Populate zreceiver return code
      LOOP AT t_receivers.
        ld_receiver = t_receivers-retrn_code.
      ENDLOOP.
    ENDFORM.

    Please  go throught the code    ... this  is  my salary sending  program to  all the employees   as pdf attach file of his  salary breakup ...... it was  so clear  how the   data  is converted in th  pdf   format   .... and more understanding way the internal tables are declared ....
    DATA W_OPTIONS LIKE ITCPO OCCURS 0 WITH HEADER LINE.
      DATA : z_itcpp LIKE itcpp OCCURS 0 WITH HEADER LINE.
      DATA : otfdt like ITCOO OCCURS 0 WITH HEADER LINE.
      DATA : pdfdt like TLINE OCCURS 0 with header line.
       DATA: NUMBYTES TYPE I.
      DATA: OBJPACK   LIKE SOPCKLSTI1 OCCURS 2 WITH HEADER LINE.
      DATA: OBJHEAD   LIKE SOLISTI1 OCCURS 1 WITH HEADER LINE.
      DATA: OBJBIN    LIKE SOLISTI1 OCCURS 10 WITH HEADER LINE.
      DATA: OBJTXT    LIKE SOLISTI1 OCCURS 10 WITH HEADER LINE.
      DATA: RECLIST   LIKE SOMLRECI1 OCCURS 5 WITH HEADER LINE.
      DATA: DOC_CHNG  LIKE SODOCCHGI1.
      DATA: TAB_LINES LIKE SY-TABIX.
      DATA: Begin of i_errors occurs 0,
            type(1) type c,
            descr(100) type c,
           End of i_errors.
        w_options-tdprinter = 'POSTSCPT'.
        W_options-TDRDIDEV = 'XP45'.
        W_options-TDGETOTF = 'X'.
        APPEND W_options.
        call function 'OPEN_FORM'
            exporting
                  device                      = 'PRINTER'
                  dialog                      = ' '
                  form                        = 'ZHRPAYSLIP'
                  language                    =  sy-langu
                  options                     =  w_options
    *      IMPORTING
    *         LANGUAGE                    =
    *         NEW_ARCHIVE_PARAMS          =
    *         RESULT                      =
           exceptions
                 canceled                    = 1
                 device                      = 2
                 form                        = 3
                 options                     = 4
                 unclosed                    = 5
                 mail_options                = 6
                 archive_error               = 7
                 invalid_fax_number          = 8
                 more_params_needed_in_batch = 9
                 others                      = 10 .
    CALL FUNCTION 'CLOSE_FORM'
    *    IMPORTING
    *         RDI_RESULT               =
        TABLES
             OTFDATA                  = otfdt
          EXCEPTIONS
               UNOPENED                 = 1
               BAD_PAGEFORMAT_FOR_PRINT = 2
               SEND_ERROR               = 3
               OTHERS                   = 4.
        EXPORT otfdt TO MEMORY ID 'PDFT'.
    CALL FUNCTION 'CONVERT_OTF'
    EXPORTING
       FORMAT                      = 'PDF'
    *   MAX_LINEWIDTH               = 132
    *   ARCHIVE_INDEX               = ' '
    *   COPYNUMBER                  = 0
    *   ASCII_BIDI_VIS2LOG          = ' '
    *   PDF_DELETE_OTFTAB           = ' '
    IMPORTING
       BIN_FILESIZE                = NUMBYTES
    *   BIN_FILE                    =
      TABLES
        otf                         = otfdt
        lines                       = pdfdt
    * EXCEPTIONS
    *   ERR_MAX_LINEWIDTH           = 1
    *   ERR_FORMAT                  = 2
    *   ERR_CONV_NOT_POSSIBLE       = 3
    *   ERR_BAD_OTF                 = 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 .
    Refresh OBJTXT. clear OBJTXT.
      Refresh OBJPACK. clear OBJPACK.
      Refresh objbin. clear objbin.
      Refresh OBJHEAD. clear OBJHEAD.
      Refresh RECLIST. Clear RECLIST.
    * Creation of the document to be sent
    * File Name
      DOC_CHNG-OBJ_NAME = 'PAYSLIP'.
    * Mail Subject
      DOC_CHNG-OBJ_DESCR = 'Payslip'.
    * Mail Contents
      OBJTXT = 'This e-mail was sent from an automated system...'.
      APPEND OBJTXT.
      OBJTXT = 'Do not reply to this message.'.
      APPEND OBJTXT.
      OBJTXT = 'Please open the attachment to view the Payslip'.
      APPEND OBJTXT.
      OBJTXT = ''.
      APPEND OBJTXT.
      if not msgtxt1 is initial.
      OBJTXT = msgtxt1.
      APPEND OBJTXT.
      endif.
      if not msgtxt2 is initial.
      OBJTXT = msgtxt2.
      APPEND OBJTXT.
      endif.
      if not msgtxt3 is initial.
      OBJTXT = msgtxt3.
      APPEND OBJTXT.
      endif.
      DESCRIBE TABLE OBJTXT LINES TAB_LINES.
      READ TABLE OBJTXT INDEX TAB_LINES.
      DOC_CHNG-DOC_SIZE = ( TAB_LINES - 1 ) * 255 + STRLEN( OBJTXT ).
    * Creation of the entry for the compressed document
      CLEAR OBJPACK-TRANSF_BIN.
      OBJPACK-HEAD_START = 1.
      OBJPACK-HEAD_NUM = 0.
      OBJPACK-BODY_START = 1.
      OBJPACK-BODY_NUM = TAB_LINES.
      OBJPACK-DOC_TYPE = 'RAW'.
      APPEND OBJPACK.
    * Creation of the document attachment
    CALL FUNCTION 'QCE1_CONVERT'
       TABLES
         t_source_tab         = pdfdt
         t_target_tab         = objbin
       EXCEPTIONS
         convert_not_possible = 1
         OTHERS               = 2.
    describe table objbin lines tab_lines.
    OBJHEAD = 'Payslip.PDF'.
    APPEND OBJHEAD.
    ** Creation of the entry for the compressed attachment
      OBJPACK-TRANSF_BIN = 'X'.
      OBJPACK-HEAD_START = 1.
      OBJPACK-HEAD_NUM = 1.
      OBJPACK-BODY_START = 1.
      OBJPACK-BODY_NUM = TAB_LINES.
      OBJPACK-DOC_TYPE = 'PDF'.
      OBJPACK-OBJ_NAME = 'Payslip'.
      OBJPACK-OBJ_DESCR = 'Payslip'.
      OBJPACK-DOC_SIZE = TAB_LINES * 255.
      APPEND OBJPACK.
    * Completing the recipient list
    *  Read table i_pa0105 with key pernr = pernr-pernr binary search.
      loop at i_pa0105 where pernr = pernr-pernr and USRTY = '0010'.
      endloop.
      if sy-subrc = 0.
          RECLIST-RECEIVER = i_pa0105-USRID_LONG.
          RECLIST-REC_TYPE = 'U'.
          APPEND RECLIST.
      endif.
      if RECLIST[] is initial.
          loop at i_pa0105 where pernr = pernr-pernr and USRTY = 'MAIL'.
          endloop.
          if sy-subrc = 0.
              RECLIST-RECEIVER = i_pa0105-USRID.
              RECLIST-REC_TYPE = 'U'.
              APPEND RECLIST.
          endif.
      endif.
       if not RECLIST[] is initial.
    * Sending the document
        CALL FUNCTION 'SO_NEW_DOCUMENT_ATT_SEND_API1'
        EXPORTING
           DOCUMENT_DATA = DOC_CHNG
           PUT_IN_OUTBOX = ''
           COMMIT_WORK = 'X'
        TABLES
           PACKING_LIST = OBJPACK
           OBJECT_HEADER = OBJHEAD
           CONTENTS_BIN = OBJBIN
           CONTENTS_TXT = OBJTXT
           RECEIVERS = RECLIST
        EXCEPTIONS
           TOO_MANY_RECEIVERS = 1
           DOCUMENT_NOT_SENT = 2
           OPERATION_NO_AUTHORIZATION = 4
        OTHERS = 99.
        CASE SY-SUBRC.
           WHEN 0.
                   LOOP AT RECLIST.
    *                   Concatenate pernr-pernr '-'  RECLIST-RECEIVER(48)
    into error1.
                       IF RECLIST-RETRN_CODE = 0.
    *                     Concatenate error1 ': The document was sent' into
    error1.
                         i_errors-descr = pernr-pernr.
                         i_errors-type = 'S'.
                         append i_errors.
                       ELSE.
                         Concatenate error1 ': The document could not be
    sent' into error1.
                         i_errors-descr = error1.
                         i_errors-type = 'E'.
                         append i_errors.
                       ENDIF.
                   ENDLOOP.
            WHEN 1.
               Concatenate pernr-pernr '-'  RECLIST-RECEIVER(48) into
    error1.
               Concatenate error1 ': No authorization for sending to the
    recipients' into error1.
               i_errors-descr = error1.
               i_errors-type = 'E'.
               append i_errors.
            WHEN 2.
               Concatenate pernr-pernr '-'  RECLIST-RECEIVER(48) into
    error1.
               Concatenate error1 ': Document could not be sent to the
    recipient' into error1.
               i_errors-descr = error1.
               i_errors-type = 'E'.
               append i_errors.
            WHEN 4.
               Concatenate pernr-pernr '-'  RECLIST-RECEIVER(48) into
    error1.
               Concatenate error1 ': No send authorization' into error1.
               i_errors-descr = error1.
               i_errors-type = 'E'.
               append i_errors.
            WHEN OTHERS.
               Concatenate pernr-pernr '-'  RECLIST-RECEIVER(48) into
    error1.
               Concatenate error1 ': Error occurred while sending' into
    error1.
               i_errors-descr = error1.
               i_errors-type = 'E'.
               append i_errors.
        ENDCASE.
      else.
        error1 = pernr-pernr.
    *    Concatenate error1 ': Maintain Infotype 0105.' into error1.
        i_errors-descr = error1.
        i_errors-type = 'M'.
        append i_errors.
      endif.
    girish

  • To convert report  output from A4 page to A3 page

    Hi to all
    I am modifying the comparative statement report (For different vendors and items) which is in A4 page.
    now i want to convert it in A3 page size.
    Plz tell me what's the line-size, line count and different changes i have to do .
    Thanks & Regards
    Anubhav

    Hi ,
      You can set a element variable . While using ' write ' , you can multiply it after 'at' . For Example :
    data : i type i ,
             page(2) .
    if page = 'A3'
      i = 10 .
    else .
      i = 15 .
    endif .
    perform mywrite using 10 'abc'  .
    form mywrite using i_pos s_value  .
      data j type i .
      j = i * i_pos .
      write : at j s_value .
    endform.

Maybe you are looking for