Attatching PDF File in background step

Sample, Rick Rick.Sample at graybar.com
Fri Jan 23 12:42:43 EST 2009


I have a need to get a Trip PDF and attach it to a Task in a background
step. 
I get the PDF just fine. I attach to a task in FORE GROUND just fine and
dandy. 
 
Now, where I am stumped. How to attach in a background step. 
I obviously can not use GUI controls to achieve this, so anyone have an
idea or three, or an example to reference? 
 
Thanks much! 
 
Rick Sample | Office (314) 573-5700 | rick.sample at graybar.com 
www.graybar.com <http://www.graybar.com/>  - Graybar Works to Your
Advantage 
 
 
CALL FUNCTION 'PTRM_WEB_FORM_PDF_GET'
  EXPORTING
    i_employeenumber   = object-key-employeenumber
    i_tripnumber       = object-key-tripnumber
*    i_periodnumber     = '000'
*    i_trip_component   = ' '
*    i_trip_data_source = 'DB'
    i_display_form     = ' '
    i_language         = sy-langu
  IMPORTING
    e_pdf_form         = lwa_pdf_form
  TABLES
    et_return          = et_return.
 
LOG-POINT ID ztravel FIELDS et_return.
LOG-POINT ID ztravel FIELDS log_crap '4_gotPDF_return_code?'.
 
** container
*IF g_pdf_my_container IS INITIAL.
*  CREATE OBJECT g_pdf_my_container
*    EXPORTING
*      container_name = 'HTML_FORM'
*    EXCEPTIONS
*      OTHERS         = 1.
*  IF sy-subrc <> 0.
*  ENDIF.
*ENDIF.
*
** html control
*IF g_pdf_html_control IS INITIAL.
*  CREATE OBJECT g_pdf_html_control
*    EXPORTING
*      parent = g_pdf_my_container
*    EXCEPTIONS
*      OTHERS = 1.
*  IF sy-subrc <> 0.
*  ENDIF.
*ENDIF.
*
*alignment = align_at_left + align_at_right +
*            align_at_top + align_at_bottom.
*
*CALL METHOD g_pdf_html_control->set_alignment
*  EXPORTING
*    alignment = alignment
*  EXCEPTIONS
*    OTHERS    = 1.
*IF sy-subrc <> 0.
*ENDIF.
*
*l_pdf_size = XSTRLEN( lwa_pdf_form ).
*l_len = l_pdf_size.
*WHILE l_len >= 1000.
*  l_pdf_line = lwa_pdf_form+l_offset(1000).
*  APPEND l_pdf_line TO l_pdf_data.
*  ADD 1000 TO l_offset.
*  SUBTRACT 1000 FROM l_len.
*ENDWHILE.
*IF l_len > 0.
*  l_pdf_line = lwa_pdf_form+l_offset(l_len).
*  APPEND l_pdf_line TO l_pdf_data.
*ENDIF.
*
*l_myurl = 'PDF.pdf'.
*CALL METHOD g_pdf_html_control->load_data
*  EXPORTING
*    url          = l_myurl
*    size         = l_pdf_size
*    type         = 'application'
*    subtype      = 'pdf'
*  IMPORTING
*    assigned_url = l_url
*  CHANGING
*    data_table   = l_pdf_data
*  EXCEPTIONS
*    OTHERS       = 1.
*IF sy-subrc <> 0.
*ENDIF.
 
** show data
*CALL METHOD g_pdf_html_control->show_data
*  EXPORTING
*    url    = l_url
*  EXCEPTIONS
*    OTHERS = 1.
*IF sy-subrc <> 0.
*ENDIF.
 
*BREAK-POINT ID ztravel.
swc_get_element container 'zTaskID'  ztaskid.
LOG-POINT ID ztravel FIELDS ztaskid.
LOG-POINT ID ztravel FIELDS log_crap '4_got_ztaskid?'.
workitem_id = ztaskid.
 
att_header-file_type = 'B'.
att_header-file_name = 'PDF'.
att_header-file_extension = 'PDF'.
att_bin = lwa_pdf_form.
 
BREAK-POINT ID ztravel.
CALL FUNCTION 'SAP_WAPI_ATTACHMENT_ADD'
  EXPORTING
    workitem_id    = workitem_id
    att_header     = att_header
    att_bin        = att_bin
    document_owner = sy-uname
    language       = sy-langu
    do_commit      = 'X'
  IMPORTING
    return_code    = return_code
    att_id         = att_id
  TABLES
    message_lines  = message_lines
    message_struct = message_struct.
 
LOG-POINT ID ztravel FIELDS return_code.
LOG-POINT ID ztravel FIELDS log_crap '4_attach_return_code?'.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mailman.mit.edu/pipermail/sap-wug/attachments/20090123/f8ba7353/attachment.htm


More information about the SAP-WUG mailing list