Application Development Blog Posts
Learn and share on deeper, cross technology development topics such as integration and connectivity, automation, cloud extensibility, developing at scale, and security.
Showing results for 
Search instead for 
Did you mean: 
Active Contributor
I haven't been on here in awhile. But today I was looking out my window in April in Michigan at the snow.  For those of you reading it not thinking that is a big deal. It's been since the 1800s since we've gotten snow this late in April. And yes, I'm inside looking at that snow.  Take a look at the ground - yes lovely green grass and my pine tree looks happy.  It's a bit of a hybrid out there spring and winter on the ground. I am getting to the real point of my blog.

So I'm learning.  Yes, never stop learning. But I'm trying to cram as much information into my brain as possible. Then I remind myself when I started with SAP - I was cramming then too.  Anyway, while cramming things into my brain, I still have due dates.  So being me, I want to use the newer stuff.  So I have been taking a hybrid approach. Perhaps not the best way, but it's been what I can do.

We have HANA on-premise.  What makes this important is we still can use older techniques and then simply call them from FIORI.  In a pinch I can use all old programming.  I thought I'd give an example of my "Hybrid" programming.  OOP ALV has been my friend for a long time.  It's so easy to use to present information.

So here are some bits and pieces of my program. (Watch me go back and fourth to Eclipse, I'll eventually learn all the short cuts there, but haven't yet.  My piece of wisdom for you - learn Eciplse as soon as possible.

The Requirement:

A way to pull together ingredient contracts and the sales order relating to them.  Next if they are checked, remove them from the balance.  Yes, the simple requirements usually end up being a problem.  <Laughing>

Part 1 - getting the data. For this I got to use some of the new "stuff"! Yes, I used Eclipse.

It would have made more sense to use CDS.  For those of you learning like me.   (I love comments)  Please take a look at  mike.pokrakacomments at the end.  I'm going to quote them here.
"Personally I’d suggest using CDS in first instance and go for AMDP if you need features such as scripting or to extract that last little squeak in performance.

In your scenario, you can do the JOINs in one or more CDS view(s) and then do a SELECT with FOR ALL ENTRIES or a temporary table. A great reason for CDS is you can build up complex joins in layers of multiple views, which is easier to build and test than a single complex SELECT with a bunch of JOINs.

Have a look at some of the SAP CDS views for this area, you might even find one that already supplies most of what you need and you can then either extend it or build your own view on top of it."

USING vbak vbap
vbkd vbep tvagt
vbpa kna1.

tmp1 = apply_filter( vbap, :iv_where);

et_log = select
when b.gbsta = 'A'
then 'Open'
when b.gbsta= 'B'
then 'Open'
when b.gbsta = 'C'
then 'Closed'
end as stat,
c.bezei as rej,
concat( b.werks, concat( '/', b.lgort ) ) as werk_sloc,
ship.kunnr as shipto,
kna1.name1 as shipto_name,
kna1.ORT01 as city,
kna1.regio as region,
merch.kunnr as merch,
z2_kna1.name1 as merch_name,
a.kunnr as soldto,
soldto.name1 as soldto_name
:tmp1 as b

inner join vbak as a on a.mandt = b.mandt and
a.vbeln = b.vbeln

left outer join tvagt as c
on a.mandt = c.mandt and
b.abgru = c.abgru and
c.spras = 'E'

left outer join vbep as vbep
on a.mandt = vbep.mandt and
b.vbeln = vbep.vbeln and
b.posnr = vbep.posnr and
vbep.bmeng > 0

left outer join vbkd as vbkd
on a.mandt = vbkd.mandt and
b.vbeln = vbkd.vbeln and
vbkd.posnr = '000000'

left outer join vbpa as ship
on a.mandt = ship.mandt and
a.vbeln = ship.vbeln and
ship.posnr = '000000' and
ship.parvw = 'WE'

left outer join kna1 as kna1
on a.mandt = kna1.mandt and
ship.kunnr = kna1.kunnr

left outer join vbpa as merch
on a.mandt = merch.mandt and
a.vbeln = merch.vbeln and
b.posnr = merch.posnr and
merch.parvw = 'Z2'

left outer join kna1 as z2_kna1
on a.mandt = z2_kna1.mandt and
merch.mandt = z2_kna1.mandt and
merch.kunnr = z2_kna1.kunnr

left outer join kna1 as soldto
on a.mandt = soldto.mandt and
a.kunnr = soldto.kunnr

mike.pokrakaFor those of you wondering if you can use new and old methods - yes you can. You can only change them in Eclipse.
  method fill_dates.
data: lv_from type dats,
lv_to type dats,

lv_from = im_from.
lv_to = im_to.
* Explode BOM
auskz = abap_true
brems = abap_true
capid = 'PP01'
datuv = sy-datlo " Valid-From Date
mktls = abap_true
mehrs = abap_true
mtnrv = ls_stko-matnr
stlal = ls_stko-stlal
stlan = ls_stko-stlan
werks = ls_stko-werks
stb = lt_stb


So yes - a bit of a hybrid there.  Now we can take a peak at how I called them.
* CONVERT the SELECTION to where clause
DATA(lv_where) = cl_shdb_seltab=>combine_seltabs(
it_named_seltabs = VALUE #(
( name = 'VBELN' dref = REF #( s_vbeln[] ) )
( name = 'POSNR' dref = REF #( s_item[] ) )
iv_client_field = 'MANDT'

* Get contract details
iv_where = lv_where
iv_client = sy-mandt
et_log = DATA(lt_result) ).
CATCH cx_amdp_error INTO DATA(amdp_error).
cl_demo_output=>display( amdp_error->get_text( ) ).

OK, we've got our data - yes - not my total program.  But just snippets.  The fun part of my ALV - not the entire thing.
   gs_variant-report = sy-repid.
DATA: it_fieldcat TYPE lvc_t_fcat,
x_fieldcat TYPE lvc_s_fcat.
x_fieldcat-col_pos = 1.
x_fieldcat-seltext = 'APPLIED'.
x_fieldcat-fieldname = 'APPLIED'.
x_fieldcat-edit = abap_true.
x_fieldcat-checkbox = abap_true.
x_fieldcat-tabname = 'GT_SALES_DETAIL'.
APPEND x_fieldcat TO it_fieldcat.

 CALL METHOD grid1->set_table_for_first_display
i_bypassing_buffer = abap_true
i_structure_name = 'ZINGRD_CONTRACT'
is_print = gs_print
is_layout = gs_layout
it_toolbar_excluding = lt_exc
i_save = gv_save
is_variant = gs_variant
it_fieldcatalog = it_fieldcat
it_outtab = gt_sales_detail.
gv_check = abap_true.

CALL METHOD cl_gui_control=>set_focus EXPORTING control = grid1.

Last thing to do is to create the FIORI tile. Yes a lot different than normal.Security is based a lot on where you place your tile. You will want to download the Step by Step guide to do this.  And since it is amazing, I won't share the step by step here.

So my lovely FIORI report.  Yes, you can't see much of it.  Just the headings. Why? No company information.



That's my hybrid approach. Now a challenge for you.

First my code. I'm sure there are things I could have done better. Please share in the comments so someone else doesn't duplicate my interesting code thinking that's the best way of doing it.

Second this is how I'm learning? How about you? Are you using some of the SAP created procedures. If your comment is too long. A blog would be awesome! Are you using a hybrid approach or simply switching to doing things the new way? How about those of you that have never programmed the old way? How about you not on-premise? I have a lot of question and am loving reading the blogs when I get a chance.


Labels in this area