Skip to Content
author's profile photo Former Member
Former Member

print, pdf, mail from form

Hello,

I want to print, create pdf file on desktop and send external mail of invoice from SAP form (all in one program).

I have following question:

1) can we do all from one program?

2) Will it download pdf file on presentation server (c:\filename.pdf) even thought output will be called in a document while saving in backgroung?

3) If we send mail can we have multiple recipents?

4) Any sample code or reference?

Thank you.

AP

Add a comment
10|10000 characters needed characters exceeded

Related questions

2 Answers

  • Best Answer
    author's profile photo Former Member
    Former Member
    Posted on Mar 20, 2008 at 04:33 AM

    Hi,

    This is the program to download form into pdf file.

    1.Directly with RSTXPDFT4.

    or

    TABLES : vbrk.

    *}

    TYPE-POOLS : slis.

    ************************************************************************

    • GLOBAL TYPES

    • naming convention: "TY_name"

    ************************************************************************

    *

    ************************************************************************

    • GLOBAL CONSTANTS

    • naming convention: "c_name"

    ************************************************************************

    *

    ************************************************************************

    • GLOBAL ELEMENTARY VARIABLES

    • naming convention: "w_name"

    ************************************************************************

    *

    ************************************************************************

    • GLOBAL STRUCTURES

    • naming convention: "st_name"

    ************************************************************************

    *

    ************************************************************************

    • GLOBAL INTERNAL TABLES

    • naming convention: "i_name"

    ************************************************************************

    DATA:i_bdcdata TYPE TABLE OF bdcdata ,

    i_fieldcat TYPE slis_t_fieldcat_alv ,

    i_vbrk TYPE TABLE OF ty_vbrk ,

    i_sort TYPE slis_t_sortinfo_alv , "for sorting the fields

    i_rows TYPE lvc_t_row .

    ************************************************************************

    • PARAMETERS & SELECT-OPTIONS

    • aming convention: "p_name" & "s_name"

    ************************************************************************

    *{

    SELECTION-SCREEN BEGIN OF BLOCK b1." WITH FRAME TITLE text-010.

    SELECT-OPTIONS : s_vkorg FOR vbrk-vkorg OBLIGATORY,

    s_fkart FOR vbrk-fkart OBLIGATORY,

    s_kunag FOR vbrk-kunag ,

    s_vbeln FOR vbrk-vbeln ,

    s_fkdat FOR vbrk-fkdat OBLIGATORY.

    SELECTION-SCREEN END OF BLOCK b1.

    SELECTION-SCREEN BEGIN OF BLOCK b2.

    PARAMETERS: p_file1 TYPE string DEFAULT 'C:\'.

    SELECTION-SCREEN END OF BLOCK b2.

    *}

    DEFINE m_fieldcat.

    add 1 to st_fieldcat-col_pos.

    st_fieldcat-fieldname = &1.

    st_fieldcat-ref_tabname = 'VBRK'.

    st_fieldcat-seltext_s = &2.

    st_fieldcat-seltext_m = &3.

    st_fieldcat-seltext_l = &4.

    append st_fieldcat to i_fieldcat.

    END-OF-DEFINITION.

    ************************************************************************

    • START-OF-SELECTION

    ************************************************************************

    *{

    AT SELECTION-SCREEN ON VALUE-REQUEST FOR p_file1.

    CALL METHOD cl_gui_frontend_services=>directory_browse

    CHANGING

    selected_folder = p_file1

    EXCEPTIONS

    cntl_error = 1

    error_no_gui = 2

    not_supported_by_gui = 3

    OTHERS = 4.

    IF sy-subrc <> 0.

    MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno

    WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.

    ENDIF.

    START-OF-SELECTION.

    EXPORT w_file FROM p_file1 TO MEMORY ID 'ZMEM1'(005).

    *}

    PERFORM f1000_get_data.

    PERFORM f2000_display_data.

    *&----


    *

    *& Form F1000_get_data

    *&----


    • This routine is used for Get the data from VBRK based on

    • Selection Screen

    *----


    *

    FORM f1000_get_data.

    SELECT vkorg

    fkart

    kunag

    vbeln

    fkdat

    INTO TABLE i_vbrk

    FROM vbrk

    WHERE vkorg IN s_vkorg

    AND fkart IN s_fkart

    AND kunag IN s_kunag

    AND vbeln IN s_vbeln

    AND fkdat IN s_fkdat.

    IF sy-subrc NE 0.

    MESSAGE i014(zmsg) WITH 'No data is available for your Input'(003).

    ENDIF.

    ENDFORM. "get_data

    *&----


    *

    *& Form F2000_display_data

    *&----


    • This routine is used for building field catalogs and display

    • ALV Data

    *----


    *

    FORM f2000_display_data.

    PERFORM f6000_field_cat.

    PERFORM f7000_sort.

    CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'

    EXPORTING

    i_callback_program = sy-repid

    i_callback_pf_status_set = 'F3000_PF_STATUS_SET'

    i_callback_user_command = 'F4000_USER_COMMAND'

    is_layout = st_layout

    it_fieldcat = i_fieldcat

    it_sort = i_sort

    TABLES

    t_outtab = i_vbrk.

    ENDFORM. "display_data

    *&----


    *

    *& Form F6000_field_cat

    *&----


    • This routine is used for building field catalogs and display

    • ALV Data

    *----


    *

    FORM f6000_field_cat.

    m_fieldcat 'VKORG' '' '' ''.

    m_fieldcat 'FKART' 'Billing Document Type'(007) 'Billing Document Type'(007) 'Billing Document Type'(007).

    m_fieldcat 'KUNAG' 'Customer No'(008) 'Customer No'(008) 'Customer No'(008).

    m_fieldcat 'VBELN' 'Invoice No'(009) 'Invoice No'(009) 'Invoice No'(009).

    m_fieldcat 'FKDAT' '' '' ''.

    st_layout-cell_merge = 'X'.

    st_layout-colwidth_optimize = 'X'.

    st_layout-box_fieldname = 'VKORG'.

    ENDFORM. "F7000_field_cat

    &----


    *& Form F7000_sort

    &----


    FORM f7000_sort .

    CLEAR st_sort.

    st_sort-fieldname = 'VBELN'.

    st_sort-up = 'X'.

    st_sort-group = 'UL'.

    APPEND st_sort TO i_sort.

    ENDFORM. "f6000_sort

    ----


    • FORM F3000_PF_STATUS_SET *

    *&----


    • This routine is for creating User button on output

    ----


    FORM f3000_pf_status_set USING ut_extab TYPE slis_t_extab. "#EC CALLED

    SET PF-STATUS 'ZPF_STATUS' OF PROGRAM 'ZVRXX_SF_PDF_DOWNLOAD'

    EXCLUDING ut_extab.

    ENDFORM. " PF_STATUS_SET

    ----


    • FORM F4000_USER_COMMAND *

    *&----


    • This routine is for When user on clicks on custom button in

    • OUTPUT and Download to PDF format

    ----


    FORM f4000_user_command USING ucomm TYPE sy-ucomm

    sel TYPE slis_selfield.

    TYPES: BEGIN OF ty_alv,

    lights(1) TYPE c, "Exception, Holding the value of the lights

    number(14) TYPE c, "billing document no

    text(150) TYPE c, "text

    END OF ty_alv.

    DATA: gs_alv TYPE ty_alv,

    gt_alv TYPE TABLE OF ty_alv,

    gr_alv TYPE REF TO cl_salv_table,

    gr_columns TYPE REF TO cl_salv_columns_table,

    gr_column TYPE REF TO cl_salv_column,

    lw_ref TYPE REF TO cx_salv_not_found,

    lw_ref1 TYPE REF TO cx_salv_msg,

    lw_ref2 TYPE REF TO cx_salv_data_error,

    lw_text TYPE string,

    lw_pdf(3) TYPE c,

    lw_pdf1(3) TYPE c.

    DATA: ref_grid TYPE REF TO cl_gui_alv_grid.

    DATA :lw_row_index TYPE lvc_index ,

    lw_subrc TYPE sy-subrc .

    CONSTANTS : c_0 TYPE c VALUE '0'.

    *then insert the following code in your USER_COMMAND routine...

    IF ref_grid IS INITIAL.

    CALL FUNCTION 'GET_GLOBALS_FROM_SLVC_FULLSCR'

    IMPORTING

    e_grid = ref_grid.

    ENDIF.

    IF NOT ref_grid IS INITIAL.

    CALL METHOD ref_grid->check_changed_data.

    ENDIF.

    CASE ucomm.

    WHEN 'PDF'.

    lw_pdf = 'PDF'.

    EXPORT lw_pdf1 FROM lw_pdf TO MEMORY ID 'ZMEM4'(004).

    CALL METHOD ref_grid->get_selected_rows

    IMPORTING

    et_index_rows = i_rows.

    LOOP AT i_rows

    INTO st_selected_line.

    lw_row_index = st_selected_line-index.

    CLEAR st_selected_line.

    READ TABLE i_vbrk

    INTO st_vbrk

    INDEX lw_row_index.

    IF sy-subrc EQ 0.

    CLEAR:w_vbeln.

    MOVE st_vbrk-vbeln TO w_vbeln.

    EXPORT lw_vbeln1 FROM w_vbeln TO MEMORY ID 'ZMEM'(004).

    lw_subrc = 1.

    *--Begin of changes for DRFK904991

    *--We need an identifier to tell the print program that PDF is being

    • downloaded through this program and the word "COPY" should not be

    • printed hence we are exporting this flag to memory which will be

    • read later on in the smartform

    DATA l_pdf TYPE c.

    l_pdf = 'X'.

    EXPORT l_pdf TO MEMORY ID 'ZPDF'.

    PERFORM f5000_print_vbeln USING w_vbeln.

    FREE MEMORY ID 'ZPDF'.

    *--End of changes for DRFK904991

    IMPORT lw_subrc1 TO lw_subrc FROM MEMORY ID 'ZMEM2'(006).

    CLEAR : w_objky.

    SELECT objky

    FROM nast

    UP TO 1 ROWS

    INTO w_objky

    WHERE kappl EQ c_v3

    AND objky EQ w_vbeln

    AND ( kschl EQ c_zrd0 OR kschl EQ c_zrdx ).

    • and nacha eq '8'. "--02/15/2008

    ENDSELECT.

    *insertion by kudalarr on 05-02-2008

    *displaying the status of download.

    IF w_objky NE space

    AND lw_subrc EQ c_0.

    st_check-value = 'PDF is Generated Successfully'(001).

    gs_alv-lights = '3'. "Color green

    gs_alv-number = w_objky.

    gs_alv-text = st_check-value.

    APPEND gs_alv TO gt_alv.

    ELSE.

    st_check-value = 'PDF is not Generated'(002).

    gs_alv-lights = '1'. "Color red

    gs_alv-number = w_vbeln.

    gs_alv-text = st_check-value.

    APPEND gs_alv TO gt_alv.

    ENDIF.

    ENDIF.

    lw_subrc = 1.

    EXPORT lw_subrc1 FROM lw_subrc TO MEMORY ID 'ZMEM2'.

    ENDLOOP.

    ENDCASE.

    *GETTING ALL THE COLUMNS AND ASSISGNING THE COLUMN NAMES TO THE RESPECTIVE.

    TRY.

    CALL METHOD cl_salv_table=>factory

    IMPORTING

    r_salv_table = gr_alv

    CHANGING

    t_table = gt_alv.

    CATCH cx_salv_msg INTO lw_ref1.

    lw_text = lw_ref1->get_text( ).

    IF NOT lw_text IS INITIAL.

    ENDIF.

    ENDTRY.

    gr_columns = gr_alv->get_columns( ).

    TRY.

    CALL METHOD gr_columns->get_column

    EXPORTING

    columnname = 'NUMBER'

    RECEIVING

    value = gr_column.

    CATCH cx_salv_not_found INTO lw_ref .

    lw_text = lw_ref->get_text( ).

    IF NOT lw_text IS INITIAL.

    ENDIF.

    ENDTRY.

    TRY.

    CALL METHOD gr_column->set_long_text

    EXPORTING

    value = 'Invoice number'(010).

    CALL METHOD gr_columns->get_column

    EXPORTING

    columnname = 'TEXT'

    RECEIVING

    value = gr_column.

    CALL METHOD gr_column->set_long_text

    EXPORTING

    value = 'Status'(011).

    CATCH cx_salv_not_found ."INTO LW_REF.

    lw_text = lw_ref->get_text( ).

    IF NOT lw_text IS INITIAL.

    ENDIF.

    ENDTRY.

    *DISPALYING THE STATUS OF PDF GENERATION.

    TRY.

    gr_columns->set_exception_column( value = 'LIGHTS' ).

    CALL METHOD gr_alv->display.

    CATCH cx_salv_data_error INTO lw_ref2.

    lw_text = lw_ref2->get_text( ).

    IF NOT lw_text IS INITIAL.

    ENDIF.

    ENDTRY.

    IF NOT sel IS INITIAL.

    ENDIF.

    *end of insertion by kudalarr on 05-02-2008

    ENDFORM. "sub_user_command

    "F6000_sort

    &----


    *& Form F5000_print_vbeln

    &----


    • text

    ----


    • --> p1 text

    • <-- p2 text

    ----


    FORM f5000_print_vbeln USING l_vbeln TYPE vbeln.

    CONSTANTS: c_ctumode(1) TYPE c VALUE 'N', "set the parametrs for call transaction.

    c_cupdate(1) TYPE c VALUE 'A'. "set the parametrs for call transaction

    DATA:lw_kschl TYPE sna_kschl.

    DATA : lw_field TYPE dd03l-fieldname,

    lw_counter(2) TYPE n .

    REFRESH: i_bdcdata.

    CLEAR: lw_kschl,

    lw_counter,

    lw_field.

    SELECT kschl

    FROM nast

    INTO lw_kschl

    UP TO 1 ROWS

    WHERE kappl EQ c_v3

    AND kschl EQ c_rd00

    AND objky EQ l_vbeln.

    • and nacha eq '8'. "--02/15/2008

    ENDSELECT.

    IF sy-subrc EQ 0.

    lw_counter = lw_counter + 1.

    ENDIF.

    CLEAR:lw_kschl.

    SELECT kschl

    FROM nast

    INTO lw_kschl

    UP TO 1 ROWS

    WHERE kappl EQ c_v3

    AND ( kschl EQ c_zrd0 OR kschl EQ c_zrdx )

    AND objky EQ l_vbeln.

    • and nacha eq '8'. "--02/15/2008

    ENDSELECT.

    IF sy-subrc = 0.

    lw_counter = lw_counter + 1.

    ELSE.

    MESSAGE i015(zmsg) WITH 'No output Type Available for the selected Invoice'(013) l_vbeln.

    ENDIF.

    PERFORM bdc_dynpro USING 'SAPMV60A' '0101'.

    PERFORM bdc_field USING 'BDC_CURSOR'

    'VBRK-VBELN'.

    PERFORM bdc_field USING 'BDC_OKCODE'

    '=DRCK'.

    PERFORM bdc_field USING 'VBRK-VBELN'

    l_vbeln.

    PERFORM bdc_dynpro USING 'SAPLVMSG' '0200'.

    CONCATENATE 'NAST-KSCHL(' lw_counter ')' INTO lw_field.

    PERFORM bdc_field USING 'BDC_CURSOR'

    lw_field.

    CLEAR:lw_field.

    CONCATENATE 'ROW_MARK(' lw_counter ')' INTO lw_field.

    PERFORM bdc_field USING 'BDC_OKCODE'

    '=PRNT'.

    PERFORM bdc_field USING lw_field

    'X'.

    CALL TRANSACTION 'VF03' USING i_bdcdata MODE c_ctumode

    UPDATE c_cupdate.

    IF sy-subrc EQ 0.

    MESSAGE s999(zyus) WITH 'Invoice Report'(012).

    ENDIF.

    ENDFORM. " SUB_PRINT_VBELN

    ----


    • Start new screen *

    ----


    FORM bdc_dynpro USING program dynpro .

    CLEAR st_bdcdata.

    st_bdcdata-program = program.

    st_bdcdata-dynpro = dynpro.

    st_bdcdata-dynbegin = 'X'.

    APPEND st_bdcdata TO i_bdcdata.

    ENDFORM. "BDC_DYNPRO

    ----


    • Insert field *

    ----


    FORM bdc_field USING fnam fval.

    CLEAR st_bdcdata.

    st_bdcdata-fnam = fnam.

    st_bdcdata-fval = fval.

    APPEND st_bdcdata TO i_bdcdata.

    ENDFORM.

    Regards(replay with points),

    Shiva.

    Edited by: shiva kumar on Mar 20, 2008 5:33 AM

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Mar 20, 2008 at 04:34 AM

    Hi,

    Have a look program RSTXPDFT4.

    Regards

    Kiran Sure

    Add a comment
    10|10000 characters needed characters exceeded

Before answering

You should only submit an answer when you are proposing a solution to the poster's problem. If you want the poster to clarify the question or provide more information, please leave a comment instead, requesting additional details. When answering, please include specifics, such as step-by-step instructions, context for the solution, and links to useful resources. Also, please make sure that you answer complies with our Rules of Engagement.
You must be Logged in to submit an answer.

Up to 10 attachments (including images) can be used with a maximum of 1.0 MB each and 10.5 MB total.