oData AND SAP NW Gateway OVERVIEW
Posted: September 10, 2014 Filed under: oData, SAP Gateway Leave a commentLink to presentation on “oDATA AND SAPGateway”I did earlier this year.
http://slides.com/sakiv/odatagatewayintro#/
SAPUI5 with Gateway
Posted: September 10, 2014 Filed under: HMTL5, SAP, SAP Gateway, SAP Mobile, SAPUI5/OpenUI5 Leave a commentLink to presentation I did earlier for training my colleagues.
http://slides.com/sakiv/sapui5withgateway#/
Understanding CSV files and their handling in ABAP
Posted: September 10, 2014 Filed under: SAP, SAP ABAP Leave a commentFrom my blog on SCN
http://scn.sap.com/community/abap/blog/2014/09/09/understanding-csv-files-and-their-handling-in-abap
Installation and version management of mobile applications without any MDM solution
Posted: August 23, 2014 Filed under: iOS/ ObjectiveC, Mobile, SAP, SAP Mobile Leave a comment
Retain selection screen values on program restart for transactions with chosen selections
Posted: August 20, 2014 Filed under: SAP, SAP ABAP | Tags: SAP, SAP ABAP Leave a commentFrom my blog on SCN
I had an interesting last week and what looked easy at the outset did my head in for quite a while. I tried various methods and the below approach was able to give me a satisfactory solution.
Let’s have a look at the high level requirement.
– Copy a standard SAP transaction and customise it . Below picture describes the requirement
The transaction is started with only few fields of the complete selection screen as the selection screen has too many fields and may confuse the users.
The users need to navigate back and forth between different modes of output screen. At the first display of output screen ( let’s call them as levels – so the output screen is at level 0 when initially displayed and if called again goes to level 1 and so on . Similarly when the user comes back from a higher level of screen, the level will decrease : from 1 to 0 ). And of course when the program navigates back from level 0 of selection screen, it should display the selection screen.
I prototyped using a simple program using flight model.
– Selection Screen : Contains all fields.
However, the transaction is always run with a variant which hides the last field.
– Let’s test with some data.
We get the level 0 output screen.
Now click on filter ( search icon on top right )
and we get level 1 screen.
Looks good so far. Now, let’s try going back – going back to level 0 gives the screen as anticipated. However, when we go back and see that the selection screen parameters have gone back. The selection screen has gone blank !
Let’s see what’s going on.
As we need to keep track of different levels of screen, if the level of screen is greater than 0.
…….
ELSEIF sy–ucomm = ‘EXIT’.
IF gv_list_level > 0.
gv_list_level = gv_list_level – 1.
gt_flight[] = gt_master_flight[].
CALL SCREEN 100.
ENDIF.
When we want to go back to selection screen from screen at level 0, we use below:
SUBMIT zsubmit_flight
WITH report EQ ‘ZTESTFLIGHT’
WITH variant = ‘ZFLIGHT_VAR’
WITH SELECTION-TABLE gt_seltab .
zsubmit_flight is a standard SAP report used by the report and can’t be changed by us.
SUBMIT (REPORT) WITH VARIANT = VARIANT
USING SELECTION–SET VARIANT
VIA SELECTION-SCREEN
Workaround:
1) Store selected values by call of RS_REFRESH_FROM_SELECTOPTIONS
2) Export the selection table before doing a program restart.
EXPORT gt_seltab TO MEMORY ID gc_sel_mem.
3) Retrieve the selection table AT SELECTION-SCREEN OUTPUT.
RS_VARIANT_CONTENTS gives the parameters and select-options actually visible in the variant.
IMPORT gt_seltab FROM MEMORY ID gc_sel_mem.
IF NOT gt_seltab[] IS INITIAL.
CALL FUNCTION ‘RS_VARIANT_CONTENTS’
EXPORTING
report = ‘ZTESTFLIGHT’
variant = ‘ZFLIGHT_VAR’
TABLES
l_params = lt_params
l_selop = lt_selops
valutab = lt_value
EXCEPTIONS
variant_non_existent = 1
variant_obsolete = 2
OTHERS = 3.
IF sy–subrc <> 0.
clear: lt_value,
lt_selops,
lt_value.
ENDIF.
* Update parameters values
LOOP AT lt_params INTO lw_param.
READ TABLE gt_seltab REFERENCE INTO lo_values WITH KEY selname = lw_param–name.
IF sy–subrc = 0.
lv_attr = lo_values->selname.
TRANSLATE lv_attr TO UPPER CASE.
ASSIGN (lv_attr) TO <fs_attr_val>.
<fs_attr_val> = lo_values->low.
ENDIF.
ENDLOOP.
* Update select-option values
LOOP AT lt_selops INTO lw_param.
READ TABLE gt_seltab REFERENCE INTO lo_values WITH KEY selname = lw_param–name.
IF sy–subrc = 0.
CONCATENATE lo_values->selname ‘SIGN’ INTO lv_attr SEPARATED BY ‘-‘.
TRANSLATE lv_attr TO UPPER CASE.
ASSIGN (lv_attr) TO <fs_attr_sign>.
<fs_attr_sign> = lo_values->sign.
CONCATENATE lo_values->selname ‘OPTION’ INTO lv_attr SEPARATED BY ‘-‘.
TRANSLATE lv_attr TO UPPER CASE.
ASSIGN (lv_attr) TO <fs_attr_option>.
<fs_attr_option> = lo_values->option.
CONCATENATE lo_values->selname ‘LOW’ INTO lv_attr SEPARATED BY ‘-‘.
TRANSLATE lv_attr TO UPPER CASE.
ASSIGN (lv_attr) TO <fs_attr_low>.
<fs_attr_low> = lo_values->low.
CONCATENATE lo_values->selname ‘HIGH’ INTO lv_attr SEPARATED BY ‘-‘.
TRANSLATE lv_attr TO UPPER CASE.
ASSIGN (lv_attr) TO <fs_attr_high>.
<fs_attr_high> = lo_values->high.
lv_attr = lo_values->selname.
TRANSLATE lv_attr TO UPPER CASE.
ASSIGN (lv_attr) TO <fs_attr_main>.
CONCATENATE lv_attr ‘[]’ INTO lv_attr_tab.
ASSIGN (lv_attr_tab) TO <fs_attr_tab>.
IF lo_values->low IS NOT INITIAL OR lo_values->high IS NOT INITIAL.
REFRESH <fs_attr_tab>.
APPEND <fs_attr_main> TO <fs_attr_tab>.
ENDIF.
ENDIF.
ENDLOOP.
ENDIF.
– Create a transaction ‘ZFLIGHT’ with program ZTESTFLIGHT , variant ZFLIGHT_VAR.
The code can be referred here:
The code can be referred here:
ZSUBMIT_FLIGHT
https://github.com/viksingh/ABAP_Demo/blob/master/ZSUBMIT_FLIGHT
Program ZTESTFLIGHT with issues:
https://github.com/viksingh/ABAP_Demo/blob/master/ZTESTFLIGHT_1
Program ZTESTFLIGHT with corrections:
ABAP_Demo/ZTESTFLIGHT_2 at master · viksingh/ABAP_Demo · GitHub
The key here is function module RS_VARIANT_CONTENTS and the dynamic update of selection screen after restart of a transaction.
ZSUBMIT_FLIGHT
https://github.com/viksingh/ABAP_Demo/blob/master/ZSUBMIT_FLIGHT
Program ZTESTFLIGHT with issues:
https://github.com/viksingh/ABAP_Demo/blob/master/ZTESTFLIGHT_1
Program ZTESTFLIGHT with corrections:
ABAP_Demo/ZTESTFLIGHT_2 at master · viksingh/ABAP_Demo · GitHub
The key here is function module RS_VARIANT_CONTENTS and the dynamic update of selection screen after restart of a transaction.
ABAP dynamic internal table sort saves the day
Posted: August 16, 2014 Filed under: SAP, SAP ABAP Leave a commentRequirement to refresh the ALV to display only display unique fields. Thankfully the sort fields of an itab can be specified dynamically now.
TRY.
SORT gt_output BY (lt_sorttab).
DELETE ADJACENT DUPLICATES FROM gt_output COMPARING ALL FIELDS.
CATCH cx_sy_dyn_table_ill_comp_val.
gt_output[] = lt_output[].
ENDTRY.
Understanding and updating MIGO defaults in ABAP
Posted: July 29, 2014 Filed under: SAP, SAP ABAP Leave a commentPosted on SCN at http://scn.sap.com/community/abap/blog/2014/07/28/understanding-and-modifying-migos-defaults-programmatically.
Recently I had a situation where I needed to update MIGOs defaults programatically. I tried to search for a solution but couldn’t see it mentioned anywhere and hence decided to write it down . I hope that it’ll be useful for anyone in a similar situation.
Background:
MIGO is a multi-purpose transaction which can be used for various activities in material management – performing goods movements, receipt of purchase order etc. It replaces many older transactions . There are others as well but to list down a few:
- Post a goods receipt to a known purchase order (transaction MB01)
- Change a material document from goods receipts (transaction MB02)
- Display a material document from goods receipts (transaction MB03)
- Cancel a material document from goods receipts (transaction MBST)
To understand why we may need to ever need to modify MIGO defaults, consider the below situation.
– A file arrives for processing in SAP ( say as a batch job ) .
– Initial goods movement is tried using a BAPI. If the processing fails , a user SM35 BDC session is created for processing which can be reprocessed by users ( the users are familiar with MIGO ). A custom transaction for reprocessing is created as the users couldn’t be given access to SM35. SM35 allows you to display and potentially reprocess all sessions which can be tricky if the authorisations are a bit leaky.
The failed sessions can then be processed by a custom transaction – the SM35 sessions are persisted to a temporary table to be used by reprocessing transaction.
Problem:
Everything looks good in theory : all automatic postings are done in background and any errors can be handled by the custom transaction. However, while the user is performing the reprocessing the MIGO session, something interesting happens – if the user opens a parallel MIGO session and performs some other processing in parallel, the subsequent sessions start to fail in the custom transaction. Users could be processing multiple sessions sequentially and might go away and do some other movements in parallel in MIGO.
Why does this happen ?
MIGO stores user’s defaults trying to optimise the usage so that the user doesn’t have to set the selections – this causes the defaults to be always set whenever you use the transaction. The parallel session which the user opened has overridden the defaults and as a result, subsequent failed sessions have different default values set in the screen even though the BDC recording used in SM35 session was set correctly. User defaults is overriding BDC set values .
Looking at the below image, the BDC session has set values A07 and R10 for action and sub-selection within action.
However, if the user choses something else in a parallel session ( say A05 and a sub-selection ) , it overrides the action default and subsequent SM35 sessions start failing as then MIGO will start with A05 / sub-selection.
Solution:
MIGO stores user’s defaults in table ESDUS and these defaults correspond to MIGO_FIRSTLINE action. Seeing the below table entries, the settings for the user are:
Default is action = A07
and sub-selection for A07 is R10.
Hence, A07 / R10 will appear for ACTION and sub-selection ( as shown in above image ) .
Show Me The Code:
Now, we know where they’re stored, how to update them ?
Class CL_MMIM_USERDEFAULTS can be used to read and update the parameters. It’s a singleton and hence there should be only instance at a given time. Consequently, if we’re using it we have to ensure the instance is destroyed . This is achieved by FLUSH_ALL method of the class. Above methods are self explanatory and the constructor requires ACTION value.
So I did the following:
– Instantiate the class using ACTION as “MIGO_FIRSTLINE” and set the instance values.
– Set the values:
o_migo_defaults->set
( i_element = ‘ACTION’
i_active = lv_action ).
– Flush the value to dB and destroy the instance
o_migo_defaults->flush( ). “Save values to dB
o_migo_defaults->flush_all( ). “Destroy this instance as others instance will start producing errors
The table has other values used in MIGO defaults ( e.g. default movement type for an action ) and can be similarly updated.
Integration Gateway in SAP Mobile Platform 3.0
Posted: July 6, 2014 Filed under: SAP, SAP Mobile Leave a commentMain features of SMP 3.0 :
– SUP, Agentry and Mobiliser combined. This itself is a pretty big as each of the platforms had an integration framework and it had to be harmonised . It’s simplified to just use SMP with services exposed in oData format.
– Through SMP 3.0, services from ABAP backend ( using SAP Gateway ) and non SAP backends can be easily consumed. This is pretty powerful as data could be spread out over multiple kinds of data sources. It allows for data consumption from JPA, JDBC , SOAP etc.
– Eclipse GWPA has been enhanced for new features – to consume services from different backend types.
– A big drawback I see is that it doesn’t seem to talk about MBO based replication. My first iOS mobility project involved creating an iOS ( iPAD app ) using SUP which was based on MBOs and it’s sad to see them go. Support for offline capabilities is planned from later releases of SMP 3.0.
– A big positive is the ability to schedule different data based on speed ( or other requirements ) – the ability to assign priorities in scheduling is a big one – our users were extremely frustrated that they can’t control the information they wanted and had to wait for sync of everything from past before relevant data for today could be synced.
Comparisons between SAP Gateway and SAP Integration Gateway:
– ABAP based vs Lean Java server ( Java, OSGI ).
– Supports SAP vs Supports both SAP and non-SAP data sources.
– Available as a standalone solution vs embedded inside SMP 3.0 .
– On premse vs On premise / Cloud.
SAP HANA CDS ( Core Data Services )
Posted: February 24, 2014 Filed under: HANA, SAP, SAP ABAP | Tags: ABAP, HANA, SAP Leave a commentWith SAP HANA platform, there has been a major shift in the way database is looked at. Traditionally, ABAP developers brought most of the data back to application server and manipulated based forming the core logic of the application.With HANA, the emphasis has been to do more in the databse ( akka code pushdown ).
However, there are some major drawbacks:
– It relies on development in two areas : HANA views / procedures which are then consumed in ABAP.
– Two separate mechanisms for ALM with ABAP and HANA transports.
With SAP NW 7.4 SP5, ABAP open SQL has been enhanced and views can be created using DDL. This is known as CDS ( Core Data Services ) .
Looking at an example: Create a basic view.
And the view can be consumed in ABAP – Need to add @ annotation .
These can be extended so that if DDIC additions are made, the view gets them automatically.
And the views can be made more complex.
and even more complex.
This to me looks like a step in the right direction as:
– it’s open SQL and hence is dB agnostic. Hence, it can be supported for other vendors databases in future.
– No separate development done in HANA reducing complexity of application development
ABAP SP5 on HANA is out
Posted: February 20, 2014 Filed under: HANA, SAP Leave a commentCloud Appliiance Library has been updated with SP5. This is a big release as it has lot of “code push down” features.
Performance Worklist Tool: The SQL Performance Worklist (Transaction: SWLT) allows you to correlate SQL runtime data with ABAP code analysis to plan optimizations using results from the new SQLMonitor and CodeInspector.
CDS Viewbuilding: CDS Viewbuilding is drastically improving the existing viewbuilding mechanisms in ABAP.
Extended OpenSQL: Open SQL has been enhanced with new features, especially a lot of limitations have been removed, the JOIN functionality has been enhances as have been arithmetical and string expressions.
ABAP managed Database Procedures (AMDP): AMDPs enables you to create database procedures directly in ABAP using e.g. SQL Script and to seamlessly integrate it in modern ABAP development. An AMDP can be implemented using an ABAP method.
And then there are additions to ABAP.
– MOVE-CORRESPONDING for Internal Tables : No longer RTTI required for such activities.
and some more:
Expressions and Functions
Table Comprehensions
Meshes
Open SQL additions
Links :
http://help.sap.com/abapdocu_740/en/index.htm?file=ABENNEWS-740_SP05.htm
http://help.sap.com/abapdocu_740/en/index.htm?file=ABENABAP_HANA.htm
Two more enhancements with the solution from CAL ( Cloud Appliance Library ) :
– Front End provided , installation of eclipse and HANA studio no longer mandatory e.g. if you have a mac.
– BW is present in the same system.