Wednesday, 6 May 2020

Understanding the ABAP Program Logic With Profile Data Analyzer for Performance Optimization and Other Tasks

The Purpose


In the following SAP Community blog post which is published in the last month, we’d like to demonstrate the basic usage of the new tool “profile data analyzer” with two SM21 examples. With these examples, we can see that the profile data analyzer not only helps us to analyze the performance issue systematically and find out the most expensive parts of a program in a graphic and interactive way, but also helps us to understand the program logic, including getting an overall picture quickly and drilling down to the details easily.

Monday, 4 May 2020

Understanding Fragments based Adobe form building using LiveCycle version 10+ with OData as back-end.

Adobe has come up with new Fragments based approach for building Adobe Forms using LiveCycle designer from version 10 and above. And these Forms are part of New Output Management for S/4 HANA Systems. In this blog post I would like to explain briefly about Fragments based Forms and also would cover regular Forms (which is categorized as of type “Standalone Form”) with OData as backend. I would like to say that even though traditional Form building provisions precisely speaking SAP Scripts, SMARTFORMS and Adobe Forms with ABAP based Interfaces are still available as an alternative for this but still I would like to ask all of you to give this a try at least for learning purposes if your client is not insisting on this. If not now definitely going ahead, we might be bound to use this option (Adobe Form with OData backend) only.

Friday, 1 May 2020

Shared Memory Objects – Transfer data between ABAP programs

Shared memory is a memory area resides in the application server which is accessible to all the ABAP programs. In this post I’ll be discussing the way to access and use that memory area to cater business requirements by using a shared memory object.

Business Requirement


Sharing data between ABAP programs is a common business requirement. There are different ways of achieving that. Let’s take a simple business scenario.

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.