2006 Jul 06 8:21 AM
Hi,
I need to send a mail through my ABAP Program. The content of the mail is the content of an Internal Table.
I need to format the content of the Internal Table with proper spacing and heading.
Somebody please help me in this regard.
Thanks in advance.
2006 Jul 06 8:41 AM
HI,
U can create Standard Texts (SO10) and use this in the abap program for filling up the Mail Contents by Internal Table Data using REPLACE command.
Before u use REPLACE Call the Functionl Module "READ_TEXT".
NOTE:
In the Standard Texts U can use &1, &2, &3..... etc... for which u are replacing the Internal Table content in ABAP Program.
Hai
Check the following Code
DATA: OBJPACK LIKE SOPCKLSTI1 OCCURS 2 WITH HEADER LINE.
DATA: OBJHEAD LIKE SOLISTI1 OCCURS 1 WITH HEADER LINE.
DATA: OBJBIN LIKE SOLISTI1 OCCURS 10 WITH HEADER LINE.
DATA: OBJTXT LIKE SOLISTI1 OCCURS 10 WITH HEADER LINE.
DATA: RECLIST LIKE SOMLRECI1 OCCURS 5 WITH HEADER LINE.
DATA: DOC_CHNG LIKE SODOCCHGI1.
DOC_CHNG-OBJ_NAME = 'TEST'.
DOC_CHNG-OBJ_DESCR = 'Test-Dokument fur API1 Test'(001).
OBJTXT = 'Mindestgebot : $250000'.
APPEND OBJTXT.
OBJTXT = 'Eine Abbildung des zur Versteigerung stehenden Bildes'.
APPEND OBJTXT.
OBJTXT = 'wurde als Anlage beigefugt.'.
APPEND OBJTXT.
DESCRIBE TABLE OBJTXT LINES TAB_LINES.
READ TABLE OBJTXT INDEX TAB_LINES.
DOC_CHNG-DOC_SIZE = ( TAB_LINES - 1 ) * 255 + STRLEN( OBJTXT ).
* ERSTELLEN DES EINTRAGS ZUM KOMPRIMIERTEN DOKUMENT
CLEAR OBJPACK-TRANSF_BIN.
OBJPACK-HEAD_START = 1.
OBJPACK-HEAD_NUM = 0.
OBJPACK-BODY_START = 1.
OBJPACK-BODY_NUM = TAB_LINES.
OBJPACK-DOC_TYPE = 'RAW'.
APPEND OBJPACK.
* ERSTELLEN DER ANLAGE FUR DAS DOKUMENT
OBJBIN = '\O/ '. APPEND OBJBIN.
OBJBIN = ' '. APPEND OBJBIN.
OBJBIN = ' / \ '. APPEND OBJBIN.
DESCRIBE TABLE OBJBIN LINES TAB_LINES.
OBJHEAD = 'picasso.txt'. APPEND OBJHEAD.
* Erstellen des Eintrags zur komprimierten Anlage
OBJPACK-TRANSF_BIN = 'X'.
OBJPACK-HEAD_START = 1.
OBJPACK-HEAD_NUM = 1.
OBJPACK-BODY_START = 1.
OBJPACK-BODY_NUM = TAB_LINES.
OBJPACK-DOC_TYPE = 'TXT'.
OBJPACK-OBJ_NAME = 'ANLAGE'.
OBJPACK-OBJ_DESCR = 'Abbildung Objekt 138'.
OBJPACK-DOC_SIZE = TAB_LINES * 255.
APPEND OBJPACK.
* Fullen der Empfangerliste
RECLIST-RECEIVER = SY-UNAME.
RECLIST-REC_TYPE = 'B'.
APPEND RECLIST.
CALL FUNCTION 'SO_NEW_DOCUMENT_ATT_SEND_API1'
EXPORTING
DOCUMENT_DATA = DOC_CHNG
PUT_IN_OUTBOX = 'X'
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.
LOOP at <Internal tablename>.
use concatenate stement into 'Fieldname' separated by ' '.
endloop.
Thanks & Regards
Sreeni
2006 Jul 06 8:38 AM
Hello,
If u r using the FM SO_NEW_DOCUMENT_SEND_API1 to send the mail.
Then declare the int. table
DATA OBJCONT LIKE SOLI OCCURS 0 WITH HEADER LINE.
For example if ur data table is itab.
LOOP at itab.
COcatenate d1 f2 f3 into objcont-line separated by ' '.
endloop.
Try like this.
If it useful award the points.
Regards,
Vasanth
2006 Jul 06 8:41 AM
HI,
U can create Standard Texts (SO10) and use this in the abap program for filling up the Mail Contents by Internal Table Data using REPLACE command.
Before u use REPLACE Call the Functionl Module "READ_TEXT".
NOTE:
In the Standard Texts U can use &1, &2, &3..... etc... for which u are replacing the Internal Table content in ABAP Program.
2006 Jul 06 9:30 AM
Hi!
My problem is that while displaying internal table details in the mail body....under each heading...if any field value is blank...the next field value shifts left. so i need to know that if a field has 7 characters and is blank(no data) for that record..nxt field value should start from 8th position.
should i format using write statement?
or any function module exists for formatting?
I am displaying the part of the code:
*********the heading of mail body*****************
CONCATENATE 'SNo.' 'PROCESS' '---SERVER---' ' CLNT ' ' STATUS '
' TIME ' ' STARTDATE ' ' STARTTIME ' ' USER ' ' REPORT ' ' TABLE '
'REASON FOR WAITING' INTO I_OBJCONT SEPARATED BY '|'.
APPEND I_OBJCONT.
*****internal table data to be displayed***********
LOOP AT WP_EXCEED_INFO.
CONCATENATE CNT WP_EXCEED_INFO-WP_PID WP_EXCEED_INFO-WP_SERVER
WP_EXCEED_INFO-WP_MANDT WP_EXCEED_INFO-WP_STATUS
WP_EXCEED_INFO-WP_ELTIME WP_EXCEED_INFO-STARTDATE
WP_EXCEED_INFO-STARTTIME WP_EXCEED_INFO-WP_BNAME
WP_EXCEED_INFO-WP_REPORT WP_EXCEED_INFO-WP_TABLE
WP_EXCEED_INFO-WP_WAITINF INTO I_OBJCONT SEPARATED BY '|'.
APPEND I_OBJCONT.
ENDLOOP.
AND i am using SO_NEW_DOCUMENT_ATT_SEND_API1.
Thanks in advance.
2006 Jul 06 10:32 AM
Hi MANJUNATHA,
I created std text using so10. can u plz let me knw a example of hw to use Replace...?
Thanks.
2006 Jul 06 11:05 AM
Hi,
Am sending sample Code where I will be copying "t_line" with Internal Table contents and Finally taking it into t_mailtext.
This "t_mailtext" is used as the body of the Mail.....
The future formatting can be done in Standard Text without changing the ABAP Code
data: id like THEAD-TDID,
language like THEAD-TDSPRAS,
name like THEAD-TDNAME,
object like THEAD-TDOBJECT,
t_lines like TLINE occurs 0 with header line,
t_mailtext TYPE bcsy_text.
REFRESH : t_lines.
id = 'ST'.
language = 'EN'.
name = 'ZREJECT_JV'. "Standard Text Name
object = 'TEXT'.
CALL FUNCTION 'READ_TEXT'
EXPORTING
client = sy-mandt
id = id
language = language
name = name
object = object
TABLES
lines = t_lines
EXCEPTIONS
id = 1
language = 2
name = 3
not_found = 4
object = 5
reference_check = 6
wrong_access_to_archive = 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.
REFRESH : t_mailtext.
LOOP AT t_lines.
CLEAR : amount.
************
REPLACE '&01' IN t_lines WITH contr_name. "Controller Name
REPLACE '&02' IN t_lines WITH p_t_jv_disp-bukrs. "CCode
SELECT SINGLE butxt
FROM t001
INTO butxt
WHERE bukrs = p_t_jv_disp-bukrs.
REPLACE '&03' IN t_lines WITH butxt. "CCode Text
amount = p_t_jv_disp-dmbtr.
CALL FUNCTION 'CONVERSION_EXIT_ALPHA_OUTPUT'
EXPORTING
input = amount
IMPORTING
output = amount.
REPLACE '&04' IN t_lines WITH amount. "Document amount
REPLACE '&05' IN t_lines WITH p_t_jv_disp-belnr. "Document Number
REPLACE '&06' IN t_lines WITH p_t_jv_disp-gsber. "Business Area
SELECT SINGLE gtext
FROM tgsbt
INTO gtext
WHERE gsber = p_t_jv_disp-gsber.
REPLACE '&07' IN t_lines WITH gtext. "Business Area Text
REPLACE '&08' IN t_lines WITH remark_temp.
REPLACE '&09' IN t_lines WITH p_t_jv_disp-bktxt. "A/C Header Text
APPEND t_lines-tdline TO t_mailtext.
ENDLOOP.
For further details contact me
Regards,
Manjunatha
Message was edited by: MANJUNATHA KS
2006 Jul 06 11:10 AM
Hai
Check the following Code
DATA: OBJPACK LIKE SOPCKLSTI1 OCCURS 2 WITH HEADER LINE.
DATA: OBJHEAD LIKE SOLISTI1 OCCURS 1 WITH HEADER LINE.
DATA: OBJBIN LIKE SOLISTI1 OCCURS 10 WITH HEADER LINE.
DATA: OBJTXT LIKE SOLISTI1 OCCURS 10 WITH HEADER LINE.
DATA: RECLIST LIKE SOMLRECI1 OCCURS 5 WITH HEADER LINE.
DATA: DOC_CHNG LIKE SODOCCHGI1.
DOC_CHNG-OBJ_NAME = 'TEST'.
DOC_CHNG-OBJ_DESCR = 'Test-Dokument fur API1 Test'(001).
OBJTXT = 'Mindestgebot : $250000'.
APPEND OBJTXT.
OBJTXT = 'Eine Abbildung des zur Versteigerung stehenden Bildes'.
APPEND OBJTXT.
OBJTXT = 'wurde als Anlage beigefugt.'.
APPEND OBJTXT.
DESCRIBE TABLE OBJTXT LINES TAB_LINES.
READ TABLE OBJTXT INDEX TAB_LINES.
DOC_CHNG-DOC_SIZE = ( TAB_LINES - 1 ) * 255 + STRLEN( OBJTXT ).
* ERSTELLEN DES EINTRAGS ZUM KOMPRIMIERTEN DOKUMENT
CLEAR OBJPACK-TRANSF_BIN.
OBJPACK-HEAD_START = 1.
OBJPACK-HEAD_NUM = 0.
OBJPACK-BODY_START = 1.
OBJPACK-BODY_NUM = TAB_LINES.
OBJPACK-DOC_TYPE = 'RAW'.
APPEND OBJPACK.
* ERSTELLEN DER ANLAGE FUR DAS DOKUMENT
OBJBIN = '\O/ '. APPEND OBJBIN.
OBJBIN = ' '. APPEND OBJBIN.
OBJBIN = ' / \ '. APPEND OBJBIN.
DESCRIBE TABLE OBJBIN LINES TAB_LINES.
OBJHEAD = 'picasso.txt'. APPEND OBJHEAD.
* Erstellen des Eintrags zur komprimierten Anlage
OBJPACK-TRANSF_BIN = 'X'.
OBJPACK-HEAD_START = 1.
OBJPACK-HEAD_NUM = 1.
OBJPACK-BODY_START = 1.
OBJPACK-BODY_NUM = TAB_LINES.
OBJPACK-DOC_TYPE = 'TXT'.
OBJPACK-OBJ_NAME = 'ANLAGE'.
OBJPACK-OBJ_DESCR = 'Abbildung Objekt 138'.
OBJPACK-DOC_SIZE = TAB_LINES * 255.
APPEND OBJPACK.
* Fullen der Empfangerliste
RECLIST-RECEIVER = SY-UNAME.
RECLIST-REC_TYPE = 'B'.
APPEND RECLIST.
CALL FUNCTION 'SO_NEW_DOCUMENT_ATT_SEND_API1'
EXPORTING
DOCUMENT_DATA = DOC_CHNG
PUT_IN_OUTBOX = 'X'
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.
LOOP at <Internal tablename>.
use concatenate stement into 'Fieldname' separated by ' '.
endloop.
Thanks & Regards
Sreeni
2006 Sep 05 1:08 PM
Hi
did you get any solution for your following question mailformating
need to send a mail through my ABAP Program. The content of the mail is the content of an Internal Table.
I need to format the content of the Internal Table with proper spacing and heading.
if so please send me the details how to do that
i too have the same problem
thanks in advance
| User | Count |
|---|---|
| 4 | |
| 2 | |
| 2 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 |