SAP for Utilities Discussions
Connect with fellow SAP users to share best practices, troubleshoot challenges, and collaborate on building a sustainable energy future. Join the discussion.
cancel
Showing results for 
Search instead for 
Did you mean: 

Generating Invoice in PDF format

Former Member
0 Kudos

As part if the SAP MCF implementation, the requirement is to generate invoice in PDF format, I couldn't understand what needs to be done from the below help guide.

Can anyone please help me understand on what needs to be done.

Thanks.

You can use the Biller Direct API GEN_EBPP_GET_INVOICE_DETAIL in the SAP ERP system to retrieve an invoice PDF. This API performs generic retrievals of invoice PDFs for various industries and components.

In this API, BAdI FIS_INVOICEDETAIL is used. This BAdI has several SAP-delivered implementations. One of them is specifically for IS-U: ISU_INVOICEDETAIL.

This implementation searches the archive for invoices and tries to retrieve invoice PDFs using ISU_GET_INVOICES_PDF_RAW. If this implementation doesn’t satisfy the business requirements, a new BAdI implementation can be created. For testing purposes, when there is no archive for invoices, you can create a BAdI implementation where the ISU_GET_PDF_FILE API can be used to retrieve a simulated PDF document. This can only be used for testing since PDF simulation is time-consuming and shouldn’t be used in a production environment

1 REPLY 1

yevgen_trukhin
Contributor
0 Kudos

Hi Aravind, by default InvoicePDF OData entity tries to get you an invoice from an archive. The API that will try to get it will be ISU_GET_INVOICES_PDF_RAW. This is a preferred way.  Or you can do your own custom implementation and get the PDF from anywhere else. Some customers have their own API or use 3rd party to retrieve the PDF.

For testing purposes you could also generate the PDF on the fly but it time consuming to perform this in runtime. To do this you would need to create your own implementation of Badi  FIS_INVOICEDETAIL and you use API ISU_GET_PDF_FILE.

Sample code for GET_INVOICE_DETAIL method of the badi which will simultate/generate for you the PDF (use at your own risk, i use it for TESTING😞


DATA lv_empty TYPE string.
DATA lv_invoice_id TYPE opbel_kk.
DATA:
        l_pdf         TYPE xstring,
        lt_pdf_sim    TYPE w3mimetabtype,
        l_pdf_sim     LIKE LINE OF lt_pdf_sim,
        lt_pdf_arc    TYPE ebc_t_raw_data,
        l_pdf_arc     LIKE LINE OF lt_pdf_arc.

DATA: lt_pdf TYPE fis_inv_docdetail_raw_t,
         ls_pdf TYPE tbl1024.

* First try to retrieve simulated PDF bill
IF i_billing_doc CN 'ISU'.

SPLIT i_billing_doc AT 'ISU' INTO lv_empty lv_invoice_id.

CALL FUNCTION 'ISU_GET_PDF_FILE'
EXPORTING
         x_opbel           = lv_invoice_id
         x_no_dialog       = 'X'
IMPORTING
         y_pdf_file_sim    = lt_pdf_sim
         y_pdf_file_archiv = lt_pdf_arc
EXCEPTIONS
         not_found         = 1
         general_fault     = 2
OTHERS            = 3.
IF sy-subrc = 0.
IF lt_pdf_sim[] IS NOT INITIAL.
*   converting lines of pdf table into one string
LOOP AT lt_pdf_sim INTO l_pdf_sim.
CONCATENATE l_pdf l_pdf_sim-line INTO l_pdf IN BYTE MODE.
ENDLOOP.

CALL FUNCTION 'SCMS_XSTRING_TO_BINARY'
EXPORTING
buffer     = l_pdf
TABLES
             binary_tab = t_pdf.
ENDIF.
IF lt_pdf_arc[] IS NOT INITIAL.
*   converting lines of pdf table into one string
LOOP AT lt_pdf_arc INTO l_pdf_arc.
CONCATENATE l_pdf l_pdf_arc-line INTO l_pdf IN BYTE MODE.
ENDLOOP.

CALL FUNCTION 'SCMS_XSTRING_TO_BINARY'
EXPORTING
buffer     = l_pdf
TABLES
             binary_tab = t_pdf.
ENDIF.
ENDIF.

"t_pdf = lt_pdf.

ENDIF.

I hope this helps

Yevgen