Code: Alles auswählen.
form objhead_param_get_internal using objhead type soli_tab
changing param type c
value type c
tabix type sytabix.
data soli type soli.
data found type c.
data moff type i.
data l_param_search type soli-line.
data l_param_head type soli-line.
data l_tabix type sytabix.
clear: value, tabix.
find '=' in param match offset moff.
if moff > 0.
param = param(moff).
endif.
l_param_search = param.
translate l_param_search to upper case. "#EC SYNTCHAR
loop at objhead into soli.
l_tabix = sy-tabix.
clear moff.
find '=' in soli-line match offset moff.
check sy-subrc = 0.
l_param_head = soli(moff).
translate l_param_head to upper case. "#EC SYNTCHAR
if l_param_head = l_param_search.
add 1 to moff.
value = soli+moff.
tabix = l_tabix.
return.
endif.
endloop.
Code: Alles auswählen.
DATA: idate type d,
edate type d.
parameters d type marc-werks.
parameters e type c length 4.
TYPES: BEGIN OF t_mara,
MATNR LIKE mara-matnr,
MSTAV LIKE mara-mstav,
MSTDV LIKE mara-MSTDV,
END OF t_mara.
DATA it_mara type standard table of t_mara with header line.
* data for send function
DATA: DOC_DATA LIKE SODOCCHGI1,
OBJECT_ID LIKE SOODK,
mailtxt LIKE SOLI OCCURS 10 WITH HEADER LINE,
RECEIVER LIKE SOMLRECI1 OCCURS 1 WITH HEADER LINE,
t_html TYPE STANDARD TABLE OF w3html,
t_fields TYPE STANDARD TABLE OF w3fields WITH HEADER LINE,
t_header TYPE STANDARD TABLE OF w3head WITH HEADER LINE,
lt_mara TYPE lvc_t_fcat WITH HEADER LINE,
w_head TYPE w3head,
wa_header TYPE w3head.
idate = syst-datum.
CALL FUNCTION 'RP_CALC_DATE_IN_INTERVAL'
EXPORTING
DATE = idate
DAYS = 0
MONTHS = 9
SIGNUM = '+'
YEARS = 0
IMPORTING
CALC_DATE = edate.
SELECT MATNR MSTAV MSTDV FROM MARA INTO corresponding fields of table it_mara
WHERE MSTAV EQ '05'
AND MSTDV BETWEEN idate AND edate.
CHECK it_mara[] IS NOT INITIAL.
* Mail Text für Überschrift
wa_header-text = 'Folgende Materialen laufen demnächst aus' .
wa_header-font = 'Arial'.
wa_header-size = '2'.
* Tabelle Spalten Header
lt_mara-coltext = 'Materialnummer'.
APPEND lt_mara.
lt_mara-coltext = 'Mat. Status'.
APPEND lt_mara.
lt_mara-coltext = 'Auslaufdatum'.
REFRESH t_html.
LOOP AT lt_mara.
w_head-text = lt_mara-coltext.
*-Populate the Column Headings
CALL FUNCTION 'WWW_ITAB_TO_HTML_HEADERS'
EXPORTING
field_nr = sy-tabix
text = w_head-text
fgcolor = 'black'
bgcolor = 'gray'
TABLES
header = t_header.
*-Populate Column Properties
CALL FUNCTION 'WWW_ITAB_TO_HTML_LAYOUT'
EXPORTING
field_nr = sy-tabix
fgcolor = 'black'
size = '3'
TABLES
fields = t_fields.
ENDLOOP.
CALL FUNCTION 'WWW_ITAB_TO_HTML' "Convert Internal Table to HTML Table
EXPORTING
table_header = wa_header
TABLES
html = t_html
fields = t_fields
row_header = t_header
itable = it_mara.
* insert receiver (sap name)
REFRESH RECEIVER.
CLEAR RECEIVER.
MOVE: e TO RECEIVER-RECEIVER,
'X' TO RECEIVER-EXPRESS,
'C' TO RECEIVER-REC_TYPE.
APPEND RECEIVER.
* insert mail description
WRITE 'End of Production Material Report'
TO DOC_DATA-OBJ_DESCR.
CALL FUNCTION 'SO_NEW_DOCUMENT_SEND_API1'
EXPORTING
DOCUMENT_DATA = DOC_DATA
document_type = 'HTM'
IMPORTING
NEW_OBJECT_ID = OBJECT_ID
TABLES
OBJECT_Header = t_html
OBJECT_CONTENT = t_html
RECEIVERS = RECEIVER
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.
IF sy-subrc EQ 0.
commit work.
ENDIF.