Month: July 2013

Home / 2013 / July (Page 2)

Project Management – Redesigning your baby

Well, lately I’ve been spending a lot of time on the rework of Rapier.  I’m sure you’ve noticed some of my posts in the past.  My original baby, Rapier, started as a crazy idea I came up with on a plane ride  home from my project in Boston.  Rapier started as a BSP application, then when I realized that BSP was a dying technology, I moved to ABAP Web Dynpro.  Now, I’m moving to add a ton of new functionality to the application that started it all.

Now, with all of these new ideas, it forces you to revisit what you originally designed, and come at it from a new perspective.  While that sounds obvious to any developer, it comes with a price that I’m not sure everyone realizes (I didn’t at the time).  When I first converted to Web Dynpro, I left most of the original structure intact, and focused on the web dynpro conversion and understanding that new coding.  Now that I’m full blown into version 2 functionality, I’m realizing there are a lot of pieces that could be designed better.

This post is to remind you that a simply adding new functionality comes with a lot of additional work.  For example, I’m looking at adding a new product designed around the field service engineer.  There is a lot of shared functionality between the 2 products.  So that required me to reevaluate all of my tables and classes, so they could easily shared.  Suddenly, this meant that all of my tables, classes, etc. needed to be created under a new shared namespace.  All of those items then needed to be swapped out of the existing code, etc.  Get the picture?  simply letting my code be reused, caused a huge chain reaction that took almost a week to reconcile.  And all of this wasn’t changing any functionality.  Just renaming things.

So, the word of advise for today is to remember that when you redesign, add plenty of time to your schedule.  If you choose to do it right, it’s gonna take longer than expected.  It’s worth it in the long run, but everything comes with a price.

 

Web Dynpro – Testing a Dynamic Table

Now, since I always learn things the hard way, and if you’ve been reading my posts for any length of time, you’ll know that I can be a bonehead when it comes to things…  but I’m too stubborn to give up (hence why I’m writing this post.  ha ha ha).  Anyway, my latest discovery was in the testing of my new dynamic table.  I really needed a table with some editable fields, but in the creation of my table, the context node was empty.  So the table was being created, but there were no lines in the table.  Well, maybe it was the lack of sleep, but my brain was moving a little slow, so I didn’t grasp that the dynamic table was empty…  thus, impossible to see if there were any fields editable.

So, short story, you need to populate at least one row in the table, even if it’s empty.  Here’s an example:

* navigate from <CONTEXT> to <NOT_ITEM> via lead selection
lo_nd = wd_context->get_child_node( name = wd_this->wdctx_item ).
lo_nd->get_static_attributes_table( importing table = lt ).
IF lt IS INITIAL.
APPEND wa to lt.
lo_nd->bind_table( new_items = lt set_initial_elements = abap_true ).
ENDIF.

this simple addition, and suddenly I could see my editable fields in my dynamic table.  Probably obvious to a lot of folks, but yet another lesson learned in my never ending journey.

Thanks for reading.

 

ABAP – Web Dynpro Dynamic Table, again

Well, as it turns out, I didn’t figure out everything I needed for a dynamic table.  =)  The dynamic table code that I previously talked about works great, until you want to control the read only vs. editable aspects of the table.  I found a great way of creating a Dynamic Table in ABAP Web Dynpro that gives me the control that I needed to do allow for editing.

First things first, you need to create a context node and the attributes for to define the table.  You could do this dynamically, but I’m finding it’s cleaner to build it normally.  Either way, once it exists, here how to build the dynamic table.

*** create dynamic table for Notification – Items
cl_wd_table=>new_table(
exporting
id = ‘TB_TABLE’
bind_data_source = ‘CONTEXT_NODE’
visible_row_count = 5
read_only  = abap_false
receiving
control = l_table ).

*** build table columns
loop at <cols> into wa_config.
wa_cols = cl_wd_table_column=>new_table_column( ).

*For Dynamically creating Input Field
CASE type.
when ‘TEXT’ OR ‘TIME’ or ‘DATE’ or ‘DROPDOWN’.
CALL METHOD cl_wd_input_field=>new_input_field
EXPORTING
bind_value = lv_bind
id         = lv_id
state      = lv_state
read_only  = abap_false
on_enter   = ‘ON_ENTER’
RECEIVING
control    = lr_input.
wa_cols->set_table_cell_editor( lr_input ).
when ‘CHECK’.
CALL METHOD cl_wd_checkbox=>new_checkbox
EXPORTING
bind_checked = lv_bind
id           = lv_id
state        = lv_state
RECEIVING
control      = lr_check.
wa_cols->set_table_cell_editor( lr_check ).
ENDCASE.
ELSE.
CALL METHOD cl_wd_text_view=>new_text_view
EXPORTING
bind_text  = lv_bind
id         = lv_id
RECEIVING
control    = lr_textview.
wa_cols->set_table_cell_editor( lr_textview ).
ENDIF.

l_col_hdr = cl_wd_caption=>new_caption( ).
l_col_hdr->set_text( lv_col_text ).
wa_cols->set_header( l_col_hdr ).

l_table->add_column( wa_cols ).
endloop.

l_root ?= view->get_element( ‘TC_XXX’ ).
grid_data = cl_wd_grid_data=>new_grid_data( l_table ).
l_table->set_layout_data( grid_data ).
l_root->add_child( l_table ).
Now this code obviously won’t work out of the box, but you should be able to get the idea of how to use it.  If you have questions on this let me know and I can expand on the code provided.  Thanks for reading.

 

Variant Configuration – Set_Default

If you’ve ever had to use the SET_DEFAULT statement in variant configuration, you grasp just how cryptic the syntax can be.  That’s why I wanted to point out this little trick that you might not yet be aware of.  You can replace the SET_DEFAULT syntax with a nice little operator.  Take a look below to see for yourself.

Example of the old way to set a default:
TABLE TEST( INPUT1 = INPUT1,
OUTPUT1 = $SELF.CHAR ),
$SET_DEFAULT( $SELF, OUTPUT1, $SELF.CHAR)

With this:
TABLE TEST( INPUT1 = INPUT1,
OUTPUT1 ?= $SELF.OUTPUT1 )

It doesn’t have to be used in a table, but can be most anywhere you use the = statement.  So in my opinion, why would you ever use the cryptic SET_DEFAULT statement again =)

 

Variant Configuration – IS Invisible

Hello everyone, it’s funny, I’ve been doing a lot more Variant Configuration work lately, and it reminds me of all the fun tricks I’ve either heard about or have used in the past.  The most recent one I was reminded of was the new IS INVISIBLE syntax.  So, as a reminder:

Old method:  $SELF.SCREEN_DEP_INVISIBLE = ‘CHAR1’

Cool new Way:$SELF.CHAR1 IS INVISIBLE

Now, either method you still need a reference characteristic that is attached to SCREEN_DEP-INVISIBLE.

Benefits include no persistent data storage, where used checking, and syntax checking of characteristic name.  Why does this matter?  for example, the biggest issue with the old method in my mind is that you have to enter the characteristic into quotes?  this means, it’s just a text string, and if you spell it wrong, you don’t get an error, it just doesn’t work.  Using the IS INVISIBLE, it will give you a syntax error if you enter in the wrong name.  The same goes for conducting a where used of a characteristic, in the event you tried to rename it or remove it.  the IS INVISIBLE syntax will show you it’s been used there.

It’s also much cleaner.  Anyway, hope you enjoyed this tidbit.

 

Happy Independence Day

Just a quick wish to you for a safe and happy fourth of July.  I also hope you stop to remember exactly why we celebrate this holiday.  Our founding fathers worked very hard to provide us the freedom and liberty they so desperately wanted, yet didn’t have.  Now today, every day we lose more of that liberty and more of those freedoms in the name of “security”, “political correctness” or “entitlements”.

Today, remember all the things you love to do and be grateful that a couple hundred years ago, our founding fathers earned that for us.  And be vigilant, because Ben Franklin said it best:

“Those who would give up essential Liberty, to purchase a little temporary Safety, deserve neither Liberty nor Safety”

 

Variant Configuration – SSC Eclipse Editor

Well, I wanted to pass on my most recent and valuable discovery about the SSC Eclipse Editor.  That is prototyping a new model is so much easier in this editor.  Now, the VC purest in me still knows that at the end of the day, the VC rules must still be adhered to, and best practices in modeling don’t change.  But here’s the value of the SSC Eclipse Editor.

If you model like I do, you work best by just jumping in and starting to put things together.  Well, this is great up to the point of enter in master/transactional data.  If you know SAP, you know that deleting things, renaming things, or going in a whole new direction is a royal PITA once you create a sales orders or production orders, etc.  because at that point, you have to jump through a lot of hoops to do some renaming…

The SSC Eclipse Editor is not locked into the same issues.  Because it’s text based, you put everything together, do your initial testing, and if you don’t like the way something is working… or more commonly, you find out new information half way through your model, you can quickly adapt, change names, restructure tables etc.  With very little pain.

Now don’t get me wrong, you’ll still have these pains because at some point you need to connect the SSC Model to either ECC or CRM, once that happens, you’ll be back to the same pain, but when you prototype the model, it sure is nice (for me) to have that flexibility to change my design on the fly without a lot of headaches (in fact, something a simple find and replace everywhere gets me where I need to be).  This is certainly not possible in the standard ECC Variant Configuration…  Food for thought…

Thanks for reading,

 

ABAP – How to Spool SD Output Documents

Well, this is a continuation of my post from yesterday, so if you missed it, I talked about using the ABAP Web Dynpro Download element to display documents on your web application.  What I talked about yesterday was completely based on having a spool job to convert.  So…  today I’ll talk about how you can Spool SD Output Documents again and again, and easily retrieve them.

SUBMIT RSNAST00
WITH S_KAPPL = i_kappl
WITH S_OBJKY = i_objky
WITH S_KSCHL = i_kschl
WITH P_AGAIN = ‘X’
WITH P_SUFF2 = lv_suff2
AND RETURN.

You might already be familiar with the program RSNAST00, but who knew you could use it for this (I didn’t…  =>  ).  You’ll notice, it’s a pretty simple program.  You give the Output type, the document key, and you can even using define a special key field (SUFF2) that makes it easier to retrieve.

After you run the program, simply go to table TSP01 and enter in the enough criteria to pull out the spool. Then you simply assign this to a context element, and link it to your download element.  And by doing this it will give you another popup window in your favorite web browser showing your output.

Now for my shameless plug.  I’ve done this all in Rapier now (it’ll be released in version 2 this fall), but thanks to this technique, I’ve been able to output Order Confirmations, invoices, etc…  directly onto the customer website, so they pull their own documents anytime they want.  If you’re interested in seeing this in action, let me know and I’ll be happy to setup a demo to show you.  Rapier 2.0 is gonna be really cool.  I’ve been putting a lot of hours into this recently, so you’ll want to check it out.  And, remember, if you’re in the market and you buy now, you get the charter customer price, and the ability to influence functionality that will be officially released this fall.    Ok… commercial over… =)

Thanks for reading,

ABAP – Using Web Dynpro Download Element

One of my recent adventures was find a way to pull documents out of SAP, and display them within my web application.  This turned out to be rather challenging, but I learned some neat tricks about ABAP Web Dynpro along the way.  The Web Dynpro Download Element is one of my new favorites, once I figured out how I could use it.

Let’s set the stage.  You have a document withing SAP that you want to display to your web user.  The Web Dynpro Download Element works perfectly for this…  provided you can feed it the proper data.  What I figured out is that in order to make this work, you need to get your document into an XSTRING format.  I think this is a RAW string or something like that, but it’s not important.  What is important is how do you get it into the XSTRING format.  One of the cool tricks I found online was using the following function module:

CONVERT_OTFSPOOLJOB_2_PDF

This function will convert a spool job into the XSTRING format you need to output it.  Now, getting things into the spool can be another headache, so tomorrow I’ll talk about how to get your standard SD documents into the spool again so you can read them out of the Web Dynpro Download Element.

Thanks for reading,