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

PO output with XML and PDF format

Hi All,

I need PO output with XML and PDF format. when I give print it shld go to vendor with xml and pdf format through mail. please kindly guide me on this .

Thanks in advance

JK

Add a comment
10|10000 characters needed characters exceeded

Related questions

3 Answers

  • Best Answer
    author's profile photo Former Member
    Former Member
    Posted on Jul 16, 2008 at 05:58 AM
    • Internal Table declarations

    DATA: I_OTF TYPE ITCOO OCCURS 0 WITH HEADER LINE,

    I_TLINE TYPE TABLE OF TLINE WITH HEADER LINE,

    I_RECEIVERS TYPE TABLE OF SOMLRECI1 WITH HEADER LINE,

    I_RECORD LIKE SOLISTI1 OCCURS 0 WITH HEADER LINE,

    • Objects to send mail.

    I_OBJPACK LIKE SOPCKLSTI1 OCCURS 0 WITH HEADER LINE,

    I_OBJTXT LIKE SOLISTI1 OCCURS 0 WITH HEADER LINE,

    I_OBJBIN LIKE SOLISTI1 OCCURS 0 WITH HEADER LINE,

    I_RECLIST LIKE SOMLRECI1 OCCURS 0 WITH HEADER LINE,

    • Work Area declarations

    WA_OBJHEAD TYPE SOLI_TAB,

    W_CTRLOP TYPE SSFCTRLOP,

    W_COMPOP TYPE SSFCOMPOP,

    W_RETURN TYPE SSFCRESCL,

    WA_DOC_CHNG TYPE SODOCCHGI1,

    W_DATA TYPE SODOCCHGI1,

    WA_BUFFER TYPE STRING,u201DTo convert from 132 to 255

    • Variables declarations

    V_FORM_NAME TYPE RS38L_FNAM,

    V_LEN_IN LIKE SOOD-OBJLEN,

    V_LEN_OUT LIKE SOOD-OBJLEN,

    V_LEN_OUTN TYPE I,

    V_LINES_TXT TYPE I,

    V_LINES_BIN TYPE I.

    CALL FUNCTION u2018SSF_FUNCTION_MODULE_NAMEu2019

    EXPORTING

    FORMNAME = u2018ZTESTu2019

    IMPORTING

    FM_NAME = V_FORM_NAME

    EXCEPTIONS

    NO_FORM = 1

    NO_FUNCTION_MODULE = 2

    OTHERS = 3.

    IF SY-SUBRC <> 0.

    MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO

    WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.

    ENDIF.

    W_CTRLOP-GETOTF = u2018Xu2019.

    W_CTRLOP-NO_DIALOG = u2018Xu2019.

    W_COMPOP-TDNOPREV = u2018Xu2019.

    CALL FUNCTION V_FORM_NAME

    EXPORTING

    CONTROL_PARAMETERS = W_CTRLOP

    OUTPUT_OPTIONS = W_COMPOP

    USER_SETTINGS = u2018Xu2019

    IMPORTING

    JOB_OUTPUT_INFO = W_RETURN

    EXCEPTIONS

    FORMATTING_ERROR = 1

    INTERNAL_ERROR = 2

    SEND_ERROR = 3

    USER_CANCELED = 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.

    I_OTF[] = W_RETURN-OTFDATA[].

    CALL FUNCTION u2018CONVERT_OTFu2019

    EXPORTING

    FORMAT = u2018PDFu2019

    MAX_LINEWIDTH = 132

    IMPORTING

    BIN_FILESIZE = V_LEN_IN

    TABLES

    OTF = I_OTF

    LINES = I_TLINE

    EXCEPTIONS

    ERR_MAX_LINEWIDTH = 1

    ERR_FORMAT = 2

    ERR_CONV_NOT_POSSIBLE = 3

    OTHERS = 4.

    • Fehlerhandling

    IF SY-SUBRC <> 0.

    ENDIF.

    LOOP AT I_TLINE.

    TRANSLATE I_TLINE USING u2018~u2019.

    CONCATENATE WA_BUFFER I_TLINE INTO WA_BUFFER.

    ENDLOOP.

    TRANSLATE WA_BUFFER USING u2018~u2019.

    DO.

    I_RECORD = WA_BUFFER.

    APPEND I_RECORD.

    SHIFT WA_BUFFER LEFT BY 255 PLACES.

    IF WA_BUFFER IS INITIAL.

    EXIT.

    ENDIF.

    ENDDO.

    • Attachment

    REFRESH:

    I_RECLIST,

    I_OBJTXT,

    I_OBJBIN,

    I_OBJPACK.

    CLEAR WA_OBJHEAD.

    I_OBJBIN[] = I_RECORD[].

    o

    +

    #

    *

    o

    + Create Message Body

    1. Title and Description

    I_OBJTXT = u2018test with pdf-Attachment!u2019.

    APPEND I_OBJTXT.

    DESCRIBE TABLE I_OBJTXT LINES V_LINES_TXT.

    READ TABLE I_OBJTXT INDEX V_LINES_TXT.

    WA_DOC_CHNG-OBJ_NAME = u2019smartformu2019.

    WA_DOC_CHNG-EXPIRY_DAT = SY-DATUM + 10.

    WA_DOC_CHNG-OBJ_DESCR = u2019smartformu2019.

    WA_DOC_CHNG-SENSITIVTY = u2018Fu2019.

    WA_DOC_CHNG-DOC_SIZE = V_LINES_TXT * 255.

    1. Main Text

    • wa_doc_chng-doc_size = ( v_lines_txt - 1 ) * 255 + strlen( i_objtxt )

    *.

    CLEAR I_OBJPACK-TRANSF_BIN.

    I_OBJPACK-HEAD_START = 1.

    I_OBJPACK-HEAD_NUM = 0.

    I_OBJPACK-BODY_START = 1.

    I_OBJPACK-BODY_NUM = V_LINES_TXT.

    I_OBJPACK-DOC_TYPE = u2018RAWu2019.

    APPEND I_OBJPACK.

    o

    +

    1. Attachment

    • (pdf-Attachment)

    I_OBJPACK-TRANSF_BIN = u2018Xu2019.

    I_OBJPACK-HEAD_START = 1.

    I_OBJPACK-HEAD_NUM = 0.

    I_OBJPACK-BODY_START = 1.

    • Länge des Attachment ermitteln

    DESCRIBE TABLE I_OBJBIN LINES V_LINES_BIN.

    READ TABLE I_OBJBIN INDEX V_LINES_BIN.

    I_OBJPACK-DOC_SIZE = V_LINES_BIN * 255 .

    I_OBJPACK-BODY_NUM = V_LINES_BIN.

    I_OBJPACK-DOC_TYPE = u2018PDFu2019.

    I_OBJPACK-OBJ_NAME = u2019smartu2019.

    I_OBJPACK-OBJ_DESCR = u2018testu2019.

    APPEND I_OBJPACK.

    CLEAR I_RECLIST.

    I_RECLIST-RECEIVER = email address in qoutes.

    I_RECLIST-REC_TYPE = u2018Uu2019.

    APPEND I_RECLIST.

    CALL FUNCTION u2018SO_NEW_DOCUMENT_ATT_SEND_API1u2032

    EXPORTING

    DOCUMENT_DATA = WA_DOC_CHNG

    PUT_IN_OUTBOX = u2018Xu2019

    TABLES

    PACKING_LIST = I_OBJPACK

    OBJECT_HEADER = WA_OBJHEAD

    CONTENTS_BIN = I_OBJBIN

    CONTENTS_TXT = I_OBJTXT

    RECEIVERS = I_RECLIST

    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.

    Another EXample

    CALL FUNCTION 'RSPO_FIND_SPOOL_REQUESTS'

    EXPORTING

    RQOWNER = SY-UNAME

    TABLES

    SPOOLREQUESTS = SPOOL_REQUESTS.

    READ TABLE SPOOL_REQUESTS INDEX 1.

    GD_SPOOL_NR = SPOOL_REQUESTS-RQIDENT.

    CALL FUNCTION 'CONVERT_OTFSPOOLJOB_2_PDF'

    EXPORTING

    SRC_SPOOLID = GD_SPOOL_NR

    NO_DIALOG = C_NO

    IMPORTING

    PDF_BYTECOUNT = GD_BYTECOUNT

    PDF_SPOOLID = PDFSPOOLID

    BTC_JOBNAME = JOBNAME

    BTC_JOBCOUNT = JOBCOUNT

    TABLES

    PDF = IT_PDF_OUTPUT

    EXCEPTIONS

    ERR_NO_OTF_SPOOLJOB = 1

    ERR_NO_SPOOLJOB = 2

    ERR_NO_PERMISSION = 3

    ERR_CONV_NOT_POSSIBLE = 4

    ERR_BAD_DSTDEVICE = 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.

    CHECK SY-SUBRC = 0.

    FOR XML SEE THIS:

    http://www.erpgenie.com/netweaver/images/SAP%20Smart%20Forms%20XSF%20-%20XML%20Output%20for%20Smart%20Forms%20for%20SAP%20Web%20Application%20Server%20610.pdf

    REWARD IF HELPFUL

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Jul 16, 2008 at 06:30 AM

    hi,

    try this code to get in pdf form

    REPORT zsuresh_test.

    • Variable declarations

    DATA:

    w_form_name TYPE tdsfname VALUE 'ZSURESH_TEST',

    w_fmodule TYPE rs38l_fnam,

    w_cparam TYPE ssfctrlop,

    w_outoptions TYPE ssfcompop,

    W_bin_filesize TYPE i, " Binary File Size

    w_FILE_NAME type string,

    w_File_path type string,

    w_FULL_PATH type string.

    • Internal tables declaration

    • Internal table to hold the OTF data

    DATA:

    t_otf TYPE itcoo OCCURS 0 WITH HEADER LINE,

    • Internal table to hold OTF data recd from the SMARTFORM

    t_otf_from_fm TYPE ssfcrescl,

    • Internal table to hold the data from the FM CONVERT_OTF

    T_pdf_tab LIKE tline OCCURS 0 WITH HEADER LINE.

    • This function module call is used to retrieve the name of the Function

    • module generated when the SMARTFORM is activated

    CALL FUNCTION 'SSF_FUNCTION_MODULE_NAME'

    EXPORTING

    formname = w_form_name

    • VARIANT = ' '

    • DIRECT_CALL = ' '

    IMPORTING

    fm_name = w_fmodule

    EXCEPTIONS

    no_form = 1

    no_function_module = 2

    OTHERS = 3

    .

    IF sy-subrc <> 0.

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

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

    ENDIF.

    • Calling the SMARTFORM using the function module retrieved above

    • GET_OTF parameter in the CONTROL_PARAMETERS is set to get the OTF

    • format of the output

    w_cparam-no_dialog = 'X'.

    w_cparam-preview = space. " Suppressing the dialog box

    " for print preview

    w_cparam-getotf = 'X'.

    • Printer name to be used is provided in the export parameter

    • OUTPUT_OPTIONS

    w_outoptions-tddest = 'LP01'.

    CALL FUNCTION w_fmodule

    EXPORTING

    • ARCHIVE_INDEX =

    • ARCHIVE_INDEX_TAB =

    • ARCHIVE_PARAMETERS =

    control_parameters = w_cparam

    • MAIL_APPL_OBJ =

    • MAIL_RECIPIENT =

    • MAIL_SENDER =

    output_options = w_outoptions

    • USER_SETTINGS = 'X'

    IMPORTING

    • DOCUMENT_OUTPUT_INFO =

    job_output_info = t_otf_from_fm

    • JOB_OUTPUT_OPTIONS =

    EXCEPTIONS

    formatting_error = 1

    internal_error = 2

    send_error = 3

    user_canceled = 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.

    t_otf[] = t_otf_from_fm-otfdata[].

    • Function Module CONVERT_OTF is used to convert the OTF format to PDF

    CALL FUNCTION 'CONVERT_OTF'

    EXPORTING

    FORMAT = 'PDF'

    MAX_LINEWIDTH = 132

    • ARCHIVE_INDEX = ' '

    • COPYNUMBER = 0

    • ASCII_BIDI_VIS2LOG = ' '

    • PDF_DELETE_OTFTAB = ' '

    IMPORTING

    BIN_FILESIZE = W_bin_filesize

    • BIN_FILE =

    TABLES

    otf = T_OTF

    lines = T_pdf_tab

    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.

    • To display File SAVE dialog window

    CALL METHOD cl_gui_frontend_services=>file_save_dialog

    • EXPORTING

    • WINDOW_TITLE =

    • DEFAULT_EXTENSION =

    • DEFAULT_FILE_NAME =

    • FILE_FILTER =

    • INITIAL_DIRECTORY =

    • WITH_ENCODING =

    • PROMPT_ON_OVERWRITE = 'X'

    CHANGING

    filename = w_FILE_NAME

    path = w_FILE_PATH

    fullpath = w_FULL_PATH

    • USER_ACTION =

    • FILE_ENCODING =

    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.

    • Use the FM GUI_DOWNLOAD to download the generated PDF file onto the

    • presentation server

    CALL FUNCTION 'GUI_DOWNLOAD'

    EXPORTING

    BIN_FILESIZE = W_bin_filesize

    filename = w_FULL_PATH

    FILETYPE = 'BIN'

    • APPEND = ' '

    • WRITE_FIELD_SEPARATOR = ' '

    • HEADER = '00'

    • TRUNC_TRAILING_BLANKS = ' '

    • WRITE_LF = 'X'

    • COL_SELECT = ' '

    • COL_SELECT_MASK = ' '

    • DAT_MODE = ' '

    • CONFIRM_OVERWRITE = ' '

    • NO_AUTH_CHECK = ' '

    • CODEPAGE = ' '

    • IGNORE_CERR = ABAP_TRUE

    • REPLACEMENT = '#'

    • WRITE_BOM = ' '

    • TRUNC_TRAILING_BLANKS_EOL = 'X'

    • WK1_N_FORMAT = ' '

    • WK1_N_SIZE = ' '

    • WK1_T_FORMAT = ' '

    • WK1_T_SIZE = ' '

    • IMPORTING

    • FILELENGTH =

    tables

    data_tab = T_pdf_tab

    • FIELDNAMES =

    • EXCEPTIONS

    • FILE_WRITE_ERROR = 1

    • NO_BATCH = 2

    • GUI_REFUSE_FILETRANSFER = 3

    • INVALID_TYPE = 4

    • NO_AUTHORITY = 5

    • UNKNOWN_ERROR = 6

    • HEADER_NOT_ALLOWED = 7

    • SEPARATOR_NOT_ALLOWED = 8

    • FILESIZE_NOT_ALLOWED = 9

    • HEADER_TOO_LONG = 10

    • DP_ERROR_CREATE = 11

    • DP_ERROR_SEND = 12

    • DP_ERROR_WRITE = 13

    • UNKNOWN_DP_ERROR = 14

    • ACCESS_DENIED = 15

    • DP_OUT_OF_MEMORY = 16

    • DISK_FULL = 17

    • DP_TIMEOUT = 18

    • FILE_NOT_FOUND = 19

    • DATAPROVIDER_EXCEPTION = 20

    • CONTROL_FLUSH_ERROR = 21

    • OTHERS = 22

    .

    IF sy-subrc <> 0.

    • MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO

    • WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.

    ENDIF.

    reward points if useful,

    siri

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Dec 18, 2008 at 07:24 AM

    jj

    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.