Technology Blogs by Members
Explore a vibrant mix of technical expertise, industry insights, and tech buzz in member blogs covering SAP products, technology, and events. Get in the mix!
cancel
Showing results for 
Search instead for 
Did you mean: 
dharmenda_kumar
Explorer

Introduction.


SAP Gateway has been known to all with its unique features. It provides the URL based link access to SAP backend business data. It can be used for CRUDQ (CREATE/ READ/UPDATE/DELETE/ QUERY) operations.

I am not going in details of it... to achieve the URL a SAP GATEWAY (GW) project is created in SAP backend system via T-code SEGW. Once the Project is create and generated the necessary service is registered to GW system (frontend) and the registered service with technical Service name can be used for accessing the URL for various entities for numerous operations.

The issue comes in the formation of the URL based on its complexity following navigation and expands. Another issue we face is the formation of the sample input JSON file as payload.

Main Part


The aim of blog to provide a simplified program which provides the list of possible URL for all entities of SAP GW project along with sample input JSON file for CREATE, DEEP INSERT and UPDATE operation as payload.

I have created a utility program which will generate URL for any gateway project and sample input JSON file.

Possible Actions by this program:

  1. Automatically generate the URL for all entity along with its navigation and Expands.

  2. Download the Generated URL into an excel

  3. Show sample Input JSON file for entity with CREATE/ DEEP INSERT and UPDATE operations.

  4. It handles multi nested entity for sample input JSON file and necessary date and time activity both in JSON file and URL as key or filter option.


Limitations:

  1. For filter based URL for QUERY filter parameters are selected only from properties of entity not from nested property (via complex type).

  2. Generation of Multi-Level navigation is not supported

  3. Generation of Batch Input URL is not supported

  4. Generation of Media type URL is not handled.(Next version)


 

Sample GW project: ZGW_DK_CTYPE


Details of the project with screenshot:























For the above project, the basic URL prefix will be as: "/sap/opu/odata/sap/ZGW_DK_CTYPE_SRV/"

Source code:


URL Generator ABAP code>>


Program Name >> ZDK_GW_URL-> Title as "Generate GW URL"
*&---------------------------------------------------------------------*
*& Report ZDK_GW_URL
*&
*&---------------------------------------------------------------------*
*&
*&
*&---------------------------------------------------------------------*

REPORT zdk_gw_url.
TABLES sscrfields.
TYPES : gtty_line TYPE STANDARD TABLE OF line.
TYPES: BEGIN OF gty_output,
entity TYPE /iwbep/med_entity_tech_name,
operation TYPE /iwfnd/med_mdl_operation,
method TYPE /iwbep/sbui_od_http_method,
url TYPE das_uri,
END OF gty_output,
gtty_output TYPE STANDARD TABLE OF gty_output.

DATA: gt_output TYPE gtty_output.

CLASS zcl_evt_handler DEFINITION DEFERRED.
DATA: go_evt TYPE REF TO zcl_evt_handler.
DATA: go_alv TYPE REF TO cl_salv_table.
DATA: gv_srv TYPE /iwbep/med_grp_technical_name.
DATA: gv_srvver TYPE /iwbep/med_grp_version.
DATA: gt_association TYPE /iwbep/if_mgw_med_odata_types=>ty_t_med_reference.
DATA: gt_associationset TYPE /iwbep/if_mgw_med_odata_types=>ty_t_med_reference.
DATA: gt_nav TYPE /iwbep/if_mgw_med_odata_types=>ty_t_med_reference.
DATA: go_project TYPE REF TO /iwbep/cl_sbdm_project.
DATA: go_model TYPE REF TO /iwbep/cl_mgw_odata_model.
* class declaration and implementation
CLASS zcl_evt_handler DEFINITION.
PUBLIC SECTION.
METHODS : handle_double_click FOR EVENT double_click OF cl_salv_events_table
IMPORTING row.
ENDCLASS. "zcl_evt_handler DEFINITION
*----------------------------------------------------------------------*
* CLASS zcl_evt_handler IMPLEMENTATION
*----------------------------------------------------------------------*
*
*----------------------------------------------------------------------*
CLASS zcl_evt_handler IMPLEMENTATION.
METHOD handle_double_click.
PERFORM handle_double_click USING row .
ENDMETHOD. "handle_event_app
ENDCLASS. "zcl_evt_handler IMPLEMENTATION
* selection screen
PARAMETERS : p_proj TYPE /iwbep/i_sbd_pr-project DEFAULT 'ZGW_DK_CTYPE' OBLIGATORY .
PARAMETERS : p_toxl AS CHECKBOX.
SELECTION-SCREEN: FUNCTION KEY 1.
*SELECTION-SCREEN: FUNCTION KEY 2.

INITIALIZATION.
PERFORM addon_btn.

AT SELECTION-SCREEN .
CASE sscrfields-ucomm.
WHEN 'FC01'.
PERFORM show_progam_help.
ENDCASE.

START-OF-SELECTION.
PERFORM get_project_inst.

END-OF-SELECTION.
PERFORM prepare_url_table.
* show alv
IF p_toxl IS NOT INITIAL.
PERFORM download_to_excel.
ENDIF.
PERFORM show_alv.
**********************************************************************
*&---------------------------------------------------------------------*
*& Form HANDLE_EVENT_APP
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* -->P_ROW text
* -->P_LT_ROWS text
*----------------------------------------------------------------------*
FORM handle_double_click USING iv_sel TYPE int4.
DATA: ls_output LIKE LINE OF gt_output.
READ TABLE gt_output INTO ls_output INDEX iv_sel.
IF sy-subrc IS NOT INITIAL OR ( ls_output-operation <> 'CREATE' AND ls_output-operation <> 'DEEP INSERT' AND ls_output-operation <> 'UPDATE' ).
MESSAGE 'Either no URL selected or selected URL must be CREATE/DEEP INSERT/UPDATE' TYPE 'S' DISPLAY LIKE 'E' .
RETURN.
ENDIF.
* no create the sample url table.
PERFORM prepare_sample_data_json USING ls_output.
ENDFORM. " HANDLE_EVENT_APP
*&---------------------------------------------------------------------*
*& Form DOWNLOAD_TO_EXCEL
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* -->P_GT_OUTPUT text
*----------------------------------------------------------------------*
FORM download_to_excel.
* download the data from gt_output into an excel .
* file save dialogue
DATA: filename TYPE string,
path TYPE string,
fullpath TYPE string.
CALL METHOD cl_gui_frontend_services=>file_save_dialog
EXPORTING
window_title = 'Save URL File' " Window Title
default_extension = '.xls' " Default Extension
default_file_name = p_proj && '_GW_URL'
file_filter = '(*.XLS,*.XLSX) *.XLS*' " File Type Filter Table
CHANGING
filename = filename " File Name to Save
path = path " Path to File
fullpath = fullpath " Path + File Name
EXCEPTIONS
cntl_error = 1
error_no_gui = 2
not_supported_by_gui = 3
invalid_default_file_name = 4.
IF sy-subrc <> 0.
MESSAGE 'File save cancelled' TYPE 'S' DISPLAY LIKE 'E'.
RETURN.
ENDIF.
* prepare the header
TYPES : BEGIN OF lty_heading,
fieldname TYPE char50,
END OF lty_heading.
DATA: lt_heading TYPE STANDARD TABLE OF lty_heading.

APPEND 'Entity' TO lt_heading.
APPEND 'Operation' TO lt_heading.
APPEND 'HTTP Method' TO lt_heading.
APPEND 'URL' TO lt_heading.


CALL METHOD cl_gui_frontend_services=>gui_download
EXPORTING
filename = fullpath
filetype = 'ASC'
write_field_separator = abap_true
fieldnames = lt_heading[]
CHANGING
data_tab = gt_output
EXCEPTIONS
file_write_error = 1
no_batch = 2
gui_refuse_filetransfer = 3
invalid_type = 4
no_authority = 5
unknown_error = 6
header_not_allowed = 7
separator_not_allowed = 8
filesize_not_allowed = 9
header_too_long = 10
dp_error_create = 11
dp_error_send = 12
dp_error_write = 13
unknown_dp_error = 14
access_denied = 15
dp_out_of_memory = 16
disk_full = 17
dp_timeout = 18
file_not_found = 19
dataprovider_exception = 20
control_flush_error = 21
not_supported_by_gui = 22
error_no_gui = 23
OTHERS = 24.
ENDFORM. " DOWNLOAD_TO_EXCEL
*&---------------------------------------------------------------------*
*& Form GET_PROJECT_INST
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM get_project_inst .
DATA: lv_proj TYPE /iwbep/i_sbd_pr-project,
lv_node TYPE /iwbep/i_sbd_pr-node_uuid.
CREATE OBJECT go_evt.
SELECT
project
node_uuid
FROM /iwbep/i_sbd_pr
UP TO 1 ROWS
INTO (lv_proj , lv_node )
WHERE project = p_proj.
ENDSELECT.
IF sy-subrc IS NOT INITIAL.
MESSAGE 'Project not available' TYPE 'S' DISPLAY LIKE 'E'.
LEAVE LIST-PROCESSING.
ENDIF.
TRY.
* --- Project is loaded for the first time
CREATE OBJECT go_project
EXPORTING
iv_project_name = lv_proj
iv_node_guid = lv_node.
* get model
DATA:lo_model_tech TYPE REF TO /iwbep/if_sbdm_model.
DATA: lv_model TYPE /iwbep/med_mdl_technical_name.
DATA: lv_version TYPE /iwbep/med_mdl_version.
lo_model_tech = go_project->/iwbep/if_sbdm_project~get_model( ).
lv_model = lo_model_tech->get_technical_model_name( ).
lv_version = lo_model_tech->get_model_version( ).
* get service name and its version
DATA: lo_srv_tech TYPE REF TO /iwbep/if_sbdm_service.
lo_srv_tech = go_project->/iwbep/if_sbdm_project~get_service( ).
gv_srv = lo_srv_tech->get_technical_service_name( ).
gv_srvver = lo_srv_tech->get_service_version( ).

DATA lr_med_provider TYPE REF TO /iwbep/if_mgw_med_provider.

lr_med_provider = /iwbep/cl_mgw_med_provider=>get_med_provider( ).
go_model ?= lr_med_provider->get_model(
iv_technical_name = lv_model
iv_version = lv_version
).
* get association list
gt_association = go_model->/iwbep/if_mgw_odata_re_model~get_associations( ).
gt_associationset = go_model->/iwbep/if_mgw_odata_re_model~get_association_sets( ).
* get navigation list.
gt_nav = go_model->/iwbep/if_mgw_odata_re_model~get_navigation_properties( ).
CATCH cx_root.
ENDTRY.
ENDFORM. " GET_PROJECT_INST
*&---------------------------------------------------------------------*
*& Form SHOW_ALV
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM show_alv .
TRY .
CALL METHOD cl_salv_table=>factory
IMPORTING
r_salv_table = go_alv "Basis Class Simple ALV Tables
CHANGING
t_table = gt_output.
* handle display setting
DATA: lo_dis TYPE REF TO cl_salv_display_settings.
lo_dis = go_alv->get_display_settings( ).
lo_dis->set_striped_pattern( abap_true ).
* lo_dis->set_horizontal_lines( abap_false ).
* handle coloums
DATA: lo_cols TYPE REF TO cl_salv_columns_table.
lo_cols = go_alv->get_columns( ).
lo_cols->set_optimize( abap_true ).
* handle specifi column
DATA: lo_col TYPE REF TO cl_salv_column.
lo_col ?= lo_cols->get_column( 'URL' ).
lo_col->set_output_length( 250 ).
lo_col->set_optimized( abap_false ).
* set toolbar
DATA: lo_func TYPE REF TO cl_salv_functions_list.
lo_func = go_alv->get_functions( ).
lo_func->set_default( abap_true ).
* go_alv->set_screen_status(
* pfstatus = 'ALV_BTNS' "copied from SAPLSLVC_FULLSCREEN, STANDARD_FULLSCREEN - remove save and add btns
* report = sy-repid ).
* set handler for event management
DATA: lo_event TYPE REF TO cl_salv_events_table.
lo_event = go_alv->get_event( ).
* SET HANDLER go_evt->on_user_command FOR lo_event.
SET HANDLER go_evt->handle_double_click FOR lo_event.
* set selection mode
DATA: lo_sel TYPE REF TO cl_salv_selections.
lo_sel = go_alv->get_selections( ).
lo_sel->set_selection_mode( if_salv_c_selection_mode=>single ).
MESSAGE 'Double Click to get the sample Input JSON file' TYPE 'S'.
* display
go_alv->display( ).
CATCH: cx_salv_msg, cx_salv_not_found. " ALV: General Error Class with Message
MESSAGE 'Error in displaying ALV' TYPE 'S' DISPLAY LIKE 'E'.
LEAVE LIST-PROCESSING.
ENDTRY.
ENDFORM. " SHOW_ALV
*&---------------------------------------------------------------------*
*& Form PREPARE_URL_TABLE
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM prepare_url_table .
DATA: ls_output TYPE gty_output.
FIELD-SYMBOLS: <lfs_output> TYPE gty_output.
DATA: ls_entity TYPE /iwbep/if_mgw_med_odata_types=>ty_s_med_entity_type.
DATA: lv_uri TYPE das_uri.
DATA: ls_setname LIKE LINE OF ls_entity-set_names.
DATA: ls_prop LIKE LINE OF ls_entity-properties.
DATA: lv_index TYPE syindex VALUE 0.
DATA: lv_svalue TYPE char30.
DATA: lc_svalue TYPE char15 VALUE '''XXXXXXXX'''.
DATA: lc_sdvalue TYPE char30 VALUE 'datetime''YYYY-MM-DDTHH:MM:SS'''.
DATA: lv_pattern TYPE string.
**********************************************************************
IF lines( go_model->mt_entities ) > 0.
APPEND 'Entity Operation URL' TO gt_output.
ENDIF.
**********************************************************************

* prepare the sample length of url
lv_uri = '/sap/opu/odata/sap/' && gv_srv && '/'.
LOOP AT go_model->mt_entities INTO ls_entity WHERE type = 'R'.
ls_output-entity = ls_entity-name.
* get the entity set name
READ TABLE ls_entity-set_names INTO ls_setname INDEX 1.
IF sy-subrc IS NOT INITIAL.
CONTINUE. " ie set name not found.. nothing can be done.
ENDIF.
DO 6 TIMES.
lv_index = 0. CLEAR lv_pattern.
CASE sy-index.
WHEN 1.
ls_output-operation = 'CREATE'.
ls_output-method = 'POST'.
ls_output-url = lv_uri && ls_setname.
WHEN 2.
ls_output-operation = 'DEEP INSERT'.
ls_output-method = 'POST'.
ls_output-url = lv_uri && ls_setname.
WHEN 3.
ls_output-operation = 'READ'.
ls_output-method = 'GET'.
ls_output-url = lv_uri && ls_setname.
* now add the properties
LOOP AT ls_entity-properties INTO ls_prop WHERE is_key = abap_true.
lv_svalue = lc_svalue.
IF ls_prop-core_type = 'Edm.DateTime'. " ie date time analysis >>datetime'2017-04-24T00:00:00'
lv_svalue = lc_sdvalue.
ENDIF.
IF lv_index >= 1. " ie more than one iteration.
lv_pattern = lv_pattern && ',' && ls_prop-external_name && '=' && lv_svalue.
ELSE.
lv_pattern = '(' && ls_prop-external_name && '=' && lv_svalue .
ENDIF.
lv_index = lv_index + 1.
ENDLOOP.
lv_pattern = lv_pattern && ')'.
IF lv_pattern IS NOT INITIAL.
ls_output-url = ls_output-url && lv_pattern.
CLEAR lv_pattern.
ENDIF.
WHEN 4.
ls_output-operation = 'UPDATE'.
ls_output-method = 'PUT'.
ls_output-url = lv_uri && ls_setname.
* now add the properties
LOOP AT ls_entity-properties INTO ls_prop WHERE is_key = abap_true.
lv_svalue = lc_svalue.
IF ls_prop-core_type = 'Edm.DateTime'. " ie date time analysis >>datetime'2017-04-24T00:00:00'
lv_svalue = lc_sdvalue.
ENDIF.
IF lv_index >= 1. " ie more than one iteration.
lv_pattern = lv_pattern && ',' && ls_prop-external_name && '=' && lv_svalue.
ELSE.
lv_pattern = '(' && ls_prop-external_name && '=' && lv_svalue .
ENDIF.
lv_index = lv_index + 1.
ENDLOOP.
lv_pattern = lv_pattern && ')'.
IF lv_pattern IS NOT INITIAL.
ls_output-url = ls_output-url && lv_pattern.
CLEAR lv_pattern.
ENDIF.
WHEN 5.
ls_output-operation = 'DELETE'.
ls_output-method = 'DELETE'.
ls_output-url = lv_uri && ls_setname.
* now add the properties
LOOP AT ls_entity-properties INTO ls_prop WHERE is_key = abap_true.
lv_svalue = lc_svalue.
IF ls_prop-core_type = 'Edm.DateTime'. " ie date time analysis >>datetime'2017-04-24T00:00:00'
lv_svalue = lc_sdvalue.
ENDIF.
IF lv_index >= 1. " ie more than one iteration.
lv_pattern = lv_pattern && ',' && ls_prop-external_name && '=' && lv_svalue.
ELSE.
lv_pattern = '(' && ls_prop-external_name && '=' && lv_svalue.
ENDIF.
lv_index = lv_index + 1.
ENDLOOP.
lv_pattern = lv_pattern && ')'.
IF lv_pattern IS NOT INITIAL.
ls_output-url = ls_output-url && lv_pattern.
CLEAR lv_pattern.
ENDIF.
WHEN 6.
ls_output-operation = 'QUERY'.
ls_output-method = 'GET'.
ls_output-url = lv_uri && ls_setname.
* ls_output-url = ls_output-url && '?$filter='.
* now add property for filter based on filter flag
LOOP AT ls_entity-properties INTO ls_prop WHERE filterable = abap_true.
lv_svalue = lc_svalue.
IF ls_prop-core_type = 'Edm.DateTime'. " ie date time analysis >>datetime'2017-04-24T00:00:00'
lv_svalue = lc_sdvalue.
ENDIF.
IF lv_index >= 1. " ie more than one iteration.
CONCATENATE lv_pattern 'and' ls_prop-external_name 'eq' lv_svalue INTO lv_pattern SEPARATED BY space.
* ls_output-url = ls_output-url && ' and' && ' ' && ls_prop-external_name && ' eq' && ' ' && lv_svalue .
ELSE.
CONCATENATE '?$filter=' ls_prop-external_name INTO lv_pattern. CONDENSE lv_pattern NO-GAPS.
CONCATENATE lv_pattern 'eq' lv_svalue INTO lv_pattern SEPARATED BY space.
* ls_output-url = ls_output-url && ls_prop-external_name && ' eq' && ' ' && lv_svalue.
ENDIF.
lv_index = lv_index + 1.
ENDLOOP.
IF lv_pattern IS NOT INITIAL.
ls_output-url = ls_output-url && lv_pattern.
CLEAR lv_pattern.
ENDIF.
* get the sorting sequence.
lv_index = 0. CLEAR lv_pattern.
LOOP AT ls_entity-properties INTO ls_prop WHERE sortable = abap_true.
IF lv_index >= 1.
lv_pattern = lv_pattern && ',' && ls_prop-external_name && ' desc'.
ELSE.
lv_pattern = '$orderby=' && ls_prop-external_name && ' desc'.
ENDIF.
lv_index = lv_index + 1.
ENDLOOP.
IF lv_pattern IS NOT INITIAL.
ls_output-url = ls_output-url && '&' && lv_pattern.
CLEAR lv_pattern.
ENDIF.
WHEN OTHERS.
ENDCASE.
APPEND ls_output TO gt_output.
ENDDO.
ENDLOOP.
* handle function import
**********************************************************************
IF lines( go_model->mt_operations ) > 0. " ie atleast 1 exist.
APPEND ' Function Import URL' TO gt_output.
ENDIF.
**********************************************************************
DATA: ls_operation LIKE LINE OF go_model->mt_operations.
LOOP AT go_model->mt_operations INTO ls_operation.
APPEND INITIAL LINE TO gt_output ASSIGNING <lfs_output>.
<lfs_output>-entity = ls_operation-name.
<lfs_output>-operation = 'Function Import'.
* get the http method
DATA: ls_annot LIKE LINE OF go_model->mt_private_annotations.
READ TABLE go_model->mt_private_annotations INTO ls_annot
WITH KEY entity_id-uuid = ls_operation-entity_id.
IF sy-subrc IS NOT INITIAL.
CONTINUE.
ENDIF.
DATA: ls_annot_valueset LIKE LINE OF ls_annot-annotations.
READ TABLE ls_annot-annotations INTO ls_annot_valueset INDEX 1.
IF sy-subrc IS NOT INITIAL.
CONTINUE.
ENDIF.
DATA: ls_annot_value LIKE LINE OF ls_annot_valueset-valueset.
READ TABLE ls_annot_valueset-valueset INTO ls_annot_value INDEX 1.
IF sy-subrc IS NOT INITIAL.
CONTINUE.
ENDIF.
<lfs_output>-method = ls_annot_value-value.
* get the importing parameter
READ TABLE go_model->mt_entities INTO ls_entity WITH KEY entity_id = ls_operation-input_node.
IF sy-subrc IS NOT INITIAL.
CONTINUE.
ENDIF.
* get the url
<lfs_output>-url = lv_uri && <lfs_output>-entity.
* get the import paramter
lv_index = 0. CLEAR lv_pattern.
LOOP AT ls_entity-properties INTO ls_prop.
lv_svalue = lc_svalue.
IF ls_prop-core_type = 'Edm.DateTime'. " ie date time analysis >>datetime'2017-04-24T00:00:00'
lv_svalue = lc_sdvalue.
ENDIF.
* ?CustomerId='2004009104'&ContractAccount=' '
IF lv_index >= 1.
lv_pattern = lv_pattern && '&' && ls_prop-external_name && '=' && lv_svalue.
ELSE.
lv_pattern = '?' && ls_prop-external_name && '=' && lv_svalue.
ENDIF.
lv_index = lv_index + 1.
ENDLOOP.
IF lv_pattern IS NOT INITIAL.
<lfs_output>-url = <lfs_output>-url && lv_pattern. CLEAR lv_pattern.
ENDIF.
ENDLOOP.
**********************************************************************
IF lines( gt_nav ) > 0.
APPEND 'Entity Navigation URL' TO gt_output.
ENDIF.
**********************************************************************
DATA: ls_nav LIKE LINE OF gt_nav.
SORT go_model->mt_entities BY entity_id.
LOOP AT gt_nav INTO ls_nav.
READ TABLE go_model->mt_entities INTO ls_entity WITH KEY entity_id = ls_nav-source_entity_id BINARY SEARCH.
IF sy-subrc IS NOT INITIAL.
CONTINUE.
ENDIF.
READ TABLE gt_output INTO ls_output WITH KEY entity = ls_entity-external_name operation = 'READ'.
IF sy-subrc IS NOT INITIAL.
CONTINUE.
ENDIF.
ls_output-operation = 'Navigation'.
ls_output-url = ls_output-url && '/' && ls_nav-external_name.
APPEND ls_output TO gt_output.
CLEAR ls_output .
ENDLOOP.

**********************************************************************
IF lines( gt_association ) > 0.
APPEND 'Entity Expand URL' TO gt_output.
ENDIF.
**********************************************************************
DATA: ls_association LIKE LINE OF gt_association.
* DATA: lv_index TYPE sytabix.
DATA: ls_entityt LIKE LINE OF go_model->mt_entities.
SORT gt_association BY source_entity_id.
LOOP AT go_model->mt_entities INTO ls_entity.
READ TABLE gt_association WITH KEY source_entity_id = ls_entity-entity_id BINARY SEARCH TRANSPORTING NO FIELDS.
IF sy-subrc IS NOT INITIAL.
CONTINUE.
ENDIF.
lv_index = sy-tabix.
lv_pattern = '?$expand='.
LOOP AT gt_association INTO ls_association FROM lv_index.
IF ls_association-source_entity_id <> ls_entity-entity_id.
ls_output-operation = 'Expand'.
IF lv_pattern IS NOT INITIAL.
ls_output-url = ls_output-url && lv_pattern.
APPEND ls_output TO gt_output.
CLEAR ls_output.
ENDIF.
CLEAR lv_pattern.
EXIT.
ENDIF.
READ TABLE gt_output INTO ls_output WITH KEY entity = ls_entity-external_name operation = 'READ'.
IF sy-subrc IS NOT INITIAL.
CONTINUE.
ENDIF.
READ TABLE go_model->mt_entities INTO ls_entityt WITH KEY entity_id = ls_association-target_entity_id BINARY SEARCH.
IF sy-subrc IS NOT INITIAL.
CONTINUE.
ENDIF.
READ TABLE ls_entityt-set_names INTO ls_setname INDEX 1.
IF sy-subrc IS INITIAL.
lv_pattern = lv_pattern && ls_setname.
ENDIF.
lv_pattern = lv_pattern && ','.
ENDLOOP.
IF lv_pattern IS NOT INITIAL.
ls_output-operation = 'Expand'.
ls_output-url = ls_output-url && lv_pattern.
APPEND ls_output TO gt_output.
CLEAR : ls_output, lv_pattern.
ENDIF.
ENDLOOP.
ENDFORM. " PREPARE_URL_TABLE
*&---------------------------------------------------------------------*
*& Form PREPARE_SAMPLE_DATA_JSON
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* -->P_LS_OUTPUT text
*----------------------------------------------------------------------*
FORM prepare_sample_data_json USING is_url TYPE gty_output.
DATA: lt_sample TYPE STANDARD TABLE OF line.
DATA: ls_entity LIKE LINE OF go_model->mt_entities.
DATA: ls_sample TYPE line.
READ TABLE go_model->mt_entities INTO ls_entity
WITH KEY external_name = is_url-entity.
IF sy-subrc IS NOT INITIAL.
MESSAGE 'Internal Error' TYPE 'S' DISPLAY LIKE 'E' .
RETURN.
ENDIF.
ls_sample-line = 'JSON File for "' && is_url-entity && '" for Operation "' && is_url-operation && '"'.
APPEND ls_sample TO lt_sample.
CASE is_url-operation.
WHEN 'CREATE' OR 'UPDATE'.
PERFORM gen_sample_per_entity USING ls_entity-entity_id 1 CHANGING lt_sample.
WHEN 'DEEP INSERT'.
PERFORM gen_deep_sample_per_entity USING ls_entity-entity_id 1 CHANGING lt_sample.
WHEN OTHERS.
ENDCASE.
PERFORM show_sample_data USING lt_sample.
ENDFORM. " PREPARE_SAMPLE_DATA_JSON
*&---------------------------------------------------------------------*
*& Form SHOW_SAMPLE_DATA
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* -->P_LT_SAMPLE text
*----------------------------------------------------------------------*
FORM show_sample_data USING it_sample TYPE gtty_line.
DATA: ls_hinfo TYPE help_info.
DATA: excludefun TYPE STANDARD TABLE OF syucomm.
DATA: lt_lines TYPE STANDARD TABLE OF tline.
DATA: ls_line TYPE tline.
APPEND '%SC' TO excludefun.
APPEND 'DPRB' TO excludefun.
APPEND 'ERHI' TO excludefun.
APPEND 'DINF' TO excludefun.
APPEND 'VPFL' TO excludefun.
APPEND 'DWFL' TO excludefun.
APPEND 'DBAC' TO excludefun.
APPEND 'DTRA' TO excludefun.
APPEND 'DMAI' TO excludefun.
APPEND 'DPRI' TO excludefun.
DATA: ls_sample TYPE line.
LOOP AT it_sample INTO ls_sample.
ls_line-tdformat = '/'.
ls_line-tdline = ls_sample.
APPEND ls_line TO lt_lines.
ENDLOOP.
CALL FUNCTION 'HELP_DOCULINES_SHOW'
EXPORTING
cucol = 2
curow = 1
help_infos = ls_hinfo
TABLES
excludefun = excludefun " Single-Character Flag
helplines = lt_lines. " Single-Character Flag
* DATA : lo_alv TYPE REF TO cl_salv_table.
* TRY .
* CALL METHOD cl_salv_table=>factory
* IMPORTING
* r_salv_table = lo_alv "Basis Class Simple ALV Tables
* CHANGING
* t_table = it_sample.
** set the pop up for screen
* lo_alv->set_screen_popup(
* EXPORTING
* start_column = 5
* start_line = 2
* ).
** handle display setting
* DATA: lo_dis TYPE REF TO cl_salv_display_settings.
* lo_dis = lo_alv->get_display_settings( ).
* lo_dis->set_horizontal_lines( abap_false ).
** handle coloums
* DATA: lo_cols TYPE REF TO cl_salv_columns_table.
* lo_cols = lo_alv->get_columns( ).
* lo_cols->set_optimize( abap_true ).
*** handle specifi column
* DATA: lo_col TYPE REF TO cl_salv_column.
* lo_col ?= lo_cols->get_column( 'LINE' ).
* lo_col->set_zero( abap_true ).
* lo_alv->display( ).
* CATCH: cx_salv_msg, cx_salv_not_found. " ALV: General Error Class with Message
* MESSAGE 'Error in displaying ALV' TYPE 'S' DISPLAY LIKE 'E'.
* RETURN.
* ENDTRY.
ENDFORM. " SHOW_SAMPLE_DATA
*&---------------------------------------------------------------------*
*& Form ADD_TABS
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* -->P_LV_TAB text
* <--P_LS_SAMPLE text
*----------------------------------------------------------------------*
FORM add_tabs USING iv_tab TYPE int4
CHANGING cs_sample TYPE line.
* CONSTANTS : lc_tab TYPE char4 VALUE ' '.
CONSTANTS : lc_tab TYPE char4 VALUE ' '.
DO iv_tab TIMES.
CONCATENATE lc_tab cs_sample-line INTO cs_sample-line RESPECTING BLANKS.
ENDDO.
ENDFORM. " ADD_TABS
*&---------------------------------------------------------------------*
*& Form PERPARE_SAMPLE_LINE
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* -->P_LS_PROP text
* <--P_LS_SAMPLE text
*----------------------------------------------------------------------*
FORM perpare_sample_line USING is_prop TYPE /iwbep/if_mgw_med_odata_types=>ty_s_med_property
CHANGING cs_sample TYPE line.
DATA: lv_svalue TYPE string VALUE 'XXXXXXXX'.
CASE is_prop-core_type.
WHEN 'Edm.String'.
PERFORM prepare_sample_value USING is_prop-length CHANGING lv_svalue.
WHEN 'Edm.DateTime'.
PERFORM prepare_date_sample_value CHANGING lv_svalue.
WHEN OTHERS.
PERFORM prepare_sample_value USING is_prop-length CHANGING lv_svalue.
ENDCASE.
cs_sample-line = '"' && is_prop-external_name && '" : "' && lv_svalue && '"'.
ENDFORM. " PERPARE_SAMPLE_LINE
*&---------------------------------------------------------------------*
*& Form REMOVE_LAST_LINE_COMMA
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* <--P_LT_SAMPLE text
*----------------------------------------------------------------------*
FORM remove_last_line_comma CHANGING ct_sample TYPE gtty_line.
DATA: lv_index TYPE int4.
FIELD-SYMBOLS: <lfs_sample> TYPE line.
lv_index = lines( ct_sample ).
READ TABLE ct_sample ASSIGNING <lfs_sample> INDEX lv_index.
IF sy-subrc IS INITIAL.
lv_index = strlen( <lfs_sample> ) - 1.
<lfs_sample> = <lfs_sample>+0(lv_index).
ENDIF.
ENDFORM. " REMOVE_LAST_LINE_COMMA
*&---------------------------------------------------------------------*
*& Form add_last_line_comma
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* -->CT_SAMPLE text
*----------------------------------------------------------------------*
FORM add_last_line_comma CHANGING ct_sample TYPE gtty_line.
DATA: lv_index TYPE int4.
FIELD-SYMBOLS: <lfs_sample> TYPE line.
lv_index = lines( ct_sample ).
READ TABLE ct_sample ASSIGNING <lfs_sample> INDEX lv_index.
IF sy-subrc IS INITIAL.
<lfs_sample>-line = <lfs_sample>-line && ','.
ENDIF.
ENDFORM. " REMOVE_LAST_LINE_COMMA
*&---------------------------------------------------------------------*
*& Form ADD_NESTED_LINE
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* -->P_LS_ENTITY_EXTERNAL_NAME text
* <--P_LS_SAMPLE text
*----------------------------------------------------------------------*
FORM add_nested_line USING iv_external_name TYPE /iwbep/med_external_name
CHANGING cs_sample TYPE line.
cs_sample-line = '"' && iv_external_name && '" : {'.
ENDFORM. " ADD_NESTED_LINE
*&---------------------------------------------------------------------*
*& Form ADD_NESTED_LINES
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* -->P_LT_REF text
* <--P_LT_SAMPLE text
* <--P_LV_INDEX text
*----------------------------------------------------------------------*
FORM add_nested_lines USING it_ref TYPE /iwbep/if_mgw_med_odata_types=>ty_t_med_reference
is_ref1 TYPE /iwbep/if_mgw_med_odata_types=>ty_s_med_reference
iv_index TYPE syindex
iv_tab TYPE int4
CHANGING ct_sample TYPE gtty_line.
DATA: ls_ref LIKE LINE OF it_ref.
DATA: ls_ref1 LIKE LINE OF it_ref.
DATA: ls_entity LIKE LINE OF go_model->mt_entities.
DATA: ls_sample TYPE line.
DATA: ls_prop LIKE LINE OF ls_entity-properties.
DATA: lv_tab TYPE int4.
DATA: lv_index TYPE syindex.
LOOP AT it_ref INTO ls_ref FROM iv_index. " this process needs to be iterated in case deep nesting.
IF NOT ( ls_ref-source_entity_id = is_ref1-source_entity_id AND ls_ref-reference_type = 'X' ).
EXIT.
ENDIF.
READ TABLE go_model->mt_entities INTO ls_entity WITH KEY entity_id = ls_ref-target_entity_id.
IF sy-subrc IS NOT INITIAL.
CONTINUE.
ENDIF.
PERFORM add_nested_line USING ls_ref-external_name CHANGING ls_sample.
lv_tab = iv_tab - 1.
PERFORM add_tabs USING lv_tab CHANGING ls_sample.
APPEND ls_sample TO ct_sample.
LOOP AT ls_entity-properties INTO ls_prop.
PERFORM perpare_sample_line USING ls_prop CHANGING ls_sample.
PERFORM add_tabs USING iv_tab CHANGING ls_sample.
ls_sample-line = ls_sample-line && ','.
APPEND ls_sample TO ct_sample.
ENDLOOP.
* at the end of adding properties check if any nested item is there or not..
* check if there is additional lines to it.. as nested info
READ TABLE it_ref INTO ls_ref1 WITH KEY source_entity_id = ls_entity-entity_id reference_type = 'X' BINARY SEARCH.
IF sy-subrc IS NOT INITIAL." no more nested so just remove the last comma.
PERFORM remove_last_line_comma CHANGING ct_sample.
ELSE.
lv_index = sy-tabix.
lv_tab = iv_tab + 1.
PERFORM add_nested_lines USING it_ref ls_ref1 lv_index lv_tab CHANGING ct_sample.
* at the end of all nested entity.. remove the last comma.
PERFORM remove_last_line_comma CHANGING ct_sample.
ENDIF.
* PERFORM remove_last_line_comma CHANGING ct_sample.
ls_sample-line = '},'.
PERFORM add_tabs USING iv_tab CHANGING ls_sample.
APPEND ls_sample TO ct_sample.
ENDLOOP.
ENDFORM. " ADD_NESTED_LINES
*&---------------------------------------------------------------------*
*& Form GEN_SAMPLE_PER_ENTITY
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* -->P_IS_URL_ENTITY text
* -->P_LV_TAB text
*----------------------------------------------------------------------*
FORM gen_sample_per_entity USING iv_entity_id TYPE /iwbep/med_entity_id
iv_tab TYPE sytabix
CHANGING ct_sample TYPE gtty_line.
DATA: ls_sample TYPE line.
DATA: ls_sample1 TYPE line.
DATA: lt_ref TYPE /iwbep/if_mgw_med_odata_types=>ty_t_med_reference.
DATA: ls_ref1 LIKE LINE OF lt_ref.
DATA: ls_ref LIKE LINE OF lt_ref.
DATA: ls_entity LIKE LINE OF go_model->mt_entities.
DATA: ls_prop LIKE LINE OF ls_entity-properties.
* CONSTANTS : lc_tab TYPE char4 VALUE ' '.
DATA: lc_svalue TYPE char15 VALUE 'XXXXXXXX'.
DATA: lv_index TYPE int4.
DATA: lv_tab TYPE syindex.
lv_tab = iv_tab.
* get the ref.
lt_ref = go_model->mt_references.
SORT lt_ref BY source_entity_id reference_type.
IF iv_tab = 1.
PERFORM prep_open_close_box USING '{' 1 CHANGING ct_sample.
ENDIF.
READ TABLE go_model->mt_entities INTO ls_entity
WITH KEY entity_id = iv_entity_id.
IF sy-subrc IS NOT INITIAL.
RETURN.
ENDIF.
* begin of sample data creation
LOOP AT ls_entity-properties INTO ls_prop.
* IF ls_prop-is_key = abap_true. " do not put key in the sample input file.
* CONTINUE.
* ENDIF.
PERFORM perpare_sample_line USING ls_prop CHANGING ls_sample.
* concatenate the data with tabs
PERFORM add_tabs USING lv_tab CHANGING ls_sample.

ls_sample-line = ls_sample-line && ','.
APPEND ls_sample TO ct_sample.
CLEAR : ls_sample.
ENDLOOP.
* check if there is additional lines to it.. as nested info
READ TABLE lt_ref INTO ls_ref1 WITH KEY source_entity_id = ls_entity-entity_id reference_type = 'X' BINARY SEARCH.
IF sy-subrc IS NOT INITIAL." no more nested so just remove the last comma.
PERFORM remove_last_line_comma CHANGING ct_sample.
ELSE.
lv_index = sy-tabix.
lv_tab = lv_tab + 1." nested line possible
LOOP AT lt_ref INTO ls_ref FROM lv_index. " this process needs to be iterated in case deep nesting.
IF NOT ( ls_ref-source_entity_id = ls_ref1-source_entity_id AND ls_ref-reference_type = 'X' ).
EXIT.
ENDIF.
* DATA: lv_entity TYPE /iwbep/med_entity_tech_name.
* lv_entity = ls_ref-target_entity_id.
PERFORM add_nested_line USING ls_ref-external_name CHANGING ls_sample.
* lv_tab = iv_tab - 1.
PERFORM add_tabs USING iv_tab CHANGING ls_sample.
APPEND ls_sample TO ct_sample.
PERFORM gen_sample_per_entity USING ls_ref-target_entity_id lv_tab
CHANGING ct_sample .
PERFORM add_last_line_comma CHANGING ct_sample.
ENDLOOP.

* PERFORM add_nested_lines USING lt_ref ls_ref1 lv_index lv_tab CHANGING ct_sample.

* at the end of all nested entity.. remove the last comma.
PERFORM remove_last_line_comma CHANGING ct_sample.
ENDIF.
PERFORM prep_open_close_box USING '}' iv_tab CHANGING ct_sample.
ENDFORM. " GEN_SAMPLE_PER_ENTITY
*&---------------------------------------------------------------------*
*& Form PREP_OPEN_CLOSE_BOX
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* -->P_2253 text
* -->P_IV_TAB text
* <--P_CT_SAMPLE text
*----------------------------------------------------------------------*
FORM prep_open_close_box USING iv_pattern TYPE char1
iv_tab TYPE sytabix
CHANGING ct_sample TYPE gtty_line.
DATA: ls_sample TYPE line.
ls_sample-line = iv_pattern.
DATA: lv_tab TYPE sytabix.
lv_tab = iv_tab - 1.
PERFORM add_tabs USING lv_tab CHANGING ls_sample.
APPEND ls_sample TO ct_sample.
ENDFORM. " PREP_OPEN_CLOSE_BOX
*&---------------------------------------------------------------------*
*& Form GEN_DEEP_SAMPLE_PER_ENTITY
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* -->P_LS_ENTITY_ENTITY_ID text
* -->P_1 text
* <--P_LT_SAMPLE text
*----------------------------------------------------------------------*
FORM gen_deep_sample_per_entity USING iv_entity_id TYPE /iwbep/med_entity_id
iv_tab TYPE sytabix
CHANGING ct_sample TYPE gtty_line.
DATA: ls_sample TYPE line.
DATA: ls_sample1 TYPE line.
DATA: lt_ref TYPE /iwbep/if_mgw_med_odata_types=>ty_t_med_reference.
DATA: ls_ref1 LIKE LINE OF lt_ref.
DATA: ls_ref LIKE LINE OF lt_ref.
DATA: ls_entity LIKE LINE OF go_model->mt_entities.
DATA: ls_prop LIKE LINE OF ls_entity-properties.
* CONSTANTS : lc_tab TYPE char4 VALUE ' '.
DATA: lc_svalue TYPE char15 VALUE 'XXXXXXXX'.
DATA: lv_index TYPE int4.
DATA: lv_tab TYPE syindex.
lv_tab = iv_tab.
* get the ref.
lt_ref = go_model->mt_references.
SORT lt_ref BY source_entity_id reference_type.
IF iv_tab = 1.
PERFORM prep_open_close_box USING '{' 1 CHANGING ct_sample.
ENDIF.
READ TABLE go_model->mt_entities INTO ls_entity
WITH KEY entity_id = iv_entity_id.
IF sy-subrc IS NOT INITIAL.
RETURN.
ENDIF.
* begin of sample data creation
LOOP AT ls_entity-properties INTO ls_prop.
IF ls_prop-is_key = abap_true. " do not put key in the sample input file.
CONTINUE.
ENDIF.
PERFORM perpare_sample_line USING ls_prop CHANGING ls_sample.
* concatenate the data with tabs
PERFORM add_tabs USING lv_tab CHANGING ls_sample.

ls_sample-line = ls_sample-line && ','.
APPEND ls_sample TO ct_sample.
CLEAR : ls_sample.
ENDLOOP.
* check if there is additional lines to it.. as nested info
READ TABLE lt_ref INTO ls_ref1 WITH KEY source_entity_id = ls_entity-entity_id reference_type = 'X' BINARY SEARCH.
IF sy-subrc IS NOT INITIAL." no more nested so just remove the last comma.
* PERFORM remove_last_line_comma CHANGING ct_sample.
ELSE.
lv_index = sy-tabix.
lv_tab = lv_tab + 1." nested line possible
LOOP AT lt_ref INTO ls_ref FROM lv_index. " this process needs to be iterated in case deep nesting.
IF NOT ( ls_ref-source_entity_id = ls_ref1-source_entity_id AND ls_ref-reference_type = 'X' ).
EXIT.
ENDIF.
PERFORM add_nested_line USING ls_ref-external_name CHANGING ls_sample.
PERFORM add_tabs USING iv_tab CHANGING ls_sample.
APPEND ls_sample TO ct_sample.
PERFORM gen_sample_per_entity USING ls_ref-target_entity_id lv_tab
CHANGING ct_sample .
ENDLOOP.
PERFORM add_last_line_comma CHANGING ct_sample.
ENDIF.
**********************************************************************
* check for the association
DATA: ls_association LIKE LINE OF gt_association.
DATA : lv_entityset TYPE /iwbep/med_external_name.
LOOP AT gt_association INTO ls_association WHERE source_entity_id = iv_entity_id.
* check if the cardinality
IF ls_association-target_card = 'M' OR ls_association-target_card = 'N'." ie multiline.
PERFORM get_enity_set_name USING ls_association-target_entity_id CHANGING lv_entityset.
ls_sample-line = '"' && lv_entityset && '" :'.
PERFORM add_tabs USING iv_tab CHANGING ls_sample.
APPEND ls_sample TO ct_sample.
lv_tab = iv_tab + 1.
PERFORM prep_open_close_box USING '[' lv_tab CHANGING ct_sample.
DO 2 TIMES. " for multiline populate 2 recrods
PERFORM prep_open_close_box USING '{' lv_tab CHANGING ct_sample.
PERFORM gen_sample_per_entity USING ls_association-target_entity_id lv_tab
CHANGING ct_sample .
PERFORM add_last_line_comma CHANGING ct_sample.
ENDDO.
PERFORM remove_last_line_comma CHANGING ct_sample.
PERFORM prep_open_close_box USING ']' lv_tab CHANGING ct_sample.
ELSE. "single line ie one entry only in the file.
PERFORM get_enity_set_name USING ls_association-target_entity_id CHANGING lv_entityset.
PERFORM add_nested_line USING lv_entityset CHANGING ls_sample.
PERFORM add_tabs USING iv_tab CHANGING ls_sample.
APPEND ls_sample TO ct_sample.
lv_tab = iv_tab + 1.
PERFORM gen_sample_per_entity USING ls_association-target_entity_id lv_tab
CHANGING ct_sample .
ENDIF.
PERFORM add_last_line_comma CHANGING ct_sample.
ENDLOOP.
**********************************************************************
PERFORM remove_last_line_comma CHANGING ct_sample.
PERFORM prep_open_close_box USING '}' iv_tab CHANGING ct_sample.
ENDFORM. " GEN_DEEP_SAMPLE_PER_ENTITY
*&---------------------------------------------------------------------*
*& Form GET_ENITY_SET_NAME
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* <--P_LV_ENTITYSET text
*----------------------------------------------------------------------*
FORM get_enity_set_name USING iv_entity_id TYPE /iwbep/med_entity_id
CHANGING cv_entityset TYPE /iwbep/med_external_name.
DATA: ls_entity LIKE LINE OF go_model->mt_entities.
READ TABLE go_model->mt_entities INTO ls_entity
WITH KEY entity_id = iv_entity_id.
IF sy-subrc IS INITIAL.
READ TABLE ls_entity-set_names INTO cv_entityset INDEX 1.
ENDIF.
ENDFORM. " GET_ENITY_SET_NAME
*&---------------------------------------------------------------------*
*& Form PREPARE_SAMPLE_VALUE
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* -->P_LS_PROP_LENGTH text
* <--P_LV_SVALUE text
*----------------------------------------------------------------------*
FORM prepare_sample_value USING iv_length TYPE int4
CHANGING cv_svalue TYPE string.
CLEAR cv_svalue.
DO iv_length TIMES.
IF sy-index > 15.
cv_svalue = cv_svalue && '...' && iv_length && 'Chars'.
EXIT.
ENDIF.
cv_svalue = cv_svalue && 'X'.
ENDDO.
ENDFORM. " PREPARE_SAMPLE_VALUE
*&---------------------------------------------------------------------*
*& Form PREPARE_DATE_SAMPLE_VALUE
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* <--P_LV_SVALUE text
*----------------------------------------------------------------------*
FORM prepare_date_sample_value CHANGING cv_svalue TYPE string.
cv_svalue = '\/Date(ms since 01.01.1970)\/'.
ENDFORM. " PREPARE_DATE_SAMPLE_VALUE
*&---------------------------------------------------------------------*
*& Form ADDON_BTN
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM addon_btn .
%_p_proj_%_app_%-text = 'SAP GW Project'.
%_p_toxl_%_app_%-text = 'Download URL to Excel'.


DATA: ls_functxt TYPE smp_dyntxt.
ls_functxt-text = 'Functionality>Read First'.
ls_functxt-icon_id = icon_information.
ls_functxt-icon_text = 'Functionality>Read First'.
sscrfields-functxt_01 = ls_functxt.
ENDFORM. " ADDON_BTN
*&---------------------------------------------------------------------*
*& Form SHOW_PROGAM_HELP
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM show_progam_help .
DATA: lt_sample TYPE gtty_line.
APPEND 'Purpose of program:' TO lt_sample.
APPEND 'To generate all possible sample URL and input JSON data file for Gateway Project.' TO lt_sample.
APPEND 'Generation of URL>>' TO lt_sample.
APPEND '1. It will generate sample URL with sample values for all entities.' TO lt_sample.
APPEND ' a. ALV has limitation of displaying the URL up to 128 chars only.' TO lt_sample.
APPEND ' So, in some cases only partial URL is visible. To get the entire URL,' TO lt_sample.
APPEND ' download the URL via “Download URL to Excel” checkbox in selection screen.' TO lt_sample.
APPEND '2. It will generate sample navigation URL based on their navigations' TO lt_sample.
APPEND ' a. Generation of Multi-level navigation URL is not supported.' TO lt_sample.
APPEND '3. It will generated Expand URL based on associations.' TO lt_sample.
APPEND INITIAL LINE TO lt_sample.
APPEND 'Generation of SAMPLE Input JSON file >>' TO lt_sample.
APPEND '1. It will generate Sample input JSON file based for CREATE, DEEP INSERT and UPDATE' TO lt_sample.
APPEND ' by double clicking the CREATE/DEEP INSERT/UPDATE URL’s in ALV output.' TO lt_sample.
APPEND '2. Sample JSON will contain dummy value of ‘X’ up to 15 char and if more than value' TO lt_sample.
APPEND ' will contains the max possible char length with ‘…’. E.g. "XXXXXXXXXXXXXXX...20Chars".' TO lt_sample.
APPEND '3. If sample JSON contains the multiple set of values i.e. array like in case of DEEP INSERT,' TO lt_sample.
APPEND ' then of set of value is repeated up to 2 set only under “[ ]”.' TO lt_sample.
APPEND INITIAL LINE TO lt_sample.
APPEND 'Execution process:' TO lt_sample.
APPEND '1. To view the Generated URL List provide SAP GW Gateway project name and execute' TO lt_sample.
APPEND ' a. Output will be viewed in ALV' TO lt_sample.
APPEND '2. To download the Generated URL List select “ Download URL to Excel” along with' TO lt_sample.
APPEND ' Gateway project name and execute' TO lt_sample.
APPEND ' a. Output will be viewed in ALV' TO lt_sample.
APPEND ' b. Generated Output will complete URL list will be downloaded in an EXCEL sheet' TO lt_sample.
APPEND ' at the path provided by User after Execution. ' TO lt_sample.
APPEND '3. To view the Sample input file double click on the line with operation CREATE,' TO lt_sample.
APPEND ' DEEP INSERT and UPDATE only.' TO lt_sample.
PERFORM show_sample_data USING lt_sample.
ENDFORM. " SHOW_PROGAM_HELP

Execution Output screenshot>>



After execution >>





On double click on CREATE or DEEP CREATE  or UPDATE will generate sample Input JSON file



Sample JSON for DEEP INSERT.



On selecting the check box "Download URL to excel" will download the completed generated URL in Excel document.

Conclusion


It’s an utility application to help developer provide an easy way to generate the GW URL which many a times become a cumbersome activity. The main challenge is always to create the sample JSON input file for payload. With this program both requirement is achieved letting system generate all possible URL and sample JSON file as per the entity and it association making efficient GW process development and testing.
4 Comments
Labels in this area