We have added search box. Key in SAP issue keyword to search
TopBottom

Announcement: wanna exchange links? contact me at sapchatroom@gmail.com.

Re: [sap-log-mm] Send Purchase Order by Mail

Posted by Admin at
Share this post:
Ma.gnolia DiggIt! Del.icio.us Yahoo Furl Technorati Reddit

Reply from Pankaj.sapabap on Jun 11 at 11:34 AM
Hi Aglez,

I got your requirement. If you want to to put a customize body along with
PO as pdf in attachment, you have to write an implicit enhancement in the
FM "SBCOMS_SEND_REQUEST_CREATE"

I did a similar task, hereby attaching the sample code to be written
in enhancement:

ENHANCEMENT 1 ZENHANCE_BODY_TEXT. "active version
IF SY-TCODE eq 'ME9F'.
*BREAK-POINT.
DATA : WA_NOTE_TEXT1 TYPE SOLI,
WA_RECEIVERS TYPE SOOS1,
IT_ADR6 LIKE ADR6 OCCURS 0 WITH HEADER LINE,
V_LIFNR TYPE LFA1-LIFNR,
V_PERSNUMBER TYPE USR21-PERSNUMBER,
V_SMTP_ADDR TYPE ADR6-SMTP_ADDR,
V_SMTP_ADDR1 TYPE ADR6-SMTP_ADDR,
"New Variable as for givinf a particular ID in PO Mail Cc Option
VAR1 TYPE CHAR255,
VAR11 TYPE CHAR255,
VAR21 TYPE EKKO-ERNAM,
VAR31 TYPE LFA1-ADRNR,
V_NAMEV TYPE KNVK-NAMEV,
V_NAME1 TYPE KNVK-NAME1,
V_NAME TYPE STRING,
NAME11 TYPE LFA1-NAME1,
NAME21 TYPE LFA1-NAME2,
U_NAME1 TYPE ZDIGISIGN-NAME1,
U_NAME2 TYPE ZDIGISIGN-NAME2,
C_NAME TYPE STRING,
C_NAME12 TYPE STRING,
V_PODATE TYPE EKKO-BEDAT,
V_POAMOUNT TYPE EKKO-RLWRT,
V_POAMOUNT_C(15) TYPE C,
V_EBELN TYPE THEAD-TDNAME,
CONTACTNO1 TYPE ZDIGISIGN-CONTACTNO,
EMAILID1 TYPE ZDIGISIGN-EMAILID,
TEXT TYPE STRING,
TEXT1 TYPE STRING,
TEXT2 TYPE STRING,
DATE1(10) TYPE C,
DD1(2) TYPE C,
MM1(2) TYPE C,
YYYY1(4) TYPE C.

DATA : IT_ADDRESS LIKE BAPIADDR3 OCCURS 0 WITH HEADER LINE,
IT_BAPIRET2 LIKE BAPIRET2 OCCURS 0 WITH HEADER LINE.

DATA : begin of i_data occurs 0,
TDFORMAT(2) type c,
TDLINE(140) type c,
end of i_data.

DATA : V_BODY TYPE STRING.

FIELD-SYMBOLS
: <FS_PO_NO1> TYPE ANY,
<FS_MSG_TYPE1> TYPE ANY,
<FS_USNAM1> TYPE ANY,"ADDED
<FS_KAPPL1> TYPE ANY."ADDED

CONSTANTS:
C_PO_NO1 TYPE CHAR255 VALUE '(Y640FM06P)NAST-OBJKY',
"'(SAPFM06P)NAST-OBJKY' ,
C_MSG_TYPE1 TYPE CHAR255 VALUE '(Y640FM06P)NAST-KSCHL',
"'(SAPFM06P)NAST-KSCHL',
C_USNAM1 TYPE CHAR255 VALUE '(Y640FM06P)NAST-USNAM',"ADDED
C_KAPPL1 TYPE CHAR255 VALUE '(Y640FM06P)NAST-KAPPL',"ADDED
C_LINE1_11 TYPE CHAR255 VALUE

'We are please to place the attached "Purchase Order" for the
mentioned details.'
.
* Move po Number
CLEAR VAR1.
VAR11 = C_PO_NO1.
ASSIGN (VAR11) TO <FS_PO_NO1>.

* Move Message Type
CLEAR VAR11.
VAR11 = C_MSG_TYPE1.
ASSIGN (VAR11) TO <FS_MSG_TYPE1>.

* Move Application type
CLEAR VAR11.
VAR11 = C_KAPPL1.
ASSIGN (VAR11) TO <FS_KAPPL1>.

* Move User Name Processing the Transaction
CLEAR VAR11.
VAR11 = C_USNAM1.
ASSIGN (VAR11) TO <FS_USNAM1>.

IF <FS_PO_NO1> IS ASSIGNED AND
<FS_MSG_TYPE1> IS ASSIGNED AND
<FS_USNAM1> IS ASSIGNED.

IF ( <FS_MSG_TYPE1> = 'ZNEU' OR <FS_MSG_TYPE1> = 'ZNEW' ) AND <FS_KAPPL1> =
'EF'.
SELECT SINGLE ERNAM FROM EKKO INTO VAR21 WHERE EBELN = <FS_PO_NO1>.
SELECT SINGLE LIFNR FROM EKKO INTO V_LIFNR WHERE EBELN = <FS_PO_NO1>.
SELECT SINGLE RLWRT FROM EKKO INTO V_POAMOUNT WHERE EBELN = <FS_PO_NO1>.
V_POAMOUNT_C = V_POAMOUNT.
CONDENSE V_POAMOUNT_C.
SELECT SINGLE BEDAT FROM EKKO INTO V_PODATE WHERE EBELN = <FS_PO_NO1>.
DD1 = V_PODATE+6(2).
MM1 = V_PODATE+4(2).
YYYY1 = V_PODATE+0(4).
CONCATENATE DD1 MM1 YYYY1 INTO DATE1 SEPARATED BY '-'.
SELECT SINGLE ADRNR FROM LFA1 INTO VAR31 WHERE LIFNR = V_LIFNR.
SELECT SINGLE NAME1 NAME2 INTO (NAME11, NAME21)
FROM LFA1 WHERE LIFNR = V_LIFNR.

SELECT * FROM ADR6
INTO TABLE IT_ADR6
WHERE ADDRNUMBER = VAR31.

SELECT SINGLE PERSNUMBER INTO V_PERSNUMBER FROM USR21 WHERE BNAME =
<FS_USNAM1>.
SELECT SINGLE SMTP_ADDR FROM ADR6 INTO V_SMTP_ADDR WHERE PERSNUMBER =
V_PERSNUMBER.
******FOR PREPAROR DETAILS
* SELECT SINGLE NAME1 NAME2 CONTACTNO EMAILID INTO (U_NAME1, U_NAME2,
CONTACTNO1, EMAILID1)
* FROM ZDIGISIGN WHERE USERNAME = VAR21.
CALL FUNCTION 'BAPI_USER_GET_DETAIL'
EXPORTING
USERNAME = VAR21
CACHE_RESULTS = 'X'
IMPORTING
* LOGONDATA =
* DEFAULTS =
ADDRESS = IT_ADDRESS
* COMPANY =
* SNC =
* REF_USER =
* ALIAS =
* UCLASS =
* LASTMODIFIED =
* ISLOCKED =
TABLES
* PARAMETER =
* PROFILES =
* ACTIVITYGROUPS =
RETURN = IT_BAPIRET2
* ADDTEL =
* ADDFAX =
* ADDTTX =
* ADDTLX =
* ADDSMTP =
* ADDRML =
* ADDX400 =
* ADDRFC =
* ADDPRT =
* ADDSSF =
* ADDURI =
* ADDPAG =
* ADDCOMREM =
* PARAMETER1 =
* GROUPS =
* UCLASSSYS =
* EXTIDHEAD =
* EXTIDPART =
* SYSTEMS =
.
READ TABLE IT_ADDRESS INDEX 1.
U_NAME1 = IT_ADDRESS-FIRSTNAME.
U_NAME2 = IT_ADDRESS-LASTNAME.
CONTACTNO1 = IT_ADDRESS-TEL1_NUMBR.
EMAILID1 = IT_ADDRESS-E_MAIL.
CONCATENATE U_NAME1 U_NAME2 INTO C_NAME12 SEPARATED BY SPACE.
CONCATENATE IT_ADDRESS-TITLE_P C_NAME12 INTO C_NAME.
******FOR VENDOR NAME
SELECT SINGLE NAMEV NAME1 INTO (V_NAMEV, V_NAME1) FROM KNVK WHERE LIFNR =
V_LIFNR.

********** FOR PO HEADER TEXT**********
V_EBELN = <FS_PO_NO1>.
CALL FUNCTION 'READ_TEXT'
EXPORTING
CLIENT = SY-MANDT
ID = 'F01'
LANGUAGE = 'E'
NAME = V_EBELN
OBJECT = 'EKKO'
TABLES
LINES = I_data[].
************ For PO Mails in "To" option
*READ TABLE IT_ADR6 WITH KEY FLGDEFAULT = 'X'.
*WA_RECEIVERS-recextnam = IT_ADR6-SMTP_ADDR.
*WA_RECEIVERS-SNDCP = 'X'.
*WA_RECEIVERS-RECESC = 'U'.
*WA_RECEIVERS-SNDPRI = '1'.
*APPEND WA_RECEIVERS TO RECEIVERS.
************
************ For PO Mails in "Cc" option
V_SMTP_ADDR1 = email@removed'.
WA_RECEIVERS-recextnam = V_SMTP_ADDR1.
WA_RECEIVERS-SNDCP = 'X'.
WA_RECEIVERS-RECESC = 'U'.
WA_RECEIVERS-SNDPRI = '1'.
APPEND WA_RECEIVERS TO RECEIVERS.
***************

************ For PO Mails in "Cc" option
LOOP AT IT_ADR6 WHERE FLGDEFAULT NE 'X'.
WA_RECEIVERS-recextnam = IT_ADR6-SMTP_ADDR.
WA_RECEIVERS-SNDCP = 'X'.
WA_RECEIVERS-RECESC = 'U'.
WA_RECEIVERS-SNDPRI = '3'.
APPEND WA_RECEIVERS TO RECEIVERS.
ENDLOOP.
*************
**********For PO Mails in "Bcc" option(who has created the PO)
WA_RECEIVERS-recextnam = V_SMTP_ADDR.
WA_RECEIVERS-SNDBC = 'X'.
WA_RECEIVERS-RECESC = 'U'.
WA_RECEIVERS-SNDPRI = '3'.
APPEND WA_RECEIVERS TO RECEIVERS.
*********
***********For PO Mail body**********
CONCATENATE 'Dear' V_NAMEV V_NAME1',' INTO WA_NOTE_TEXT1 separated by space.
APPEND WA_NOTE_TEXT1 TO NOTE_TEXT.
APPEND INITIAL LINE TO NOTE_TEXT.
IF NOT I_DATA[] IS INITIAL.
LOOP AT I_DATA.
CONCATENATE TEXT I_DATA-TDLINE INTO TEXT separated by space.
ENDLOOP.
REPLACE ALL OCCURRENCES OF '<(>&<)>' IN TEXT WITH '&'.
ENDIF.
CONCATENATE '"' <FS_PO_NO1> '"' INTO TEXT1.
CONCATENATE 'We are pleased to inform you that Purchase Order No.' TEXT1
'dated' DATE1 'has been placed with your organization ' INTO WA_NOTE_TEXT1
separated by space.
APPEND WA_NOTE_TEXT1 TO NOTE_TEXT.
CONCATENATE '"' TEXT '".' INTO TEXT2.
CONCATENATE 'for' TEXT2 INTO WA_NOTE_TEXT1 separated by space.
APPEND WA_NOTE_TEXT1 TO NOTE_TEXT.
CONCATENATE
'A copy of the order has been attached herewith for your attention.' ' '
INTO WA_NOTE_TEXT1 .
APPEND WA_NOTE_TEXT1 TO NOTE_TEXT.
APPEND INITIAL LINE TO NOTE_TEXT.
CONCATENATE
'Kindly confirm acceptance of the order in writing at the earliest.
All correspondence in this matter may please'
' 'INTO WA_NOTE_TEXT1.
APPEND WA_NOTE_TEXT1 TO NOTE_TEXT.
CONCATENATE ' be addessed to' C_NAME 'of the company.' INTO WA_NOTE_TEXT1
separated by space .
APPEND WA_NOTE_TEXT1 TO NOTE_TEXT.
APPEND INITIAL LINE TO NOTE_TEXT.
CONCATENATE 'Yours faithfully,' '' INTO WA_NOTE_TEXT1.
APPEND WA_NOTE_TEXT1 TO NOTE_TEXT.
CONCATENATE 'For NOIDA POWER COMPANY LIMITED' '' INTO WA_NOTE_TEXT1 .
APPEND WA_NOTE_TEXT1 TO NOTE_TEXT.
CONCATENATE U_NAME1 U_NAME2 INTO WA_NOTE_TEXT1 separated by space.
APPEND WA_NOTE_TEXT1 TO NOTE_TEXT.
IF CONTACTNO1 NE ' '.
CONCATENATE 'Contact No.' ':' CONTACTNO1 INTO WA_NOTE_TEXT1 separated by
space .
APPEND WA_NOTE_TEXT1 TO NOTE_TEXT.
ENDIF.
IF EMAILID1 NE ' '.
CONCATENATE 'Email Id' ':' EMAILID1 INTO WA_NOTE_TEXT1 separated by space.
APPEND WA_NOTE_TEXT1 TO NOTE_TEXT.
ENDIF.
*************
ENDIF.
ENDIF.
ENDIF.
*********End Of Code
Added*********

ENDENHANCEMENT.

Thanks,
Pankaj

---------------Original Message---------------
From: Al Glez
Sent: Friday, June 08, 2012 2:27 PM
Subject: Send Purchase Order by Mail

Hi Gurus, I will like to send a mail automatically to the vendor with the purchase order as pdf when saving. This part is ok.

Now, I want to include a text in the mail with the PO number and some other data.
First: how do I send any plain text in the body of the mail?
Second: Is it possible to include some parameters to get data like PO order number, or PO date?
Thanks in advance.


Al

 
Reply to this email to post your response.
 
__.____._
Manage Settings | Unsubscribe | Create FAQ | Send Feedback
  
Copyright © 2012 Toolbox.com and message author.
Toolbox.com 4343 N. Scottsdale Road Suite 280, Scottsdale, AZ 85251
pretty lady ask a question
 
Pankaj.sapabap  
 
Mark as helpful
View this online
Ask a new question
 
In the Spotlight
Have an SAP Question? Ask Your Peers at Toolbox for IT

_.____.__

0 comments:

Post a Comment

T r a n s l a t e to your language