Quantcast
Channel: SCN : Blog List - ABAP Development
Viewing all articles
Browse latest Browse all 943

How to call Invoice as a PDF in SAPGUI

$
0
0

Let’s consider that we have two screens with screen numbers 2000 and 3000.


Screen 2000 contains table control which displays the list of invoices and if we double click on any invoice number that particular invoice should get displayed in Screen 3000 in PDF format.


Here calling the Invoice in PDF means calling the standard Invoice Smartform which is LB_BIL_INVOICE. Below is the function module which is used to transfer the data from driver program (RLB_INVOICE) to smartform.


1.jpg

For the above function module we need to pass the values to mandatory import parameters IS_BIL_INVOICE, IS_NAST and IS_REPEAT so that we will get JOB_OUTPUT_INFO as an export parameter which is required to generate PDF file.


Passing values to IS_BIL_INVOICE


IS_BIL_INVOICE is of type LBBIL_INVOICE which is a deep structure and this need structure needs to filled with valid data in order to display the invoice details on the Smartform layout.



2.jpg

When we execute Tcode VF03 to display invoice details an entry will be created in NAST table when an output type is triggered and we have a field OBJECT KEY (OBJKY) in that entry, which is VBELN for V3 application. Based on the entries in NAST table the data will get populated into the structure IS_BIL_INVOICE. By using the below function module we can create the entries into this deep structure.


3.jpg

Here in the above function module the import parameter IF_BIL_NUMBER refers to NAST-OBJKY, IF_PARVW refers to NAST-PARVW, IF_PARNR refers to NAST-PARNR and IF_LANGUAGE refers to NAST-SPRAS.


Based on the object key (VBELN ) fetch the record from NAST table and pass those respective fields to import parameters of the above function  module.

5.jpg

The import parameter IS_PRINT_DATA_TO_READ is the structure to Select Tables to be Complete for Printing SmartForms.


After getting the IS_BIL_INVOICE as an export parameter. Pass this structure to smartform function module to get OTFDATA (JOB_OUTPUT_INFO-OTFDATA).

6.jpg

Now we have OTF Date, the next step is to convert this OTF into PDF by using the below function module.

7.jpg

The next step is to convert pdf to xstring and further convert this Xstring to binary data so that SAPGUI can use this binary data to display the invoice in PDF format. Please go through the below code for clear understanding.


8.jpg

Select the ‘Respond to double click’ checkbox in table control in screen painter of screen 2000 and assign a function code say ‘PICK’. In the PAI event of Screen 2000 write the below code.


9.jpg

10.jpg


11.jpg


12.jpg

Write the below code in the PBO of screen 3000.


14.jpg

17.jpg

Write below code in the PAI of screen 3000.

18.jpg

REFERALS:

 


This link is very useful for clear understanding on how to read OTF data in Adobe Reader (PDF format ). I have even used some of the content from this link to put all the data together.

 

               This link contains everything about PDF files in SAP.

 

  • Refer to standard driver program RLB_INVOICE .



*******************************************************************************************************************

Your feedback is highly appreciated, Thank you,

                                                                                                                                                                                                                  Untitled-1.jpg

*****************************************************************************************************************************************************************************************





Viewing all articles
Browse latest Browse all 943

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>