Logo In Excel sheet, through mail
Hi folks,
I have developed a report, where data is sent from Internal table to the vendors through mail as an Excel attachment. Now i need to include mu company logo in the attachment.Is it possible to create logo in Excel and send it as an attachment in the mail...If so, Could any body suggest me how to do so..
Thanks in advance,
Shyam.
first download your log into program useing below code after that you can pass this to your
REPORT z_ooalv_logo.
****DECLARATION FOR LOGO INSERT
CONSTANTS: cntl_true TYPE i VALUE 1,
cntl_false TYPE i VALUE 0.
DATA:h_picture TYPE REF TO cl_gui_picture,
h_pic_container TYPE REF TO cl_gui_custom_container.
DATA: graphic_url(255),
graphic_refresh(1),
g_result LIKE cntl_true.
DATA: BEGIN OF graphic_table OCCURS 0,
line(255) TYPE x,
END OF graphic_table.
DATA: graphic_size TYPE i.
CALL SCREEN 100.
*& Module PICTURE OUTPUT
text
MODULE picture OUTPUT.
DATA: l_graphic_xstr TYPE xstring,
l_graphic_conv TYPE i,
l_graphic_offs TYPE i.
CALL METHOD cl_ssf_xsf_utilities=>get_bds_graphic_as_bmp
EXPORTING
p_object = 'GRAPHICS'
p_name = 'EDS'"IMAGE NAME - Image name from SE78
p_id = 'BMAP'
p_btype = 'BCOL'
RECEIVING
p_bmp = l_graphic_xstr
EXCEPTIONS
not_found = 1
OTHERS = 2.
graphic_size = XSTRLEN( l_graphic_xstr ).
CHECK graphic_size > 0.
l_graphic_conv = graphic_size.
l_graphic_offs = 0.
WHILE l_graphic_conv > 255.
graphic_table-line = l_graphic_xstr+l_graphic_offs(255).
APPEND graphic_table.
l_graphic_offs = l_graphic_offs + 255.
l_graphic_conv = l_graphic_conv - 255.
ENDWHILE.
graphic_table-line = l_graphic_xstr+l_graphic_offs(l_graphic_conv).
APPEND graphic_table.
CALL FUNCTION 'DP_CREATE_URL'
EXPORTING
type = 'image'
subtype = cndp_sap_tab_unknown " 'X-UNKNOWN'
size = graphic_size
lifetime = cndp_lifetime_transaction "'T'
TABLES
data = graphic_table
CHANGING
url = graphic_url
EXCEPTIONS
dp_invalid_parameter = 1
dp_error_put_table = 2
dp_error_general = 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.
EXIT.
ENDIF.
CREATE OBJECT h_pic_container
EXPORTING container_name = 'LOGO'.
CREATE OBJECT h_picture EXPORTING parent = h_pic_container.
CALL METHOD h_picture->load_picture_from_url
EXPORTING
url = graphic_url
IMPORTING
RESULT = g_result.
ENDMODULE. " PICTURE OUTPUT
then you use mail format
FORM send_file_as_email_attachment tables pit_message
pit_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.
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] = pit_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.
Similar Messages
-
Logo in excel sheet while mailing
Hi,
Is there anyway we can add logo to excel.I am sending excel sheet as attachment via email, now i need to add logo into the excel sheet. Is it possible to add logo into excel sheet.
Regards,
Karthik.kHi Karthik,
I'm not sure, how you are developing the above.
If your devopment is focusing more on Excel better go for OLE.
By using this you can open an existing Excel template (so you can place your logo here).
You can do many more things by this method by writing macro (like formatting data, drawing graphs, etc).
Regards
Surya. -
Downloading logo in excel sheet from application server
hi all
how can i download a logo in excel sheet from the application server(logo is in OAOR tcode) .you can also specify with OOPS concept.
rewards assured.
Reagrds
Swarnali Basuhi naresh
i think there is some miscommunication in case of my question,my requirement is to add a logo in excel sheet from application server,i mean when the user clicks to download the excel sheet the logo should immediately appear in the excel sheet,and it is not a fixed logo it can be anything which appears in applicaton server(on that program).
as far as excel sheet stanalone is concerned i know to do it and as well as to get the logo in the application server standalone ,but i cant download the logo in excel sheet from the application server.now does my question make sense ?
Reagrds
Swarnali -
How to upload datas in excel sheet through BDC
Hi,
I know how to upload datas in Text format through BDC...Suppose even when datas are in .xls format,I saved that file as Text(tab delimited) format...then file become text format and it can be easily uploaded....
So, I want to know How to upload datas in excel sheet through BDChi,
try this Example, hope useful to u, assign me point.
report ZMSV1_BDC_CALL
no standard page heading line-size 255.
*include bdcrecx1.
*parameters: dataset(132) lower case.
DO NOT CHANGE - the generated data section - DO NOT CHANGE ***
If it is nessesary to change the data section use the rules:
1.) Each definition of a field exists of two lines
2.) The first line shows exactly the comment
'* data element: ' followed with the data element
which describes the field.
If you don't have a data element use the
comment without a data element name
3.) The second line shows the fieldname of the
structure, the fieldname must consist of
a fieldname and optional the character '_' and
three numbers and the field length in brackets
4.) Each field must be type C.
Generated data section with specific formatting - DO NOT CHANGE ***
data: begin of record,
data element: BUKRS
BUKRS_001(004),
data element: KTOKK
KTOKK_002(004),
data element: NAME1_GP
NAME1_003(035),
data element: SORTL
SORTL_004(010),
data element: ORT01_GP
ORT01_005(035),
data element: LAND1_GP
LAND1_006(003),
data element: SPRAS
SPRAS_007(002),
data element: BANKS
BANKS_01_008(003),
data element: BANKK
BANKL_01_009(015),
data element: BANKN
BANKN_01_010(018),
end of record.
End generated data section ***
data: itab like record occurs 0 .
data: it_bdc type bdcdata occurs 0 with header line.
data: it_msg type bdcmsgcoll occurs 0 with header line.
parameter p_file type rlgrap-filename default 'c:\vendor.txt' obligatory
start-of-selection.
perform open_dataset using p_file.
perform open_group.
*perform close_group.
*perform close_dataset using dataset.
*& Form open_dataset
text
-->P_P_FILE text
form open_dataset using p_p_file.
CALL FUNCTION 'WS_UPLOAD'
EXPORTING
CODEPAGE = ' '
FILENAME = p_file
FILETYPE = 'DAT'
HEADLEN = ' '
LINE_EXIT = ' '
TRUNCLEN = ' '
USER_FORM = ' '
USER_PROG = ' '
DAT_D_FORMAT = ' '
IMPORTING
FILELENGTH =
TABLES
data_tab = itab
EXCEPTIONS
CONVERSION_ERROR = 1
FILE_OPEN_ERROR = 2
FILE_READ_ERROR = 3
INVALID_TYPE = 4
NO_BATCH = 5
UNKNOWN_ERROR = 6
INVALID_TABLE_WIDTH = 7
GUI_REFUSE_FILETRANSFER = 8
CUSTOMER_ERROR = 9
NO_AUTHORITY = 10
OTHERS = 11
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. " open_dataset
*& Form open_group
text
--> p1 text
<-- p2 text
form open_group .
loop at itab into record.
perform bdc_dynpro using 'SAPMF02K' '0105'.
perform bdc_field using 'BDC_CURSOR'
'RF02K-KTOKK'.
perform bdc_field using 'BDC_OKCODE'
'/00'.
perform bdc_field using 'RF02K-BUKRS'
record-BUKRS_001.
perform bdc_field using 'RF02K-KTOKK'
record-KTOKK_002.
perform bdc_dynpro using 'SAPMF02K' '0110'.
perform bdc_field using 'BDC_CURSOR'
'LFA1-ORT01'.
perform bdc_field using 'BDC_OKCODE'
'/00'.
perform bdc_field using 'LFA1-NAME1'
record-NAME1_003.
perform bdc_field using 'LFA1-SORTL'
record-SORTL_004.
perform bdc_field using 'LFA1-ORT01'
record-ORT01_005.
perform bdc_field using 'LFA1-LAND1'
record-LAND1_006.
perform bdc_field using 'LFA1-SPRAS'
record-SPRAS_007.
perform bdc_dynpro using 'SAPMF02K' '0120'.
perform bdc_field using 'BDC_CURSOR'
'LFA1-KUNNR'.
perform bdc_field using 'BDC_OKCODE'
'/00'.
perform bdc_dynpro using 'SAPMF02K' '0130'.
perform bdc_field using 'BDC_CURSOR'
'LFBK-KOINH(01)'.
perform bdc_field using 'BDC_OKCODE'
'=ENTR'.
perform bdc_field using 'LFBK-BANKS(01)'
record-BANKS_01_008.
perform bdc_field using 'LFBK-BANKL(01)'
record-BANKL_01_009.
perform bdc_field using 'LFBK-BANKN(01)'
record-BANKN_01_010.
perform bdc_dynpro using 'SAPMF02K' '0130'.
perform bdc_field using 'BDC_CURSOR'
'LFBK-BANKS(01)'.
perform bdc_field using 'BDC_OKCODE'
'=ENTR'.
perform bdc_dynpro using 'SAPMF02K' '0210'.
perform bdc_field using 'BDC_CURSOR'
'LFB1-AKONT'.
perform bdc_field using 'BDC_OKCODE'
'/00'.
perform bdc_dynpro using 'SAPMF02K' '0215'.
perform bdc_field using 'BDC_CURSOR'
'LFB1-ZTERM'.
perform bdc_field using 'BDC_OKCODE'
'/00'.
perform bdc_dynpro using 'SAPMF02K' '0220'.
perform bdc_field using 'BDC_CURSOR'
'LFB5-MAHNA'.
perform bdc_field using 'BDC_OKCODE'
'/00'.
perform bdc_dynpro using 'SAPLSPO1' '0300'.
perform bdc_field using 'BDC_OKCODE'
'=YES'.
call transaction 'FK01' using it_bdc mode 'A' update 'S'
messages into it_msg.
write:/ sy-subrc.
perform message_formatwrite.
refresh it_bdc.
clear it_bdc.
endloop.
endform. " open_group
*& Form message_formatwrite
text
--> p1 text
<-- p2 text
form message_formatwrite .
data:l_msg(10).
loop at it_msg.
CALL FUNCTION 'FORMAT_MESSAGE'
EXPORTING
ID = SY-MSGID
LANG = sy-langu
NO = SY-MSGNO
V1 = SY-MSGV1
V2 = SY-MSGV2
V3 = SY-MSGV3
V4 = SY-MSGV4
IMPORTING
MSG = l_msg
EXCEPTIONS
NOT_FOUND = 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.
endloop.
endform. " message_formatwrite
*& Form bdc_dynpro
text
-->P_0112 text
-->P_0113 text
form bdc_dynpro using value(p_0112)
value(p_0113).
it_bdc-program = p_0112.
it_bdc-dynpro = p_0113.
it_bdc-dynbegin = 'X'.
append it_bdc.
clear it_bdc.
endform. " bdc_dynpro
*& Form bdc_field
text
-->P_0117 text
-->P_0118 text
form bdc_field using value(p_0117)
value(p_0118).
it_bdc-fnam = p_0117.
it_bdc-fval = p_0118.
append it_bdc.
clear it_bdc.
endform. " bdc_field
Regards
fareedas -
Logo in Excel Sheet and Appending Data under it
Dear All,
I have a requirement to insert Company Logo in excel sheet.
Is it possible?
Currently we have decided to have the logo already in the spreadsheet and append the data in excel under the logo.
Any directions towards to development would be helpful. Thankyou.
Regards,
Durvi.Hi Guys.
Sorry just answering my own question.
The requirement was acheived by having logo already in the file.
But Vijay's answer was good one, archived it already. I did not find the thread you provided. Already awarded you points.
Thanks for your replies.
Cheers. -
Upload data in excel sheet through BDC
Dear all,
How do we upload data in excel sheet through BDC?
Thanks in advance.
Regards,
Sandra.Hi,
The sample code is as given below:
REPORT upload_supply_area.
*include for dispaying icons in error log
INCLUDE <icon>.
*Declaration of structure.
TYPES:BEGIN OF x_struct,
werks TYPE v_pvbe-werks, "Plant
prvbe TYPE v_pvbe-prvbe, "Supply Area
pvbtx TYPE v_pvbe-pvbtx, "Production supply area description
lgort TYPE v_pvbe-lgort, "Storage Location
rgver TYPE v_pvbe-rgver, "Person responsible for one or more supply areas
END OF x_struct.
TYPES:BEGIN OF x_messages,
msgtyp(1) type c,
werks TYPE v_pvbe-werks, "Plant
prvbe TYPE v_pvbe-prvbe, "Supply Area
message(120) type c,
END OF x_messages.
DATA: it_messages TYPE STANDARD TABLE OF x_messages .
DATA: wa_messages TYPE x_messages.
DATA:it_msgtab TYPE STANDARD TABLE OF bdcmsgcoll,
wa_msgtab TYPE bdcmsgcoll.
*internal table for BDC
DATA: it_bdcdata TYPE STANDARD TABLE OF bdcdata.
DATA: wa_bdcdata TYPE bdcdata.
DATA:it_file TYPE STANDARD TABLE OF x_struct. "internal table which has same structure as file
DATA:wa_file TYPE x_struct. "work area which has same structure as file
DATA: it_excel TYPE STANDARD TABLE OF alsmex_tabline,
wa_excel TYPE alsmex_tabline.
DATA: x_ctuprms TYPE ctu_params.
DATA:nodata TYPE c VALUE '/'.
data:con(50) type c.
data:con1(50) type c.
*selection screen
SELECTION-SCREEN BEGIN OF BLOCK b1 WITH FRAME TITLE text-001.
*Enter file name on presentation server
PARAMETERS: p_file TYPE rlgrap-filename OBLIGATORY.
SELECTION-SCREEN END OF BLOCK b1.
AT SELECTION-SCREEN ON VALUE-REQUEST FOR p_file.
*Function which enables the user to browse the files on hard disk
CALL FUNCTION 'KD_GET_FILENAME_ON_F4'
EXPORTING
program_name = syst-repid
static = 'X'
CHANGING
file_name = p_file
EXCEPTIONS
mask_too_long = 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.
START-OF-SELECTION.
*Subroutine to upload excel file and read it
PERFORM upload.
*Subroutine to upload supply area data
PERFORM fill.
*& Form bdc_dynpro
Fill the BDC table
FORM bdc_dynpro USING program dynpro. "#EC *
CLEAR wa_bdcdata.
wa_bdcdata-program = program.
wa_bdcdata-dynpro = dynpro.
wa_bdcdata-dynbegin = 'X'.
APPEND wa_bdcdata TO it_bdcdata.
ENDFORM. "BDC_DYNPRO
*& Form bdc_field
Fill the BDC table
FORM bdc_field USING fnam fval. "#EC *
IF fval <> nodata.
CLEAR wa_bdcdata.
wa_bdcdata-fnam = fnam.
wa_bdcdata-fval = fval.
APPEND wa_bdcdata TO it_bdcdata. "#EC
ENDIF.
ENDFORM. "BDC_FIELD
*& Form collect_messages
Collect the messages from transaction
FORM collect_messages . "#EC *
DATA: w_msg(100).
LOOP AT it_msgtab INTO wa_msgtab.
CALL FUNCTION 'FORMAT_MESSAGE'
EXPORTING
id = wa_msgtab-msgid
lang = wa_msgtab-msgspra
no = wa_msgtab-msgnr
v1 = wa_msgtab-msgv1
v2 = wa_msgtab-msgv2
IMPORTING
msg = w_msg
EXCEPTIONS
not_found = 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.
CONDENSE w_msg.
CLEAR wa_messages.
wa_messages-msgtyp = wa_msgtab-msgtyp.
wa_messages-message = w_msg.
wa_messages-werks = wa_file-werks.
wa_messages-prvbe = wa_file-prvbe.
if wa_messages-message eq 'Formatting error in the field V_PVBE-RGVER; see next message'.
wa_messages-message = 'Invalid name of the person responsible'.
endif.
if wa_messages-message eq 'Formatting error in the field V_PVBE-LGORT; see next message'.
wa_messages-message = 'Enter the storage location'.
endif.
APPEND wa_messages TO it_messages .
ENDLOOP.
REFRESH it_msgtab.
ENDFORM. "collect_messages
*& Form write_messages
Display the messages
FORM write_messages .
DELETE ADJACENT DUPLICATES FROM it_messages COMPARING werks prvbe.
LOOP AT it_messages INTO wa_messages .
WRITE:/1 sy-vline.
IF wa_messages-msgtyp = 'S'.
WRITE: 10 icon_green_light.
ELSEIF wa_messages-msgtyp = 'E'.
WRITE: 10 icon_red_light.
ELSEIF wa_messages-msgtyp = 'W'.
WRITE: 10 icon_yellow_light.
ENDIF.
WRITE: 20 sy-vline.
WRITE : 30 'Plant-', wa_messages-werks . "#EC NOTEXT
WRITE: 48 sy-vline.
WRITE : 49 'Supply Area-', wa_messages-prvbe . "#EC NOTEXT
WRITE: 79 sy-vline.
WRITE : 80 wa_messages-message .
WRITE: 180 sy-vline.
WRITE:/1 sy-vline.
ULINE 1(180).
ENDLOOP.
ENDFORM. " write_m
*& Form fill_params
Processing mode for the transaction
FORM fill_params .
x_ctuprms-dismode = 'N'.
x_ctuprms-updmode = 'A'.
x_ctuprms-defsize = 'X'.
ENDFORM. "fill_params
*& Form upload
Upload the excel file and read the data
FORM upload .
*Function to upload excel file
CALL FUNCTION 'ALSM_EXCEL_TO_INTERNAL_TABLE'
EXPORTING
filename = p_file
i_begin_col = 1
i_begin_row = 2
i_end_col = 5
i_end_row = 9999
TABLES
intern = it_excel
EXCEPTIONS
inconsistent_parameters = 1
upload_ole = 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.
CLEAR wa_file.
*Read the file row-wise
LOOP AT it_excel INTO wa_excel.
CASE wa_excel-col .
*Read plant
WHEN '1'.
wa_file-werks = wa_excel-value.
*Read supply area
WHEN '2'.
wa_file-prvbe = wa_excel-value.
*Read decription
WHEN '3'.
wa_file-pvbtx = wa_excel-value.
*Read storage location
WHEN '4'.
wa_file-lgort = wa_excel-value.
*Read Person responsible
WHEN '5'.
IF STRLEN( wa_excel-value ) = 1.
CONCATENATE '00' wa_excel-value INTO con.
wa_file-rgver = con.
ELSEIF STRLEN( wa_excel-value ) = 2.
CONCATENATE '0' wa_excel-value INTO con1.
wa_file-rgver = con1.
ELSE.
wa_file-rgver = wa_excel-value.
ENDIF.
ENDCASE.
AT END OF row.
CONDENSE:wa_file-werks,wa_file-prvbe,wa_file-pvbtx,wa_file-lgort,wa_file-rgver.
APPEND wa_file TO it_file.
CLEAR wa_file.
ENDAT .
ENDLOOP.
ENDFORM. " upload
*& Form fill
Call the transaction 'PK05'
FORM fill .
*Upload the data through transaction 'PK05'
PERFORM fill_params.
LOOP AT it_file INTO wa_file.
PERFORM bdc_dynpro USING 'SAPLSVIX' '0100'.
PERFORM bdc_field USING 'BDC_CURSOR'
'D0100_FIELD_TAB-LOWER_LIMIT(01)'.
PERFORM bdc_field USING 'BDC_OKCODE'
'=OKAY'.
PERFORM bdc_dynpro USING 'SAPL0PK1' '0020'.
PERFORM bdc_field USING 'BDC_CURSOR'
'V_PVBE-PVBTX(01)'.
PERFORM bdc_field USING 'BDC_OKCODE'
'=NEWL'.
PERFORM bdc_dynpro USING 'SAPL0PK1' '0021'.
PERFORM bdc_field USING 'BDC_CURSOR'
'V_PVBE-RGVER'.
PERFORM bdc_field USING 'BDC_OKCODE'
'/00'.
PERFORM bdc_field USING 'V_PVBE-WERKS'
wa_file-werks.
PERFORM bdc_field USING 'V_PVBE-PRVBE'
wa_file-prvbe.
PERFORM bdc_field USING 'V_PVBE-PVBTX'
wa_file-pvbtx.
PERFORM bdc_field USING 'V_PVBE-LGORT'
wa_file-lgort.
PERFORM bdc_field USING 'V_PVBE-RGVER'
wa_file-rgver.
PERFORM bdc_dynpro USING 'SAPL0PK1' '0021'.
PERFORM bdc_field USING 'BDC_CURSOR'
'V_PVBE-WERKS'.
PERFORM bdc_field USING 'BDC_OKCODE'
'=SAVE'.
PERFORM bdc_field USING 'V_PVBE-WERKS'
wa_file-werks.
PERFORM bdc_field USING 'V_PVBE-PRVBE'
wa_file-prvbe.
PERFORM bdc_field USING 'V_PVBE-PVBTX'
wa_file-pvbtx.
PERFORM bdc_field USING 'V_PVBE-LGORT'
wa_file-lgort.
PERFORM bdc_field USING 'V_PVBE-RGVER'
wa_file-rgver.
CALL TRANSACTION 'PK05'
USING it_bdcdata
OPTIONS FROM x_ctuprms
MESSAGES INTO it_msgtab.
REFRESH it_bdcdata.
PERFORM collect_messages.
CLEAR wa_file.
ENDLOOP.
PERFORM write_messages.
ENDFORM. " fill -
Excel sheet attached mail when opened shows a error message
hi all,
i have created a report for sending the output to the sap inbox as excel attachment . my problem is ;it always shows an error message when ever the attachment is opened.
I have used the function 'SO_NEW_DOCUMENT_ATT_SEND_API1' and in the table parameters, TABLES
packing_list =
passing the .XLS format and excel sheet name.
please provide me a solution to stop the display of this error message having the contents 'this file is not in a recognizable format'.
thanks and regards\
Thomas
Coding :
FORM sub_output_timeadm USING lv_usrid TYPE gty_timhours-usrid.
DATA : lv_emp1(10) TYPE c,
lv_ename(40) TYPE c,
lv_hour(10) ,
lv_lgart(15),
lv_scc(10),
lv_rcc(10),
lv_order(15),
lv_ordtext(40),
lv_act(10).
DATA : lwa_content TYPE solisti1.
DATA : lit_objpack LIKE sopcklsti1 OCCURS 2 WITH HEADER LINE,"#EC *
lit_objbin LIKE solisti1 OCCURS 0 WITH HEADER LINE,
lit_objtxt LIKE solisti1 OCCURS 2 WITH HEADER LINE,
lit_reclist LIKE somlreci1 OCCURS 2 WITH HEADER LINE,
lwa_docdat LIKE sodocchgi1 OCCURS 1 WITH HEADER LINE,
lv_tab_lines LIKE sy-tabix.
DATA : lv_file LIKE rlgrap-filename,
lv_line LIKE solisti1-line,
lv_vt TYPE c VALUE cl_abap_char_utilities=>horizontal_tab.
DATA : lwa_receivers TYPE somlreci1 .
*Object text details
PERFORM sub_objtxt_data TABLES lit_objtxt
lit_objpack
USING lv_tab_lines.
*Document data details
PERFORM sub_document_data TABLES lwa_docdat
lit_objtxt
USING lv_file
lv_tab_lines.
PERFORM sub_topofpage TABLES lit_objbin
USING lv_line
lv_vt.
PERFORM sub_fill_columnhead TABLES lit_objbin.
LOOP AT git_content INTO lwa_content.
lv_emp1 = lwa_content+2(10).
CONDENSE lv_emp1.
lv_ename = lwa_content+15(40).
SHIFT lv_ename LEFT.
* CONDENSE lv_ename.
IF lv_ename+0(7) = text-024.
WRITE lv_ename TO lv_ename RIGHT-JUSTIFIED.
ELSE.
CONDENSE lv_ename.
ENDIF.
lv_hour = lwa_content+58(10).
CONDENSE lv_hour.
lv_lgart = lwa_content+70(15).
CONDENSE lv_lgart.
lv_scc = lwa_content+90(10).
CONDENSE lv_scc.
lv_rcc = lwa_content+103(10).
CONDENSE lv_rcc.
lv_order = lwa_content+115(15).
CONDENSE lv_order.
lv_ordtext = lwa_content+132(40).
CONDENSE lv_ordtext.
lv_act = lwa_content+174(10).
CONDENSE lv_act.
CONCATENATE lv_emp1
lv_ename
lv_hour
lv_lgart
lv_scc
lv_rcc
lv_order
lv_ordtext
lv_act INTO lv_line SEPARATED BY lv_vt.
CONCATENATE gc_add lv_line lv_vt INTO lv_line.
APPEND lv_line TO lit_objbin.
CLEAR :lv_emp1,
lv_ename,
lv_hour,
lv_lgart,
lv_scc,
lv_rcc,
lv_order,
lv_ordtext,
lv_act ,lv_line,lwa_content.
ENDLOOP.
DESCRIBE TABLE lit_objbin LINES lv_tab_lines.
lv_tab_lines = lv_tab_lines + 1.
* Object pack details
PERFORM sub_objpack_data TABLES lit_objbin
lit_objpack
USING lv_tab_lines
lv_file.
*Receiver list details
PERFORM sub_reclist_timeadm TABLES lit_reclist
USING lv_usrid.
READ TABLE lit_reclist INDEX 1.
IF sy-subrc = 0.
CALL FUNCTION 'SO_NEW_DOCUMENT_ATT_SEND_API1'
EXPORTING
document_data = lwa_docdat
put_in_outbox = gc_x
commit_work = gc_x
TABLES
packing_list = lit_objpack
contents_bin = lit_objbin
contents_txt = lit_objtxt
receivers = lit_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.
CASE sy-subrc.
* WHEN 0.
* MESSAGE i014.
* WHEN 1.
* MESSAGE i016.
* WHEN 2.
* MESSAGE i016.
* WHEN 4.
* MESSAGE i015.
* WHEN OTHERS.
* MESSAGE i017.
ENDCASE.
ENDIF.
REFRESH git_content.
CLEAR gwa_content.
FORM sub_objtxt_data TABLES xt_objtxt STRUCTURE solisti1
xt_objpack STRUCTURE sopcklsti1
USING xv_tab_lines .
DATA : lv_zdat(10) TYPE c,
lv_zdat2(10) TYPE c.
CONSTANTS: lc_hiphen(1) TYPE c VALUE '-'.
* write sy-datum to lv_zdat mm/dd/yyyy.
* concatenate text-022 lv_zdat into xt_objtxt separated by space.
* APPEND xt_objtxt.clear xt_objtxt.
WRITE pnpbegda TO lv_zdat MM/DD/YYYY.
WRITE pnpendda TO lv_zdat2 MM/DD/YYYY.
CONCATENATE text-080
lv_zdat
lc_hiphen
lv_zdat2 INTO xt_objtxt SEPARATED BY space.
APPEND xt_objtxt.CLEAR xt_objtxt.
xt_objtxt = text-067.
APPEND xt_objtxt.CLEAR xt_objtxt.
CLEAR: lv_zdat,
lv_zdat2.
DESCRIBE TABLE xt_objtxt LINES xv_tab_lines.
READ TABLE xt_objtxt INDEX xv_tab_lines.
CLEAR xt_objpack-transf_bin.
xt_objpack-head_start = 1.
xt_objpack-head_num = 0.
xt_objpack-body_start = 1.
xt_objpack-body_num = xv_tab_lines.
xt_objpack-doc_type = gc_raw.
APPEND xt_objpack.
CLEAR xt_objpack.
ENDFORM. " sub_objtxt_data
*& Form sub_document_data
*To fix the size of the document
* -->XT_DOCDAT
* -->XT_OBJTXT
* -->XV_LV_FILE
* -->XV_TAB_LINES
FORM sub_document_data TABLES xt_docdat STRUCTURE sodocchgi1
xt_objtxt STRUCTURE solisti1
USING xv_lv_file
xv_tab_lines. "#EC *
DATA : lv_subject TYPE string,
lv_open TYPE c VALUE '(',
lv_close TYPE c VALUE ')',
lv_slash TYPE c VALUE '/'.
xt_docdat-obj_name = xv_lv_file.
CONCATENATE lv_open sy-sysid
lv_slash sy-mandt lv_close INTO lv_subject.
xt_docdat-obj_descr = lv_subject.
xt_docdat-doc_size
= ( xv_tab_lines - 1 ) * 255 + STRLEN( xt_objtxt ).
ENDFORM. " sub_document_data
*& Form sub_topofpage
* text
* -->P_LIT_OBJBIN text
FORM sub_topofpage TABLES xt_objbin STRUCTURE solisti1
USING xv_lv_line
xv_vt.
DATA: lwa_line TYPE slis_listheader.
LOOP AT git_header INTO lwa_line.
CONCATENATE lwa_line-key lwa_line-info
INTO xv_lv_line SEPARATED BY xv_vt.
CONCATENATE gc_add xv_lv_line xv_vt
xv_vt "TAB space
xv_vt
xv_vt
xv_vt
xv_vt
xv_vt
* xv_vt
* xv_vt
* xv_vt
* xv_vt
* xv_vt
* xv_vt
* xv_vt
INTO xv_lv_line.
APPEND xv_lv_line TO xt_objbin.
ENDLOOP.
ENDFORM. " sub_topofpage
*& Form sub_fill_columnhead
* text
* --> p1 text
* <-- p2 text
FORM sub_fill_columnhead TABLES xt_objbin STRUCTURE solisti1.
DATA: lv_line LIKE solisti1-line,
lv_vt TYPE c VALUE cl_abap_char_utilities=>horizontal_tab,
lv_zdat(10).
DATA : lv_line1(40),
lv_line2(10),
lv_line3(10),
lv_line4(3),
lv_line5(40).
lv_line1 = text-008.
WRITE sy-datum TO lv_zdat MM/DD/YYYY.
lv_line2 = lv_zdat.
CONCATENATE lv_vt
lv_line1
lv_vt
lv_vt
lv_line2
lv_vt
lv_vt
lv_vt
lv_vt
* lv_vt
INTO lv_line.
CONCATENATE gc_add lv_line lv_vt INTO lv_line.
APPEND lv_line TO xt_objbin.
CLEAR : lv_line, lv_line1, lv_line2, lv_zdat.
lv_line1 = text-009.
lv_line2 = text-010.
WRITE pnpbegda TO lv_zdat MM/DD/YYYY.
lv_line3 = lv_zdat.
CLEAR lv_zdat.
lv_line4 = ' - '.
WRITE pnpendda TO lv_zdat MM/DD/YYYY.
lv_line5 = lv_zdat.
CONCATENATE lv_vt
lv_line1
lv_vt
lv_vt
lv_line2
lv_vt
lv_line3
lv_line4
lv_line5
lv_vt
lv_vt
lv_vt
lv_vt
INTO lv_line.
CONCATENATE gc_add lv_line lv_vt INTO lv_line.
APPEND lv_line TO xt_objbin.
CLEAR : lv_line, lv_line1,
lv_line2,lv_line3,
lv_line4, lv_line5, lv_zdat.
CONCATENATE lv_vt
lv_vt
lv_vt
lv_vt
lv_vt
lv_vt
lv_vt
lv_vt
lv_vt
INTO lv_line.
CONCATENATE gc_add lv_line lv_vt INTO lv_line.
APPEND lv_line TO xt_objbin.
CLEAR lv_line.
CONCATENATE text-013
text-014
text-015
text-016
text-017
text-018
text-019
text-026
text-020
INTO lv_line
SEPARATED BY lv_vt.
CONCATENATE gc_add lv_line
lv_vt "TAB space
INTO lv_line.
APPEND lv_line TO xt_objbin.
ENDFORM. " sub_fill_columnhead
*& Form sub_objpack_data
*To fix the actual document size
* -->XT_OBJBIN
* -->XT_OBJPACK
* -->XV_TAB_LINES
* -->XV_LV_FILE
FORM sub_objpack_data TABLES xt_objbin STRUCTURE solisti1
xt_objpack STRUCTURE sopcklsti1
USING xv_tab_lines
xv_lv_file. "#EC *
DATA : lwa_objpack TYPE sopcklsti1.
lwa_objpack-transf_bin = gc_x.
lwa_objpack-head_start = 1.
lwa_objpack-head_num = 0.
lwa_objpack-body_start = 1.
lwa_objpack-body_num = xv_tab_lines.
lwa_objpack-doc_type = gc_xls.
lwa_objpack-obj_name = xv_lv_file.
lwa_objpack-obj_descr = gc_descr.
lwa_objpack-doc_size
= ( xv_tab_lines - 1 ) * 255 + STRLEN( xt_objbin ).
APPEND lwa_objpack TO xt_objpack.
CLEAR lwa_objpack.
ENDFORM. " sub_objpack_data
*& Form sub_reclist_timeadm
* text
* -->P_LIT_RECLIST text
* -->P_LV_USRID text
FORM sub_reclist_timeadm TABLES xt_reclist STRUCTURE somlreci1
USING lp_usrid TYPE gty_timhours-usrid."#EC *
*local constant
CONSTANTS : lc_b TYPE c VALUE 'B'.
*local workarea.
DATA : lwa_receivers TYPE somlreci1 ,
lwa_usrid TYPE gty_usrid ,
lwa_docdata TYPE sodocchgi1.
REFRESH : git_receivers.":, LIT_DOCDATA .
CLEAR : lwa_receivers,lwa_docdata.
IF p_timadm EQ 'X'.
MOVE: lp_usrid TO lwa_receivers-receiver,
text-002 TO lwa_receivers-express,
lc_b TO lwa_receivers-rec_type.
APPEND lwa_receivers TO xt_reclist.
ELSEIF p_manger EQ 'X'.
READ TABLE git_usrid INTO lwa_usrid WITH KEY pernr = gwa_emphours-magpernr
usrty = '0001' BINARY SEARCH.
IF sy-subrc EQ 0.
MOVE: lwa_usrid-usrid TO lwa_receivers-receiver,
text-002 TO lwa_receivers-express,
lc_b TO lwa_receivers-rec_type.
APPEND lwa_receivers TO xt_reclist.
ENDIF.
CLEAR : lwa_usrid .
ENDIF.Hi Tona,
Please go through the code and cross check....
REPORT zcyborg_5 NO STANDARD PAGE HEADING.
TABLES : eket.
DATA : p_date TYPE d.
DATA : w_lines TYPE sy-tabix.
TYPES : BEGIN OF types_eket,
ebeln TYPE eket-ebeln,
ebelp TYPE eket-ebelp,
eindt TYPE eket-eindt,
END OF types_eket.
DATA : t_eket TYPE STANDARD TABLE OF types_eket.
Declaration for ALV display *********************
DATA : w_grid TYPE REF TO cl_gui_alv_grid,
w_custom_container TYPE REF TO cl_gui_custom_container.
RANGES : r_eindt FOR eket-eindt.
FIELD-SYMBOLS: <fs_eket> TYPE types_eket.
INITIALIZATION.
CALL FUNCTION 'CALCULATE_DATE'
EXPORTING
days = '60-'
months = '0'
start_date = sy-datum
IMPORTING
result_date = p_date.
r_eindt-low = p_date.
r_eindt-high = sy-datum.
r_eindt-sign = 'I'.
r_eindt-option = 'BT'.
APPEND r_eindt.
START-OF-SELECTION.
PERFORM get_data.
PERFORM disp_data.
PERFORM email_data.
perform disp_alv.
*& Form get_data
text
--> p1 text
<-- p2 text
FORM get_data.
SELECT ebeln
ebelp
eindt
FROM eket
INTO TABLE t_eket
WHERE eindt IN r_eindt.
ENDFORM. " get_data
*& Form disp_data
text
--> p1 text
<-- p2 text
FORM disp_data.
DESCRIBE TABLE t_eket LINES w_lines.
WRITE :/5 'No of rows : ', w_lines.
WRITE :/5 'EBELN', 30 'EBELP', 50 'EINDT'.
SORT t_eket DESCENDING BY eindt.
LOOP AT t_eket ASSIGNING <fs_eket>.
AT NEW ebeln.
ULINE.
ENDAT.
WRITE : /5 <fs_eket>-ebeln, 30 <fs_eket>-ebelp, 50 <fs_eket>-eindt.
ENDLOOP.
ENDFORM. " disp_data
call function 'SEND_TABLE_TO_EXCEL'
exporting
structure_name = 'EKET'
tables
exceltab = t_eket
FORM email_data.
*Structures and internal table used to send data vai mail
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,
tab_lines LIKE sy-tabix,
doc_chng LIKE sodocchgi1.
DATA : it_attach TYPE STANDARD TABLE OF solisti1,
w_attach TYPE solisti1.
CONSTANTS : c_car TYPE x VALUE '0D',
c_tab TYPE x VALUE '09'.
CONCATENATE 'EBELN'
c_tab
'EBELP'
c_tab
'EINDT'
c_car INTO w_attach.
APPEND w_attach TO it_attach.
LOOP AT t_eket INTO <fs_eket>.
CONCATENATE <fs_eket>-ebeln
c_tab
<fs_eket>-ebelp
c_tab
<fs_eket>-eindt
c_car INTO w_attach.
APPEND w_attach TO it_attach.
ENDLOOP.
MOVE it_attach[] TO objbin[].
*assign a name to the email document
doc_chng-obj_name = 'Output'.
doc_chng-obj_descr = 'Old Scheduling lines'."gives the subject line
objtxt-line = 'Regards'.
APPEND objtxt.
objtxt-line = 'Shivaji'.
APPEND objtxt.
*determine the size of the body of the email
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 body of the email
*doc needs no header
objpack-head_start = 1.
objpack-head_num = 0.
*but it has a body
objpack-body_start = 1.
objpack-body_num = tab_lines.
objpack-doc_type = 'RAW'.
APPEND objpack.
*************fill the fields for packing list ***
for attachment ********
DESCRIBE TABLE objbin LINES tab_lines.
*************if it has no header ****************
objpack-transf_bin = 'X'.
objpack-head_start = 1.
objpack-head_num = 1.
*************if it has a body ********
objpack-body_start = 1.
objpack-body_num = tab_lines.
objpack-doc_type = 'XLS'.
objpack-obj_name = 'Attachement'.
objpack-obj_descr = 'file'.
objpack-doc_size = tab_lines * 255.
APPEND objpack.
************fill the mail recipient list*******
reclist-receiver = sy-uname.
**rec_type 'B' indicates sap user ,rec_type 'U' indicates internet user
reclist-rec_type = 'B'.
reclist-express = 'X'.
APPEND reclist.
Function Module to send the data as an excel attachement ****
CALL FUNCTION 'SO_NEW_DOCUMENT_ATT_SEND_API1'
EXPORTING
document_data = doc_chng
put_in_outbox = 'X'
IMPORTING
SENT_TO_ALL =
NEW_OBJECT_ID =
TABLES
packing_list = objpack
OBJECT_HEADER =
contents_bin = objbin
contents_txt = objtxt
CONTENTS_HEX =
OBJECT_PARA =
OBJECT_PARB =
receivers = 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
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. -
Uploading data from excel sheets through BDC's into sap system
hi guys,
can you please help me with this. As we use gui_upload to upload data from flat file to sap system, which function module you use to upload data from Excel sheet to sap system through bdc'shello pavan,
welcome to SDN
check the below program
REPORT ZEXCEL_TO_INTERNAL .
data: begin of itab occurs 0,
name(20) type c,
addre(20) type c,
end of itab.
DATA : ITAB1 LIKE ALSMEX_TABLINE OCCURS 0 WITH HEADER LINE.
DATA : B1 TYPE I VALUE 1,
C1 TYPE I VALUE 1,
B2 TYPE I VALUE 100,
C2 TYPE I VALUE 9999.
CALL FUNCTION 'ALSM_EXCEL_TO_INTERNAL_TABLE'
EXPORTING
FILENAME =
'C:\Documents and Settings\administrator\Desktop\ppcon001bd_24.xls'
I_BEGIN_COL = B1
I_BEGIN_ROW = C1
I_END_COL = B2
I_END_ROW = C2
TABLES
INTERN = itab1
EXCEPTIONS
INCONSISTENT_PARAMETERS = 1
UPLOAD_OLE = 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.
loop at itab1.
write:/ itab1.
Endlop.
Regards,
Naveen -
Problem with Protected Excel sheets through OLE
Hi Friends
We are facing the problem with the protected sheets in excel, when we are accessing worksheets via SAP.
We can insert the values in the protected sheet and we can do other manupalations, but when we are trying to do the autofit for the protected sheet via SAP, then its throwing an error while making it as Visible in SAP ECC 6.0.
Though it is valid, because even when we do in the excel itself, it wont allow the user to shrink the columns, but this one is possible in ECC 5.0 and we can make excel is visible on the screen.
I would like to know is this SAP Version problem or anything else apart from this? and I would like to know is there anyway to unprotect and protect the sheet through ABAP program with out a password. Now my clients wants the autofit though its protected.
Please give me any suggestions.
Thanks
Praveenits bug with ECC 5.0. If we want to make it auto fit we need to unprotect, then auto fit.
Later we can protect again -
Print my input which i accept in my procedure in Excel Sheet through pl/sql
Respected Sir,
If i want to print my input in excel sheet which i took as a input parameter for my procedure
for example my procedure:
create or replace procedure create_csv('hello this is wonder world').
I want to print hello this is wonder world in excel sheet.
How can i acheive this through pl/sql procedure. with out utl_file predefined package.
Please help me regarding this.
Sincerely,
Chandrasekhar B.S.maybe this link accessing oracle via access and excel might be of some help.
-
How to send existing excel file through mail
Hello Friends,
I have to send mail with Excel File attachement. i have already exist Excel file and that file i hv to send through mail. so pl help me out for sending existing excel file .
i.e. user pickup the exist excel file and that file would be sent to particular mail id.
thank you,
MarmikHi marmik,
1. There is some trick involved
in the binary files.
2. I have made a program (and it works fantastic)
ONLY 6 LINES FOR EMAILING
BELIEVE ME
ITS A FANTASTIC PROGRAM.
IT WILL WORK LIKE OUTLOOK EXPRESS !
3. The user is provided with
a) file name
b) email address to send mail
and it sends ANY FILE (.xls,.pdf .xyz..)
Instantaneously !
4. Make two things first :
1. Include with the name : ZAMI_INCLFOR_MAIL
2. Report with the name : ZAM_TEMP147 (any name will do)
3. Activate both and execute (2)
4. After providing filename, email adress
5. Code for Include :
10.08.2005 Amit M - Created
Include For Mail (First Req F16)
Modification Log
Data
DATA: docdata LIKE sodocchgi1,
objpack LIKE sopcklsti1 OCCURS 1 WITH HEADER LINE,
objhead LIKE solisti1 OCCURS 1 WITH HEADER LINE,
objtxt LIKE solisti1 OCCURS 10 WITH HEADER LINE,
objbin LIKE solisti1 OCCURS 10 WITH HEADER LINE,
objhex LIKE solix OCCURS 10 WITH HEADER LINE,
reclist LIKE somlreci1 OCCURS 1 WITH HEADER LINE.
DATA: tab_lines TYPE i,
doc_size TYPE i,
att_type LIKE soodk-objtp.
DATA: listobject LIKE abaplist OCCURS 1 WITH HEADER LINE.
FORM
FORM ml_customize USING objname objdesc.
Clear Variables
CLEAR docdata.
REFRESH objpack.
CLEAR objpack.
REFRESH objhead.
REFRESH objtxt.
CLEAR objtxt.
REFRESH objbin.
CLEAR objbin.
REFRESH objhex.
CLEAR objhex.
REFRESH reclist.
CLEAR reclist.
REFRESH listobject.
CLEAR listobject.
CLEAR tab_lines.
CLEAR doc_size.
CLEAR att_type.
Set Variables
docdata-obj_name = objname.
docdata-obj_descr = objdesc.
ENDFORM. "ml_customize
FORM
FORM ml_addrecp USING preceiver prec_type.
CLEAR reclist.
reclist-receiver = preceiver.
reclist-rec_type = prec_type.
APPEND reclist.
ENDFORM. "ml_customize
FORM
FORM ml_addtxt USING ptxt.
CLEAR objtxt.
objtxt = ptxt.
APPEND objtxt.
ENDFORM. "ml_customize
FORM
FORM ml_prepare USING bypassmemory whatatt_type whatname.
IF bypassmemory = ''.
Fetch List From Memory
CALL FUNCTION 'LIST_FROM_MEMORY'
TABLES
listobject = listobject
EXCEPTIONS
OTHERS = 1.
IF sy-subrc <> 0.
MESSAGE ID '61' TYPE 'E' NUMBER '731'
WITH 'LIST_FROM_MEMORY'.
ENDIF.
CALL FUNCTION 'TABLE_COMPRESS'
IMPORTING
COMPRESSED_SIZE =
TABLES
in = listobject
out = objbin
EXCEPTIONS
OTHERS = 1
IF sy-subrc <> 0.
MESSAGE ID '61' TYPE 'E' NUMBER '731'
WITH 'TABLE_COMPRESS'.
ENDIF.
ENDIF.
Header Data
Already Done Thru FM
Main Text
Already Done Thru FM
Packing Info For Text Data
DESCRIBE TABLE objtxt LINES tab_lines.
READ TABLE objtxt INDEX tab_lines.
docdata-doc_size = ( tab_lines - 1 ) * 255 + STRLEN( objtxt ).
CLEAR objpack-transf_bin.
objpack-head_start = 1.
objpack-head_num = 0.
objpack-body_start = 1.
objpack-body_num = tab_lines.
objpack-doc_type = 'TXT'.
APPEND objpack.
Packing Info Attachment
att_type = whatatt_type..
DESCRIBE TABLE objbin LINES tab_lines.
READ TABLE objbin INDEX tab_lines.
objpack-doc_size = ( tab_lines - 1 ) * 255 + STRLEN( objbin ).
objpack-transf_bin = 'X'.
objpack-head_start = 1.
objpack-head_num = 0.
objpack-body_start = 1.
objpack-body_num = tab_lines.
objpack-doc_type = att_type.
objpack-obj_name = 'ATTACHMENT'.
objpack-obj_descr = whatname.
APPEND objpack.
Receiver List
Already done thru fm
ENDFORM. "ml_prepare
FORM
FORM ml_dosend.
CALL FUNCTION 'SO_NEW_DOCUMENT_ATT_SEND_API1'
EXPORTING
document_data = docdata
put_in_outbox = 'X'
commit_work = 'X' "used from rel. 6.10
IMPORTING
SENT_TO_ALL =
NEW_OBJECT_ID =
TABLES
packing_list = objpack
object_header = objhead
contents_bin = objbin
contents_txt = objtxt
CONTENTS_HEX = objhex
OBJECT_PARA =
object_parb =
receivers = 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
IF sy-subrc <> 0.
MESSAGE ID 'SO' TYPE 'S' NUMBER '023'
WITH docdata-obj_name.
ENDIF.
ENDFORM. "ml_customize
FORM
FORM ml_spooltopdf USING whatspoolid.
DATA : pdf LIKE tline OCCURS 0 WITH HEADER LINE.
Call Function
CALL FUNCTION 'CONVERT_OTFSPOOLJOB_2_PDF'
EXPORTING
src_spoolid = whatspoolid
TABLES
pdf = pdf
EXCEPTIONS
err_no_otf_spooljob = 1
OTHERS = 12.
Convert
PERFORM doconv TABLES pdf objbin.
ENDFORM. "ml_spooltopdf
FORM
FORM doconv TABLES
mypdf STRUCTURE tline
outbin STRUCTURE solisti1.
Data
DATA : pos TYPE i.
DATA : len TYPE i.
Loop And Put Data
LOOP AT mypdf.
pos = 255 - len.
IF pos > 134. "length of pdf_table
pos = 134.
ENDIF.
outbin+len = mypdf(pos).
len = len + pos.
IF len = 255. "length of out (contents_bin)
APPEND outbin.
CLEAR: outbin, len.
IF pos < 134.
outbin = mypdf+pos.
len = 134 - pos.
ENDIF.
ENDIF.
ENDLOOP.
IF len > 0.
APPEND outbin.
ENDIF.
ENDFORM. "doconv
CODE FOR PROGRAM
5.
REPORT zam_temp147 .
INCLUDE zami_inclfor_mail.
DATA
DATA : itab LIKE tline OCCURS 0 WITH HEADER LINE.
DATA : file_name TYPE string.
data : path like PCFILE-PATH.
data : extension(5) type c.
data : name(100) type c.
SELECTION SCREEN
PARAMETERS : receiver TYPE somlreci1-receiver lower case.
PARAMETERS : p_file LIKE rlgrap-filename
OBLIGATORY.
AT SELECTION SCREEN
AT SELECTION-SCREEN ON VALUE-REQUEST FOR p_file.
CLEAR p_file.
CALL FUNCTION 'F4_FILENAME'
IMPORTING
file_name = p_file.
START-OF-SELECTION
START-OF-SELECTION.
PERFORM ml_customize USING 'Tst' 'Testing'.
PERFORM ml_addrecp USING receiver 'U'.
PERFORM upl.
PERFORM doconv TABLES itab objbin.
PERFORM ml_prepare USING 'X' extension name.
PERFORM ml_dosend.
SUBMIT rsconn01
WITH mode EQ 'INT'
AND RETURN.
FORM
FORM upl.
file_name = p_file.
CALL FUNCTION 'GUI_UPLOAD'
EXPORTING
filename = file_name
filetype = 'BIN'
TABLES
data_tab = itab
EXCEPTIONS
file_open_error = 1
file_read_error = 2
no_batch = 3
gui_refuse_filetransfer = 4
invalid_type = 5
no_authority = 6
unknown_error = 7
bad_data_format = 8
header_not_allowed = 9
separator_not_allowed = 10
header_too_long = 11
unknown_dp_error = 12
access_denied = 13
dp_out_of_memory = 14
disk_full = 15
dp_timeout = 16
OTHERS = 17.
path = file_name.
CALL FUNCTION 'PC_SPLIT_COMPLETE_FILENAME'
EXPORTING
complete_filename = path
CHECK_DOS_FORMAT =
IMPORTING
DRIVE =
EXTENSION = extension
NAME = name
NAME_WITH_EXT =
PATH =
EXCEPTIONS
INVALID_DRIVE = 1
INVALID_EXTENSION = 2
INVALID_NAME = 3
INVALID_PATH = 4
OTHERS = 5
ENDFORM. "upl
regards,
amit m. -
How to update an Excel Sheet through a WebService
Dear All,
Please help me with this query.
Kindly could you guide me on updating an Excel Sheet which is saved on my local server through a WebService which is deployed on the WebApp Server. The Server is located locally too. I have developed the WebService on the NWDS.
I have tried using POI and ODBC for updating the sheet. But it appears to me that the server is unable to fetch the excel sheet.
Please could you provide your valuable suggestions on this.
Regards,
Suyukti B NHi,
Thanks for your reply. Below are more details regarding my question. I am trying to achieve the requirement with :
Java WebDynpro (Front End) <--> WebService (Middle Tier) <->ODBC <---> Microsoft Excel (Back End)
1) I am Using the Java perspective to create the service method. The method has to read and update the excel sheet. I have created a ODBC DataSource on my local machine. I also have the SAP WebApp Server on my local machine. Below is the method I am using for "reading" the excel :
public String read(){
Connection connection = null;
String columnValue = "";
try {
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
Connection con = DriverManager.getConnection ("jdbc:odbc:DS");
Statement st = con.createStatement();
ResultSet rs = st.executeQuery("Select * from [Sheet1$]");
ResultSetMetaData rsmd = rs.getMetaData();
int numberOfColumns = rsmd.getColumnCount();
while (rs.next()) {
for (int i = 1; i <= numberOfColumns; i++) {
if (i > 1) System.out.print(", "); columnValue = rs.getString(i);
System.out.println("value is" + columnValue);
st.close();
con.close();
} catch (Exception ex) {
System.err.print("Exception: ");
System.err.println(ex.getMessage());
return "false" + ex.toString();
return "true";
This code works perfectly fine and provides me the values that are present on the Excel Sheet.
2) I now switch over from the Java Perspective to the WebService Perspective on my NetWeaver Developer Studio. I create a new WebService for the above Java method.
3) I then create an Ear file and deploy on the Server.
4) Now when I click on Test WebService, the values that are returned from the Excel are "null". It shows return String as False and an SQL Exception. java.sql.SQLException: General error.
Hence I concluded that after deploying the Service on the Server, the Excel Sheet is not being fetched or read.
Please could you provide your thoughts on this.
Thank You Very Much,
Warm Regards,
Suyukti B N -
Increase the column lengths of excel sheet through abap
I developed a abap program and it was displayed the output.
So i need to display this out put in excel sheet.
for that I read the out put and placed in the excel,
the only problem is the column lengths are small
after download i am dragging the each column,
But i need to increase the each column by the program
How can I ?
I am using the following code
lastline = new_line_c + 13.
DO .
READ LINE sy-index LINE VALUE INTO it_read-excel.
APPEND it_read.
IF sy-index > lastline.
EXIT.
ENDIF.
ENDDO.
lastline = new_line_c - 38.
colm = ( length - 37 ) / 18.
colm = colm + 4.
FOR THE EXCEL CONVERTION
INCLUDE ole2incl.
DATA: w_cell1 TYPE ole2_object,
w_cell2 TYPE ole2_object.
*--- Ole data Declarations
DATA: h_excel TYPE ole2_object, " Excel object
h_mapl TYPE ole2_object, " list of workbooks
h_map TYPE ole2_object, " workbook
h_zl TYPE ole2_object, " cell
h_f TYPE ole2_object, " font
gs_interior TYPE ole2_object, " Pattern
worksheet TYPE ole2_object,
h_cell TYPE ole2_object,
h_merge TYPE ole2_object,
h_cell1 TYPE ole2_object,
range TYPE ole2_object,
h_sheet2 TYPE ole2_object,
h_sheet3 TYPE ole2_object,
gs_font TYPE ole2_object,
flg_stop(1) TYPE c.
*DATA: t_excel_bckord LIKE t_excel OCCURS 0 WITH HEADER LINE,
*t_excel_bcklog LIKE t_excel OCCURS 0 WITH HEADER LINE,
*t_excel_blkord LIKE t_excel OCCURS 0 WITH HEADER LINE.
TYPES: data1(1500) TYPE c,
ty TYPE TABLE OF data1.
DATA: it TYPE ty WITH HEADER LINE,
it_2 TYPE ty WITH HEADER LINE,
it_3 TYPE ty WITH HEADER LINE,
rec TYPE sy-tfill,
deli(1) TYPE c,
l_amt(18) TYPE c.
DATA: BEGIN OF hex,
tab TYPE x,
END OF hex.
FIELD-SYMBOLS: <fs> .
CONSTANTS cns_09(2) TYPE n VALUE 09.
ASSIGN deli TO <fs> TYPE 'X'.
hex-tab = cns_09.
<fs> = hex-tab.
DATA gv_sheet_name(20) TYPE c .
M A C R O Declaration
DEFINE ole_check_error.
if &1 ne 0.
message e001(zz) with &1.
exit.
endif.
END-OF-DEFINITION.
DATA: xy TYPE i,
xz TYPE i,
yz TYPE i,
ab TYPE i,
pterm TYPE i.
IF h_excel-header = space OR h_excel-handle = -1.
start Excel
CREATE OBJECT h_excel 'EXCEL.APPLICATION'.
ENDIF.
PERFORM err_hdl.
*--- get list of workbooks, initially empty
CALL METHOD OF h_excel 'Workbooks' = h_mapl.
PERFORM err_hdl.
SET PROPERTY OF h_excel 'Visible' = 1.
add a new workbook
CALL METHOD OF h_mapl 'Add' = h_map.
PERFORM err_hdl.
*GV_SHEET_NAME = '1st SHEET'.
gv_sheet_name = 'Price Comparison List'.
GET PROPERTY OF h_excel 'ACTIVESHEET' = worksheet.
SET PROPERTY OF worksheet 'Name' = gv_sheet_name .
index1 = 3.
LOOP AT it_read.
heading
IF sy-tabix < 4.
it_item = it_read.
IF it_item CS '-----'.
CLEAR it_item.
APPEND it_item.
ELSE.
IF sy-tabix = 1.
it_item+0(1) = deli.
ENDIF.
APPEND it_item.
ENDIF.
ENDIF.
headear data and item
IF sy-tabix > 4 AND sy-tabix < descline1.
it_item = it_read.
IF it_item CS '----'.
ELSE.
REPLACE ALL OCCURRENCES OF sy-vline IN it_item WITH deli.
APPEND it_item.
ENDIF.
ENDIF.
xy = 2.
xz = 38.
discount etc
IF sy-tabix >= descline1 AND sy-tabix < descline.
it_item = it_read.
it_item+12(1) = deli.
it_item+22(1) = deli.
it_item+43(1) = deli.
WHILE xy < colm.
xz = xz + 18.
it_item+xz(1) = deli.
xy = xy + 1.
ENDWHILE.
APPEND it_item.
ENDIF.
payment terms
xy = 2.
xz = 37.
pterm = descline + 6.
IF sy-tabix > descline AND sy-tabix < pterm.
it_item = it_read.
IF it_item CS '-----'.
CLEAR it_item.
APPEND it_item.
ELSE.
it_item+12(1) = deli.
it_item+15(1) = deli.
it_item+36(1) = deli.
WHILE xy < colm.
xz = xz + 17.
it_item+xz(1) = deli.
xy = xy + 1.
ENDWHILE.
APPEND it_item.
ENDIF.
ENDIF.
prepared by
lastline = pterm + 3.
IF sy-tabix >= pterm AND sy-tabix <= lastline.
it_item = it_read.
IF it_item CS '-----'.
ELSE.
it_item+0(1) = deli.
it_item+54(1) = ' '.
it_item+16(1) = deli.
APPEND it_item.
ENDIF.
ENDIF.
remaarks
yz = lastline + 10.
IF sy-tabix > lastline AND sy-tabix <= yz.
it_item = it_read.
it_item+0(1) = deli.
it_item+54(1) = ' '.
APPEND it_item.
ENDIF.
approved by
ab = yz + 5.
IF sy-tabix > yz AND sy-tabix < ab.
it_item = it_read.
IF it_item CS '-----'.
ELSE.
it_item+0(1) = deli.
it_item+54(1) = ' '.
it_item+14(1) = deli.
APPEND it_item.
ENDIF.
ENDIF.
ENDLOOP.
*--Formatting the area of additional data 1 and doing the BOLD
CALL METHOD OF h_excel 'Cells' = w_cell1
EXPORTING
#1 = 1
#2 = 1.
CALL METHOD OF h_excel 'Cells' = w_cell2
EXPORTING
#1 = 1
#2 = colm.
CALL METHOD OF h_excel 'Range' = h_cell
EXPORTING
#1 = w_cell1
#2 = w_cell2.
*CALL METHOD OF gs_cells 'Select' .
GET PROPERTY OF h_cell 'Font' = gs_font .
SET PROPERTY OF gs_font 'Bold' = 1 .
*Bold for the second row
CALL METHOD OF h_excel 'Cells' = w_cell1
EXPORTING
#1 = 2
#2 = 1.
CALL METHOD OF h_excel 'Cells' = w_cell2
EXPORTING
#1 = 1
#2 = colm.
CALL METHOD OF h_excel 'Range' = h_cell
EXPORTING
#1 = w_cell1
#2 = w_cell2.
*CALL METHOD OF gs_cells 'Select' .
GET PROPERTY OF h_cell 'Font' = gs_font .
SET PROPERTY OF gs_font 'Bold' = 1 .
*Bold for the fourth row
CALL METHOD OF h_excel 'Cells' = w_cell1
EXPORTING
#1 = 4
#2 = 1.
CALL METHOD OF h_excel 'Cells' = w_cell2
EXPORTING
#1 = 1
#2 = colm.
CALL METHOD OF h_excel 'Range' = h_cell
EXPORTING
#1 = w_cell1
#2 = w_cell2.
*CALL METHOD OF gs_cells 'Select' .
GET PROPERTY OF h_cell 'Font' = gs_font .
SET PROPERTY OF gs_font 'Bold' = 1 .
*Bold for the fifth row
CALL METHOD OF h_excel 'Cells' = w_cell1
EXPORTING
#1 = 5
#2 = 1.
CALL METHOD OF h_excel 'Cells' = w_cell2
EXPORTING
#1 = 1
#2 = colm.
CALL METHOD OF h_excel 'Range' = h_cell
EXPORTING
#1 = w_cell1
#2 = w_cell2.
*CALL METHOD OF gs_cells 'Select' .
GET PROPERTY OF h_cell 'Font' = gs_font .
SET PROPERTY OF gs_font 'Bold' = 1 .
*Bold for the sixth row
CALL METHOD OF h_excel 'Cells' = w_cell1
EXPORTING
#1 = 6
#2 = 1.
CALL METHOD OF h_excel 'Cells' = w_cell2
EXPORTING
#1 = 1
#2 = colm.
CALL METHOD OF h_excel 'Range' = h_cell
EXPORTING
#1 = w_cell1
#2 = w_cell2.
*CALL METHOD OF gs_cells 'Select' .
GET PROPERTY OF h_cell 'Font' = gs_font .
SET PROPERTY OF gs_font 'Bold' = 1 .
DATA l_rc TYPE i.
CALL METHOD cl_gui_frontend_services=>clipboard_export
IMPORTING
data = it_item[]
CHANGING
rc = l_rc
EXCEPTIONS
cntl_error = 1
error_no_gui = 2
not_supported_by_gui = 3
OTHERS = 4.
CALL METHOD OF h_excel 'Cells' = w_cell1
EXPORTING
#1 = 1
#2 = 1.
CALL METHOD OF h_excel 'Cells' = w_cell2
EXPORTING
#1 = 1
#2 = 1.
PERFORM err_hdl.
CALL METHOD OF h_excel 'Range' = range
EXPORTING
#1 = w_cell1
#2 = w_cell2.
CALL METHOD OF range 'Select'.
PERFORM err_hdl.
CALL METHOD OF worksheet 'Paste'.
PERFORM err_hdl.
CALL METHOD OF h_excel 'QUIT'.
FREE OBJECT h_zl.
FREE OBJECT h_mapl.
FREE OBJECT h_map.
FREE OBJECT h_excel.Hello Ravi,
Thank you very much for your suggestions.. but still have some more doubts:
What i want to do is :
-->call report in background job with a selection criteria.
-->the output of the report should be trasnsfered to excel sheet
-->then the excel sheet should be sent to XI..
My doubts are:
-> is it possible with every report or we need some extra code to achieve this
-> If yes, then how exactly it should be done. can you please explain in more detail.
Thank you very much for your help.
Best Regards,
Jasmeet -
Open excel sheet through program calculate value and fetch value in program
Hi experts,
My requirement is to open a excel sheet while i execute a report,There is some calculation that i need to do in excel sheet and want to fetch the calculated value back in to my program.
Is there any way of doing so ?
Regards,
KashyapHi Aditya ,
let me once more clarify with ur requirements .
User is uploading an excel sheet.
U doing validations on the records and getting the error in records.
Displaying the uploaded excel sheet to user to rectify the errors.
and then update the databse with the correct records.
So for the above
use WS_upload ,GUI_Upload FM for uploading the excel sheet in itab.
using this itab ,Dynamically add one more column for the errors.
Refer :Re: Could anyone tell me how can I add columns in a internal table dynamically?
Display records in an editable ALV grid.
BCALV_EDIT_01
BCALV_EDIT_02
BCALV_EDIT_03
BCALV_EDIT_04
BCALV_FULLSCREEN_GRID_EDIT
BCALV_GRID_EDIT
BCALV_TEST_GRID_EDIT_01
BCALV_TEST_GRID_EDITABLE
Also see this
http://www.sapdevelopment.co.uk/reporting/alv/alvscr.htm
then update the database
Regards
Renu
Edited by: Renu Gusain on May 8, 2009 8:40 AM -
Non-English string access from excel sheet through JDBC
My excel sheet data is
Test ������������
I am using JDBC connectivity for accessing the Excel sheet.
Code looks like,
List Output = new List();
try
Class.forName( "sun.jdbc.odbc.JdbcOdbcDriver" );
c = DriverManager.getConnection( "jdbc:odbc:qa-list", "", "" );
stmnt = c.createStatement();
ResultSet rs = stmnt.executeQuery("select * from [Sheet1$];");
ResultSetMetaData rsmd = rs.getMetaData();
int numberOfColumns = rsmd.getColumnCount();
for(int i=1; i <= numberOfColumns; i++){
Output.add(rsmd.getColumnLabel(i));
catch( Exception e )
System.err.println( e );
finally
try
stmnt.close();
c.close();
catch( Exception e )
System.err.println( e );
Now. I am showing those data into the table(JTable) Applet programming.
For, English string it is showing properly but, for non-English string are showing �???????????????????�
I would like to know what could be the reason.
Addional info:
ava version "1.6.0_01"
Java(TM) SE Runtime Environment (build 1.6.0_01-b06)
Java HotSpot(TM) Client VM (build 1.6.0_01-b06, mixed mode, sharing)
If possible please send some reference code .I have one excel sheet which having differenct countries specific meaining of common words.
I am using JDBC connectivity for accessing that Excel sheet.
Code looks like,
List Output = new List();
try
Class.forName( "sun.jdbc.odbc.JdbcOdbcDriver" );
c = DriverManager.getConnection( "jdbc:odbc:qa-list", "", "" );
stmnt = c.createStatement();
ResultSet rs = stmnt.executeQuery("select * from [Sheet1$];");
ResultSetMetaData rsmd = rs.getMetaData();
int numberOfColumns = rsmd.getColumnCount();
for(int i=1; i <= numberOfColumns; i++){
Output.add(rsmd.getColumnLabel(i));
catch( Exception e ){
System.err.println( e );
finally{
try{
stmnt.close();
c.close();
catch( Exception e ){
System.err.println( e );
Now. I am showing those output data into the table(JTable) in my Applet programming.
For, English string it is showing properly but, for non-English strings are showing question marks like, �?????�
I would like to know what could be the reason.
Please help me, i am stuck in my project.
Maybe you are looking for
-
I have a problem. By ues of the overcloaking center, i have seen that my IOH temp is at 77 degress celcius, which troubles me, especially since i have no idea of what IOH is.. so my questions is, what excactly is IOH and how can cool it, to a more to
-
Hi, I am try to configure the MLS for XI adapter according to the document. When doing a testing it give me this error. - <SAP:Error xmlns:SAP="http://sap.com/xi/XI/Message/30" xmlns:SOAP="http://schemas.xmlsoap.org/soap/envelope/" SOAP:mustUnderstan
-
Can't print or install anything.
I was doing some disk cleanup and I probably discarded something essential that I shouldn't have. The system seemed to work okay until I tried to print and although the printers show up, printing fails. Tried to reinstall drivers but I get an error m
-
hi all... Recently, one of our users started getting this error message "GuiXT lock situation", as you can see on the following print screens: http://www.mj23.org/sap/guixt01.jpg http://www.mj23.org/sap/guixt02.jpg Could you please let me know: 1. Wh
-
I Use Isquint to change wav files to mpeg4. I seem to have issues at times with the video quality after the conversion. They play fine via wav file but once converted they seem to distort at times. I this a Isquint issue or an id10t issue? Thanks..