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
Similar Messages
-
How to convert data from a report in PDF which are specified on multiple lines ?
It often occurs that in a report one detail entry is folded onto two subsequent lines.
e.g.
No.
Container Lt Ht Tp F/E Dam Weight Temp Bi Im First Seal No. Cell Booking ref.
In Arr id A Tml PoL PD PoD C T L R F B
1 XXXU123456-7 20 ST I F 24.000 SLX11 1 25A CVA12345
How does the conversion to Excel is going to handle this ?
I need the second line of data in my excel sheet.
YES 9/10 14:15 BEANR REFCTHello Jay,
Don't use SSIS to convert. Use SSIS to FTP the files out.
How you convert to PDF: the format is owned by Adobe so there might be royalties involved, but there are paid and free (OSS) libraries to doing so. Just search online.
Arthur
MyBlog
Twitter -
Unable to convert dates to text in scanned PDFs
I am using Adobe Acrobat XI Pro. I am converting scanned images to text by recognizing the text using OCR.
However, some portions of my file, specially dates in format MM/DD/YY format are not being converted to text. I cannot even convert them to text by clicking "Find All Suspect" under "OCR Suspects" since they are not being listed.
Please help.Find All Suspects does not convert to text but it gives the option to accept a text as converted by the OCR. However, in case of the dates, this is not an option since the date is being treated as an image. Any other method which might help to recognize dates as text?
-
While converting spool to PDF, no data is coming in the PDF file.
Hi All,
I am submitting a z program ZPR022_INNCOMETAX_REPORT_COPY1 (which has some output display) from Z_ITSLIP_MAIL. I am creating a job, submitting the above program via JOB to SAP-SPOOL.
In program ZPR022_INNCOMETAX_REPORT_COPY1 , I am getting the run time job information and from there I am getting the spool id. Now I am converting the spool id to a PDF. This PDF should contain the output of the program ZPR022_INNCOMETAX_REPORT_COPY1. This output is normal output using Write statement only. But once the program is executed, I could find no data in the PDF file. When I check in SM37 and SP02, both the JOB and the SPOOL are created. What I feel is the program is not picking the spool id at the run time. Could any one help me in this regard how to proceed.
Please find the code below.
Program 1.
LOOP AT pernr.
CLEAR p_job.
p_stim = p_stim + 120.
CONCATENATE'ITSlip' pernr-low p_job sy-datum INTO p_job SEPARATED BY
space.
CALL FUNCTION 'JOB_OPEN'
EXPORTING
jobname = p_job
sdlstrtdt = p_sdat
sdlstrttm = p_stim
IMPORTING
jobcount = l_jobcount.
SUBMIT ZPR022_INNCOMETAX_REPORT_COPY1
WITH pnptimr6 = 'X'
WITH pnpbegda = period-low
WITH pnpendda = period-high
WITH pnppernr-low = pernr-low
WITH pnpabkrs-low = 'IN'
VIA JOB p_job
NUMBER l_jobcount
TO SAP-SPOOL WITHOUT SPOOL DYNPRO
SPOOL PARAMETERS ls_params
WITH immediately = 'X'
KEEP IN SPOOL = 'X'
AND RETURN.
CALL FUNCTION 'JOB_CLOSE'
EXPORTING
jobcount = l_jobcount
jobname = p_job
strtimmed = 'X'
PRDMINS = 2.
sdlstrtdt = p_sdat
sdlstrttm = p_stim.
ENDLOOP.
Program 2.
IF sy-batch EQ 'X'.
LOOP AT pnppernr.
SELECT SINGLE * FROM pa0105
WHERE pernr EQ pnppernr-low
AND subty EQ '0010'
AND endda EQ '99991231'.
p_email1 = pa0105-usrid_long..
PERFORM get_job_details.
PERFORM obtain_spool_id.
PERFORM convert_spool_to_pdf.
PERFORM process_email.
IF sy-sysid = c_dev.
WAIT UP TO 5 SECONDS.
SUBMIT rsconn01 WITH mode = 'INT'
WITH output = 'X'
AND RETURN.
ENDIF.
ENDLOOP.
ELSE.
SKIP.
WRITE:/ 'Program must be executed in background in-order for spool'
'request to be created.'.
EXPORT gd_spool_nr TO MEMORY ID 'SPOOLTOPDF'.
ENDIF.
ENDFORM. " SEND_MAIL
*& Form get_job_details
text
--> p1 text
<-- p2 text
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. " get_job_details
*& Form obtain_spool_id
text
--> p1 text
<-- p2 text
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. " obtain_spool_id
*& Form convert_spool_to_pdf
text
--> p1 text
<-- p2 text
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. " convert_spool_to_pdf
*& Form process_email
text
--> p1 text
<-- p2 text
FORM process_email .
DESCRIBE TABLE it_mess_att LINES gd_recsize.
CHECK gd_recsize > 0.
PERFORM send_email USING p_email1.
ENDFORM. "process_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 = 'IT Declaration'.
CONCATENATE 'ITSLIP' ' ' INTO gd_attachment_name.
it_mess_bod = 'IT FORM for this month'.
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_email1
'MindTree Payroll team'
'PDF'
gd_attachment_name
gd_attachment_desc
p_sender
gd_sender_type
CHANGING gd_error
gd_reciever.
ENDFORM. " process_email
*& Form send_file_as_email_attachment
text
-->P_IT_MESS_BOD text
-->P_IT_MESS_ATT text
-->P_P_EMAIL text
-->P_4422 text
-->P_4423 text
-->P_GD_ATTACHMENT_NAME text
-->P_GD_ATTACHMENT_DESC text
-->P_P_SENDER text
-->P_GD_SENDER_TYPE text
<--P_GD_ERROR text
<--P_GD_RECIEVER text
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 = 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. "send_file_as_email_attachment
Points will be rewarded.
Regards,
BalajiHi,
I think you are retrieving the spool before the entire spool is generated.
Put the following logic to retrieve spool iD
CHECK WHETHER STATUS OF JOB IS COMPLETED OR CANCELLED
WHILE 1 = 1.
GET THE JOB STEPLIST WHICH HAS THE SPOOL NUMBER
CALL FUNCTION 'BP_JOB_READ'
EXPORTING
job_read_jobcount = w_jobcount
job_read_jobname = w_jobname
job_read_opcode = '35'
JOB_STEP_NUMBER =
IMPORTING
job_read_jobhead = wa_jobhead
TABLES
job_read_steplist = i_jobsteplist
CHANGING
RET =
EXCEPTIONS
invalid_opcode = 1
job_doesnt_exist = 2
job_doesnt_have_steps = 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.
BEGIN OF INSERTION U179942 E1BK928781
IF STATUS OF JOB IS COMPLETED(F) OR CANCELLED(A)
READ THE JOBSTEPLIST & GET THE SPOOL NUMBER
IF wa_jobhead-status = c_a OR wa_jobhead-status = c_f.
READ TABLE i_jobsteplist INTO wa_jobsteplist INDEX 1.
CHECK wa_jobsteplist-listident <> space.
w_spool_number = wa_jobsteplist-listident.
EXIT.
ENDIF.
ENDWHILE.
Best regards,
Prashant -
Im getting an error when running a procedure that includes this code.
I need to select from a dynamic column name and save the result in a variable, but seem to be having trouble with the values being fed to sp_executesql
DECLARE @retval AS DECIMAL(12,2)
DECLARE @MonthVal VARCHAR(20), @SpreadKeyVal INT
DECLARE @sqlcmd AS NVARCHAR(150)
DECLARE @paramdef NVARCHAR(150)
SET @MonthVal = 'Month' + CAST(@MonthNumber AS VARCHAR(2) );
SET @SpreadKeyVal = @SpreadKey; --CAST(@SpreadKey AS VARCHAR(10) );
SET @sqlcmd = N' SELECT @retvalout = @MonthVal FROM dbo.CourseSpread WHERE CourseSpreadId = @SpreadKeyVal';
SET @paramdef = N'@MonthVal VARCHAR(20), @SpreadKeyVal INT, @retvalout DECIMAL(12,2) OUTPUT'
--default
SET @retval = 0.0;
EXECUTE sys.sp_executesql @sqlcmd,@paramdef, @MonthVal = 'Month4',@SpreadKeyVal = 1, @retvalout = @retval OUTPUT;
SELECT @retval
DECLARE @return_value DECIMAL(12,2)
EXEC @return_value = [dbo].[GetSpreadValueByMonthNumber]
@SpreadKey = 1,
@MonthNumber = 4
SELECT 'Return Value' = @return_value
Msg 8114, Level 16, State 5, Line 1
Error converting data type varchar to numeric.Please follow basic Netiquette and post the DDL we need to answer this. Follow industry and ANSI/ISO standards in your data. You should follow ISO-11179 rules for naming data elements. You should follow ISO-8601 rules for displaying temporal data. We need
to know the data types, keys and constraints on the table. Avoid dialect in favor of ANSI/ISO Standard SQL. And you need to read and download the PDF for:
https://www.simple-talk.com/books/sql-books/119-sql-code-smells/
>> I need to select from a dynamic column name and save the result in a variable, but seem to be having trouble with the values being fed to sp_executesql <<
This is so very, very wrong! A column is an attribute of an entity. The idea that you are so screwed up that you have no idea if you want
the shoe size, the phone number or something else at run time of this entity.
In Software Engineering we have a principle called cohesion that says a model should do one and only one task, have one and only one entry point, and one and only one exit point.
Hey, on a scale from 1 to 10, what color is your favorite letter of the alphabet? Yes, your mindset is that level of sillyity and absurdity.
Do you know that SQL is a declarative language? This family of languages does not use local variables!
Now think about “month_val” and what it means. A month is a temporal unit of measurement, so this is as silly as saying “liter_val” in your code. Why did you use “sp_” on a procedure? It has special meaning in T-SQL.
Think about how silly this is:
SET @month_val = 'Month' + CAST(@month_nbr AS VARCHAR(2));
We do not do display formatting in a query. This is a violation of at the tiered architecture principle. We have a presentation layer. But more than that, the INTERVAL temporal data type is a {year-month} and never just a month. This is fundamental.
We need to see the DDL so we can re-write this mess. Want to fix it or not?
--CELKO-- Books in Celko Series for Morgan-Kaufmann Publishing: Analytics and OLAP in SQL / Data and Databases: Concepts in Practice Data / Measurements and Standards in SQL SQL for Smarties / SQL Programming Style / SQL Puzzles and Answers / Thinking
in Sets / Trees and Hierarchies in SQL -
Hi all, I am learning how to convert emails to PDF files and there is some great functionality there!! I have not discovered how to convert multiple outlook emails into multiple PDF files (one PDF file for each email) - all at the same time (not one at a time)!! Is there a way to do this using Acrobat X?? The purpose of this is for long-term business archiving. When I search for an email in the archive, I do not want to pull up a portfolio containing 1000 emails or a 1000 page PDF file with multiple emails run together!!! I want to pull up individual emails containing my search terms. I have been searching for a way to archive emails and MS OUTLOOK .PST files are NOT the answer. I get a lot of business emails with large attachments and I do not file my emails in separate sub-folders (by client or job). I want to convert multiple emails (by date range) from my UNIVERSAL INBOX into multiple PDF files for long term storage (with each email being converted into its own, separate PDF file and named with the same name as the "Re: line" of the email). This has been a HUGE problem for me....and Acrobat is sooooo close to the solution for me. Can anyone help?? If so, will attachments be converted? If not, is there a separate software program or add-in that I can buy that will do this?? I use MS Office 2010, Adobe Acrobat X Pro, Windows 7 64 BIT. Thanks for your help!!
I am a retired person and did'nt realize I already have a Adobe account, so you can scrap the entire information. Thanks for the trial anyway and have a great week.
Frederick -
How do I convert a document as a fillable pdf that will allow the end user to save?
When I convert a Word document into a PDF fillable file, the end user cannot save their file. How to I make the file savable for the end user?
Hi TinaEllis,
Is your end user using Reader to fill out the PDF form? If so, the PDF needs to be Reader enabled. Please see Adobe Acrobat X Pro * Enable Reader users to save form data.
Please let us know if you have additional questions.
Best,
Sara -
Enquiry on converting a *.txt file to a *.pdf file
Enquiry on converting a *.txt file to a *.pdf file
Aim of this software: Let the user to choose a *.txt file to convert it to a *.pdf file.
1. User clicks a choose file button. [chooseFileButton]
2. User clicks the Export 2 button [exportButton2]
3. User clicks the Text -> PDF button [pdfConverterButton]
After choosing the file and click the choose file button:
System prints out (for debbuging use...)
---------------------------Print from Trans.java - method transMemory--------------------
File's name: file.txt
File's path: C:\Users\charles\Desktop\netbean\Pdfproject1\file.txt
After clicking the Export 2 button, system prints out:
---------------Print out the File's name - from DataOut.java - getData() Method-------------------------
File's Name: file.txt
----------------Print out the file's path - from DataOut.java - getData() Method--------------
File's path: C:\Users\charles\Desktop\netbean\Pdfproject1\file.txt
The file now being read by the system: transNameData.txt
The data being copied to this file: copyOfFileName.txt Destination
This file has been copied: file.txt Original
The following content has been copied:
---start of content - from TheFile.java - save2() method---
Some content.....................................
--------end of content--------
Jul 18, 2010 3:32:04 PM mainFrame1 exportButton2ActionPerformed
SEVERE: null
java.io.IOException: Permission denied
at java.io.FileInputStream.readBytes(Native Method)
at java.io.FileInputStream.read(FileInputStream.java:199)
at java.io.DataInputStream.read(DataInputStream.java:132)
at sun.nio.cs.StreamDecoder.readBytes(StreamDecoder.java:264)
at sun.nio.cs.StreamDecoder.implRead(StreamDecoder.java:306)
at sun.nio.cs.StreamDecoder.read(StreamDecoder.java:158)
at java.io.InputStreamReader.read(InputStreamReader.java:167)
at java.io.BufferedReader.fill(BufferedReader.java:136)
at java.io.BufferedReader.readLine(BufferedReader.java:299)
at java.io.BufferedReader.readLine(BufferedReader.java:362)
at TheFile.save2(TheFile.java:144)
at mainFrame1.exportButton2ActionPerformed(mainFrame1.java:168)
at mainFrame1.access$200(mainFrame1.java:30)
at mainFrame1$3.actionPerformed(mainFrame1.java:79)
at java.awt.Button.processActionEvent(Button.java:392)
at java.awt.Button.processEvent(Button.java:360)
at java.awt.Component.dispatchEventImpl(Component.java:4630)
at java.awt.Component.dispatchEvent(Component.java:4460)
at java.awt.EventQueue.dispatchEvent(EventQueue.java:599)
at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:269)
at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:184)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:174)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:169)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:161)
at java.awt.EventDispatchThread.run(EventDispatchThread.java:122)
After clicking the text -> PDF button, system prints out:
The following data is called by the PDF converter button...
---------------Print out the File's name - from DataOut.java - getData() Method-------------------------
File's Name: file.txt
----------------Print out the file's path - from DataOut.java - getData() Method--------------
File's path: C:\Users\charles\Desktop\netbean\Pdfproject1\file.txt
MakePdf.java is loading... - createPdf() method
File you have chosen and this file will be converted to a PDF file: file.txt
And the content of the file is:
---start of content--- (Info from MakePdf.java)
Some content.....................................
---end of content---
Print out the content again: Some content..................................... ---> Info from SubClass DocToPdf of MakePdf.java
Exception in thread "AWT-EventQueue-0" ExceptionConverter: java.io.IOException: The document has no pages.
at com.lowagie.text.pdf.PdfPages.writePageTree(Unknown Source)
at com.lowagie.text.pdf.PdfWriter.close(Unknown Source)
at com.lowagie.text.pdf.PdfDocument.close(Unknown Source)
at com.lowagie.text.Document.close(Unknown Source)
at MakePdf$DocToPdf.createDoc(MakePdf.java:140)
at MakePdf.createPdf(MakePdf.java:97)
at TheFile.forPdfUse(TheFile.java:267)
at mainFrame1.pdfConverterButtonActionPerformed(mainFrame1.java:184)
at mainFrame1.access$300(mainFrame1.java:30)
at mainFrame1$4.actionPerformed(mainFrame1.java:86)
at javax.swing.AbstractButton.fireActionPerformed(AbstractButton.java:1995)
at javax.swing.AbstractButton$Handler.actionPerformed(AbstractButton.java:2318)
at javax.swing.DefaultButtonModel.fireActionPerformed(DefaultButtonModel.java:387)
at javax.swing.DefaultButtonModel.setPressed(DefaultButtonModel.java:242)
at javax.swing.plaf.basic.BasicButtonListener.mouseReleased(BasicButtonListener.java:236)
at java.awt.Component.processMouseEvent(Component.java:6263)
at javax.swing.JComponent.processMouseEvent(JComponent.java:3267)
at java.awt.Component.processEvent(Component.java:6028)
at java.awt.Container.processEvent(Container.java:2041)
at java.awt.Component.dispatchEventImpl(Component.java:4630)
at java.awt.Container.dispatchEventImpl(Container.java:2099)
at java.awt.Component.dispatchEvent(Component.java:4460)
at java.awt.LightweightDispatcher.retargetMouseEvent(Container.java:4574)
at java.awt.LightweightDispatcher.processMouseEvent(Container.java:4238)
at java.awt.LightweightDispatcher.dispatchEvent(Container.java:4168)
at java.awt.Container.dispatchEventImpl(Container.java:2085)
at java.awt.Window.dispatchEventImpl(Window.java:2478)
at java.awt.Component.dispatchEvent(Component.java:4460)
at java.awt.EventQueue.dispatchEvent(EventQueue.java:599)
at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:269)
at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:184)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:174)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:169)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:161)
at java.awt.EventDispatchThread.run(EventDispatchThread.java:122)
BUILD SUCCESSFUL (total time: 1 minute 41 seconds)Source code: MakePdf.java
import com.lowagie.text.DocumentException;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.swing.*;
import java.lang.String;
import java.io.*;
public class TheFile {
String pathData;
String nameData;
public void PrepareJFileChooserData2(){
try {
// Create a object for JFileChooser.
final JFileChooser choose = new JFileChooser();
choose.showOpenDialog(null);
File file = new File(choose.getSelectedFile(), "");
pathData = file.getPath(); //get the path of the chosen file
nameData = file.getName(); //get the name of the chosen file
//Try to copy file to a temp file.
Cfile2 cfile = new Cfile2();
cfile.writeFile(nameData); // write nameData into the temp.txt file.
//return pathData;
} catch (IOException ex) {
Logger.getLogger(TheFile.class.getName()).log(Level.SEVERE, null, ex);
public String getPathName(){
return pathData;
public String getNameData(){
return nameData;
public class Cfile2{
public void writeFile(String fName) throws IOException {
PrintWriter pr = new PrintWriter(new File("temp.txt"));
pr.println();
pr.print("\n");
pr.write("-------------------From SubClass - Cfile2 in TheFile.java----------------------");
pr.write("File Name: " +nameData); // write the value of nameData to temp.txt
pr.print("\n");
pr.write("File's Path: "+pathData); // write the value of pathData to temp.txt
pr.print("\n");
pr.print("-------------------------------------------------------------------------------");
pr.flush(); // Flush the data.
pr.close(); // Close to unlock and flush to disk.
public void save2() throws FileNotFoundException, IOException{
// Copy and print out the file's name only
String fileName = "transNameData.txt";
File originFile = new File(fileName); //open the file to read
System.out.println("The file now being read by the system: " +originFile); //originFile = transNameData.txt
File destinationFile = new File("copyOfFileName.txt"); // open another file and prepare to write in
try {
//Start trying to write data to file - copyOfFileName.txt
byte[] readData = new byte[2048];
FileInputStream fis = new FileInputStream(new File(fileName)); // Seems it writes the value of transNameData.txt to copy.txt
int count = fis.available();
if(count>0){
FileOutputStream fos = new FileOutputStream(destinationFile);
int i = fis.read(readData);
while (i != -1) {
fos.write(readData, 0, i);
i = fis.read(readData);
System.out.println("The data being copied to this file: " +destinationFile+ " Destination");
fos.flush();
fos.close();
fis.close();
}else{
System.out.print("Error");
} catch (IOException e) {
System.out.println(e);
// Copy the content of the file only
FileInputStream fstream = new FileInputStream("transNameData.txt");
// Get the object of DataInputStream
DataInputStream in = new DataInputStream(fstream);
BufferedReader br = new BufferedReader(new InputStreamReader(in));
String strLine;
//Read File Line By Line
while ((strLine = br.readLine()) != null) {
// Print the content on the console
System.out.println ("This file has been copied: " +strLine+ " Original"); //Work successfully, strLine has the value [file's title]
File newDestinationFile = new File("ContentCopy.txt"); //Open the newCopy.txt file
byte[] newReadData = new byte[2048];
FileInputStream newFileInputStream = new FileInputStream(new File(strLine)); // See whether it can write it in... ok done!
//String newString = newReadData.toString();
//System.out.print("Content that has been copied: " +newString); //It prints out data in byte form...?!
FileOutputStream newFileOutputStream = new FileOutputStream(newDestinationFile);
int i = newFileInputStream.read(newReadData);
while (i != -1) {
newFileOutputStream.write(newReadData, 0, i);
i = newFileInputStream.read(newReadData);
FileInputStream newfstream = new FileInputStream(strLine);
// Get the object of DataInputStream
DataInputStream newin = new DataInputStream(newfstream);
BufferedReader newbr = new BufferedReader(new InputStreamReader(newin));
String content;
//Read File Line By Line
while ((content = newbr.readLine()) != null) {
// Print the content on the console
System.out.println("\n");
System.out.println("The following content has been copied: ");
System.out.println(" ");
System.out.println("---start of content - from TheFile.java - save2() method---");
System.out.println(" ");
System.out.println(content);
System.out.println(" ");
System.out.println("--------end of content--------");
//Close the input stream
in.close();
//Close the input stream
in.close();
//----------- start PDF parser ---> to txt format -------
public void pdf() throws FileNotFoundException, IOException{
//-----again--
FileInputStream inStream = new FileInputStream("transNameData.txt");
// Get the object of DataInputStream
DataInputStream in = new DataInputStream(inStream);
BufferedReader br = new BufferedReader(new InputStreamReader(in));
String strLine;
//Read File Line By Line
while ((strLine = br.readLine()) != null) {
// Print the content on the console
System.out.println ("Watch out: " +strLine+ " ---> It should be printed successfully!!"); //Work successfully
//---again......
PDFTextParser pdftextparser = new PDFTextParser();
pdftextparser.pdftoText(strLine);
public void forPdfUse() throws FileNotFoundException, IOException, DocumentException{
MakePdf makePdf = new MakePdf();
makePdf.createPdf();
} -
Convert MS Word (.doc) document to pdf document
Hi All,
My requirement is that I need to convert MS Word (.doc) document to pdf document.
Is there any standard SAP function module.
Pls guide me.
RishiI dont understand why you want to use SAP to convert word file to PDF file.
1. Search in google
2. www.win2pdf.com - this may be useful
Still if you want to use SAP to do that then follow the below procedure.
1. Upload the data from word to internal table using the function module : GUI_UPLOAD.
2. Use spool :
1) RSPO_OPEN_SPOOLREQUEST - Open spool request
2) RSPO_WRITE_SPOOLREQUEST - Write to spool request
3) RSPO_CLOSE_SPOOLREQUEST - Close spool request
3. use the function module CONVERT_ABAPSPOOLJOB_2_PDF to convert spool in to PDF format.
Regards,
~Satya -
How to convert a protected document into a PDF?
Hello,
I need to develop a plugin that needs to convert a protected document in office format into a pdf. I looked into the sdk and found the method AVConversionConvertToPDFWithHandler (). But can this method also apply the digital rigths of the protected document to the newly created pdf?
Is there any other way to convert a protected document into a pdf and at the same time apply the rights to the pdf? I don't want to use Adobe LiveCycle for digital rights management.
What are the requirements to develop a DRM plugin for acrobat?
Please Help!
Thanks in advance!The AVConversion APIs will use Office itself to perform the conversion (well, the rendering part). I would ASSUME that when Office opens the document, it will ask for any necessary passwords or other information to determine if the user has the rights to view and/or process the content of the document. If they do, then the conversion will succeed otherwise it will fail. The PDF will not have any DRM applied to it, since we don't know anything about the Office DRM options.
If you wish to apply DRM to the PDF, you will need to do that yourself or using tools such as LiveCycle Rights Management.
From: Adobe Forums <[email protected]<mailto:[email protected]>>
Reply-To: "[email protected]<mailto:[email protected]>" <[email protected]<mailto:[email protected]>>
Date: Tue, 29 Nov 2011 02:26:37 -0800
To: Leonard Rosenthol <[email protected]<mailto:[email protected]>>
Subject: How to convert a protected document into a PDF?
How to convert a protected document into a PDF?
created by poortip87<http://forums.adobe.com/people/poortip87> in Acrobat SDK - View the full discussion<http://forums.adobe.com/message/4051919#4051919 -
Need to convert Date from calendar to String in the format dd-mom-yyyy
Need to convert Date from calendar to String in the format dd-mom-yyyy+..
This is absolutely necessary... any help plz..
Rgds
ArwinderLook up the SimpleDateFormat class: http://java.sun.com/j2se/1.4.2/docs/api/java/text/SimpleDateFormat.html
Arwinder wrote:
This is absolutely necessary... any help plz..For you maybe, not others. Please refrain from trying to urge others to answer your queries. They'll do it at their own pace ( if at all ).
People on the forum help others voluntarily, it's not their job.
Help them help you.
Learn how to ask questions first: http://faq.javaranch.com/java/HowToAskQuestionsOnJavaRanch
(Yes I know it's on JavaRanch but I think it applies everywhere)
---------------------------------------------------------------- -
I just watched the tutorial and did exactly what it was telling me to do, and I still can't get it done. Once I have selected the file, I get a box that pops up that says "Subscribe now to convert unlimited number of files to PDFs. Subscribe Now. I already have done this! I am a subscriber! Arrrrhhhgggg!
Hello Kathie,
Please let me know what exactly are you trying to do using Adobe online service.
You might try accessing the same service for some other PDFs and check.
Have you signed up correctly at "https://cloud.acrobat.com/" using your Adobe ID credentials.
If the same message pops up, then please visit Contact Customer Care as they could let you know if there is any problem with your account.
Hope to get your response.
regards,
Anubha -
What is the best way to load and convert data from a flat file?
Hi,
I want to load data from a flat file, convert dates, numbers and some fields with custom logic (e.g. 0,1 into N,Y) to the correct format.
The rows where all to_number, to_date and custom conversions succeed should go into table STG_OK. If some conversion fails (due to an illegal format in the flat file), those rows (where the conversion raises some exception) should go into table STG_ERR.
What is the best and easiest way to archive this?
Thanks,
Carsten.Hi,
thanks for your answers so far!
I gave them a thought and came up with two different alternatives:
Alternative 1
I load the data from the flat file into a staging table using sqlldr. I convert the data to the target format using sqlldr expressions.
The columns of the staging table have the target format (date, number).
The rows that cannot be loaded go into a bad file. I manually load the data from the bad file (without any conversion) into the error table.
Alternative 2
The columns of the staging table are all of type varchar2 regardless of the target format.
I define data rules for all columns that require a later conversion.
I load the data from the flat file into the staging table using external table or sqlldr without any data conversion.
The rows that cannot be loaded go automatically into the error table.
When I read the data from the staging table, I can safely convert it since it is already checked by the rules.
What I dislike in alternative 1 is that I manually have to create a second file and a second mapping (ok, I can automate this using OMB*Plus).
Further, I would prefer using expressions in the mapping for converting the data.
What I dislike in alternative 2 is that I have to create a data rule and a conversion expression and then keep the data rule and the conversion expression in sync (in case of changes of the file format).
I also would prefer to have the data in the staging table in the target format. Well, I might load it into a second staging table with columns having the target format. But that's another mapping and a lot of i/o.
As far as I know I need the data quality option for using data rules, is that true?
Is there another alternative without any of these drawbacks?
Otherwise I think I will go for alternative 1.
Thanks,
Carsten. -
Error converting data type nvarchar to numeric 'witholding tax' (OWHT)
Hi Guys.
After I have upgraded my clients 2007 PL 30 database to 8.81 PL05, and running a repair to fix inconsistincies, I am receiveing some error when opening any sales documents.
It takes place when I open a sales document, or browse previous docs. When browsing previous docs, it onlly happens on some of them.
I also receive a different error when viewing sales orders: Error converting data type nvarchar to numeric (CRD2).
Any ideas how to fix it?
It does not limit me from processing and using the rest of the functionality. All calculations with queries in the docs are still working.
Thanks.Hi,
Please check Note No. : 1402855 and see if the same applied to the issue mentioned by you.
Kind Regards,
Jitin
SAP Business One Forum Team -
I have a project that entails tax forms from the IRS -- I know everyone's favorite stuff.
1)I need to setup a form that asks the webusers questions regarding their personal tax information -
2) then validate/massage that data/information and determine what PDF form template to output this data to. (possibly output to 4 forms determined by users response)
3) output the data collected in step 1 to the correct PDF template/form example template= http://www.irs.gov/pub/irs-pdf/f1040.pdf - applying the data to the correct fields - bascially filling out the users name, address, calculations etc.
4)allow the user to save/print/download the produced form in step 3
I know I am not the first person to need this functionality. Can you please simply answer my question - can this be done? Does it require software from other companies, or is this something that can be accomplished with just adobe products? If so, can you point me to some tutorials that show me the necessary process to do this?
I very much appreciate any support you can provide me - I need to start on this project yesterday.
Thanks in advance for your time.In your PHP code, change this -
$editFormAction = $_SERVER['PHP_SELF'];
to this -
?>
<?php
if ((isset($_POST["MM_insert"])) && ($_POST["MM_insert"] == "registreren")) {
// add your captcha verification code here ....
// captcha most likely ends with a header command to relocate failed attempts, so make sure you add
// an exit() command after that header. Otherwise, allow the successful captcha to fall into the following
// block of code.
// don't ignore that closing brace
?>
<?php
$editFormAction = $_SERVER['PHP_SELF'];
Maybe you are looking for
-
Is there a way that I can transfer my money from one account to another
I bouget an iTunes card of 30$ and it won't let me purchase anything because I forgot my security questiona that I made when I was 10 years old. Is there amy way I can transfer the money?
-
Select unique rows from two tables...
Hi, I have two tables, replies1 and replies2. SQL> desc replies Name Null? Type URN VARCHAR2(36) ADDRESS VARCHAR2(18) FILESIZE NUMBER AS_NUM VARCHAR2(6) SQL> desc replies2 Name Null? Type URN VARCHAR2(36) ADDRESS VARCHAR2(18) AS_NUM VARCHAR2(6) Both
-
I am wanting to set up a home server (at my house) using a mac mini and an external hard drive array. I want to use the home server for a lot of different things including but not limited to: #1. Backing up computers to the server. #2. Using the serv
-
Add Transition to Grid control when it is made Visible.
Hi. I have a collapsed Grid and when I tap a HyperLinkButton I want the Grid to start getting visible from the closest point from the Button or any other transition effect similar to this. To simplify my question, how do I add a transition effect to
-
I've noticed that while in the music store and previewing movies, that if the download speed isn't fast enough to catch up with the preview that is playing, the video stops and I am returned to the movie's info screen. Instead, I would figure it woul