Skip to Content
Technical Articles
Author's profile photo Stefan Schnell

How To Read Data From a PDF Formular and Use it Inside ABAP

I presented here the possibility to use Quick PDF Library from Debenu easily. Here now another use case: Very often we use forms in our business work flows. You fill out a form and send it via e-mail to next person in the process chain. This person inspects the content and transfers the data from the form in the EDP system – very often manually. But it is very easy possible to read the data from a PDF form automatically and use it in your ABAP context.

Here an example how to read data from a PDF form to create a new user via the function module BAPI_USER_CREATE1:

  1. Create a form with a text editor, in my case I use Writer from OpenOffice./wp-content/uploads/2015/07/001_749803.jpg
  2. Save the form as PDF file./wp-content/uploads/2015/07/002_749846.jpg

     

  3. Fill out the form in the Acrobat Reader and save the PDF file./wp-content/uploads/2015/07/0021_749848.jpg

     

  4. Now you can use the data from the form inside your ABAP code, e.g. like this./wp-content/uploads/2015/07/003_749850.jpg

     

  5. On this way it is very easy to create new users in your central user management system to distribute them on the target system. You have the PDF form as verification and it is not necessary to do something manually./wp-content/uploads/2015/07/004_749851.jpg

Here the code:

"-Begin-----------------------------------------------------------------
  Program zBAPI_USER_CREATE1_ReadForm.

    "-Variables---------------------------------------------------------
      Data PDF Type Ref To zDebenuPDFLibraryAX1115.
      Data rc Type Integer.
      Data UserName Type String.
      Data Password Type String.
      Data FirstName Type String.
      Data LastName Type String.
      Data FullName Type String.
      Data LogonData Type BAPILOGOND.
      Data Address Type BAPIADDR3.
      Data BAPIUserName Type BAPIBNAME-BAPIBNAME.
      Data BAPIPassword Type BAPIPWD.

    "-Main--------------------------------------------------------------
      Create Object PDF.
      If PDF->LoadLib( ) = 1.

        PDF->LoadFromFile( Exporting Password = ''
          FileName = 'BAPI_USER_CREATE1_Fill.pdf'
          Importing Result = rc ).
        If rc = 1.

          PDF->GetFormFieldValueByTitle( Exporting Title = 'username'
            Importing Result = UserName ).
          PDF->GetFormFieldValueByTitle( Exporting Title = 'password'
            Importing Result = Password ).
          PDF->GetFormFieldValueByTitle( Exporting Title = 'firstname'
            Importing Result = FirstName ).
          PDF->GetFormFieldValueByTitle( Exporting Title = 'lastname'
            Importing Result = LastName ).
          PDF->GetFormFieldValueByTitle( Exporting Title = 'fullname'
            Importing Result = FullName ).

          BAPIUserName = UserName.
          BAPIPassword-BAPIPWD = Password.
          Address-FirstName = FirstName.
          Address-LastName = LastName.
          Address-FullName = FullName.

          Call Function 'BAPI_USER_CREATE1'
            Exporting
              USERNAME = BAPIUserName
              LOGONDATA = LogonData
              PASSWORD = BAPIPassword
              ADDRESS = Address.

        EndIf.

        PDF->FreeLib( ).
      EndIf.

"-End-------------------------------------------------------------------

This is an simple example but it shows exemplary the possibilities.

Assigned Tags

      3 Comments
      You must be Logged on to comment or reply to a post.
      Author's profile photo Kashinath Goud G
      Kashinath Goud G

      Hi Stefan.

      Data PDF Type Ref To zDebenuPDFLibraryAX1115

       

      Can i know what is the below class u have mentioned.

      zDebenuPDFLibraryAX1115.
      Author's profile photo Stefan Schnell
      Stefan Schnell

      Kashinath Goud G

      Hello Kashinath,

      you can find the source of class here:

      http://www.stschnell.de/temp/DebenuPDFLibraryAX1115.Class.zip

      Best regards
      Stefan

      Author's profile photo Kiran kumar Chelikani
      Kiran kumar Chelikani

      HI Stefan,

       

      The source of class link is not working.

      Can you please help with the details.

       

      Regrds,

      Kiran.