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.
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.
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.
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
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.
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 Keys, oAuth 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’sSearch 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.
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.
We want to consume it inSAPto 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.
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.
* Method 2 METHOD http_client_request_get_method. * Request and Get ip_http_client->request->set_header_field( name = '~request_method' value = 'GET' ). ENDMETHOD.
* 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'.
*--------------------------------------------------------------------* * 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( ) .
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 inSAP 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.
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.
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 .
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 ).
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 ).
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 .
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.
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 .
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.
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 ).
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.
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.
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.
Really take a look at this means (itemized code is accessible toward the finish of the article beneath)
Connect your feedback address with the Google Guides Programming interface web address to get the client information.
Demand the information. Really take a look at your cases (lower/upper) of the strategies (they may be case touchy).
Send the request.
Get the reaction from Google Programming interface.
Presently, you have the string content. Simply glance through the string at the ideal locations and get the scope/longitude data.
<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.
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.
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 .
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 ).
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.
How to Show the ALV Output and the Selection Screen on the same Screen? Typically the ALV yield is shown in another screen. Not on a similar screen where you have the choice boundaries and select choices. In any case, at times client need to see what they input in the screen and what they get yield in the ALV in a similar screen. It simply assists them with performing better, report better and break down better. This prerequisite and situation isn’t new. We have answer for it from in those days in 2008.
On the off chance that the arrangement is as of now there, why again another article?
The previous arrangement gave utilizes SALV class “CL_SALV_TABLE”. We will utilize “CL_GUI_ALV_GRID” class because of its upgraded highlights.
Expectations (How to Show the ALV Output and the Selection Screen on the same Screen)
Choice Screen and ALV on A similar Screen.
Add a Button on the ALV Toolbar.
Handle Client Order.
For additional data on the use and working of the class CL_GUI_ALV_GRID, you can allude to the demo programs gave by SAP the name like “BCALV_GRID* “.
Sample programs provided by SAP on the usage of CL_GUI_ALV_GRID.
Output (How to Show the ALV Output and the Selection Screen on the same Screen)
Simple Selection Screen with one Select-Options S_CARRID of type SFLIGHT-CARRID
Below is the Final Output which the Client is Expecting.
Selection screen and ALV on same screen
Let’s Design
High Level Programming Paradigm:
All in all, pseudo code for this necessity.
The docking holder should be made in the introduction occasion.
ALV should be made on that docking holder.
Trade the Chose Result Table Information to ABAP Memory (this part we could do without. Yet, till we track down an improved arrangement, we should utilize it).
Import information from ABAP Memory and Produce the Result.
Global Data Declarations
CLASS lcl_report DEFINITION DEFERRED.
DATA: lo_report TYPE REF TO lcl_report. "Reference object of the local class
DATA: alv_container TYPE REF TO cl_gui_docking_container, "ALV Container
alv_grid TYPE REF TO cl_gui_alv_grid, "ALV Grid
layout TYPE lvc_s_layo. "Layout Options
DATA gv_carrid TYPE sflight-carrid. "Variable for Select-options declaration.
Selection Screen Declarations
SELECTION-SCREEN: BEGIN OF BLOCK block_1 WITH FRAME TITLE text-001.
SELECT-OPTIONS: s_carrid FOR gv_carrid.
SELECTION-SCREEN: END OF BLOCK block_1.
Local Class Definition
CLASS lcl_report DEFINITION .
PUBLIC SECTION.
DATA: gt_data TYPE STANDARD TABLE OF sflight.
METHODS :
get_data,
generate_output,
toolbar FOR EVENT toolbar OF cl_gui_alv_grid
IMPORTING e_object, "To add some buttons on the ALV toolbar
user_command FOR EVENT user_command OF cl_gui_alv_grid
IMPORTING e_ucomm.
ENDCLASS.
Local Class Implementation
Method: GET_DATA
CLASS lcl_report IMPLEMENTATION.
"Method Get Data
METHOD get_data.
* data selection
SELECT * FROM sflight
INTO TABLE me->gt_data
WHERE carrid IN s_carrid.
IF sy-dbcnt IS INITIAL.
MESSAGE s398(00) WITH 'No data selected'.
ENDIF.
*
* Export to memory
EXPORT data = me->gt_data TO MEMORY ID sy-cprog.
ENDMETHOD.
Method: GENERATE_OUTPUT
"Method generate_output
METHOD generate_output.
* Local data
DATA: variant TYPE disvariant.
DATA: repid TYPE sy-repid.
* Import output table from the memory and free afterwards
IMPORT data = me->gt_data FROM MEMORY ID sy-cprog.
FREE MEMORY ID sy-cprog.
*
* Only if there is some data
CHECK me->gt_data IS NOT INITIAL.
repid = sy-repid.
variant-report = sy-repid.
variant-username = sy-uname.
layout-zebra = 'X'.
CHECK alv_container IS INITIAL.
CREATE OBJECT alv_container
EXPORTING
repid = repid
dynnr = sy-dynnr
side = alv_container->dock_at_bottom
extension = 200.
CREATE OBJECT alv_grid
EXPORTING
i_parent = alv_container.
* ALV Specific. Data selection.
SET HANDLER : lo_report->toolbar FOR alv_grid.
SET HANDLER : lo_report->user_command FOR alv_grid.
CALL METHOD alv_grid->set_table_for_first_display
EXPORTING
is_layout = layout
is_variant = variant
i_save = 'U'
i_structure_name = 'SFLIGHT'
CHANGING
it_outtab = me->gt_data.
ENDMETHOD.
Method: TOOLBAR
In this technique, we will make one press button (similarly as an illustration of no usefulness), for instance, to save a record, on the off chance that we had made this ALV as editable.
"Method Tool-bar
METHOD toolbar.
DATA: lv_toolbar TYPE stb_button.
* Push Button "For Example SAVE
CLEAR lv_toolbar.
MOVE 'FC_SAVE' TO lv_toolbar-function. "Function Code
lv_toolbar-icon = icon_system_save. "Save Icon
MOVE 'Save'(100) TO lv_toolbar-text. "Push button Text
MOVE 'Save'(100) TO lv_toolbar-quickinfo. "Push button Quick-Info
MOVE space TO lv_toolbar-disabled. "Push button enabled
APPEND lv_toolbar TO e_object->mt_toolbar.
ENDMETHOD.
Method: USER_COMMAND
This strategy will be utilized to deal with every one of the orders given by the client, for instance assuming client push on the Save button we made above, and so on. I have kept this segment as clear, you can add the rationale as required.
In the event that you set the breakpoint at the above strategy and press the Save button on the ALV, the execution will stop. Kindly check the underneath screen capture:
User Command captured when clicked on “Save” button.
Finally, the Events of the program execution
INITIALIZATION.
* object for the report
CREATE OBJECT lo_report.
* generate output
lo_report->generate_output( ).
START-OF-SELECTION.
* Get data
lo_report->get_data( ).
Conclusion
In this blog entry we took in the nuts and bolts of making an ALV on the determination screen with the utilization of CL_GUI_ALV_GRID class.
On the off chance that you simply duplicate the above code scraps and glue it to your SE38 supervisor and actuate it. Very much like one of our sluggish editors. You will find the result like underneath. Indeed!! It is a functioning code. What’s more, you don’t have to configure any screen components.
For what reason did we have to utilize ABAP Memory when all information is there in the program and we are showing them in a similar program?
At the point when the program control arrives at the introduction occasion, all memory is invigorated and worldwide information is made FREE. After all everything ought to be instated in the introduction occasion. That is the occupation of the introduction occasion. Thusly, we must have the ALV information someplace to pull it back when we are in Instatement occasion. Presently you know why we had to take help of the ABAP Memory.
By and large, on the off chance that the necessity is to eliminate the entire ALV framework toolbar, it’s quite simple as it requires setting one field (no_toolbar) in format as ‘X’. Let’s dive into the Selective Handling of the Buttons in ALV Grid Toolbar.
Setting the no_toolbar would give the result as beneath. Kindly check, there is NO Toolbar in the ALV Result.
We can pass this design as bringing in boundary for strategy ‘set_table_for_first_display’.
Be that as it may, in the event of Article Arranged ALV, debilitating a few fastens and empowering some can get bit precarious.
The objective of this article is to give a comprehensive picture with regards to meeting this prerequisite and sort of make it a solitary complete perspective for all engineers who need some assistance on this point.
As displayed above, in design, there is a field to eliminate the entire toolbar and we have no simple method for handicapping only a couple of buttons from the toolbar list. Selective Handling of the Buttons in ALV Grid Toolbar.
However, every time it isn’t 1 or 0 100% of the time. Here and there, we really want a center way.
Handicapping of a portion of the buttons is a greater amount of the genuine prerequisite you will get in execution projects as ALV network toolbar is an exceptionally useful asset to use it for capabilities like arranging, sifting, trading information to yield and so on.
Yet, how to accomplish it?
OK!!! So the response to this is Occasion Controllers. That’s it!!! Presently on the off chance that you are a novice to Drain Improvement, the occasion overseer is finished in ALV report advancements. In this article, we will attempt to make sense of the ideas and subtleties of occasion overseers however much as could be expected so that regardless of whether you are a fresher, you ought to have the option to figure out it and effectively execute it.
On a significant level, this execution can be isolated into underneath steps:
Making of ALV Framework, Compartment (This item will be alluded from standard kinds given by SAP) and Occasion overseer protests (This article will allude to nearby class).
Meaning of Occasion Overseer class with the technique to deal with toolbar.
Execution of the strategy.
Setting of the occasion controller and its setting off components.
The primary arrangement is there in sync four so we will cover that at the last. Just to ensure you read the total article and figure out the general picture.
Presently prior to going any additionally we should initially get our ideas clear about occasions overseers.
Occasion overseers are strategies which get called once their separate occasions are set off.
This setting off should be possible by means of programming utilizing “raise_event” strategy for the network.
In the first place, we will make matrix variable concerning cl_gui_alv_grid. We would likewise require a compartment to consume this framework.
Now for event handling, we will create a local class lcl_event_handler in the program.
DATA gref_event_handler TYPE REF TO lcl_event_handler .
In the beneath neighborhood class we can make a technique that will deal with our toolbar handling. We acquainted two additional techniques purposefully with further explain our idea about occasion controllers.
Presently prior to going for execution, we will likewise perceive how we can set overseers for this strategy.
As referenced, to raise an occasion, we will set off occasions utilizing ‘raise_event’ strategy which will call handle_user_command from our neighborhood controller class. Further handling should be possible in this technique execution utilizing ‘ucomm’ boundary.
Aside from bringing the occasion up in our program with above strategy, a few unexpected occasions are remembered for standard SAP class CL_GUI_ALV_GRID.
Class CL_GUI_ALV_GRID will set off an occasion for toolbar inside through technique ‘SET_TABLE_FOR_FIRST_DISPLAY’ and we will deal with that brought occasion up in our nearby class strategy execution.
To show records in ALV we use strategy ‘SET_TABLE_FOR_FIRST_DISPLAY’ which calls technique ‘REFRESH_TABLE_DISPLAY’ which thusly calls strategy ‘SOFT_REFRESH_TABLE_DISPLAY’ that further calls strategy ‘SET_TOOLBAR’. This SET_TOOLBAR raises the occasion for toolbar taking care of.
We will deal with this occasion through our custom strategy.
Handle_toolbar strategy as e_object as bringing in boundary. Network toolbar data gets put away in table ‘e_object->mt_toolbar’. This data incorporates Capability, Symbol, Data, Kind of button, Cripple Banner and so on.
To handicap the button it is expected to alter this table ‘e_object->mt_toolbar’ with Cripple Banner with ‘X’. Comparatively to empower button which is crippled by Framework, this banner should be reset.
In beneath technique, we are handicapping not many buttons as well as empowering one button which was debilitating as a matter of course in the framework. Sections of this table will seem to be this.
Every one of the buttons with their data get put away in table ‘e_object->mt_toolbar’ as displayed underneath.
The end-product will look something like this.
In the event that you are a novice, underneath is the bit by bit process for you.
Create a program in t-code SE38.
Go to t-code SE80 and create a Screen. (Selective Handling of the Buttons in ALV Grid Toolbar)
Give the screen number.
Give a description and hit the Layout.
Click on the Custom Control and drag it across to the layout. (Selective Handling of the Buttons in ALV Grid Toolbar)
Give the Custom Control some name. We give it the name as CC_ALV. This name would be utilized in the program.
In the program, we have given similar name to customs control.
This finishes the screen and customs control plan. Presently we want to compose our program to deal with it.
Use the below program (at the bottom of this article) and activate your code.
Let’s test it.
OOPs.. we get no output.
What did we miss?
Since your ALV Custom Holder showed nothing. Let us take a quick trip and see the PBO PAI screen.
Uncomment the PBO and PAI modules and retest.
OOPs, again no output.
What did we miss now?
On the off chance that you take a gander at the program intently, the MODULE Show has not yet been characterized in that frame of mind on the screen.
Go to the screen and add the Presentation module in PBO.
Presently test it one final time. At last, you can see the ALV yield.
If you have any desire to analyze, when Occasion Overseers, you would see the underneath distinction.
Trust this article was adequately clear to explain how to utilize custom regulators and compartments. You currently know how to utilize the occasion controllers. Likewise, it ought to have given you enough knowledge to deal with the device bar fastens unequivocally.
Complete Code Snippet.
*&---------------------------------------------------------------------* *& Program to show ALV Grid Display with Some Toolbar buttons disabled * *&---------------------------------------------------------------------* REPORT ztest_alv_grid_test NO STANDARD PAGE HEADING LINE-SIZE 132 LINE-COUNT 65. *--------------------------------------------------------------------* * Tables *--------------------------------------------------------------------* TABLES : mara. *--------------------------------------------------------------------* * Types *--------------------------------------------------------------------* TYPES : BEGIN OF tty_mara, matnr TYPE matnr, ernam TYPE ernam, mtart TYPE mtart, matkl TYPE matkl, END OF tty_mara. *--------------------------------------------------------------------* * Data *--------------------------------------------------------------------* DATA : g_tab_mara TYPE STANDARD TABLE OF tty_mara. *--- Object for ALV grid DATA gref_alvgrid TYPE REF TO cl_gui_alv_grid . *--- Object for Custom container DATA gref_ccontainer TYPE REF TO cl_gui_custom_container . *--- Name of the custom control added on the screen CONSTANTS con_custom_control_name TYPE scrfname VALUE 'CC_ALV'. *--- Field catalog DATA g_tab_fieldcat TYPE lvc_t_fcat . *--- Field catalog structure DATA g_wa_fieldcat TYPE lvc_s_fcat . *----Layout DATA g_str_layout TYPE lvc_s_layo. *--- Event handler class CLASS lcl_event_handler DEFINITION DEFERRED. *--- Object for Event Handler DATA gref_event_handler TYPE REF TO lcl_event_handler . *--------------------------------------------------------------------* * Local Class Definition for Event Handler *--------------------------------------------------------------------* CLASS lcl_event_handler DEFINITION . PUBLIC SECTION . CLASS-DATA alv_err TYPE subrc. METHODS * Event handler for toolbar in alvgrid. handle_toolbar FOR EVENT toolbar OF cl_gui_alv_grid IMPORTING e_object. ENDCLASS. *--------------------------------------------------------------------* * Local Class Implementation for Event Handler *--------------------------------------------------------------------* CLASS lcl_event_handler IMPLEMENTATION . * Method for toolbar handling METHOD handle_toolbar.
DATA : l_wa_toolbar TYPE stb_button.
* Disabling some Buttons MOVE 'X' TO l_wa_toolbar-disabled. * This sets the data MODIFY e_object->mt_toolbar FROM l_wa_toolbar TRANSPORTING disabled WHERE function = '&DETAIL' OR function = '&MB_SUM' OR function = '&MB_VIEW' OR function = '&MB_SUBTOT' OR function = '&PRINT_BACK' OR function = '&COL0' OR function = '&GRAPH' OR function = '&INFO' OR function = '&REFRESH' OR function = '&LOCAL&CUT' OR function = '&LOCAL©' OR function = '&LOCAL&PASTE' OR function = '&LOCAL&UNDO' OR function = '&LOCAL&APPEND' OR function = '&LOCAL&INSERT_ROW' OR function = '&LOCAL&DELETE_ROW' OR function = '&LOCAL©_ROW' .
* Enabling some Buttons MOVE ' ' TO l_wa_toolbar-disabled. * This sets the data MODIFY e_object->mt_toolbar FROM l_wa_toolbar TRANSPORTING disabled WHERE function = '&FIND_MORE'.
ENDMETHOD. "handle_toolbar ENDCLASS .
*--------------------------------------------------------------------* * Selection Screen *--------------------------------------------------------------------* SELECTION-SCREEN BEGIN OF BLOCK bm WITH FRAME TITLE text-001. SELECT-OPTIONS : s_matnr FOR mara-matnr. SELECTION-SCREEN END OF BLOCK bm.
*--------------------------------------------------------------------* * Start of Selection *--------------------------------------------------------------------* START-OF-SELECTION. * Fetch data PERFORM get_testdatafordisplay.
*--------------------------------------------------------------------* * End of Selection *--------------------------------------------------------------------* END-OF-SELECTION. * Field Catalog PERFORM create_fieldcat CHANGING g_tab_fieldcat. * Layout PERFORM create_layout CHANGING g_str_layout. * Display Report PERFORM display_report.
*&---------------------------------------------------------------------* *& Form GET_TESTDATAFORDISPLAY *&---------------------------------------------------------------------* FORM get_testdatafordisplay . SELECT matnr ernam mtart matkl FROM mara INTO CORRESPONDING FIELDS OF TABLE g_tab_mara WHERE matnr IN s_matnr . ENDFORM. " GET_TESTDATAFORDISPLAY *&---------------------------------------------------------------------* *& Form CREATE_FIELDCAT *&---------------------------------------------------------------------* FORM create_fieldcat CHANGING c_tab_fieldcat TYPE lvc_t_fcat. DATA : ls_fcat TYPE lvc_s_fcat. ls_fcat-col_pos = 0. ls_fcat-fieldname = 'MATNR'. ls_fcat-coltext = 'Material Number'. ls_fcat-seltext = 'Material Number'. ls_fcat-col_opt = 'X'. APPEND ls_fcat TO c_tab_fieldcat. ls_fcat-col_pos = 1. ls_fcat-fieldname = 'ERNAM'. ls_fcat-coltext = 'Created By'. ls_fcat-seltext = 'Created By'. ls_fcat-col_opt = 'X'. APPEND ls_fcat TO c_tab_fieldcat. ls_fcat-col_pos = 2. ls_fcat-fieldname = 'MTART'. ls_fcat-coltext = 'Material Type'. ls_fcat-seltext = 'Material Type'. ls_fcat-col_opt = 'X'. APPEND ls_fcat TO c_tab_fieldcat. ls_fcat-col_pos = 3. ls_fcat-fieldname = 'MATKL'. ls_fcat-coltext = 'Material Group'. ls_fcat-seltext = 'Material Group'. ls_fcat-col_opt = 'X'. APPEND ls_fcat TO c_tab_fieldcat. ENDFORM. " CREATE_FIELDCAT *&---------------------------------------------------------------------* *& Form CREATE_LAYOUT *&---------------------------------------------------------------------* FORM create_layout CHANGING c_str_layout TYPE lvc_s_layo.. * c_str_layout-no_toolbar = 'X'. ENDFORM. " CREATE_LAYOUT
*&---------------------------------------------------------------------* *& Form DISPLAY_REPORT *&---------------------------------------------------------------------* FORM display_report . CALL SCREEN 100. ENDFORM. " DISPLAY_REPORT *&---------------------------------------------------------------------* *& Module USER_COMMAND_0100 INPUT *&---------------------------------------------------------------------* MODULE user_command_0100 INPUT. DATA: l_var_valid TYPE c, l_selected_cells TYPE STANDARD TABLE OF lvc_s_cell.
CASE sy-ucomm. WHEN 'EXIT' OR 'ENDE' or 'ECAN'. LEAVE PROGRAM. WHEN 'BACK' OR 'E'. LEAVE TO SCREEN 0. WHEN 'INS'. CALL METHOD gref_alvgrid->raise_event EXPORTING i_ucomm = 'INS'. WHEN 'DELETE'.
WHEN OTHERS. ENDCASE.
ENDMODULE. " DISPLAY OUTPUT *&---------------------------------------------------------------------* *& Module DISPLAY OUTPUT *&---------------------------------------------------------------------* MODULE display OUTPUT. PERFORM display_test_alv. ENDMODULE. " DISPLAY OUTPUT *&---------------------------------------------------------------------* *& Form DISPLAY_TEST_ALV *&---------------------------------------------------------------------* FORM display_test_alv . IF gref_alvgrid IS INITIAL . *----Creating custom container instance CREATE OBJECT gref_ccontainer EXPORTING container_name = con_custom_control_name EXCEPTIONS cntl_error = 1 cntl_system_error = 2 create_error = 3 lifetime_error = 4 lifetime_dynpro_dynpro_link = 5 OTHERS = 6. IF sy-subrc <> 0. *--Exception handling ENDIF. * checking instance existence, creating instance, setting for first display and refreshing *----Creating ALV Grid instance CREATE OBJECT gref_alvgrid EXPORTING i_parent = gref_ccontainer EXCEPTIONS error_cntl_create = 1 error_cntl_init = 2 error_cntl_link = 3 error_dp_create = 4 OTHERS = 5. IF sy-subrc <> 0. *--Exception handling ENDIF. *--Creating an instance for the event handler CREATE OBJECT gref_event_handler. SET HANDLER gref_event_handler->handle_toolbar FOR gref_alvgrid .
Let’s dive into the ALV Report On SAP HANA – Opportunities And Challenges. The HANA Tempest has been clearing everybody away. As of September 2017, SAP report guaranteed there were in excess of 1000 Clients currently live on S/4HANA. So tomorrow while possibly not today, all Professionals chipping away at SAP would need to swim through the HANA waters. Reducing the SAP Professionals to ABAPer, who program ALV Reports each and every other week. Have you thought about how fortunate or unfortunate it tends to be to plan an ALV in SAP with HANA as Suite as well as Data set? In this article, we would attempt to introduce stories from the two times, preceding HANA and in HANA.ALV Report On SAP HANA – Opportunities And Challenges!
ALV Reports are the Cockroaches of SAP world, which would survive every evolution.
Roots or Establishment or the Beginning point in ALV is same in HANA World as it was before in conventional data set, for example Choice SCREEN. Tragically, we will quite often make a few determinations when we see this. The screen needs to have checkboxes, radio buttons, choice screen blocks and so forth. This is miserable on the grounds that toward one side we see Fiori Platforms have dynamic and beautiful screens with applications upgrading Client Experience (UX) utilizing SAP UI5 and at the opposite end the customary ALV.
Rather cribbing about it, we want to recall that clients (actually) request ALV reports like standard T-Code yield for example ME2N (citing on the grounds that that was the prerequisite I got). Afterall everything isn’t about client experience. Complex business needs likewise get some weight.
Regardless, whether you are attempting to learn Fiori or SAPUI5, ALV reports can’t be supplanted. In this way, likewise begin investigating the new way you can make the ALVs.
How might we make our (ABAPers) lives merry and fascinating? Add HANA in with the general mish-mash and what you get is simpler to code (well not really) and all the more critically more prominent improvement in the exhibition.
The improvement in execution is exclusively credited to one thing that is the idea called “Code Push Down” or “Code to Information (Data set) Worldview”. Heard it anyplace? Try not to say No. We are at the twentieth part in our HANA ABAP Series.
What is Code Push Down? (ALV Report On SAP HANA – Opportunities And Challenges)
Here we have a tipping point. One can go for the strategy for utilizing Discs View alongside AMDP (if vital) or go with IDA. Utilizing IDA is much more straightforward than AMDP, yet possibly one can’t be a swap for the other. They play their own parts to play. In the following article, I will cover the distinctions and benefits of IDA against Albums.
Prior to looking down it would be smart to discover somewhat more about AMDP (ABAP Oversaw Data set System) and IDA (Coordinated Information Access).
So for ALV in HANA, we have the accompanying:
Selection Screen
Data is ready in CDS +/- AMDP
What next? Just connect them.
3. Applying selection screen criteria into CDS view entries.
The third step is a piece precarious. We again have various open doors here.
3.1 Either pass all the determination screen channels into AMDP ( NOT Compact discs View as a result of the way that Cds Perspectives are defined and can’t take more than one incentive for a solitary field and choice screen of the ALV report has select choices which are in range tables)
OR
3.2 Get every one of the passages from Compact discs View into your Application Layer and afterward continue with regular coding practice.
At this point, experienced ABAPers would agree that that first methodology (AMDP) would do every one of the positive qualities regarding execution.
Now we have narrowed down to:
Choice Screen
Information is prepared in Discs +/ – AMDP
Applying choice screen measures into Discs view sections utilizing AMDP and bringing just required passages into AS layer and continuing with regular SALV manufacturing plant class utilizing Oh no.
Conversion of SELECT-OPTIONS into Dynamic “WHERE CLAUSE”: When the standard determination screen is constructed, the main obstacle is incorporate the select choices into AMDP. To accomplish that we have the accompanying code piece:
DATA(lv_where) = cl_shdb_seltab=>combine_seltabs(
it_named_seltabs = VALUE #(
( name = 'MATNR' dref = REF #( so_matnr[] ) )
( name = 'EBELN' dref = REF #( so_ebeln[] ) )
) ).
Trust you can grasp the above code. Else, the beneath elective for a similar activity can assist you with bettering.
cl_shdb_seltab=>combine_seltabs(
EXPORTING
it_named_seltabs = VALUE #(
( name = 'MATNR' dref = REF #( so_matnr[] ) )
( name = 'EBELN' dref = REF #( so_ebeln[] ) )
)
RECEIVING
rv_where = DATA(lv_where) ).
2. Using Dynamic where clause in AMDP: The following test is to utilize the where condition. There is an element in SAP AS 7.40 and higher of “APPLY Channel”. The lv_where statement worked above is passed to AMDP technique boundary ip_filters.
Conclusion: ALV Report On SAP HANA – Opportunities And Challenges
Making the most of HANA DB and HANA instruments like HANA Studio we enjoy following benefits ( opportunity ):
Further developed Execution since there is Code Push Down and larger part of the Information bringing is finished at HANA DB alongside collections/total/midpoints.
On the Fly powerful custom naming of the Result Fields in ALV [can be finished utilizing CDS].
Dynamic SELECT questions in AMDP in light of the information given by Client and content put away in the DB [e.g. Assuming that in DB we have fields City and Country, we can utilize the CASE articulation to finish up assuming that input city given by the client is the capital or not].
Dispose of FOR ALL Sections. [Use Internal Joins instead]. Did we simply get into another sticky situation?
Can be extremely powerful for External Participate in situations where we really want to skirt the field esteems that are available in one table however NOT in other.
The opposite side of the story, challenges:
At the point when we go with Discs Perspectives to extricate information into AS layer, then, at that point, there might be still some presentation issues (despite the fact that Cds relics would in any case give great exhibitions, still some unacceptable utilization of Cds can blow up).
Kindly trust that the following article will get a brief look at the genuine code to exhibit all the abovementioned and IDA. Along these lines, if it’s not too much trouble, remain tuned and get yourself HANA-tized.
Now we want to hear from you.
Kindly leave your input, stories and speedy remarks beneath.