ABAP Coding

Home / SAP / Archive by category "ABAP Coding" (Page 2)

ABAP Web Dynpro – File Download SNAFU

Well, I just spent the better part of 20 hours hacking out my latest issue.  In my Rapier web application, one of the cool features I provide is the ability to download an output document from SAP.  Say for example, a quotation or order confirmation.  Well, I was using some fancy trick that converts the spool to PDF, then using the UI Element File Download.  Everything was great in testing.  No problems.  Then a couple weeks ago, I started updating all my documentation.  I came to do a screen shot of this and it it came out in jiberish.  It happened that I was using Firefox.  I tried it, and it worked fine on Internet Explorer, but all the other browsers displayed the text, instead of the pdf…  WTF!!!

So I did my due diligence, and hunted Google long and hard, hoping for a clue.  Nothing jumped out at me.  So, I then applied the latest support packs to my system.  No change.  Then I thought, maybe the kernel needs an update…  no change…  crap.  That burned through a lot of hours in SGEN time, downloading files, system down time, etc…  all for nothing (well, not nothing, but not the result I wanted).

Finally, last night, I decided to look at the UI Element itself, and what I was mapping to it.  I turned out, I was mapping a blank value to MIME_TYPE.  Interestingly, IE was smart enough to recognize the PDF, but none of the other browsers were.  Since all my dev work was on IE, and much of my testing as well, I missed this little fact.  As soon as I added application/pdf to that field…  magically, it began working on all my browsers again.  Woohoo!!!

Now, I hope you can learn from me again… first off, test your WDP on multiple browsers, unless you know you’re only going to support one browser.  This can’t be done in a customer facing application.  Second, MIME_TYPE makes all the difference.  It explicitly tells the system how to render the file.  Don’t take it for granted.

Thanks for reading,

ABAP – Finding Icon Codes

I just picked up a new little trick.  Often when I’m programming, I like to pull in the standard SAP icons.  The problem is that it is always a hassle to find the 4 digit code that corresponds to the icon I want to use.  So I found this little trick online to simplify the process.

1. Go to transaction ICON to find the icon you wish to use.  It will have a full description, like ICON_ORDER for example.

2. Go to SE11, enter ICON into the Type Group.  Press Display

3.  Scroll through the list (or use Control-F) to find the icon code associated with the ICON_ORDER.

Pretty slick,  Thanks for reading,

ABAP – Changing SAP Data Type Descriptions

Well, completely by accident, a friend of mine taught me a cool new trick.  There is a standard way to change data type descriptions of standard SAP fields without doing any sort of core mods.  It’s all built right into transaction CMOD, and I never knew it was available.  I truly learn something new about SAP all the time.  So, here goes…  go to transaction CMOD, then use the following menu path:
Goto–>Text Enhancements–>Keywords–>Change

blog02-01

Next, select the data element you want to change the description.

blog02-02

I picked MVGR4 for an example.

blog02-03

Now update any descriptions you want to change.  Save it, and attach it to a transport.  You’re done.

Take a look at what happens in VA02 for this field now:

blog02-09

Pretty cool, and pretty easy.

Thanks for reading,

Netweaver Gateway – Service Implementation

I’m finally getting back to the Netweaver Gateway stuff.  This piece is the most powerful, and also the most complicated.  I struggled with this for a while, so it’s a good idea for me to explain it and make sure I don’t forget myself 🙂  I’m going to focus on the query implementation, but all of the options work the same way.

segw01-01

Open up the Service Implementation folder, then open the entity set you wish to map.

Create – Use this to create a new entry.
Delete – Use this to delete an entry
GetEntitySet(read) – use this to read back a single entry
GetEntitySet(query) – use this to read back an entire table.
Update – use this to update an existing entry.

Now, one of the things I’ve found is that for most of these entries, it really all does depend on your RFC that is being called.  For example, you could likely call Create or Update using the same RFC and it would work, as long as your RFC code was properly defined.

segw01-02

Now this screen shows you a completed mapping for the query operation.  Depending on your RFC and how you defined things previously, you can use the Propose Mapping button to fill in all of the fields for you.  Or, you can drag and drop from the right hand window.  Now, one of the things that I originally had issues with supplying the inputs for my RFC.  What I discovered, is that in Netweaver Gateway, you can have the same parameter show up multiple times, once as an input and once as an output.  All you need to do is point it to the correct field.  If you look above at the OrderNumber field, you’ll notice that it’s listed twice, once with an arrow pointing left (output) and one with an arrow pointing right (input).  If you look in the mapping field, you’ll notice that the input and output point to different fields.

Like everything, you must know your RFC to do this correctly.  Then, if you need to use the same field again, you must use the insert, select the field from the list, press the arrow until it points to the right, and finally select the mapping field from the RFC that should be the import.

At this point, if you have the gateway configured, you are ready to test and connect it to your mobile app 🙂

Thanks for reading,

Web Dynpro – Activating Services

It occurred to me, this might be rudimentary to most anyone that’s been doing BSP’s or Web Dynpro, for the newbies out there, this might not be obvious.  Since I just put a new Web Dynpro App into my test system, I thought this would be a great chance to document the process and share it with y’all 🙂

First off, go to transaction SICF.  Depending on your version of SAP this might look a little different (this is ERP 6.0).  But you’ll be able to see what I’m talking about.

blog02-01

Normally, when you go to use Web Dynpro for the first time, there are a bunch of services that need to be activated.  Your web browser will tell you exactly what they are.  You either navigate the menus manually, or if you enter in the Service Name, SAP will take you directly to the one you want to activate (I like option 2).

blog02-02

Here’s an example service.  You’ll notice that it’s grayed out when it is inactive.  So go ahead and right click on the service.

blog02-03

Select the Activate Service.

blog02-04ow

Now, depending on what you select to activate, if there are other services below the one you selected, you can choose Yes with the hierarchy to activate the service and everything below it.  Or you if select Yes, it will just activate that one service.

That’s it.  Now, keep in mind, there are a lot of other things within the service itself that can be updated, but for now, this is my little tidbit.

Thanks for reading,

Netweaver Gateway – Creating the Entityset

In the last post, we created the entity for our service.  One of the next pieces is the entityset.  This is a really easy piece, but still required in order to complete the service.  We go back to SEGW.

segw2-01

next…

segw2-02

Name your entityset, and pick the entity you want to link to…  Now you’re ready for the next step…  we’ll get there in a future post.

Thanks for reading,

Netweaver Gateway – Creating a Service from RFC

Well, picking up where we left off on Netweaver Gateway.  Last time we created the project, now it’s time to actually create the service.  In my example, I have already created an RFC to feed the information I need to the service.  So, here’s how to do it.  Return to transaction SEGW.

segw03

next…

segw04

Here, you need to give it an entity name.  This is what you’ll be using going forward.  Select the type as Remote function call, and then list the name of the function.

segw05

Now we get to the magic.  The RFC has now pulled in all the inputs and outputs from the function.  Now, you check the fields you want to make part of your “entity”.  The entity will contain the fields that you plan to extract or feed into your service.

segw06

After you select the fields you want, you must define at least one key.

segw07

Now, you have the entity.  With this piece, you’re ready to start doing something with the data.

In a future post, I’ll talk about the next steps for the service.

Thanks for reading,

ABAP – Web Dynpro – Dynamic Cell Variants

Well, in my continued adventure, I found a new component in web dynpro call a cell variant.  The basic idea behind this is that you can change what kind of cell is within a table.  For example, sometimes you may want a field editable, based on the contents, and other times it should just be a text view.  Well, I had something similar in my latest web dynpro experiment.  I needed to do  dynamic cell variants.  By this, I wanted to add the cell variant to an ALV table, so I couldn’t just manually add it to the column.  Well, thanks a cool document I found, I was able to pull this off…  mostly.

http://www.sdn.sap.com/irj/scn/go/portal/prtroot/docs/library/uuid/f0e7461d-5e6c-2b10-dda9-9e99df4d136d?overridelayout=true

Now, I use the term mostly, because of course, I tried branch out on my own.  It’s probably easiest to explain with a little code and my example.  First, I had a column in my ALV table that either listed a single serial number, or should provide a link to another window to show all the serial numbers associated with the document.  This is perfect for the cell variant.  I set it up so that

Here’s where I started, and syntactically, it would fine:

data: l_cv_ser TYPE REF TO cl_salv_wd_cv_standard,
lr_link_ser TYPE REF TO cl_salv_wd_uie_link_to_action,
l_col TYPE REF TO cl_salv_wd_column.

create OBJECT lr_link_ser.
lr_link_ser->set_text_fieldname( EXPORTING value = ‘SERNR’ ).
* create cell variant
create OBJECT l_cv_ser.
  l_cv_ser->set_key( VALUE = ‘MULTIPLE’ ).
* add link to action editor
l_cv_ser->set_editor( lr_link_ser ).
* Get column
l_col = lv_value->if_salv_wd_column_settings~get_column( ‘SERNR’ ).
* add cell variant to column
l_col->add_cell_variant( r_cell_variant = l_cv_ser ).
* assign attribute
  l_col->set_sel_cell_variant_fieldname( ‘SERNR’ ).

Now, if you pay close attention to the bold lines, these were my problem.  See, the data in the column might be MULTIPLE, or it be 1, 2, 3, 800034234, or any serial number.  So in my initial testing, it was all multiple, so it worked great.  suddenly I was getting a short dump when it hit a cell with a value other than MULTIPLE.  It finally hit me…  with a cell variant, you either need to define an editor for each value in the column?  or you need to make a new column with only 1 value or blank.  i ended up going down the second path.

data: l_cv_ser TYPE REF TO cl_salv_wd_cv_standard,
lr_link_ser TYPE REF TO cl_salv_wd_uie_link_to_action,
l_col TYPE REF TO cl_salv_wd_column.

create OBJECT lr_link_ser.
lr_link_ser->set_text_fieldname( EXPORTING value = ‘SERNR’ ).
* create cell variant
create OBJECT l_cv_ser.
l_cv_ser->set_key( VALUE = ‘X’ ).
* add link to action editor
l_cv_ser->set_editor( lr_link_ser ).
* Get column
l_col = lv_value->if_salv_wd_column_settings~get_column( ‘SERNR’ ).
* add cell variant to column
l_col->add_cell_variant( r_cell_variant = l_cv_ser ).
* assign attribute
l_col->set_sel_cell_variant_fieldname( ‘CV_SER’ ).
lv_value->if_salv_wd_column_settings~delete_column( id = ‘CV_SER’ ).

I hope this sheds some light on the cell variant.  it really is a pretty slick tool.
Thanks for reading,

Netweaver Gateway – Creating the Project

Well, since I recently spoke about using the gateway client, I figured I should talk about creating the service to use the gateway client.  The first step in this process is creating the project.  Like so many things, you must start small in order to build…  so let’s the netweaver gateway project and get this party started.

First, go to transaction SEGW

segw01

Press Create.

segw02

Now, put in the project name, description and package.  For me, I do everything within my own namespace, so notice how both the project and the package must start with the namespace.  Press the green check and you have your project.

segw021

In future posts, I’ll walk you through the next steps.

Thanks for reading,

Netweaver Gateway – Using the Gateway Client

Well, I just found a great document out there in SCN for how to use the Gateway Client.  I was kind of struggling with this, but after finding this trick, it makes it a lot easier.

http://scn.sap.com/docs/DOC-47626

There really isn’t a lot to say about this.  The author did a great job of making it simple.  I’ll be doing more posts in the near future about NW gateway, since I’ve recently learned how to make an RFC and create a service for it in the Gateway.  Don’t want to forget what I learned, and maybe you will find it valuable as well.

Thanks for reading,