Wednesday, 17 August 2016

UI5 Deep Entities

Surprisingly, it's not possible to just pass a table of data (or an Array, if we're talking JavaScript) into an ABAP FM.
This was a little disappointing, given my oData experience so far went from 


  • messing around with the DPC_EXT methods (where you had to do a bit of work to read the contents of the message from the frontend) 
to
  • just cloning the FM interface out to an oData structure (where you didn't have to do any work...


I think you can guess which one I preferred... 

So when you need to populate lots of stuff into a function module (e.g. you're creating a Sales Order, and you need to pass header data and several lines of line Item data)

you need to use a "Deep Entity". This immediately makes me think that the entity is sitting around contemplating the meaning of life, questioning it's own existence, etc etc.

The setting up of a deep entity call is described in detail here:

http://scn.sap.com/community/gateway/blog/2014/04/27/step-by-step-development-guide-for-createdeepentity-operation

and the corresponding front-end call is described here: 

https://scn.sap.com/thread/3557655

I'm about to go through these; if there's anything notable about them, I'll blog in some additions below. Peace.





Monday, 25 July 2016

UI5 SplitApp Container

Excellent jsbin here that explains how to have multiple views in a splitapp... 

http://jsbin.com/aku_switch_views/1/edit?html,output

The bit I'd been missing for a day or two was:

app.toDetail which includes the natty UI5 swishy animation for no extra development effort from myself! :D

Whilst we're here, we should probably shout out jsbin for their excellent crowd-sourced examples library, which also include an online editor (like the w3schools example). Super tool!

Monday, 11 July 2016

Test data table randomiser

Okay, so I need to populate some interesting test data in a Z-table I'm supposed to be reading. I could be really boring and set up a bunch of sequential data, which all drops out of the table in a boring organised way. This is right out, it'll just look really contrived.

I could set up a number of itabs, each with lists of possible data, then randomly attack each of them, getting me an interesting set of data. I've done this in the past, and it looked fine, just took a while.

I could just populate the table whilly-nilly. This works fine, again, takes a while, and doesn't get the computer to do the work...

The method I've just employed, I'm happy with; populate a small table, whilly-nilly, then randomly attack that table to make the data you send to the database. This has the required combination of randomness, interestingness, and capacity to create lots of data all at the once. (I'm only doing 20 here, but could just as easily be 200!).

define getRand .


  CALL FUNCTION 'QF05_RANDOM_INTEGER'
  EXPORTING
    RAN_INT_MAX         = 5
    RAN_INT_MIN         = 1
  IMPORTING
    RAN_INT             = l_rndInt.

READ TABLE t_zpd_rh2 INDEX l_rndINt into &1.

end-OF-DEFINITION.


REPORT ZPD_POP_RH2.

"Dataset to randomise out of...

data: t_ZPD_RH2 type TABLE OF ZPD_RH2.


data: l_ZPD_RH2 type ZPD_RH2,
      l_ZPD_RH2_feeder type ZPD_RH2,
      l_rndInt type QF00-RAN_INT.

*(operation/workcentre/plant/description)
l_zpd_rh2-property = 1.
l_zpd_rh2-work_centre = 'WC1'.
l_zpd_rh2-plant = '1000'.
l_zpd_rh2-description = 'Replace boiler'.
append l_zpd_rh2 to t_zpd_rh2.

l_zpd_rh2-property = 2.
l_zpd_rh2-work_centre = 'WC2'.
l_zpd_rh2-plant = '2000'.
l_zpd_rh2-description = 'Renovate Bathroom'.
append l_zpd_rh2 to t_zpd_rh2.

l_zpd_rh2-property = 3.
l_zpd_rh2-work_centre = 'WC3'.
l_zpd_rh2-plant = '3000'.
l_zpd_rh2-description = 'Replace kitchen sink'.
append l_zpd_rh2 to t_zpd_rh2.

l_zpd_rh2-property = 4.
l_zpd_rh2-work_centre = 'WC4'.
l_zpd_rh2-plant = '4000'.
l_zpd_rh2-description = 'Fix leaky tap'.
append l_zpd_rh2 to t_zpd_rh2.

l_zpd_rh2-property = 5.
l_zpd_rh2-work_centre = 'WC5'.
l_zpd_rh2-plant = '5000'.
l_zpd_rh2-description = 'Diagnose bad smell'.
append l_zpd_rh2 to t_zpd_rh2.

data: l_operation type int4.


do 20 times.
  clear l_zpd_rh2.

  l_operation = l_operation + 1.
  l_zpd_rh2-operation = l_operation.

  getRand l_ZPD_RH2_feeder.
  l_zpd_rh2-work_centre = l_ZPD_RH2_feeder-work_centre.

  getRand l_ZPD_RH2_feeder.
  l_zpd_rh2-plant = l_ZPD_RH2_feeder-plant.

  getRand l_ZPD_RH2_feeder.
  l_zpd_rh2-description = l_ZPD_RH2_feeder-description.

  getRand l_ZPD_RH2_feeder.
  l_zpd_rh2-property = l_ZPD_RH2_feeder-property.


  append l_zpd_rh2 to t_zpd_rh2.

enddo.

MODIFY zpd_rh2 from TABLE t_zpd_rh2.

commit work and wait.

Friday, 3 June 2016

PI Search Nuisance

PI Searching is case sensitive... thus 

yields different results to:

I need all the help I can get with PI, and this is just irritating!

Monday, 18 April 2016

Memory ID tip..

Came across this neat trick today : 

So, normally, we use the "export to memory id" and "import from memory id" commands when we need to pick up data from one place and read it in another, without the hassle of passing it from place to place as the code gets processed.

In the above case, there were many shell layers between where the variable was set, and where it was read. However, Simon has done us all a favour, and assigned the variable to Class-attribute. The beauty of this is that it makes the SET really easy to find if you've got the READ, and vice versa... It's a neat simple trick, but it's a good way of organising your code!

Wednesday, 6 January 2016

If Line Exists...

New to ABAP 740 (okay, that's well old, but new to me) this blog describes how to use the itab function "if line_exists"


Looks really useful!

Monday, 23 November 2015

CTRL-N

Opens a new session... Just like Word, Outlook, Chrome, Notebook etc etc.

Press Ctrl-N in GUI. Now triggers new session. Useful. 3 of my colleagues hadn't heard about this, so thought it worth broadcasting! SAP starts to behave a bit like other software. Good.