Posted: Mon Sep 10, 2007 8:20 pm Post subject: Mailing in SAP
Z_IDOC_INPUT_ALEAUD Code
Code:
FUNCTION Z_IDOC_INPUT_ALEAUD.
*"----------------------------------------------------------------------
*"*"Local interface:
*" IMPORTING
*" VALUE(INPUT_METHOD) LIKE BDWFAP_PAR-INPUTMETHD
*" VALUE(MASS_PROCESSING) LIKE BDWFAP_PAR-MASS_PROC
*" EXPORTING
*" VALUE(WORKFLOW_RESULT) LIKE BDWF_PARAM-RESULT
*" VALUE(APPLICATION_VARIABLE) LIKE BDWF_PARAM-APPL_VAR
*" VALUE(IN_UPDATE_TASK) LIKE BDWFAP_PAR-UPDATETASK
*" VALUE(CALL_TRANSACTION_DONE) LIKE BDWFAP_PAR-CALLTRANS
*" TABLES
*" IDOC_CONTRL STRUCTURE EDIDC
*" IDOC_DATA STRUCTURE EDIDD
*" IDOC_STATUS STRUCTURE BDIDOCSTAT
*" RETURN_VARIABLES STRUCTURE BDWFRETVAR
*" SERIALIZATION_INFO STRUCTURE BDI_SER
*" EXCEPTIONS
*" WRONG_FUNCTION_CALLED
*"----------------------------------------------------------------------
DATA: T_IDOC_CONTROL LIKE EDIDC OCCURS 0 WITH HEADER LINE,
T_IDOC_DATA LIKE EDIDD OCCURS 0 WITH HEADER LINE,
T_ALE_ERR LIKE ALE_ERR_MESSAGE OCCURS 0 WITH HEADER LINE,
X_OBJCONT LIKE SOLI OCCURS 0 WITH HEADER LINE,
X_OBJHEAD LIKE SOLI OCCURS 0 WITH HEADER LINE,
RAW_HEAD LIKE SORH OCCURS 0 WITH HEADER LINE,
X_RECEIVERS LIKE SOOS1 OCCURS 0 WITH HEADER LINE.
DATA: W_E1ADHDR LIKE E1ADHDR,
W_E1STATE LIKE E1STATE,
W_E1PRTOB LIKE E1PRTOB,
X_OBJECT_HD_CHANGE LIKE SOOD1,
RECEIVING_SYSTEM LIKE EDIDC-SNDPRN,
SENDING_SYSTEM LIKE EDIDC-RCVPRN,
H_TEXT LIKE SOOD1-OBJDES,
FOLDER_NAME LIKE SOS06-S_FOLNAM,
SUBRC LIKE SY-SUBRC,
GLOBAL_SUBRC LIKE SY-SUBRC,
X_OBJECT_TYPE LIKE SOOD-OBJTP.
*-------------------------------------------------------------------
***INCLUDE LZALAF01 .
*-------------------------------------------------------------------
*&---------------------------------------------------------------------*
*& Form SEND_SAP_MAIL
*&---------------------------------------------------------------------*
FORM SEND_SAP_MAIL
TABLES T_ALE_ERR STRUCTURE ALE_ERR_MESSAGE
USING RECEIVING_SYSTEM LIKE EDIDC-SNDPRN
SENDING_SYSTEM LIKE EDIDC-RCVPRN
ZTAUD STRUCTURE ZTAUD
SUBRC LIKE SY-SUBRC.
DATA: T_ALE_ERR_WA LIKE ALE_ERR_MESSAGE OCCURS 0 WITH HEADER LINE,
X_OBJCONT LIKE SOLI OCCURS 0 WITH HEADER LINE,
* x_objhead like soli occurs 0 with header line,
X_RECEIVERS LIKE SOOS1 OCCURS 0 WITH HEADER LINE.
DATA:
X_OBJECT_HD_CHANGE LIKE SOOD1,
H_TEXT LIKE SOLI-LINE,
H_STATUS LIKE EDIDC-STATUS,
X_OBJECT_TYPE LIKE SOOD-OBJTP.
MOVE 'RAW' TO X_OBJECT_TYPE.
H_TEXT = TEXT-002.
REPLACE '&' WITH ZTAUD-MESTYP INTO H_TEXT.
REPLACE '&' WITH RECEIVING_SYSTEM INTO H_TEXT.
CONDENSE H_TEXT.
MOVE: SY-LANGU TO X_OBJECT_HD_CHANGE-OBJLA,
TEXT-001 TO X_OBJECT_HD_CHANGE-OBJSRT,
TEXT-001 TO X_OBJECT_HD_CHANGE-OBJNAM,
H_TEXT TO X_OBJECT_HD_CHANGE-OBJDES,
'F' TO X_OBJECT_HD_CHANGE-OBJSNS. " Functional
LOOP AT T_ALE_ERR.
IF H_STATUS <> T_ALE_ERR-STATUS.
IF H_STATUS <> SPACE.
PERFORM ERROR_REPORT
TABLES X_OBJCONT
T_ALE_ERR_WA
USING H_STATUS
RECEIVING_SYSTEM
SENDING_SYSTEM.
CLEAR T_ALE_ERR_WA.
REFRESH T_ALE_ERR_WA.
ENDIF.
H_STATUS = T_ALE_ERR-STATUS.
ENDIF.
T_ALE_ERR_WA = T_ALE_ERR.
APPEND T_ALE_ERR_WA.
ENDLOOP.
IF SY-SUBRC = 0.
PERFORM ERROR_REPORT
TABLES X_OBJCONT
T_ALE_ERR_WA
USING H_STATUS
RECEIVING_SYSTEM
SENDING_SYSTEM.
CLEAR T_ALE_ERR_WA.
REFRESH T_ALE_ERR_WA.
ENDIF.
CLEAR X_RECEIVERS.
REFRESH X_RECEIVERS.
MOVE ZTAUD-DLINAM TO X_RECEIVERS-RECNAM. " Distribution list
MOVE 'X' TO X_RECEIVERS-SNDEX.
MOVE 'C' TO X_RECEIVERS-RECESC.
APPEND X_RECEIVERS.
*&---------------------------------------------------------------------*
*& Form ERROR_REPORT
*&---------------------------------------------------------------------*
FORM ERROR_REPORT
TABLES X_OBJCONT STRUCTURE SOLI
T_ALE_ERR_WA STRUCTURE ALE_ERR_MESSAGE
USING H_STATUS LIKE EDIDC-STATUS
RECEIVING_SYSTEM LIKE EDIDC-SNDPRN
SENDING_SYSTEM LIKE EDIDC-RCVPRN.
DATA: H_TEXT LIKE SOLI-LINE,
H_LINES(5) TYPE C.
CLEAR X_OBJCONT.
APPEND X_OBJCONT.
CLEAR H_TEXT.
CASE H_STATUS.
WHEN '51'.
H_TEXT = TEXT-004.
WHEN '56'.
H_TEXT = TEXT-005.
WHEN '61'.
H_TEXT = TEXT-006.
WHEN '63'.
H_TEXT = TEXT-007.
WHEN '65'.
H_TEXT = TEXT-008.
WHEN '60'.
H_TEXT = TEXT-009.
WHEN OTHERS.
H_TEXT = H_STATUS.
H_TEXT = TEXT-010.
REPLACE '&' WITH H_LINES INTO H_TEXT.
X_OBJCONT = H_TEXT.
APPEND X_OBJCONT.
H_TEXT = TEXT-011.
REPLACE '&' WITH RECEIVING_SYSTEM INTO H_TEXT.
REPLACE '&' WITH SENDING_SYSTEM INTO H_TEXT.
X_OBJCONT = H_TEXT.
APPEND X_OBJCONT.
LOOP AT T_ALE_ERR_WA.
H_TEXT = TEXT-012.
REPLACE '&' WITH T_ALE_ERR_WA-DOCNUMRCV INTO H_TEXT.
REPLACE '&' WITH T_ALE_ERR_WA-DOCNUMSND INTO H_TEXT.
X_OBJCONT = H_TEXT.
APPEND X_OBJCONT.
ENDLOOP.
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum You cannot attach files in this forum You can download files in this forum
All product names are trademarks of their respective companies. SAPNET.RU websites are in no way affiliated with SAP AG. SAP, SAP R/3, R/3 software, mySAP, ABAP, BAPI, xApps, SAP NetWeaver and any other are registered trademarks of SAP AG. Every effort is made to ensure content integrity. Use information on this site at your own risk.