SAP & Oracle partner and support companies

Loading

Archives 2025

SAP

How I used SAP Adobe Form as my personal PDF editor

Who said SAP is only for Enterprise Resource Planning? (How I used SAP Adobe Form as my personal PDF editor?)

As of late, I had a need to alter a PDF record to address a grammatical mistake in my last name. I was in my office.My office PC and organization has solid restictions. I can’t download and introduce any outer programming. I really want to take help from our office help-work area to introduce any genuine programming. Unfortunately, they didn’t have a PDF manager for us. Also, they didn’t have authorization to introduce free preliminary programming from web.

My necessity was to promptly address my last name. There was an extra ‘H’. Right spelling is Shrestha and it was incorrectly spelled as Shres’H’tha. I would have rather not held up till the night to return home and utilize the PDF supervisor at my own PC. Being an ABAPer, I considered utilizing SAP Adobe Structure. So why pause? I wore my designer’s cap; hit the SAP t-code ‘SFP’ Structure Manufacturer: Section Point.

You can do the underneath steps, regardless of whether you have never worked in Adobe structures. You simply have to have the Adobe LifeCycle Originator introduced in your framework. Fortunately for me, I had it in my framework as a matter of course. Let’s get started on How I used SAP Adobe Form as my personal PDF editor?

Step 1: Go to t-code ‘SFP’ and make the Connection point as displayed beneath. Save it in a vehicle or save as neighborhood object. Actuate it.

SAP Adobe Interface
www.sapyard.com

Step 2: Go to t-code ‘SFP’ once more and make the Structure. Give the Point of interaction name which you made previously. Save it in transport or save as neighborhood object.

4

Important: Go to Layout TabTools menu and Import.

Adobe Form

This is the most import step. Here we want to import the PDF record which we need to alter. I will choose my document which should be altered. The PDF opens up like in PDF supervisor. Would anything that you like to. We can add lines, change textual styles, colors, add logo/pic and so on. My necessity was to address my last name. I tapped on the line/word and eliminated the extra ‘H’ from my last name (as I was doing in ordinary PDF proofreader).

Go to Print Preview Tab, drift your mouse on the PDF and you see the SAVE symbol. Save it at your ideal objective envelope in your framework and open it to see the new perfect mistake free PDF.

Note: This is certainly not an instructional exercise for SAP Adobe Structure. This is only an illustration of a strange use of SAP Adobe Structure to meet a viable need.

Trust you loved this post. Did you at any point apply any such clever or commonsense arrangements? Might you want to partake in the remark area?

Rather than accomplishing basically everything displayed above, simply follow the underneath steps.

Assuming you preferred it, kindly go ahead and it. Much thanks to you for visiting!!

assumption: Adobe LiveCycle is introduced in your machine

1. Browse: %ProgramFiles(x86)%\Adobe\Designer 9.0\ (or Designer 8.0, which ever version you have)
2. Run: FormDesigner.exe
3. Do your things in the PDF editor

10

YOU MAY LIKE THIS

Top Skills Required to Excel as a SAP MM Consultant

Building Client Relationships: From Technical Expert to Trusted Advisor

Simplified Business Workplace – Workflow Inbox in SAP R/3

SAP

Do all ABAPers know Fixed Point Arithmetic?

A mystery to start.. (Do all ABAPers know Fixed Point Arithmetic)

What might be the result of this compose articulation.

DATA: v_kwert_n TYPE kwert.

v_kwert_n = '1.234'.

WRITE:/ 'From Program: ', v_kwert_n.

Did you figure it could be ‘1.234’? Or on the other hand assuming that you were infront of the framework and you ended up taking a gander at the information component KWERT and it has 2 decimal. So you figured it would be ‘1.23’. Let’s go into the practical on this question, do all ABAPers know Fixed Point Arithmetic?

You can also read for :- Trick to adjust the variants

Allow me to show what my result was.

1

Oopss!!! This isn’t the very thing you anticipated. Correct?
Presently, you would attempt to challenge this result by really, composing the above lines of code in your framework. What!!! You get an alternate result.

Your result for a similar code.

2

All in all, for what reason is it different in yours and mine? Allow me to acquaint you with the top story, ‘Fixed Point Number-crunching’ (FPA). My program had the Proper Point Number juggling (menu->go to->attribute) uncontrolled. Yours’ absolute requirement been checked naturally.

3

As indicated by SAP, Fixed point number-crunching:
Assuming that you mark this checkbox, all estimations in the program will utilize fixed point math.

In the event that you don’t choose this actually look at box, stuffed numbers (ABAP/4 sort P, Word reference types CURR, DEC or QUAN) will be treated as whole numbers when they are utilized in tasks, examinations, and computations, regardless of the quantity of decimal spots characterized. Transitional outcomes in math estimations will likewise be adjusted to the following entire number. The quantity of decimal spots characterized is possibly considered when you yield the response utilizing the Compose explanation.

As a program quality, the decent point mathematics decides if for quantities of type p the decimal point is regarded by tasks or not.

Presently, let us see the way of behaving of the beneath code.

* In calling Program
DATA:
v_kwert TYPE kwert,
v_kwert_n TYPE kwert.

v_kwert_n = ( 1000 * '1.234' ) / 1000.

* Calling FM to multiply the same number with 1000 and divide by 1000
CALL FUNCTION 'Elearning'
IMPORTING
xkwert = v_kwert.

WRITE:/ 'From Program: ', 20 v_kwert_n.
WRITE:/ 'From FM: ', 20 v_kwert.
* In FM Elearning.
FUNCTION Elearning.

xkwert = ( 1000 * '1.234' ) / 1000.

ENDFUNCTION.

Check, the numerical articulation is precise in the calling program and called FM. Yet, the result is unique, in light of the fact that the Program has Fixed Point Math unrestrained while the FM has it checked.

4

Mess about by turning the FPA on and off on the other hand in program and FM and see the result.

SAP unequivocally suggest not turning off the proper point number-crunching in any program.

Genuine Venture Situation: Really look at the down to earth issue, where the client has issue in computation in VOFM routine where the standard SAP program SAPLV61A doesn’t have Fixed Point Math checked.

In such cases, we ought to call a custom FM with Fixed Point Arithimetic checked and do the computation in the FM and pass the last worth to the primary program (VOFM).

With the above gyan (sanskrit word for information), let us check whether we could decide the right result of the beneath code (taken from SAP Help documentation)

CLASS cl_test DEFINITION.
 PUBLIC SECTION.

 CLASS-METHODS meth RETURNING value(p) TYPE string.

ENDCLASS.

CLASS cl_test IMPLEMENTATION.
 METHOD meth.

 p = '1000'.

 ENDMETHOD.
ENDCLASS.

* Calling in program
START-OF-SELECTION.

DATA v_pack TYPE p DECIMALS 2.

v_pack = cl_test=>meth( ).

write:/ v_pack.

The present Something worth mulling over.
I) What might be the result worth of variable v_pack assuming that the Decent Point Number juggling is checked?
ii) What might be the result worth of variable v_pack in the event that the Decent Point Number juggling isn’t checked?

Assuming that you enjoyed it, kindly offer it! Much obliged!

YOU MAY BE INTERESTED IN

SAP ALE IDoc Configuration Steps: Streamlining Communication

Adapting generative AI to business context

How to integrate sap with other systems ?

SAP

Trick to adjust the variants

Trick to adjust the variants. Say, your variation was turned out great till yesterday and amazingly, you receive message like beneath for a similar variant. ”Variant xxxxxxxxx of program xxxxxxx isn’t the ongoing rendition”. Trick to adjust the variants.

Arrangement: Change or erase the variant.Deleting and reproducing the variation would address the issue. Be that as it may, in the event that you have 100s of variation for a similar report, it would be drawn-out to erase and yet again make.

Better way is to change the variation utilizing program RSVARDOC_610. Go to t-code SE38, enter this program name and execute (F8). In the determination screen, give the program name and variation you need to change. To change all variation then put ‘*’ in the variation name segment. In the event that it isn’t framework variation then keep the SYSVAR area clear.

You can also read for:- Background job not listed in transaction SM50

On the off chance that your SAP framework doesn’t have this program, then search RSVARDOC* and check whether you have any refreshed program for the momentum adaptation of your framework. In the event that you find no other program other than RSVARDOC, utilize this program.

YOU MAY LIKE THIS

Advanced Code Snippet Techniques : Mastering the Craft

IDoc to EDI Mapping: Bridging the Gap

SAP Training Institute

SAP

Background job not listed in transaction SM50

Before going for Background job not listed in transaction SM50. Here and there you might have a foundation work dynamic in your work sign in SM37 which you need to troubleshoot or do some examination at run time. However, shockingly, you probably won’t have the option to see it in Cycle Outline t-code SM50. Let’s get started on background job not listed in transaction SM50.

The above work/report isn’t in the SM50 list underneath.

Solution 1:
Your scene should have more than one application servers. So you want to investigate different servers other than the server where SM50 is running. Check the above screen shot. The SM50 was running in server 05. The rundown of servers should be visible from t-code SM51.

Check the work which you are chasing after is available in server 07.

You can also read for :- Extensive Tips and Tricks for Interactive SAP ALV

Solution 2: You can likewise see your work in the Worldwide Work Cycle Outline t-code SM66.
Check in the underneath screen, there are occupations from various servers(20/02/04/05/07 and so forth). You can see the positions which was absent in SM50 list.

Tip to debug active job:
You can investigate the completed foundation occupations planned by your own client id by utilizing order JDBG.

You can investigate the dynamic foundation occupations booked by any client id utilizing t-code SM50/SM51.
Select the work, Program/Meeting >Program->Debugging.

Much thanks for your time!!

YOU MAY LIKE THIS

Automatically Fill Test Data in FM & BAPIs for SE37 – The Lazy Way

SAP ABAP – From Basic to Advanced OData

Objects of Data Dictionary in SAP ABAP

SAP

Transport ABAP Report Variants into a Work Bench Request

A few times it is expected to move the determination variations (made for a report program) starting with one climate then onto the next. We will examine this prerequisite with an example situation. Transport ABAP Report Variants into a Work Bench Request.

Moves toward be followed are: Let’s get started with Transport ABAP Report Variants into a Work Bench Request.

You can also read for:- Navigating the Cloud with SAP BTP ABAP Environment

Step 1) Execute exchange SE38 and give the name of the program as:

Step 2) In a similar screen really look at the radio button “Variations” and snap In plain view pushbuttonor follow menu way Goto – > Variations as:

Step 3) In the following screen follow the menu way Utilities – > Transport demand.. as:

Step 4) Execute (F8) the program accordingly shows up in the following screen as:

Step 5) Up on execution a spring up would seem requesting choosing the variations (saved against that report program) to be shipped as:

(We can choose the variations we want and avoid the others)

Stage 6) Up on squeezing Proceed, a next spring up shows up; requesting the vehicle subtleties as:

Here we can pick our own vehicle to move the choice variations for the report program starting with one climate then onto the next.

Trust this data would be helpful to all freshers. 

YOU MAY BE INTERESTED IN

Your Definitive Guide to Becoming a SAP ABAP Developer

Use of data elements in SAP ABAP

Top SAP ABAP Interview Questions (2024)

SAP

SAP ABAP CRM Tips

Opening CRM Request in another window (SAP ABAP CRM Tips)

At the point when there is a prerequisite to open a CRM Request (Client Request. Administration Request. and so forth) from a program, the typical interaction is to populate the Business Item Boundary (CRM_OBJECT_ID) with the Exchange Number (OBJECT_ID) and afterward doing a CALL Exchange to CRMD_ORDER. Be that as it may, this technique doesn’t appear to work.

SET Boundary ID ‘CRM_OBJECT_ID’ FIELD .
CALL Exchange ‘CRMD_ORDER’ AND Skirt FIRST SCREEN.

It won’t get into the exchange (CRM Request) , however stop at the inquiry screen.
The strategy for getting around could be utilizing the BAPI BAPI_BUSPROCESSND_DISPLAY to show the CRM Request. You can utilize it to show the CRM Request screen straightforwardly. Simply pass your Request Header GUID ID to the business cycle and the CRMD_ORDER screen will be shown.

CALL FUNCTION 'BAPI_BUSPROCESSND_DISPLAY'
EXPORTING
business_process = <order_header_guid>

2: Embedding or Erasing Standard/Custom messages in CRM GUI.(SAP ABAP CRM Tips)
If conceivable, you can follow the accompanying advances.

a) First delete message, for example
* Deleting the messages from stack

CALL FUNCTION 'CRM_MESSAGES_DELETE'
EXPORTING
iv_caller_name = gc_object_name-order
iv_ref_object = iv_item
it_r_msgidno = lt_idno
EXCEPTIONS
OTHERS = 1.

b) Check for corresponding message text already exists or not, for example

CALLFUNCTION'CRM_TEXT_READ_API'
EXPORTING
it_guid = lt_object_guids
iv_object_kind = gc_object_kind-orderadm_i
IMPORTING
et_text = lt_text.

OR
Search the corresponding messages, for example:

ls_idno-sign = 'I'.
ls_idno-option = 'EQ'.
ls_idno-low-msgid = 'Z_ZZZ_CA_MESSAGES'.
ls_idno-low-msgno = '126'.
APPEND ls_idno TO lt_idno.

CALL FUNCTION 'CRM_MESSAGES_SEARCH'
EXPORTING
it_r_msgidno = lt_idno
iv_ref_object = iv_header_guid
iv_ref_kind = gc_object_kind-orderadm_h
iv_only_errors_on_object = true
IMPORTING
et_msg_info = lt_msg_info
EXCEPTIONS
appl_log_error = 1
error_occurred = 2
OTHERS = 3.

c) If the message does not exist. Then raise message. For example

CALLFUNCTION'CRM_MESSAGE_COLLECT'
EXPORTING
iv_caller_name = gc_object_name-order
iv_ref_object = iv_item
iv_ref_kind = gc_object_kind-orderadm_i
iv_logical_key = 'MAINTAIN'
iv_msgno = lv_msgno
iv_msgid = 'CRM_ORDERADM_I'
iv_msgty = lv_msgty
EXCEPTIONS
not_found = 1
appl_log_error = 2
OTHERS = 3.

YOU MAY LIKE THIS

Conquering the Full Stack Developer Interview: Essential Questions and Expert Tips

Cracking the Code: Your Earning Potential as a SAP ABAP Developer with 5 Years of Experience

SAP ABAP Interview Questions Real time Expectations

SAP

Advance SAPUI5 – Integration of Google Maps JavaScript API with SAPUI5 App

Numerous multiple times, freshers in any innovation request genuine Venture models. To those lovers, my idea will be, pick any situation you can imagine, and it tends to be a genuine undertaking situation. Interest and Investigation is the way to learning. At the point when we are interested like a youngster and begin getting clarification on some pressing issues, we sort out fascinating stuffs. As of late, I was looking for certain cafés and their particular courses on Google Guide in some Food Conveyance Android Portable Application. While utilizing the application I figured how it would look on the off chance that we coordinate the Integration of Google Maps JavaScript API with SAPUI5 App and make it a utility device for tracking down a spot, computing distance between two spots, custom marker offices, etc. One of my companions has a mark inscriptions which says “Believing isn’t sufficient, we really want to do”.

I attempted to execute my considerations and ultimately, I was effective in making a good application. In this article, I will exhibit every one of the means in subtleties to accomplish the usefulness.

To coordinate Integration of Google Maps JavaScript API with SAPUI5 App, we really want Google Guide Programming interface. Google has given various APIs viz Google Guide Android Programming interface, Google Guides for iOS, Google Guides for Road, Google Guides Course Programming interface and some more. For our application, we will utilize Google Guides JavaScript Programming interface. The motivation to pick Guides JavaScript Programming interface is basic, it permits us to alter the guides with our own substance and symbolism for show on website pages and cell phones.

You can also read this:- GPS like tool in SAP using Google Map API

Glimpse of the Google Map we integrated (Integration of Google Maps JavaScript API with SAPUI5 App)

To utilize the Google Guides Programming interface, we really want a designer key. Prior to figuring out how to incorporate Google Guides Programming interface with SAPUI5, we want to figure out how to make a designer key?

A. Steps for Creating Google Maps Developer Key

Step 1 : Go to the Google Developers Console

Step 2 : Create a New Project.

Step 3 : Select created Project from list of Projects and Select Dashboard Tab.

Step 4 : Click on API Explore and enable APIs inside Getting Started Tile/Block in same page.

Step 5 : On next page click on Enable APIs and Services button .

Step 6 : After clicking on the button it will navigate to API Library Page. Here select Maps JavaScript API.

Step 7 : On next page click on Enable button, below Maps JavaScript API. Now API will be enabled and we need to create credentials for the same.

Step 8 : Select Credentials tab and click on Hyper Link i.e. Credentials in APIs & Services.

Step 9 : On next page click on CREATE CREDENTIALS button.

Step 10 : Select API key and OAuth Client ID to create the both one by one under CREATE CREDENTIALS button.

Steps 11 : In Left Pane of the console/page under Credential, you can see your project’s API KeysoAuth Client ID, and Service Accounts details.

Trust you found out about how to make a Google Guides Programming interface Engineer Key and you will actually want to produce the designer key.

Presently how about we move to joining some portion of Google Guides JavaScript Programming interface with SAPUI5 Application.

B. Steps to Integrate Google Maps JavaScript API with SAPUI5

Step 1 : Create an SAPUI5 Application.

Step 2 : Load the Maps JavaScript API.

To stack the Guides JavaScript Programming interface, we really want to utilize a content label which is displayed in underneath model:

Step 3 : Creating DOM Element for the Map.

Step 4 : Creating Map Object and Setting the Map Options (Default Place Coordinates i.e. Latitude and Longitude).

Reclassify onAfterRendering snare strategy for SAPUI5 and compose the beneath code for making Guide Item and setting the Guide Choices/Required Boundaries.

Step 5 : Creating Custom Marker on clicking inside Map and saving the custom data based on requirement.

Pop-up screen code is as below:

Custom Technique for showing Spring up screen and catching/saving the information for the specific made Marker according to the prerequisite. Here the technique I have made is named as fnOnClickPlace which is featured and brought in above screen capture. Source code for this technique is as beneath:

fnSave and fnCancel are functions created in Pop-up Screen for Saving the data and Cancelling the action.

Piece for handling the Caught/Saved information as JSON and utilizing according to prerequisite.

Step 6 : Google Map’s Search Functionality (Finding/Searching Particular Place)

Here client can find/search any spot across the globe with the assistance of Google’s Strong Google Guides JavaScript Programming interface. The following is the screen captures of the rationale used to accomplish the result.

For testing the carried out Search usefulness of Google Guide, I will look through the spot as ‘Parliament of Delhi’. Subsequent to tapping on Search button, it’s showing the right outcome for example Parliament of India.

Step 7 : Calculating Distance between two places/points

We can really look at the distance between two spots/focuses with the assistance of Google Guides JavaScript Programming interface without any problem. Source Code is as underneath:

For testing the Distance Computation usefulness of our executed SAPUI5 Application, I will track down the distance among Silkboard and Roopena Agrahara. The determined distance between both the focuses is totally right. You might approve it utilizing different sources.

We get it, this is a high level theme and you will have not many questions. If it’s not too much trouble, go ahead and put your inquiries. We will attempt are ideal to answer to give further explanation. Likewise, kindly remark your ideas, criticism for me which will assist me with introducing better instructional exercises in future.

You may be like:-

Extensive Tips and Tricks for Interactive SAP ALV

Add custom fields in standard MIRO header screen through BADI_FDCB_SUBBAS01

Steps to add custom Tab in standard MIRO item screen using BADI MRM_ITEM_CUSTFIELDS

    SAP

    Real Time Exchange Rate with Real Time Data Using Yahoo Finance API

    let’s dive into the Real Time Exchange Rate with Real Time Data Using Yahoo Finance API. In the prior posts Google Guide Programming interface in SAP and GPS like apparatus in SAP we perceived how we can use the Google Guide APIs and consume them in SAP. Here, we expand the utilization of comparative APIs to follow the conversion scale continuous. By the constant we mean, it would be invigorated naturally at a decent timespan which we set and it would show the genuine rate for that portion of the time. Why generally Google, this time we would utilize Yippee’s Programming interface. Let’s get into the Real Time Exchange Rate with Real Time Data Using Yahoo Finance API.

    This, Yahoo’s Money Programming interface has the underneath structure.

    Yahoo and SAP

    We want to consume it in SAP to show the swapping scale constant and furthermore revive it consequently without the need to stir things up around town button on the screen. Could it be cool, in the event that you are in a Money Association and you project the conversion scale or stock worth on an immense wall from SAP and it gets revived constant for each bystander to see?

    Allow us to see what our Application can do.

    Give the time span at which you maintain that the outcomes should be revived.

    The result is shown for a specific time frame.

    Presently, it is revived consequently. The message shows the time at which the information was revived.

    Kindly note, there is no invigorate button on the screen. Our Application handles the invigorate.

    There is no advanced science. Class Strategy CL_GUI_ALV_GRID->REFRESH_TABLE_DISPLAY is going about our business.

    A unique notice of the Class/Connection point CL_GUI_TIMER and Occasion Completed is likewise required.

    Really take a look at the Technique TIMER_EVENT in the Class CL_AUTO in the code.

    METHODS :display_report,
    * Define event handling method for event FINISHED of class CL_GUI_TIMER.
    timer_event FOR EVENT finished OF cl_gui_timer.

    Conceptually, what is happening?

    Occasion Completed of class CL_GUI_TIMER is raised after the Clock has hung tight for the Stretch gave in the choice screen. An audience strategy for Completed occasion is made and the Invigorate rationale is carried out.

    Another significant step is to call the Pursue strategy for CL_GUI_TIMER the Invigorate to actuate the time once more.

    METHOD timer_event .
    
    DATA: lv_time TYPE char10.
    
    * Get Data
    me->get_data( ) .
    
    IF me->ob_grid IS INITIAL .
    
    CALL FUNCTION 'GET_GLOBALS_FROM_SLVC_FULLSCR'
    IMPORTING
    e_grid = ob_grid.
    ELSE.
    
    * Refresh the ALV
    CALL METHOD ob_grid->refresh_table_display.
    
    ENDIF.
    
    WRITE sy-uzeit TO lv_time USING EDIT MASK '__:__:__'.
    
    CONCATENATE 'Screen refreshed at' lv_time INTO DATA(lv_msg) SEPARATED BY space.
    
    MESSAGE lv_msg TYPE 'S' . " Get the cuuent timE as message
    
    * Call RUN method of CL_GUI_TIMER again to activate timer
    me->ob_timer->run( ) .
    
    ENDMETHOD.
    
    

    This article is a result of exploration done to figure out how to track and follow the vehicle of specialist co-ops like Ola or Uber and so forth. The thought was to utilize the point of interaction/program which we made before where we consumed Google Guide APIs. Be that as it may, tragically, we were unable to sort out any free APIs which would return the specific place of the vehicles constant. Yet, we wound up finding this Programming interface which returned constant stock and conversion scale.

    The moves toward consume the Programming interface is the very same as our past articles. Thusly, we have not portrayed them again here. Assuming that you have disarray, if it’s not too much trouble, allude to our prior articles or just put breakpoints in the code and begin troubleshooting. The rationale is clear.

    To get such helpful articles straightforwardly to your inbox, kindly Buy in. We regard your security and treat API safeguarding it in a serious way.

    Do you have anything to add to this article? Have you confronted any issue utilizing Adobe Structures? Would you like to share any genuine task necessity or arrangements? Kindly let it all out. Kindly leave your considerations in the remark area.

    Much thanks for your time!!

    We have characterized a design ‘ZAUTO_EXC’ for the beneath application. You could require this too.

    Exchange Rate in SAP

    The total working code piece for this subject. Kindly reproduce it in your SAP climate and have a great time.

    **---------------------------------------------------------------------*
    ** Date : 07/05/2025 *
    ** Author : Varad (elearningsolutions) *
    ** Title : Auto Refresh the Screen Output *
    **---------------------------------------------------------------------*
    REPORT elearningsolutions MESSAGE-ID zma.

    *&---------------------------------------------------------------------*
    *& CLASS DEFINATION FOR ADDTING AUTO REFRESH
    *&---------------------------------------------------------------------*
    CLASS cl_auto DEFINITION .

    PUBLIC SECTION .
    *&---------------------------------------------------------------------*
    *& TYPE-POOLS
    *&---------------------------------------------------------------------*
    TYPE-POOLS: truxs, slis.

    DATA : ob_timer TYPE REF TO cl_gui_timer .

    METHODS :display_report,
    * Define event handling method for event FINISHED of class CL_GUI_TIMER.
    timer_event FOR EVENT finished OF cl_gui_timer.
    PRIVATE SECTION .

    *&---------------------------------------------------------------------*
    *& Types and Data
    *&---------------------------------------------------------------------*
    TYPES: BEGIN OF ty_dest,
    time_date TYPE zauto_exc-time_date,
    ex_type TYPE zauto_exc-ex_type,
    rate TYPE zauto_exc-rate,
    time_stamp TYPE zauto_exc-time_stamp,
    END OF ty_dest.

    DATA: gt_dest TYPE STANDARD TABLE OF ty_dest.
    DATA : ob_grid TYPE REF TO cl_gui_alv_grid . "DISPLAY DATA
    DATA : gt_dest1 TYPE STANDARD TABLE OF ty_dest.

    *&---------------------------------------------------------------------*
    *& Methods
    *&---------------------------------------------------------------------*
    METHODS :
    get_data,

    create_http_client IMPORTING ip_url TYPE string
    EXPORTING ex_http_client TYPE REF TO if_http_client,

    http_client_request_get_method
    IMPORTING ip_http_client TYPE REF TO if_http_client,

    http_client_send IMPORTING ip_http_client TYPE REF TO if_http_client,

    http_client_receive IMPORTING ip_http_client TYPE REF TO if_http_client
    EXPORTING ex_content TYPE string,

    get_data_ex IMPORTING ip_content TYPE string.

    ENDCLASS.

    CLASS cl_auto IMPLEMENTATION.

    * Method 1
    METHOD create_http_client.

    * Get client from url
    CALL METHOD cl_http_client=>create_by_url
    EXPORTING
    url = ip_url " '/webservice/v1/symbols/allcurrencies/quote'.
    IMPORTING
    client = ex_http_client
    EXCEPTIONS
    argument_not_found = 1
    plugin_not_active = 2
    internal_error = 3
    OTHERS = 4.

    ENDMETHOD.

    * Method 2
    METHOD http_client_request_get_method.
    * Request and Get
    ip_http_client->request->set_header_field( name = '~request_method' value = 'GET' ).
    ENDMETHOD.

    * Method 3
    METHOD http_client_send.
    * Send the request
    ip_http_client->send( ).
    ENDMETHOD.

    * Method 4
    METHOD http_client_receive.
    * Reterive the result
    CALL METHOD ip_http_client->receive
    EXCEPTIONS
    http_communication_failure = 1
    http_invalid_state = 2
    http_processing_failed = 3
    OTHERS = 4.
    ex_content = ip_http_client->response->get_cdata( ).

    ENDMETHOD.

    * Method 5
    METHOD get_data_ex.

    * Local data declaration
    DATA: lv_url TYPE c LENGTH 255,
    ls_dest TYPE ty_dest,
    moff TYPE syst-tabix,
    moff1 TYPE syst-tabix,
    lv_len TYPE syst-tabix,
    lv_ex_type TYPE c LENGTH 20,
    lv_rate TYPE c LENGTH 20,
    lv_time_date TYPE c LENGTH 40.

    *&---------------------------------------------------------------------*
    *& Find exchange
    *&---------------------------------------------------------------------*
    DO .
    * Find <location> text in the content string
    FIND '<field name="name">' IN SECTION OFFSET moff OF ip_content IGNORING CASE MATCH OFFSET moff .

    IF sy-subrc = 0 .

    moff = moff + 19 .

    FIND '</field>' IN SECTION OFFSET moff OF ip_content IGNORING CASE MATCH OFFSET moff1 .

    lv_len = moff1 - moff .

    lv_ex_type = ip_content+moff(lv_len) .

    ls_dest-ex_type = lv_ex_type.
    *--------------------------------------------------------------------*
    * ---------------Find rate
    *--------------------------------------------------------------------*
    FIND '<field name="price">' IN SECTION OFFSET moff OF ip_content IGNORING CASE MATCH OFFSET moff .

    IF sy-subrc = 0 .

    moff = moff + 20 .

    FIND '</field>' IN SECTION OFFSET moff OF ip_content IGNORING CASE MATCH OFFSET moff1 .

    lv_len = moff1 - moff .

    lv_rate = ip_content+moff(lv_len) .

    ls_dest-rate = lv_rate.

    ENDIF.

    *==============================================================
    * Find date and time stamp from api
    *==============================================================

    FIND '<field name="utctime">' IN SECTION OFFSET moff OF ip_content IGNORING CASE MATCH OFFSET moff .
    IF sy-subrc = 0 .

    moff = moff + 22 .
    FIND '</field>' IN SECTION OFFSET moff OF ip_content IGNORING CASE MATCH OFFSET moff1 .
    lv_len = moff1 - moff .
    lv_time_date = ip_content+moff(lv_len) .
    ls_dest-time_date = lv_time_date.

    ENDIF.

    * GET TIME form system for verfication .
    ls_dest-time_stamp = sy-uzeit.

    APPEND ls_dest TO gt_dest.

    ELSE.

    EXIT.

    ENDIF.

    ENDDO .

    ENDMETHOD.

    METHOD get_data .

    CLEAR: gt_dest.

    DATA: lv_http_client TYPE REF TO if_http_client,
    lv_content TYPE string,
    lv_url TYPE string.

    * Prepare the url of the address
    lv_url = 'http://finance.yahoo.com/webservice/v1/symbols/allcurrencies/quote'.

    create_http_client( EXPORTING ip_url = lv_url
    IMPORTING ex_http_client = lv_http_client ).

    http_client_request_get_method( EXPORTING ip_http_client = lv_http_client ).

    http_client_send( EXPORTING ip_http_client = lv_http_client ).

    http_client_receive( EXPORTING ip_http_client = lv_http_client
    IMPORTING ex_content = lv_content ).

    get_data_ex( EXPORTING ip_content = lv_content ).

    * Updating data every time
    CLEAR:gt_dest1.

    me->gt_dest1 = gt_dest.

    ENDMETHOD.

    METHOD timer_event .

    DATA: lv_time TYPE char10.

    me->get_data( ) .

    IF me->ob_grid IS INITIAL .

    CALL FUNCTION 'GET_GLOBALS_FROM_SLVC_FULLSCR'
    IMPORTING
    e_grid = ob_grid.
    ELSE.

    CALL METHOD ob_grid->refresh_table_display.

    ENDIF.

    WRITE sy-uzeit TO lv_time USING EDIT MASK '__:__:__'.

    CONCATENATE 'Screen refreshed at' lv_time INTO DATA(lv_msg) SEPARATED BY space.

    MESSAGE lv_msg TYPE 'S' . " Get the cuuent timE as message

    * Call RUN method of CL_GUI_TIMER again to activate timer
    me->ob_timer->run( ) .

    ENDMETHOD.

    METHOD display_report . " Only call for first display

    me->get_data( ) .

    CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY_LVC'
    EXPORTING
    i_structure_name = 'ZAUTO_EXC'
    TABLES
    t_outtab = me->gt_dest1.
    ENDMETHOD.

    ENDCLASS.

    *--------------------------------------------------------------------*
    * Start of Selection
    *--------------------------------------------------------------------*
    DATA : ob_auto TYPE REF TO cl_auto,
    ob_timer TYPE REF TO cl_gui_timer.

    *--------------------------------------------------------------------*
    * Selection Screen Parameters
    *--------------------------------------------------------------------*
    PARAMETERS : p_refres TYPE char01 AS CHECKBOX,
    p_int TYPE i.

    *--------------------------------------------------------------------*
    * Start of Selection
    *--------------------------------------------------------------------*
    START-OF-SELECTION.

    * Create main object
    CREATE OBJECT ob_auto .

    IF p_refres IS NOT INITIAL .

    CREATE OBJECT ob_auto->ob_timer .
    SET HANDLER ob_auto->timer_event FOR ob_auto->ob_timer .

    * Set interval for timer
    ob_auto->ob_timer->interval = p_int .

    * Call method RUN of CL_GUI_TIMER.
    ob_auto->ob_timer->run( ) .

    ENDIF.

    *--------------------------------------------------------------------*
    * End of Selection
    *--------------------------------------------------------------------*
    END-OF-SELECTION.

    * display dat first time
    ob_auto->display_report( ) .

    YOU MAY BE INTERESTED

    Future of APIs in SAP: Gazing into the Crystal Ball

    SAP API Landscape

    Why is it called rapid prototyping?

    SAP API Development

    SAP

    GPS like tool in SAP using Google Map API

    In the previous article, we perceived how we can get the scope and longitude of any location utilizing Google Guide Programming interface. Adding to that learning, here, we would figure out how to get the distance between two locations. We would likewise perceive how we can infer turn by turn headings between two given addresses. To add more to the tomfoolery, we would likewise open a program from SAP and show the course between two focuses on the guide. Let’s delve into the GPS like tool in SAP using Google Map API.

    Do you think, this is interesting? 

    To put it plainly, this device would carry on like a GPS like tool in SAP using Google Map API, which would assist you with getting the Directions (Scopes/Longitudes), Course and Guide with complete heading.

    Before we check, how it tends to be finished, let us first see, what we are referring to.

    I.  First radio button: Coordinates & Distance

    We get the Directions of two locations and furthermore the distance between them.

    II.  Second Radio button: Turn by turn route

    The device would give you the total separation of the course from the source to the objective location. It would likewise furnish you with different courses if accessible.

    II.  Let’s check the third radio button which says ‘Display Map‘.

    As mentioned, this GPS Device would show the guide alongside the courses in an Internet Browser. Look at this.

    Google Map

    Did you like it?

    You can utilize the code piece gave toward the finish of this article and attempt it yourself. The code gave here would function for what it’s worth. The idea was at that point made sense of in our previous post ‘Get Scope and Longitude of any spot utilizing Google Guide Programming interface in SAP’.

    For the three result choices, we want to call three APIs. As made sense of in the previous article, we link the strings with source and objective location, Scopes and Longitudes and so forth to finish the Programming interface URL and get the XML information. Perusing the XML information and pinpointing the required data is the stunt which we have previously learned.

    a) GeoCode API String for Coordinates:

    * Prepare the url of the GeoCode API
      CONCATENATE
        'http://maps.google.com/maps/api/geocode/xml?address='
        lv_address
        INTO lv_http_url .

    b) Distance Matrix API String for retrieving the distance between Coordinates:

    * Prepare the url for the DistanceMatrix API using From Address Coordinates and To Address Coordinates
      CONCATENATE
        'http://maps.googleapis.com/maps/api/distancematrix/xml?origins='
        <fs_dest>-place_f '|' <fs_dest>-lat_f ',' <fs_dest>-lng_f ','
        '&destinations=' <fs_dest>-place_t '|' <fs_dest>-lat_t ',' <fs_dest>-lng_t
        '&alternatives=' 'true'
        INTO lv_http_url .

    c) Directions API String to trace the route on the Map:

    * Prepare the url for Directions API for the From Address Coordinates and To Address Coordinates
      CONCATENATE
        'http://maps.googleapis.com/maps/api/directions/xml?origin='
        <fs_dest>-place_f '|' <fs_dest>-lat_f ',' <fs_dest>-lng_f
        '&destination=' <fs_dest>-place_t '|' <fs_dest>-lat_t ',' <fs_dest>-lng_t
        '&alternatives=' 'true'
        INTO lv_http_url .

    where:
    lv_address               = From/To address
    <fs_dest>-place_f = From address
    <fs_dest>-lat_f      = From address latitude
    <fs_dest>-lng_f     = From address longitude
    <fs_dest>-place_t = To address
    <fs_dest>-lat_t      = To address latitude
    <fs_dest>-lng_t      = To address longitude

    Once you have the correct API URL, use this cl_http_client class and create_by_url method to get the detailed information.

    * Get client from url
      CALL METHOD cl_http_client=>create_by_url
        EXPORTING
          url                = lv_http_url
        IMPORTING
          client             = p_http_client
        EXCEPTIONS
          argument_not_found = 1
          plugin_not_active  = 2
          internal_error     = 3
          OTHERS             = 4.

    Kindly go through the nitty gritty code to check how it functions. There may be better ways of perusing these APIs and XML information however we simply needed to show the potential outcomes. You can investigate more and sort out the most ideal way for you.

    In the event that you track down any trouble in figuring out the code or idea, kindly keep in touch with us or leave your inquiry in the remark segment. We would doubtlessly answer.

    In the event that you have question whether this apparatus would work for Non-India address. Be have confidence, it works for any location. Really look at the result for the location in the USA.

    To get such commonsense issues and objectives straightforwardly to your inbox, assuming no one minds, Purchase in. We respect your security and view shielding it in a serious manner.

    Expecting that you partook in this post, assuming no one minds, hit the deal buttons.

    Much obliged to you generous for your time!!

    *-----------------------------------------------------------------------
    * Title : Get Latitude and Longitude of a place from Google API
    * Get distance between two addresses
    * Show the turn by turn route of two addresses
    * Show route in map in a browser
    *-----------------------------------------------------------------------
    * Change History :
    * Author DATE REQUEST# DESCRIPTION
    *--------------- ---------- ----------- -------------------------------
    * Intial Development
    *-----------------------------------------------------------------------
    REPORT elearningsolutions_gps_google_api NO STANDARD PAGE HEADING
    LINE-COUNT 132.
    *&---------------------------------------------------------------------*
    *& TYPE-POOLS
    *&---------------------------------------------------------------------*
    TYPE-POOLS: truxs, slis.
    *&---------------------------------------------------------------------*
    *& Selection Screen
    *&---------------------------------------------------------------------*
    SELECTION-SCREEN BEGIN OF BLOCK b1 WITH FRAME TITLE text-t01.
    PARAMETERS : p_add_f TYPE c LENGTH 50,
    p_add_t TYPE c LENGTH 50.
    SELECTION-SCREEN END OF BLOCK b1.

    SELECTION-SCREEN BEGIN OF BLOCK b2 WITH FRAME TITLE text-t02.
    PARAMETERS:
    p_alv RADIOBUTTON GROUP
    p_route RADIOBUTTON GROUP
    p_map RADIOBUTTON GROUP
    SELECTION-SCREEN END OF BLOCK b2.

    *&---------------------------------------------------------------------*
    *& Types and Data
    *&---------------------------------------------------------------------*
    TYPES: BEGIN OF ty_dest,
    place_f TYPE c LENGTH 50, " From Place
    place_t TYPE c LENGTH 50, " To Place
    lat_f TYPE c LENGTH 20, " From Latitude
    lng_f TYPE c LENGTH 20, " From Longitude
    lat_t TYPE c LENGTH 20, " To Latitude
    lng_t TYPE c LENGTH 20, " To Longitude
    dis TYPE c LENGTH 30, " Distance
    END OF ty_dest,

    BEGIN OF ty_route,
    route_n TYPE c LENGTH 255, " Start of New Route
    summary TYPE c LENGTH 120, " Route Summary
    step TYPE syst_tabix, " Turn step
    ins TYPE c LENGTH 255, " Instruction
    dis TYPE c LENGTH 20, " Distance
    END OF ty_route.

    TYPES: t_ty_route TYPE TABLE OF ty_route.

    DATA:
    gt_dest TYPE STANDARD TABLE OF ty_dest,
    gt_route TYPE STANDARD TABLE OF ty_route.

    FIELD-SYMBOLS:
    <fs_dest> TYPE ty_dest.


    *&---------------------------------------------------------------------*
    *& Start of Selection
    *&---------------------------------------------------------------------*
    START-OF-SELECTION .

    * Get longitude and latitude of From Address
    PERFORM get_long_lat USING p_add_f.

    * Get longitude and latitude of To Address
    PERFORM get_long_lat USING p_add_t.

    *&---------------------------------------------------------------------*
    *& End of Selection
    *&---------------------------------------------------------------------*
    END-OF-SELECTION .

    * Get distance between two address
    PERFORM measure_distance.

    * Get detailed turn by turn address
    PERFORM turn_by_turn_route.

    * Show the output
    PERFORM show_output.


    ************************************************************************
    *&---------------------------------------------------------------------*
    *& Sub Routines
    *&---------------------------------------------------------------------*
    ************************************************************************
    FORM get_long_lat USING lv_address TYPE char50.

    DATA:
    lv_http_client TYPE REF TO if_http_client,
    lv_content TYPE string.

    * Creation of new IF_HTTP_Client object
    PERFORM create_http_client USING lv_address
    CHANGING lv_http_client .

    * Request and Get
    PERFORM http_client_request_get_method USING lv_http_client.

    * Send the request
    PERFORM http_client_send USING lv_http_client.

    * Retrieve the result
    PERFORM http_client_receive USING lv_http_client CHANGING lv_content.

    * Get the actual coordinate using the content string
    PERFORM get_coordinates USING lv_content lv_address.


    ENDFORM. " get_long_lat
    *&---------------------------------------------------------------------*
    *& Form CREATE_HTTP_CLIENT
    *&---------------------------------------------------------------------*
    * Create HTTP Client
    *----------------------------------------------------------------------*
    FORM create_http_client USING lv_address TYPE char50
    CHANGING p_http_client TYPE REF TO if_http_client.

    DATA: lv_http_url TYPE string.

    * Prepare the url of the GeoCode API
    CONCATENATE
    'http://maps.google.com/maps/api/geocode/xml?address='
    lv_address
    INTO lv_http_url .

    * Get client from url
    CALL METHOD cl_http_client=>create_by_url
    EXPORTING
    url = lv_http_url
    IMPORTING
    client = p_http_client
    EXCEPTIONS
    argument_not_found = 1
    plugin_not_active = 2
    internal_error = 3
    OTHERS = 4.

    ENDFORM.
    *&---------------------------------------------------------------------*
    *& Form HTTP_CLIENT_REQUEST_GET_METHOD
    *&---------------------------------------------------------------------*
    * Request and Get Method
    *----------------------------------------------------------------------*
    FORM http_client_request_get_method USING p_http_client TYPE REF TO if_http_client..
    * Request and Get
    p_http_client->request->set_header_field( name = '~request_method' value = 'GET' ).
    ENDFORM.
    *&---------------------------------------------------------------------*
    *& Form HTTP_CLIENT_SEND
    *&---------------------------------------------------------------------*
    * Send request
    *----------------------------------------------------------------------*
    FORM http_client_send USING p_http_client TYPE REF TO if_http_client.
    * Send the request
    p_http_client->send( ).
    ENDFORM.
    *&---------------------------------------------------------------------*
    *& Form HTTP_CLIENT_RECEIVE
    *&---------------------------------------------------------------------*
    * Get the string content
    *----------------------------------------------------------------------*
    FORM http_client_receive USING p_http_client TYPE REF TO if_http_client
    CHANGING p_p_content TYPE string.
    * Reterive the result
    CALL METHOD p_http_client->receive
    EXCEPTIONS
    http_communication_failure = 1
    http_invalid_state = 2
    http_processing_failed = 3
    OTHERS = 4.

    * CALL METHOD p_http_client->response->get_cdata(
    * RECEIVING
    * data = p_p_content " Character data
    * EXCEPTIONS
    * OTHERS = 1 ).

    p_p_content = p_http_client->response->get_cdata( ).

    ENDFORM.
    *&---------------------------------------------------------------------*
    *& Form GET_COORDINATES
    *&---------------------------------------------------------------------*
    * Get Latitute Longitude Coordinate
    *----------------------------------------------------------------------*
    FORM get_coordinates USING p_p_content TYPE string
    lv_address TYPE char50.

    * Local data declaration
    DATA: lv_url TYPE c LENGTH 255,
    ls_dest TYPE ty_dest,
    moff TYPE syst-tabix,
    moff1 TYPE syst-tabix,
    lv_len TYPE syst-tabix,
    lv_lat TYPE c LENGTH 20,
    lv_lng TYPE c LENGTH 20.

    * Field symbol
    FIELD-SYMBOLS:
    <lfs_dest> TYPE ty_dest.
    *&---------------------------------------------------------------------*
    *& Processing string
    *&---------------------------------------------------------------------*
    DO .
    * Find <location> text in the content string
    FIND '<location>' IN SECTION OFFSET moff OF p_p_content IGNORING CASE MATCH OFFSET moff .

    IF sy-subrc = 0 .
    * <location> is a 10 character string, hence adding 10
    moff = moff + 10 .

    * Find closing tag </location> text in the content string
    FIND '</location>' IN SECTION OFFSET moff OF p_p_content IGNORING CASE MATCH OFFSET moff1 .

    * Find the length of string between tag <location> and </location>
    lv_len = moff1 - moff .

    * We have seen the API string contet, so we know <lat> </lat> <lng> </lng> are there between
    * <location> and </location>
    *--------------------------------------------------------------------*
    * ---------------Find latitude
    *--------------------------------------------------------------------*
    * Find string <lat>
    FIND '<lat>' IN SECTION OFFSET moff OF p_p_content IGNORING CASE MATCH OFFSET moff .
    IF sy-subrc = 0 .
    * <lat> is a 5 character string, hence adding 5
    moff = moff + 5 .

    * Find closing tag </lat> text in the content string
    FIND '</lat>' IN SECTION OFFSET moff OF p_p_content IGNORING CASE MATCH OFFSET moff1 .

    * Find the length of string between tag <lat> and </lat>
    lv_len = moff1 - moff .

    * Characters between <lat> </lat> will have the latitude coorniate
    lv_lat = p_p_content+moff(lv_len) .

    * From place address
    ls_dest-place_f = lv_address .

    * Keep latitude in structure
    ls_dest-lat_f = lv_lat.

    ENDIF.

    *--------------------------------------------------------------------*
    * ---------------Find longitude
    *--------------------------------------------------------------------*
    * Find string <lng>
    FIND '<lng>' IN SECTION OFFSET moff OF p_p_content IGNORING CASE MATCH OFFSET moff .
    IF sy-subrc = 0 .

    * <lng> is a 5 character string, hence adding 5
    moff = moff + 5 .

    * Find closing tag </lng> text in the content string
    FIND '</lng>' IN SECTION OFFSET moff OF p_p_content IGNORING CASE MATCH OFFSET moff1 .

    * Find the length of string between tag <lng> and </lng>
    lv_len = moff1 - moff .

    * Characters between <lng> </lng> will have the latitude coorniate
    lv_lng = p_p_content+moff(lv_len) .

    * Keep longitude in structure
    ls_dest-lng_f = lv_lng.

    ENDIF.
    ELSE.

    EXIT.

    ENDIF.

    ENDDO .

    IF gt_dest[] IS INITIAL.
    * This part would trigger for From Latitude and Longitude
    * Put in internal table to display later
    APPEND ls_dest TO gt_dest.
    CLEAR:ls_dest .

    ELSE.

    * This part would trigger for To Latitude and Longitude
    READ TABLE gt_dest ASSIGNING <lfs_dest> INDEX 1.
    IF sy-subrc EQ 0.
    <lfs_dest>-place_t = lv_address.
    <lfs_dest>-lat_t = ls_dest-lat_f.
    <lfs_dest>-lng_t = ls_dest-lng_f.
    ENDIF.

    ENDIF.

    ENDFORM.
    *&---------------------------------------------------------------------*
    *& Form DISPLAY_LAT_LONGITUDE
    *&---------------------------------------------------------------------*
    * Display Latitude and Longitude
    *----------------------------------------------------------------------*
    FORM display_lat_longitude .

    DATA:
    lr_alv TYPE REF TO cl_salv_table,
    lr_columns TYPE REF TO cl_salv_columns_table,
    lr_column TYPE REF TO cl_salv_column,
    lr_functions TYPE REF TO cl_salv_functions_list,
    lr_display TYPE REF TO cl_salv_display_settings,
    lr_layout TYPE REF TO cl_salv_layout,
    ls_key TYPE salv_s_layout_key,
    lr_sorts TYPE REF TO cl_salv_sorts.

    " Check to make sure the internal table has data.
    IF lines( gt_dest ) > 0.

    TRY.
    * Create ALV instance
    * Use CALL METHOD since this is a static method
    CALL METHOD cl_salv_table=>factory
    IMPORTING
    r_salv_table = lr_alv
    CHANGING
    t_table = gt_dest.

    * Get functions object and then set all the functions to be allowed
    lr_functions = lr_alv->get_functions( ).
    lr_functions->set_all( ).

    lr_columns = lr_alv->get_columns( ).

    CALL METHOD lr_columns->get_column
    EXPORTING
    columnname = 'PLACE_F'
    RECEIVING
    value = lr_column.
    CALL METHOD lr_column->set_short_text
    EXPORTING
    value = ''.
    CALL METHOD lr_column->set_medium_text
    EXPORTING
    value = ''.
    CALL METHOD lr_column->set_long_text
    EXPORTING
    value = 'From Place Name'.

    CALL METHOD lr_columns->get_column
    EXPORTING
    columnname = 'LAT_F'
    RECEIVING
    value = lr_column.
    CALL METHOD lr_column->set_short_text
    EXPORTING
    value = ''.
    CALL METHOD lr_column->set_medium_text
    EXPORTING
    value = ''.
    CALL METHOD lr_column->set_long_text
    EXPORTING
    value = 'From Latitude'.

    CALL METHOD lr_columns->get_column
    EXPORTING
    columnname = 'LNG_F'
    RECEIVING
    value = lr_column.
    CALL METHOD lr_column->set_short_text
    EXPORTING
    value = ''.
    CALL METHOD lr_column->set_medium_text
    EXPORTING
    value = ''.
    CALL METHOD lr_column->set_long_text
    EXPORTING
    value = 'From Longitude'.

    CALL METHOD lr_columns->get_column
    EXPORTING
    columnname = 'PLACE_T'
    RECEIVING
    value = lr_column.
    CALL METHOD lr_column->set_short_text
    EXPORTING
    value = ''.
    CALL METHOD lr_column->set_medium_text
    EXPORTING
    value = ''.
    CALL METHOD lr_column->set_long_text
    EXPORTING
    value = 'To Place Name'.

    CALL METHOD lr_columns->get_column
    EXPORTING
    columnname = 'LAT_T'
    RECEIVING
    value = lr_column.
    CALL METHOD lr_column->set_short_text
    EXPORTING
    value = ''.
    CALL METHOD lr_column->set_medium_text
    EXPORTING
    value = ''.
    CALL METHOD lr_column->set_long_text
    EXPORTING
    value = 'To Latitude'.

    CALL METHOD lr_columns->get_column
    EXPORTING
    columnname = 'LNG_T'
    RECEIVING
    value = lr_column.
    CALL METHOD lr_column->set_short_text
    EXPORTING
    value = ''.
    CALL METHOD lr_column->set_medium_text
    EXPORTING
    value = ''.
    CALL METHOD lr_column->set_long_text
    EXPORTING
    value = 'To Longitude'.

    CALL METHOD lr_columns->get_column
    EXPORTING
    columnname = 'DIS'
    RECEIVING
    value = lr_column.
    CALL METHOD lr_column->set_short_text
    EXPORTING
    value = ''.
    CALL METHOD lr_column->set_medium_text
    EXPORTING
    value = ''.
    CALL METHOD lr_column->set_long_text
    EXPORTING
    value = 'Distance between From & To Address'.



    lr_columns->set_optimize( ).

    * Set sort column
    lr_sorts = lr_alv->get_sorts( ).
    lr_sorts->clear( ).

    * This code is to get the layout, save the layout and display the layout
    lr_layout = lr_alv->get_layout( ).
    ls_key-report = sy-repid.
    lr_layout->set_key( ls_key ).
    lr_layout->set_default( ' ' ).
    lr_layout->set_save_restriction( cl_salv_layout=>restrict_none ).


    lr_display = lr_alv->get_display_settings( ).
    lr_display->set_striped_pattern( cl_salv_display_settings=>true ).

    * Now display the report as an ALV grid
    lr_alv->display( ).

    CATCH cx_salv_msg.
    WRITE: 'Error displaying grid CX_SALV_MSG!'(001).

    CATCH cx_salv_not_found.
    WRITE: 'Error displaying grid CX_SALV_NOT_FOUND!'(002).

    CATCH cx_salv_data_error.
    WRITE: 'Error displaying grid CX_SALV_DATA_ERROR!'(003).

    CATCH cx_salv_existing.
    WRITE: 'Error displaying grid CX_SALV_EXISTING!'(004).

    ENDTRY.

    ELSE.
    MESSAGE 'No data to display' TYPE 'I'.
    LEAVE LIST-PROCESSING.

    ENDIF.


    ENDFORM.
    *&---------------------------------------------------------------------*
    *& Form MEASURE_DISTANCE
    *&---------------------------------------------------------------------*
    * Get distance between the from and to address
    *----------------------------------------------------------------------*
    FORM measure_distance .

    DATA:
    lv_http_client TYPE REF TO if_http_client,
    lv_content TYPE string.

    LOOP AT gt_dest ASSIGNING <fs_dest>.

    * Creation of new IF_HTTP_Client object
    PERFORM create_http_client_dist CHANGING lv_http_client .

    * Request and Get
    PERFORM http_client_request_get_method USING lv_http_client.

    * Send the request
    PERFORM http_client_send USING lv_http_client.

    * Retrieve the result
    PERFORM http_client_receive USING lv_http_client CHANGING lv_content.

    * Get the actual coordinate using the content string
    PERFORM get_coordinates_dist USING lv_content.

    ENDLOOP.

    ENDFORM.
    *&---------------------------------------------------------------------*
    *& Form CREATE_HTTP_CLIENT_DIST
    *&---------------------------------------------------------------------*
    * * Create HTTP Client
    *----------------------------------------------------------------------*
    FORM create_http_client_dist CHANGING p_http_client TYPE REF TO if_http_client.

    DATA: lv_http_url TYPE string.

    * Prepare the url for the DistanceMatrix API From Address Coordinates and To Address Coordinates
    CONCATENATE
    'http://maps.googleapis.com/maps/api/distancematrix/xml?origins='
    <fs_dest>-place_f '|' <fs_dest>-lat_f ',' <fs_dest>-lng_f ','
    '&destinations=' <fs_dest>-place_t '|' <fs_dest>-lat_t ',' <fs_dest>-lng_t
    '&alternatives=' 'true'
    INTO lv_http_url .

    * Get client from url
    CALL METHOD cl_http_client=>create_by_url
    EXPORTING
    url = lv_http_url
    IMPORTING
    client = p_http_client
    EXCEPTIONS
    argument_not_found = 1
    plugin_not_active = 2
    internal_error = 3
    OTHERS = 4.

    ENDFORM.
    *&---------------------------------------------------------------------*
    *& Form GET_COORDINATES_DIST
    *&---------------------------------------------------------------------*
    * Get Latitute Longitude Coordinate
    *----------------------------------------------------------------------*
    FORM get_coordinates_dist USING p_p_content TYPE string.

    * Local data declaration
    DATA: lv_url TYPE c LENGTH 255,
    ls_dest TYPE ty_dest,
    moff TYPE syst-tabix,
    moff1 TYPE syst-tabix,
    lv_len TYPE syst-tabix,
    lv_lat TYPE c LENGTH 20,
    lv_lng TYPE c LENGTH 20.

    * Field symbol
    FIELD-SYMBOLS:
    <lfs_dest> TYPE ty_dest.
    *&---------------------------------------------------------------------*
    *& Processing string
    *&---------------------------------------------------------------------*
    DO .
    * Find <distance> text in the content string
    FIND '<distance>' IN SECTION OFFSET moff OF p_p_content IGNORING CASE MATCH OFFSET moff .
    IF sy-subrc = 0 .

    * <distance> is a 10 character string, hence adding 10
    moff = moff + 10 .

    * Find closing tag </distance> text in the content string
    FIND '</distance>' IN SECTION OFFSET moff OF p_p_content IGNORING CASE MATCH OFFSET moff1 .

    ** Find the length of string between tag <distance> and </distance>
    * lv_len = moff1 - moff .

    * We have seen the API string contet, so we know <text> </text> are there between
    * <distance> and </distance>
    FIND '<text>' IN SECTION OFFSET moff OF p_p_content IGNORING CASE MATCH OFFSET moff .
    IF sy-subrc = 0 .
    * <text> is a 6 character string, hence adding 6
    moff = moff + 6 .

    * Find closing tag </text> text in the content string
    FIND '</text>' IN SECTION OFFSET moff OF p_p_content IGNORING CASE MATCH OFFSET moff1 .

    * Find the length of string between tag <text> and </text>
    lv_len = moff1 - moff .

    * Characters between <text> </text> will have the distance
    <fs_dest>-dis = p_p_content+moff(lv_len).

    * Get one distance and exit
    EXIT.

    ENDIF.

    ELSE.
    EXIT.
    ENDIF.
    ENDDO .
    ENDFORM.
    *&---------------------------------------------------------------------*
    *& Form SHOW_OUTPUT
    *&---------------------------------------------------------------------*
    * Show output
    *----------------------------------------------------------------------*
    FORM show_output .

    IF p_alv IS NOT INITIAL.

    * Show Latitute, Longitude and Distance
    PERFORM display_lat_longitude.

    ELSEIF p_route IS NOT INITIAL.

    * Show the complete break down of driving route
    PERFORM display_turn_by_turn_route.

    ELSEIF p_map IS NOT INITIAL.

    * Show direction in map
    PERFORM show_map.

    ENDIF.

    ENDFORM.
    *&---------------------------------------------------------------------*
    *& Form TURN_BY_TURN_ROUTE
    *&---------------------------------------------------------------------*
    * Get turn by turn ROUTE
    *----------------------------------------------------------------------*
    FORM turn_by_turn_route .

    DATA:
    lv_http_client TYPE REF TO if_http_client,
    lv_content TYPE string,
    lv_xstring TYPE xstring,
    li_xml_table TYPE TABLE OF smum_xmltb.

    IF p_route IS NOT INITIAL.

    LOOP AT gt_dest ASSIGNING <fs_dest>.

    * Creation of new IF_HTTP_Client object
    PERFORM create_http_client_direction CHANGING lv_http_client .

    * Request and Get
    PERFORM http_client_request_get_method USING lv_http_client.

    * Send the request
    PERFORM http_client_send USING lv_http_client.

    * Retrieve the result
    PERFORM http_client_receive USING lv_http_client CHANGING lv_content.

    ** Get the actual coordinate using the content string
    * PERFORM get_coordinates_dist USING lv_content.

    * Convert String to XString
    PERFORM convert_string_to_xstring USING lv_content CHANGING lv_xstring.

    * Parse XML document into a table structure
    PERFORM parse_xml_to_table USING lv_xstring CHANGING li_xml_table.

    * Clean XML file
    PERFORM clean_xml_data USING li_xml_table.



    ENDLOOP.

    ENDIF.

    ENDFORM.
    *&---------------------------------------------------------------------*
    *& Form CONVERT_STRING_TO_XSTRING
    *&---------------------------------------------------------------------*
    * Convert sting to xstring
    *----------------------------------------------------------------------*
    FORM convert_string_to_xstring USING p_p_content TYPE string
    CHANGING p_p_xstring TYPE xstring.

    CALL FUNCTION 'SCMS_STRING_TO_XSTRING'
    EXPORTING
    text = p_p_content
    IMPORTING
    buffer = p_p_xstring
    EXCEPTIONS
    failed = 1
    OTHERS = 2.

    ENDFORM.
    *&---------------------------------------------------------------------*
    *& Form PARSE_XML_TO_TABLE
    *&---------------------------------------------------------------------*
    * Parse XML docment into a table structure
    *----------------------------------------------------------------------*
    FORM parse_xml_to_table USING p_p_xstring TYPE xstring
    CHANGING p_li_xml_table TYPE hrpayfr_t_smum_xmltb.

    DATA:
    li_return TYPE TABLE OF bapiret2.

    CALL FUNCTION 'SMUM_XML_PARSE'
    EXPORTING
    xml_input = p_p_xstring
    TABLES
    xml_table = p_li_xml_table
    return = li_return.

    ENDFORM.
    *&---------------------------------------------------------------------*
    *& Form CREATE_HTTP_CLIENT_DIRECTION
    *&---------------------------------------------------------------------*
    * Get Direction API
    *----------------------------------------------------------------------*
    FORM create_http_client_direction CHANGING p_http_client TYPE REF TO if_http_client.

    DATA: lv_http_url TYPE string.

    * Prepare the url for Directions API for the From Address Coordinates and To Address Coordinates
    CONCATENATE
    'http://maps.googleapis.com/maps/api/directions/xml?origin='
    <fs_dest>-place_f '|' <fs_dest>-lat_f ',' <fs_dest>-lng_f
    '&destination=' <fs_dest>-place_t '|' <fs_dest>-lat_t ',' <fs_dest>-lng_t
    '&alternatives=' 'true'
    INTO lv_http_url .

    CONDENSE lv_http_url.

    * Get client from url
    CALL METHOD cl_http_client=>create_by_url
    EXPORTING
    url = lv_http_url
    IMPORTING
    client = p_http_client
    EXCEPTIONS
    argument_not_found = 1
    plugin_not_active = 2
    internal_error = 3
    OTHERS = 4.

    ENDFORM.
    *&---------------------------------------------------------------------*
    *& Form CLEAN_XML_DATA
    *&---------------------------------------------------------------------*
    * Clean XML data to cleaner format
    *----------------------------------------------------------------------*
    FORM clean_xml_data USING p_li_xml_table TYPE hrpayfr_t_smum_xmltb.
    DATA:
    ls_xml TYPE smum_xmltb,
    ls_path TYPE ty_route.

    * Deleting time mentioned in the XML. If you want time, you need to
    * keep this and manipulate later
    DELETE p_li_xml_table WHERE cvalue CS 'min'.

    * Remove sub total for partial route. If you want time, you need to
    * keep this and manipulate later
    DELETE p_li_xml_table WHERE
    hier = '5' AND
    type = 'V' AND
    cname = 'text'.

    * Reading the XML data
    LOOP AT p_li_xml_table INTO ls_xml.

    AT FIRST.
    * First step is new route by default
    ls_path-route_n = abap_true.
    ENDAT.

    * Remove the XML format tag codes
    REPLACE ALL OCCURRENCES OF '<b>' IN ls_xml-cvalue WITH space.
    REPLACE ALL OCCURRENCES OF '</b>' IN ls_xml-cvalue WITH space.

    * Remove the XML format tag codes
    REPLACE ALL OCCURRENCES OF '<div style="font-size:0.9em">' IN ls_xml-cvalue WITH '.'.
    REPLACE ALL OCCURRENCES OF '</div>' IN ls_xml-cvalue WITH space.

    * Check the name
    CASE ls_xml-cname.

    * Get the summary of the route
    WHEN 'summary'.
    ls_path-summary = ls_xml-cvalue.

    * Driving instruction
    WHEN 'html_instructions'.
    ls_path-ins = ls_xml-cvalue.

    * Text would have the distance and unit
    WHEN 'text'.
    ls_path-dis = ls_xml-cvalue.

    * Copyrights means, start of new path
    WHEN 'copyrights'.

    ls_path-route_n = 'X'.
    CLEAR ls_path-step.

    WHEN OTHERS.
    * do nothing

    ENDCASE.

    * If there is some data, populate the route table
    IF ls_path-ins IS NOT INITIAL
    AND ls_path-dis IS NOT INITIAL.

    ls_path-step = ls_path-step + 1.

    * This will have the route details
    APPEND ls_path TO gt_route.

    CLEAR: ls_path-ins, ls_path-dis, ls_path-route_n, ls_path-summary.

    ENDIF.

    CLEAR: ls_xml.

    ENDLOOP.

    ENDFORM.
    *&---------------------------------------------------------------------*
    *& Form DISPLAY_TURN_BY_TURN_ROUTE
    *&---------------------------------------------------------------------*
    * Display Turn by Turn route
    *----------------------------------------------------------------------*
    FORM display_turn_by_turn_route .

    DATA:
    lr_alv TYPE REF TO cl_salv_table,
    lr_columns TYPE REF TO cl_salv_columns_table,
    lr_column TYPE REF TO cl_salv_column,
    lr_functions TYPE REF TO cl_salv_functions_list,
    lr_display TYPE REF TO cl_salv_display_settings,
    lr_layout TYPE REF TO cl_salv_layout,
    ls_key TYPE salv_s_layout_key,
    lr_sorts TYPE REF TO cl_salv_sorts.

    " Check to make sure the internal table has data.
    IF lines( gt_route ) > 0.

    TRY.
    * Create ALV instance
    * Use CALL METHOD since this is a static method
    CALL METHOD cl_salv_table=>factory
    IMPORTING
    r_salv_table = lr_alv
    CHANGING
    t_table = gt_route.

    * Get functions object and then set all the functions to be allowed
    lr_functions = lr_alv->get_functions( ).
    lr_functions->set_all( ).

    lr_columns = lr_alv->get_columns( ).

    CALL METHOD lr_columns->get_column
    EXPORTING
    columnname = 'ROUTE_N'
    RECEIVING
    value = lr_column.
    CALL METHOD lr_column->set_short_text
    EXPORTING
    value = ''.
    CALL METHOD lr_column->set_medium_text
    EXPORTING
    value = ''.
    CALL METHOD lr_column->set_long_text
    EXPORTING
    value = 'New Route Indicator'.

    CALL METHOD lr_columns->get_column
    EXPORTING
    columnname = 'SUMMARY'
    RECEIVING
    value = lr_column.
    CALL METHOD lr_column->set_short_text
    EXPORTING
    value = ''.
    CALL METHOD lr_column->set_medium_text
    EXPORTING
    value = ''.
    CALL METHOD lr_column->set_long_text
    EXPORTING
    value = 'Via'.

    CALL METHOD lr_columns->get_column
    EXPORTING
    columnname = 'STEP'
    RECEIVING
    value = lr_column.
    CALL METHOD lr_column->set_short_text
    EXPORTING
    value = ''.
    CALL METHOD lr_column->set_medium_text
    EXPORTING
    value = ''.
    CALL METHOD lr_column->set_long_text
    EXPORTING
    value = 'Important Turns'.

    CALL METHOD lr_columns->get_column
    EXPORTING
    columnname = 'INS'
    RECEIVING
    value = lr_column.
    CALL METHOD lr_column->set_short_text
    EXPORTING
    value = ''.
    CALL METHOD lr_column->set_medium_text
    EXPORTING
    value = ''.
    CALL METHOD lr_column->set_long_text
    EXPORTING
    value = 'Instructions'.

    CALL METHOD lr_columns->get_column
    EXPORTING
    columnname = 'DIS'
    RECEIVING
    value = lr_column.
    CALL METHOD lr_column->set_short_text
    EXPORTING
    value = ''.
    CALL METHOD lr_column->set_medium_text
    EXPORTING
    value = ''.
    CALL METHOD lr_column->set_long_text
    EXPORTING
    value = 'Distance'.

    lr_columns->set_optimize( ).

    * Set sort column
    lr_sorts = lr_alv->get_sorts( ).
    lr_sorts->clear( ).

    * This code is to get the layout, save the layout and display the layout
    lr_layout = lr_alv->get_layout( ).
    ls_key-report = sy-repid.
    lr_layout->set_key( ls_key ).
    lr_layout->set_default( ' ' ).
    lr_layout->set_save_restriction( cl_salv_layout=>restrict_none ).


    lr_display = lr_alv->get_display_settings( ).
    lr_display->set_striped_pattern( cl_salv_display_settings=>true ).

    * Now display the report as an ALV grid
    lr_alv->display( ).

    CATCH cx_salv_msg.
    WRITE: 'Error displaying grid CX_SALV_MSG!'(001).

    CATCH cx_salv_not_found.
    WRITE: 'Error displaying grid CX_SALV_NOT_FOUND!'(002).

    CATCH cx_salv_data_error.
    WRITE: 'Error displaying grid CX_SALV_DATA_ERROR!'(003).

    CATCH cx_salv_existing.
    WRITE: 'Error displaying grid CX_SALV_EXISTING!'(004).

    ENDTRY.

    ELSE.
    MESSAGE 'No route data to display' TYPE 'I'.
    LEAVE LIST-PROCESSING.

    ENDIF.

    ENDFORM.
    *&---------------------------------------------------------------------*
    *& Form SHOW_MAP
    *&---------------------------------------------------------------------*
    * Show direction on the map
    *----------------------------------------------------------------------*
    FORM show_map .

    DATA:
    lv_http_client TYPE REF TO if_http_client,
    lv_content TYPE string.

    LOOP AT gt_dest ASSIGNING <fs_dest>.

    * Call Browser
    PERFORM call_browser.

    EXIT.
    ENDLOOP.

    ENDFORM.
    *&---------------------------------------------------------------------*
    *& Form CALL_BROWSER
    *&---------------------------------------------------------------------*
    * Route map
    *----------------------------------------------------------------------*
    FORM call_browser.

    DATA: lv_url TYPE c LENGTH 255.

    * Prepare the url for Directions API for the From Address Coordinates and To Address Coordinates
    CONCATENATE
    'https://www.google.co.in/maps/dir/'
    <fs_dest>-lat_f ',' <fs_dest>-lng_f '/'
    <fs_dest>-lat_t ',' <fs_dest>-lng_t
    INTO lv_url .

    * Condense the text
    CONDENSE lv_url.

    * Open the route in browser
    CALL FUNCTION 'CALL_BROWSER'
    EXPORTING
    url = lv_url
    EXCEPTIONS
    frontend_not_supported = 1
    frontend_error = 2
    prog_not_found = 3
    no_batch = 4
    unspecified_error = 5
    OTHERS = 6.


    ENDFORM.

    YOU MAY BE INTERESTED IN

    Consuming APIs in SAP Applications

    SAP API Landscape

    SAP API Development: Bridging the Digital Divide

    Stream of data api

    SAP

    Get Latitude and Longitude of any place using Google Map API in SAP

    Before diving into the Get Latitude and Longitude of any place using Google Map API in SAP. Understand SAP shocks us consistently. Indeed, even in the wake of working for over 10 years, another undertaking or client will have a few prerequisites which are exceptional and you want out of the case thinking and arrangement. The beneath post is a comparable necessity where a client needed to realize the Geo Directions of some random spot. There are numerous ways of getting the Scopes and Longitudes however Kuldeep Joshi (who contributed this post), found an extremely helpful way by utilizing Google Guide Programming interface. He thought Google Guide is free and promptly accessible, so why not use it in SAP effortlessly.

    Check underneath, assuming the client enters any location, he ought to get the scope and longitude of that spot. Get Latitude and Longitude of any place using Google Map API in SAP.

    Geo Coordinates in SAP

    Isn’t it a cool requirement?

    How might we accomplish this?

    Straightforward, interface with Google Guide Administration (read Programming interface), examine through its substance string and track down your information. It needs some perusing the string, yet this is truly successful and simple arrangement.

    You can also read for:- Is Google using Oracle?

    Really take a look at this means (itemized code is accessible toward the finish of the article beneath)

    http_client

    Connect your feedback address with the Google Guides Programming interface web address to get the client information.

    Generate Google Map API path

    Demand the information. Really take a look at your cases (lower/upper) of the strategies (they may be case touchy).

    Get Method

    Send the request.

    Request service

    Get the reaction from Google Programming interface.

    Receive the request

    Presently, you have the string content. Simply glance through the string at the ideal locations and get the scope/longitude data.

    Geo Code from Google Map API

    <location> </location> are the opening and closing tag. We need to find the latitudes and longitudes in between these two tags.

    Similarly <lat> </lat> and <lng> </lng> are the opening and closing tags for Latitude and Longitude respectively.

    This is one illustration of the substance record got from Google Programming interface. Taking a gander at the information, it is extremely clear, where we can track down the directions.

    Google API

    Ideally, this post would assist you with tracking down the expected directions. In the following post would tell the best way to find the distance between two tends to involving Google Programming interface in SAP. Additionally, he would show, how to open the two tends to in research Guide and show the distance in the program. If it’s not too much trouble, remain tuned.

    Furthermore, our code not just works for India address, it works for any location on the planet. We should actually look at a location in USA.

    Coordinates in SAP ABAP

    You can approve the directions in Google Guide physically.

    Here is the code snippet used for this post.

    *-----------------------------------------------------------------------
    * Date : 07/05/2025
    * Author : Varad (For www.elearningsolutions.co.in)
    * Title : Get Latitude and Longitude of a place from Google API
    *-----------------------------------------------------------------------
    * Change History :
    * Author DATE REQUEST# DESCRIPTION
    *--------------- ---------- ----------- -------------------------------
    * varad 07/05/2025 Intial Development
    *-----------------------------------------------------------------------
    REPORT elearningsolutions_google_api NO STANDARD PAGE HEADING
    LINE-COUNT 132.
    *-----------------------------------------------------------------------
    * Title : Get Latitude and Longitude of a place from Google API
    *-----------------------------------------------------------------------
    * Change History :
    * Author DATE REQUEST# DESCRIPTION
    *--------------- ---------- ----------- ------------------------------- Intial Development
    *-----------------------------------------------------------------------
    *&---------------------------------------------------------------------*
    *& TYPE-POOLS
    *&---------------------------------------------------------------------*
    TYPE-POOLS: truxs, slis.
    *&---------------------------------------------------------------------*
    *& Selection Screen
    *&---------------------------------------------------------------------*
    PARAMETERS : p_add_f TYPE c LENGTH 50.


    *&---------------------------------------------------------------------*
    *& Types and Data
    *&---------------------------------------------------------------------*
    TYPES: BEGIN OF ty_dest,
    place_f TYPE c LENGTH 50,
    lat_f TYPE c LENGTH 20,
    lng_f TYPE c LENGTH 20,
    END OF ty_dest.

    DATA: gt_dest TYPE STANDARD TABLE OF ty_dest.


    *&---------------------------------------------------------------------*
    *& Start of Selection
    *&---------------------------------------------------------------------*
    START-OF-SELECTION .

    * Get longitude and latitude
    PERFORM get_long_lat.

    *&---------------------------------------------------------------------*
    *& End of Selection
    *&---------------------------------------------------------------------*
    END-OF-SELECTION .

    * Show Latitute and Longitude
    PERFORM display_lat_longitude.
    *&---------------------------------------------------------------------*
    *& Sub Routines
    *&---------------------------------------------------------------------*
    FORM get_long_lat .

    DATA:
    lv_http_client TYPE REF TO if_http_client,
    lv_content TYPE string.

    * Creation of new IF_HTTP_Client object
    PERFORM create_http_client CHANGING lv_http_client.

    * Request and Get
    PERFORM http_client_request_get_method USING lv_http_client.

    * Send the request
    PERFORM http_client_send USING lv_http_client.

    * Retrieve the result
    PERFORM http_client_receive USING lv_http_client CHANGING lv_content.

    * Get the actual coordinate using the content string
    PERFORM get_coordinates USING lv_content.


    ENDFORM. " get_long_lat
    *&---------------------------------------------------------------------*
    *& Form CREATE_HTTP_CLIENT
    *&---------------------------------------------------------------------*
    * Create HTTP Client
    *----------------------------------------------------------------------*
    FORM create_http_client CHANGING p_http_client TYPE REF TO if_http_client.

    DATA: lv_http_url TYPE string.

    * Prepare the url of the address
    CONCATENATE
    'http://maps.google.com/maps/api/geocode/xml?address='
    p_add_f
    INTO lv_http_url .

    * Get client from url
    CALL METHOD cl_http_client=>create_by_url
    EXPORTING
    url = lv_http_url
    IMPORTING
    client = p_http_client
    EXCEPTIONS
    argument_not_found = 1
    plugin_not_active = 2
    internal_error = 3
    OTHERS = 4.

    ENDFORM.
    *&---------------------------------------------------------------------*
    *& Form HTTP_CLIENT_REQUEST_GET_METHOD
    *&---------------------------------------------------------------------*
    * Request and Get Method
    *----------------------------------------------------------------------*
    FORM http_client_request_get_method USING p_http_client TYPE REF TO if_http_client..
    * Request and Get
    p_http_client->request->set_header_field( name = '~request_method' value = 'GET' ).
    ENDFORM.
    *&---------------------------------------------------------------------*
    *& Form HTTP_CLIENT_SEND
    *&---------------------------------------------------------------------*
    * Send request
    *----------------------------------------------------------------------*
    FORM http_client_send USING p_http_client TYPE REF TO if_http_client.
    * Send the request
    p_http_client->send( ).
    ENDFORM.
    *&---------------------------------------------------------------------*
    *& Form HTTP_CLIENT_RECEIVE
    *&---------------------------------------------------------------------*
    * Get the string content
    *----------------------------------------------------------------------*
    FORM http_client_receive USING p_http_client TYPE REF TO if_http_client
    CHANGING p_p_content TYPE string.
    * Reterive the result
    CALL METHOD p_http_client->receive
    EXCEPTIONS
    http_communication_failure = 1
    http_invalid_state = 2
    http_processing_failed = 3
    OTHERS = 4.
    p_p_content = p_http_client->response->get_cdata( ).

    ENDFORM.
    *&---------------------------------------------------------------------*
    *& Form GET_COORDINATES
    *&---------------------------------------------------------------------*
    * Get Latitute Longitude Coordinate
    *----------------------------------------------------------------------*
    FORM get_coordinates USING p_p_content TYPE string.

    * Local data declaration
    DATA: lv_url TYPE c LENGTH 255,
    ls_dest TYPE ty_dest,
    moff TYPE syst-tabix,
    moff1 TYPE syst-tabix,
    lv_len TYPE syst-tabix,
    lv_lat TYPE c LENGTH 20,
    lv_lng TYPE c LENGTH 20.

    *&---------------------------------------------------------------------*
    *& Processing string
    *&---------------------------------------------------------------------*
    DO .
    * Find <location> text in the content string
    FIND '<location>' IN SECTION OFFSET moff OF p_p_content IGNORING CASE MATCH OFFSET moff .

    IF sy-subrc = 0 .
    * <location> is a 10 character string, hence adding 10
    moff = moff + 10 .

    * Find closing tag </location> text in the content string
    FIND '</location>' IN SECTION OFFSET moff OF p_p_content IGNORING CASE MATCH OFFSET moff1 .

    * Find the length of string between tag <location> and </location>
    lv_len = moff1 - moff .

    * We have seen the API string contet, so we know <lat> </lat> <lng> </lng> are there between
    * <location> and </location>
    *--------------------------------------------------------------------*
    * ---------------Find latitude
    *--------------------------------------------------------------------*
    * Find string <lat>
    FIND '<lat>' IN SECTION OFFSET moff OF p_p_content IGNORING CASE MATCH OFFSET moff .
    IF sy-subrc = 0 .
    * <lat> is a 5 character string, hence adding 5
    moff = moff + 5 .

    * Find closing tag </lat> text in the content string
    FIND '</lat>' IN SECTION OFFSET moff OF p_p_content IGNORING CASE MATCH OFFSET moff1 .

    * Find the length of string between tag <lat> and </lat>
    lv_len = moff1 - moff .

    * Characters between <lat> </lat> will have the latitude coorniate
    lv_lat = p_p_content+moff(lv_len) .

    * From place address
    ls_dest-place_f = p_add_f .

    * Keep latitude in structure
    ls_dest-lat_f = lv_lat.

    ENDIF.

    *--------------------------------------------------------------------*
    * ---------------Find longitude
    *--------------------------------------------------------------------*
    * Find string <lng>
    FIND '<lng>' IN SECTION OFFSET moff OF p_p_content IGNORING CASE MATCH OFFSET moff .
    IF sy-subrc = 0 .

    * <lng> is a 5 character string, hence adding 5
    moff = moff + 5 .

    * Find closing tag </lng> text in the content string
    FIND '</lng>' IN SECTION OFFSET moff OF p_p_content IGNORING CASE MATCH OFFSET moff1 .

    * Find the length of string between tag <lng> and </lng>
    lv_len = moff1 - moff .

    * Characters between <lng> </lng> will have the latitude coorniate
    lv_lng = p_p_content+moff(lv_len) .

    * Keep longitude in structure
    ls_dest-lng_f = lv_lng.

    ENDIF.
    ELSE.

    EXIT.

    ENDIF.

    ENDDO .

    * Put in internal table to display later
    APPEND ls_dest TO gt_dest.
    CLEAR:ls_dest .

    ENDFORM.
    *&---------------------------------------------------------------------*
    *& Form DISPLAY_LAT_LONGITUDE
    *&---------------------------------------------------------------------*
    * Display Latitude and Longitude
    *----------------------------------------------------------------------*
    FORM display_lat_longitude .

    DATA:
    lr_alv TYPE REF TO cl_salv_table,
    lr_columns TYPE REF TO cl_salv_columns_table,
    lr_column TYPE REF TO cl_salv_column,
    lr_functions TYPE REF TO cl_salv_functions_list,
    lr_display TYPE REF TO cl_salv_display_settings,
    lr_layout TYPE REF TO cl_salv_layout,
    ls_key TYPE salv_s_layout_key,
    lr_sorts TYPE REF TO cl_salv_sorts.

    " Check to make sure the internal table has data.
    IF lines( gt_dest ) > 0.

    TRY.
    * Create ALV instance
    * Use CALL METHOD since this is a static method
    CALL METHOD cl_salv_table=>factory
    IMPORTING
    r_salv_table = lr_alv
    CHANGING
    t_table = gt_dest.

    * Get functions object and then set all the functions to be allowed
    lr_functions = lr_alv->get_functions( ).
    lr_functions->set_all( ).

    lr_columns = lr_alv->get_columns( ).

    CALL METHOD lr_columns->get_column
    EXPORTING
    columnname = 'PLACE_F'
    RECEIVING
    value = lr_column.
    CALL METHOD lr_column->set_short_text
    EXPORTING
    value = ''.
    CALL METHOD lr_column->set_medium_text
    EXPORTING
    value = ''.
    CALL METHOD lr_column->set_long_text
    EXPORTING
    value = 'Place Name'.

    CALL METHOD lr_columns->get_column
    EXPORTING
    columnname = 'LAT_F'
    RECEIVING
    value = lr_column.
    CALL METHOD lr_column->set_short_text
    EXPORTING
    value = ''.
    CALL METHOD lr_column->set_medium_text
    EXPORTING
    value = ''.
    CALL METHOD lr_column->set_long_text
    EXPORTING
    value = 'Latitude'.

    CALL METHOD lr_columns->get_column
    EXPORTING
    columnname = 'LNG_F'
    RECEIVING
    value = lr_column.
    CALL METHOD lr_column->set_short_text
    EXPORTING
    value = ''.
    CALL METHOD lr_column->set_medium_text
    EXPORTING
    value = ''.
    CALL METHOD lr_column->set_long_text
    EXPORTING
    value = 'Longitude'.


    lr_columns->set_optimize( ).

    * Set sort column
    lr_sorts = lr_alv->get_sorts( ).
    lr_sorts->clear( ).

    * This code is to get the layout, save the layout and display the layout
    lr_layout = lr_alv->get_layout( ).
    ls_key-report = sy-repid.
    lr_layout->set_key( ls_key ).
    lr_layout->set_default( ' ' ).
    lr_layout->set_save_restriction( cl_salv_layout=>restrict_none ).


    lr_display = lr_alv->get_display_settings( ).
    lr_display->set_striped_pattern( cl_salv_display_settings=>true ).

    * Now display the report as an ALV grid
    lr_alv->display( ).

    CATCH cx_salv_msg.
    WRITE: 'Error displaying grid CX_SALV_MSG!'(001).

    CATCH cx_salv_not_found.
    WRITE: 'Error displaying grid CX_SALV_NOT_FOUND!'(002).

    CATCH cx_salv_data_error.
    WRITE: 'Error displaying grid CX_SALV_DATA_ERROR!'(003).

    CATCH cx_salv_existing.
    WRITE: 'Error displaying grid CX_SALV_EXISTING!'(004).

    ENDTRY.

    ELSE.
    MESSAGE 'No data to display' TYPE 'I'.
    LEAVE LIST-PROCESSING.

    ENDIF.


    ENDFORM.

    If you have any desire to get such viable issues and goals directly to your inbox, kindly Buy in. We regard your security and treat safeguarding it in a serious way.

    YOU MAY LIKE THIS

    Building APIs with SAP Tools and Technologies

    A Deep Dive into the SAP API Hub

    API Documentation: A Comprehensive Guide to Seamless Integration

    API Integration: Bridging the Digital Divide

    × How can I help you?