I also posted what the program requirements were for this project.
I called that program the heart of the system. What I am going to post today is a program that runs every so often that will trigger the program I posted last week to transmit a single fax or e-mail.
First a small review. The following picture is trying to show you what your report program will have to do.
The program is a pretty simple one.
Data Sectionreport zgeneric_email_send. data: global_time type sy-timlo, global_zemail_001 type table of zemail_001 with header line, bdcdata like bdcdata occurs 0 with header line, local_endtime type sy-timlo, global_date(8) type c.This was an attempt to keep the program from trying to send a transmission while the files were still being updated.
get time field global_time. local_endtime = global_time + 3599.Retrive the data to determine what data is going to be transmitted.
while global_time < local_endtime. select single * from zemail_001 into global_zemail_001 where sent_date = 0 and status = 'U' or sent_date = ' ' and status = 'U'. if sy-subrc = 0. update zemail_001 set status = 'L' where source_program = global_zemail_001-source_program and email_date = global_zemail_001-email_date and email_time = global_zemail_001-email_time and kunnr = global_zemail_001-kunnr. perform open_group. concatenate global_zemail_001-email_date+4(4) global_zemail_001-email_date+0(4) into global_date. perform bdc_dynpro using 'ZGENERIC_EMAIL' '1000'. perform bdc_field using 'BDC_CURSOR' 'S_TEST-LOW'. perform bdc_field using 'BDC_OKCODE' '=ONLI'. perform bdc_field using 'S_SOURCE-LOW' global_zemail_001-source_program. perform bdc_field using 'S_DATE-LOW' global_date. perform bdc_field using 'S_TIME-LOW' global_zemail_001-email_time. perform bdc_transaction using 'ZEMAIL_SEND'. call function 'BDC_CLOSE_GROUP'. call transaction 'ZEMAIL_SEND' using bdcdata mode 'E'. clear bdcdata. refresh bdcdata. else. wait up to 5 seconds. endif. get time field global_time. endwhile.This is to handle the call to the BDC process
form open_group. call function 'BDC_OPEN_GROUP' exporting client = sy-mandt group = 'EMAIL_TRAN' user = sy-uname keep = 'X'. endform. "open_group include zbdc_include.ZBDC_INCLUDE
form bdc_dynpro using program dynpro. clear bdcdata. bdcdata-program = program. bdcdata-dynpro = dynpro. bdcdata-dynbegin = 'X'. append bdcdata. endform. "BDC_DYNPRO *&---------------------------------------------------------------------* *& Form bdc_field *&---------------------------------------------------------------------* * text *----------------------------------------------------------------------* * -->FNAM text * -->FVAL text *----------------------------------------------------------------------* form bdc_field using fnam fval. clear bdcdata. bdcdata-fnam = fnam. bdcdata-fval = fval. append bdcdata. endform. " BDC_FIELD *&---------------------------------------------------------------------* *& Form bdc_transaction *&---------------------------------------------------------------------* * text *----------------------------------------------------------------------* * -->TCODE text *----------------------------------------------------------------------* form bdc_transaction using tcode. * batch input session call function 'BDC_INSERT' exporting tcode = tcode tables dynprotab = bdcdata. endform.Well that's it if you would like me to send you the program as a text file let me know and I will e-mail it to you. My next post will be the on demand program that allows you to resend a transmission.