2007 May 28 7:00 AM
helllo
I have a requirement in which i have to create a custom table with the fields plant,storage location and approver user id.........and when the purchase requisition is created the work flow should be triggered and the fields issuing plant and storage location should be read frm the PR and the related approver user id should be sent a mail for approval and .........and also the requisitioner and creator should be sent a mail when rejection or approval....now my question is where can i get the approver user id frm????how to send the mail to them....could anybody please help me with this requirement briefly even if it takes some time
regards
anik
2007 May 28 7:08 AM
Hi
Use the Business Object BUS2105 for this
and go through the program related to this object and
see the sample code that was written to saend a mail from this WF object
Implementation of object type BUS2105 *****
INCLUDE <object>.
DATA: BDCDATA LIKE BDCDATA OCCURS 0 WITH HEADER LINE.
BEGIN_DATA OBJECT. " Do not change.. DATA is generated
only private members may be inserted into structure private
DATA:
" begin of private,
" to declare private attributes remove comments and
" insert private attributes here ...
" end of private,
BEGIN OF KEY,
NUMBER LIKE EBAN-BANFN,
END OF KEY.
END_DATA OBJECT. " Do not change.. DATA is generated
TABLES eban.
begin_method change changing container.
DATA:
requisitionitemsold LIKE bapiebanv OCCURS 0,
requisitionitemsnew LIKE bapiebanv OCCURS 0,
requisitionaccountol LIKE bapiebknv OCCURS 0,
requisitionaccountne LIKE bapiebknv OCCURS 0,
requisitiontextold LIKE bapiebantx OCCURS 0,
requisitiontextnew LIKE bapiebantx OCCURS 0,
return LIKE bapireturn OCCURS 0.
swc_get_table container 'RequisitionItemsOld' requisitionitemsold.
swc_get_table container 'RequisitionItemsNew' requisitionitemsnew.
swc_get_table container 'RequisitionAccountOl' requisitionaccountol.
swc_get_table container 'RequisitionAccountNe' requisitionaccountne.
swc_get_table container 'RequisitionTextOld' requisitiontextold.
swc_get_table container 'RequisitionTextNew' requisitiontextnew.
swc_get_table container 'Return' return.
CALL FUNCTION 'BAPI_REQUISITION_CHANGE'
EXPORTING
number = object-key-number
TABLES
return = return
requisition_text_new = requisitiontextnew
requisition_text_old = requisitiontextold
requisition_account_new = requisitionaccountne
requisition_account_old = requisitionaccountol
requisition_items_new = requisitionitemsnew
requisition_items_old = requisitionitemsold
EXCEPTIONS
OTHERS = 01.
CASE sy-subrc.
WHEN 0. " OK
WHEN OTHERS. " to be implemented
ENDCASE.
swc_set_table container 'RequisitionItemsOld' requisitionitemsold.
swc_set_table container 'RequisitionItemsNew' requisitionitemsnew.
swc_set_table container 'RequisitionAccountOl' requisitionaccountol.
swc_set_table container 'RequisitionAccountNe' requisitionaccountne.
swc_set_table container 'RequisitionTextOld' requisitiontextold.
swc_set_table container 'RequisitionTextNew' requisitiontextnew.
swc_set_table container 'Return' return.
end_method.
begin_method getitemsforrelease changing container.
DATA:
relgroup LIKE bapimmpara-rel_group,
relcode LIKE bapimmpara-rel_code,
itemsforrelease LIKE bapimmpara-selection,
requisitionitems LIKE bapiebanc OCCURS 0,
return LIKE bapireturn OCCURS 0.
swc_get_element container 'RelGroup' relgroup.
swc_get_element container 'RelCode' relcode.
swc_get_element container 'ItemsForRelease' itemsforrelease.
IF sy-subrc <> 0.
MOVE 'X' TO itemsforrelease.
ENDIF.
swc_get_table container 'RequisitionItems' requisitionitems.
swc_get_table container 'Return' return.
CALL FUNCTION 'BAPI_REQUISITION_GETITEMSREL'
EXPORTING
items_for_release = itemsforrelease
rel_code = relcode
rel_group = relgroup
TABLES
requisition_items = requisitionitems
return = return
EXCEPTIONS
OTHERS = 01.
CASE sy-subrc.
WHEN 0. " OK
WHEN OTHERS. " to be implemented
ENDCASE.
swc_set_table container 'RequisitionItems' requisitionitems.
swc_set_table container 'Return' return.
end_method.
begin_method delete changing container.
DATA:
requisitionitemstode LIKE bapieband OCCURS 0,
return LIKE bapireturn OCCURS 0.
swc_get_table container 'RequisitionItemsToDe' requisitionitemstode.
swc_get_table container 'Return' return.
CALL FUNCTION 'BAPI_REQUISITION_DELETE'
EXPORTING
number = object-key-number
TABLES
requisition_items_to_delete = requisitionitemstode
return = return
EXCEPTIONS
OTHERS = 01.
CASE sy-subrc.
WHEN 0. " OK
WHEN OTHERS. " to be implemented
ENDCASE.
swc_set_table container 'RequisitionItemsToDe' requisitionitemstode.
swc_set_table container 'Return' return.
end_method.
begin_method getdetail changing container.
DATA:
accountassignment LIKE bapimmpara-selection,
itemtexts LIKE bapimmpara-selection,
services LIKE bapimmpara-selection,
servicetexts LIKE bapimmpara-selection,
requisitionitems LIKE bapieban OCCURS 0,
requisitionaccountas LIKE bapiebkn OCCURS 0,
requisitiontext LIKE bapiebantx OCCURS 0,
requisitionlimits LIKE bapiesuh OCCURS 0,
requisitioncontractl LIKE bapiesuc OCCURS 0,
requisitionservices LIKE bapiesll OCCURS 0,
requisitionsrvtexts LIKE bapieslltx OCCURS 0,
requisitionsrvaccass LIKE bapieskl OCCURS 0,
return LIKE bapireturn OCCURS 0.
swc_get_element container 'AccountAssignment' accountassignment.
IF sy-subrc <> 0.
MOVE space TO accountassignment.
ENDIF.
swc_get_element container 'ItemTexts' itemtexts.
IF sy-subrc <> 0.
MOVE space TO itemtexts.
ENDIF.
swc_get_element container 'Services' services.
IF sy-subrc <> 0.
MOVE space TO services.
ENDIF.
swc_get_element container 'ServiceTexts' servicetexts.
IF sy-subrc <> 0.
MOVE space TO servicetexts.
ENDIF.
swc_get_table container 'RequisitionItems' requisitionitems.
swc_get_table container 'RequisitionAccountAs' requisitionaccountas.
swc_get_table container 'RequisitionText' requisitiontext.
swc_get_table container 'RequisitionLimits' requisitionlimits.
swc_get_table container 'RequisitionContractL' requisitioncontractl.
swc_get_table container 'RequisitionServices' requisitionservices.
swc_get_table container 'RequisitionSrvTexts' requisitionsrvtexts.
swc_get_table container 'RequisitionSrvAccass' requisitionsrvaccass.
swc_get_table container 'Return' return.
CALL FUNCTION 'BAPI_REQUISITION_GETDETAIL'
EXPORTING
services = services
service_texts = servicetexts
item_texts = itemtexts
account_assignment = accountassignment
number = object-key-number
TABLES
requisition_contract_limits = requisitioncontractl
requisition_services = requisitionservices
requisition_services_texts = requisitionsrvtexts
requisition_srv_accass_values = requisitionsrvaccass
return = return
requisition_limits = requisitionlimits
requisition_text = requisitiontext
requisition_account_assignment = requisitionaccountas
requisition_items = requisitionitems
EXCEPTIONS
OTHERS = 01.
CASE sy-subrc.
WHEN 0. " OK
WHEN OTHERS. " to be implemented
ENDCASE.
swc_set_table container 'RequisitionItems' requisitionitems.
swc_set_table container 'RequisitionAccountAs' requisitionaccountas.
swc_set_table container 'RequisitionText' requisitiontext.
swc_set_table container 'RequisitionLimits' requisitionlimits.
swc_set_table container 'RequisitionContractL' requisitioncontractl.
swc_set_table container 'RequisitionServices' requisitionservices.
swc_set_table container 'RequisitionSrvTexts' requisitionsrvtexts.
swc_set_table container 'RequisitionSrvAccass' requisitionsrvaccass.
swc_set_table container 'Return' return.
end_method.
begin_method getreleaseinfo changing container.
DATA:
item LIKE bapirlgnrq-preq_item,
relcode LIKE bapirlgnrq-rel_code,
generalreleaseinfo LIKE bapirlgnrq OCCURS 0,
releaseprerequisites LIKE bapirlcorq OCCURS 0,
releasealreadyposted LIKE bapirlcorq OCCURS 0,
releasefinal LIKE bapirlcorq OCCURS 0,
return LIKE bapireturn OCCURS 0.
swc_get_element container 'Item' item.
swc_get_element container 'RelCode' relcode.
swc_get_table container 'GeneralReleaseInfo' generalreleaseinfo.
swc_get_table container 'ReleasePrerequisites' releaseprerequisites.
swc_get_table container 'ReleaseAlreadyPosted' releasealreadyposted.
swc_get_table container 'ReleaseFinal' releasefinal.
swc_get_table container 'Return' return.
CALL FUNCTION 'BAPI_REQUISITION_GETRELINFO'
EXPORTING
rel_code = relcode
item = item
number = object-key-number
TABLES
return = return
release_final = releasefinal
release_already_posted = releasealreadyposted
release_prerequisites = releaseprerequisites
general_release_info = generalreleaseinfo
EXCEPTIONS
OTHERS = 01.
CASE sy-subrc.
WHEN 0. " OK
WHEN OTHERS. " to be implemented
ENDCASE.
swc_set_table container 'GeneralReleaseInfo' generalreleaseinfo.
swc_set_table container 'ReleasePrerequisites' releaseprerequisites.
swc_set_table container 'ReleaseAlreadyPosted' releasealreadyposted.
swc_set_table container 'ReleaseFinal' releasefinal.
swc_set_table container 'Return' return.
end_method.
begin_method display changing container.
CALL FUNCTION 'MMPUR_REQUISITION_DISPLAY'
EXPORTING
im_banfn = object-key-number
EXCEPTIONS
OTHERS = 1.
IF sy-subrc <> 0.
MESSAGE ID sy-msgid TYPE 'S' NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ENDIF.
end_method.
begin_method existencecheck changing container.
DATA: lv_banfn LIKE object-key-number.
SELECT banfn FROM eban INTO lv_banfn
WHERE banfn EQ object-key-number.
ENDSELECT.
IF sy-subrc NE 0. "154883
exit_object_not_found. "154883
ENDIF. "154883
end_method.
begin_method singlerelease changing container.
DATA: purchaserequisition LIKE eban-banfn,
releasecode LIKE rm06b-frgab,
call_updkz.
swc_get_element container 'ReleaseCode' releasecode.
purchaserequisition = object-key-number.
CALL FUNCTION 'ME_RELEASE_REQUISITION'
EXPORTING
im_banfn = purchaserequisition
im_frgco = releasecode
im_wf = 'X'
IMPORTING
ex_updkz = call_updkz
EXCEPTIONS
OTHERS = 0.
IF call_updkz NE space.
IF call_updkz EQ 'N'.
CLEAR call_updkz.
ENDIF.
swc_set_element container result call_updkz.
ELSE.
exit_cancelled.
ENDIF.
end_method.
begin_method inforeleasereset changing container.
DATA:
releasecode LIKE rm06b-frgab.
swc_get_element container 'ReleaseCode' releasecode.
end_method.
begin_method inforeleaserejected changing container.
CALL FUNCTION 'MMPUR_REQUISITION_DISPLAY'
EXPORTING
im_banfn = object-key-number
im_change = 'X'
EXCEPTIONS
OTHERS = 1.
IF sy-subrc <> 0.
MESSAGE ID sy-msgid TYPE 'S' NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ENDIF.
end_method.
begin_method inforeleaseeffected changing container.
DATA:
releasecode LIKE rm06b-frgab.
swc_get_element container 'ReleaseCode' releasecode.
end_method.
begin_method release changing container.
DATA:
relcode LIKE bapimmpara-rel_code,
relstatusnew LIKE bapimmpara-rel_status,
relindicatornew LIKE bapimmpara-rel_ind,
return LIKE bapireturn OCCURS 0.
swc_get_element container 'RelCode' relcode.
swc_get_table container 'Return' return.
CALL FUNCTION 'BAPI_REQUISITION_RELEASE_GEN'
EXPORTING
number = object-key-number
rel_code = relcode
IMPORTING
rel_indicator_new = relindicatornew
rel_status_new = relstatusnew
TABLES
return = return
EXCEPTIONS
OTHERS = 01.
CASE sy-subrc.
WHEN 0. " OK
WHEN OTHERS. " to be implemented
ENDCASE.
swc_set_element container 'RelStatusNew' relstatusnew.
swc_set_element container 'RelIndicatorNew' relindicatornew.
swc_set_table container 'Return' return.
end_method.
begin_method resetrelease changing container.
DATA:
relcode LIKE bapimmpara-rel_code,
relstatusnew LIKE bapimmpara-rel_status,
relindicatornew LIKE bapimmpara-rel_ind,
return LIKE bapireturn OCCURS 0.
swc_get_element container 'RelCode' relcode.
swc_get_table container 'Return' return.
CALL FUNCTION 'BAPI_REQUISITION_RESET_REL_GEN'
EXPORTING
number = object-key-number
rel_code = relcode
IMPORTING
rel_indicator_new = relindicatornew
rel_status_new = relstatusnew
TABLES
return = return
EXCEPTIONS
OTHERS = 01.
CASE sy-subrc.
WHEN 0. " OK
WHEN OTHERS. " to be implemented
ENDCASE.
swc_set_element container 'RelStatusNew' relstatusnew.
swc_set_element container 'RelIndicatorNew' relindicatornew.
swc_set_table container 'Return' return.
end_method.
begin_method getitems changing container.
DATA:
preqno LIKE bapieban-preq_no,
purgroup LIKE bapieban-pur_group,
preqname LIKE bapieban-preq_name,
preqdate LIKE bapieban-preq_date,
material LIKE bapieban-material,
matgrp LIKE bapieban-mat_grp,
trackingno LIKE bapieban-trackingno,
plant LIKE bapieban-plant,
doctype LIKE bapieban-doc_type,
delivdate LIKE bapieban-deliv_date,
reldate LIKE bapieban-rel_date,
shorttext LIKE bapieban-short_text,
assigneditems LIKE bapimmpara-selection,
closeditems LIKE bapimmpara-selection,
deleteditems LIKE bapimmpara-selection,
partiallyordereditems LIKE bapimmpara-selection,
onlynonmaterialitems LIKE bapimmpara-selection,
openitems LIKE bapimmpara-selection,
requisitionitems LIKE bapiebanc OCCURS 0,
return LIKE bapireturn OCCURS 0.
swc_get_element container 'PreqNo' preqno.
swc_get_element container 'PurGroup' purgroup.
swc_get_element container 'PreqName' preqname.
swc_get_element container 'PreqDate' preqdate.
swc_get_element container 'Material' material.
swc_get_element container 'MatGrp' matgrp.
swc_get_element container 'Trackingno' trackingno.
swc_get_element container 'Plant' plant.
swc_get_element container 'DocType' doctype.
swc_get_element container 'DelivDate' delivdate.
swc_get_element container 'RelDate' reldate.
swc_get_element container 'ShortText' shorttext.
swc_get_element container 'AssignedItems' assigneditems.
IF sy-subrc <> 0.
MOVE space TO assigneditems.
ENDIF.
swc_get_element container 'ClosedItems' closeditems.
IF sy-subrc <> 0.
MOVE space TO closeditems.
ENDIF.
swc_get_element container 'DeletedItems' deleteditems.
IF sy-subrc <> 0.
MOVE space TO deleteditems.
ENDIF.
swc_get_element container 'PartiallyOrderedItems'
partiallyordereditems.
IF sy-subrc <> 0.
MOVE space TO partiallyordereditems.
ENDIF.
swc_get_element container 'OnlyNonMaterialItems' onlynonmaterialitems.
IF sy-subrc <> 0.
MOVE space TO onlynonmaterialitems.
ENDIF.
swc_get_element container 'OpenItems' openitems.
IF sy-subrc <> 0.
MOVE 'X' TO openitems.
ENDIF.
swc_get_table container 'RequisitionItems' requisitionitems.
CALL FUNCTION 'BAPI_REQUISITION_GETITEMS'
EXPORTING
deliv_date = delivdate
rel_date = reldate
short_text = shorttext
assigned_items = assigneditems
closed_items = closeditems
deleted_items = deleteditems
partially_ordered_items = partiallyordereditems
only_non_material_items = onlynonmaterialitems
open_items = openitems
preq_no = preqno
pur_group = purgroup
preq_name = preqname
preq_date = preqdate
material = material
doc_type = doctype
plant = plant
trackingno = trackingno
mat_grp = matgrp
TABLES
requisition_items = requisitionitems
return = return
EXCEPTIONS
OTHERS = 01.
CASE sy-subrc.
WHEN 0. " OK
WHEN OTHERS. " to be implemented
ENDCASE.
swc_set_table container 'RequisitionItems' requisitionitems.
swc_set_table container 'Return' return.
end_method.
begin_method edit changing container.
CALL FUNCTION 'MMPUR_REQUISITION_DISPLAY'
EXPORTING
im_banfn = object-key-number
im_change = 'X'
EXCEPTIONS
OTHERS = 1.
IF sy-subrc <> 0.
MESSAGE ID sy-msgid TYPE 'S' NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ENDIF.
end_method.
begin_method createfromdata changing container.
DATA:
requisitionitems LIKE bapiebanc OCCURS 0,
requisitionaccountas LIKE bapiebkn OCCURS 0,
requisitionitemtext LIKE bapiebantx OCCURS 0,
requisitionlimits LIKE bapiesuhc OCCURS 0,
requisitioncontractl LIKE bapiesucc OCCURS 0,
requisitionservices LIKE bapiesllc OCCURS 0,
requisitionsrvtext LIKE bapieslltx OCCURS 0,
requisitionsrvaccass LIKE bapiesklc OCCURS 0,
return LIKE bapireturn OCCURS 0,
extensionin LIKE bapiparex OCCURS 0,
skipitemswitherror LIKE bapimmpara-selection.
swc_get_table container 'RequisitionItems' requisitionitems.
swc_get_table container 'RequisitionAccountAs' requisitionaccountas.
swc_get_table container 'RequisitionItemText' requisitionitemtext.
swc_get_table container 'RequisitionLimits' requisitionlimits.
swc_get_table container 'RequisitionContractL' requisitioncontractl.
swc_get_table container 'RequisitionServices' requisitionservices.
swc_get_table container 'RequisitionSrvText' requisitionsrvtext.
swc_get_table container 'RequisitionSrvAccass' requisitionsrvaccass.
swc_get_table container 'ExtensionIn' extensionin.
swc_get_element container 'SkipItemsWithError' skipitemswitherror.
CALL FUNCTION 'BAPI_REQUISITION_CREATE'
EXPORTING
skip_items_with_error = skipitemswitherror
IMPORTING
number = object-key-number
TABLES
requisition_services = requisitionservices
requisition_srv_accass_values = requisitionsrvaccass
return = return
requisition_services_text = requisitionsrvtext
extensionin = extensionin
requisition_items = requisitionitems
requisition_account_assignment = requisitionaccountas
requisition_item_text = requisitionitemtext
requisition_limits = requisitionlimits
requisition_contract_limits = requisitioncontractl
EXCEPTIONS
OTHERS = 01.
CASE sy-subrc.
WHEN 0. " OK
WHEN OTHERS. " to be implemented
ENDCASE.
swc_set_table container 'RequisitionItems' requisitionitems.
swc_set_table container 'RequisitionAccountAs' requisitionaccountas.
swc_set_table container 'RequisitionItemText' requisitionitemtext.
swc_set_table container 'RequisitionLimits' requisitionlimits.
swc_set_table container 'RequisitionContractL' requisitioncontractl.
swc_set_table container 'RequisitionServices' requisitionservices.
swc_set_table container 'RequisitionSrvAccass' requisitionsrvaccass.
swc_set_table container 'Return' return.
end_method.
begin_method editasync changing container.
CALL FUNCTION 'MMPUR_REQUISITION_DISPLAY'
EXPORTING
im_banfn = object-key-number
im_change = 'X'
EXCEPTIONS
OTHERS = 1.
IF sy-subrc <> 0.
MESSAGE ID sy-msgid TYPE 'S' NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ENDIF.
end_method.
----
Start new screen *
----
FORM BDC_DYNPRO USING PROGRAM DYNPRO.
CLEAR BDCDATA.
BDCDATA-PROGRAM = PROGRAM.
BDCDATA-DYNPRO = DYNPRO.
BDCDATA-DYNBEGIN = 'X'.
APPEND BDCDATA.
ENDFORM.
----
Insert field *
----
FORM BDC_FIELD USING FNAM FVAL.
IF FVAL <> SPACE.
CLEAR BDCDATA.
BDCDATA-FNAM = FNAM.
BDCDATA-FVAL = FVAL.
APPEND BDCDATA.
ENDIF.
ENDFORM.
*********************************************************************
BEGIN_METHOD SEND_MAIL CHANGING CONTAINER.
tables : usr21,t16fw.
data : v_ebeln like ekko-ebeln,
v_str(37), v_str1(21), v_str2(25), v_str3(7),
v_ernam like ekko-ernam,
v_rel_code LIKE rm06b-frgab,
v_pos like t16fw-objid,
v_pernr like adr6-PERSnumbeR,
v_adrnr like adr6-addrnumber,
v_usrid like pa0105-usrid,
v_bsart type bbsrt, " PR Type
v_batxt type batxt, " PR Type Description
v_mail like adr6-smtp_addr,
v_sendor type syuname,
v_receiver type string,
v_header type string,
v_body type string.
swc_get_element container 'reqno' v_ebeln.
swc_get_element container 'ReleaseCode' v_rel_code.
clear: v_pos, v_pernr, v_usrid, v_adrnr, v_mail,v_bsart, v_batxt,
v_sendor, v_receiver, v_header, v_body , v_ernam.
select single bsart ernam into (v_bsart, v_ernam)
from eban where banfn = v_ebeln.
select single batxt from t161t into v_batxt
where spras = sy-langu and
bsart = v_bsart and
bstyp = 'B'.
select single objid from t16fw into v_pos
where frgco = v_rel_code
and otype = 'S'.
if sy-subrc eq 0.
select single pernr into v_pernr from pa0001
where endda eq '99991231' and
plans eq v_pos.
if sy-subrc = 0.
select single usrid into v_usrid from pa0105
where endda eq '99991231' and
subty eq '0001' and
pernr eq v_pernr.
if sy-subrc = 0.
select single persnumber addrnumber from usr21
into (v_pernr,v_adrnr)
where bname = v_usrid.
if sy-subrc = 0.
select single smtp_addr into v_mail from adr6
where addrnumber = v_adrnr and
persnumber = v_pernr.
if sy-subrc <> 0.
concatenate v_usrid '@sipchem.com' into v_mail.
v_receiver = v_mail.
else.
v_receiver = v_mail.
endif.
v_sendor = v_ernam.
v_header = 'Purchase Requisition Release'.
v_str = 'Pls release it through your SAP Inbox'.
v_str1 = 'Purchase Requestion #'.
v_str3 = 'of type'.
v_str2 = 'is awaiting your release.'.
concatenate v_str1 v_ebeln v_str3 v_batxt v_str2 v_str
into v_body separated by space.
Call Function Module To send mail
CALL FUNCTION 'UWSP_SEND_MAIL_TO_WEB'
EXPORTING
id_header = v_header
id_body = v_body
id_receiver = v_receiver
ID_SENDER = v_ernam
ID_HTML_MAIL =
ID_COMMIT_WORK = 'X'
EXCEPTIONS
ERROR = 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.
endif.
endif.
endif.
endif.
END_METHOD.
***********************************************************************
BEGIN_METHOD SENDMAILREJECT CHANGING CONTAINER.
data : v_ebeln like ekko-ebeln,
v_str(24), v_str1(21), v_str2(18), v_str3(7),
v_ernam like ekko-ernam,
v_rel_code LIKE rm06b-frgab,
v_pos like t16fw-objid,
v_pernr like adr6-PERSnumbeR,
v_adrnr like adr6-addrnumber,
v_usrid like pa0105-usrid,
v_bsart type bbsrt, " PR Type
v_batxt type batxt, " PR Type Description
v_mail like adr6-smtp_addr,
v_sendor type syuname,
v_receiver type string,
v_header type string,
v_body type string.
swc_get_element container 'reqno' v_ebeln.
swc_get_element container 'ReleaseCode' v_rel_code.
clear: v_pos, v_pernr, v_usrid, v_adrnr, v_mail,v_bsart, v_batxt,
v_sendor, v_receiver, v_header, v_body , v_ernam.
select single bsart ernam into (v_bsart, v_ernam)
from eban where banfn = v_ebeln.
select single batxt from t161t into v_batxt
where spras = sy-langu and
bsart = v_bsart and
bstyp = 'B'.
select single objid from t16fw into v_pos
where frgco = v_rel_code
and otype = 'S'.
if sy-subrc eq 0.
select single pernr into v_pernr from pa0001
where endda eq '99991231' and
plans eq v_pos.
if sy-subrc = 0.
select single usrid into v_usrid from pa0105
where endda eq '99991231' and
subty eq '0001' and
pernr eq v_pernr.
endif.
endif.
if sy-subrc = 0.
select single persnumber addrnumber from usr21
into (v_pernr,v_adrnr)
where bname = v_ernam.
if sy-subrc = 0.
select single smtp_addr into v_mail from adr6
where addrnumber = v_adrnr and
persnumber = v_pernr.
if sy-subrc <> 0.
concatenate v_ernam '@sipchem.com' into v_mail.
v_receiver = v_mail.
else.
v_receiver = v_mail.
endif.
v_sendor = v_usrid.
v_header = 'Purchase Requisition Rejection'.
v_str = 'Pls check your SAP Inbox'.
v_str1 = 'Purchase Requestion #'.
v_str3 = 'of type'.
v_str2 = 'has been rejected.'.
concatenate v_str1 v_ebeln v_str3 v_batxt v_str2 v_str
into v_body separated by space.
Call Function Module To send mail
CALL FUNCTION 'UWSP_SEND_MAIL_TO_WEB'
EXPORTING
id_header = v_header
id_body = v_body
id_receiver = v_receiver
ID_SENDER = v_ernam
ID_HTML_MAIL =
ID_COMMIT_WORK = 'X'
EXCEPTIONS
ERROR = 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.
endif.
*endif.
*endif.
END_METHOD.
***********************************************************************
BEGIN_METHOD SENDMAILCOMPLETE CHANGING CONTAINER.
data : v_ebeln like ekko-ebeln,
v_str(24), v_str1(21), v_str2(18), v_str3(7),
v_ernam like ekko-ernam,
v_rel_code LIKE rm06b-frgab,
v_pos like t16fw-objid,
v_pernr like adr6-PERSnumbeR,
v_adrnr like adr6-addrnumber,
v_usrid like pa0105-usrid,
v_bsart type bbsrt, " PR Type
v_batxt type batxt, " PR Type Description
v_mail like adr6-smtp_addr,
v_sendor type syuname,
v_receiver type string,
v_header type string,
v_body type string.
swc_get_element container 'reqno' v_ebeln.
swc_get_element container 'ReleaseCode' v_rel_code.
clear: v_pos, v_pernr, v_usrid, v_adrnr, v_mail,v_bsart, v_batxt,
v_sendor, v_receiver, v_header, v_body , v_ernam.
select single bsart ernam into (v_bsart, v_ernam)
from eban where banfn = v_ebeln.
select single batxt from t161t into v_batxt
where spras = sy-langu and
bsart = v_bsart and
bstyp = 'B'.
select single objid from t16fw into v_pos
where frgco = v_rel_code
and otype = 'S'.
if sy-subrc eq 0.
select single pernr into v_pernr from pa0001
where endda eq '99991231' and
plans eq v_pos.
if sy-subrc = 0.
select single usrid into v_usrid from pa0105
where endda eq '99991231' and
subty eq '0001' and
pernr eq v_pernr.
endif.
endif.
if sy-subrc = 0.
select single persnumber addrnumber from usr21
into (v_pernr,v_adrnr)
where bname = v_ernam.
if sy-subrc = 0.
select single smtp_addr into v_mail from adr6
where addrnumber = v_adrnr and
persnumber = v_pernr.
if sy-subrc <> 0.
concatenate v_ernam '@sipchem.com' into v_mail.
v_receiver = v_mail.
else.
v_receiver = v_mail.
endif.
v_sendor = v_usrid.
v_header = 'Purchase Requisition Released'.
v_str = 'Pls check your SAP Inbox'.
v_str1 = 'Purchase Requestion #'.
v_str3 = 'of type'.
v_str2 = 'has been released.'.
concatenate v_str1 v_ebeln v_str3 v_batxt v_str2 v_str
into v_body separated by space.
Call Function Module To send mail
CALL FUNCTION 'UWSP_SEND_MAIL_TO_WEB'
EXPORTING
id_header = v_header
id_body = v_body
id_receiver = v_receiver
ID_SENDER = v_ernam
ID_HTML_MAIL =
ID_COMMIT_WORK = 'X'
EXCEPTIONS
ERROR = 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.
endif.
END_METHOD.
Reward points if useful
Regards
Anji
2007 Dec 23 6:16 AM
hi
can u pls tell me how to use bapi_requisition_delete for deleting open purchase requisitions.can u pls give me a sample code or steps for same. my mail id is sandeshk10@yahoo.co.in
thanks
sandesh