ABAP log

May 2, 2008

SAP APO Simsessions cleanup

Filed under: ABAP, APO, SAP — abaplog @ 6:56 pm

As I wrote last week, we had some problems with data not being released when making a call from R/3 to APO via RFC. I expected the data - the sumulation sessions of APO liveCache - to be cleaned up as soon as the RFC call is getting back into R/3, but they remained in memory as long as our dialog transaction on R/3 side was kept open. This was a kind of concern for our team as a problem potentially affecting liveCache performance, though in liveCache monitoring (LC10), the memory consumed by those simsessions looked quite innocent in comparison with others.

So, what was that? Whenever we want to read some liveCache data, we need to open a “session” first, for it is a required parameter to most of APO functions reading data from or writing to liveCache. Exceptions are of course BAPIs, that are dedicated to be called easily from outside. And if you are in some user exit of BADi, you don’t need the session because normally you are given one as a parameter.

So, before we start, we usually create a new session with the function /SAPAPO/RRP_SIMSESSION_CREATE. If it’s being done in a “short-living” fashion, like a report that is run and then exited, one’s sessions are gone very soon. But ours was kept open by some users, sometimes for hours. LiveCache deletes the sessions that it finds to be too old (as defined in customizing), but we wanted them to go away faster. In the same function group as CREATE function, there is the function /SAPAPO/RRP_SIMSESSION_LEAVE, but I found it to be slightly suspicious, for it is used by SAP itself only at couple of places. In addition, the code I had to fix could be calling CREATE function several times. Do I have to call LEAVE every time right after? Or are there any other ways?

I decided to search on OSS. There are many notes dealing with sessions that remain open, and I looked at how SAP solved the problem. They did it better than just calling LEAVE. Instead, before calling CREATE, they try to find any existing session created earlier in the program by calling /SAPAPO/RRP_SIMSESSION_GET. If it fails, they create a new one and set a flag (a global variable) indicating that they have to release the created session. I decided to use the same logic, so the whole sequence looked like:

*   Try to get an existing session first
    call function '/SAPAPO/RRP_SIMSESSION_GET'
      importing
        ev_simsession = lv_simsession.
    if lv_simsession is initial.
*     Create a new simsession
      call function '/SAPAPO/RRP_SIMSESSION_CREATE'
        exporting
          iv_simid       = ls_params-simversion
          iv_change_mode = gc_false
        importing
          ev_simsession  = lv_simsession.
      gf_sims_created = gc_true.
    endif.

* ..... now depending on program conditions,
*       follow more GET/CREATE blocks, with GET
*       most likely returning the session created earlier

* And now, cleanup:

* Did we create any sessions?
  if gf_sims_created = gc_true.
*   Check if there are any sessions still open
*   (who knows - maybe they are deleted already)
    call function '/SAPAPO/RRP_SIMSESSION_GET'
      importing
        ev_simsession = lf_simsession.
    if not lf_simsession is initial.
      call function '/SAPAPO/TSIM_SIMULATION_CANCEL'
        exceptions
          others = 0.
      gf_sims_created = gc_false.
    endif.
  endif.

April 25, 2008

Rappers with SAP OSS, anyone?

Filed under: ABAP, APO, SAP — abaplog @ 7:49 pm

After having built rather complex logic of reading some data from APO and bringing it into R/3, we’ve got some unexpected behaviour. As long as R/3 transaction remains open (this is a dialog transaction), it seems that the RFC “session” on the APO side is not completely closed, and its data, including APO liveCache simulation sessions, is not released (consuming memory).

I’ve spent some time in debugger, then on OSS, browsing through many OSS notes. I hope we have a solution now, we still got to test it. And the time I spent in OSS was not wasted. Imagine you are looking for OSS notes on liveCache and you find a note whose title begins with “liveCache 7.5 crash”! I mean, it rhymes so perfectly that I wonder whether there were any rappers at SAP Support who created this one! (This is the note 946768 by the way). :)

April 19, 2008

And ABAP be still as bright.

Filed under: ABAP, APO, SAP — abaplog @ 7:29 pm

Let’s start again after a long pause, with a shorter post (carrying some good news)…

Three weeks ago, when I was back from vacation during which we’ve experienced some almost scary things, SAP guys visited my company office with a long-waited-for presentation. The topic was, as you may expect from a technical-oriented presentation, the new possibilities that the latest NetWeaver release brings to a developer. It was nice, stuffed with information, six hour session. Well, I would strip it of some things that normally are useful only for SAP sales. What was interesting is that on that day, it was the very first time that I’ve heard some statement about the role of ABAP in the future.

The question is being asked again and again, since we’ve been in dotcom and Java hype: are we going to see ABAP obsoleted and replaced by Java or something else? If you try to look for some “roadmap”-type documents on SAP site, you will never find it. SAP is pushing SOA and “classic” ABAP is in a deep deep shadow now. So we’ve asked the question one more time. And heard a clear answer. Now guess: do you believe they are going to dump it and start it over? Do you think we customers are going to accept testing and debugging the brand new code. No way. The whole R/3, plus APO, plus many other “core” apps will be powered by ABAP. (And personally, I doubt that any of those guys operating machine tools at the factory floor will ever see “the cool cool benefits of SAP portals, whatever”.) I regret now that I did not write it down to have it signed by SAP representative. But it looks like “ABAP will still as bright.”

PS. If I made you think that Web apps are repulsive to me, you are mistaken. Go visit my personal site (link is on the right).

February 23, 2008

Ten years of… ummm… Nevermind.

Filed under: ABAP, SAP — abaplog @ 9:47 pm

I was thinking how will I name this article. “Ten years of ABAP” is kind of selfish but well, here I say that anyways. “Ten years of fun” is not true, for SAP can be very stress-inducing. So, nevermind, let me tell the story.

Ten years ago, on a cold February morning we got off the train to Moscow and rushed to subway to be on our first ABAP training on time. We were six, a newly formed team of a software services company, to get prepared to do technical SAP work. Just one of us knew something about SAP from practice, and the rest, including myself, didn’t have a clue. The week before I was sitting in front of Visual C++, the most advanced development environment then and now, and could not imagine downgrading to simple tools that SAP then offered. I decided to quit my job and take another one, to try this fancy business software.

In 1998, SAP was a hot skill in computer industry and my company (my new company) already had many people with SAP skills. But they were to busy to switch to a new project, so the management decided to take a risk hiring inexperienced people and investing into training. Somehow, when they called SAP Russia to arrange an on-demand training in ABAP, SAP folks got very excited, mostly because they wanted to know who the hell are we, if we are not SAP clients. In my small native country, there was exactly ONE client of SAP at that time. But the potential revenue prospects dissolved all their doubts (not that I’ve heard of widely going piracy of R/3) and they offered a BC400 on demand and then BC415/BC425 from the official schedule.

Moscow never stops offering surprises to its visitors. Enormous city with so many things going on. Just couple of weeks before, I was visiting the office of my (previous) company in Provence, Southern France and it was quite a fun to see the price tags in Moscow easily translated to French Francs, for things easily comparable like McDonald’s, for exchange rate was 1 to 1. The crash of Russian market several months later has corrected that. So, we took the subway, then a bus, both considerably cheaper than in France, and got off in some high-rise residential area to look for the office of SAP Consult CIS. SAP Russia was a company selling software, and SAP Consult did consulting and training. Because of some stupid law or may be for tax convenience, SAP decided to split into two companies there.

SAP Consult was (and maybe still is) located in a former kindergarten that they’ve bought and completely renovated. They didn’t have those small desks and chairs, no. They had nice classrooms with the latest equipment and a broadband connection to SAP Germany. Though SAP already announced the R/3 4.0, we were trained on 3.1, to start our work with 3.0 then, transitioning to 3.1 one year later.

We all were impressed by the training. The second week (we did that two weeks later actually) was not as good because it was with different instructor. But BC400 was impressive. I did not have a much of specialized training and this was the first one then, but this guy who gave it was outstanding. And he wasn’t even a professional educator! His main job was consulting and we had several years of SAP experience. (I wonder when did SAP start its business in Russia).

Back from our training, we continued slowly. Fortunately for us, we worked on a project of IBM Storage Systems Division, where they have extremely well organized processes and lots of competent and ready to help folks. So, after maybe one year, we could say that we understand something in SAP or ABAP world. :) The SAP instance we were working on was by that time one of the biggest and it that was a well known project, even mentioned by SAP itself in one of their “success stories”.

Working was fun. I could not imagine that I will have a chance to use my (almost dead) knowledge of mainframes on this project that I still had from university. But then, R/3 3.x still had this good old ABAP editor where you had to type a command to get more empty lines to write your code, or to paste your text (ok, there were some keyboard shortcuts too, but not for everything). And in addition to standard corporate mail on Lotus Notes, we all got to learn simple things in the same mainframe environment that comes with OS/360 and its descendants. IBM used it as a backup and for some internal applications. Funny, I still had some “tricks” in my head like “if your screen is stuck and reacts strange to anything you type, which means you got out of normal command environment, type IPL PTS and then you’ll be fine”. SAP was considerably easier then, for it had a menu and was more intuitive in 1998.

Looking back I would say that working with on SAP implementation is not as appealing as developing a standalone software, what I did before jumping on ABAP. I’m tired of mentioning that SAP still doesn’t have any useful documentation that helps ABAPers to map business and technical sides of work. But it is nevertheless rewarding (not only from financial incentive point of view). And it’s good to feel how your single line of code can kick the multimillion multiterabyte system in the butt. Ten years didn’t change that - just try to trash your T000 table with DELETE and you’ll know what I mean.

February 19, 2008

Great SAP NetWeaver/ABAP presentations at SDN.

Filed under: ABAP, SAP, SDN — abaplog @ 6:43 pm

Yes, you read it right. I have criticised the quality of SDN content and it made us at sapfans.com many good laughs, but sometimes there are actually very valuable things. Several weeks ago the SDN newsletter brought me a link to a Thomas Jung blog entry about the latest features of ABAP Workbench and SAP NetWeaver tools. It took me some time to get them all because those are big files. They are not films though but a mix of presentations, screen recordings and background commentary, all built based on the workshop Thomas, SAP NetWeaver Product Manager (who looks like knowing the very details of stuff he is managing!), presented at the latest TechEd.

Here’s the link: https://www.sdn.sap.com/irj/sdn/weblogs?blog=/pub/wlg/8126

Not everything is new there - Advanced ABAP part contains some older things, and I did not look at Web Dynpro yet - this has to be some older stuff too. But I highly recommend getting the presentations and investing some time to watch them. Even if you still work with some old SAP version, it’s very useful to know what is coming in the next years.

February 4, 2008

Scary SAP transactions.

Filed under: SAP — abaplog @ 7:02 pm

Sometimes SAP can be really scary. Just look what do they have in ERP 6.0 release:

acc.jpg

A must transaction for every business traveller!

Or look at this list of possible employee dismissal reasons for some HR transaction in 4.6:

dismiss.jpg

Would they please be so fair to declare unjustified dismissal?

The Data Dictionary also has some strange values list for the domain BEN_LNCOD that belongs to HR.

Value: Accidental Death or Dismemberment

ok, I understand this one, after seeing the machines used at our plants.

Value: Death and Dismemberment

When compared with the first value, do they mean now it’s a voluntary dismemberment or what, if it’s not accidental? Like a lizard throwing off its tail probably.

And finally:

Value: Supplemental Death and Dismemberment

Supplemental, you say?

January 28, 2008

Betting on SAP ESA. Part 2.

Filed under: ABAP, SAP, esa, soa — abaplog @ 9:31 pm

Today I am going to continue looking into the current SOA offer from SAP. As I wrote previously, I wanted to evaluate the ESA components in different modules of SAP ERP, and I am starting with master data.

Master data is obviously not the first candidate for extensive coverage with services. Most of it is pretty static and is loaded once, at the beginning of implementation or deployment of the system to new company divisions/plants. That’s why we didn’t have really good support of master data with BAPIs, and I don’t think it’s going to change with ESA. In this entry, it won’t be a review of a full set of every possible basic data piece that an enterprise would need, just several most useful and obvious to be supported by the enterprise services. Let’s have a look. I will be comparing the ESA offer with the current set of BAPI functions in my old 4.6C.

We start with basics. Materials - this is what all companies need to operate even if they  services oriented businesses. Why do we need to support materials with “official” functions and enterprise services? Imagine we are a manufacturing company. Most of them use external systems for product development and lifecycle management (those big systems from Parametrics or IBM/Dassault for example). If the products and their actual data are coming from such systems, we will most likely need to design interfaces, and those interfaces will have to support reliable live links into our SAP ERP. Good old BAPIs provided us with a full set of functions to manage materials. Currently, in the ES catalogue of SAP, I could find only read-only services: Manage Material In and Query Material In. Not that much.

Materials are bought and sold. So here come customers and vendors. Why the need for support here? Imagine some cool future system (SRM or CRM kind) where our business partners will be able to access some of their details, maybe even including possibility to change the data. You’ve heard about Plaxo? You change your data and all your contacts have the immediate access to updates. May be it sounds like a crazy idea, but what about our customer having a way to update their address or contact details without waiting for our company employees to do that? For me it sounds reasonable, so I wanted to check whether we have services for customers and vendors.

For customers, we had full set of BAPIs.  ESA offer: Manage/Query Customer In. There is no “create” service/method, but at least we can find and change things.

For vendors, we have a limited set of BAPIs, mainly for reading. ESA goes the same way today: Manage Supplier In, Query Supplier In - both read only. NOTE: there is probably a difference between “supplier” and “vendor” - I won’t dig deeper here. I did not find anything about “vendors” in ESA directory.

The BAPIs in 4.6C have an object “Vendor price catalogue”, that may be useful to us. ESA: offers no such thing today. Perhaps they have obsoleted it.

Because of the similar background as in the case with materials, it would be great to have access to bills of materials and routings used in the production process. They can also be managed from external CAD/CAM/PDM/PLM systems.

For routings, we got “create” and “check” BAPIs; no read, no change. ESA offer: nothing.

BOMs - no BAPIs. ESA: Query Production Bill of Material In. AHA! That’s a progress! But still only read operations.

With the similar background, documents are a good candidate area. Those can be drawings from external systems. In this case, SAP offers a full set of BAPIs and a full of enterprise services, like Document Action In, Manage Document In.

One interesting BAPI set, related to master data, that I have found: Currency exchange rate. Currency rate data is normally delivered to companies via EDI, and to complement it, SAP offers BAPIs for create and change operations. However, I could not find any related enterprise services.

So, you see, we don’t have lots of exciting things for master data in ESA, but as I said, I would expect less for master data and more for dynamic data to work with the mechanics of business modules. Those areas are going to be covered in later entries of ABAPlog.

January 14, 2008

Betting on SAP ESA.

Filed under: ABAP, SAP, esa, soa — abaplog @ 9:31 pm

We’ve been waiting, and here we are! We are now in 2008, which means that 2007 is already in the past, and the end of 2007 was the magic date when all SAP applications, including mySAP Business Suite or ECC or whatever it’s called now, will be completely covered by SAP services architecture, SAP ESA. The first detailed announcements came as early as 2003, with SAP keeping on track through those four years.

I don’t believe anyone expected that we are going to get 100% coverage. It takes time. I was quite skeptical, after reading all exciting announcements of Open BAPI Network since 1997 and years later, still using illegal tricks to work with SAP, instead of published and SAP-blessed interfaces. When I checked the ESA services directory at SDN back in 2006, it looked even poorer than BAPI directory. A couple of months ago, though I did not write what have I found and what I haven’t in 2006, I could say that SAP did a significant progress.

My primary interest in their new offer is the possibility to shift from dirty database stuff, yet more dirty tricks with internal functions and the frustration with incomplete BAPIs to some well documented way of exploring and updating SAP data and of course, connecting SAP with other systems. From what I could read, we’ll soon be able to forget the syntax of SQL SELECTs, the knowledge paid with our sweat and our employers’ money.

While SAP was integrating the ESA support and the development of the ESA connections to SAP internal business logic was far away, companies could already use ESA/SOA to have SAP talking in SOA language to the systems that already expose business functionality through services. That means, as soon as you install NetWeaver, which has ESA support since, I think, 2003, you could, in your SAP programs (ABAP or Java-based), simply speaking, read or update data in your external system that exposes business logic as services. And in this other system you could call services exposed by your SAP as soon as you have implemented them yourself. If you wanted, say, read a sales order from your SAP system, you still had to do this with BAPIs or in some other way. You had to wait for 2008 to come to have both sides of story.

Now, the new era is coming. We can’t say it’s already here, even if it has to be according to press releases. The most important for us is to know the following:

1. What do we have with ESA today.

2. How good is the progress that SAP is having implementing their new architecture in each application.

In the next weeks I’m going to make some kind of analysis of SAP’s current offer, in terms of what business functionality is exposed today in the latest version of ESA. I don’t need to have the latest version at work to do that because everything we need to know can be found at SAP SDN Enterprise Services Workplace. In the past ten years I had to do technical work with most of SAP R/3 modules, minus HR, plus SAP APO. (Those days it’s mostly production planning related). I’ll try to cover the areas where I have some general idea, so that at the end we could see whether we should rush buy books about the services jungle.

Stay tuned!

December 18, 2007

Dusty ABAP snippets.

Filed under: ABAP, SAP — abaplog @ 8:29 pm

Many code samples or tips I post here originate in my collection that was built in last years. When I discover or code something worth keeping, I strip company specifics from the code and save it in simple text files. Some code snippets are used again and again, like macros in this post below or data caching forms. But once in a while I have to reuse the code after blowing away the dust.

That was back in 2000 when I have to do some report that, among other things, had to show costing estimates from the product costing runs. I don’t remember any more how did I find the solution (probably after my functional analyst gave up trying to help me to get the data easily), but it was using a couple of BAPI functions. And two weeks ago, after getting a similar requirement and having spent some time with debugger and asking FI/CO colleagues and everyone else, I have thought that this is actually a “deja vu”. Quick check of my code library - YES! I had to do some adjustments to the code and use the debugger to get the right constants corresponding to my company’s logic, but was still a wonder that my old code did. Here it goes:

* Macro to prefill select option

DEFINE ADD_SELECTION_VALUE.

  &2-SIGN = 'I'.

  &2-OPTION = 'EQ'.

  &2-LOW = &1.

  APPEND &2.

  CLEAR &2.

END-OF-DEFINITION.

form get_cost_element
  using
    pi_plant type werks_d
    pi_matnr type matnr
    pi_date  type sydatum
  changing
    po_cost  type total_amt.

  data:
    lt_cvar  type standard table of bapicstgva with header line,
    lt_matnr type standard table of bapimateri with header line,
    lt_plant type standard table of bapiplant  with header line,
    lt_costs type standard table of bapisplitt with header line.

  data: begin of it_list occurs 0.
          include structure bapicolist.
  data: end of it_list.

  data:
    ls_cost_header like bapiheader.

  data:
    ls_ret   type bapireturn,
    lf_found type char1 value ' '.

* ABCD is the costing variant. It should be your company specifics.
  add_selection_value 'ABDC' lt_cvar.
  add_selection_value pi_matnr lt_matnr.
  add_selection_value pi_plant lt_plant.

  clear: po_cost.

  call function 'BAPI_COSTESTIMATE_GETLIST'
       importing
            return             = ls_ret
       tables
            costing_variant    = lt_cvar
            material           = lt_matnr
            plant              = lt_plant
            cost_estimate_list = it_list
       exceptions
            others             = 1.
  check sy-subrc = 0.
* sort to get result of the last costing run
  sort it_list by valid_from descending.
* XX and YYY should be specific to your task.
* Check with debugger after calling the first BAPI
  loop at it_list where cstg_type = 'XX' and
                        vltn_vrnt = 'YYY'.
    if lf_found = 'X'.
      exit.
    endif.
*   Get first costing suitable by date
    if pi_date >= it_list-valid_from and
       pi_date  0.
          po_cost = lt_costs-total_amt.
          lf_found = 'X'.
          exit.
        endloop.
      endif.
    endif.
  endloop.

endform.

December 9, 2007

New frontiers of APO

Filed under: ABAP, APO, SAP — abaplog @ 3:26 pm

The capture of new markets by SAP flagship solutions like APO is sometimes missed by the press. But you can still discover the advances in the least expected ways.

This happened to me when the girl in our drug store offered me the best solution she had to my flu problem, earlier this year:

apo.jpg

Well, as long as the solution is “Made in Germany”, it doesn’t hurt, right? So I decided to give it a try and I still remain very satisfied with it. After all, the cost is quite reasonable and you DO get ROI after just several days of use! (No kidding here. I normally don’t trust the homoeopathic stuff but this one works wonderfully.)

So, let me give you my advice:

If your APO makes you sick, you just need a different version. Like that one on the photo above! 

Older Posts »

Blog at WordPress.com.