‎2007 Jan 06 3:07 AM
Hi,
i am getting the following msg when i try to execute following code:
<b>The internal table "RT_ATTACH" has no header line - explicit
specification of an output area with "INTO wa" or "ASSIGNING <fs>" is
required.</b>
can anyone help me solving this one. where i am going wrong?
TYPES: begin of it_attach, "occurs 0,
field1 TYPE string, "(1000),
end of it_attach.
DATA :rt_attach TYPE STANDARD TABLE OF it_attach,
rs_attach LIKE LINE OF rt_attach.
DATS: w_cnt TYPE i,
CONCATENATE text-001 text-002 xxxxxxxxxx into rs_attach-field1
SEPARATED By con_tab.
CONCATENATE con_cret rs_attach-field1 INTO rs_attach-field1.
append rs_attach to rt_attach.
READ TABLE rt_attach INDEX w_cnt.
‎2007 Jan 06 3:17 AM
The internal table you declared is without header. You need to declare a work area like your internal table.
DATA: wa_rtattach like line of rt_attach.
OR
DATA: wa_rtattch type rt_attach.
read table rt_attach into wa_rtattch.
Thanks,
Santosh
‎2007 Jan 06 3:17 AM
The internal table you declared is without header. You need to declare a work area like your internal table.
DATA: wa_rtattach like line of rt_attach.
OR
DATA: wa_rtattch type rt_attach.
read table rt_attach into wa_rtattch.
Thanks,
Santosh
‎2007 Jan 06 3:25 AM
READ TABLE rt_attach INDEX w_cnt.
here your int table is without header line so after reading the data it cannot place the data to the header line and you dint specify any work area to take the value also so you have to specify that
data : wa LIKE LINE OF rt_attach.
read table rt_attach<b> into wa</b> index w_cnt
regards
shiba dutta
‎2007 Jan 06 5:45 AM
hi,
do like this.
*Table declaration (new method) "USE THIS WAY!!!
TYPES: BEGIN OF it_attach,
field1 TYPE string, "(1000),
end of it_attach.
.
DATA: rt_attach TYPE STANDARD TABLE OF it_attach INITIAL SIZE 0, "itab
wa_attach TYPE it_attach. "work area (header line)
CONCATENATE text-001 text-002 xxxxxxxxxx into wa_attach -field1
SEPARATED By con_tab.
CONCATENATE con_cret wa_attach-field1 INTO wa_attach-field1.
append wa_attach to rt_attach.
clear wa_attach.
READ TABLE rt_attach into wa_attach INDEX w_cnt.
Regards
anver
‎2007 Jan 06 7:49 AM
Hi Anver,
i did exactly the same. i am able to grasp the values. now the main problem lies in read statement. even though i am able to pick 7 values to my internal table, w_cnt is showing zero all the time. for pursual here is the complete code. plz help me resolving this. i am highlighting where i am getting error.
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 sy-tabix,
w_sent_all(1) TYPE c,
w_doc_data LIKE sodocchgi1,
gd_error TYPE sy-subrc,
gd_reciever TYPE sy-subrc.
DATA: it_message TYPE STANDARD TABLE OF solisti1 INITIAL SIZE 0
WITH HEADER LINE.
TYPES: BEGIN OF it_attach,
field1 TYPE string,
END OF it_attach.
DATA : rt_attach TYPE STANDARD TABLE OF it_attach, "it_attach occurs 0 with header line,
rs_attach LIKE LINE OF rt_attach. "TYPE it_attach occurs 0 with header line.
DATA: p_email TYPE somlreci1-receiver.
DATA: t_fname(16) type C.
Constants
CONSTANTS: zero(1) VALUE '0'.
SELECTION-SCREEN : BEGIN OF BLOCK b_mail WITH FRAME TITLE text-027. "D01K937047
PARAMETERS : p_mail AS CHECKBOX.
SELECTION-SCREEN : END OF BLOCK b_mail.
IF p_mail EQ 'X'.
PERFORM create_mail.
ENDIF.
&----
*& Form create_mail
&----
text
----
--> p1 text
<-- p2 text
----
FORM create_mail.
*DATA: t_fname(20) type C.
DATA: t_tit(100) type C.
Populate table with detaisl to be entered into .xls file
PERFORM build_xls_data_table.
Populate message body text
perform populate_email_message_body.
move 'AMD_WIP' to t_fname.
CONCATENATE t_fname sy-datum INTO t_fname.
Send file by email as .xls speadsheet
move 'AMD WIP Flush Report' to t_tit.
PERFORM send_file_as_email_attachment
tables it_message
rt_attach
using p_email
t_tit
'xls'
'E-T'
t_fname
' '
' '
changing gd_error
gd_reciever.
Instructs mail send program for SAPCONNECT to send email(rsconn01)
PERFORM initiate_mail_execute_program.
ENDFORM. " sendmail
&----
*& Form build_xls_data_table
&----
text
----
--> p1 text
<-- p2 text
----
FORM build_xls_data_table .
class cl_abap_char_utilities definition load.
constants:
con_tab type c value cl_abap_char_utilities=>HORIZONTAL_TAB,
con_cret type c value cl_abap_char_utilities=>CR_LF.
clear rs_attach.
CONCATENATE text-006 text-018 text-007 text-008 text-009 text-010
text-011 text-012 text-013 text-020 text-014 text-015
text-016 text-017 text-019 text-021 text-022 text-023
text-024 text-025 text-026 into rs_attach-field1
SEPARATED By con_tab.
CONCATENATE con_cret rs_attach-field1 INTO rs_attach-field1.
append rs_attach to rt_attach.
sort t_output by lot_id ascending.
Set up the attachment file
LOOP AT t_output INTO s_output.
CLEAR rs_attach.
CONCATENATE : s_output-lot_id
s_output-lot_id_arrival
s_output-product
s_output-cust_code
s_output-lot_type
s_output-s_lot_type
s_output-start_date
s_output-out_date
s_output-start_qty
s_output-out_qty
s_output-context_1
s_output-context_2
s_output-context_3
s_output-ship_to
s_output-cr_md_pdef
s_output-cr_pdef
s_output-poly_ret
s_output-poly_stp
s_output-poly_etc
s_output-die_quantity
s_output-cust_ponumber
INTO rs_attach-field1 SEPARATED BY con_tab.
CONCATENATE con_cret rs_attach-field1 INTO rs_attach-field1.
APPEND rs_attach to rt_attach.
ENDLOOP.
rv_file = filename.
ENDFORM. " build_xls_data_table
&----
*& Form send_file_as_email_attachment
&----
text
----
-->P_IT_MESSAGE text
-->P_RT_ATTACH text
-->P_P_EMAIL text
-->P_T_TIT text
-->P_4543 text
-->P_4544 text
-->P_T_FNAME text
-->P_4546 text
-->P_4547 text
<--P_GD_ERROR text
<--P_GD_RECIEVER text
----
FORM send_file_as_email_attachment tables pit_message
prt_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: progname(40) TYPE C.
DATA: begin of email_list occurs 0.
include structure zatsg_email.
DATA: end of email_list.
ld_email = p_email.
ld_mtitle = p_mtitle.
ld_format = p_format.
ld_attdescription = p_attdescription.
ld_attfilename = t_fname.
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 rt_attach INTO rs_attach INDEX w_cnt.
w_doc_data-doc_size =
( w_cnt - 1 ) * 256 + STRLEN( rs_attach-field1 ).
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[] = prt_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 = 'TXT'.
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 * 256.
APPEND t_packing_list.
IF p_email EQ 'X'.
progname = sy-repid.
SELECT * FROM zatsg_email INTO TABLE email_list
WHERE pgnam EQ progname AND kunnr EQ '0000000095'.
check not email_list[] is initial.
loop at email_list.
ld_email = email_list-email.
Add the recipients email address
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.
CLEAR t_receivers.
ENDLOOP.
CALL FUNCTION 'SO_NEW_DOCUMENT_ATT_SEND_API1'
EXPORTING
DOCUMENT_DATA = w_doc_data
PUT_IN_OUTBOX = 'X'
COMMIT_WORK = 'X'
IMPORTING
SENT_TO_ALL = w_sent_all
NEW_OBJECT_ID =
TABLES
PACKING_LIST = t_packing_list
OBJECT_HEADER =
CONTENTS_BIN = t_attachment
CONTENTS_TXT = it_message
CONTENTS_HEX =
OBJECT_PARA =
OBJECT_PARB =
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
&----
*& Form initiate_mail_execute_program
&----
text
----
--> p1 text
<-- p2 text
----
FORM initiate_mail_execute_program.
WAIT UP TO 2 SECONDS.
SUBMIT rsconn01 WITH mode = 'INT'
WITH output = 'X'
AND RETURN.
ENDFORM. " initiate_mail_execute_program
&----
*& Form populate_email_message_body
&----
text
----
--> p1 text
<-- p2 text
----
FORM populate_email_message_body .
REFRESH it_message.
it_message = 'Please find attached a AMD_WIP records'.
APPEND it_message.
ENDFORM. " populate_email_message_body
‎2007 Jan 06 6:59 AM
Hi,
Instead of
"DATA :rt_attach TYPE STANDARD TABLE OF it_attach, "
Please try " DATA :rt_attach like it_attach occurs 0 with header line ,"
Leave the rest of the code intact
Purpose :
it is creating an internal table with header line and for more help try F1...you can find the "Occurs 0 specification" as an obselete method but it will do your job....
Regards
Bx