Wednesday 29 April 2020

SAP ABAP, SAP PO and Microsoft Azure Logic App mashup – SharePoint Integration

Overview:-


Many of us have already integrated SAP with SharePoint using SAP Process Integration with REST api. In this blog post i will be explaining how we can use Microsoft Azure Logic App to drop PDF into SharePoint. With Logic App development efforts in SAP PO is reduced.

Implementation:-


In the ECC when a smartform is created a Function Module is generated.

SAP Process Orchestration,  ABAP Development, SAP Process Integration

Later smartform FM is called in the actual program to generate OTF, and then with the OTF, PDF is created.

below program returns OTF and then generate PDF.

gs_control_param-getotf      = 'X'. "When get OTF is set to "X" then FM will return OTF 

CALL FUNCTION gv_fm_name "Name of the FM generated by smartforms 
          EXPORTING
            control_parameters = gs_control_param
            mail_recipient     = lv_recipient
            mail_sender        = lv_sender
            output_options     = gs_composer_param
            user_settings      = ' '
            is_nast            = nast
          IMPORTING
            job_output_info    = gs_job_output
          EXCEPTIONS
            formatting_error   = 1
            internal_error     = 2
            send_error         = 3
            user_canceled      = 4
            OTHERS             = 5.
        IF sy-subrc EQ 0.
          DATA:gv_pdf_xstring       TYPE xstring,
               gt_job_output_info   TYPE STANDARD TABLE OF itcoo,
               lv_base64str         TYPE string.
                 
          gt_job_output_info[] = gs_job_output-otfdata[].

         CALL FUNCTION 'CONVERT_OTF'
              EXPORTING
                format                = 'PDF'
              IMPORTING
                bin_file              = gv_pdf_xstring
              TABLES
                otf                   = gt_job_output_info
                lines                 = gt_pdf_tab[]
              EXCEPTIONS
                err_max_linewidth     = 1
                err_format            = 2
                err_conv_not_possible = 3
                err_bad_otf           = 4
                OTHERS                = 5.
         IF sy-subrc EQ 0.

         cl_http_utility=>if_http_utility~encode_x_base64( EXPORTING unencoded = gv_pdf_xstring RECEIVING encoded = lv_base64str ).

        ELSE.

With the FM “CONVERT_OTF”  OTF is converted to PFD and then PDF is encoded into base64 string using SAP standard method cl_http_utility=>if_http_utility~encode_x_base64.

DATA: ls_output              TYPE zws_mt_doc_to_spo_rqst, 
      ls_input               TYPE zws_mt_doc_to_spo_resp.

ls_output-mt_doc_to_spo_rqst-folder_path        = 'test/test/'.
ls_output-mt_doc_to_spo_rqst-file_name          = 'test.pdf'.
ls_output-mt_doc_to_spo_rqst-file_content_b64str  = lv_base64str.

  TRY.
       DATA(lo_doctospo) = NEW ZWS_CO_SI_DOC_TO_SPO_SYNC( ).
       lo_doctospo->si_doc_to_spo_sync_out( EXPORTING output = ls_output IMPORTING input = ls_input ).
    CATCH cx_ai_system_fault INTO DATA(lo_exception).
  ENDTRY.

The generated base64 string is assigned to a proxy structure (generated in SPROXY) and sent to SAP PO using SOAP sender(proxy) adapter.

SAP PO Configuration:-


In SAP PO ESR just 1 to 1 mapping is needed so i have created Data Type, Message Type and Service Interface.

Request Message Type

SAP Process Orchestration,  ABAP Development, SAP Process Integration

Response Message Type.

SAP Process Orchestration,  ABAP Development, SAP Process Integration

Service Interface

SAP Process Orchestration,  ABAP Development, SAP Process Integration

There are multiple ways of sending PDF to SAP PO but i prefer converting PDF into base64 format in ECC itself using standard method in ABAP.

Other methods are as below.

1. Send PDF as an attachment from ECC along with the payload and then convert attachment into base64 string using UDF in graphical mapping or Java mapping.

2. using ABAP program generate PDF and save in Application server(AL11) then with FILE adapter in SAP PO pick the PDF(binary file) and convert PDF into base64 string using JAVA Mapping

If I opt above 2 approaches then i need to write a piece of code in SAP PO as well so i thought of performing all the conversion in ABAP itself(why to write java code in SAP PO if ABAP has already got standard class/method to encode/decode Base64 format )

In the Integration Directory we have used SOAP and REST adapter and configured like below.

SOAP sender adapter.

SAP Process Orchestration,  ABAP Development, SAP Process Integration

REST Receiver Adapter.

SAP Process Orchestration,  ABAP Development, SAP Process Integration

It is a HTTP POST operation.

SAP Process Orchestration,  ABAP Development, SAP Process Integration

Microsoft Azure Logic App Configuration:-


In the Microsoft Azure Portal under resource group create a new Logic App.

Logic App can be found under Integration –> Logic App(Microsoft has already provided document, tutorials and templates so that we can learn/understand and develop our logic App )

SAP Process Orchestration,  ABAP Development, SAP Process Integration

Once Logic App is created select Trigger “When HTTP request is received” and under use sample payload to generate JSON Schema paste the JSON structure we developed in SAP PO Data Type(it will be in XML, convert it to JSON and paste here) and it will automatically generate JSON schema .

The REST receiver adapter in SAP PO will convert XML to JSON and send request to below Logic App to perform actions and drop files in SharePoint.

SAP Process Orchestration,  ABAP Development, SAP Process Integration

Now click over + button and select Add an action

SAP Process Orchestration,  ABAP Development, SAP Process Integration

A menu will appear, type SharePoint in the search box and select SharePoint Create File Action from the result.

SAP Process Orchestration,  ABAP Development, SAP Process Integration

There are many other SharePoint actions available in the Logic App, i have selected Create File because i want to drop(create) a file in SharePoint. likewise we can use other actions if we need to do other operations.

Now when the create file appears, enter login details which has got access to SharePoint site where we will be dropping our PDF.

SAP Process Orchestration,  ABAP Development, SAP Process Integration

SAP Process Orchestration,  ABAP Development, SAP Process Integration

◉ A new window will appear, when we simply click over field we can select dynamic content(whatever is there in JSON schema will appear)

◉ Whichever site the user has access will appear in the drop-down

◉ within site select the folder path where we will be dropping our file(we are sending path from SAP so path is being accessed dynamically here)

◉ enter the file name(we are sending filename from SAP so name is being accessed dynamically here)

◉ Since we are sending our PDF as base64 string, we will be converting it to binary here by writing expression base64ToBinary(triggerBody()?[‘FileContentB64Str’]) FileContentB64Str has been selected from Dynamic content

SAP Process Orchestration,  ABAP Development, SAP Process Integration

◉ base64ToBinary is present under Conversion functions under expression

Finally we will be creating last action that is Response(Send back response to SAP PO& ECC)

SAP Process Orchestration,  ABAP Development, SAP Process Integration

Once done our Logic App workflow will look like this.

SAP Process Orchestration,  ABAP Development, SAP Process Integration

Testing:-


When the program is executed proxy program is invoked and data is sent to SAP PO which can be seen in SAP PO message monitor.

SAP Process Orchestration,  ABAP Development, SAP Process Integration

Logs can also be viewed in Azure Logic App monitor.

SAP Process Orchestration,  ABAP Development, SAP Process Integration

SAP Process Orchestration,  ABAP Development, SAP Process Integration

Finally PDF can be seen in SharePoint.

SAP Process Orchestration,  ABAP Development, SAP Process Integration

Scenario In a Nutshell:-


1. Return OTF from smartform Function Module, convert it to PDF, encode PDF into Base64 format and finally send out of SAP with SAP PO proxy configuration.

2. Configure SAP REST Receiver Adapter to call Logic App.

3. Logic App SharePoint create file action will connect to the SharePoint site and with base64toBinary operation decode Base64 string into binary file.

Monday 27 April 2020

CDS based data extraction – Part III Miscellaneous

Back to the CDS view extraction..

After the Overview in part I and Delta deep dive in part II, I would like to spend the final blog on some miscellaneous points regarding CDS view based extraction.

Hierarchy extraction


The topic of hierarchy extraction deserves a small section, as some things have changed here in contrast to the classical extractors. You will need to make some changes to your hierachy bearing characteristics in order to work with the hierarchy CDS views. This is due to the fact that the node texts are not delivered by the actual hiercharchy CDS view, but a separate one.

Friday 24 April 2020

ABAP CDS VIEWS simplified – PART 2

INTRODUCTION:


ABAP Core Data Service Views also known as ABAP CDS Views. There are so many limitations in SE11 views but we can come out of all the limitations and create a powerful views with the help of ABAP CDS Views.

In general SE11 views and ABAP CDS Views both will create a database views at the backend. When we try to access these views as a table in the ABAP code, this code will be executed at the database level.

Wednesday 22 April 2020

Implementing Clearing Interface using POSTING_INTERFACE_CLEARING in s4 Hana 1709.

SAP has provided a clearing process using tcode FB05 which is not very user friendly in order to perform clearing a new module is created in SAP using provided interface for the convenience of users.

Create a screen using below interface:

Monday 20 April 2020

Semi-automatic custom code adaptation for SAP Cloud Platform ABAP Environment

If you intend to use SAP Cloud Platform ABAP Environment and want to bring your custom code application to the Cloud the time will come, when you will need to adapt your custom code for Cloud on your brand new ABAP system running in the SAP Cloud Platform ABAP Environment.

For this purpose, you will run the proven tool ABAP Test Cockpit with the SAP_CP_READINESS check variant in ABAP Development Tools in Eclipse on your ABAP system in the SAP Cloud Platform ABAP Environment and will get a worklist of ATC findings which you will need to fix.

Friday 17 April 2020

HCM Processes & Forms: A Concise Commentary on Comments

This time, I thought I would finally get around to covering one topic that has come up probably the most of all over the years with HCM Processes and Forms….how do we access the comments (aka. notes) that are put into the form?!?!?!? Well, there are multiple ways depending on what exactly you need to do, and I hope to cover those here. Sooo come along and let’s all get reacquainted!

Wednesday 15 April 2020

Implementing Unit Tests for an ABAP Report Program

In this blog, I will walk you through unit testing for an ABAP Report. Also, I will showcase an example where I have implemented Unit Testing for a simple report program.

Well, so, you have a report program in place and now there is a need to implement Unit Testing for the same. One thing is thus clear, that the CUT here is the report program for which unit tests are to be written. If you just got confused with the term ‘CUT’ I used here, I would recommend you take a glance through my first blogpost of this series I listed above. There is a glossary of all the terms used in the world of ABAP Unit Testing listed out, which would probably help.

Monday 13 April 2020

Constants management

In every system i work i usually have a table for constants management, some tables are designed for single values, some tables to accept ranges too, but generally each table i found for constants management have some limitations.

I’m actually using a solution that give me enough freedom to accomodate any kind of constant i need and i’ve been built a class to work with the table in a way i feel comfortable, i’m going to share some code to work with single values and SAP ranges, but the class is expandable and the table fields can hold anything you need, while reading i recommend you to see the code in the github repository at the end of the post, without full source code it may be hard to follow the explanation.

Friday 10 April 2020

Implementing DCL with CDS Views and Roles

I am going to write here about how to use the concept of DCL with CDS views and using roles to provide row based authorizations in UI.

So, DCL stands for Data Control Language. It provides an access control mechanism to restrict the results returned by the CDS view from the database according to conditions. With the help of roles (PFCG), we can also use the same DCL and restrict the results for different categories of users.

Let us look into the process, with the help of an example.

Wednesday 8 April 2020

Formatted excel using XML

In every business, it is necessary to convey data within or outside of SAP. When we think about exporting data from SAP to a non-SAP system, the very first option that comes in mind is excel. Because, it is a fast and easy way but the only drawback is, it gives plain text without color, alignment, and style. So in this blog post, you are going to learn, how to generate a formatted excel file.

Monday 6 April 2020

Understanding Polymorphism

In this blog-post i want to give you a deep understanding of polymorphism with interfaces.

The object-orientated memory allocation model


In context of object orientation the terms “class”, “object” and “instantiation” are very common. But what does this really mean? Let’s consider a simple class:

Friday 3 April 2020

Navigation from SAP S/4 HANA to SAP ECC 6.0 to view the replicated sales order

Recently I was assigned an interesting development, the requirements was to have a button “View legacy Sales Order” on standard sales order screen (VA03) on SAP S/4 HANA system if user clicks that button the system should open VA03 – display sales order that got replicated in the legacy ECC system using a RFC – single sign on (Different system).

Below are the step by step development that I did to accomplish the same.

Wednesday 1 April 2020

Analyze ABAP Performance Traces with the Profile Data Analyzer

In this blog, we would like to introduce the “profile data analyzer”, a new standalone tool to analyze performance trace, including the idea behind it and the analysis steps. The profile data analyzer supports both ABAP performance trace and SAP JVM Profiler performance trace (*.prf format) as documented in KBA 2879724, but we will focus on the analysis of ABAP performance trace in this blog.

It provides additional graphic and interactive views comparing to SAT/SE30/ST12 to make the performance analysis easy, for example, in the following scenarios.