2015 Jul 13 10:19 AM
Hi People,
I have one requirement.
A report program which has po number on selection screen.
After execution it should goto that PO, read it and den covert it into pdf and den mail it further.
The PO is attached to NEU o/p type and it is a script.
...
So now i used 'ME_READ_PO_FOR_PRINTING' and ' ME_PRINT_PO' FMs....i am getting Print Preview dialog box, so my question is how should i remove it and convert it into PDF format somehow....for emailing purpose i have my code.
Regards,
2015 Jul 13 10:59 AM
Hi Ketan,
1.Once you get data in the internal table convert this format into pdf.
2.Now you can mail that pdf data.
See sample code below:
CALL FUNCTION 'CLOSE_FORM'
IMPORTING
RESULT = ITCPP
TABLES
OTFDATA = DATAB[]
EXCEPTIONS
UNOPENED = 3.
IF FINAA-NACHA = 2.
COMMIT WORK.
ENDIF.
IF SY-SUBRC = 3.
MESSAGE E403.
ENDIF.
CALL FUNCTION 'CONVERT_OTF'
EXPORTING
FORMAT = 'PDF'
* MAX_LINEWIDTH = 132
* ARCHIVE_INDEX = ' '
* COPYNUMBER = 0
* ASCII_BIDI_VIS2LOG = ' '
* PDF_DELETE_OTFTAB = ' '
* PDF_USERNAME = ' '
* PDF_PREVIEW = ' '
* USE_CASCADING = ' '
IMPORTING
BIN_FILESIZE = BIN_FILESIZE
* BIN_FILE =
TABLES
OTF = DATAB[]
LINES = PDFTAB[]
* EXCEPTIONS
* ERR_MAX_LINEWIDTH = 1
* ERR_FORMAT = 2
* ERR_CONV_NOT_POSSIBLE = 3
* ERR_BAD_OTF = 4
* OTHERS = 5
.
IF SY-SUBRC <> 0.
* Implement suitable error handling here
ENDIF.
Hi Ketan,
1.Once you get data in the internal table convert this format into pdf.
2.Now you can mail that pdf data.
See sample code below:
CALL FUNCTION 'CLOSE_FORM'
IMPORTING
RESULT = ITCPP
TABLES
OTFDATA = DATAB[]
EXCEPTIONS
UNOPENED = 3.
IF FINAA-NACHA = 2.
COMMIT WORK.
ENDIF.
IF SY-SUBRC = 3.
MESSAGE E403.
ENDIF.
CALL FUNCTION 'CONVERT_OTF'
EXPORTING
FORMAT = 'PDF'
* MAX_LINEWIDTH = 132
* ARCHIVE_INDEX = ' '
* COPYNUMBER = 0
* ASCII_BIDI_VIS2LOG = ' '
* PDF_DELETE_OTFTAB = ' '
* PDF_USERNAME = ' '
* PDF_PREVIEW = ' '
* USE_CASCADING = ' '
IMPORTING
BIN_FILESIZE = BIN_FILESIZE
* BIN_FILE =
TABLES
OTF = DATAB[]
LINES = PDFTAB[]
* EXCEPTIONS
* ERR_MAX_LINEWIDTH = 1
* ERR_FORMAT = 2
* ERR_CONV_NOT_POSSIBLE = 3
* ERR_BAD_OTF = 4
* OTHERS = 5
.
IF SY-SUBRC <> 0.
* Implement suitable error handling here
ENDIF.
2015 Jul 13 10:59 AM
Hi Ketan,
1.Once you get data in the internal table convert this format into pdf.
2.Now you can mail that pdf data.
See sample code below:
CALL FUNCTION 'CLOSE_FORM'
IMPORTING
RESULT = ITCPP
TABLES
OTFDATA = DATAB[]
EXCEPTIONS
UNOPENED = 3.
IF FINAA-NACHA = 2.
COMMIT WORK.
ENDIF.
IF SY-SUBRC = 3.
MESSAGE E403.
ENDIF.
CALL FUNCTION 'CONVERT_OTF'
EXPORTING
FORMAT = 'PDF'
* MAX_LINEWIDTH = 132
* ARCHIVE_INDEX = ' '
* COPYNUMBER = 0
* ASCII_BIDI_VIS2LOG = ' '
* PDF_DELETE_OTFTAB = ' '
* PDF_USERNAME = ' '
* PDF_PREVIEW = ' '
* USE_CASCADING = ' '
IMPORTING
BIN_FILESIZE = BIN_FILESIZE
* BIN_FILE =
TABLES
OTF = DATAB[]
LINES = PDFTAB[]
* EXCEPTIONS
* ERR_MAX_LINEWIDTH = 1
* ERR_FORMAT = 2
* ERR_CONV_NOT_POSSIBLE = 3
* ERR_BAD_OTF = 4
* OTHERS = 5
.
IF SY-SUBRC <> 0.
* Implement suitable error handling here
ENDIF.
2015 Jul 13 11:13 AM
Hi YOGENDRA PANDEY,
Thanks for the reply.
For now my code is as follows after execution :
******************* (For now PO number is hardcoded)
TABLES: nast, "Messages
*nast, "Messages
tnapr, "Programs & Forms
itcpo, "Communicationarea for Spool
arc_params, "Archive parameters
toa_dara, "Archive parameters
addr_key. "Adressnumber for ADDRESS
TYPE-POOLS MEEIN .
TYPES:
*- Tabelle der Aenderungsbescheibungen -
*
BEGIN OF meein_XAEND.
include structure cdshw.
types: EBELP LIKE EKPO-EBELP,
ZEKKN LIKE EKKN-ZEKKN,
ETENR LIKE EKET-ETENR,
CTXNR LIKE T166C-CTXNR,
ROUNR LIKE T166C-ROUNR,
INSERT,
FLAG_ADRNR,
END OF meein_XAEND,
*- Tabelle der Textänderungen -
*
BEGIN OF meein_XAETX,
EBELP LIKE EKPO-EBELP,
TEXTART LIKE CDSHW-TEXTART,
CHNGIND LIKE CDSHW-CHNGIND,
END OF meein_XAETX.
types: meein_xaend_itab type meein_xaend occurs 0.
* TYPES: BEGIN OF meein_purchase_doc_print,
* xekko LIKE ekko,
* xpekko LIKE pekko,
* xekpa LIKE msgpa OCCURS 0,
* xekpo LIKE ekpo OCCURS 0,
* xpekpo LIKE pekpo OCCURS 0,
* xeket LIKE eket OCCURS 0,
* xekkn LIKE ekkn OCCURS 0,
* xekek LIKE ekek OCCURS 0,
* xekeh LIKE ekeh OCCURS 0,
* xaend TYPE meein_xaend OCCURS 0,
* xtkomv TYPE komv OCCURS 0,
* xaetx TYPE meein_xaetx OCCURS 0,
* END OF meein_purchase_doc_print.
DATA: l_druvo LIKE t166k-druvo,
l_nast LIKE nast,
l_from_memory,
l_doc TYPE MEEIN_PURCHASE_DOC_PRINT,
p_nast TYPE nast,
ent_retco TYPE sysubrc,
ent_screen TYPE char1.
p_nast-mandt = sy-mandt.
p_nast-kappl = 'EF'.
p_nast-objky = '4500012164'.
p_nast-kschl = 'NEU'.
p_nast-spras = 'E'.
IF p_nast-aende EQ space.
l_druvo = '1'.
ELSE.
l_druvo = '2'.
ENDIF.
nast = p_nast.
*TYPEs-group : MEEIN.
CALL FUNCTION 'ME_READ_PO_FOR_PRINTING'
EXPORTING
ix_nast = nast
ix_screen = ent_screen
IMPORTING
ex_retco = ent_retco
ex_nast = l_nast
doc = l_doc
CHANGING
cx_druvo = l_druvo
cx_from_memory = l_from_memory.
CHECK ent_retco EQ 0.
CALL FUNCTION 'ME_PRINT_PO'
EXPORTING
ix_nast = l_nast
ix_druvo = l_druvo
doc = l_doc
ix_screen = ent_screen
ix_from_memory = l_from_memory
ix_toa_dara = toa_dara
ix_arc_params = arc_params
ix_fonam = tnapr-fonam "HW 214570
IMPORTING
ex_retco = ent_retco.
*****************
after this execution m gettin the dialog box of choosing OP device and other options, so ma qn is how to remove it first...by passing LP01 as OP device......
And now where you want me to write the code u specified now ???
2015 Jul 13 12:17 PM
Hi Ketan,
You are saying that it is a sapscript so after close form operation convert it to pdf.Below thread may b help you.
| User | Count |
|---|---|
| 4 | |
| 2 | |
| 2 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 |